From 6856359f7cb8544bd51a141fea9eeab28e6d1b25 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 24 Mar 2011 13:09:54 +0000 Subject: the beginnings of general source monitoring --- src/pulseaudio-mgr.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src/pulseaudio-mgr.c') diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index 95f4c06..2ead17c 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,7 +260,6 @@ 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_REMOVE) { gint cached_index = device_get_current_sink_input_index (sink); @@ -270,12 +272,26 @@ pm_subscribed_events_callback (pa_context *c, } 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. + // 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); + } + else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) { + 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: g_debug("PA_SUBSCRIPTION_EVENT_SERVER event triggered."); pa_operation *o; @@ -333,6 +349,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"); @@ -500,6 +517,15 @@ pm_sink_input_info_callback (pa_context *c, } } +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, -- cgit v1.2.3 From b4dc15ac004d49a46cba1b88c1c5cdf8c12755ba Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 24 Mar 2011 15:22:30 +0000 Subject: now using the source output --- src/pulseaudio-mgr.c | 61 +++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 32 deletions(-) (limited to 'src/pulseaudio-mgr.c') 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, -- cgit v1.2.3