Merge lp:~phablet-team/media-hub/fix-1538703-take2 into lp:media-hub
- fix-1538703-take2
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Alfonso Sanchez-Beato |
Approved revision: | 200 |
Merged at revision: | 180 |
Proposed branch: | lp:~phablet-team/media-hub/fix-1538703-take2 |
Merge into: | lp:media-hub |
Diff against target: |
702 lines (+205/-95) 16 files modified
CMakeLists.txt (+2/-2) debian/changelog (+7/-0) debian/libmedia-hub-doc.install (+1/-1) doc/CMakeLists.txt (+2/-2) include/core/media/service.h (+0/-3) src/core/media/hashed_keyed_player_store.cpp (+1/-0) src/core/media/mpris/service.h (+0/-1) src/core/media/player_configuration.h (+3/-0) src/core/media/player_implementation.cpp (+86/-6) src/core/media/player_skeleton.h (+2/-0) src/core/media/service_implementation.cpp (+5/-10) src/core/media/service_implementation.h (+0/-1) src/core/media/service_skeleton.cpp (+94/-59) src/core/media/service_skeleton.h (+2/-0) src/core/media/service_stub.cpp (+0/-9) src/core/media/service_stub.h (+0/-1) |
To merge this branch: | bzr merge lp:~phablet-team/media-hub/fix-1538703-take2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alfonso Sanchez-Beato | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Konrad Zapałowicz (community) | code | Approve | |
Review via email: mp+292584@code.launchpad.net |
Commit message
A rewrite of how the current player is set which is what the MPRIS control interface actively uses.
Description of the change
A rewrite of how the current player is set which is what the MPRIS control interface actively uses.
Konrad Zapałowicz (kzapalowicz) wrote : | # |
Jim Hodapp (jhodapp) : | # |
- 199. By Jim Hodapp
-
Make sure to check if player_service is not nullptr before using it in is_current_player()
Konrad Zapałowicz (kzapalowicz) wrote : | # |
LGTM
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:198
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:199
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
Looks good, just curious why you had to remove the version dependency for libdbus-cpp-dev ?
- 200. By Jim Hodapp
-
Restore the libdbus-cpp-dev min version check
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
LGTM
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2016-04-04 18:54:45 +0000 | |||
3 | +++ CMakeLists.txt 2016-05-04 13:11:44 +0000 | |||
4 | @@ -20,11 +20,11 @@ | |||
5 | 20 | # we define the version to be 5.0.0 | 20 | # we define the version to be 5.0.0 |
6 | 21 | if (${DISTRO_CODENAME} STREQUAL "vivid") | 21 | if (${DISTRO_CODENAME} STREQUAL "vivid") |
7 | 22 | set(UBUNTU_MEDIA_HUB_VERSION_MAJOR 4) | 22 | set(UBUNTU_MEDIA_HUB_VERSION_MAJOR 4) |
9 | 23 | set(UBUNTU_MEDIA_HUB_VERSION_MINOR 1) | 23 | set(UBUNTU_MEDIA_HUB_VERSION_MINOR 2) |
10 | 24 | set(UBUNTU_MEDIA_HUB_VERSION_PATCH 0) | 24 | set(UBUNTU_MEDIA_HUB_VERSION_PATCH 0) |
11 | 25 | else () | 25 | else () |
12 | 26 | set(UBUNTU_MEDIA_HUB_VERSION_MAJOR 5) | 26 | set(UBUNTU_MEDIA_HUB_VERSION_MAJOR 5) |
14 | 27 | set(UBUNTU_MEDIA_HUB_VERSION_MINOR 0) | 27 | set(UBUNTU_MEDIA_HUB_VERSION_MINOR 1) |
15 | 28 | set(UBUNTU_MEDIA_HUB_VERSION_PATCH 0) | 28 | set(UBUNTU_MEDIA_HUB_VERSION_PATCH 0) |
16 | 29 | endif() | 29 | endif() |
17 | 30 | endif() | 30 | endif() |
18 | 31 | 31 | ||
19 | === modified file 'debian/changelog' | |||
20 | --- debian/changelog 2016-04-07 02:00:40 +0000 | |||
21 | +++ debian/changelog 2016-05-04 13:11:44 +0000 | |||
22 | @@ -1,3 +1,10 @@ | |||
23 | 1 | media-hub (4.2.0+16.04.20160407.1-0ubuntu1) UNRELEASED; urgency=medium | ||
24 | 2 | |||
25 | 3 | * Improve the MPRIS player control interface so that it only | ||
26 | 4 | controls the last Player instance that called play(). | ||
27 | 5 | |||
28 | 6 | -- Jim Hodapp <jim.hodapp@canonical.com> Tue, 03 May 2016 11:32:14 -0400 | ||
29 | 7 | |||
30 | 1 | media-hub (4.1.0+16.04.20160407.1-0ubuntu1) xenial; urgency=medium | 8 | media-hub (4.1.0+16.04.20160407.1-0ubuntu1) xenial; urgency=medium |
31 | 2 | 9 | ||
32 | 3 | * Add a proper logger to media-hub that includes traces, timestamps | 10 | * Add a proper logger to media-hub that includes traces, timestamps |
33 | 4 | 11 | ||
34 | === modified file 'debian/libmedia-hub-doc.install' | |||
35 | --- debian/libmedia-hub-doc.install 2014-03-06 22:51:51 +0000 | |||
36 | +++ debian/libmedia-hub-doc.install 2016-05-04 13:11:44 +0000 | |||
37 | @@ -1,1 +1,1 @@ | |||
39 | 1 | usr/share/doc/music-hub/html | 1 | usr/share/doc/media-hub/html |
40 | 2 | 2 | ||
41 | === modified file 'doc/CMakeLists.txt' | |||
42 | --- doc/CMakeLists.txt 2013-08-14 18:05:23 +0000 | |||
43 | +++ doc/CMakeLists.txt 2016-05-04 13:11:44 +0000 | |||
44 | @@ -26,5 +26,5 @@ | |||
45 | 26 | COMMENT "Generating API documentation with Doxygen" VERBATIM) | 26 | COMMENT "Generating API documentation with Doxygen" VERBATIM) |
46 | 27 | install( | 27 | install( |
47 | 28 | DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html | 28 | DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html |
48 | 29 | DESTINATION share/doc/music-hub) | ||
49 | 30 | endif(DOXYGEN_FOUND) | ||
50 | 31 | \ No newline at end of file | 29 | \ No newline at end of file |
51 | 30 | DESTINATION share/doc/media-hub) | ||
52 | 31 | endif(DOXYGEN_FOUND) | ||
53 | 32 | 32 | ||
54 | === modified file 'include/core/media/service.h' | |||
55 | --- include/core/media/service.h 2015-09-08 20:03:56 +0000 | |||
56 | +++ include/core/media/service.h 2016-05-04 13:11:44 +0000 | |||
57 | @@ -60,9 +60,6 @@ | |||
58 | 60 | /** @brief Resumes a fixed-name session directly by player key. */ | 60 | /** @brief Resumes a fixed-name session directly by player key. */ |
59 | 61 | virtual std::shared_ptr<Player> resume_session(Player::PlayerKey) = 0; | 61 | virtual std::shared_ptr<Player> resume_session(Player::PlayerKey) = 0; |
60 | 62 | 62 | ||
61 | 63 | /** @brief Sets the current player that the MPRIS interface will control */ | ||
62 | 64 | virtual void set_current_player(Player::PlayerKey) = 0; | ||
63 | 65 | |||
64 | 66 | /** @brief Pauses sessions other than the supplied one. */ | 63 | /** @brief Pauses sessions other than the supplied one. */ |
65 | 67 | virtual void pause_other_sessions(Player::PlayerKey) = 0; | 64 | virtual void pause_other_sessions(Player::PlayerKey) = 0; |
66 | 68 | 65 | ||
67 | 69 | 66 | ||
68 | === modified file 'src/core/media/hashed_keyed_player_store.cpp' | |||
69 | --- src/core/media/hashed_keyed_player_store.cpp 2016-03-07 14:51:01 +0000 | |||
70 | +++ src/core/media/hashed_keyed_player_store.cpp 2016-05-04 13:11:44 +0000 | |||
71 | @@ -64,6 +64,7 @@ | |||
72 | 64 | void media::HashedKeyedPlayerStore::remove_player_for_key(const media::Player::PlayerKey& key) | 64 | void media::HashedKeyedPlayerStore::remove_player_for_key(const media::Player::PlayerKey& key) |
73 | 65 | { | 65 | { |
74 | 66 | std::lock_guard<std::recursive_mutex> lg{guard}; | 66 | std::lock_guard<std::recursive_mutex> lg{guard}; |
75 | 67 | |||
76 | 67 | auto it = map.find(key); | 68 | auto it = map.find(key); |
77 | 68 | if (it != map.end()) | 69 | if (it != map.end()) |
78 | 69 | { | 70 | { |
79 | 70 | 71 | ||
80 | === modified file 'src/core/media/mpris/service.h' | |||
81 | --- src/core/media/mpris/service.h 2016-01-04 08:30:35 +0000 | |||
82 | +++ src/core/media/mpris/service.h 2016-05-04 13:11:44 +0000 | |||
83 | @@ -127,7 +127,6 @@ | |||
84 | 127 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(DestroySession, Service, 1000) | 127 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(DestroySession, Service, 1000) |
85 | 128 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(CreateFixedSession, Service, 1000) | 128 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(CreateFixedSession, Service, 1000) |
86 | 129 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(ResumeSession, Service, 1000) | 129 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(ResumeSession, Service, 1000) |
87 | 130 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(SetCurrentPlayer, Service, 1000) | ||
88 | 131 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(PauseOtherSessions, Service, 1000) | 130 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(PauseOtherSessions, Service, 1000) |
89 | 132 | }; | 131 | }; |
90 | 133 | } | 132 | } |
91 | 134 | 133 | ||
92 | === modified file 'src/core/media/player_configuration.h' | |||
93 | --- src/core/media/player_configuration.h 2015-04-17 16:44:30 +0000 | |||
94 | +++ src/core/media/player_configuration.h 2016-05-04 13:11:44 +0000 | |||
95 | @@ -19,6 +19,7 @@ | |||
96 | 19 | #define CORE_UBUNTU_MEDIA_PLAYER_CLIENT_CONFIGURATION_H_ | 19 | #define CORE_UBUNTU_MEDIA_PLAYER_CLIENT_CONFIGURATION_H_ |
97 | 20 | 20 | ||
98 | 21 | #include <core/media/player.h> | 21 | #include <core/media/player.h> |
99 | 22 | #include <core/media/service.h> | ||
100 | 22 | 23 | ||
101 | 23 | #include <core/dbus/bus.h> | 24 | #include <core/dbus/bus.h> |
102 | 24 | #include <core/dbus/object.h> | 25 | #include <core/dbus/object.h> |
103 | @@ -35,6 +36,8 @@ | |||
104 | 35 | std::shared_ptr<core::dbus::Service> service; | 36 | std::shared_ptr<core::dbus::Service> service; |
105 | 36 | // The actual session object representing a player instance. | 37 | // The actual session object representing a player instance. |
106 | 37 | std::shared_ptr<core::dbus::Object> session; | 38 | std::shared_ptr<core::dbus::Object> session; |
107 | 39 | // The Service instance that manages Player instances | ||
108 | 40 | core::ubuntu::media::Service* player_service; | ||
109 | 38 | }; | 41 | }; |
110 | 39 | 42 | ||
111 | 40 | #endif // CORE_UBUNTU_MEDIA_PLAYER_CLIENT_CONFIGURATION_H_ | 43 | #endif // CORE_UBUNTU_MEDIA_PLAYER_CLIENT_CONFIGURATION_H_ |
112 | 41 | 44 | ||
113 | === modified file 'src/core/media/player_implementation.cpp' | |||
114 | --- src/core/media/player_implementation.cpp 2016-04-06 15:28:29 +0000 | |||
115 | +++ src/core/media/player_implementation.cpp 2016-05-04 13:11:44 +0000 | |||
116 | @@ -17,7 +17,10 @@ | |||
117 | 17 | * Jim Hodapp <jim.hodapp@canonical.com> | 17 | * Jim Hodapp <jim.hodapp@canonical.com> |
118 | 18 | */ | 18 | */ |
119 | 19 | 19 | ||
120 | 20 | #include <core/media/service.h> | ||
121 | 21 | |||
122 | 20 | #include "player_implementation.h" | 22 | #include "player_implementation.h" |
123 | 23 | #include "service_skeleton.h" | ||
124 | 21 | #include "util/timeout.h" | 24 | #include "util/timeout.h" |
125 | 22 | 25 | ||
126 | 23 | #include <unistd.h> | 26 | #include <unistd.h> |
127 | @@ -301,14 +304,14 @@ | |||
128 | 301 | } | 304 | } |
129 | 302 | } | 305 | } |
130 | 303 | 306 | ||
132 | 304 | void update_mpris_properties(void) | 307 | void update_mpris_properties() |
133 | 305 | { | 308 | { |
135 | 306 | bool has_previous = track_list->has_previous() | 309 | const bool has_previous = track_list->has_previous() |
136 | 307 | or parent->Parent::loop_status() != Player::LoopStatus::none; | 310 | or parent->Parent::loop_status() != Player::LoopStatus::none; |
138 | 308 | bool has_next = track_list->has_next() | 311 | const bool has_next = track_list->has_next() |
139 | 309 | or parent->Parent::loop_status() != Player::LoopStatus::none; | 312 | or parent->Parent::loop_status() != Player::LoopStatus::none; |
142 | 310 | auto n_tracks = track_list->tracks()->size(); | 313 | const auto n_tracks = track_list->tracks()->size(); |
143 | 311 | bool has_tracks = (n_tracks > 0) ? true : false; | 314 | const bool has_tracks = (n_tracks > 0) ? true : false; |
144 | 312 | 315 | ||
145 | 313 | MH_INFO("Updating MPRIS TrackList properties:"); | 316 | MH_INFO("Updating MPRIS TrackList properties:"); |
146 | 314 | MH_INFO("\tTracks: %d", n_tracks); | 317 | MH_INFO("\tTracks: %d", n_tracks); |
147 | @@ -322,6 +325,58 @@ | |||
148 | 322 | parent->can_go_next().set(has_next); | 325 | parent->can_go_next().set(has_next); |
149 | 323 | } | 326 | } |
150 | 324 | 327 | ||
151 | 328 | bool pause_other_players(media::Player::PlayerKey key) | ||
152 | 329 | { | ||
153 | 330 | if (not config.parent.player_service) | ||
154 | 331 | return false; | ||
155 | 332 | |||
156 | 333 | media::ServiceSkeleton* skel { | ||
157 | 334 | reinterpret_cast<media::ServiceSkeleton*>(config.parent.player_service) | ||
158 | 335 | }; | ||
159 | 336 | skel->pause_other_sessions(key); | ||
160 | 337 | return true; | ||
161 | 338 | } | ||
162 | 339 | |||
163 | 340 | bool update_current_player(media::Player::PlayerKey key) | ||
164 | 341 | { | ||
165 | 342 | if (not config.parent.player_service) | ||
166 | 343 | return false; | ||
167 | 344 | |||
168 | 345 | media::ServiceSkeleton* skel { | ||
169 | 346 | reinterpret_cast<media::ServiceSkeleton*>(config.parent.player_service) | ||
170 | 347 | }; | ||
171 | 348 | skel->set_current_player(key); | ||
172 | 349 | return true; | ||
173 | 350 | } | ||
174 | 351 | |||
175 | 352 | bool is_current_player() const | ||
176 | 353 | { | ||
177 | 354 | if (not config.parent.player_service) | ||
178 | 355 | return false; | ||
179 | 356 | |||
180 | 357 | media::ServiceSkeleton* skel { | ||
181 | 358 | reinterpret_cast<media::ServiceSkeleton*>(config.parent.player_service) | ||
182 | 359 | }; | ||
183 | 360 | return skel->is_current_player(parent->key()); | ||
184 | 361 | } | ||
185 | 362 | |||
186 | 363 | bool is_multimedia_role() const | ||
187 | 364 | { | ||
188 | 365 | return parent->audio_stream_role() == media::Player::AudioStreamRole::multimedia; | ||
189 | 366 | } | ||
190 | 367 | |||
191 | 368 | bool reset_current_player() | ||
192 | 369 | { | ||
193 | 370 | if (not config.parent.player_service) | ||
194 | 371 | return false; | ||
195 | 372 | |||
196 | 373 | media::ServiceSkeleton* skel { | ||
197 | 374 | reinterpret_cast<media::ServiceSkeleton*>(config.parent.player_service) | ||
198 | 375 | }; | ||
199 | 376 | skel->reset_current_player(); | ||
200 | 377 | return true; | ||
201 | 378 | } | ||
202 | 379 | |||
203 | 325 | // Our link back to our parent. | 380 | // Our link back to our parent. |
204 | 326 | media::PlayerImplementation<Parent>* parent; | 381 | media::PlayerImplementation<Parent>* parent; |
205 | 327 | // We just store the parameters passed on construction. | 382 | // We just store the parameters passed on construction. |
206 | @@ -478,6 +533,16 @@ | |||
207 | 478 | // are cleared | 533 | // are cleared |
208 | 479 | d->clear_wakelocks(); | 534 | d->clear_wakelocks(); |
209 | 480 | d->track_list->reset(); | 535 | d->track_list->reset(); |
210 | 536 | |||
211 | 537 | // This is not a fatal error but merely a warning that should | ||
212 | 538 | // be logged | ||
213 | 539 | if (d->is_multimedia_role() and d->is_current_player()) | ||
214 | 540 | { | ||
215 | 541 | MH_DEBUG("==== Resetting current player"); | ||
216 | 542 | if (not d->reset_current_player()) | ||
217 | 543 | MH_WARNING("Failed to reset current player"); | ||
218 | 544 | } | ||
219 | 545 | |||
220 | 481 | // And tell the outside world that the client has gone away | 546 | // And tell the outside world that the client has gone away |
221 | 482 | d->on_client_disconnected(); | 547 | d->on_client_disconnected(); |
222 | 483 | }); | 548 | }); |
223 | @@ -687,7 +752,8 @@ | |||
224 | 687 | d->track_list->reset(); | 752 | d->track_list->reset(); |
225 | 688 | 753 | ||
226 | 689 | // If empty uri, give the same meaning as QMediaPlayer::setMedia("") | 754 | // If empty uri, give the same meaning as QMediaPlayer::setMedia("") |
228 | 690 | if (uri.empty()) { | 755 | if (uri.empty()) |
229 | 756 | { | ||
230 | 691 | MH_DEBUG("Resetting current media"); | 757 | MH_DEBUG("Resetting current media"); |
231 | 692 | return true; | 758 | return true; |
232 | 693 | } | 759 | } |
233 | @@ -697,6 +763,7 @@ | |||
234 | 697 | // Don't set new track as the current track to play since we're calling open_resource_for_uri above | 763 | // Don't set new track as the current track to play since we're calling open_resource_for_uri above |
235 | 698 | static const bool make_current = false; | 764 | static const bool make_current = false; |
236 | 699 | d->track_list->add_track_with_uri_at(uri, media::TrackList::after_empty_track(), make_current); | 765 | d->track_list->add_track_with_uri_at(uri, media::TrackList::after_empty_track(), make_current); |
237 | 766 | |||
238 | 700 | return ret; | 767 | return ret; |
239 | 701 | } | 768 | } |
240 | 702 | 769 | ||
241 | @@ -722,6 +789,19 @@ | |||
242 | 722 | void media::PlayerImplementation<Parent>::play() | 789 | void media::PlayerImplementation<Parent>::play() |
243 | 723 | { | 790 | { |
244 | 724 | MH_TRACE(""); | 791 | MH_TRACE(""); |
245 | 792 | if (d->is_multimedia_role()) | ||
246 | 793 | { | ||
247 | 794 | MH_DEBUG("==== Pausing all other multimedia player sessions"); | ||
248 | 795 | if (not d->pause_other_players(d->config.key)) | ||
249 | 796 | MH_WARNING("Failed to pause other player sessions"); | ||
250 | 797 | |||
251 | 798 | MH_DEBUG("==== Updating the current player"); | ||
252 | 799 | // This player will begin playing so make sure it's the current player. If | ||
253 | 800 | // this operation fails it is not a fatal condition but should be logged | ||
254 | 801 | if (not d->update_current_player(d->config.key)) | ||
255 | 802 | MH_WARNING("Failed to update current player"); | ||
256 | 803 | } | ||
257 | 804 | |||
258 | 725 | d->engine->play(); | 805 | d->engine->play(); |
259 | 726 | } | 806 | } |
260 | 727 | 807 | ||
261 | 728 | 808 | ||
262 | === modified file 'src/core/media/player_skeleton.h' | |||
263 | --- src/core/media/player_skeleton.h 2015-04-17 15:13:56 +0000 | |||
264 | +++ src/core/media/player_skeleton.h 2016-05-04 13:11:44 +0000 | |||
265 | @@ -57,6 +57,8 @@ | |||
266 | 57 | std::shared_ptr<core::dbus::Service> service; | 57 | std::shared_ptr<core::dbus::Service> service; |
267 | 58 | // The session object that we want to expose the skeleton upon. | 58 | // The session object that we want to expose the skeleton upon. |
268 | 59 | std::shared_ptr<core::dbus::Object> session; | 59 | std::shared_ptr<core::dbus::Object> session; |
269 | 60 | // The Service instance that manages Player instances | ||
270 | 61 | core::ubuntu::media::Service* player_service; | ||
271 | 60 | // Our functional dependencies. | 62 | // Our functional dependencies. |
272 | 61 | apparmor::ubuntu::RequestContextResolver::Ptr request_context_resolver; | 63 | apparmor::ubuntu::RequestContextResolver::Ptr request_context_resolver; |
273 | 62 | apparmor::ubuntu::RequestAuthenticator::Ptr request_authenticator; | 64 | apparmor::ubuntu::RequestAuthenticator::Ptr request_authenticator; |
274 | 63 | 65 | ||
275 | === modified file 'src/core/media/service_implementation.cpp' | |||
276 | --- src/core/media/service_implementation.cpp 2016-04-05 19:27:50 +0000 | |||
277 | +++ src/core/media/service_implementation.cpp 2016-05-04 13:11:44 +0000 | |||
278 | @@ -186,11 +186,13 @@ | |||
279 | 186 | auto player = std::make_shared<media::PlayerImplementation<media::PlayerSkeleton>> | 186 | auto player = std::make_shared<media::PlayerImplementation<media::PlayerSkeleton>> |
280 | 187 | (media::PlayerImplementation<media::PlayerSkeleton>::Configuration | 187 | (media::PlayerImplementation<media::PlayerSkeleton>::Configuration |
281 | 188 | { | 188 | { |
282 | 189 | // Derive a PlayerSkeleton-specific Configuration based on Player::Configuration | ||
283 | 189 | media::PlayerSkeleton::Configuration | 190 | media::PlayerSkeleton::Configuration |
284 | 190 | { | 191 | { |
285 | 191 | conf.bus, | 192 | conf.bus, |
286 | 192 | conf.service, | 193 | conf.service, |
287 | 193 | conf.session, | 194 | conf.session, |
288 | 195 | conf.player_service, | ||
289 | 194 | d->request_context_resolver, | 196 | d->request_context_resolver, |
290 | 195 | d->request_authenticator | 197 | d->request_authenticator |
291 | 196 | }, | 198 | }, |
292 | @@ -258,11 +260,6 @@ | |||
293 | 258 | return std::shared_ptr<media::Player>(); | 260 | return std::shared_ptr<media::Player>(); |
294 | 259 | } | 261 | } |
295 | 260 | 262 | ||
296 | 261 | void media::ServiceImplementation::set_current_player(Player::PlayerKey) | ||
297 | 262 | { | ||
298 | 263 | // no impl | ||
299 | 264 | } | ||
300 | 265 | |||
301 | 266 | void media::ServiceImplementation::pause_other_sessions(media::Player::PlayerKey key) | 263 | void media::ServiceImplementation::pause_other_sessions(media::Player::PlayerKey key) |
302 | 267 | { | 264 | { |
303 | 268 | MH_TRACE(""); | 265 | MH_TRACE(""); |
304 | @@ -276,11 +273,9 @@ | |||
305 | 276 | const std::shared_ptr<media::Player> current_player = | 273 | const std::shared_ptr<media::Player> current_player = |
306 | 277 | d->configuration.player_store->player_for_key(key); | 274 | d->configuration.player_store->player_for_key(key); |
307 | 278 | 275 | ||
313 | 279 | // We immediately make the player known as new current player. | 276 | d->configuration.player_store->enumerate_players([current_player, key] |
314 | 280 | if (current_player->audio_stream_role() == media::Player::multimedia) | 277 | (const media::Player::PlayerKey& other_key, |
315 | 281 | d->configuration.player_store->set_current_player_for_key(key); | 278 | const std::shared_ptr<media::Player>& other_player) |
311 | 282 | |||
312 | 283 | d->configuration.player_store->enumerate_players([current_player, key](const media::Player::PlayerKey& other_key, const std::shared_ptr<media::Player>& other_player) | ||
316 | 284 | { | 279 | { |
317 | 285 | // Only pause a Player if all of the following criteria are met: | 280 | // Only pause a Player if all of the following criteria are met: |
318 | 286 | // 1) currently playing | 281 | // 1) currently playing |
319 | 287 | 282 | ||
320 | === modified file 'src/core/media/service_implementation.h' | |||
321 | --- src/core/media/service_implementation.h 2015-09-08 20:03:56 +0000 | |||
322 | +++ src/core/media/service_implementation.h 2016-05-04 13:11:44 +0000 | |||
323 | @@ -49,7 +49,6 @@ | |||
324 | 49 | void destroy_session(const std::string&, const Player::Configuration&); | 49 | void destroy_session(const std::string&, const Player::Configuration&); |
325 | 50 | std::shared_ptr<Player> create_fixed_session(const std::string& name, const Player::Configuration&); | 50 | std::shared_ptr<Player> create_fixed_session(const std::string& name, const Player::Configuration&); |
326 | 51 | std::shared_ptr<Player> resume_session(Player::PlayerKey key); | 51 | std::shared_ptr<Player> resume_session(Player::PlayerKey key); |
327 | 52 | void set_current_player(Player::PlayerKey key); | ||
328 | 53 | void pause_other_sessions(Player::PlayerKey key); | 52 | void pause_other_sessions(Player::PlayerKey key); |
329 | 54 | 53 | ||
330 | 55 | private: | 54 | private: |
331 | 56 | 55 | ||
332 | === modified file 'src/core/media/service_skeleton.cpp' | |||
333 | --- src/core/media/service_skeleton.cpp 2016-04-06 15:28:29 +0000 | |||
334 | +++ src/core/media/service_skeleton.cpp 2016-05-04 13:11:44 +0000 | |||
335 | @@ -63,7 +63,7 @@ | |||
336 | 63 | object(impl->access_service()->add_object_for_path( | 63 | object(impl->access_service()->add_object_for_path( |
337 | 64 | dbus::traits::Service<media::Service>::object_path())), | 64 | dbus::traits::Service<media::Service>::object_path())), |
338 | 65 | configuration(config), | 65 | configuration(config), |
340 | 66 | exported(impl->access_bus(), config.cover_art_resolver, impl) | 66 | exported(impl->access_bus(), config.cover_art_resolver, impl, configuration) |
341 | 67 | { | 67 | { |
342 | 68 | object->install_method_handler<mpris::Service::CreateSession>( | 68 | object->install_method_handler<mpris::Service::CreateSession>( |
343 | 69 | std::bind( | 69 | std::bind( |
344 | @@ -95,11 +95,6 @@ | |||
345 | 95 | &Private::handle_resume_session, | 95 | &Private::handle_resume_session, |
346 | 96 | this, | 96 | this, |
347 | 97 | std::placeholders::_1)); | 97 | std::placeholders::_1)); |
348 | 98 | object->install_method_handler<mpris::Service::SetCurrentPlayer>( | ||
349 | 99 | std::bind( | ||
350 | 100 | &Private::handle_set_current_player, | ||
351 | 101 | this, | ||
352 | 102 | std::placeholders::_1)); | ||
353 | 103 | object->install_method_handler<mpris::Service::PauseOtherSessions>( | 98 | object->install_method_handler<mpris::Service::PauseOtherSessions>( |
354 | 104 | std::bind( | 99 | std::bind( |
355 | 105 | &Private::handle_pause_other_sessions, | 100 | &Private::handle_pause_other_sessions, |
356 | @@ -133,7 +128,8 @@ | |||
357 | 133 | key, | 128 | key, |
358 | 134 | impl->access_bus(), | 129 | impl->access_bus(), |
359 | 135 | impl->access_service(), | 130 | impl->access_service(), |
361 | 136 | impl->access_service()->add_object_for_path(op) | 131 | impl->access_service()->add_object_for_path(op), |
362 | 132 | impl | ||
363 | 137 | }; | 133 | }; |
364 | 138 | 134 | ||
365 | 139 | MH_DEBUG("Session created by request of: %s, key: %d, uuid: %d, path: %s", | 135 | MH_DEBUG("Session created by request of: %s, key: %d, uuid: %d, path: %s", |
366 | @@ -241,12 +237,6 @@ | |||
367 | 241 | // Signal player reconnection | 237 | // Signal player reconnection |
368 | 242 | auto player = configuration.player_store->player_for_key(key); | 238 | auto player = configuration.player_store->player_for_key(key); |
369 | 243 | player->reconnect(); | 239 | player->reconnect(); |
370 | 244 | // We only care to allow the MPRIS controls to apply to multimedia player (i.e. audio, video) | ||
371 | 245 | if (player->audio_stream_role() == media::Player::AudioStreamRole::multimedia) | ||
372 | 246 | { | ||
373 | 247 | MH_TRACE("Setting current_player"); | ||
374 | 248 | exported.set_current_player(player); | ||
375 | 249 | } | ||
376 | 250 | 240 | ||
377 | 251 | auto reply = dbus::Message::make_method_return(msg); | 241 | auto reply = dbus::Message::make_method_return(msg); |
378 | 252 | reply->writer() << op; | 242 | reply->writer() << op; |
379 | @@ -369,7 +359,8 @@ | |||
380 | 369 | key, | 359 | key, |
381 | 370 | impl->access_bus(), | 360 | impl->access_bus(), |
382 | 371 | impl->access_service(), | 361 | impl->access_service(), |
384 | 372 | impl->access_service()->add_object_for_path(op) | 362 | impl->access_service()->add_object_for_path(op), |
385 | 363 | impl | ||
386 | 373 | }; | 364 | }; |
387 | 374 | 365 | ||
388 | 375 | auto session = impl->create_session(config); | 366 | auto session = impl->create_session(config); |
389 | @@ -543,7 +534,7 @@ | |||
390 | 543 | } | 534 | } |
391 | 544 | 535 | ||
392 | 545 | explicit Exported(const dbus::Bus::Ptr& bus, const media::CoverArtResolver& cover_art_resolver, | 536 | explicit Exported(const dbus::Bus::Ptr& bus, const media::CoverArtResolver& cover_art_resolver, |
394 | 546 | media::ServiceSkeleton* impl) | 537 | media::ServiceSkeleton* impl, const ServiceSkeleton::Configuration& config) |
395 | 547 | : bus{bus}, | 538 | : bus{bus}, |
396 | 548 | /* Export MediaHub service interface on dbus */ | 539 | /* Export MediaHub service interface on dbus */ |
397 | 549 | service{dbus::Service::add_service(bus, "org.mpris.MediaPlayer2.MediaHub")}, | 540 | service{dbus::Service::add_service(bus, "org.mpris.MediaPlayer2.MediaHub")}, |
398 | @@ -552,7 +543,8 @@ | |||
399 | 552 | player{mpris::Player::Skeleton::Configuration{bus, object, player_defaults()}}, | 543 | player{mpris::Player::Skeleton::Configuration{bus, object, player_defaults()}}, |
400 | 553 | playlists{mpris::Playlists::Skeleton::Configuration{bus, object, mpris::Playlists::Skeleton::Configuration::Defaults{}}}, | 544 | playlists{mpris::Playlists::Skeleton::Configuration{bus, object, mpris::Playlists::Skeleton::Configuration::Defaults{}}}, |
401 | 554 | cover_art_resolver{cover_art_resolver}, | 545 | cover_art_resolver{cover_art_resolver}, |
403 | 555 | impl{impl} | 546 | impl{impl}, |
404 | 547 | service_skel_config(config) | ||
405 | 556 | { | 548 | { |
406 | 557 | object->install_method_handler<core::dbus::interfaces::Properties::GetAll>([this](const core::dbus::Message::Ptr& msg) | 549 | object->install_method_handler<core::dbus::interfaces::Properties::GetAll>([this](const core::dbus::Message::Ptr& msg) |
407 | 558 | { | 550 | { |
408 | @@ -574,7 +566,7 @@ | |||
409 | 574 | // Setup method handlers for mpris::Player methods. | 566 | // Setup method handlers for mpris::Player methods. |
410 | 575 | auto next = [this](const core::dbus::Message::Ptr& msg) | 567 | auto next = [this](const core::dbus::Message::Ptr& msg) |
411 | 576 | { | 568 | { |
413 | 577 | const auto sp = current_player.lock(); | 569 | const auto sp = service_skel_config.player_store->current_player().get(); |
414 | 578 | 570 | ||
415 | 579 | if (is_multimedia_role()) | 571 | if (is_multimedia_role()) |
416 | 580 | sp->next(); | 572 | sp->next(); |
417 | @@ -585,7 +577,7 @@ | |||
418 | 585 | 577 | ||
419 | 586 | auto previous = [this](const core::dbus::Message::Ptr& msg) | 578 | auto previous = [this](const core::dbus::Message::Ptr& msg) |
420 | 587 | { | 579 | { |
422 | 588 | const auto sp = current_player.lock(); | 580 | const auto sp = service_skel_config.player_store->current_player().get(); |
423 | 589 | 581 | ||
424 | 590 | if (is_multimedia_role()) | 582 | if (is_multimedia_role()) |
425 | 591 | sp->previous(); | 583 | sp->previous(); |
426 | @@ -596,7 +588,7 @@ | |||
427 | 596 | 588 | ||
428 | 597 | auto pause = [this](const core::dbus::Message::Ptr& msg) | 589 | auto pause = [this](const core::dbus::Message::Ptr& msg) |
429 | 598 | { | 590 | { |
431 | 599 | const auto sp = current_player.lock(); | 591 | const auto sp = service_skel_config.player_store->current_player().get(); |
432 | 600 | 592 | ||
433 | 601 | if (is_multimedia_role() and sp->can_pause()) | 593 | if (is_multimedia_role() and sp->can_pause()) |
434 | 602 | sp->pause(); | 594 | sp->pause(); |
435 | @@ -607,7 +599,7 @@ | |||
436 | 607 | 599 | ||
437 | 608 | auto stop = [this](const core::dbus::Message::Ptr& msg) | 600 | auto stop = [this](const core::dbus::Message::Ptr& msg) |
438 | 609 | { | 601 | { |
440 | 610 | const auto sp = current_player.lock(); | 602 | const auto sp = service_skel_config.player_store->current_player().get(); |
441 | 611 | 603 | ||
442 | 612 | if (is_multimedia_role()) | 604 | if (is_multimedia_role()) |
443 | 613 | sp->stop(); | 605 | sp->stop(); |
444 | @@ -618,7 +610,7 @@ | |||
445 | 618 | 610 | ||
446 | 619 | auto play = [this, impl](const core::dbus::Message::Ptr& msg) | 611 | auto play = [this, impl](const core::dbus::Message::Ptr& msg) |
447 | 620 | { | 612 | { |
449 | 621 | const auto sp = current_player.lock(); | 613 | const auto sp = service_skel_config.player_store->current_player().get(); |
450 | 622 | 614 | ||
451 | 623 | if (is_multimedia_role() and sp->can_play()) | 615 | if (is_multimedia_role() and sp->can_play()) |
452 | 624 | { | 616 | { |
453 | @@ -636,7 +628,7 @@ | |||
454 | 636 | 628 | ||
455 | 637 | auto play_pause = [this, impl](const core::dbus::Message::Ptr& msg) | 629 | auto play_pause = [this, impl](const core::dbus::Message::Ptr& msg) |
456 | 638 | { | 630 | { |
458 | 639 | const auto sp = current_player.lock(); | 631 | const auto sp = service_skel_config.player_store->current_player().get(); |
459 | 640 | 632 | ||
460 | 641 | if (is_multimedia_role()) | 633 | if (is_multimedia_role()) |
461 | 642 | { | 634 | { |
462 | @@ -662,67 +654,79 @@ | |||
463 | 662 | 654 | ||
464 | 663 | inline bool is_multimedia_role() | 655 | inline bool is_multimedia_role() |
465 | 664 | { | 656 | { |
467 | 665 | const auto sp = current_player.lock(); | 657 | MH_TRACE(""); |
468 | 666 | 658 | ||
469 | 659 | const auto sp = service_skel_config.player_store->current_player().get(); | ||
470 | 667 | return (sp ? sp->audio_stream_role() == media::Player::AudioStreamRole::multimedia : false); | 660 | return (sp ? sp->audio_stream_role() == media::Player::AudioStreamRole::multimedia : false); |
471 | 668 | } | 661 | } |
472 | 669 | 662 | ||
474 | 670 | void set_current_player(const std::shared_ptr<media::Player>& cp) | 663 | void set_current_player(media::Player::PlayerKey key) |
475 | 671 | { | 664 | { |
476 | 672 | MH_TRACE(""); | 665 | MH_TRACE(""); |
479 | 673 | // We will not keep the object alive. | 666 | |
480 | 674 | current_player = cp; | 667 | // Update the current player in the Player store |
481 | 668 | service_skel_config.player_store->set_current_player_for_key(key); | ||
482 | 669 | const auto player_sp = service_skel_config.player_store->current_player().get(); | ||
483 | 675 | 670 | ||
484 | 676 | // And announce that we can be controlled again. | 671 | // And announce that we can be controlled again. |
485 | 677 | player.properties.can_control->set(true); | 672 | player.properties.can_control->set(true); |
486 | 678 | 673 | ||
487 | 679 | // We wire up player state changes | 674 | // We wire up player state changes |
489 | 680 | connections.seeked_to = cp->seeked_to().connect([this](std::uint64_t position) | 675 | connections.seeked_to = player_sp->seeked_to().connect([this](std::uint64_t position) |
490 | 681 | { | 676 | { |
491 | 682 | player.signals.seeked_to->emit(position); | 677 | player.signals.seeked_to->emit(position); |
492 | 683 | }); | 678 | }); |
493 | 684 | 679 | ||
495 | 685 | connections.duration_changed = cp->duration().changed().connect([this](std::uint64_t duration) | 680 | connections.duration_changed = player_sp->duration().changed().connect([this](std::uint64_t duration) |
496 | 686 | { | 681 | { |
497 | 687 | player.properties.duration->set(duration); | 682 | player.properties.duration->set(duration); |
498 | 688 | }); | 683 | }); |
499 | 689 | 684 | ||
501 | 690 | connections.position_changed = cp->position().changed().connect([this](std::uint64_t position) | 685 | connections.position_changed = player_sp->position().changed().connect([this](std::uint64_t position) |
502 | 691 | { | 686 | { |
503 | 692 | player.properties.position->set(position); | 687 | player.properties.position->set(position); |
504 | 693 | }); | 688 | }); |
505 | 694 | 689 | ||
508 | 695 | connections.playback_status_changed = cp->playback_status().changed().connect( | 690 | connections.playback_status_changed = player_sp->playback_status().changed().connect( |
509 | 696 | [this](core::ubuntu::media::Player::PlaybackStatus status) | 691 | [this, key, player_sp](core::ubuntu::media::Player::PlaybackStatus status) |
510 | 697 | { | 692 | { |
512 | 698 | player.properties.playback_status->set(mpris::Player::PlaybackStatus::from(status)); | 693 | const auto cp = service_skel_config.player_store->current_player().get(); |
513 | 694 | // If key points to the current player's key, then update status | ||
514 | 695 | if (cp and key == cp->key()) | ||
515 | 696 | player.properties.playback_status->set(mpris::Player::PlaybackStatus::from(status)); | ||
516 | 699 | }); | 697 | }); |
517 | 700 | 698 | ||
519 | 701 | connections.loop_status_changed = cp->loop_status().changed().connect( | 699 | connections.loop_status_changed = player_sp->loop_status().changed().connect( |
520 | 702 | [this](core::ubuntu::media::Player::LoopStatus status) | 700 | [this](core::ubuntu::media::Player::LoopStatus status) |
521 | 703 | { | 701 | { |
522 | 704 | player.properties.loop_status->set(mpris::Player::LoopStatus::from(status)); | 702 | player.properties.loop_status->set(mpris::Player::LoopStatus::from(status)); |
523 | 705 | }); | 703 | }); |
524 | 706 | 704 | ||
538 | 707 | connections.can_play_changed = cp->can_play().changed().connect( | 705 | connections.can_play_changed = player_sp->can_play().changed().connect( |
539 | 708 | [this](bool can_play) | 706 | [this, key, player_sp](bool can_play) |
540 | 709 | { | 707 | { |
541 | 710 | player.properties.can_play->set(can_play); | 708 | const auto cp = service_skel_config.player_store->current_player().get(); |
542 | 711 | }); | 709 | // If key points to the current player's key, then update can_play |
543 | 712 | 710 | if (cp and key == cp->key()) | |
544 | 713 | connections.can_pause_changed = cp->can_pause().changed().connect( | 711 | player.properties.can_play->set(can_play); |
545 | 714 | [this](bool can_pause) | 712 | }); |
546 | 715 | { | 713 | |
547 | 716 | player.properties.can_pause->set(can_pause); | 714 | connections.can_pause_changed = player_sp->can_pause().changed().connect( |
548 | 717 | }); | 715 | [this, key, player_sp](bool can_pause) |
549 | 718 | 716 | { | |
550 | 719 | connections.can_go_previous_changed = cp->can_go_previous().changed().connect( | 717 | const auto cp = service_skel_config.player_store->current_player().get(); |
551 | 718 | // If key points to the current player's key, then update can_pause | ||
552 | 719 | if (cp and key == cp->key()) | ||
553 | 720 | player.properties.can_pause->set(can_pause); | ||
554 | 721 | }); | ||
555 | 722 | |||
556 | 723 | connections.can_go_previous_changed = player_sp->can_go_previous().changed().connect( | ||
557 | 720 | [this](bool can_go_previous) | 724 | [this](bool can_go_previous) |
558 | 721 | { | 725 | { |
559 | 722 | player.properties.can_go_previous->set(can_go_previous); | 726 | player.properties.can_go_previous->set(can_go_previous); |
560 | 723 | }); | 727 | }); |
561 | 724 | 728 | ||
563 | 725 | connections.can_go_next_changed = cp->can_go_next().changed().connect( | 729 | connections.can_go_next_changed = player_sp->can_go_next().changed().connect( |
564 | 726 | [this](bool can_go_next) | 730 | [this](bool can_go_next) |
565 | 727 | { | 731 | { |
566 | 728 | player.properties.can_go_next->set(can_go_next); | 732 | player.properties.can_go_next->set(can_go_next); |
567 | @@ -734,16 +738,16 @@ | |||
568 | 734 | // different DBus object paths, /core/ubuntu/media/Service/sessions/<n> | 738 | // different DBus object paths, /core/ubuntu/media/Service/sessions/<n> |
569 | 735 | // and /org/mpris/MediaPlayer2 (this is the one enforced by the MPRIS spec). | 739 | // and /org/mpris/MediaPlayer2 (this is the one enforced by the MPRIS spec). |
570 | 736 | // Discuss why this is needed with tvoss. | 740 | // Discuss why this is needed with tvoss. |
573 | 737 | player.properties.duration->set(cp->duration().get()); | 741 | player.properties.duration->set(player_sp->duration().get()); |
574 | 738 | player.properties.position->set(cp->position().get()); | 742 | player.properties.position->set(player_sp->position().get()); |
575 | 739 | player.properties.playback_status->set(mpris::Player::PlaybackStatus::from( | 743 | player.properties.playback_status->set(mpris::Player::PlaybackStatus::from( |
577 | 740 | cp->playback_status().get())); | 744 | player_sp->playback_status().get())); |
578 | 741 | player.properties.loop_status->set(mpris::Player::LoopStatus::from( | 745 | player.properties.loop_status->set(mpris::Player::LoopStatus::from( |
584 | 742 | cp->loop_status().get())); | 746 | player_sp->loop_status().get())); |
585 | 743 | player.properties.can_play->set(cp->can_play().get()); | 747 | player.properties.can_play->set(player_sp->can_play().get()); |
586 | 744 | player.properties.can_pause->set(cp->can_pause().get()); | 748 | player.properties.can_pause->set(player_sp->can_pause().get()); |
587 | 745 | player.properties.can_go_previous->set(cp->can_go_previous().get()); | 749 | player.properties.can_go_previous->set(player_sp->can_go_previous().get()); |
588 | 746 | player.properties.can_go_next->set(cp->can_go_next().get()); | 750 | player.properties.can_go_next->set(player_sp->can_go_next().get()); |
589 | 747 | 751 | ||
590 | 748 | #if 0 | 752 | #if 0 |
591 | 749 | // TODO cover_art_resolver() is not implemented yet | 753 | // TODO cover_art_resolver() is not implemented yet |
592 | @@ -788,7 +792,27 @@ | |||
593 | 788 | MH_TRACE(""); | 792 | MH_TRACE(""); |
594 | 789 | // And announce that we can no longer be controlled. | 793 | // And announce that we can no longer be controlled. |
595 | 790 | player.properties.can_control->set(false); | 794 | player.properties.can_control->set(false); |
597 | 791 | current_player.reset(); | 795 | player.properties.can_play->set(false); |
598 | 796 | player.properties.can_pause->set(false); | ||
599 | 797 | player.properties.can_go_previous->set(false); | ||
600 | 798 | player.properties.can_go_next->set(false); | ||
601 | 799 | |||
602 | 800 | // Reset to null event connections | ||
603 | 801 | connections.seeked_to = the_empty_signal.connect([](){}); | ||
604 | 802 | connections.duration_changed = the_empty_signal.connect([](){}); | ||
605 | 803 | connections.position_changed = the_empty_signal.connect([](){}); | ||
606 | 804 | connections.playback_status_changed = the_empty_signal.connect([](){}); | ||
607 | 805 | connections.loop_status_changed = the_empty_signal.connect([](){}); | ||
608 | 806 | connections.can_play_changed = the_empty_signal.connect([](){}); | ||
609 | 807 | connections.can_pause_changed = the_empty_signal.connect([](){}); | ||
610 | 808 | connections.can_go_previous_changed = the_empty_signal.connect([](){}); | ||
611 | 809 | connections.can_go_next_changed = the_empty_signal.connect([](){}); | ||
612 | 810 | } | ||
613 | 811 | |||
614 | 812 | bool is_current_player(media::Player::PlayerKey key) | ||
615 | 813 | |||
616 | 814 | { | ||
617 | 815 | return key == service_skel_config.player_store->current_player().get()->key(); | ||
618 | 792 | } | 816 | } |
619 | 793 | 817 | ||
620 | 794 | dbus::Bus::Ptr bus; | 818 | dbus::Bus::Ptr bus; |
621 | @@ -801,10 +825,9 @@ | |||
622 | 801 | 825 | ||
623 | 802 | // The CoverArtResolver used by the exported player. | 826 | // The CoverArtResolver used by the exported player. |
624 | 803 | media::CoverArtResolver cover_art_resolver; | 827 | media::CoverArtResolver cover_art_resolver; |
625 | 804 | // The actual player instance. | ||
626 | 805 | std::weak_ptr<media::Player> current_player; | ||
627 | 806 | 828 | ||
628 | 807 | media::ServiceSkeleton* impl; | 829 | media::ServiceSkeleton* impl; |
629 | 830 | ServiceSkeleton::Configuration service_skel_config; | ||
630 | 808 | 831 | ||
631 | 809 | // We track event connections. | 832 | // We track event connections. |
632 | 810 | struct | 833 | struct |
633 | @@ -899,11 +922,23 @@ | |||
634 | 899 | d->configuration.player_store->player_for_key(key); | 922 | d->configuration.player_store->player_for_key(key); |
635 | 900 | // We only care to allow the MPRIS controls to apply to multimedia player (i.e. audio, video) | 923 | // We only care to allow the MPRIS controls to apply to multimedia player (i.e. audio, video) |
636 | 901 | if (player->audio_stream_role() == media::Player::AudioStreamRole::multimedia) | 924 | if (player->audio_stream_role() == media::Player::AudioStreamRole::multimedia) |
638 | 902 | d->exported.set_current_player(player); | 925 | d->exported.set_current_player(key); |
639 | 926 | } | ||
640 | 927 | |||
641 | 928 | bool media::ServiceSkeleton::is_current_player(media::Player::PlayerKey key) const | ||
642 | 929 | { | ||
643 | 930 | return d->exported.is_current_player(key); | ||
644 | 931 | } | ||
645 | 932 | |||
646 | 933 | void media::ServiceSkeleton::reset_current_player() | ||
647 | 934 | { | ||
648 | 935 | MH_TRACE(""); | ||
649 | 936 | d->exported.reset_current_player(); | ||
650 | 903 | } | 937 | } |
651 | 904 | 938 | ||
652 | 905 | void media::ServiceSkeleton::pause_other_sessions(media::Player::PlayerKey key) | 939 | void media::ServiceSkeleton::pause_other_sessions(media::Player::PlayerKey key) |
653 | 906 | { | 940 | { |
654 | 941 | MH_TRACE(""); | ||
655 | 907 | d->configuration.impl->pause_other_sessions(key); | 942 | d->configuration.impl->pause_other_sessions(key); |
656 | 908 | } | 943 | } |
657 | 909 | 944 | ||
658 | 910 | 945 | ||
659 | === modified file 'src/core/media/service_skeleton.h' | |||
660 | --- src/core/media/service_skeleton.h 2015-09-08 20:03:56 +0000 | |||
661 | +++ src/core/media/service_skeleton.h 2016-05-04 13:11:44 +0000 | |||
662 | @@ -60,6 +60,8 @@ | |||
663 | 60 | std::shared_ptr<Player> create_fixed_session(const std::string& name, const Player::Configuration&); | 60 | std::shared_ptr<Player> create_fixed_session(const std::string& name, const Player::Configuration&); |
664 | 61 | std::shared_ptr<Player> resume_session(Player::PlayerKey); | 61 | std::shared_ptr<Player> resume_session(Player::PlayerKey); |
665 | 62 | void set_current_player(Player::PlayerKey key); | 62 | void set_current_player(Player::PlayerKey key); |
666 | 63 | bool is_current_player(Player::PlayerKey key) const; | ||
667 | 64 | void reset_current_player(); | ||
668 | 63 | void pause_other_sessions(Player::PlayerKey key); | 65 | void pause_other_sessions(Player::PlayerKey key); |
669 | 64 | 66 | ||
670 | 65 | void run(); | 67 | void run(); |
671 | 66 | 68 | ||
672 | === modified file 'src/core/media/service_stub.cpp' | |||
673 | --- src/core/media/service_stub.cpp 2015-09-08 20:03:56 +0000 | |||
674 | +++ src/core/media/service_stub.cpp 2016-05-04 13:11:44 +0000 | |||
675 | @@ -139,15 +139,6 @@ | |||
676 | 139 | }); | 139 | }); |
677 | 140 | } | 140 | } |
678 | 141 | 141 | ||
679 | 142 | void media::ServiceStub::set_current_player(Player::PlayerKey key) | ||
680 | 143 | { | ||
681 | 144 | auto op = d->object->invoke_method_synchronously<mpris::Service::SetCurrentPlayer, | ||
682 | 145 | void>(key); | ||
683 | 146 | |||
684 | 147 | if (op.is_error()) | ||
685 | 148 | throw std::runtime_error("Problem setting current player: " + op.error()); | ||
686 | 149 | } | ||
687 | 150 | |||
688 | 151 | void media::ServiceStub::pause_other_sessions(media::Player::PlayerKey key) | 142 | void media::ServiceStub::pause_other_sessions(media::Player::PlayerKey key) |
689 | 152 | { | 143 | { |
690 | 153 | auto op = d->object->invoke_method_synchronously<mpris::Service::PauseOtherSessions, | 144 | auto op = d->object->invoke_method_synchronously<mpris::Service::PauseOtherSessions, |
691 | 154 | 145 | ||
692 | === modified file 'src/core/media/service_stub.h' | |||
693 | --- src/core/media/service_stub.h 2015-09-08 20:03:56 +0000 | |||
694 | +++ src/core/media/service_stub.h 2016-05-04 13:11:44 +0000 | |||
695 | @@ -45,7 +45,6 @@ | |||
696 | 45 | void destroy_session(const std::string& uuid, const Player::Configuration&); | 45 | void destroy_session(const std::string& uuid, const Player::Configuration&); |
697 | 46 | std::shared_ptr<Player> create_fixed_session(const std::string& name, const Player::Configuration&); | 46 | std::shared_ptr<Player> create_fixed_session(const std::string& name, const Player::Configuration&); |
698 | 47 | std::shared_ptr<Player> resume_session(Player::PlayerKey key); | 47 | std::shared_ptr<Player> resume_session(Player::PlayerKey key); |
699 | 48 | void set_current_player(Player::PlayerKey key); | ||
700 | 49 | void pause_other_sessions(Player::PlayerKey key); | 48 | void pause_other_sessions(Player::PlayerKey key); |
701 | 50 | 49 | ||
702 | 51 | private: | 50 | private: |
Minor issue