Merge lp:~jhodapp/media-hub/fix-1398047 into lp:media-hub

Proposed by Jim Hodapp
Status: Merged
Approved by: Ricardo Mendoza
Approved revision: 101
Merged at revision: 102
Proposed branch: lp:~jhodapp/media-hub/fix-1398047
Merge into: lp:media-hub
Diff against target: 96 lines (+15/-11)
1 file modified
src/core/media/service_implementation.cpp (+15/-11)
To merge this branch: bzr merge lp:~jhodapp/media-hub/fix-1398047
Reviewer Review Type Date Requested Status
Ricardo Mendoza (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+245786@code.launchpad.net

Commit message

Pause playback when recording begins.

Description of the change

Pause playback when recording begins.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ricardo Mendoza (ricmm) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/core/media/service_implementation.cpp'
2--- src/core/media/service_implementation.cpp 2014-11-25 16:35:48 +0000
3+++ src/core/media/service_implementation.cpp 2015-01-07 20:44:06 +0000
4@@ -88,7 +88,7 @@
5 Private *p = reinterpret_cast<Private*>(userdata);
6 pa_threaded_mainloop_signal(p->mainloop(), 0);
7 }, this);
8-
9+
10 if (o)
11 {
12 while (pa_operation_get_state(o) == PA_OPERATION_RUNNING)
13@@ -105,7 +105,7 @@
14 pa_threaded_mainloop_unlock(pulse_mainloop);
15 }
16 }
17-
18+
19 if (pulse_mainloop == nullptr)
20 {
21 pulse_mainloop = pa_threaded_mainloop_new();
22@@ -117,16 +117,16 @@
23 pulse_mainloop = nullptr;
24 }
25 }
26-
27+
28 do {
29 create_pulse_context();
30 } while (pulse_context == nullptr);
31-
32+
33 // Wait for next instance death.
34 return false;
35 });
36 }));
37-
38+
39 // Connect the property change signal that will allow media-hub to take appropriate action
40 // when the battery level reaches critical
41 auto stub_service = dbus::Service::use_service(bus, "com.canonical.indicator.power");
42@@ -175,6 +175,9 @@
43 if (disp_cookie > 0)
44 return;
45
46+ // Make sure we pause all playback sessions so that it doesn't interfere with recorded audio
47+ pause_playback();
48+
49 auto result = uscreen_session->invoke_method_synchronously<core::UScreen::keepDisplayOn, int>();
50 if (result.is_error())
51 throw std::runtime_error(result.error().print());
52@@ -287,7 +290,7 @@
53 p->pause_playback_if_necessary(i->index);
54 p->active_sink = new_sink;
55 }, this);
56-
57+
58 (void) o;
59 }
60
61@@ -311,7 +314,7 @@
62 {
63 if (pulse_context != nullptr)
64 return;
65-
66+
67 active_sink = std::make_tuple(-1, -1, "");
68
69 bool keep_going = true, ok = true;
70@@ -397,13 +400,13 @@
71
72 if (eol)
73 return;
74-
75+
76 Private *p = reinterpret_cast<Private*>(userdata);
77 p->primary_idx = i->index;
78 p->update_wired_output();
79 }, this);
80-
81- update_active_sink();
82+
83+ update_active_sink();
84
85 pa_context_set_subscribe_callback(pulse_context,
86 [](pa_context *context, pa_subscription_event_type_t t, uint32_t idx, void *userdata)
87@@ -471,7 +474,8 @@
88 int primary_idx;
89
90 // Gets signaled when both the headphone jack is removed or an A2DP device is
91- // disconnected and playback needs pausing
92+ // disconnected and playback needs pausing. Also gets signaled when recording
93+ // begins.
94 core::Signal<void> pause_playback;
95 std::unique_ptr<CallMonitor> call_monitor;
96 std::list<media::Player::PlayerKey> paused_sessions;

Subscribers

People subscribed via source and target branches