diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-03-24 15:22:30 +0000 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-03-24 15:22:30 +0000 |
commit | b4dc15ac004d49a46cba1b88c1c5cdf8c12755ba (patch) | |
tree | a2a7baa26ca72039a27a5d05934e3ba0092212d7 | |
parent | 6856359f7cb8544bd51a141fea9eeab28e6d1b25 (diff) | |
download | ayatana-indicator-sound-b4dc15ac004d49a46cba1b88c1c5cdf8c12755ba.tar.gz ayatana-indicator-sound-b4dc15ac004d49a46cba1b88c1c5cdf8c12755ba.tar.bz2 ayatana-indicator-sound-b4dc15ac004d49a46cba1b88c1c5cdf8c12755ba.zip |
now using the source output
-rw-r--r-- | src/device.c | 8 | ||||
-rw-r--r-- | src/device.h | 4 | ||||
-rw-r--r-- | src/pulseaudio-mgr.c | 61 | ||||
-rw-r--r-- | src/voip-input-menu-item.c | 18 | ||||
-rw-r--r-- | src/voip-input-menu-item.h | 4 |
5 files changed, 46 insertions, 49 deletions
diff --git a/src/device.c b/src/device.c index 79b7b50..bf4a543 100644 --- a/src/device.c +++ b/src/device.c @@ -123,10 +123,10 @@ device_sink_update (Device* self, } gint -device_get_current_sink_input_index (Device* self) +device_get_voip_source_output_index (Device* self) { DevicePrivate* priv = DEVICE_GET_PRIVATE (self); - return voip_input_menu_item_get_sink_input_index (priv->voip_input_menu_item); + return voip_input_menu_item_get_source_output_index (priv->voip_input_menu_item); } static void @@ -211,11 +211,11 @@ device_is_sink_populated (Device* self) } void -device_activate_voip_item (Device* self, gint sink_input_index, gint client_index) +device_activate_voip_item (Device* self, gint source_output_index, gint client_index) { DevicePrivate* priv = DEVICE_GET_PRIVATE (self); if (voip_input_menu_item_is_interested (priv->voip_input_menu_item, - sink_input_index, + source_output_index, client_index)){ voip_input_menu_item_enable (priv->voip_input_menu_item, TRUE); } diff --git a/src/device.h b/src/device.h index 9c74344..ccaf4ea 100644 --- a/src/device.h +++ b/src/device.h @@ -68,8 +68,8 @@ void device_ensure_sink_is_unmuted (Device* self); // source and sinkinput/client related for VOIP functionality void device_update_voip_input_source (Device* sink, const pa_source_info* update); -void device_activate_voip_item (Device* sink, gint sink_input_index, gint client_index); -gint device_get_current_sink_input_index (Device* sink); +void device_activate_voip_item (Device* sink, gint source_output_index, gint client_index); +gint device_get_voip_source_output_index (Device* sink); gboolean device_is_voip_source_populated (Device* sink); gint device_get_source_index (Device* self); void device_determine_blocking_state (Device* self); diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index 2ead17c..a31084a 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -260,17 +260,7 @@ pm_subscribed_events_callback (pa_context *c, } break; case PA_SUBSCRIPTION_EVENT_SINK_INPUT: - g_debug ("sink input event"); - if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { - gint cached_index = device_get_current_sink_input_index (sink); - - g_debug ("Just saw a sink input removal event - index = %i and cached index = %i", index, cached_index); - - if (index == cached_index){ - device_deactivate_voip_client (sink); - } - } - else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) { + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) { g_debug ("some new sink input event ? - index = %i", index); // Maybe blocking state ?. pa_operation_unref (pa_context_get_sink_input_info (c, @@ -281,8 +271,11 @@ pm_subscribed_events_callback (pa_context *c, case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT: g_debug ("source output event"); if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { - //gint cached_index = device_get_current_sink_input_index (sink); - //g_debug ("Just saw a sink input removal event - index = %i and cached index = %i", index, cached_index); + gint cached_source_output_index = device_get_voip_source_output_index (sink); + if (index == cached_source_output_index){ + g_debug ("Just saw a source output removal event - index = %i and cached index = %i", index, cached_source_output_index); + device_deactivate_voip_client (sink); + } } else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) { g_debug ("some new source output event ? - index = %i", index); @@ -487,21 +480,39 @@ pm_sink_input_info_callback (pa_context *c, g_warning("Sink input info callback : SINK INPUT INFO IS NULL or our user_data is not what we think it should be"); return; } + Device* a_sink = DEVICE (userdata); + // And finally check for the mute blocking state + if (device_get_sink_index (a_sink) == info->sink){ + device_determine_blocking_state (a_sink); + } + } +} - if (IS_DEVICE (userdata) == FALSE){ - g_warning ("sink input info callback - our user data is not what we think it should be"); +static void +pm_source_output_info_callback (pa_context *c, + const pa_source_output_info *info, + int eol, + void *userdata) +{ + if (eol > 0) { + return; + } + else { + if (info == NULL || IS_DEVICE (userdata) == FALSE) { + g_warning("Source output callback: SOURCE OUTPUT INFO IS NULL or our user_data is not what we think it should be"); return; } + // Check if this is Voip sink input gint result = pa_proplist_contains (info->proplist, PA_PROP_MEDIA_ROLE); Device* a_sink = DEVICE (userdata); if (result == 1){ - g_debug ("Sink input info has media role property"); + //g_debug ("Source output info has media role property"); const char* value = pa_proplist_gets (info->proplist, PA_PROP_MEDIA_ROLE); - g_debug ("prop role = %s", value); + //g_debug ("prop role = %s", value); if (g_strcmp0 (value, "phone") == 0 || g_strcmp0 (value, "production") == 0) { - g_debug ("And yes its a VOIP app ... sink input index = %i", info->index); + g_debug ("We have a VOIP/PRODUCTION ! - index = %i", info->index); device_activate_voip_item (a_sink, (gint)info->index, (gint)info->client); // TODO to start with we will assume our source is the same as what this 'client' // is pointing at. This should probably be more intelligent : @@ -509,23 +520,9 @@ pm_sink_input_info_callback (pa_context *c, // from the sink input ensure our voip item is using the right source. } } - - // And finally check for the mute blocking state - if (device_get_sink_index (a_sink) == info->sink){ - device_determine_blocking_state (a_sink); - } } } -static void -pm_source_output_info_callback (pa_context *c, - const pa_source_output_info *info, - int eol, - void *userdata) -{ - -} - static void pm_update_device (pa_context *c, const pa_sink_info *info, diff --git a/src/voip-input-menu-item.c b/src/voip-input-menu-item.c index e645e69..7cbdd45 100644 --- a/src/voip-input-menu-item.c +++ b/src/voip-input-menu-item.c @@ -35,7 +35,7 @@ struct _VoipInputMenuItemPrivate { pa_channel_map channel_map; pa_volume_t base_volume; gint source_index; - gint sink_input_index; + gint source_output_index; gint client_index; }; @@ -82,7 +82,7 @@ voip_input_menu_item_init (VoipInputMenuItem *self) FALSE ); priv->source_index = NOT_ACTIVE; - priv->sink_input_index = NOT_ACTIVE; + priv->source_output_index = NOT_ACTIVE; priv->client_index = NOT_ACTIVE; priv->mute = NOT_ACTIVE; } @@ -183,18 +183,18 @@ voip_input_menu_item_update (VoipInputMenuItem* item, gboolean voip_input_menu_item_is_interested (VoipInputMenuItem* item, - gint sink_input_index, + gint source_output_index, gint client_index) { 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 != NOT_ACTIVE && + if (priv->source_output_index != NOT_ACTIVE && priv->source_index != NOT_ACTIVE){ return FALSE; } - priv->sink_input_index = sink_input_index; + priv->source_output_index = source_output_index; priv->client_index = client_index; return TRUE; @@ -204,7 +204,7 @@ gboolean voip_input_menu_item_is_active (VoipInputMenuItem* item) { VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item); - return (priv->sink_input_index != NOT_ACTIVE && priv->client_index != NOT_ACTIVE); + return (priv->source_output_index != NOT_ACTIVE && priv->client_index != NOT_ACTIVE); } @@ -223,11 +223,11 @@ voip_input_menu_item_get_index (VoipInputMenuItem* item) } gint -voip_input_menu_item_get_sink_input_index (VoipInputMenuItem* item) +voip_input_menu_item_get_source_output_index (VoipInputMenuItem* item) { VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item); - return priv->sink_input_index; + return priv->source_output_index; } /** @@ -250,7 +250,7 @@ voip_input_menu_item_deactivate_voip_client (VoipInputMenuItem* item) { VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item); priv->client_index = NOT_ACTIVE; - priv->sink_input_index = NOT_ACTIVE; + priv->source_output_index = NOT_ACTIVE; voip_input_menu_item_enable (item, FALSE); } diff --git a/src/voip-input-menu-item.h b/src/voip-input-menu-item.h index 30ada5a..1446e03 100644 --- a/src/voip-input-menu-item.h +++ b/src/voip-input-menu-item.h @@ -50,14 +50,14 @@ void voip_input_menu_item_update (VoipInputMenuItem* item, const pa_source_info* source); void voip_input_menu_item_enable (VoipInputMenuItem* item, gboolean active); gboolean voip_input_menu_item_is_interested (VoipInputMenuItem* item, - gint sink_input_index, + gint source_output_index, gint client_index); gboolean voip_input_menu_item_is_active (VoipInputMenuItem* item); gboolean voip_input_menu_item_is_populated (VoipInputMenuItem* item); // TODO rename get source index gint voip_input_menu_item_get_index (VoipInputMenuItem* item); -gint voip_input_menu_item_get_sink_input_index (VoipInputMenuItem* item); +gint voip_input_menu_item_get_source_output_index (VoipInputMenuItem* item); void voip_input_menu_item_deactivate_source (VoipInputMenuItem* item, gboolean visible); void voip_input_menu_item_deactivate_voip_client (VoipInputMenuItem* item); |