aboutsummaryrefslogtreecommitdiff
path: root/src/active-sink.c
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-02-04 19:55:20 +0000
committerConor Curran <conor.curran@canonical.com>2011-02-04 19:55:20 +0000
commit381d827c0da72499f6092c7bb8cb6238ba0d2746 (patch)
treee01af7ffa0e1876259f4731d47c34b99db5849ab /src/active-sink.c
parent6bfc46de9234f0ef39d90b934fb406eebec4c59c (diff)
downloadayatana-indicator-sound-381d827c0da72499f6092c7bb8cb6238ba0d2746.tar.gz
ayatana-indicator-sound-381d827c0da72499f6092c7bb8cb6238ba0d2746.tar.bz2
ayatana-indicator-sound-381d827c0da72499f6092c7bb8cb6238ba0d2746.zip
hook back volume and mute setting and test
Diffstat (limited to 'src/active-sink.c')
-rw-r--r--src/active-sink.c56
1 files changed, 37 insertions, 19 deletions
diff --git a/src/active-sink.c b/src/active-sink.c
index 37cdf51..16ab784 100644
--- a/src/active-sink.c
+++ b/src/active-sink.c
@@ -77,7 +77,7 @@ active_sink_init(ActiveSink *self)
// Init our menu items.
priv->mute_menuitem = g_object_new (MUTE_MENU_ITEM_TYPE, NULL);
- priv->volume_slider_menuitem = g_object_new (SLIDER_MENU_ITEM_TYPE, NULL);
+ priv->volume_slider_menuitem = slider_menu_item_new (self);
}
static void
@@ -101,14 +101,14 @@ active_sink_populate (ActiveSink* sink,
priv->name = g_strdup (update->name);
priv->index = update->index;
// Why the double negative !?
- active_sink_update_mute (sink, !!update->mute);
+ active_sink_mute_update (sink, !!update->mute);
priv->volume = active_sink_construct_mono_volume (&update->volume);
priv->base_volume = update->base_volume;
priv->channel_map = update->channel_map;
pa_volume_t vol = pa_cvolume_max (&update->volume);
gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
- active_sink_update_volume (sink, volume_percent);
+ active_sink_volume_update (sink, volume_percent);
g_debug ("Active sink has been populated - volume %f", volume_percent);
}
@@ -141,7 +141,27 @@ active_sink_get_index (ActiveSink* self)
}
void
-active_sink_update_volume (ActiveSink* self, gdouble percent)
+active_sink_deactivate (ActiveSink* self)
+{
+ ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ priv->current_sound_state = UNAVAILABLE;
+ sound_service_dbus_update_sound_state (priv->service,
+ priv->current_sound_state);
+ priv->index = -1;
+ g_free(priv->name);
+ priv->name = NULL;
+}
+
+SoundState
+active_sink_get_state (ActiveSink* self)
+{
+ ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
+ return priv->current_sound_state;
+}
+
+// To the UI
+void
+active_sink_volume_update (ActiveSink* self, gdouble percent)
{
ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
slider_menu_item_update (priv->volume_slider_menuitem, percent);
@@ -152,20 +172,25 @@ active_sink_update_volume (ActiveSink* self, gdouble percent)
priv->current_sound_state);
}
+// From the UI
void
-active_sink_deactivate (ActiveSink* self)
+active_sink_update_volume (ActiveSink* self, gdouble percent)
{
+ pa_cvolume new_volume;
+ pa_cvolume_init(&new_volume);
+ new_volume.channels = 1;
+ pa_volume_t new_volume_value = (pa_volume_t) ((percent * PA_VOLUME_NORM) / 100);
+ pa_cvolume_set(&new_volume, 1, new_volume_value);
+
ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
- priv->current_sound_state = UNAVAILABLE;
- sound_service_dbus_update_sound_state (priv->service,
- priv->current_sound_state);
- priv->index = -1;
- g_free(priv->name);
- priv->name = NULL;
+
+ pa_cvolume_set(&priv->volume, priv->channel_map.channels, new_volume_value);
+
}
+
void
-active_sink_update_mute (ActiveSink* self, gboolean muted)
+active_sink_mute_update (ActiveSink* self, gboolean muted)
{
ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
mute_menu_item_update (priv->mute_menuitem, muted);
@@ -178,13 +203,6 @@ active_sink_update_mute (ActiveSink* self, gboolean muted)
sound_service_dbus_update_sound_state (priv->service, state);
}
-SoundState
-active_sink_get_state (ActiveSink* self)
-{
- ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self);
- return priv->current_sound_state;
-}
-
static SoundState
active_sink_get_state_from_volume (ActiveSink* self)