Merge lp:~cjcurran/indicator-sound/fix-playlist-null-pointer into lp:indicator-sound/fifth

Proposed by Conor Curran
Status: Merged
Approved by: Ted Gould
Approved revision: 301
Merged at revision: 299
Proposed branch: lp:~cjcurran/indicator-sound/fix-playlist-null-pointer
Merge into: lp:indicator-sound/fifth
Diff against target: 221 lines (+97/-38)
3 files modified
src/mpris2-controller.vala (+1/-2)
src/mpris2-interfaces.vala (+6/-6)
src/pulseaudio-mgr.c (+90/-30)
To merge this branch: bzr merge lp:~cjcurran/indicator-sound/fix-playlist-null-pointer
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+95395@code.launchpad.net

Description of the change

Fixes bugs attached.

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

Makes sense to me. Not sure I can recreate those bugs, but this should make things safer no matter.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/mpris2-controller.vala'
--- src/mpris2-controller.vala 2011-10-21 19:03:54 +0000
+++ src/mpris2-controller.vala 2012-03-01 16:02:32 +0000
@@ -248,8 +248,7 @@
248 private bool fetch_active_playlist()248 private bool fetch_active_playlist()
249 { 249 {
250 if (this.playlists.ActivePlaylist.valid == false){250 if (this.playlists.ActivePlaylist.valid == false){
251 // TODO 251 return false;
252 // What happens here ?
253 } 252 }
254 PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;253 PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
255 playlists_item.active_playlist_update ( this.playlists.ActivePlaylist.details );254 playlists_item.active_playlist_update ( this.playlists.ActivePlaylist.details );
256255
=== modified file 'src/mpris2-interfaces.vala'
--- src/mpris2-interfaces.vala 2011-03-08 21:43:50 +0000
+++ src/mpris2-interfaces.vala 2012-03-01 16:02:32 +0000
@@ -49,15 +49,15 @@
4949
50// Playlist container50// Playlist container
51public struct PlaylistDetails{51public struct PlaylistDetails{
52 public ObjectPath path;52 public ObjectPath? path;
53 public string name;53 public string? name;
54 public string icon_path;54 public string? icon_path;
55}55}
5656
57// Active playlist property container57// Active playlist property container
58public struct ActivePlaylistContainer{58public struct ActivePlaylistContainer{
59 public bool valid;59 public bool valid;
60 public PlaylistDetails details;60 public PlaylistDetails? details;
61}61}
6262
63[DBus (name = "org.mpris.MediaPlayer2.Playlists")]63[DBus (name = "org.mpris.MediaPlayer2.Playlists")]
@@ -69,11 +69,11 @@
69 69
70 //methods70 //methods
71 public abstract async void ActivatePlaylist(ObjectPath playlist_id) throws IOError;71 public abstract async void ActivatePlaylist(ObjectPath playlist_id) throws IOError;
72 public abstract async PlaylistDetails[] GetPlaylists ( uint32 index,72 public abstract async PlaylistDetails[]? GetPlaylists ( int32 index,
73 uint32 max_count,73 uint32 max_count,
74 string order,74 string order,
75 bool reverse_order ) throws IOError;75 bool reverse_order ) throws IOError;
76 //signals76 //signals
77 public signal void PlaylistChanged (PlaylistDetails details);77 public signal void PlaylistChanged (PlaylistDetails details);
78 78
79}
80\ No newline at end of file79\ No newline at end of file
80}
8181
=== modified file 'src/pulseaudio-mgr.c'
--- src/pulseaudio-mgr.c 2012-02-22 16:40:59 +0000
+++ src/pulseaudio-mgr.c 2012-03-01 16:02:32 +0000
@@ -121,7 +121,6 @@
121reconnect_to_pulse (gpointer user_data)121reconnect_to_pulse (gpointer user_data)
122{122{
123 g_debug("Attempt a pulse connection");123 g_debug("Attempt a pulse connection");
124 // reset
125 g_return_val_if_fail (IS_DEVICE (user_data), FALSE);124 g_return_val_if_fail (IS_DEVICE (user_data), FALSE);
126125
127 connection_attempts += 1;126 connection_attempts += 1;
@@ -175,50 +174,107 @@
175pm_update_volume (gint sink_index, pa_cvolume new_volume)174pm_update_volume (gint sink_index, pa_cvolume new_volume)
176{175{
177 if (sink_index < 0 || pulse_context == NULL){176 if (sink_index < 0 || pulse_context == NULL){
178 return;177 g_warning ("pm_update_volume sink index is negative or the context is null");
179 }178 return;
180 pa_operation_unref (pa_context_set_sink_volume_by_index (pulse_context,179 }
181 sink_index,180
182 &new_volume,181 if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){
183 NULL,182 g_warning ("pm_update_volume context is not in a ready state");
184 NULL) );183 return;
184 }
185
186 pa_operation *operation = NULL;
187
188 operation = pa_context_set_sink_volume_by_index (pulse_context,
189 sink_index,
190 &new_volume,
191 NULL,
192 NULL);
193 if (!operation){
194 g_warning ("pm_update_volume operation failed for some reason");
195 return;
196 }
197 pa_operation_unref (operation);
185}198}
186199
187void200void
188pm_update_mute (gboolean update)201pm_update_mute (gboolean update)
189{202{
190 pa_operation_unref (pa_context_get_sink_info_list (pulse_context,203 if (pulse_context == NULL){
191 pm_toggle_mute_for_every_sink_callback,204 g_warning ("pm_update_mute - the context is null");
192 GINT_TO_POINTER (update)));205 return;
206 }
207
208 if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){
209 g_warning ("pm_update_mute context is not in a ready state");
210 return;
211 }
212
213 pa_operation *operation = NULL;
214
215 operation = pa_context_get_sink_info_list (pulse_context,
216 pm_toggle_mute_for_every_sink_callback,
217 GINT_TO_POINTER (update));
218 if (!operation){
219 g_warning ("pm_update_mute operation failed for some reason");
220 return;
221 }
222 pa_operation_unref (operation);
193}223}
194224
195void225void
196pm_update_mic_gain (gint source_index, pa_cvolume new_gain)226pm_update_mic_gain (gint source_index, pa_cvolume new_gain)
197{227{
198 // LP: #850662
199 if (source_index < 0 || pulse_context == NULL){228 if (source_index < 0 || pulse_context == NULL){
200 return;229 g_warning ("pm_update_mic_gain source index is negative or the context is null");
201 }230 return;
202 pa_operation_unref (pa_context_set_source_volume_by_index (pulse_context,231 }
203 source_index,232
204 &new_gain,233 if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){
205 NULL,234 g_warning ("pm_update_mic_gain context is not in a ready state");
206 NULL) );235 return;
236 }
237
238 pa_operation *operation = NULL;
239
240 operation = pa_context_set_source_volume_by_index (pulse_context,
241 source_index,
242 &new_gain,
243 NULL,
244 NULL);
245 if (!operation){
246 g_warning ("pm_update_mic_gain operation failed for some reason");
247 return;
248 }
249 pa_operation_unref (operation);
207}250}
208251
209void252void
210pm_update_mic_mute (gint source_index, gint mute_update)253pm_update_mic_mute (gint source_index, gint mute_update)
211{254{
212 // LP: #850662255 if (source_index < 0){
213 if (source_index < 0){256 return;
214 return;257 }
215 }258
216 pa_operation_unref (pa_context_set_source_mute_by_index (pulse_context,259 if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){
217 source_index,260 g_warning ("pm_update_mic_mute context is not in a ready state");
218 mute_update,261 return;
219 NULL,262 }
220 NULL));263
264 pa_operation *operation = NULL;
265
266 operation = pa_context_set_source_mute_by_index (pulse_context,
267 source_index,
268 mute_update,
269 NULL,
270 NULL);
271 if (!operation){
272 g_warning ("pm_update_mic_mute operation failed for some reason");
273 return;
274 }
275 pa_operation_unref (operation);
221}276}
277
222/**********************************************************************************************************************/278/**********************************************************************************************************************/
223// Pulse-Audio asychronous call-backs279// Pulse-Audio asychronous call-backs
224/**********************************************************************************************************************/280/**********************************************************************************************************************/
@@ -308,8 +364,6 @@
308 }364 }
309}365}
310366
311
312
313static void367static void
314pm_context_state_callback (pa_context *c, void *userdata)368pm_context_state_callback (pa_context *c, void *userdata)
315{369{
@@ -337,6 +391,12 @@
337 break;391 break;
338 case PA_CONTEXT_TERMINATED:392 case PA_CONTEXT_TERMINATED:
339 g_debug ("Terminated");393 g_debug ("Terminated");
394 device_sink_deactivated (DEVICE (userdata));
395
396 if (reconnect_idle_id != 0){
397 g_source_remove (reconnect_idle_id);
398 reconnect_idle_id = 0;
399 }
340 break;400 break;
341 case PA_CONTEXT_READY:401 case PA_CONTEXT_READY:
342 connection_attempts = 0;402 connection_attempts = 0;

Subscribers

People subscribed via source and target branches