From 5d56e1dc1ee21ec92028275690b5ce2f7595e68e Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 29 Feb 2012 21:05:26 +0000 Subject: make sure to return if there is no valid playlist --- src/mpris2-controller.vala | 3 +-- src/mpris2-interfaces.vala | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index cc80a86..0fa7b6c 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -248,8 +248,7 @@ public class Mpris2Controller : GLib.Object private bool fetch_active_playlist() { if (this.playlists.ActivePlaylist.valid == false){ - // TODO - // What happens here ? + return false; } PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; playlists_item.active_playlist_update ( this.playlists.ActivePlaylist.details ); diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala index 5dab1d2..57b582d 100644 --- a/src/mpris2-interfaces.vala +++ b/src/mpris2-interfaces.vala @@ -49,9 +49,9 @@ public interface MprisPlayer : Object { // Playlist container public struct PlaylistDetails{ - public ObjectPath path; - public string name; - public string icon_path; + public ObjectPath? path; + public string? name; + public string? icon_path; } // Active playlist property container @@ -69,11 +69,11 @@ public interface MprisPlaylists : Object { //methods public abstract async void ActivatePlaylist(ObjectPath playlist_id) throws IOError; - public abstract async PlaylistDetails[] GetPlaylists ( uint32 index, + public abstract async PlaylistDetails[]? GetPlaylists ( int32 index, uint32 max_count, string order, bool reverse_order ) throws IOError; //signals public signal void PlaylistChanged (PlaylistDetails details); -} \ No newline at end of file +} -- cgit v1.2.3 From 00455609711cfc94e2488ad5a5012632bcbfee44 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 1 Mar 2012 12:12:43 +0000 Subject: how can we be sure the details struct is not null, is this the fix to that memory corruption --- src/mpris2-interfaces.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala index 57b582d..ee86c2b 100644 --- a/src/mpris2-interfaces.vala +++ b/src/mpris2-interfaces.vala @@ -57,7 +57,7 @@ public struct PlaylistDetails{ // Active playlist property container public struct ActivePlaylistContainer{ public bool valid; - public PlaylistDetails details; + public PlaylistDetails? details; } [DBus (name = "org.mpris.MediaPlayer2.Playlists")] -- cgit v1.2.3 From ee55f50a379890e68ab9af68d02565b52a24655d Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 1 Mar 2012 13:55:50 +0000 Subject: play it safe around UI pulse interactions - hopefully circumvents odd crashes that have been reported --- src/pulseaudio-mgr.c | 88 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index 3a80cbd..aca156a 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -121,7 +121,6 @@ static gboolean reconnect_to_pulse (gpointer user_data) { g_debug("Attempt a pulse connection"); - // reset g_return_val_if_fail (IS_DEVICE (user_data), FALSE); connection_attempts += 1; @@ -175,50 +174,83 @@ void pm_update_volume (gint sink_index, pa_cvolume new_volume) { if (sink_index < 0 || pulse_context == NULL){ + g_warning ("pm_update_volume sink index is negative or the context is null"); return; } - pa_operation_unref (pa_context_set_sink_volume_by_index (pulse_context, - sink_index, - &new_volume, - NULL, - NULL) ); + pa_operation *operation = NULL; + + operation = pa_context_set_sink_volume_by_index (pulse_context, + sink_index, + &new_volume, + NULL, + NULL); + if (!operation){ + g_warning ("pm_update_volume operation failed for some reason"); + return; + } + pa_operation_unref (operation); } void pm_update_mute (gboolean update) { - pa_operation_unref (pa_context_get_sink_info_list (pulse_context, - pm_toggle_mute_for_every_sink_callback, - GINT_TO_POINTER (update))); + if (pulse_context == NULL){ + g_warning ("pm_update_mute - the context is null"); + return; + } + pa_operation *operation = NULL; + + operation = pa_context_get_sink_info_list (pulse_context, + pm_toggle_mute_for_every_sink_callback, + GINT_TO_POINTER (update)); + if (!operation){ + g_warning ("pm_update_mute operation failed for some reason"); + return; + } + pa_operation_unref (operation); } void pm_update_mic_gain (gint source_index, pa_cvolume new_gain) { - // LP: #850662 if (source_index < 0 || pulse_context == NULL){ + g_warning ("pm_update_mic_gain source index is negative or the context is null"); + return; + } + pa_operation *operation = NULL; + + operation = pa_context_set_source_volume_by_index (pulse_context, + source_index, + &new_gain, + NULL, + NULL); + if (!operation){ + g_warning ("pm_update_mic_gain operation failed for some reason"); return; } - pa_operation_unref (pa_context_set_source_volume_by_index (pulse_context, - source_index, - &new_gain, - NULL, - NULL) ); + pa_operation_unref (operation); } void pm_update_mic_mute (gint source_index, gint mute_update) { - // LP: #850662 - if (source_index < 0){ - return; - } - pa_operation_unref (pa_context_set_source_mute_by_index (pulse_context, - source_index, - mute_update, - NULL, - NULL)); + if (source_index < 0){ + return; + } + pa_operation *operation = NULL; + + operation = pa_context_set_source_mute_by_index (pulse_context, + source_index, + mute_update, + NULL, + NULL); + if (!operation){ + g_warning ("pm_update_mic_mute operation failed for some reason"); + return; + } + pa_operation_unref (operation); } + /**********************************************************************************************************************/ // Pulse-Audio asychronous call-backs /**********************************************************************************************************************/ @@ -308,8 +340,6 @@ pm_subscribed_events_callback (pa_context *c, } } - - static void pm_context_state_callback (pa_context *c, void *userdata) { @@ -337,6 +367,12 @@ pm_context_state_callback (pa_context *c, void *userdata) break; case PA_CONTEXT_TERMINATED: g_debug ("Terminated"); + device_sink_deactivated (DEVICE (userdata)); + + if (reconnect_idle_id != 0){ + g_source_remove (reconnect_idle_id); + reconnect_idle_id = 0; + } break; case PA_CONTEXT_READY: connection_attempts = 0; -- cgit v1.2.3 From 40837488c4fa94e96cdfefae65020e2b443e46f5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 1 Mar 2012 16:00:38 +0000 Subject: check the state of the pulse context to ensure it's ready for interaction --- src/pulseaudio-mgr.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index aca156a..fee504e 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -177,6 +177,12 @@ pm_update_volume (gint sink_index, pa_cvolume new_volume) g_warning ("pm_update_volume sink index is negative or the context is null"); return; } + + if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){ + g_warning ("pm_update_volume context is not in a ready state"); + return; + } + pa_operation *operation = NULL; operation = pa_context_set_sink_volume_by_index (pulse_context, @@ -198,6 +204,12 @@ pm_update_mute (gboolean update) g_warning ("pm_update_mute - the context is null"); return; } + + if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){ + g_warning ("pm_update_mute context is not in a ready state"); + return; + } + pa_operation *operation = NULL; operation = pa_context_get_sink_info_list (pulse_context, @@ -217,6 +229,12 @@ pm_update_mic_gain (gint source_index, pa_cvolume new_gain) g_warning ("pm_update_mic_gain source index is negative or the context is null"); return; } + + if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){ + g_warning ("pm_update_mic_gain context is not in a ready state"); + return; + } + pa_operation *operation = NULL; operation = pa_context_set_source_volume_by_index (pulse_context, @@ -237,6 +255,12 @@ pm_update_mic_mute (gint source_index, gint mute_update) if (source_index < 0){ return; } + + if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){ + g_warning ("pm_update_mic_mute context is not in a ready state"); + return; + } + pa_operation *operation = NULL; operation = pa_context_set_source_mute_by_index (pulse_context, -- cgit v1.2.3