aboutsummaryrefslogtreecommitdiff
path: root/src/pulse-manager.c
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-02-10 00:46:07 +0000
committerConor Curran <conor.curran@canonical.com>2010-02-10 00:46:07 +0000
commitb117e1edcf717da7d0d0cd890a85cc86366df931 (patch)
treea0d9250a187b729198cb6f378b08416d49f7c654 /src/pulse-manager.c
parent8d9276778375d9187a8f9839ff11e8aa5b186da0 (diff)
downloadayatana-indicator-sound-b117e1edcf717da7d0d0cd890a85cc86366df931.tar.gz
ayatana-indicator-sound-b117e1edcf717da7d0d0cd890a85cc86366df931.tar.bz2
ayatana-indicator-sound-b117e1edcf717da7d0d0cd890a85cc86366df931.zip
silly/nasty scaling bug caught
Diffstat (limited to 'src/pulse-manager.c')
-rw-r--r--src/pulse-manager.c86
1 files changed, 48 insertions, 38 deletions
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index e7570c6..858ae7b 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -22,33 +22,10 @@ static void pulse_server_info_callback(pa_context *c, const pa_server_info *info
static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, void *userdata);
static void destroy_sink_info(void *value);
+
/*
-Refine the resolution of the slider or binary scale it to achieve a more subtle volume control.
-Use the base volume stored in the sink struct to calculate actual linear volumes.
+Entry point
*/
-void set_sink_volume(gdouble percent)
-{
- g_debug("in the pulse manager:set_sink_volume with percent %f", percent);
- if(DEFAULT_SINK_INDEX < 0)
- {
- g_warning("We have no default sink !!! - returning after not attempting to set any volume of any sink");
- return;
- }
- gdouble linear_input = (gdouble)(percent);
- linear_input /= 100.0;
- g_debug("linear double input = %f", linear_input);
- pa_volume_t new_volume = pa_sw_volume_from_linear(linear_input);
- // Use this to achieve more accurate scaling using the base volume (in the sink struct already!)
- //pa_volume_t new_volume = (pa_volume_t) ((GPOINTER_TO_INT(linear_input) * s->base_volume) / 100);
- g_debug("about to try to set the sw volume to a linear volume of %f", pa_sw_volume_to_linear(new_volume));
- g_debug("and an actual volume of %f", (gdouble)new_volume);
- pa_cvolume dev_vol;
- sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
- pa_cvolume_set(&dev_vol, s->volume.channels, new_volume);
- // TODO - really this needs to be set in the success callback - if call fails then the ui will not be updated indefinitely!
- pa_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &dev_vol, NULL, NULL));
-}
-
void establish_pulse_activities(SoundServiceDbus *service)
{
dbus_service = service;
@@ -75,18 +52,6 @@ void close_pulse_activites()
g_debug("I just closed communication with Pulse");
}
-static void mute_each_sink(gpointer key, gpointer value, gpointer user_data)
-{
- sink_info *info = (sink_info*)value;
- pa_operation_unref(pa_context_set_sink_mute_by_index(pulse_context, info->index, GPOINTER_TO_INT(user_data), context_success_callback, NULL));
- g_debug("in the pulse manager: mute each sink %i", GPOINTER_TO_INT(user_data));
-}
-
-void toggle_global_mute(gboolean mute_value)
-{
- g_hash_table_foreach(sink_hash, mute_each_sink, GINT_TO_POINTER(mute_value));
- g_debug("in the pulse manager: toggle global mute value %i", mute_value);
-}
static void destroy_sink_info(void *value)
{
@@ -107,6 +72,10 @@ static void test_hash(){
}
+/*
+Controllers & Utilities
+*/
+
static gboolean sink_available()
{
if (g_hash_table_size(sink_hash) < 1)
@@ -150,6 +119,46 @@ static gdouble get_default_sink_volume()
return value;
}
+static void mute_each_sink(gpointer key, gpointer value, gpointer user_data)
+{
+ sink_info *info = (sink_info*)value;
+ pa_operation_unref(pa_context_set_sink_mute_by_index(pulse_context, info->index, GPOINTER_TO_INT(user_data), context_success_callback, NULL));
+ g_debug("in the pulse manager: mute each sink %i", GPOINTER_TO_INT(user_data));
+}
+
+void toggle_global_mute(gboolean mute_value)
+{
+ g_hash_table_foreach(sink_hash, mute_each_sink, GINT_TO_POINTER(mute_value));
+ g_debug("in the pulse manager: toggle global mute value %i", mute_value);
+}
+
+
+/*
+Refine the resolution of the slider or binary scale it to achieve a more subtle volume control.
+Use the base volume stored in the sink struct to calculate actual linear volumes.
+*/
+void set_sink_volume(gdouble percent)
+{
+ g_debug("in the pulse manager:set_sink_volume with percent %f", percent);
+ if(DEFAULT_SINK_INDEX < 0)
+ {
+ g_warning("We have no default sink !!! - returning after not attempting to set any volume of any sink");
+ return;
+ }
+ gdouble linear_input = (gdouble)(percent);
+ linear_input /= 100.0;
+ g_debug("linear double input = %f", linear_input);
+ pa_volume_t new_volume = pa_sw_volume_from_linear(linear_input);
+ // Use this to achieve more accurate scaling using the base volume (in the sink struct already!)
+ //pa_volume_t new_volume = (pa_volume_t) ((GPOINTER_TO_INT(linear_input) * s->base_volume) / 100);
+ g_debug("about to try to set the sw volume to a linear volume of %f", pa_sw_volume_to_linear(new_volume));
+ g_debug("and an actual volume of %f", (gdouble)new_volume);
+ pa_cvolume dev_vol;
+ sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
+ pa_cvolume_set(&dev_vol, s->volume.channels, new_volume);
+ pa_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &dev_vol, NULL, NULL));
+}
+
/**********************************************************************************************************************/
// Pulse-Audio asychronous call-backs
@@ -293,7 +302,8 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
gdouble volume_percent = (vol/s->base_volume) * 100;
g_debug("When using base volume => volume = %f", 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, pa_sw_volume_to_linear(vol) * 100);
+ sound_service_dbus_update_sink_volume(dbus_service, pa_sw_volume_to_linear(vol));
+
update_mute_ui(s->mute);
}
else{