Merge lp:~larsu/indicator-sound/reconnect-to-pulse into lp:indicator-sound/13.10

Proposed by Lars Karlitski
Status: Merged
Approved by: Ted Gould
Approved revision: 383
Merged at revision: 384
Proposed branch: lp:~larsu/indicator-sound/reconnect-to-pulse
Merge into: lp:indicator-sound/13.10
Diff against target: 84 lines (+40/-25)
1 file modified
src/volume-control.vala (+40/-25)
To merge this branch: bzr merge lp:~larsu/indicator-sound/reconnect-to-pulse
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+188319@code.launchpad.net

Commit message

Reconnect when pulseaudio terminates (or crashes)

Description of the change

Reconnect when pulseaudio terminates (or crashes)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/volume-control.vala'
--- src/volume-control.vala 2013-06-18 19:00:27 +0000
+++ src/volume-control.vala 2013-09-30 12:15:16 +0000
@@ -46,21 +46,7 @@
46 if (loop == null)46 if (loop == null)
47 loop = new PulseAudio.GLibMainLoop ();47 loop = new PulseAudio.GLibMainLoop ();
4848
49 var props = new Proplist ();49 this.reconnect_to_pulse ();
50 props.sets (Proplist.PROP_APPLICATION_NAME, "Ubuntu Audio Settings");
51 props.sets (Proplist.PROP_APPLICATION_ID, "com.canonical.settings.sound");
52 props.sets (Proplist.PROP_APPLICATION_ICON_NAME, "multimedia-volume-control");
53 props.sets (Proplist.PROP_APPLICATION_VERSION, "0.1");
54
55 context = new PulseAudio.Context (loop.get_api(), null, props);
56
57 context.set_state_callback (context_state_callback);
58
59 if (context.connect(null, Context.Flags.NOFAIL, null) < 0)
60 {
61 warning( "pa_context_connect() failed: %s\n", PulseAudio.strerror(context.errno()));
62 return;
63 }
64 }50 }
6551
66 /* PulseAudio logic*/52 /* PulseAudio logic*/
@@ -153,18 +139,47 @@
153139
154 private void context_state_callback (Context c)140 private void context_state_callback (Context c)
155 {141 {
156 if (c.get_state () == Context.State.READY)142 switch (c.get_state ()) {
157 {143 case Context.State.READY:
158 c.subscribe (PulseAudio.Context.SubscriptionMask.SINK |144 c.subscribe (PulseAudio.Context.SubscriptionMask.SINK |
159 PulseAudio.Context.SubscriptionMask.SOURCE |145 PulseAudio.Context.SubscriptionMask.SOURCE |
160 PulseAudio.Context.SubscriptionMask.SOURCE_OUTPUT);146 PulseAudio.Context.SubscriptionMask.SOURCE_OUTPUT);
161 c.set_subscribe_callback (context_events_cb);147 c.set_subscribe_callback (context_events_cb);
162 update_sink ();148 update_sink ();
163 update_source ();149 update_source ();
164 this.ready = true;150 this.ready = true;
151 break;
152
153 case Context.State.FAILED:
154 case Context.State.TERMINATED:
155 this.reconnect_to_pulse ();
156 break;
157
158 default:
159 this.ready = false;
160 break;
165 }161 }
166 else162 }
163
164 void reconnect_to_pulse ()
165 {
166 if (this.ready) {
167 this.context.disconnect ();
168 this.context = null;
167 this.ready = false;169 this.ready = false;
170 }
171
172 var props = new Proplist ();
173 props.sets (Proplist.PROP_APPLICATION_NAME, "Ubuntu Audio Settings");
174 props.sets (Proplist.PROP_APPLICATION_ID, "com.canonical.settings.sound");
175 props.sets (Proplist.PROP_APPLICATION_ICON_NAME, "multimedia-volume-control");
176 props.sets (Proplist.PROP_APPLICATION_VERSION, "0.1");
177
178 this.context = new PulseAudio.Context (loop.get_api(), null, props);
179 this.context.set_state_callback (context_state_callback);
180
181 if (context.connect(null, Context.Flags.NOFAIL, null) < 0)
182 warning( "pa_context_connect() failed: %s\n", PulseAudio.strerror(context.errno()));
168 }183 }
169184
170 /* Mute operations */185 /* Mute operations */

Subscribers

People subscribed via source and target branches