aboutsummaryrefslogtreecommitdiff
path: root/src/pulse-manager.c
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-02-17 11:15:00 +0000
committerConor Curran <conor.curran@canonical.com>2010-02-17 11:15:00 +0000
commit1a50894fa430b11105e2051334d41ac2ab705355 (patch)
treec2f2f473049f18553d6b6ac34344c3cc88bd4c1b /src/pulse-manager.c
parenta33c5276c9f07d54af523406445070bef6edf256 (diff)
parent34483439f5254a35daf6dbd47b959936edc499e1 (diff)
downloadayatana-indicator-sound-1a50894fa430b11105e2051334d41ac2ab705355.tar.gz
ayatana-indicator-sound-1a50894fa430b11105e2051334d41ac2ab705355.tar.bz2
ayatana-indicator-sound-1a50894fa430b11105e2051334d41ac2ab705355.zip
merge with ui work - fixed start up regression - keyboard ui implemented - volume control much smoother
Diffstat (limited to 'src/pulse-manager.c')
-rw-r--r--src/pulse-manager.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index aa3481a..269ac58 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -158,9 +158,9 @@ static gdouble get_default_sink_volume()
return 0;
sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
pa_volume_t vol = pa_cvolume_avg(&s->volume);
- gdouble value = pa_sw_volume_to_linear(vol);
- g_debug("software volume = %f", value);
- return value;
+ gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
+ g_debug("software volume = %f", volume_percent);
+ return volume_percent;
}
static void mute_each_sink(gpointer key, gpointer value, gpointer user_data)
@@ -189,18 +189,15 @@ void set_sink_volume(gdouble percent)
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_volume_t new_volume = (pa_volume_t) ((percent * PA_VOLUME_NORM) / 100);
+ g_debug("new_volume double check :%f", pa_sw_volume_to_linear(new_volume));
+ g_debug("new volume calculated :%f", (gdouble)new_volume);
+ pa_cvolume dev_vol;
pa_cvolume_set(&dev_vol, s->volume.channels, new_volume);
-
+ // TODO why don't you update the sink_info here with the appropriate pa_cvolume (&dev_vol)
pa_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &dev_vol, NULL, NULL));
}
@@ -321,7 +318,6 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
if(position >= 0) // => index is within the keys of the hash.
{
sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(info->index));
- //g_debug("attempting to update sink with name %s", s->name);
s->name = g_strdup(info->name);
s->description = g_strdup(info->description);
s->icon_name = g_strdup(pa_proplist_gets(info->proplist, PA_PROP_DEVICE_ICON_NAME));
@@ -336,14 +332,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
- 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));
+ gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
+ g_debug("Updating volume from PA manager with volume = %f", volume_percent);
+ sound_service_dbus_update_sink_volume(dbus_service, volume_percent);
if (mute_changed == TRUE)
sound_service_dbus_update_sink_mute(dbus_service, s->mute);
-
update_mute_ui(s->mute);
}
}