aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-02-08 17:21:05 +0000
committerConor Curran <conor.curran@canonical.com>2010-02-08 17:21:05 +0000
commitea417ae84133c26aed0b257376ab1d1c567a9779 (patch)
treef889cfcbaf1efe9f20e338b27f516bf8f6f3976b /src
parentf9ef87f71c488f6791e32b1cf7205fb65db81ce8 (diff)
downloadayatana-indicator-sound-ea417ae84133c26aed0b257376ab1d1c567a9779.tar.gz
ayatana-indicator-sound-ea417ae84133c26aed0b257376ab1d1c567a9779.tar.bz2
ayatana-indicator-sound-ea417ae84133c26aed0b257376ab1d1c567a9779.zip
automatic slider volume updates working
Diffstat (limited to 'src')
-rw-r--r--src/common-defs.h2
-rw-r--r--src/indicator-sound.c13
-rw-r--r--src/pulse-manager.c5
-rw-r--r--src/sound-service-dbus.c9
-rw-r--r--src/sound-service-dbus.h4
-rw-r--r--src/sound-service.xml2
6 files changed, 21 insertions, 14 deletions
diff --git a/src/common-defs.h b/src/common-defs.h
index a06b1b3..c969ddb 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -1,6 +1,6 @@
/* constants used for signals on the dbus. This file is shared between client and server implementation */
#define SIGNAL_SINK_INPUT_WHILE_MUTED "SinkInputWhileMuted"
-#define SIGNAL_UPDATE_SINK_VOLUME "UpdateSinkVolume"
+#define SIGNAL_SINK_VOLUME_UPDATE "SinkVolumeUpdate"
// DBUS items
#define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-item"
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 9ceebd1..fe1b6fb 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -90,7 +90,7 @@ static gboolean slider_value_changed_event_cb(GtkRange *range, gpointer user_da
static DBusGProxy *sound_dbus_proxy = NULL;
static void connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata);
static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gint sink_index, gboolean value, gpointer userdata);
-void catch_signal_sink_volume_update(DBusGProxy * proxy, gint sink_volume, gpointer userdata);
+static void catch_signal_sink_volume_update(DBusGProxy * proxy, gdouble volume_percent, gpointer userdata);
/****Volume States 'members' ***/
static const gint STATE_MUTED = 0;
@@ -193,8 +193,8 @@ connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer u
g_debug("about to connect to the signals");
dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_CALLBACK(catch_signal_sink_input_while_muted), NULL, NULL);
- dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_UPDATE_SINK_VOLUME, G_TYPE_INT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_UPDATE_SINK_VOLUME, G_CALLBACK(catch_signal_sink_volume_update), NULL, NULL);
+ dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_TYPE_DOUBLE, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_CALLBACK(catch_signal_sink_volume_update), NULL, NULL);
}
@@ -211,9 +211,12 @@ static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gint sink_in
g_debug("signal caught - I don't believe it ! with index %i and value %i", sink_index, value);
}
-void catch_signal_sink_volume_update(DBusGProxy * proxy, gint sink_volume, gpointer userdata)
+static void catch_signal_sink_volume_update(DBusGProxy * proxy, gdouble volume_percent, gpointer userdata)
{
- g_debug("signal caught - update sink volume with value : %i", sink_volume);
+ g_debug("signal caught - update sink volume with value : %f", volume_percent);
+ GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);
+ GtkRange* range = (GtkRange*)slider;
+ gtk_range_set_value(range, volume_percent);
}
static void
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index 87f20ae..ff6f1bb 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -290,8 +290,11 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
{
//update the UI
pa_volume_t vol = pa_cvolume_avg(&s->volume);
+ // Use the base of the device to ensure maximum acceptable levels on the hardware
+ gint volume_percent = (vol/s->base_volume);
+ g_debug("When using base volume => volume = %i", volume_percent);
g_debug("about to update ui with linear volume of %f", pa_sw_volume_to_linear(vol));
- sound_service_dbus_update_sink_volume(dbus_service, vol * 100);
+ sound_service_dbus_update_sink_volume(dbus_service, pa_sw_volume_to_linear(vol) * 100);
}
}
else
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index 9a325fe..635dfeb 100644
--- a/src/sound-service-dbus.c
+++ b/src/sound-service-dbus.c
@@ -88,8 +88,8 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass)
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
+ g_cclosure_marshal_VOID__DOUBLE,
+ G_TYPE_NONE, 1, G_TYPE_DOUBLE);
}
/**
@@ -112,6 +112,7 @@ sound_service_dbus_get_sink_list (SoundServiceDbus *self)
/**
+SIGNALS
Utility methods to emit signals from the service into the ether.
**/
void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, gint sink_index, gboolean value)
@@ -125,9 +126,9 @@ void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, gint sink_
value);
}
-void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gint sink_volume)
+void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_volume)
{
- g_debug("Emitting signal: UPDATE_SINK_VOLUME, with sink_volme %i", sink_volume);
+ g_debug("Emitting signal: SINK_VOLUME_UPDATE, with sink_volme %f", sink_volume);
g_signal_emit(obj,
signals[SINK_VOLUME_UPDATE],
0,
diff --git a/src/sound-service-dbus.h b/src/sound-service-dbus.h
index bb4fbe8..dc52861 100644
--- a/src/sound-service-dbus.h
+++ b/src/sound-service-dbus.h
@@ -51,14 +51,14 @@ struct _SoundServiceDbusClass {
GObjectClass parent_class;
/* Signals -> outward messages to the DBUS and beyond*/
void (* sink_input_while_muted) (SoundServiceDbus *self, gint sink_index, gboolean is_muted, gpointer sound_data);
- void (* sink_volume_update) (SoundServiceDbus *self, gint sink_volume);
+ void (* sink_volume_update) (SoundServiceDbus *self, gdouble sink_volume, gpointer sound_data);
};
GType sound_service_dbus_get_type (void) G_GNUC_CONST;
// Utility methods to get the messages across into the sound-service-dbus
void sound_service_dbus_sink_input_while_muted (SoundServiceDbus* obj, gint sink_index, gboolean value);
-void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gint sink_volume);
+void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_volume);
void set_pa_sinks_hash(SoundServiceDbus *self, GHashTable *sinks);
// DBUS METHODS
diff --git a/src/sound-service.xml b/src/sound-service.xml
index 0a35690..e7f3e75 100644
--- a/src/sound-service.xml
+++ b/src/sound-service.xml
@@ -14,7 +14,7 @@ Our respective UI element should listen to this and therefore will be updated wi
<arg name="mute_value" type="b" direction="out"/>
</signal>
<signal name="SinkVolumeUpdate">
- <arg name="volume_percent" type="x" direction="out"/>
+ <arg name="volume_percent" type="u" direction="out"/>
</signal>
</interface>
</node>