From 8ec8d6d2abc55ddc140fc5d390ba2034b1fa6588 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 28 Feb 2011 12:45:19 +0000 Subject: caught a edge case bug which was causing those weird crashes --- src/pulseaudio-mgr.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index 76102e4..a0199ea 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -220,11 +220,12 @@ pm_subscribed_events_callback (pa_context *c, } break; case PA_SUBSCRIPTION_EVENT_SOURCE: - g_debug ("Looks like source event of some description"); + g_debug ("Looks like source event of some description - index = %i", index); // We don't care about any other sink other than the active one. if (index != active_sink_get_source_index (sink)) return; if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { + g_debug ("Source removal event - index = %i", index); active_sink_deactivate_voip_source (sink, FALSE); } else{ @@ -396,8 +397,8 @@ pm_sink_info_callback (pa_context *c, return; } else { - if (IS_ACTIVE_SINK (userdata) == FALSE){ - g_warning ("sink info callback - our user data is not what we think it should be"); + if (IS_ACTIVE_SINK (userdata) == FALSE || sink == NULL){ + g_warning ("sink info callback - our user data is not what we think it should be or the sink parameter is null"); return; } ActiveSink* a_sink = ACTIVE_SINK (userdata); @@ -418,8 +419,8 @@ pm_default_sink_info_callback (pa_context *c, return; } else { - if (IS_ACTIVE_SINK (userdata) == FALSE){ - g_warning ("Default sink info callback - our user data is not what we think it should be"); + if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){ + g_warning ("Default sink info callback - our user data is not what we think it should be or the info parameter is null"); return; } // Only repopulate if there is a change with regards the index @@ -441,9 +442,8 @@ pm_sink_input_info_callback (pa_context *c, return; } else { - if (info == NULL) { - // TODO: watch this carefully - PA async api should not be doing this . . . - g_warning("\n Sink input info callback : SINK INPUT INFO IS NULL BUT EOL was not POSITIVE!!!"); + if (info == NULL || IS_ACTIVE_SINK (userdata) == FALSE) { + g_warning("Sink input info callback : SINK INPUT INFO IS NULL or our user_data is not what we think it should be"); return; } @@ -486,8 +486,8 @@ pm_update_active_sink (pa_context *c, return; } else{ - if (IS_ACTIVE_SINK (userdata) == FALSE){ - g_warning ("update_active_sink - our user data is not what we think it should be"); + if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){ + g_warning ("update_active_sink - our user data is not what we think it should be or the info parameter is null"); return; } active_sink_update (ACTIVE_SINK(userdata), info); @@ -504,6 +504,11 @@ pm_toggle_mute_for_every_sink_callback (pa_context *c, return; } else { + if (IS_ACTIVE_SINK (userdata) == FALSE || sink == NULL){ + g_warning ("toggle_mute cb - our user data is not what we think it should be or the sink parameter is null"); + return; + } + pa_operation_unref (pa_context_set_sink_mute_by_index (c, sink->index, GPOINTER_TO_INT(userdata), @@ -523,8 +528,8 @@ pm_default_source_info_callback (pa_context *c, return; } else { - if (IS_ACTIVE_SINK (userdata) == FALSE){ - g_warning ("Default sink info callback - our user data is not what we think it should be"); + if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){ + g_warning ("Default source info callback - our user data is not what we think it should be or the source info parameter is null"); return; } // If there is an index change we need to change our cached source @@ -546,8 +551,8 @@ pm_source_info_callback (pa_context *c, return; } else { - if (IS_ACTIVE_SINK (userdata) == FALSE){ - g_warning ("Default sink info callback - our user data is not what we think it should be"); + if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){ + g_warning ("source info callback - our user data is not what we think it should be or the source info parameter is null"); return; } // For now we will take the first available @@ -567,8 +572,8 @@ pm_update_source_info_callback (pa_context *c, return; } else { - if (IS_ACTIVE_SINK (userdata) == FALSE){ - g_warning ("Default sink info callback - our user data is not what we think it should be"); + if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL ){ + g_warning ("source info update callback - our user data is not what we think it should be or the source info paramter is null"); return; } g_debug ("Got a source update for %s , index %i", info->name, info->index); -- cgit v1.2.3 From 55c48f356f9969efbe2805daaedaf1e5db48cfce Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 28 Feb 2011 18:51:58 +0000 Subject: raise / activate players on button release as opposed to button press --- src/title-widget.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/title-widget.c b/src/title-widget.c index 675c59f..b8058b8 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -44,8 +44,8 @@ static void title_widget_dispose (GObject *object); static void title_widget_finalize (GObject *object); // keyevent consumers -static gboolean title_widget_button_press_event (GtkWidget *menuitem, - GdkEventButton *event); +static gboolean title_widget_button_release_event (GtkWidget *menuitem, + GdkEventButton *event); // Dbusmenuitem properties update callback static void title_widget_property_update(DbusmenuMenuitem* item, gchar* property, @@ -64,7 +64,7 @@ title_widget_class_init (TitleWidgetClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - widget_class->button_press_event = title_widget_button_press_event; + widget_class->button_release_event = title_widget_button_release_event; g_type_class_add_private (klass, sizeof (TitleWidgetPrivate)); @@ -132,8 +132,8 @@ title_widget_finalize (GObject *object) /* Suppress/consume keyevents */ static gboolean -title_widget_button_press_event (GtkWidget *menuitem, - GdkEventButton *event) +title_widget_button_release_event (GtkWidget *menuitem, + GdkEventButton *event) { //g_debug("TitleWidget::menu_press_event"); TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(menuitem); @@ -147,8 +147,8 @@ title_widget_button_press_event (GtkWidget *menuitem, } static void -title_widget_property_update(DbusmenuMenuitem* item, gchar* property, - GVariant* value, gpointer userdata) +title_widget_property_update (DbusmenuMenuitem* item, gchar* property, + GVariant* value, gpointer userdata) { g_return_if_fail (IS_TITLE_WIDGET (userdata)); TitleWidget* mitem = TITLE_WIDGET(userdata); -- cgit v1.2.3 From c231d1697cd1dc94d754e3aaaafca4a124a2eda3 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 1 Mar 2011 11:23:15 +0000 Subject: play it safe with the dbus method call@ --- src/sound-service-dbus.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 9be39c7..b493ce8 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -295,6 +295,8 @@ static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self, gchar* player_name, gboolean blacklist) { + g_return_val_if_fail (player_name != NULL, FALSE); + gboolean result = FALSE; GSettings* our_settings = NULL; our_settings = g_settings_new ("com.canonical.indicators.sound"); -- cgit v1.2.3 From 031015221d4551339e14b31838d364386952a63b Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 1 Mar 2011 18:51:37 +0000 Subject: fix for reconnect bug while autospawn is true --- src/pulseaudio-mgr.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index a0199ea..17545a4 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -31,6 +31,7 @@ with this program. If not, see . #include #include "pulseaudio-mgr.h" +#include "config.h" #define RECONNECT_DELAY 5 @@ -116,24 +117,44 @@ Method which connects to the pulse server and is used to track reconnects. static gboolean reconnect_to_pulse (gpointer user_data) { - g_debug("Attempt to reconnect to pulse"); + g_debug("Attempt a pulse connection"); // reset + g_return_val_if_fail (IS_ACTIVE_SINK (user_data), FALSE); + connection_attempts += 1; if (pulse_context != NULL) { pa_context_unref(pulse_context); pulse_context = NULL; } - pulse_context = pa_context_new( pa_glib_mainloop_get_api( pa_main_loop ), - "com.canonical.indicators.sound" ); + pa_proplist *proplist; + + proplist = pa_proplist_new (); + pa_proplist_sets (proplist, + PA_PROP_APPLICATION_NAME, + "Indicator Sound"); + pa_proplist_sets (proplist, + PA_PROP_APPLICATION_ID, + "com.canonical.indicators.sound"); + pa_proplist_sets (proplist, + PA_PROP_APPLICATION_ICON_NAME, + "multimedia-volume-control"); + pa_proplist_sets (proplist, + PA_PROP_APPLICATION_VERSION, + PACKAGE_VERSION); + + pulse_context = pa_context_new_with_proplist (pa_glib_mainloop_get_api( pa_main_loop ), + NULL, + proplist); + pa_proplist_free (proplist); g_assert(pulse_context); pa_context_set_state_callback (pulse_context, pm_context_state_callback, user_data); int result = pa_context_connect (pulse_context, NULL, - PA_CONTEXT_NOFAIL, - user_data); + (pa_context_flags_t)PA_CONTEXT_NOFAIL, + NULL); if (result < 0) { g_warning ("Failed to connect context: %s", @@ -280,8 +301,10 @@ pm_context_state_callback (pa_context *c, void *userdata) g_debug("connecting - waiting for the server to become available"); break; case PA_CONTEXT_AUTHORIZING: + g_debug ("Authorizing"); break; case PA_CONTEXT_SETTING_NAME: + g_debug ("Setting name"); break; case PA_CONTEXT_FAILED: g_warning("PA_CONTEXT_FAILED - Is PulseAudio Daemon running ?"); @@ -289,10 +312,11 @@ pm_context_state_callback (pa_context *c, void *userdata) if (reconnect_idle_id == 0){ reconnect_idle_id = g_timeout_add_seconds (RECONNECT_DELAY, reconnect_to_pulse, - userdata); + (gpointer)userdata); } break; case PA_CONTEXT_TERMINATED: + g_debug ("Terminated"); break; case PA_CONTEXT_READY: connection_attempts = 0; @@ -579,4 +603,4 @@ pm_update_source_info_callback (pa_context *c, g_debug ("Got a source update for %s , index %i", info->name, info->index); active_sink_update_voip_input_source (ACTIVE_SINK (userdata), info); } -} \ No newline at end of file +} -- cgit v1.2.3 From c373cdd1c65b5ec43e93317600508a5b0d9e7a44 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 1 Mar 2011 20:36:26 +0000 Subject: fixed a bug introduced in the last merge earlier this week --- src/pulseaudio-mgr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index 17545a4..6d11221 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -528,11 +528,10 @@ pm_toggle_mute_for_every_sink_callback (pa_context *c, return; } else { - if (IS_ACTIVE_SINK (userdata) == FALSE || sink == NULL){ - g_warning ("toggle_mute cb - our user data is not what we think it should be or the sink parameter is null"); + if (sink == NULL) { + g_warning ("toggle_mute cb - sink parameter is null - why ?"); return; } - pa_operation_unref (pa_context_set_sink_mute_by_index (c, sink->index, GPOINTER_TO_INT(userdata), -- cgit v1.2.3 From 52976fc65cc974e481722acc68e44857a737599a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 3 Mar 2011 15:45:05 +0000 Subject: fixes two playlists bugs plus a little code tidy up in the indicator-sound --- src/indicator-sound.c | 29 ++--------------------------- src/mpris2-controller.vala | 6 +++--- src/playlists-menu-item.vala | 30 ++++++++++++++++++++++++++---- 3 files changed, 31 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 4980ab8..6e1acc9 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -443,28 +443,15 @@ new_voip_slider_widget (DbusmenuMenuitem * newitem, { g_debug("indicator-sound: new_voip_slider_widget"); GtkWidget* voip_widget = NULL; - //IndicatorObject *io = NULL; g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); voip_widget = voip_input_widget_new (newitem); -/* - / io = g_object_get_data (G_OBJECT (client), "indicator"); -*/ - //IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io)); - //priv->volume_widget = volume_widget; GtkWidget* ido_slider_widget = voip_input_widget_get_ido_slider(VOIP_INPUT_WIDGET(voip_widget)); gtk_widget_show_all(ido_slider_widget); - // register the style callback on this widget with state manager's style change - // handler (needs to remake the blocking animation for each style). -/* - g_signal_connect (ido_slider_widget, "style-set", - G_CALLBACK(sound_state_manager_style_changed_cb), - priv->state_manager); -*/ GtkMenuItem *menu_volume_item = GTK_MENU_ITEM(ido_slider_widget); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), @@ -509,23 +496,11 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) switch (event->keyval) { case GDK_Right: digested = TRUE; -/* - if (event->state & GDK_CONTROL_MASK) { - new_value = 100; - } else { -*/ - new_value = current_value + five_percent; - //} + new_value = current_value + five_percent; break; case GDK_Left: digested = TRUE; -/* - if (event->state & GDK_CONTROL_MASK) { - new_value = 0; - } else { -*/ - new_value = current_value - five_percent; - //} + new_value = current_value - five_percent; break; case GDK_plus: digested = TRUE; diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index bf930fc..c7305f4 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -222,7 +222,7 @@ public class Mpris2Controller : GLib.Object } if( current_playlists != null ){ - //debug( "Size of the playlist array = %i", current_playlists.length ); + debug( "Size of the playlist array = %i", current_playlists.length ); PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; playlists_item.update(current_playlists); } @@ -238,7 +238,7 @@ public class Mpris2Controller : GLib.Object debug(" We don't have an active playlist"); } PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; - playlists_item.update_active_playlist ( this.playlists.ActivePlaylist.details ); + playlists_item.active_playlist_update ( this.playlists.ActivePlaylist.details ); return false; } @@ -251,4 +251,4 @@ public class Mpris2Controller : GLib.Object debug("Could not activate playlist %s because %s", (string)path, e.message); } } -} \ No newline at end of file +} diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index 8a2ccac..bc39129 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -34,7 +34,9 @@ public class PlaylistsMenuitem : PlayerItem construct{ this.current_playlists = new HashMap(); this.root_item = new Menuitem(); + this.root_item.property_set ( MENUITEM_PROP_LABEL, "Choose Playlist" ); + this.root_item.property_set ( MENUITEM_PATH, "" ); } public new void update (PlaylistDetails[] playlists) @@ -51,10 +53,25 @@ public class PlaylistsMenuitem : PlayerItem menuitem.property_set_bool (MENUITEM_PROP_ENABLED, true); menuitem.item_activated.connect(() => { - submenu_item_activated (menuitem.id );}); - this.current_playlists.set( menuitem.id, menuitem ); + submenu_item_activated (menuitem.id ); + } + ); + this.current_playlists.set( menuitem.id, menuitem ); this.root_item.child_append( menuitem ); } + // Finally remove any that might have been deleted + foreach (Dbusmenu.Menuitem item in this.current_playlists.values) { + bool within = false; + foreach (PlaylistDetails detail in playlists){ + if (detail.path == item.property_get (MENUITEM_PATH)) { + within = true; + break; + } + } + if (within == false){ + this.root_item.child_delete (item); + } + } } public void update_individual_playlist (PlaylistDetails new_detail) @@ -65,6 +82,10 @@ public class PlaylistsMenuitem : PlayerItem item.property_set (MENUITEM_PROP_ICON_NAME, new_detail.icon_path); } } + // If its active make sure the name is updated on the root item. + if (this.root_item.property_get (MENUITEM_PATH) == new_detail.path) { + this.root_item.property_set (MENUITEM_PROP_LABEL, new_detail.name); + } } private bool already_observed (PlaylistDetails new_detail) @@ -76,11 +97,12 @@ public class PlaylistsMenuitem : PlayerItem return false; } - public void update_active_playlist(PlaylistDetails detail) + public void active_playlist_update (PlaylistDetails detail) { var update = detail.name; if ( update == "" ) update = "Choose Playlist"; - this.root_item.property_set ( MENUITEM_PROP_LABEL, update ); + this.root_item.property_set (MENUITEM_PROP_LABEL, update); + this.root_item.property_set (MENUITEM_PATH, detail.path); } private void submenu_item_activated (int menu_item_id) -- cgit v1.2.3 From 64ead2414c7e40155eb9241848b1837beb84ae7c Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 3 Mar 2011 17:13:15 +0000 Subject: final playlist delete tweak --- src/playlists-menu-item.vala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index bc39129..f4d7233 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -69,7 +69,10 @@ public class PlaylistsMenuitem : PlayerItem } } if (within == false){ - this.root_item.child_delete (item); + if (this.root_item.property_get (MENUITEM_PATH) == item.property_get (MENUITEM_PATH)){ + this.root_item.property_set (MENUITEM_PROP_LABEL, "Choose Playlist"); + } + this.root_item.child_delete (item); } } } -- cgit v1.2.3