Merge lp:~phablet-team/media-hub/bg-playlist-fixes into lp:media-hub/stable
- bg-playlist-fixes
- Merge into stable
Status: | Merged |
---|---|
Approved by: | Jim Hodapp |
Approved revision: | 168 |
Merged at revision: | 163 |
Proposed branch: | lp:~phablet-team/media-hub/bg-playlist-fixes |
Merge into: | lp:media-hub/stable |
Prerequisite: | lp:~morphis/media-hub/previous-to-same-after-four-secs |
Diff against target: |
703 lines (+237/-42) 11 files modified
include/core/media/track_list.h (+8/-0) src/core/media/mpris/service.h (+12/-0) src/core/media/mpris/track_list.h (+17/-0) src/core/media/player_implementation.cpp (+12/-0) src/core/media/service_skeleton.cpp (+22/-6) src/core/media/track_list.cpp (+5/-0) src/core/media/track_list_implementation.cpp (+25/-18) src/core/media/track_list_skeleton.cpp (+102/-16) src/core/media/track_list_skeleton.h (+4/-0) src/core/media/track_list_stub.cpp (+29/-2) src/core/media/track_list_stub.h (+1/-0) |
To merge this branch: | bzr merge lp:~phablet-team/media-hub/bg-playlist-fixes |
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jim Hodapp (community) | code | Approve | |
Review via email: mp+276094@code.launchpad.net |
Commit message
Make sure our iterator for the current track points to the right place when (un)shuffling (LP #1510219). Fix crash when client tries to set the player for a non-existing key. Do not add empty URIs to the list (LP: #1511029).
Description of the change
Make sure our iterator for the current track points to the right place when (un)shuffling (LP #1510219). Fix crash when client tries to set the player for a non-existing key. Do not add empty URIs to the list (LP: #1511029).
- 165. By Alfonso Sanchez-Beato
-
Do not add empty URIs to the list (LP: #1511029)
- 166. By Alfonso Sanchez-Beato
-
Send TrackChanged signals only when the TrackAdded signal for the
corresponding track has already been sent.
- 167. By Alfonso Sanchez-Beato
-
Address review comments
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
Branch refreshed after addressing comments.
Jim Hodapp (jhodapp) wrote : | # |
Looks good, one minor change still needed.
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
Branch refreshed after addressing comment.
- 168. By Alfonso Sanchez-Beato
-
Address review comment
- 169. By Alfonso Sanchez-Beato
-
Repeat current track when already played more than five seconds
- 170. By Alfonso Sanchez-Beato
-
Fix for the repeat track feature
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
lp:~morphis/media-hub/previous-to-same-after-four-secs merged + fix for it
- 171. By Alfonso Sanchez-Beato
-
Add TrackListReset signal, which is emitted when the Reset DBus method is
called. - 172. By Alfonso Sanchez-Beato
-
Update properly playlist iterator when adding or removing tracks
(LP: #1511073). - 173. By Alfonso Sanchez-Beato
-
Use get/set_current track when shuffling
- 174. By Alfonso Sanchez-Beato
-
Force index update when changing the track list
Jim Hodapp (jhodapp) wrote : | # |
A few comments below about the latest changes.
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
Some comments answered. I will update the branch later as I will modify qtubuntu-media too.
- 175. By Alfonso Sanchez-Beato
-
Address review comments
Jim Hodapp (jhodapp) wrote : | # |
Several comments inline below.
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
See comments below. I will address the remaining issues asap.
- 176. By Alfonso Sanchez-Beato
-
Address review comments
Jim Hodapp (jhodapp) wrote : | # |
A couple of comments below.
Preview Diff
1 | === modified file 'include/core/media/track_list.h' | |||
2 | --- include/core/media/track_list.h 2015-10-23 14:39:34 +0000 | |||
3 | +++ include/core/media/track_list.h 2015-11-13 15:27:09 +0000 | |||
4 | @@ -54,6 +54,11 @@ | |||
5 | 54 | { | 54 | { |
6 | 55 | InsufficientPermissionsToAddTrack(); | 55 | InsufficientPermissionsToAddTrack(); |
7 | 56 | }; | 56 | }; |
8 | 57 | |||
9 | 58 | struct TrackNotFound : public std::runtime_error | ||
10 | 59 | { | ||
11 | 60 | TrackNotFound(); | ||
12 | 61 | }; | ||
13 | 57 | }; | 62 | }; |
14 | 58 | 63 | ||
15 | 59 | static const Track::Id& after_empty_track(); | 64 | static const Track::Id& after_empty_track(); |
16 | @@ -123,6 +128,9 @@ | |||
17 | 123 | /** Indicates that a track has been removed from the track list. */ | 128 | /** Indicates that a track has been removed from the track list. */ |
18 | 124 | virtual const core::Signal<Track::Id>& on_track_removed() const = 0; | 129 | virtual const core::Signal<Track::Id>& on_track_removed() const = 0; |
19 | 125 | 130 | ||
20 | 131 | /** Indicates that the track list has been reset and there are no tracks now */ | ||
21 | 132 | virtual const core::Signal<void>& on_track_list_reset() const = 0; | ||
22 | 133 | |||
23 | 126 | /** Indicates that the track list advanced from one track to another. */ | 134 | /** Indicates that the track list advanced from one track to another. */ |
24 | 127 | virtual const core::Signal<Track::Id>& on_track_changed() const = 0; | 135 | virtual const core::Signal<Track::Id>& on_track_changed() const = 0; |
25 | 128 | 136 | ||
26 | 129 | 137 | ||
27 | === modified file 'src/core/media/mpris/service.h' | |||
28 | --- src/core/media/mpris/service.h 2015-09-08 20:03:56 +0000 | |||
29 | +++ src/core/media/mpris/service.h 2015-11-13 15:27:09 +0000 | |||
30 | @@ -107,6 +107,18 @@ | |||
31 | 107 | return s; | 107 | return s; |
32 | 108 | } | 108 | } |
33 | 109 | }; | 109 | }; |
34 | 110 | |||
35 | 111 | struct PlayerKeyNotFound | ||
36 | 112 | { | ||
37 | 113 | static const std::string& name() | ||
38 | 114 | { | ||
39 | 115 | static const std::string s | ||
40 | 116 | { | ||
41 | 117 | "core.ubuntu.media.Service.Error.PlayerKeyNotFound" | ||
42 | 118 | }; | ||
43 | 119 | return s; | ||
44 | 120 | } | ||
45 | 121 | }; | ||
46 | 110 | }; | 122 | }; |
47 | 111 | 123 | ||
48 | 112 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(CreateSession, Service, 1000) | 124 | DBUS_CPP_METHOD_WITH_TIMEOUT_DEF(CreateSession, Service, 1000) |
49 | 113 | 125 | ||
50 | === modified file 'src/core/media/mpris/track_list.h' | |||
51 | --- src/core/media/mpris/track_list.h 2015-10-23 14:39:34 +0000 | |||
52 | +++ src/core/media/mpris/track_list.h 2015-11-13 15:27:09 +0000 | |||
53 | @@ -57,6 +57,14 @@ | |||
54 | 57 | "mpris.TrackList.Error.InsufficientPermissionsToAddTrack" | 57 | "mpris.TrackList.Error.InsufficientPermissionsToAddTrack" |
55 | 58 | }; | 58 | }; |
56 | 59 | }; | 59 | }; |
57 | 60 | |||
58 | 61 | struct TrackNotFound | ||
59 | 62 | { | ||
60 | 63 | static constexpr const char* name | ||
61 | 64 | { | ||
62 | 65 | "mpris.TrackList.Error.TrackNotFound" | ||
63 | 66 | }; | ||
64 | 67 | }; | ||
65 | 60 | }; | 68 | }; |
66 | 61 | 69 | ||
67 | 62 | DBUS_CPP_METHOD_DEF(GetTracksMetadata, TrackList) | 70 | DBUS_CPP_METHOD_DEF(GetTracksMetadata, TrackList) |
68 | @@ -108,6 +116,13 @@ | |||
69 | 108 | 116 | ||
70 | 109 | DBUS_CPP_SIGNAL_DEF | 117 | DBUS_CPP_SIGNAL_DEF |
71 | 110 | ( | 118 | ( |
72 | 119 | TrackListReset, | ||
73 | 120 | TrackList, | ||
74 | 121 | void | ||
75 | 122 | ) | ||
76 | 123 | |||
77 | 124 | DBUS_CPP_SIGNAL_DEF | ||
78 | 125 | ( | ||
79 | 111 | TrackMetadataChanged, | 126 | TrackMetadataChanged, |
80 | 112 | TrackList, | 127 | TrackList, |
81 | 113 | BOOST_IDENTITY_TYPE((std::tuple<std::map<std::string, dbus::types::Variant>, dbus::types::ObjectPath>)) | 128 | BOOST_IDENTITY_TYPE((std::tuple<std::map<std::string, dbus::types::Variant>, dbus::types::ObjectPath>)) |
82 | @@ -156,6 +171,7 @@ | |||
83 | 156 | configuration.object->template get_signal<Signals::TracksAdded>(), | 171 | configuration.object->template get_signal<Signals::TracksAdded>(), |
84 | 157 | configuration.object->template get_signal<Signals::TrackRemoved>(), | 172 | configuration.object->template get_signal<Signals::TrackRemoved>(), |
85 | 158 | configuration.object->template get_signal<Signals::TrackChanged>(), | 173 | configuration.object->template get_signal<Signals::TrackChanged>(), |
86 | 174 | configuration.object->template get_signal<Signals::TrackListReset>(), | ||
87 | 159 | configuration.object->template get_signal<Signals::TrackMetadataChanged>(), | 175 | configuration.object->template get_signal<Signals::TrackMetadataChanged>(), |
88 | 160 | configuration.object->template get_signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged>() | 176 | configuration.object->template get_signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged>() |
89 | 161 | } | 177 | } |
90 | @@ -201,6 +217,7 @@ | |||
91 | 201 | core::dbus::Signal<Signals::TracksAdded, Signals::TracksAdded::ArgumentType>::Ptr tracks_added; | 217 | core::dbus::Signal<Signals::TracksAdded, Signals::TracksAdded::ArgumentType>::Ptr tracks_added; |
92 | 202 | core::dbus::Signal<Signals::TrackRemoved, Signals::TrackRemoved::ArgumentType>::Ptr track_removed; | 218 | core::dbus::Signal<Signals::TrackRemoved, Signals::TrackRemoved::ArgumentType>::Ptr track_removed; |
93 | 203 | core::dbus::Signal<Signals::TrackChanged, Signals::TrackChanged::ArgumentType>::Ptr track_changed; | 219 | core::dbus::Signal<Signals::TrackChanged, Signals::TrackChanged::ArgumentType>::Ptr track_changed; |
94 | 220 | core::dbus::Signal<Signals::TrackListReset, Signals::TrackListReset::ArgumentType>::Ptr track_list_reset; | ||
95 | 204 | core::dbus::Signal<Signals::TrackMetadataChanged, Signals::TrackMetadataChanged::ArgumentType>::Ptr track_metadata_changed; | 221 | core::dbus::Signal<Signals::TrackMetadataChanged, Signals::TrackMetadataChanged::ArgumentType>::Ptr track_metadata_changed; |
96 | 205 | 222 | ||
97 | 206 | dbus::Signal <core::dbus::interfaces::Properties::Signals::PropertiesChanged, | 223 | dbus::Signal <core::dbus::interfaces::Properties::Signals::PropertiesChanged, |
98 | 207 | 224 | ||
99 | === modified file 'src/core/media/player_implementation.cpp' | |||
100 | --- src/core/media/player_implementation.cpp 2015-11-13 15:27:09 +0000 | |||
101 | +++ src/core/media/player_implementation.cpp 2015-11-13 15:27:09 +0000 | |||
102 | @@ -569,6 +569,11 @@ | |||
103 | 569 | d->update_mpris_properties(); | 569 | d->update_mpris_properties(); |
104 | 570 | }); | 570 | }); |
105 | 571 | 571 | ||
106 | 572 | d->track_list->on_track_list_reset().connect([this](void) | ||
107 | 573 | { | ||
108 | 574 | d->update_mpris_properties(); | ||
109 | 575 | }); | ||
110 | 576 | |||
111 | 572 | d->track_list->on_track_changed().connect([this](const media::Track::Id&) | 577 | d->track_list->on_track_changed().connect([this](const media::Track::Id&) |
112 | 573 | { | 578 | { |
113 | 574 | d->update_mpris_properties(); | 579 | d->update_mpris_properties(); |
114 | @@ -681,6 +686,13 @@ | |||
115 | 681 | bool media::PlayerImplementation<Parent>::open_uri(const Track::UriType& uri) | 686 | bool media::PlayerImplementation<Parent>::open_uri(const Track::UriType& uri) |
116 | 682 | { | 687 | { |
117 | 683 | d->track_list->reset(); | 688 | d->track_list->reset(); |
118 | 689 | |||
119 | 690 | // If empty uri, give the same meaning as QMediaPlayer::setMedia("") | ||
120 | 691 | if (uri.empty()) { | ||
121 | 692 | cout << __PRETTY_FUNCTION__ << ": resetting current media" << endl; | ||
122 | 693 | return true; | ||
123 | 694 | } | ||
124 | 695 | |||
125 | 684 | const bool ret = d->engine->open_resource_for_uri(uri, false); | 696 | const bool ret = d->engine->open_resource_for_uri(uri, false); |
126 | 685 | // Don't set new track as the current track to play since we're calling open_resource_for_uri above | 697 | // Don't set new track as the current track to play since we're calling open_resource_for_uri above |
127 | 686 | static const bool make_current = false; | 698 | static const bool make_current = false; |
128 | 687 | 699 | ||
129 | === modified file 'src/core/media/service_skeleton.cpp' | |||
130 | --- src/core/media/service_skeleton.cpp 2015-10-14 20:54:19 +0000 | |||
131 | +++ src/core/media/service_skeleton.cpp 2015-11-13 15:27:09 +0000 | |||
132 | @@ -46,6 +46,8 @@ | |||
133 | 46 | namespace dbus = core::dbus; | 46 | namespace dbus = core::dbus; |
134 | 47 | namespace media = core::ubuntu::media; | 47 | namespace media = core::ubuntu::media; |
135 | 48 | 48 | ||
136 | 49 | using namespace std; | ||
137 | 50 | |||
138 | 49 | namespace | 51 | namespace |
139 | 50 | { | 52 | { |
140 | 51 | core::Signal<void> the_empty_signal; | 53 | core::Signal<void> the_empty_signal; |
141 | @@ -132,7 +134,9 @@ | |||
142 | 132 | impl->access_service()->add_object_for_path(op) | 134 | impl->access_service()->add_object_for_path(op) |
143 | 133 | }; | 135 | }; |
144 | 134 | 136 | ||
146 | 135 | std::cout << "Session created by request of: " << msg->sender() << ", uuid: " << uuid << ", path:" << op << std::endl; | 137 | cout << "Session created by request of: " << msg->sender() |
147 | 138 | << ", key: " << key << ", uuid: " << uuid | ||
148 | 139 | << ", path:" << op << std::endl; | ||
149 | 136 | 140 | ||
150 | 137 | try | 141 | try |
151 | 138 | { | 142 | { |
152 | @@ -205,9 +209,11 @@ | |||
153 | 205 | std::string uuid; | 209 | std::string uuid; |
154 | 206 | msg->reader() >> uuid; | 210 | msg->reader() >> uuid; |
155 | 207 | 211 | ||
157 | 208 | if (uuid_player_map.count(uuid) != 0) { | 212 | if (uuid_player_map.count(uuid) != 0) |
158 | 213 | { | ||
159 | 209 | auto key = uuid_player_map.at(uuid); | 214 | auto key = uuid_player_map.at(uuid); |
161 | 210 | if (not configuration.player_store->has_player_for_key(key)) { | 215 | if (not configuration.player_store->has_player_for_key(key)) |
162 | 216 | { | ||
163 | 211 | auto reply = dbus::Message::make_error( | 217 | auto reply = dbus::Message::make_error( |
164 | 212 | msg, | 218 | msg, |
165 | 213 | mpris::Service::Errors::ReattachingSession::name(), | 219 | mpris::Service::Errors::ReattachingSession::name(), |
166 | @@ -442,9 +448,19 @@ | |||
167 | 442 | { | 448 | { |
168 | 443 | Player::PlayerKey key; | 449 | Player::PlayerKey key; |
169 | 444 | msg->reader() >> key; | 450 | msg->reader() >> key; |
173 | 445 | impl->set_current_player(key); | 451 | |
174 | 446 | 452 | core::dbus::Message::Ptr reply; | |
175 | 447 | auto reply = dbus::Message::make_method_return(msg); | 453 | if (not configuration.player_store->has_player_for_key(key)) { |
176 | 454 | cerr << __PRETTY_FUNCTION__ << " player key not found - " << key << endl; | ||
177 | 455 | reply = dbus::Message::make_error( | ||
178 | 456 | msg, | ||
179 | 457 | mpris::Service::Errors::PlayerKeyNotFound::name(), | ||
180 | 458 | "Player key not found"); | ||
181 | 459 | } else { | ||
182 | 460 | impl->set_current_player(key); | ||
183 | 461 | reply = dbus::Message::make_method_return(msg); | ||
184 | 462 | } | ||
185 | 463 | |||
186 | 448 | impl->access_bus()->send(reply); | 464 | impl->access_bus()->send(reply); |
187 | 449 | } | 465 | } |
188 | 450 | 466 | ||
189 | 451 | 467 | ||
190 | === modified file 'src/core/media/track_list.cpp' | |||
191 | --- src/core/media/track_list.cpp 2015-10-23 14:39:34 +0000 | |||
192 | +++ src/core/media/track_list.cpp 2015-11-13 15:27:09 +0000 | |||
193 | @@ -25,6 +25,11 @@ | |||
194 | 25 | { | 25 | { |
195 | 26 | } | 26 | } |
196 | 27 | 27 | ||
197 | 28 | media::TrackList::Errors::TrackNotFound::TrackNotFound() | ||
198 | 29 | : std::runtime_error{"Track not found in TrackList"} | ||
199 | 30 | { | ||
200 | 31 | } | ||
201 | 32 | |||
202 | 28 | const media::Track::Id& media::TrackList::after_empty_track() | 33 | const media::Track::Id& media::TrackList::after_empty_track() |
203 | 29 | { | 34 | { |
204 | 30 | static const media::Track::Id id{"/org/mpris/MediaPlayer2/TrackList/NoTrack"}; | 35 | static const media::Track::Id id{"/org/mpris/MediaPlayer2/TrackList/NoTrack"}; |
205 | 31 | 36 | ||
206 | === modified file 'src/core/media/track_list_implementation.cpp' | |||
207 | --- src/core/media/track_list_implementation.cpp 2015-10-23 14:39:34 +0000 | |||
208 | +++ src/core/media/track_list_implementation.cpp 2015-11-13 15:27:09 +0000 | |||
209 | @@ -118,6 +118,8 @@ | |||
210 | 118 | std::cout << "Adding Track::Id: " << id << std::endl; | 118 | std::cout << "Adding Track::Id: " << id << std::endl; |
211 | 119 | std::cout << "\tURI: " << uri << std::endl; | 119 | std::cout << "\tURI: " << uri << std::endl; |
212 | 120 | 120 | ||
213 | 121 | const auto current = get_current_track(); | ||
214 | 122 | |||
215 | 121 | auto result = tracks().update([this, id, position, make_current](TrackList::Container& container) | 123 | auto result = tracks().update([this, id, position, make_current](TrackList::Container& container) |
216 | 122 | { | 124 | { |
217 | 123 | auto it = std::find(container.begin(), container.end(), position); | 125 | auto it = std::find(container.begin(), container.end(), position); |
218 | @@ -133,20 +135,24 @@ | |||
219 | 133 | 135 | ||
220 | 134 | if (make_current) | 136 | if (make_current) |
221 | 135 | { | 137 | { |
222 | 138 | set_current_track(id); | ||
223 | 136 | // Don't automatically call stop() and play() in player_implementation.cpp on_go_to_track() | 139 | // Don't automatically call stop() and play() in player_implementation.cpp on_go_to_track() |
224 | 137 | // since this breaks video playback when using open_uri() (stop() and play() are unwanted in | 140 | // since this breaks video playback when using open_uri() (stop() and play() are unwanted in |
225 | 138 | // this scenario since the qtubuntu-media will handle this automatically) | 141 | // this scenario since the qtubuntu-media will handle this automatically) |
226 | 139 | const bool toggle_player_state = false; | 142 | const bool toggle_player_state = false; |
227 | 140 | go_to(id, toggle_player_state); | 143 | go_to(id, toggle_player_state); |
228 | 144 | } else { | ||
229 | 145 | set_current_track(current); | ||
230 | 141 | } | 146 | } |
231 | 142 | 147 | ||
232 | 143 | // Signal to the client that the current track has changed for the first track added to the TrackList | ||
233 | 144 | if (tracks().get().size() == 1) | ||
234 | 145 | on_track_changed()(id); | ||
235 | 146 | |||
236 | 147 | std::cout << "Signaling that we just added track id: " << id << std::endl; | 148 | std::cout << "Signaling that we just added track id: " << id << std::endl; |
237 | 148 | // Signal to the client that a track was added to the TrackList | 149 | // Signal to the client that a track was added to the TrackList |
238 | 149 | on_track_added()(id); | 150 | on_track_added()(id); |
239 | 151 | |||
240 | 152 | // Signal to the client that the current track has changed for the first | ||
241 | 153 | // track added to the TrackList | ||
242 | 154 | if (tracks().get().size() == 1) | ||
243 | 155 | on_track_changed()(id); | ||
244 | 150 | } | 156 | } |
245 | 151 | } | 157 | } |
246 | 152 | 158 | ||
247 | @@ -154,6 +160,9 @@ | |||
248 | 154 | { | 160 | { |
249 | 155 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 161 | std::cout << __PRETTY_FUNCTION__ << std::endl; |
250 | 156 | 162 | ||
251 | 163 | const auto current = get_current_track(); | ||
252 | 164 | |||
253 | 165 | Track::Id current_id; | ||
254 | 157 | ContainerURI tmp; | 166 | ContainerURI tmp; |
255 | 158 | for (const auto uri : uris) | 167 | for (const auto uri : uris) |
256 | 159 | { | 168 | { |
257 | @@ -185,12 +194,17 @@ | |||
258 | 185 | 194 | ||
259 | 186 | // Signal to the client that the current track has changed for the first track added to the TrackList | 195 | // Signal to the client that the current track has changed for the first track added to the TrackList |
260 | 187 | if (tracks().get().size() == 1) | 196 | if (tracks().get().size() == 1) |
262 | 188 | on_track_changed()(id); | 197 | current_id = id; |
263 | 189 | } | 198 | } |
264 | 190 | } | 199 | } |
265 | 191 | 200 | ||
266 | 201 | set_current_track(current); | ||
267 | 202 | |||
268 | 192 | std::cout << "Signaling that we just added " << tmp.size() << " tracks to the TrackList" << std::endl; | 203 | std::cout << "Signaling that we just added " << tmp.size() << " tracks to the TrackList" << std::endl; |
269 | 193 | on_tracks_added()(tmp); | 204 | on_tracks_added()(tmp); |
270 | 205 | |||
271 | 206 | if (!current_id.empty()) | ||
272 | 207 | on_track_changed()(current_id); | ||
273 | 194 | } | 208 | } |
274 | 195 | 209 | ||
275 | 196 | void media::TrackListImplementation::remove_track(const media::Track::Id& id) | 210 | void media::TrackListImplementation::remove_track(const media::Track::Id& id) |
276 | @@ -209,7 +223,6 @@ | |||
277 | 209 | 223 | ||
278 | 210 | on_track_removed()(id); | 224 | on_track_removed()(id); |
279 | 211 | } | 225 | } |
280 | 212 | |||
281 | 213 | } | 226 | } |
282 | 214 | 227 | ||
283 | 215 | void media::TrackListImplementation::go_to(const media::Track::Id& track, bool toggle_player_state) | 228 | void media::TrackListImplementation::go_to(const media::Track::Id& track, bool toggle_player_state) |
284 | @@ -266,26 +279,20 @@ | |||
285 | 266 | 279 | ||
286 | 267 | void media::TrackListImplementation::reset() | 280 | void media::TrackListImplementation::reset() |
287 | 268 | { | 281 | { |
288 | 282 | std::cout << __PRETTY_FUNCTION__ << std::endl; | ||
289 | 283 | |||
290 | 269 | // Make sure playback stops | 284 | // Make sure playback stops |
291 | 270 | on_end_of_tracklist()(); | 285 | on_end_of_tracklist()(); |
292 | 271 | // And make sure there is no "current" track | 286 | // And make sure there is no "current" track |
293 | 272 | media::TrackListSkeleton::reset(); | 287 | media::TrackListSkeleton::reset(); |
294 | 273 | 288 | ||
296 | 274 | auto result = tracks().update([this](TrackList::Container& container) | 289 | tracks().update([this](TrackList::Container& container) |
297 | 275 | { | 290 | { |
307 | 276 | TrackList::Container ids = container; | 291 | container.clear(); |
308 | 277 | 292 | on_track_list_reset()(); | |
309 | 278 | for (auto it = container.begin(); it != container.end(); ) { | 293 | |
301 | 279 | auto id = *it; | ||
302 | 280 | it = container.erase(it); | ||
303 | 281 | on_track_removed()(id); | ||
304 | 282 | } | ||
305 | 283 | |||
306 | 284 | container.resize(0); | ||
310 | 285 | d->track_counter = 0; | 294 | d->track_counter = 0; |
311 | 286 | 295 | ||
312 | 287 | return true; | 296 | return true; |
313 | 288 | }); | 297 | }); |
314 | 289 | |||
315 | 290 | (void) result; | ||
316 | 291 | } | 298 | } |
317 | 292 | 299 | ||
318 | === modified file 'src/core/media/track_list_skeleton.cpp' | |||
319 | --- src/core/media/track_list_skeleton.cpp 2015-11-13 15:27:09 +0000 | |||
320 | +++ src/core/media/track_list_skeleton.cpp 2015-11-13 15:27:09 +0000 | |||
321 | @@ -38,10 +38,14 @@ | |||
322 | 38 | 38 | ||
323 | 39 | #include <iostream> | 39 | #include <iostream> |
324 | 40 | #include <limits> | 40 | #include <limits> |
325 | 41 | #include <sstream> | ||
326 | 42 | #include <cstdint> | ||
327 | 41 | 43 | ||
328 | 42 | namespace dbus = core::dbus; | 44 | namespace dbus = core::dbus; |
329 | 43 | namespace media = core::ubuntu::media; | 45 | namespace media = core::ubuntu::media; |
330 | 44 | 46 | ||
331 | 47 | using namespace std; | ||
332 | 48 | |||
333 | 45 | struct media::TrackListSkeleton::Private | 49 | struct media::TrackListSkeleton::Private |
334 | 46 | { | 50 | { |
335 | 47 | Private(media::TrackListSkeleton* impl, const dbus::Bus::Ptr& bus, const dbus::Object::Ptr& object, | 51 | Private(media::TrackListSkeleton* impl, const dbus::Bus::Ptr& bus, const dbus::Object::Ptr& object, |
336 | @@ -63,6 +67,7 @@ | |||
337 | 63 | skeleton.signals.tracks_added, | 67 | skeleton.signals.tracks_added, |
338 | 64 | skeleton.signals.track_removed, | 68 | skeleton.signals.track_removed, |
339 | 65 | skeleton.signals.track_changed, | 69 | skeleton.signals.track_changed, |
340 | 70 | skeleton.signals.track_list_reset, | ||
341 | 66 | skeleton.signals.tracklist_replaced | 71 | skeleton.signals.tracklist_replaced |
342 | 67 | } | 72 | } |
343 | 68 | { | 73 | { |
344 | @@ -176,8 +181,53 @@ | |||
345 | 176 | media::Track::Id track; | 181 | media::Track::Id track; |
346 | 177 | msg->reader() >> track; | 182 | msg->reader() >> track; |
347 | 178 | 183 | ||
348 | 184 | auto id_it = find(impl->tracks().get().begin(), impl->tracks().get().end(), track); | ||
349 | 185 | if (id_it == impl->tracks().get().end()) { | ||
350 | 186 | ostringstream err_str; | ||
351 | 187 | err_str << "Track " << track << " not found in track list"; | ||
352 | 188 | cout << __PRETTY_FUNCTION__ << " WARNING " << err_str.str() << endl; | ||
353 | 189 | auto reply = dbus::Message::make_error( | ||
354 | 190 | msg, | ||
355 | 191 | mpris::TrackList::Error::TrackNotFound::name, | ||
356 | 192 | err_str.str()); | ||
357 | 193 | bus->send(reply); | ||
358 | 194 | return; | ||
359 | 195 | } | ||
360 | 196 | |||
361 | 197 | media::Track::Id next; | ||
362 | 198 | bool deleting_current = false; | ||
363 | 199 | |||
364 | 200 | if (id_it == impl->current_iterator()) { | ||
365 | 201 | cout << "Removing current track" << endl; | ||
366 | 202 | deleting_current = true; | ||
367 | 203 | |||
368 | 204 | if (current_track != empty_iterator) { | ||
369 | 205 | ++current_track; | ||
370 | 206 | |||
371 | 207 | if (current_track == impl->tracks().get().end() | ||
372 | 208 | && loop_status == media::Player::LoopStatus::playlist) | ||
373 | 209 | current_track = impl->tracks().get().begin(); | ||
374 | 210 | |||
375 | 211 | if (current_track == impl->tracks().get().end()) | ||
376 | 212 | current_track = empty_iterator; | ||
377 | 213 | else | ||
378 | 214 | next = *current_track; | ||
379 | 215 | } | ||
380 | 216 | } else if (current_track != empty_iterator) { | ||
381 | 217 | next = *current_track; | ||
382 | 218 | } | ||
383 | 219 | |||
384 | 179 | impl->remove_track(track); | 220 | impl->remove_track(track); |
385 | 180 | 221 | ||
386 | 222 | if (not next.empty()) { | ||
387 | 223 | current_track = find(impl->tracks().get().begin(), impl->tracks().get().end(), next); | ||
388 | 224 | |||
389 | 225 | if (deleting_current) { | ||
390 | 226 | const bool toggle_player_state = true; | ||
391 | 227 | impl->go_to(next, toggle_player_state); | ||
392 | 228 | } | ||
393 | 229 | } | ||
394 | 230 | |||
395 | 181 | auto reply = dbus::Message::make_method_return(msg); | 231 | auto reply = dbus::Message::make_method_return(msg); |
396 | 182 | bus->send(reply); | 232 | bus->send(reply); |
397 | 183 | } | 233 | } |
398 | @@ -221,12 +271,17 @@ | |||
399 | 221 | typedef core::dbus::Signal<mpris::TrackList::Signals::TracksAdded, mpris::TrackList::Signals::TracksAdded::ArgumentType> DBusTracksAddedSignal; | 271 | typedef core::dbus::Signal<mpris::TrackList::Signals::TracksAdded, mpris::TrackList::Signals::TracksAdded::ArgumentType> DBusTracksAddedSignal; |
400 | 222 | typedef core::dbus::Signal<mpris::TrackList::Signals::TrackRemoved, mpris::TrackList::Signals::TrackRemoved::ArgumentType> DBusTrackRemovedSignal; | 272 | typedef core::dbus::Signal<mpris::TrackList::Signals::TrackRemoved, mpris::TrackList::Signals::TrackRemoved::ArgumentType> DBusTrackRemovedSignal; |
401 | 223 | typedef core::dbus::Signal<mpris::TrackList::Signals::TrackChanged, mpris::TrackList::Signals::TrackChanged::ArgumentType> DBusTrackChangedSignal; | 273 | typedef core::dbus::Signal<mpris::TrackList::Signals::TrackChanged, mpris::TrackList::Signals::TrackChanged::ArgumentType> DBusTrackChangedSignal; |
402 | 274 | typedef core::dbus::Signal< | ||
403 | 275 | mpris::TrackList::Signals::TrackListReset, | ||
404 | 276 | mpris::TrackList::Signals::TrackListReset::ArgumentType> | ||
405 | 277 | DBusTrackListResetSignal; | ||
406 | 224 | typedef core::dbus::Signal<mpris::TrackList::Signals::TrackListReplaced, mpris::TrackList::Signals::TrackListReplaced::ArgumentType> DBusTrackListReplacedSignal; | 278 | typedef core::dbus::Signal<mpris::TrackList::Signals::TrackListReplaced, mpris::TrackList::Signals::TrackListReplaced::ArgumentType> DBusTrackListReplacedSignal; |
407 | 225 | 279 | ||
408 | 226 | Signals(const std::shared_ptr<DBusTrackAddedSignal>& remote_track_added, | 280 | Signals(const std::shared_ptr<DBusTrackAddedSignal>& remote_track_added, |
409 | 227 | const std::shared_ptr<DBusTracksAddedSignal>& remote_tracks_added, | 281 | const std::shared_ptr<DBusTracksAddedSignal>& remote_tracks_added, |
410 | 228 | const std::shared_ptr<DBusTrackRemovedSignal>& remote_track_removed, | 282 | const std::shared_ptr<DBusTrackRemovedSignal>& remote_track_removed, |
411 | 229 | const std::shared_ptr<DBusTrackChangedSignal>& remote_track_changed, | 283 | const std::shared_ptr<DBusTrackChangedSignal>& remote_track_changed, |
412 | 284 | const std::shared_ptr<DBusTrackListResetSignal>& remote_track_list_reset, | ||
413 | 230 | const std::shared_ptr<DBusTrackListReplacedSignal>& remote_track_list_replaced) | 285 | const std::shared_ptr<DBusTrackListReplacedSignal>& remote_track_list_replaced) |
414 | 231 | { | 286 | { |
415 | 232 | // Connect all of the MPRIS interface signals to be emitted over dbus | 287 | // Connect all of the MPRIS interface signals to be emitted over dbus |
416 | @@ -245,6 +300,11 @@ | |||
417 | 245 | remote_track_removed->emit(id); | 300 | remote_track_removed->emit(id); |
418 | 246 | }); | 301 | }); |
419 | 247 | 302 | ||
420 | 303 | on_track_list_reset.connect([remote_track_list_reset]() | ||
421 | 304 | { | ||
422 | 305 | remote_track_list_reset->emit(); | ||
423 | 306 | }); | ||
424 | 307 | |||
425 | 248 | on_track_changed.connect([remote_track_changed](const media::Track::Id &id) | 308 | on_track_changed.connect([remote_track_changed](const media::Track::Id &id) |
426 | 249 | { | 309 | { |
427 | 250 | remote_track_changed->emit(id); | 310 | remote_track_changed->emit(id); |
428 | @@ -259,6 +319,7 @@ | |||
429 | 259 | core::Signal<Track::Id> on_track_added; | 319 | core::Signal<Track::Id> on_track_added; |
430 | 260 | core::Signal<TrackList::ContainerURI> on_tracks_added; | 320 | core::Signal<TrackList::ContainerURI> on_tracks_added; |
431 | 261 | core::Signal<Track::Id> on_track_removed; | 321 | core::Signal<Track::Id> on_track_removed; |
432 | 322 | core::Signal<void> on_track_list_reset; | ||
433 | 262 | core::Signal<Track::Id> on_track_changed; | 323 | core::Signal<Track::Id> on_track_changed; |
434 | 263 | core::Signal<TrackList::ContainerTrackIdTuple> on_track_list_replaced; | 324 | core::Signal<TrackList::ContainerTrackIdTuple> on_track_list_replaced; |
435 | 264 | core::Signal<std::pair<Track::Id, bool>> on_go_to_track; | 325 | core::Signal<std::pair<Track::Id, bool>> on_go_to_track; |
436 | @@ -401,6 +462,7 @@ | |||
437 | 401 | 462 | ||
438 | 402 | if (do_go_to_next_track) | 463 | if (do_go_to_next_track) |
439 | 403 | { | 464 | { |
440 | 465 | cout << "next track id is " << *(current_iterator()) << endl; | ||
441 | 404 | on_track_changed()(*(current_iterator())); | 466 | on_track_changed()(*(current_iterator())); |
442 | 405 | // Don't automatically call stop() and play() in player_implementation.cpp on_go_to_track() | 467 | // Don't automatically call stop() and play() in player_implementation.cpp on_go_to_track() |
443 | 406 | // since this breaks video playback when using open_uri() (stop() and play() are unwanted in | 468 | // since this breaks video playback when using open_uri() (stop() and play() are unwanted in |
444 | @@ -425,15 +487,15 @@ | |||
445 | 425 | } | 487 | } |
446 | 426 | 488 | ||
447 | 427 | bool do_go_to_previous_track = false; | 489 | bool do_go_to_previous_track = false; |
450 | 428 | bool repeat_current_track = false; | 490 | // Position is measured in nanoseconds |
451 | 429 | const uint64_t max_position = 4 * 1000; | 491 | const uint64_t max_position = 5 * UINT64_C(1000000000); |
452 | 430 | 492 | ||
454 | 431 | // If we're playing the current already for some time we will | 493 | // If we're playing the current track for > max_position time then |
455 | 432 | // repeat it from the beginning | 494 | // repeat it from the beginning |
456 | 433 | if (d->current_position > max_position) | 495 | if (d->current_position > max_position) |
457 | 434 | { | 496 | { |
458 | 435 | std::cout << "Repeating current track..." << std::endl; | 497 | std::cout << "Repeating current track..." << std::endl; |
460 | 436 | repeat_current_track = true; | 498 | do_go_to_previous_track = true; |
461 | 437 | } | 499 | } |
462 | 438 | // Loop on the current track forever | 500 | // Loop on the current track forever |
463 | 439 | else if (d->loop_status == media::Player::LoopStatus::track) | 501 | else if (d->loop_status == media::Player::LoopStatus::track) |
464 | @@ -465,7 +527,7 @@ | |||
465 | 465 | } | 527 | } |
466 | 466 | } | 528 | } |
467 | 467 | 529 | ||
469 | 468 | if (do_go_to_previous_track && !repeat_current_track) | 530 | if (do_go_to_previous_track) |
470 | 469 | { | 531 | { |
471 | 470 | on_track_changed()(*(current_iterator())); | 532 | on_track_changed()(*(current_iterator())); |
472 | 471 | // Don't automatically call stop() and play() in player_implementation.cpp on_go_to_track() | 533 | // Don't automatically call stop() and play() in player_implementation.cpp on_go_to_track() |
473 | @@ -510,6 +572,21 @@ | |||
474 | 510 | d->current_track = d->empty_iterator; | 572 | d->current_track = d->empty_iterator; |
475 | 511 | } | 573 | } |
476 | 512 | 574 | ||
477 | 575 | media::Track::Id media::TrackListSkeleton::get_current_track(void) | ||
478 | 576 | { | ||
479 | 577 | if (d->current_track == d->empty_iterator || tracks().get().empty()) | ||
480 | 578 | return media::Track::Id{}; | ||
481 | 579 | |||
482 | 580 | return *(current_iterator()); | ||
483 | 581 | } | ||
484 | 582 | |||
485 | 583 | void media::TrackListSkeleton::set_current_track(const media::Track::Id& id) | ||
486 | 584 | { | ||
487 | 585 | const auto id_it = find(tracks().get().begin(), tracks().get().end(), id); | ||
488 | 586 | if (id_it != tracks().get().end()) | ||
489 | 587 | d->current_track = id_it; | ||
490 | 588 | } | ||
491 | 589 | |||
492 | 513 | const core::Property<bool>& media::TrackListSkeleton::can_edit_tracks() const | 590 | const core::Property<bool>& media::TrackListSkeleton::can_edit_tracks() const |
493 | 514 | { | 591 | { |
494 | 515 | return *d->skeleton.properties.can_edit_tracks; | 592 | return *d->skeleton.properties.can_edit_tracks; |
495 | @@ -527,7 +604,6 @@ | |||
496 | 527 | 604 | ||
497 | 528 | void media::TrackListSkeleton::on_position_changed(uint64_t position) | 605 | void media::TrackListSkeleton::on_position_changed(uint64_t position) |
498 | 529 | { | 606 | { |
499 | 530 | std::cout << "TrackListSkeleton::on_position_changed: position = " << position << std::endl; | ||
500 | 531 | d->current_position = position; | 607 | d->current_position = position; |
501 | 532 | } | 608 | } |
502 | 533 | 609 | ||
503 | @@ -543,21 +619,21 @@ | |||
504 | 543 | 619 | ||
505 | 544 | void media::TrackListSkeleton::on_shuffle_changed(bool shuffle) | 620 | void media::TrackListSkeleton::on_shuffle_changed(bool shuffle) |
506 | 545 | { | 621 | { |
507 | 622 | if (tracks().get().empty()) | ||
508 | 623 | return; | ||
509 | 624 | |||
510 | 625 | const auto current_id = get_current_track(); | ||
511 | 626 | |||
512 | 627 | cout << __PRETTY_FUNCTION__ << " " << shuffle | ||
513 | 628 | << " current track: " << current_id << endl; | ||
514 | 629 | |||
515 | 546 | if (shuffle) | 630 | if (shuffle) |
516 | 547 | shuffle_tracks(); | 631 | shuffle_tracks(); |
517 | 548 | else | 632 | else |
518 | 549 | { | ||
519 | 550 | // Save the current Track::Id of what's currently playing to restore after unshuffle | ||
520 | 551 | const media::Track::Id current_id = *(current_iterator()); | ||
521 | 552 | |||
522 | 553 | unshuffle_tracks(); | 633 | unshuffle_tracks(); |
523 | 554 | 634 | ||
530 | 555 | // Since we use assign() in unshuffle_tracks, which invalidates existing iterators, we need | 635 | // Shuffling and unshuffling invalidates iterators, so we re-create current_track |
531 | 556 | // to make sure that current is pointing to the right place | 636 | set_current_track(current_id); |
526 | 557 | auto it = std::find(tracks().get().begin(), tracks().get().end(), current_id); | ||
527 | 558 | if (it != tracks().get().end()) | ||
528 | 559 | d->current_track = it; | ||
529 | 560 | } | ||
532 | 561 | } | 637 | } |
533 | 562 | 638 | ||
534 | 563 | const core::Property<media::TrackList::Container>& media::TrackListSkeleton::tracks() const | 639 | const core::Property<media::TrackList::Container>& media::TrackListSkeleton::tracks() const |
535 | @@ -587,6 +663,11 @@ | |||
536 | 587 | return d->signals.on_track_removed; | 663 | return d->signals.on_track_removed; |
537 | 588 | } | 664 | } |
538 | 589 | 665 | ||
539 | 666 | const core::Signal<void>& media::TrackListSkeleton::on_track_list_reset() const | ||
540 | 667 | { | ||
541 | 668 | return d->signals.on_track_list_reset; | ||
542 | 669 | } | ||
543 | 670 | |||
544 | 590 | const core::Signal<media::Track::Id>& media::TrackListSkeleton::on_track_changed() const | 671 | const core::Signal<media::Track::Id>& media::TrackListSkeleton::on_track_changed() const |
545 | 591 | { | 672 | { |
546 | 592 | return d->signals.on_track_changed; | 673 | return d->signals.on_track_changed; |
547 | @@ -622,6 +703,11 @@ | |||
548 | 622 | return d->signals.on_track_removed; | 703 | return d->signals.on_track_removed; |
549 | 623 | } | 704 | } |
550 | 624 | 705 | ||
551 | 706 | core::Signal<void>& media::TrackListSkeleton::on_track_list_reset() | ||
552 | 707 | { | ||
553 | 708 | return d->signals.on_track_list_reset; | ||
554 | 709 | } | ||
555 | 710 | |||
556 | 625 | core::Signal<media::Track::Id>& media::TrackListSkeleton::on_track_changed() | 711 | core::Signal<media::Track::Id>& media::TrackListSkeleton::on_track_changed() |
557 | 626 | { | 712 | { |
558 | 627 | return d->signals.on_track_changed; | 713 | return d->signals.on_track_changed; |
559 | 628 | 714 | ||
560 | === modified file 'src/core/media/track_list_skeleton.h' | |||
561 | --- src/core/media/track_list_skeleton.h 2015-11-13 15:27:09 +0000 | |||
562 | +++ src/core/media/track_list_skeleton.h 2015-11-13 15:27:09 +0000 | |||
563 | @@ -57,6 +57,7 @@ | |||
564 | 57 | const core::Signal<ContainerURI>& on_tracks_added() const; | 57 | const core::Signal<ContainerURI>& on_tracks_added() const; |
565 | 58 | core::Signal<ContainerURI>& on_tracks_added(); | 58 | core::Signal<ContainerURI>& on_tracks_added(); |
566 | 59 | const core::Signal<Track::Id>& on_track_removed() const; | 59 | const core::Signal<Track::Id>& on_track_removed() const; |
567 | 60 | const core::Signal<void>& on_track_list_reset() const; | ||
568 | 60 | const core::Signal<Track::Id>& on_track_changed() const; | 61 | const core::Signal<Track::Id>& on_track_changed() const; |
569 | 61 | core::Signal<Track::Id>& on_track_changed(); | 62 | core::Signal<Track::Id>& on_track_changed(); |
570 | 62 | const core::Signal<std::pair<Track::Id, bool>>& on_go_to_track() const; | 63 | const core::Signal<std::pair<Track::Id, bool>>& on_go_to_track() const; |
571 | @@ -64,6 +65,7 @@ | |||
572 | 64 | const core::Signal<void>& on_end_of_tracklist() const; | 65 | const core::Signal<void>& on_end_of_tracklist() const; |
573 | 65 | core::Signal<void>& on_end_of_tracklist(); | 66 | core::Signal<void>& on_end_of_tracklist(); |
574 | 66 | core::Signal<Track::Id>& on_track_removed(); | 67 | core::Signal<Track::Id>& on_track_removed(); |
575 | 68 | core::Signal<void>& on_track_list_reset(); | ||
576 | 67 | 69 | ||
577 | 68 | core::Property<Container>& tracks(); | 70 | core::Property<Container>& tracks(); |
578 | 69 | void on_loop_status_changed(const core::ubuntu::media::Player::LoopStatus& loop_status); | 71 | void on_loop_status_changed(const core::ubuntu::media::Player::LoopStatus& loop_status); |
579 | @@ -80,6 +82,8 @@ | |||
580 | 80 | inline bool is_last_track(const ConstIterator &it); | 82 | inline bool is_last_track(const ConstIterator &it); |
581 | 81 | inline const TrackList::ConstIterator& current_iterator(); | 83 | inline const TrackList::ConstIterator& current_iterator(); |
582 | 82 | void reset_current_iterator_if_needed(); | 84 | void reset_current_iterator_if_needed(); |
583 | 85 | media::Track::Id get_current_track(void); | ||
584 | 86 | void set_current_track(const media::Track::Id& id); | ||
585 | 83 | 87 | ||
586 | 84 | core::Property<bool>& can_edit_tracks(); | 88 | core::Property<bool>& can_edit_tracks(); |
587 | 85 | 89 | ||
588 | 86 | 90 | ||
589 | === modified file 'src/core/media/track_list_stub.cpp' | |||
590 | --- src/core/media/track_list_stub.cpp 2015-10-23 14:39:34 +0000 | |||
591 | +++ src/core/media/track_list_stub.cpp 2015-11-13 15:27:09 +0000 | |||
592 | @@ -54,6 +54,7 @@ | |||
593 | 54 | object->get_signal<mpris::TrackList::Signals::TrackAdded>(), | 54 | object->get_signal<mpris::TrackList::Signals::TrackAdded>(), |
594 | 55 | object->get_signal<mpris::TrackList::Signals::TracksAdded>(), | 55 | object->get_signal<mpris::TrackList::Signals::TracksAdded>(), |
595 | 56 | object->get_signal<mpris::TrackList::Signals::TrackRemoved>(), | 56 | object->get_signal<mpris::TrackList::Signals::TrackRemoved>(), |
596 | 57 | object->get_signal<mpris::TrackList::Signals::TrackListReset>(), | ||
597 | 57 | object->get_signal<mpris::TrackList::Signals::TrackListReplaced>(), | 58 | object->get_signal<mpris::TrackList::Signals::TrackListReplaced>(), |
598 | 58 | object->get_signal<mpris::TrackList::Signals::TrackChanged>() | 59 | object->get_signal<mpris::TrackList::Signals::TrackChanged>() |
599 | 59 | } | 60 | } |
600 | @@ -73,17 +74,23 @@ | |||
601 | 73 | typedef core::dbus::Signal<mpris::TrackList::Signals::TrackAdded, mpris::TrackList::Signals::TrackAdded::ArgumentType> DBusTrackAddedSignal; | 74 | typedef core::dbus::Signal<mpris::TrackList::Signals::TrackAdded, mpris::TrackList::Signals::TrackAdded::ArgumentType> DBusTrackAddedSignal; |
602 | 74 | typedef core::dbus::Signal<mpris::TrackList::Signals::TracksAdded, mpris::TrackList::Signals::TracksAdded::ArgumentType> DBusTracksAddedSignal; | 75 | typedef core::dbus::Signal<mpris::TrackList::Signals::TracksAdded, mpris::TrackList::Signals::TracksAdded::ArgumentType> DBusTracksAddedSignal; |
603 | 75 | typedef core::dbus::Signal<mpris::TrackList::Signals::TrackRemoved, mpris::TrackList::Signals::TrackRemoved::ArgumentType> DBusTrackRemovedSignal; | 76 | typedef core::dbus::Signal<mpris::TrackList::Signals::TrackRemoved, mpris::TrackList::Signals::TrackRemoved::ArgumentType> DBusTrackRemovedSignal; |
604 | 77 | typedef core::dbus::Signal< | ||
605 | 78 | mpris::TrackList::Signals::TrackListReset, | ||
606 | 79 | mpris::TrackList::Signals::TrackListReset::ArgumentType> | ||
607 | 80 | DBusTrackListResetSignal; | ||
608 | 76 | typedef core::dbus::Signal<mpris::TrackList::Signals::TrackListReplaced, mpris::TrackList::Signals::TrackListReplaced::ArgumentType> DBusTrackListReplacedSignal; | 81 | typedef core::dbus::Signal<mpris::TrackList::Signals::TrackListReplaced, mpris::TrackList::Signals::TrackListReplaced::ArgumentType> DBusTrackListReplacedSignal; |
609 | 77 | typedef core::dbus::Signal<mpris::TrackList::Signals::TrackChanged, mpris::TrackList::Signals::TrackChanged::ArgumentType> DBusTrackChangedSignal; | 82 | typedef core::dbus::Signal<mpris::TrackList::Signals::TrackChanged, mpris::TrackList::Signals::TrackChanged::ArgumentType> DBusTrackChangedSignal; |
610 | 78 | 83 | ||
611 | 79 | Signals(const std::shared_ptr<DBusTrackAddedSignal>& track_added, | 84 | Signals(const std::shared_ptr<DBusTrackAddedSignal>& track_added, |
612 | 80 | const std::shared_ptr<DBusTracksAddedSignal>& tracks_added, | 85 | const std::shared_ptr<DBusTracksAddedSignal>& tracks_added, |
613 | 81 | const std::shared_ptr<DBusTrackRemovedSignal>& track_removed, | 86 | const std::shared_ptr<DBusTrackRemovedSignal>& track_removed, |
614 | 87 | const std::shared_ptr<DBusTrackListResetSignal>& track_list_reset, | ||
615 | 82 | const std::shared_ptr<DBusTrackListReplacedSignal>& track_list_replaced, | 88 | const std::shared_ptr<DBusTrackListReplacedSignal>& track_list_replaced, |
616 | 83 | const std::shared_ptr<DBusTrackChangedSignal>& track_changed) | 89 | const std::shared_ptr<DBusTrackChangedSignal>& track_changed) |
617 | 84 | : on_track_added(), | 90 | : on_track_added(), |
618 | 85 | on_tracks_added(), | 91 | on_tracks_added(), |
619 | 86 | on_track_removed(), | 92 | on_track_removed(), |
620 | 93 | on_track_list_reset(), | ||
621 | 87 | on_track_list_replaced(), | 94 | on_track_list_replaced(), |
622 | 88 | on_track_changed(), | 95 | on_track_changed(), |
623 | 89 | dbus | 96 | dbus |
624 | @@ -91,6 +98,7 @@ | |||
625 | 91 | track_added, | 98 | track_added, |
626 | 92 | tracks_added, | 99 | tracks_added, |
627 | 93 | track_removed, | 100 | track_removed, |
628 | 101 | track_list_reset, | ||
629 | 94 | track_list_replaced, | 102 | track_list_replaced, |
630 | 95 | track_changed, | 103 | track_changed, |
631 | 96 | } | 104 | } |
632 | @@ -113,9 +121,15 @@ | |||
633 | 113 | on_track_removed(id); | 121 | on_track_removed(id); |
634 | 114 | }); | 122 | }); |
635 | 115 | 123 | ||
636 | 124 | dbus.on_track_list_reset->connect([this](void) | ||
637 | 125 | { | ||
638 | 126 | std::cout << "OnTrackListReset signal arrived via the bus." << std::endl; | ||
639 | 127 | on_track_list_reset(); | ||
640 | 128 | }); | ||
641 | 129 | |||
642 | 116 | dbus.on_track_list_replaced->connect([this](const media::TrackList::ContainerTrackIdTuple& list) | 130 | dbus.on_track_list_replaced->connect([this](const media::TrackList::ContainerTrackIdTuple& list) |
643 | 117 | { | 131 | { |
645 | 118 | std::cout << "OnTrackListRemoved signal arrived via the bus." << std::endl; | 132 | std::cout << "OnTrackListReplaced signal arrived via the bus." << std::endl; |
646 | 119 | on_track_list_replaced(list); | 133 | on_track_list_replaced(list); |
647 | 120 | }); | 134 | }); |
648 | 121 | 135 | ||
649 | @@ -129,6 +143,7 @@ | |||
650 | 129 | core::Signal<Track::Id> on_track_added; | 143 | core::Signal<Track::Id> on_track_added; |
651 | 130 | core::Signal<media::TrackList::ContainerURI> on_tracks_added; | 144 | core::Signal<media::TrackList::ContainerURI> on_tracks_added; |
652 | 131 | core::Signal<Track::Id> on_track_removed; | 145 | core::Signal<Track::Id> on_track_removed; |
653 | 146 | core::Signal<void> on_track_list_reset; | ||
654 | 132 | core::Signal<media::TrackList::ContainerTrackIdTuple> on_track_list_replaced; | 147 | core::Signal<media::TrackList::ContainerTrackIdTuple> on_track_list_replaced; |
655 | 133 | core::Signal<Track::Id> on_track_changed; | 148 | core::Signal<Track::Id> on_track_changed; |
656 | 134 | core::Signal<std::pair<Track::Id, bool>> on_go_to_track; | 149 | core::Signal<std::pair<Track::Id, bool>> on_go_to_track; |
657 | @@ -139,6 +154,7 @@ | |||
658 | 139 | std::shared_ptr<DBusTrackAddedSignal> on_track_added; | 154 | std::shared_ptr<DBusTrackAddedSignal> on_track_added; |
659 | 140 | std::shared_ptr<DBusTracksAddedSignal> on_tracks_added; | 155 | std::shared_ptr<DBusTracksAddedSignal> on_tracks_added; |
660 | 141 | std::shared_ptr<DBusTrackRemovedSignal> on_track_removed; | 156 | std::shared_ptr<DBusTrackRemovedSignal> on_track_removed; |
661 | 157 | std::shared_ptr<DBusTrackListResetSignal> on_track_list_reset; | ||
662 | 142 | std::shared_ptr<DBusTrackListReplacedSignal> on_track_list_replaced; | 158 | std::shared_ptr<DBusTrackListReplacedSignal> on_track_list_replaced; |
663 | 143 | std::shared_ptr<DBusTrackChangedSignal> on_track_changed; | 159 | std::shared_ptr<DBusTrackChangedSignal> on_track_changed; |
664 | 144 | } dbus; | 160 | } dbus; |
665 | @@ -237,7 +253,13 @@ | |||
666 | 237 | track); | 253 | track); |
667 | 238 | 254 | ||
668 | 239 | if (op.is_error()) | 255 | if (op.is_error()) |
670 | 240 | throw std::runtime_error("Problem removing track: " + op.error()); | 256 | { |
671 | 257 | if (op.error().name() == | ||
672 | 258 | mpris::TrackList::Error::TrackNotFound::name) | ||
673 | 259 | throw media::TrackList::Errors::TrackNotFound{}; | ||
674 | 260 | else | ||
675 | 261 | throw std::runtime_error{"Problem removing track: " + op.error().print()}; | ||
676 | 262 | } | ||
677 | 241 | } | 263 | } |
678 | 242 | 264 | ||
679 | 243 | void media::TrackListStub::go_to(const media::Track::Id& track, bool toggle_player_state) | 265 | void media::TrackListStub::go_to(const media::Track::Id& track, bool toggle_player_state) |
680 | @@ -300,6 +322,11 @@ | |||
681 | 300 | return d->signals.on_track_removed; | 322 | return d->signals.on_track_removed; |
682 | 301 | } | 323 | } |
683 | 302 | 324 | ||
684 | 325 | const core::Signal<void>& media::TrackListStub::on_track_list_reset() const | ||
685 | 326 | { | ||
686 | 327 | return d->signals.on_track_list_reset; | ||
687 | 328 | } | ||
688 | 329 | |||
689 | 303 | const core::Signal<media::Track::Id>& media::TrackListStub::on_track_changed() const | 330 | const core::Signal<media::Track::Id>& media::TrackListStub::on_track_changed() const |
690 | 304 | { | 331 | { |
691 | 305 | return d->signals.on_track_changed; | 332 | return d->signals.on_track_changed; |
692 | 306 | 333 | ||
693 | === modified file 'src/core/media/track_list_stub.h' | |||
694 | --- src/core/media/track_list_stub.h 2015-10-21 19:40:20 +0000 | |||
695 | +++ src/core/media/track_list_stub.h 2015-11-13 15:27:09 +0000 | |||
696 | @@ -65,6 +65,7 @@ | |||
697 | 65 | const core::Signal<Track::Id>& on_track_added() const; | 65 | const core::Signal<Track::Id>& on_track_added() const; |
698 | 66 | const core::Signal<ContainerURI>& on_tracks_added() const; | 66 | const core::Signal<ContainerURI>& on_tracks_added() const; |
699 | 67 | const core::Signal<Track::Id>& on_track_removed() const; | 67 | const core::Signal<Track::Id>& on_track_removed() const; |
700 | 68 | const core::Signal<void>& on_track_list_reset() const; | ||
701 | 68 | const core::Signal<Track::Id>& on_track_changed() const; | 69 | const core::Signal<Track::Id>& on_track_changed() const; |
702 | 69 | const core::Signal<std::pair<Track::Id, bool>>& on_go_to_track() const; | 70 | const core::Signal<std::pair<Track::Id, bool>>& on_go_to_track() const; |
703 | 70 | const core::Signal<void>& on_end_of_tracklist() const; | 71 | const core::Signal<void>& on_end_of_tracklist() const; |
A few comments inline.