Merge lp:~phablet-team/media-hub/fix-1506953 into lp:media-hub

Proposed by Jim Hodapp
Status: Merged
Approved by: Konrad Zapałowicz
Approved revision: 204
Merged at revision: 202
Proposed branch: lp:~phablet-team/media-hub/fix-1506953
Merge into: lp:media-hub
Diff against target: 346 lines (+119/-23)
11 files modified
CMakeLists.txt (+2/-2)
debian/changelog (+7/-0)
include/core/media/service.h (+5/-0)
include/core/media/track.h (+0/-1)
src/core/media/player_stub.cpp (+2/-0)
src/core/media/service_implementation.cpp (+15/-0)
src/core/media/service_implementation.h (+3/-0)
src/core/media/service_skeleton.cpp (+14/-0)
src/core/media/service_skeleton.h (+3/-0)
src/core/media/service_stub.cpp (+52/-18)
src/core/media/service_stub.h (+16/-2)
To merge this branch: bzr merge lp:~phablet-team/media-hub/fix-1506953
Reviewer Review Type Date Requested Status
Konrad Zapałowicz (community) code Approve
Review via email: mp+300531@code.launchpad.net

Commit message

Emit a signal on the media-hub-client side when the dbus media-hub-server to client connection unregisters and re-registers.

Description of the change

Emit a signal on the media-hub-client side when the dbus media-hub-server to client connection unregisters and re-registers.

To post a comment you must log in.
202. By Jim Hodapp

Merge with upstream

203. By Jim Hodapp

Version bump for API change

204. By Jim Hodapp

Get rid of unnecessary debug statements

Revision history for this message
Konrad Zapałowicz (kzapalowicz) wrote :

LGTM

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-07-07 19:06:48 +0000
3+++ CMakeLists.txt 2016-07-19 21:22:30 +0000
4@@ -20,11 +20,11 @@
5 # we define the version to be 5.0.0
6 if (${DISTRO_CODENAME} STREQUAL "vivid")
7 set(UBUNTU_MEDIA_HUB_VERSION_MAJOR 4)
8- set(UBUNTU_MEDIA_HUB_VERSION_MINOR 4)
9+ set(UBUNTU_MEDIA_HUB_VERSION_MINOR 5)
10 set(UBUNTU_MEDIA_HUB_VERSION_PATCH 0)
11 else ()
12 set(UBUNTU_MEDIA_HUB_VERSION_MAJOR 5)
13- set(UBUNTU_MEDIA_HUB_VERSION_MINOR 1)
14+ set(UBUNTU_MEDIA_HUB_VERSION_MINOR 2)
15 set(UBUNTU_MEDIA_HUB_VERSION_PATCH 0)
16 endif()
17 endif()
18
19=== modified file 'debian/changelog'
20--- debian/changelog 2016-07-11 01:21:59 +0000
21+++ debian/changelog 2016-07-19 21:22:30 +0000
22@@ -1,3 +1,10 @@
23+media-hub (4.5.0+16.10.20160711-0ubuntu2) UNRELEASED; urgency=medium
24+
25+ * Emit client side signal when the dbus connection between
26+ media-hub-server and -client unregisters/registers
27+
28+ -- Jim Hodapp <jim.hodapp@canonical.com> Tue, 19 Jul 2016 17:15:35 -0400
29+
30 media-hub (4.4.0+16.10.20160711-0ubuntu1) yakkety; urgency=medium
31
32 * Add support for buffering signal.
33
34=== modified file 'include/core/media/service.h'
35--- include/core/media/service.h 2016-05-03 13:59:14 +0000
36+++ include/core/media/service.h 2016-07-19 21:22:30 +0000
37@@ -63,6 +63,11 @@
38 /** @brief Pauses sessions other than the supplied one. */
39 virtual void pause_other_sessions(Player::PlayerKey) = 0;
40
41+ /** @brief Signals when the media-hub server disappears from the bus **/
42+ virtual const core::Signal<void>& service_disconnected() const = 0;
43+ /** @brief Signals when the media-hub server reappears from the bus **/
44+ virtual const core::Signal<void>& service_reconnected() const = 0;
45+
46 protected:
47 Service() = default;
48 };
49
50=== modified file 'include/core/media/track.h'
51--- include/core/media/track.h 2016-07-11 01:21:38 +0000
52+++ include/core/media/track.h 2016-07-19 21:22:30 +0000
53@@ -26,7 +26,6 @@
54 #include <string>
55 #include <vector>
56
57-
58 namespace core
59 {
60 namespace ubuntu
61
62=== modified file 'src/core/media/player_stub.cpp'
63--- src/core/media/player_stub.cpp 2016-06-16 02:34:40 +0000
64+++ src/core/media/player_stub.cpp 2016-07-19 21:22:30 +0000
65@@ -268,11 +268,13 @@
66 dbus::types::ObjectPath(
67 d->object->path().as_string() + "/TrackList")));
68 }
69+
70 return d->track_list;
71 }
72
73 media::Player::PlayerKey media::PlayerStub::key() const
74 {
75+ MH_DEBUG("key(): %s", d->key);
76 return d->key;
77 }
78
79
80=== modified file 'src/core/media/service_implementation.cpp'
81--- src/core/media/service_implementation.cpp 2016-05-03 13:59:14 +0000
82+++ src/core/media/service_implementation.cpp 2016-07-19 21:22:30 +0000
83@@ -183,6 +183,7 @@
84 std::shared_ptr<media::Player> media::ServiceImplementation::create_session(
85 const media::Player::Configuration& conf)
86 {
87+ // Create a new Player
88 auto player = std::make_shared<media::PlayerImplementation<media::PlayerSkeleton>>
89 (media::PlayerImplementation<media::PlayerSkeleton>::Configuration
90 {
91@@ -360,3 +361,17 @@
92 d->resume_key = std::numeric_limits<std::uint32_t>::max();
93 }
94 }
95+
96+const core::Signal<void>& media::ServiceImplementation::service_disconnected() const
97+{
98+ throw std::runtime_error("This signal is only accessible from the ServiceStub");
99+ static const core::Signal<void> s;
100+ return s;
101+}
102+
103+const core::Signal<void>& media::ServiceImplementation::service_reconnected() const
104+{
105+ throw std::runtime_error("This signal is only accessible from the ServiceStub");
106+ static const core::Signal<void> s;
107+ return s;
108+}
109
110=== modified file 'src/core/media/service_implementation.h'
111--- src/core/media/service_implementation.h 2016-05-03 13:59:14 +0000
112+++ src/core/media/service_implementation.h 2016-07-19 21:22:30 +0000
113@@ -51,6 +51,9 @@
114 std::shared_ptr<Player> resume_session(Player::PlayerKey key);
115 void pause_other_sessions(Player::PlayerKey key);
116
117+ const core::Signal<void>& service_disconnected() const;
118+ const core::Signal<void>& service_reconnected() const;
119+
120 private:
121 void pause_all_multimedia_sessions(bool resume_play_after_phonecall);
122 void resume_paused_multimedia_sessions(bool resume_video_sessions = true);
123
124=== modified file 'src/core/media/service_skeleton.cpp'
125--- src/core/media/service_skeleton.cpp 2016-06-06 20:28:50 +0000
126+++ src/core/media/service_skeleton.cpp 2016-07-19 21:22:30 +0000
127@@ -935,3 +935,17 @@
128 {
129 access_bus()->stop();
130 }
131+
132+const core::Signal<void>& media::ServiceSkeleton::service_disconnected() const
133+{
134+ throw std::runtime_error("This signal is only accessible from the ServiceStub");
135+ static const core::Signal<void> s;
136+ return s;
137+}
138+
139+const core::Signal<void>& media::ServiceSkeleton::service_reconnected() const
140+{
141+ throw std::runtime_error("This signal is only accessible from the ServiceStub");
142+ static const core::Signal<void> s;
143+ return s;
144+}
145
146=== modified file 'src/core/media/service_skeleton.h'
147--- src/core/media/service_skeleton.h 2016-05-03 15:22:12 +0000
148+++ src/core/media/service_skeleton.h 2016-07-19 21:22:30 +0000
149@@ -67,6 +67,9 @@
150 void run();
151 void stop();
152
153+ virtual const core::Signal<void>& service_disconnected() const;
154+ virtual const core::Signal<void>& service_reconnected() const;
155+
156 private:
157 struct Private;
158 std::shared_ptr<Private> d;
159
160=== modified file 'src/core/media/service_stub.cpp'
161--- src/core/media/service_stub.cpp 2016-05-03 13:59:14 +0000
162+++ src/core/media/service_stub.cpp 2016-07-19 21:22:30 +0000
163@@ -24,26 +24,46 @@
164
165 #include "mpris/service.h"
166
167+#include "core/media/logger/logger.h"
168+
169 namespace dbus = core::dbus;
170 namespace media = core::ubuntu::media;
171
172-struct media::ServiceStub::Private
173-{
174- dbus::Object::Ptr object;
175-};
176-
177 media::ServiceStub::ServiceStub()
178 : core::dbus::Stub<media::Service>(the_session_bus()),
179- d(new Private{
180+ object(
181 access_service()->object_for_path(
182 dbus::types::ObjectPath(
183- dbus::traits::Service<media::Service>::object_path()))})
184+ dbus::traits::Service<media::Service>::object_path()))
185+ ),
186+ daemon(the_session_bus()),
187+ service_watcher_reg(
188+ daemon.make_service_watcher(dbus::traits::Service<media::Service>::interface_name(),
189+ dbus::DBus::WatchMode::registration)
190+ ),
191+ service_watcher_unreg(
192+ daemon.make_service_watcher(dbus::traits::Service<media::Service>::interface_name(),
193+ dbus::DBus::WatchMode::unregistration)
194+ )
195 {
196 auto bus = the_session_bus();
197 worker = std::move(std::thread([bus]()
198 {
199 bus->run();
200 }));
201+
202+ service_watcher_reg->service_registered().connect(
203+ [&]()
204+ {
205+ MH_DEBUG("media-hub service registered");
206+ signals.service_reconnected();
207+ });
208+ service_watcher_unreg->service_unregistered().connect(
209+ [&]()
210+ {
211+ MH_DEBUG("media-hub service unregistered");
212+ signals.service_disconnected();
213+ });
214 }
215
216 media::ServiceStub::~ServiceStub()
217@@ -57,7 +77,7 @@
218
219 std::shared_ptr<media::Player> media::ServiceStub::create_session(const media::Player::Configuration&)
220 {
221- auto op = d->object->invoke_method_synchronously<mpris::Service::CreateSession,
222+ const auto op = object->invoke_method_synchronously<mpris::Service::CreateSession,
223 std::tuple<dbus::types::ObjectPath, std::string>>();
224
225 if (op.is_error())
226@@ -72,18 +92,20 @@
227 });
228 }
229
230-void media::ServiceStub::detach_session(const std::string& uuid, const media::Player::Configuration&)
231+void media::ServiceStub::detach_session(const std::string& uuid,
232+ const media::Player::Configuration&)
233 {
234- auto op = d->object->invoke_method_synchronously<mpris::Service::DetachSession,
235+ const auto op = object->invoke_method_synchronously<mpris::Service::DetachSession,
236 void>(uuid);
237
238 if (op.is_error())
239 throw std::runtime_error("Problem detaching session: " + op.error());
240 }
241
242-std::shared_ptr<media::Player> media::ServiceStub::reattach_session(const std::string& uuid, const media::Player::Configuration&)
243+std::shared_ptr<media::Player> media::ServiceStub::reattach_session(const std::string& uuid,
244+ const media::Player::Configuration&)
245 {
246- auto op = d->object->invoke_method_synchronously<mpris::Service::ReattachSession,
247+ const auto op = object->invoke_method_synchronously<mpris::Service::ReattachSession,
248 dbus::types::ObjectPath>(uuid);
249
250 if (op.is_error())
251@@ -98,18 +120,20 @@
252 });
253 }
254
255-void media::ServiceStub::destroy_session(const std::string& uuid, const media::Player::Configuration&)
256+void media::ServiceStub::destroy_session(const std::string& uuid,
257+ const media::Player::Configuration&)
258 {
259- auto op = d->object->invoke_method_synchronously<mpris::Service::DestroySession,
260+ const auto op = object->invoke_method_synchronously<mpris::Service::DestroySession,
261 void>(uuid);
262
263 if (op.is_error())
264 throw std::runtime_error("Problem destroying session: " + op.error());
265 }
266
267-std::shared_ptr<media::Player> media::ServiceStub::create_fixed_session(const std::string& name, const media::Player::Configuration&)
268+std::shared_ptr<media::Player> media::ServiceStub::create_fixed_session(const std::string& name,
269+ const media::Player::Configuration&)
270 {
271- auto op = d->object->invoke_method_synchronously<mpris::Service::CreateFixedSession,
272+ const auto op = object->invoke_method_synchronously<mpris::Service::CreateFixedSession,
273 dbus::types::ObjectPath>(name);
274
275 if (op.is_error())
276@@ -125,7 +149,7 @@
277
278 std::shared_ptr<media::Player> media::ServiceStub::resume_session(media::Player::PlayerKey key)
279 {
280- auto op = d->object->invoke_method_synchronously<mpris::Service::ResumeSession,
281+ const auto op = object->invoke_method_synchronously<mpris::Service::ResumeSession,
282 dbus::types::ObjectPath>(key);
283
284 if (op.is_error())
285@@ -141,9 +165,19 @@
286
287 void media::ServiceStub::pause_other_sessions(media::Player::PlayerKey key)
288 {
289- auto op = d->object->invoke_method_synchronously<mpris::Service::PauseOtherSessions,
290+ const auto op = object->invoke_method_synchronously<mpris::Service::PauseOtherSessions,
291 void>(key);
292
293 if (op.is_error())
294 throw std::runtime_error("Problem pausing other sessions: " + op.error());
295 }
296+
297+const core::Signal<void>& media::ServiceStub::service_disconnected() const
298+{
299+ return signals.service_disconnected;
300+}
301+
302+const core::Signal<void>& media::ServiceStub::service_reconnected() const
303+{
304+ return signals.service_reconnected;
305+}
306
307=== modified file 'src/core/media/service_stub.h'
308--- src/core/media/service_stub.h 2016-05-03 13:59:14 +0000
309+++ src/core/media/service_stub.h 2016-07-19 21:22:30 +0000
310@@ -23,9 +23,12 @@
311
312 #include "service_traits.h"
313
314+#include <core/dbus/bus.h>
315+#include <core/dbus/service_watcher.h>
316 #include <core/dbus/stub.h>
317
318 #include <memory>
319+#include <string>
320
321 namespace core
322 {
323@@ -47,10 +50,21 @@
324 std::shared_ptr<Player> resume_session(Player::PlayerKey key);
325 void pause_other_sessions(Player::PlayerKey key);
326
327+ virtual const core::Signal<void>& service_disconnected() const;
328+ virtual const core::Signal<void>& service_reconnected() const;
329+
330 private:
331- struct Private;
332- std::unique_ptr<Private> d;
333+ dbus::Object::Ptr object;
334+ dbus::DBus daemon;
335+ dbus::ServiceWatcher::Ptr service_watcher_reg;
336+ dbus::ServiceWatcher::Ptr service_watcher_unreg;
337 std::thread worker;
338+
339+ struct Signals
340+ {
341+ core::Signal<void> service_disconnected;
342+ core::Signal<void> service_reconnected;
343+ } signals;
344 };
345 }
346 }

Subscribers

People subscribed via source and target branches

to all changes: