aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-02-04 11:49:25 +0000
committerConor Curran <conor.curran@canonical.com>2011-02-04 11:49:25 +0000
commit33689fcba482b5c0d16fa318836457bcb4ae83bd (patch)
treeb8e2634741a46f35a76f92b83f42b60cb451ca18 /src
parent81c80e6e823127337573b3c522f78820e7635911 (diff)
downloadayatana-indicator-sound-33689fcba482b5c0d16fa318836457bcb4ae83bd.tar.gz
ayatana-indicator-sound-33689fcba482b5c0d16fa318836457bcb4ae83bd.tar.bz2
ayatana-indicator-sound-33689fcba482b5c0d16fa318836457bcb4ae83bd.zip
blocking handled
Diffstat (limited to 'src')
-rw-r--r--src/active-sink.c11
-rw-r--r--src/active-sink.h3
-rw-r--r--src/pulseaudio-mgr.c91
3 files changed, 91 insertions, 14 deletions
diff --git a/src/active-sink.c b/src/active-sink.c
index c140fac..7e84b58 100644
--- a/src/active-sink.c
+++ b/src/active-sink.c
@@ -90,4 +90,15 @@ active_sink_is_populated (ActiveSink* sink)
return (priv->details != NULL);
}
+gboolean
+active_sink_is_muted (ActiveSink* self)
+{
+ return FALSE;
+}
+
+gint
+active_sink_get_index (ActiveSink* self)
+{
+ return 0;
+}
\ No newline at end of file
diff --git a/src/active-sink.h b/src/active-sink.h
index e6970bf..051da85 100644
--- a/src/active-sink.h
+++ b/src/active-sink.h
@@ -59,7 +59,8 @@ GType active_sink_get_type (void) G_GNUC_CONST;
void active_sink_update_details (ActiveSink* sink, sink_details* details);
gboolean active_sink_is_populated (ActiveSink* sink);
-
+gboolean active_sink_is_muted (ActiveSink* self);
+gint active_sink_get_index (ActiveSink* self);
G_END_DECLS
#endif
diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c
index ee14b6e..5f128eb 100644
--- a/src/pulseaudio-mgr.c
+++ b/src/pulseaudio-mgr.c
@@ -51,6 +51,15 @@ static void pm_sink_info_callback (pa_context *c,
const pa_sink_info *sink,
int eol,
void *userdata);
+static void pm_sink_input_info_callback (pa_context *c,
+ const pa_sink_input_info *info,
+ int eol,
+ void *userdata);
+
+static void pm_update_active_sink (pa_context *c,
+ const pa_sink_info *info,
+ int eol,
+ void *userdata);
static void populate_active_sink (const pa_sink_info *info, ActiveSink* sink);
@@ -172,20 +181,31 @@ pm_subscribed_events_callback (pa_context *c,
{
switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) {
case PA_SUBSCRIPTION_EVENT_SINK:
+ if (IS_ACTIVE_SINK (userdata) == FALSE){
+ g_warning ("subscribed events callback - our userdata is not what we think it should be");
+ return;
+ }
+ ActiveSink* sink = ACTIVE_SINK (userdata);
+ // We don't care about any other sink other than the active one.
+ if (index != active_sink_get_index (sink))
+ return;
+
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
- // TODO check the sink index is not your active index and react appropriately
+ // TODO: Fire of an unavailable state signal and try to find another sink
+ }
+ else{
+ pa_operation_unref (pa_context_get_sink_info_by_index (c,
+ index,
+ pm_update_active_sink,
+ userdata) );
}
break;
case PA_SUBSCRIPTION_EVENT_SINK_INPUT:
- if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
- //handle the sink input remove event - not relevant for current design
- }
- else {
- // query the info of the sink input to see if we have a blocking moment
- // TODO investigate what the id is here.
- //pa_operation_unref (pa_context_get_sink_input_info (c,
- // index,
- // pulse_sink_input_info_callback, userdata));
+ // We don't care about sink input removals.
+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) != PA_SUBSCRIPTION_EVENT_REMOVE) {
+ pa_operation_unref (pa_context_get_sink_input_info (c,
+ index,
+ pm_sink_input_info_callback, userdata));
}
break;
case PA_SUBSCRIPTION_EVENT_SERVER:
@@ -246,9 +266,7 @@ pm_context_state_callback (pa_context *c, void *userdata)
g_warning("Initial - pa_context_get_server_info() failed");
}
pa_operation_unref(o);
-
-
-
+
break;
}
}
@@ -327,9 +345,56 @@ pm_default_sink_info_callback (pa_context *c,
return;
}
else {
+ 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");
populate_active_sink (info, ACTIVE_SINK (userdata));
}
}
+static void
+pm_sink_input_info_callback (pa_context *c,
+ const pa_sink_input_info *info,
+ int eol,
+ void *userdata)
+{
+ if (eol > 0) {
+ return;
+ }
+ else {
+ if (info == NULL) {
+ // TODO: watch this carefully - PA async api should not be doing this . . .
+ g_warning("\n Sink input info callback : SINK INPUT INFO IS NULL BUT EOL was not POSITIVE!!!");
+ return;
+ }
+ if (IS_ACTIVE_SINK (userdata) == FALSE){
+ g_warning ("sink input info callback - our user data is not what we think it should be");
+ return;
+ }
+
+ ActiveSink* a_sink = ACTIVE_SINK (userdata);
+ if (active_sink_get_index (a_sink) == info->sink->index &&
+ active_sink_is_muted () == TRUE) {
+ // TODO fire off blocking signal
+ }
+ }
+}
+
+static void
+pm_update_active_sink (pa_context *c,
+ const pa_sink_info *info,
+ int eol,
+ void *userdata)
+{
+ if (eol > 0) {
+ return;
+ }
+ else{
+
+ }
+}
+