diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-05-18 11:45:49 +0200 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-05-18 11:45:49 +0200 |
commit | e499cede95e1eab865286b450b0d927457467749 (patch) | |
tree | d2bd0dedd33c87233f2483d79b0c3910acb9ae28 /src | |
parent | 03d29626622fa8ede6f4e00960fffb8d89382f9f (diff) | |
parent | b4dc15ac004d49a46cba1b88c1c5cdf8c12755ba (diff) | |
download | ayatana-indicator-sound-e499cede95e1eab865286b450b0d927457467749.tar.gz ayatana-indicator-sound-e499cede95e1eab865286b450b0d927457467749.tar.bz2 ayatana-indicator-sound-e499cede95e1eab865286b450b0d927457467749.zip |
source monitoring now happens even if the application is not voip specific therefore the voip slider has now become a generic mic input gain slider - hurray
Diffstat (limited to 'src')
-rw-r--r-- | src/device.c | 8 | ||||
-rw-r--r-- | src/device.h | 4 | ||||
-rw-r--r-- | src/pulseaudio-mgr.c | 69 | ||||
-rw-r--r-- | src/voip-input-menu-item.c | 18 | ||||
-rw-r--r-- | src/voip-input-menu-item.h | 4 |
5 files changed, 63 insertions, 40 deletions
diff --git a/src/device.c b/src/device.c index a3e8019..84db596 100644 --- a/src/device.c +++ b/src/device.c @@ -124,10 +124,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 @@ -198,11 +198,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 95f4c06..a31084a 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -76,7 +76,10 @@ static void pm_toggle_mute_for_every_sink_callback (pa_context *c, const pa_sink_info *sink, int eol, void* userdata); - +static void pm_source_output_info_callback (pa_context *c, + const pa_source_output_info *info, + int eol, + void *userdata); static gboolean reconnect_to_pulse (gpointer user_data); @@ -257,23 +260,29 @@ pm_subscribed_events_callback (pa_context *c, } break; case PA_SUBSCRIPTION_EVENT_SINK_INPUT: - // We don't care about sink input removals. - g_debug ("sink input event"); + 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, + index, + pm_sink_input_info_callback, userdata)); + } + break; + 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); - - if (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 sink input event ? - index = %i", index); - // Determine if its a VOIP app or a maybe blocking state. - pa_operation_unref (pa_context_get_sink_input_info (c, - index, - pm_sink_input_info_callback, userdata)); + g_debug ("some new source output event ? - index = %i", index); + // Determine if its a VOIP app. + pa_operation_unref (pa_context_get_source_output_info (c, + index, + pm_source_output_info_callback, userdata)); } break; case PA_SUBSCRIPTION_EVENT_SERVER: @@ -333,6 +342,7 @@ pm_context_state_callback (pa_context *c, void *userdata) (PA_SUBSCRIPTION_MASK_SINK| PA_SUBSCRIPTION_MASK_SOURCE| PA_SUBSCRIPTION_MASK_SINK_INPUT| + PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT| PA_SUBSCRIPTION_MASK_SERVER), NULL, NULL))) { g_warning("pa_context_subscribe() failed"); @@ -470,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 : @@ -492,11 +520,6 @@ 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); - } } } 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); |