aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-02-03 18:36:34 +0000
committerConor Curran <conor.curran@canonical.com>2011-02-03 18:36:34 +0000
commitff857b05deb7f7385c9d4d8d43be19fca225c6ca (patch)
treef438060d7bc494a15d3be5166fd21669b73e0a2a /src
parent7070e44eced4d173c0e175948b3da4ca9f9497b9 (diff)
downloadayatana-indicator-sound-ff857b05deb7f7385c9d4d8d43be19fca225c6ca.tar.gz
ayatana-indicator-sound-ff857b05deb7f7385c9d4d8d43be19fca225c6ca.tar.bz2
ayatana-indicator-sound-ff857b05deb7f7385c9d4d8d43be19fca225c6ca.zip
basics established
Diffstat (limited to 'src')
-rw-r--r--src/active-sink.c27
-rw-r--r--src/active-sink.h4
-rw-r--r--src/pulseaudio-mgr.c47
3 files changed, 51 insertions, 27 deletions
diff --git a/src/active-sink.c b/src/active-sink.c
index ee211ef..8ba88d8 100644
--- a/src/active-sink.c
+++ b/src/active-sink.c
@@ -25,6 +25,7 @@ typedef struct _ActiveSinkPrivate ActiveSinkPrivate;
struct _ActiveSinkPrivate
{
+ sink_details* details;
};
#define ACTIVE_SINK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ACTIVE_SINK_TYPE, ActiveSinkPrivate))
@@ -52,11 +53,21 @@ active_sink_class_init (ActiveSinkClass *klass)
static void
active_sink_init(ActiveSink *self)
{
+ ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE(sink);
+ priv->details = NULL;
}
static void
active_sink_dispose (GObject *object)
{
+ ActiveSink * self = ACTIVE_SINK(object);
+ ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE(sink);
+
+ if (priv->details != NULL) {
+ g_free (priv->details->name);
+ g_free (priv->details);
+ }
+
G_OBJECT_CLASS (active_sink_parent_class)->dispose (object);
}
@@ -65,3 +76,19 @@ active_sink_finalize (GObject *object)
{
G_OBJECT_CLASS (active_sink_parent_class)->finalize (object);
}
+
+void
+active_sink_update_details (ActiveSink* sink, sink_details* details)
+{
+ ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE(sink);
+ priv->details = details;
+}
+
+void gboolean
+active_sink_is_populated (ActiveSink* sink)
+{
+ ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE(sink);
+ return (priv->details != NULL)
+}
+
+ \ No newline at end of file
diff --git a/src/active-sink.h b/src/active-sink.h
index 12083b8..6aed0b6 100644
--- a/src/active-sink.h
+++ b/src/active-sink.h
@@ -55,9 +55,11 @@ typedef struct {
pa_volume_t base_volume;
} sink_details;
-
GType active_sink_get_type (void) G_GNUC_CONST;
+void active_sink_update_details (ActiveSink* sink, sink_details* details);
+void gboolean active_sink_is_populated (ActiveSink* sink)
+
G_END_DECLS
#endif
diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c
index 216c025..59faaf0 100644
--- a/src/pulseaudio-mgr.c
+++ b/src/pulseaudio-mgr.c
@@ -99,7 +99,15 @@ reconnect_to_pulse (gpointer user_data)
static void
populate_active_sink (const pa_sink_info *info, ActiveSink* sink)
{
-
+ sink_details *details;
+ details = g_new0 (sink_details, 1);
+ details->index = info->index;
+ details->name = g_strdup (info->name);
+ details->mute = !!info->mute;
+ details->volume = construct_mono_volume (&info->volume);
+ details->base_volume = info->base_volume;
+ details->channel_map = info->channel_map;
+ active_sink_update_details (sink, details);
}
/**********************************************************************************************************************/
@@ -225,6 +233,9 @@ pm_server_info_callback (pa_context *c,
pa_operation_unref(operation);
}
+// If the server doesn't have a default sink to give us
+// we should attempt to pick up the first of the list of sinks which doesn't have
+// the name 'auto_null'
static void
pm_sink_info_callback (pa_context *c,
const pa_sink_info *sink,
@@ -235,17 +246,11 @@ pm_sink_info_callback (pa_context *c,
return;
}
else {
- /* g_debug("About to add an item to our hash");*/
- sink_info *value;
- value = g_new0(sink_info, 1);
- value->index = sink->index;
- value->name = g_strdup(sink->name);
- value->mute = !!sink->mute;
- value->volume = construct_mono_volume(&sink->volume);
- value->base_volume = sink->base_volume;
- value->channel_map = sink->channel_map;
- g_hash_table_insert(sink_hash, GINT_TO_POINTER(sink->index), value);
- /* g_debug("After adding an item to our hash");*/
+ ActiveSink* a_sink = ACTIVESINK (userdata);
+ if (active_sink_is_populated (a_sink) &&
+ g_ascii_strncasecmp("auto_null", sink->name, 9) != 0){
+ populate_active_sink (info, ACTIVESINK (userdata));
+ }
}
}
@@ -256,21 +261,11 @@ pm_default_sink_info_callback (pa_context *c,
void *userdata)
{
if (eol > 0) {
+ // TODO what happens here - high and dry!
return;
- } else {
- DEFAULT_SINK_INDEX = info->index;
- /* g_debug("Just set the default sink index to %i", DEFAULT_SINK_INDEX); */
- GList *keys = g_hash_table_get_keys(sink_hash);
- gint position = g_list_index(keys, GINT_TO_POINTER(info->index));
- // Only update sink-list if the index is not in our already fetched list.
- if (position < 0) {
- pa_operation_unref(pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL));
- } else {
- sound_service_dbus_update_pa_state(dbus_service,
- determine_sink_availability(),
- default_sink_is_muted(),
- get_default_sink_volume());
- }
+ }
+ else {
+ populate_active_sink (info, ACTIVESINK (userdata));
}
}