From bc588fc03fdfc804a96f95f04c9f248932bfd885 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 12 Feb 2010 15:25:38 +0000 Subject: more trace for default sink bug --- src/pulse-manager.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pulse-manager.c b/src/pulse-manager.c index 82dbabf..e202c7d 100644 --- a/src/pulse-manager.c +++ b/src/pulse-manager.c @@ -101,13 +101,20 @@ Controllers & Utilities static gboolean sink_available() { - if (g_hash_table_size(sink_hash) < 1) + if (g_hash_table_size(sink_hash) < 1){ + g_debug("Sink_available returning false because sinks_hash is empty !!!"); return FALSE; + } sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); // TODO more testing is required for the case of having no available sink // This will need to iterate through the sinks to find an available // one as opposed to just picking the first - return ((g_strcasecmp(s->name, " auto_null ") != 0) && s->active_port == TRUE); + + g_debug("About to test for to see if the available sink is null"); + gboolean available = (g_strcasecmp(s->name, " auto_null ") != 0) && s->active_port == TRUE; + g_debug("sink_available (auto_null && !active_port) %i", available); + + return available; } static gboolean default_sink_is_muted() -- cgit v1.2.3 From 8699f5e6bd40857166afb7bf112585d28e21b8f6 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 12 Feb 2010 16:03:29 +0000 Subject: white space removal --- src/pulse-manager.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/pulse-manager.c b/src/pulse-manager.c index e202c7d..e32d723 100644 --- a/src/pulse-manager.c +++ b/src/pulse-manager.c @@ -113,7 +113,6 @@ static gboolean sink_available() g_debug("About to test for to see if the available sink is null"); gboolean available = (g_strcasecmp(s->name, " auto_null ") != 0) && s->active_port == TRUE; g_debug("sink_available (auto_null && !active_port) %i", available); - return available; } -- cgit v1.2.3 From 4a5a0923821b4b80cb8406f38d3d689c0a6f44e2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 12 Feb 2010 18:12:22 +0000 Subject: fixed the default sink issue arggg --- src/pulse-manager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pulse-manager.c b/src/pulse-manager.c index e32d723..d884da7 100644 --- a/src/pulse-manager.c +++ b/src/pulse-manager.c @@ -111,8 +111,8 @@ static gboolean sink_available() // one as opposed to just picking the first g_debug("About to test for to see if the available sink is null"); - gboolean available = (g_strcasecmp(s->name, " auto_null ") != 0) && s->active_port == TRUE; - g_debug("sink_available (auto_null && !active_port) %i", available); + gboolean available = (g_ascii_strncasecmp(s->name, " auto_null ") != 0); + g_debug("sink_available: %i", available); return available; } -- cgit v1.2.3 From 5a41275524ec324ae5a65712ccbb9ccf2d01c023 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 15 Feb 2010 12:42:08 +0000 Subject: default sink logic far more robust --- src/pulse-manager.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/pulse-manager.c b/src/pulse-manager.c index d884da7..aa3481a 100644 --- a/src/pulse-manager.c +++ b/src/pulse-manager.c @@ -44,6 +44,7 @@ static void pulse_sink_input_info_callback(pa_context *c, const pa_sink_input_in static void pulse_server_info_callback(pa_context *c, const pa_server_info *info, void *userdata); static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, void *userdata); static void destroy_sink_info(void *value); +static gboolean determine_sink_availability(); /* @@ -99,19 +100,30 @@ static void destroy_sink_info(void *value) Controllers & Utilities */ -static gboolean sink_available() +static gboolean determine_sink_availability() { + + // Firstly check to see if we have any sinks + // if not get the hell out of here ! if (g_hash_table_size(sink_hash) < 1){ g_debug("Sink_available returning false because sinks_hash is empty !!!"); + DEFAULT_SINK_INDEX = -1; return FALSE; } - sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); - // TODO more testing is required for the case of having no available sink - // This will need to iterate through the sinks to find an available - // one as opposed to just picking the first - g_debug("About to test for to see if the available sink is null"); - gboolean available = (g_ascii_strncasecmp(s->name, " auto_null ") != 0); + // Secondly, make sure the default sink index is set + // If the default sink index has not been set (via the server) it will attempt to set it to the value of the first + // index in the array of keys from the sink_hash. + GList *keys = g_hash_table_get_keys(sink_hash); + DEFAULT_SINK_INDEX = (DEFAULT_SINK_INDEX < 0) ? GPOINTER_TO_INT(g_list_first(keys)) : DEFAULT_SINK_INDEX; + + // Thirdly ensure the default sink index does not have the name "auto_null" + sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); + // Up until now the most rebost method to test this is to manually remove the available sink device + // kernel module and then reload (rmmod & modprobe). + // TODO: Edge case of dynamic loading and unloading of sinks should be handled also. + g_debug("About to test for to see if the available sink is null - s->name = %s", s->name); + gboolean available = g_ascii_strncasecmp("auto_null", s->name, 9) != 0; g_debug("sink_available: %i", available); return available; } @@ -228,18 +240,14 @@ Major candidate for refactoring. static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink, int eol, void *userdata) { if (eol > 0) { - gboolean device_available = sink_available(); + + gboolean device_available = determine_sink_availability(); if(device_available == TRUE) { - // Hopefully the PA server has set the default device if not default to 0 - DEFAULT_SINK_INDEX = (DEFAULT_SINK_INDEX < 0) ? 0 : DEFAULT_SINK_INDEX; - // TODO optimize - // Cache method returns! (unneccessary multiple utility calls) - // test_hash(); update_pa_state(TRUE, device_available, default_sink_is_muted(), get_default_sink_volume()); sound_service_dbus_update_sink_volume(dbus_service, get_default_sink_volume()); sound_service_dbus_update_sink_mute(dbus_service, default_sink_is_muted()); - g_debug("default sink index : %d", DEFAULT_SINK_INDEX); + g_debug("default sink index : %d", DEFAULT_SINK_INDEX); } else{ //Update the indicator to show PA either is not ready or has no available sink @@ -267,7 +275,6 @@ static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink, in static void pulse_default_sink_info_callback(pa_context *c, const pa_sink_info *info, int eol, void *userdata) { - g_debug("default sink info callback"); if (eol > 0) { if (pa_context_errno(c) == PA_ERR_NOENTITY) return; -- cgit v1.2.3 From a33c5276c9f07d54af523406445070bef6edf256 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 15 Feb 2010 15:23:54 +0000 Subject: Merge of cody's tweak to enable slider moving in the correct direction --- src/indicator-sound.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index a8bbeea..f2d59c3 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -375,6 +375,7 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); volume_slider = ido_scale_menu_item_new_with_range ("Volume", initial_volume_percent, 0, 100, 0.5); + g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL); GtkMenuItem *menu_volume_slider = GTK_MENU_ITEM(volume_slider); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_slider, parent); -- cgit v1.2.3 From 683d166080ad0be95e4c5374dfd6408472e24831 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 15 Feb 2010 16:34:51 +0000 Subject: added callback for key events - not working currently --- src/indicator-sound.c | 18 +++++++++++++++--- src/sound-service.c | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index f2d59c3..74c2ba4 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -83,6 +83,7 @@ static gboolean new_slider_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkWidget *widget); static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data); static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data); +static gint key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data); // DBUS communication static DBusGProxy *sound_dbus_proxy = NULL; @@ -315,11 +316,11 @@ get_icon (IndicatorObject * io) static void update_state(const gint state) { - g_debug("update state beginning - previous_state = %i", previous_state); +/* g_debug("update state beginning - previous_state = %i", previous_state);*/ previous_state = current_state; - g_debug("update state 3rd line - previous_state = %i", previous_state); +/* g_debug("update state 3rd line - previous_state = %i", previous_state);*/ current_state = state; gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); @@ -338,7 +339,7 @@ static void update_state(const gint state) static void determine_state_from_volume(gdouble volume_percent) { - g_debug("determine_state_from_volume - previous_state = %i", previous_state); +/* g_debug("determine_state_from_volume - previous_state = %i", previous_state);*/ gint state = previous_state; if (volume_percent < 30.0 && volume_percent > 0){ state = STATE_LOW; @@ -382,6 +383,7 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(slider_prop_change_cb), volume_slider); GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); + g_signal_connect(slider, "key_press_event", G_CALLBACK(key_press_cb), newitem); g_signal_connect(slider, "change-value", G_CALLBACK(user_change_value_event_cb), newitem); g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem); @@ -429,6 +431,16 @@ static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data) return FALSE; } +/** +key_press_cb: +**/ +static gint key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) +{ + g_debug("In the key press call back function"); + return -1; +} + + static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data) { DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data; diff --git a/src/sound-service.c b/src/sound-service.c index d5c4eae..228e560 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -124,8 +124,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); +/* close_pulse_activites();*/ +/* g_main_loop_quit(mainloop);*/ } return; } -- cgit v1.2.3 From 7071d039cbad013b52628e06c20415148440fe54 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 15 Feb 2010 17:27:16 +0000 Subject: set key events to listen to --- src/indicator-sound.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 74c2ba4..eadd0d0 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -382,20 +382,23 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_slider, parent); g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(slider_prop_change_cb), volume_slider); + // register slider changes listening on the range GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); - g_signal_connect(slider, "key_press_event", G_CALLBACK(key_press_cb), newitem); g_signal_connect(slider, "change-value", G_CALLBACK(user_change_value_event_cb), newitem); g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem); + // Set images on the ido primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider); gtk_image_set_from_icon_name(GTK_IMAGE(primary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)), GTK_ICON_SIZE_MENU); GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider); gtk_image_set_from_icon_name(GTK_IMAGE(secondary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)), GTK_ICON_SIZE_MENU); -/* GtkRange* range = (GtkRange*)slider; */ -/* gtk_range_set_value(range, initial_volume_percent); */ + // register Key-press listening on the widget + g_signal_connect(volume_slider, "key_press_event", G_CALLBACK(key_press_cb), newitem); + gtk_widget_set_events (volume_slider, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK); gtk_widget_show_all(volume_slider); + return TRUE; } -- cgit v1.2.3 From 19ee260d2275bdfe21a8c585973ca4110f7d7ea8 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 15 Feb 2010 21:22:10 +0000 Subject: correct key events detected --- src/indicator-sound.c | 51 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index eadd0d0..4ced74b 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -24,6 +24,7 @@ with this program. If not, see . #include #include #include +#include #include #include @@ -83,7 +84,7 @@ static gboolean new_slider_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkWidget *widget); static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data); static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data); -static gint key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data); +static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data); // DBUS communication static DBusGProxy *sound_dbus_proxy = NULL; @@ -367,6 +368,9 @@ get_menu (IndicatorObject * io) DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SLIDER_MENUITEM_TYPE, new_slider_item); + // register Key-press listening on the widget + g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), NULL); + return GTK_MENU(menu); } @@ -379,6 +383,7 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL); GtkMenuItem *menu_volume_slider = GTK_MENU_ITEM(volume_slider); + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_slider, parent); g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(slider_prop_change_cb), volume_slider); @@ -393,10 +398,6 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider); gtk_image_set_from_icon_name(GTK_IMAGE(secondary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)), GTK_ICON_SIZE_MENU); - // register Key-press listening on the widget - g_signal_connect(volume_slider, "key_press_event", G_CALLBACK(key_press_cb), newitem); - gtk_widget_set_events (volume_slider, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK); - gtk_widget_show_all(volume_slider); return TRUE; @@ -437,10 +438,44 @@ static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data) /** key_press_cb: **/ -static gint key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) +static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) { - g_debug("In the key press call back function"); - return -1; + + if(event->length > 0) + g_debug("The key event's string is '%s'\n", event->string); + + switch(event->keyval) + { + case GDK_Right: + if(event->state & GDK_CONTROL_MASK) + { + g_debug("right key was pressed with ctrl- volume set to 100"); + } + else + { + g_debug("right key was pressed - normal 5 percent increase"); + } + break; + case GDK_Left: + if(event->state & GDK_CONTROL_MASK) + { + g_debug("left key was pressed with ctrl- volume set to 0"); + } + else + { + g_debug("left key was pressed - normal 5 percent decrease"); + } + break; + case GDK_plus: + g_debug("Plus key was pressed"); + break; + case GDK_minus: + g_debug("minus key was pressed"); + break; + default: + break; + } + return FALSE; } -- cgit v1.2.3 From 5b2f72dcb953a9780f8bd3152493e5adc5b34745 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 16 Feb 2010 11:18:27 +0000 Subject: slider key controls should be working now --- src/indicator-sound.c | 72 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 4ced74b..cf1833c 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -20,7 +20,7 @@ PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ - +#include #include #include #include @@ -259,10 +259,20 @@ static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean blo static void catch_signal_sink_volume_update(DBusGProxy *proxy, gdouble volume_percent, gpointer userdata) { - g_debug("signal caught - update sink volume with value : %f", volume_percent); GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); GtkRange *range = (GtkRange*)slider; - gtk_range_set_value(range, volume_percent); + + // DEBUG + gdouble current_value = gtk_range_get_value(range); + g_debug("SIGNAL- update sink volume - current_value : %f and new value : %f", current_value, volume_percent); + + // Don't like this solution - too fuzzy + // Need the ability to detect if the slider is grabbed + if(floor(current_value) != floor(volume_percent)) + { + g_debug("Going to update slider value"); + gtk_range_set_value(range, volume_percent); + } determine_state_from_volume(volume_percent); } @@ -423,15 +433,15 @@ which will result in a programmatic value change of 0 or 100 (work around). static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data) { gdouble current_value = gtk_range_get_value(range); - if(current_value == 0 || current_value == 100) - { - DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data; - GValue value = {0}; - g_value_init(&value, G_TYPE_DOUBLE); - g_value_set_double(&value, current_value); - g_debug("Value changed listener - = %f", current_value); - dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0); - } +/* if(current_value == 0 || current_value == 100)*/ +/* {*/ + DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data; + GValue value = {0}; + g_value_init(&value, G_TYPE_DOUBLE); + g_value_set_double(&value, current_value); + g_debug("Value changed callback - = %f", current_value); + dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0); +/* }*/ return FALSE; } @@ -444,41 +454,65 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat if(event->length > 0) g_debug("The key event's string is '%s'\n", event->string); + GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); + GtkRange* range = (GtkRange*)slider; + gdouble current_value = gtk_range_get_value(range); + gdouble new_value = current_value; + const gdouble five_percent = 5; + switch(event->keyval) { case GDK_Right: if(event->state & GDK_CONTROL_MASK) { - g_debug("right key was pressed with ctrl- volume set to 100"); +/* g_debug("right key was pressed with ctrl- volume set to 100"); */ + new_value = 100; } else { - g_debug("right key was pressed - normal 5 percent increase"); +/* g_debug("right key was pressed - normal 5 percent increase"); */ + new_value = current_value + five_percent; } break; case GDK_Left: if(event->state & GDK_CONTROL_MASK) { - g_debug("left key was pressed with ctrl- volume set to 0"); +/* g_debug("left key was pressed with ctrl- volume set to 0"); */ + new_value = 0; } else { - g_debug("left key was pressed - normal 5 percent decrease"); +/* g_debug("left key was pressed - normal 5 percent decrease"); */ + new_value = current_value - five_percent; } break; case GDK_plus: - g_debug("Plus key was pressed"); +/* g_debug("Plus key was pressed");*/ + new_value = current_value + five_percent; break; case GDK_minus: - g_debug("minus key was pressed"); +/* g_debug("minus key was pressed");*/ + new_value = current_value - five_percent; break; default: break; } + +/* g_debug("new range value without being clamped = %f", new_value); */ + + new_value = CLAMP(new_value, 0, 100); + if(new_value != current_value) + { + g_debug("Attempting to set the range to %f", new_value); + gtk_range_set_value(range, new_value); + } return FALSE; } - +/** +This callback should only be called when the user actually drags the slider. +Turned off for now in favour of the non descriminating call back. +**/ static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data) { DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data; -- cgit v1.2.3 From 263c312a025fb7f235a55ba765c384cca8e833d4 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 16 Feb 2010 16:37:27 +0000 Subject: removed scaler from sink_volume setter --- src/sound-service-dbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index a4c6eda..99a9d34 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -194,7 +194,7 @@ void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, gboolean void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_volume) { SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); - priv->volume_percent = sink_volume * 100; + priv->volume_percent = sink_volume; g_debug("Emitting signal: SINK_VOLUME_UPDATE, with sink_volme %f", priv->volume_percent); g_signal_emit(obj, -- cgit v1.2.3 From de3f4ca3c7e1fac297b037edbf4e35109d1ea2f3 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 16 Feb 2010 16:38:03 +0000 Subject: updated names of icons on advise from design team --- src/indicator-sound.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index cf1833c..26b73a6 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -164,14 +164,13 @@ static void prepare_state_machine() { // TODO we need three more images volume_states = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); - g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED), g_strdup("audio-volume-muted")); - g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_ZERO), g_strdup(/*"audio-volume-zero"*/"audio-volume-muted")); - g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_LOW), g_strdup("audio-volume-low")); - g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MEDIUM), g_strdup("audio-volume-medium")); - g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_HIGH), g_strdup("audio-volume-high")); - g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT), g_strdup(/*"audio-volume-muted-blocking"*/"audio-volume-muted")); - g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_SINKS_NONE), g_strdup(/*"audio-output-none"*/"audio-volume-muted")); - //test_images_hash(); + g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED), g_strdup("audio-volume-muted-panel")); + g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_ZERO), g_strdup("audio-volume-zero-panel")); + g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_LOW), g_strdup("audio-volume-low-panel")); + g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MEDIUM), g_strdup("audio-volume-medium-panel")); + g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_HIGH), g_strdup("audio-volume-high-panel")); + g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT), g_strdup("audio-volume-muted-blocking-panel")); + g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_SINKS_NONE), g_strdup("audio-output-none-panel")); } static void -- cgit v1.2.3 From 34483439f5254a35daf6dbd47b959936edc499e1 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 16 Feb 2010 16:40:17 +0000 Subject: Volume handling now much smoother / calculating everything using Pa_volume_norm --- src/pulse-manager.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/pulse-manager.c b/src/pulse-manager.c index aa3481a..ac3d609 100644 --- a/src/pulse-manager.c +++ b/src/pulse-manager.c @@ -189,18 +189,15 @@ void set_sink_volume(gdouble percent) g_warning("We have no default sink !!! - returning after not attempting to set any volume of any sink"); return; } - gdouble linear_input = (gdouble)(percent); - linear_input /= 100.0; - g_debug("linear double input = %f", linear_input); - pa_volume_t new_volume = pa_sw_volume_from_linear(linear_input); - // Use this to achieve more accurate scaling using the base volume (in the sink struct already!) - //pa_volume_t new_volume = (pa_volume_t) ((GPOINTER_TO_INT(linear_input) * s->base_volume) / 100); - g_debug("about to try to set the sw volume to a linear volume of %f", pa_sw_volume_to_linear(new_volume)); - g_debug("and an actual volume of %f", (gdouble)new_volume); - pa_cvolume dev_vol; + sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); + + pa_volume_t new_volume = (pa_volume_t) ((percent * PA_VOLUME_NORM) / 100); + g_debug("new_volume double check :%f", pa_sw_volume_to_linear(new_volume)); + g_debug("new volume calculated :%f", (gdouble)new_volume); + pa_cvolume dev_vol; pa_cvolume_set(&dev_vol, s->volume.channels, new_volume); - + // TODO why don't you update the sink_info here with the appropriate pa_cvolume (&dev_vol) pa_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &dev_vol, NULL, NULL)); } @@ -321,7 +318,6 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v if(position >= 0) // => index is within the keys of the hash. { sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(info->index)); - //g_debug("attempting to update sink with name %s", s->name); s->name = g_strdup(info->name); s->description = g_strdup(info->description); s->icon_name = g_strdup(pa_proplist_gets(info->proplist, PA_PROP_DEVICE_ICON_NAME)); @@ -336,14 +332,11 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v { //update the UI pa_volume_t vol = pa_cvolume_avg(&s->volume); - // Use the base of the device to ensure maximum acceptable levels on the hardware - gdouble volume_percent = (vol/s->base_volume) * 100; - g_debug("When using base volume => volume = %f", volume_percent); - g_debug("about to update ui with linear volume of %f", pa_sw_volume_to_linear(vol)); - sound_service_dbus_update_sink_volume(dbus_service, pa_sw_volume_to_linear(vol)); + gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; + g_debug("Updating volume from PA manager with volume = %f", volume_percent); + sound_service_dbus_update_sink_volume(dbus_service, volume_percent); if (mute_changed == TRUE) sound_service_dbus_update_sink_mute(dbus_service, s->mute); - update_mute_ui(s->mute); } } -- cgit v1.2.3 From 59cf6bdba1c4206a9587c9b642a427e6db1a2f2c Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 17 Feb 2010 17:21:53 +0000 Subject: Handles slider feedback loop with the service nicely plus tidy up --- src/indicator-sound.c | 91 ++++++++++++++++++++------------------------------- 1 file changed, 36 insertions(+), 55 deletions(-) (limited to 'src') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 26b73a6..f9e98ed 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -82,7 +82,7 @@ static GtkMenu * get_menu (IndicatorObject * io); static GtkWidget *volume_slider = NULL; static gboolean new_slider_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkWidget *widget); -static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data); +/*static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data);*/ static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data); static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data); @@ -148,15 +148,6 @@ static void indicator_sound_init (IndicatorSound *self) } -/*static void test_images_hash()*/ -/*{*/ -/* g_debug("about to test the images hash"); */ -/* gchar* current_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state));*/ -/* g_debug("start up current image name = %s", current_name); */ -/* gchar* previous_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(previous_state));*/ -/* g_debug("start up previous image name = %s", previous_name); */ -/*}*/ - /* Prepare states Array. */ @@ -264,14 +255,7 @@ static void catch_signal_sink_volume_update(DBusGProxy *proxy, gdouble volume_pe // DEBUG gdouble current_value = gtk_range_get_value(range); g_debug("SIGNAL- update sink volume - current_value : %f and new value : %f", current_value, volume_percent); - - // Don't like this solution - too fuzzy - // Need the ability to detect if the slider is grabbed - if(floor(current_value) != floor(volume_percent)) - { - g_debug("Going to update slider value"); - gtk_range_set_value(range, volume_percent); - } + gtk_range_set_value(range, volume_percent); determine_state_from_volume(volume_percent); } @@ -337,15 +321,6 @@ static void update_state(const gint state) gtk_image_set_from_icon_name(speaker_image, image_name, GTK_ICON_SIZE_MENU); } -/*static void revert_state()*/ -/*{*/ - -/* g_debug("revert state beginning - previous_state = %i", previous_state);*/ -/* current_state = previous_state;*/ -/* gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state));*/ -/* gtk_image_set_from_icon_name(speaker_image, image_name, GTK_ICON_SIZE_MENU);*/ -/* g_debug("after reverting back to previous state of %i", current_state);*/ -/*}*/ static void determine_state_from_volume(gdouble volume_percent) { @@ -377,12 +352,16 @@ get_menu (IndicatorObject * io) DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SLIDER_MENUITEM_TYPE, new_slider_item); - // register Key-press listening on the widget + // register Key-press listening on the menu widget as the slider does not allow this. g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), NULL); return GTK_MENU(menu); } +/** +new_slider_item: +Create a new dBusMenu Slider item, register the +**/ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); @@ -398,7 +377,7 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p // register slider changes listening on the range GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); - g_signal_connect(slider, "change-value", G_CALLBACK(user_change_value_event_cb), newitem); +/* g_signal_connect(slider, "change-value", G_CALLBACK(user_change_value_event_cb), newitem); */ g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem); // Set images on the ido @@ -412,8 +391,10 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p return TRUE; } -/* Whenever we have a property change on a DbusmenuMenuitem - we need to be responsive to that. */ +/** +slider_prop_change_cb: +Whenever we have a property change on a DbusmenuMenuitem this will be called. +**/ static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkWidget *widget) { g_debug("slider_prop_change_cb - dodgy updater "); @@ -425,22 +406,21 @@ static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * } /** -This callback will get triggered irregardless of whether its a user change or a programmatic change -Our usecase for this particular callback is only interested if the slider is changed by the user hitting either icon -which will result in a programmatic value change of 0 or 100 (work around). +value_changed_event_cb: +This callback will get triggered irregardless of whether its a user change or a programmatic change. **/ static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data) { - gdouble current_value = gtk_range_get_value(range); -/* if(current_value == 0 || current_value == 100)*/ -/* {*/ + gdouble current_value = CLAMP(gtk_range_get_value(range), 0, 100); DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data; GValue value = {0}; g_value_init(&value, G_TYPE_DOUBLE); g_value_set_double(&value, current_value); g_debug("Value changed callback - = %f", current_value); - dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0); -/* }*/ + dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0); + // This is not ideal in that the icon ui will update on ui actions and not on actual service feedback. + // but necessary for now as the server does not send volume update information if the source of change was this ui. + determine_state_from_volume(current_value); return FALSE; } @@ -450,9 +430,8 @@ key_press_cb: static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) { - if(event->length > 0) - g_debug("The key event's string is '%s'\n", event->string); - +/* if(event->length > 0)*/ +/* g_debug("The key event's string is '%s'\n", event->string);*/ GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); GtkRange* range = (GtkRange*)slider; gdouble current_value = gtk_range_get_value(range); @@ -502,7 +481,7 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat new_value = CLAMP(new_value, 0, 100); if(new_value != current_value) { - g_debug("Attempting to set the range to %f", new_value); + g_debug("Attempting to set the range from the key listener to %f", new_value); gtk_range_set_value(range, new_value); } return FALSE; @@ -510,18 +489,20 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat /** This callback should only be called when the user actually drags the slider. -Turned off for now in favour of the non descriminating call back. +Turned off for now in favour of the non descriminating value-changed call back. +Once the grabbing listener is implemented on the slider may revert to using this. +Its another tool for filtering unwanted volume change updates. **/ -static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data) -{ - DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data; - gdouble clamped_input = CLAMP(input_value, 0, 100); - GValue value = {0}; - g_debug("User input on SLIDER - = %f", clamped_input); - g_value_init(&value, G_TYPE_DOUBLE); - g_value_set_double(&value, clamped_input); - dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0); - return FALSE; -} +/*static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data)*/ +/*{*/ +/* DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data;*/ +/* gdouble clamped_input = CLAMP(input_value, 0, 100);*/ +/* GValue value = {0};*/ +/* g_debug("User input on SLIDER - = %f", clamped_input);*/ +/* g_value_init(&value, G_TYPE_DOUBLE);*/ +/* g_value_set_double(&value, clamped_input);*/ +/* dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0);*/ +/* return FALSE; */ +/*} */ -- cgit v1.2.3 From 0bc2668c7bffba29b021779230507b36a2fcc8ed Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 17 Feb 2010 17:25:44 +0000 Subject: Now handles dynamic switching of sinks - filers volume signal updates on the basis of whether the original update came from the indicator and a tidy up --- src/pulse-manager.c | 111 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 89 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/pulse-manager.c b/src/pulse-manager.c index 269ac58..8fa47eb 100644 --- a/src/pulse-manager.c +++ b/src/pulse-manager.c @@ -43,10 +43,16 @@ static void context_success_callback(pa_context *c, int success, void *userdata) static void pulse_sink_input_info_callback(pa_context *c, const pa_sink_input_info *info, int eol, void *userdata); static void pulse_server_info_callback(pa_context *c, const pa_server_info *info, void *userdata); static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, void *userdata); +static void pulse_source_info_callback(pa_context *c, const pa_source_info *i, int eol, void *userdata); static void destroy_sink_info(void *value); static gboolean determine_sink_availability(); +/** +Refactoring notes +Push all UI updates out through update PA state in the service. +**/ + /* Entry point */ @@ -167,6 +173,13 @@ static void mute_each_sink(gpointer key, gpointer value, gpointer user_data) { sink_info *info = (sink_info*)value; pa_operation_unref(pa_context_set_sink_mute_by_index(pulse_context, info->index, GPOINTER_TO_INT(user_data), context_success_callback, NULL)); + if(GPOINTER_TO_INT(user_data) == 1){ + sound_service_dbus_update_sink_mute(dbus_service, TRUE); + } + else{ + sound_service_dbus_update_sink_volume(dbus_service, get_default_sink_volume()); + } + g_debug("in the pulse manager: mute each sink %i", GPOINTER_TO_INT(user_data)); } @@ -197,8 +210,9 @@ void set_sink_volume(gdouble percent) g_debug("new volume calculated :%f", (gdouble)new_volume); pa_cvolume dev_vol; pa_cvolume_set(&dev_vol, s->volume.channels, new_volume); - // TODO why don't you update the sink_info here with the appropriate pa_cvolume (&dev_vol) + s->volume = dev_vol; pa_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &dev_vol, NULL, NULL)); + } @@ -242,9 +256,9 @@ static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink, in if(device_available == TRUE) { update_pa_state(TRUE, device_available, default_sink_is_muted(), get_default_sink_volume()); - sound_service_dbus_update_sink_volume(dbus_service, get_default_sink_volume()); - sound_service_dbus_update_sink_mute(dbus_service, default_sink_is_muted()); - g_debug("default sink index : %d", DEFAULT_SINK_INDEX); + //sound_service_dbus_update_sink_volume(dbus_service, get_default_sink_volume()); + //sound_service_dbus_update_sink_mute(dbus_service, default_sink_is_muted()); + //g_debug("default sink index : %d", DEFAULT_SINK_INDEX); } else{ //Update the indicator to show PA either is not ready or has no available sink @@ -281,7 +295,17 @@ static void pulse_default_sink_info_callback(pa_context *c, const pa_sink_info * else{ DEFAULT_SINK_INDEX = info->index; g_debug("Just set the default sink index to %i", DEFAULT_SINK_INDEX); - pa_operation_unref(pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL)); + GList *keys = g_hash_table_get_keys(sink_hash); + gint position = g_list_index(keys, GINT_TO_POINTER(info->index)); + // Only update sink-list if the index is not in our already fetched list. + if(position < 0) + { + pa_operation_unref(pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL)); + } + else + { + update_pa_state(TRUE, determine_sink_availability(), default_sink_is_muted(), get_default_sink_volume()); + } } } @@ -322,19 +346,22 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v s->description = g_strdup(info->description); s->icon_name = g_strdup(pa_proplist_gets(info->proplist, PA_PROP_DEVICE_ICON_NAME)); s->active_port = (info->active_port != NULL); - // NASTY!! - gboolean mute_changed = s->mute != !!info->mute; s->mute = !!info->mute; + gboolean mute_changed = s->mute != !!info->mute; + gboolean volume_changed = (pa_cvolume_equal(&info->volume, &s->volume) == 0); s->volume = info->volume; s->base_volume = info->base_volume; s->channel_map = info->channel_map; if(DEFAULT_SINK_INDEX == s->index) { //update the UI - pa_volume_t vol = pa_cvolume_avg(&s->volume); - gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; - g_debug("Updating volume from PA manager with volume = %f", volume_percent); - sound_service_dbus_update_sink_volume(dbus_service, volume_percent); + if (volume_changed == TRUE) + { + pa_volume_t vol = pa_cvolume_avg(&s->volume); + gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; + g_debug("Updating volume from PA manager with volume = %f", volume_percent); + sound_service_dbus_update_sink_volume(dbus_service, volume_percent); + } if (mute_changed == TRUE) sound_service_dbus_update_sink_mute(dbus_service, s->mute); update_mute_ui(s->mute); @@ -382,24 +409,64 @@ static void pulse_server_info_callback(pa_context *c, const pa_server_info *info pa_operation_unref(operation); } -static void subscribed_events_callback(pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata){ - switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) { +static void pulse_source_info_callback(pa_context *c, const pa_source_info *i, int eol, void *userdata) +{ + g_debug("pulse source info callback"); +} + + +static void subscribed_events_callback(pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata) +{ + switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) + { case PA_SUBSCRIPTION_EVENT_SINK: - if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { - //TODO handle the remove event => if its our default sink - grey out the ui with update_pa_state - } else { + g_debug("PA_SUBSCRIPTION_EVENT_SINK event triggered"); + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) + { + //TODO handle the remove event => if its our default sink - update date pa state + } else + { pa_operation_unref(pa_context_get_sink_info_by_index(c, index, update_sink_info, userdata)); } break; case PA_SUBSCRIPTION_EVENT_SINK_INPUT: - // This will be triggered when the sink receives input from a new stream - // If a playback client is paused and then resumed this will NOT trigger this event. - pa_operation_unref(pa_context_get_sink_input_info(c, index, pulse_sink_input_info_callback, userdata)); - break; + g_debug("PA_SUBSCRIPTION_EVENT_SINK_INPUT event triggered!!"); + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) + { + //TODO handle the remove event + } + else + { + pa_operation_unref(pa_context_get_sink_input_info(c, index, pulse_sink_input_info_callback, userdata)); + } + break; + case PA_SUBSCRIPTION_EVENT_SOURCE: + g_debug("PA_SUBSCRIPTION_EVENT_SOURCE of some description ???"); + + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) + { + //TODO handle the remove event + } + else + { + pa_operation *o; + if (!(o = pa_context_get_source_info_by_index(c, index, pulse_source_info_callback, userdata))) { + g_warning("pa_context_get_source_info_by_index() failed"); + return; + } + pa_operation_unref(o); + } + break; case PA_SUBSCRIPTION_EVENT_SERVER: - if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_SINK ) { - g_debug("server change of some sink type ???"); + g_debug("PA_SUBSCRIPTION_EVENT_SERVER change of some description ???"); + pa_operation *o; + if(!(o = pa_context_get_server_info(c, pulse_server_info_callback, userdata))) + { + g_warning("pa_context_get_server_info() failed"); + return; } + pa_operation_unref(o); + break; } } -- cgit v1.2.3 From b862da95e5e13c69fed637e4fa4b85d894b637ce Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 17 Feb 2010 17:28:22 +0000 Subject: update_pa_state, now expected to be called throughout lifetime of service plus tidy up --- src/sound-service.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/sound-service.c b/src/sound-service.c index d5c4eae..c66ec78 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -97,6 +97,7 @@ void update_mute_ui(gboolean incoming_mute_value) { b_all_muted = incoming_mute_value; dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _(b_all_muted == FALSE ? "Mute All" : "Unmute")); + //dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), DBUSMENU_MENUITEM_PROP_ENABLED, b_all_muted); } static void set_global_mute_from_ui() @@ -104,13 +105,7 @@ static void set_global_mute_from_ui() b_all_muted = !b_all_muted; toggle_global_mute(b_all_muted); dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _(b_all_muted == FALSE ? "Mute All" : "Unmute")); - -/* GValue value = {0};*/ -/* g_value_init(&value, G_TYPE_DOUBLE);*/ -/* g_value_set_double(&value, 99.0);*/ -/* // Testing*/ -/* g_debug("BUGGY volume update");*/ -/* dbusmenu_menuitem_property_set_value(DBUSMENU_MENUITEM(volume_slider_menuitem), DBUSMENU_SLIDER_MENUITEM_PROP_VOLUME, &value);*/ + //dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), DBUSMENU_MENUITEM_PROP_ENABLED, b_all_muted); } @@ -137,7 +132,12 @@ void update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_m b_pulse_ready = pa_state; volume_percent = percent; g_debug("update pa state with state %i, availability of %i, mute value of %i and a volume percent is %f", pa_state, sink_available, sink_muted, volume_percent); - rebuild_sound_menu(root_menuitem, dbus_interface); + sound_service_dbus_update_sink_volume(dbus_interface, percent); + sound_service_dbus_update_sink_mute(dbus_interface, sink_muted); + + // Only rebuild the menu on start up... + if(volume_slider_menuitem == NULL) + rebuild_sound_menu(root_menuitem, dbus_interface); } @@ -169,7 +169,7 @@ main (int argc, char ** argv) dbusmenu_server_set_root(server, root_menuitem); establish_pulse_activities(dbus_interface); -/* // THIS DOES NOT WORK FROM HERE*/ +/* // THIS DOES NOT WORK FROM HERE - race condition ?!?*/ /* GValue value = {0};*/ /* g_value_init(&value, G_TYPE_DOUBLE);*/ /* g_value_set_double(&value, volume_percent * 100);*/ -- cgit v1.2.3 From 7de60c339a2e7e9a85618081e06d6eff66810377 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 18 Feb 2010 14:30:43 +0000 Subject: Dont listen to key events once the state is muted --- src/indicator-sound.c | 3 +++ src/pulse-manager.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 9c73df4..8e79db6 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -326,6 +326,7 @@ static void update_state(const gint state) static void determine_state_from_volume(gdouble volume_percent) { /* g_debug("determine_state_from_volume - previous_state = %i", previous_state);*/ + gint state = previous_state; if (volume_percent < 30.0 && volume_percent > 0){ state = STATE_LOW; @@ -431,6 +432,8 @@ key_press_cb: **/ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) { + if (current_state == STATE_MUTED) + return FALSE; GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); GtkRange* range = (GtkRange*)slider; diff --git a/src/pulse-manager.c b/src/pulse-manager.c index 52f9cba..9b9d7cd 100644 --- a/src/pulse-manager.c +++ b/src/pulse-manager.c @@ -342,7 +342,7 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v if(DEFAULT_SINK_INDEX == s->index) { //update the UI - if (volume_changed == TRUE) + if (volume_changed == TRUE && s->mute == FALSE) { pa_volume_t vol = pa_cvolume_avg(&s->volume); gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; -- cgit v1.2.3