diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-02-18 16:56:17 +0000 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-02-18 16:56:17 +0000 |
commit | 9a424c26c67544aafdd7cff2d66519b1c72e8aa0 (patch) | |
tree | 082a98809d9233df1ccc70fed67c678399e98822 | |
parent | 5882cc24cda26ab021224c66abf579b6b603617b (diff) | |
download | ayatana-indicator-sound-9a424c26c67544aafdd7cff2d66519b1c72e8aa0.tar.gz ayatana-indicator-sound-9a424c26c67544aafdd7cff2d66519b1c72e8aa0.tar.bz2 ayatana-indicator-sound-9a424c26c67544aafdd7cff2d66519b1c72e8aa0.zip |
bug free afaics ...
-rw-r--r-- | src/active-sink.c | 4 | ||||
-rw-r--r-- | src/active-sink.h | 2 | ||||
-rw-r--r-- | src/common-defs.h | 2 | ||||
-rw-r--r-- | src/pulseaudio-mgr.c | 16 | ||||
-rw-r--r-- | src/settings-manager.vala | 2 | ||||
-rw-r--r-- | src/voip-input-menu-item.c | 36 | ||||
-rw-r--r-- | src/voip-input-menu-item.h | 2 |
7 files changed, 40 insertions, 24 deletions
diff --git a/src/active-sink.c b/src/active-sink.c index 2e212e7..ce0e135 100644 --- a/src/active-sink.c +++ b/src/active-sink.c @@ -98,10 +98,10 @@ active_sink_activate_voip_item (ActiveSink* self, gint sink_input_index, gint cl } void -active_sink_deactivate_voip_source (ActiveSink* self) +active_sink_deactivate_voip_source (ActiveSink* self, gboolean visible) { ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); - voip_input_menu_item_deactivate_source (priv->voip_input_menu_item); + voip_input_menu_item_deactivate_source (priv->voip_input_menu_item, visible); } void diff --git a/src/active-sink.h b/src/active-sink.h index 52f0e47..57b3079 100644 --- a/src/active-sink.h +++ b/src/active-sink.h @@ -74,7 +74,7 @@ gint active_sink_get_current_sink_input_index (ActiveSink* sink); gboolean active_sink_is_voip_source_populated (ActiveSink* sink); gint active_sink_get_source_index (ActiveSink* self); void active_sink_determine_blocking_state (ActiveSink* self); -void active_sink_deactivate_voip_source (ActiveSink* self); +void active_sink_deactivate_voip_source (ActiveSink* self, gboolean visible); void active_sink_deactivate_voip_client (ActiveSink* self); SoundState active_sink_get_state (ActiveSink* self); diff --git a/src/common-defs.h b/src/common-defs.h index 1a4e71e..2184a48 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -31,7 +31,7 @@ typedef enum { AVAILABLE }SoundState; -#define DEVICE_NOT_ACTIVE -1 +#define NOT_ACTIVE -1 #define DBUSMENU_PROPERTY_EMPTY -1 /* DBUS Custom Items */ diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index e319793..76102e4 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -225,7 +225,7 @@ pm_subscribed_events_callback (pa_context *c, if (index != active_sink_get_source_index (sink)) return; if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { - active_sink_deactivate_voip_source (sink); + active_sink_deactivate_voip_source (sink, FALSE); } else{ pa_operation_unref (pa_context_get_source_info_by_index (c, @@ -421,8 +421,12 @@ pm_default_sink_info_callback (pa_context *c, if (IS_ACTIVE_SINK (userdata) == FALSE){ g_warning ("Default sink info callback - our user data is not what we think it should be"); return; - } - g_debug ("server has handed us a default sink"); + } + // Only repopulate if there is a change with regards the index + if (active_sink_get_index (ACTIVE_SINK (userdata)) == info->index) + return; + + g_debug ("Pulse Server has handed us a new default sink"); active_sink_populate (ACTIVE_SINK (userdata), info); } } @@ -523,7 +527,11 @@ pm_default_source_info_callback (pa_context *c, g_warning ("Default sink info callback - our user data is not what we think it should be"); return; } - g_debug ("server has handed us a default source"); + // If there is an index change we need to change our cached source + if (active_sink_get_source_index (ACTIVE_SINK (userdata)) == info->index) + return; + g_debug ("Pulse Server has handed us a new default source"); + active_sink_deactivate_voip_source (ACTIVE_SINK (userdata), TRUE); active_sink_update_voip_input_source (ACTIVE_SINK (userdata), info); } } diff --git a/src/settings-manager.vala b/src/settings-manager.vala index 057a47b..6800423 100644 --- a/src/settings-manager.vala +++ b/src/settings-manager.vala @@ -71,6 +71,7 @@ public class SettingsManager : GLib.Object // Convenient debug method inorder to provide visability over // the contents of both interested and blacklisted containers in its gsettings +/** private void reveal_contents() { var already_interested = this.settings.get_strv ("interested-media-players"); @@ -87,4 +88,5 @@ public class SettingsManager : GLib.Object debug ("interested array size = %i", already_interested.length); debug ("blacklisted array size = %i", blacklisted.length); } +**/ } diff --git a/src/voip-input-menu-item.c b/src/voip-input-menu-item.c index 19bc92d..b98be8d 100644 --- a/src/voip-input-menu-item.c +++ b/src/voip-input-menu-item.c @@ -82,10 +82,10 @@ voip_input_menu_item_init (VoipInputMenuItem *self) DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE ); - priv->source_index = DEVICE_NOT_ACTIVE; - priv->sink_input_index = DEVICE_NOT_ACTIVE; - priv->client_index = DEVICE_NOT_ACTIVE; - priv->mute = DEVICE_NOT_ACTIVE; + priv->source_index = NOT_ACTIVE; + priv->sink_input_index = NOT_ACTIVE; + priv->client_index = NOT_ACTIVE; + priv->mute = NOT_ACTIVE; } static void @@ -152,7 +152,7 @@ voip_input_menu_item_update (VoipInputMenuItem* item, { VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item); // only overwrite the constants of each source if the device has changed - if (priv->source_index == DEVICE_NOT_ACTIVE){ + if (priv->source_index == NOT_ACTIVE){ priv->base_volume = source->base_volume; priv->volume_steps = source->n_volume_steps; priv->channel_map = source->channel_map; @@ -170,7 +170,6 @@ voip_input_menu_item_update (VoipInputMenuItem* item, // in this order - volume first mute last!! if (priv->mute != source->mute){ g_debug ("voip menu item - update - mute = %i", priv->mute); - GVariant* new_mute_update = g_variant_new_int32 (source->mute); dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(item), DBUSMENU_VOIP_INPUT_MENUITEM_MUTE, @@ -189,8 +188,8 @@ voip_input_menu_item_is_interested (VoipInputMenuItem* item, VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item); // Check to make sure we are not handling another voip beforehand and that we // have an active sink (might need to match up at start up) - if (priv->sink_input_index != DEVICE_NOT_ACTIVE && - priv->source_index != DEVICE_NOT_ACTIVE){ + if (priv->sink_input_index != NOT_ACTIVE && + priv->source_index != NOT_ACTIVE){ return FALSE; } @@ -205,7 +204,7 @@ gboolean voip_input_menu_item_is_populated (VoipInputMenuItem* item) { VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item); - return priv->source_index != DEVICE_NOT_ACTIVE; + return priv->source_index != NOT_ACTIVE; } gint @@ -223,20 +222,27 @@ voip_input_menu_item_get_sink_input_index (VoipInputMenuItem* item) return priv->sink_input_index; } +/** + * If the pulse server informs of a default source change + * or the source in question is removed. + * @param item + */ void -voip_input_menu_item_deactivate_source (VoipInputMenuItem* item) +voip_input_menu_item_deactivate_source (VoipInputMenuItem* item, gboolean visible) { VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item); - priv->source_index = DEVICE_NOT_ACTIVE; - voip_input_menu_item_enable (item, FALSE); + priv->source_index = NOT_ACTIVE; + dbusmenu_menuitem_property_set_bool( DBUSMENU_MENUITEM(item), + DBUSMENU_MENUITEM_PROP_VISIBLE, + visible ); } void voip_input_menu_item_deactivate_voip_client (VoipInputMenuItem* item) { VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item); - priv->client_index = DEVICE_NOT_ACTIVE; - priv->sink_input_index = DEVICE_NOT_ACTIVE; + priv->client_index = NOT_ACTIVE; + priv->sink_input_index = NOT_ACTIVE; voip_input_menu_item_enable (item, FALSE); } @@ -245,7 +251,7 @@ voip_input_menu_item_enable (VoipInputMenuItem* item, gboolean active) { VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item); - if (priv->source_index == DEVICE_NOT_ACTIVE && active == TRUE) { + if (priv->source_index == NOT_ACTIVE && active == TRUE) { g_warning ("Tried to enable the VOIP menuitem but we don't have an active source ??"); active = FALSE; } diff --git a/src/voip-input-menu-item.h b/src/voip-input-menu-item.h index 5a62393..5a39d8a 100644 --- a/src/voip-input-menu-item.h +++ b/src/voip-input-menu-item.h @@ -58,7 +58,7 @@ gint voip_input_menu_item_get_index (VoipInputMenuItem* item); gint voip_input_menu_item_get_sink_input_index (VoipInputMenuItem* item); -void voip_input_menu_item_deactivate_source (VoipInputMenuItem* item); +void voip_input_menu_item_deactivate_source (VoipInputMenuItem* item, gboolean visible); void voip_input_menu_item_deactivate_voip_client (VoipInputMenuItem* item); VoipInputMenuItem* voip_input_menu_item_new (ActiveSink* sink); |