aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-04-22 19:24:45 +0100
committerConor Curran <conor.curran@canonical.com>2010-04-22 19:24:45 +0100
commitf39d4f300543d4b5717b39e45e47fbbb51c96a97 (patch)
treeb845a3a0357e9a91f37b16b5fc7f37593f32b31f /src
parent632922b21c8b6d0d313bdd2711b4865b876ad1e7 (diff)
downloadayatana-indicator-sound-f39d4f300543d4b5717b39e45e47fbbb51c96a97.tar.gz
ayatana-indicator-sound-f39d4f300543d4b5717b39e45e47fbbb51c96a97.tar.bz2
ayatana-indicator-sound-f39d4f300543d4b5717b39e45e47fbbb51c96a97.zip
greatly simplified the volume setting code without messing with balance
Diffstat (limited to 'src')
-rw-r--r--src/pulse-manager.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index e3fa097..c527d6d 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -242,27 +242,16 @@ void set_sink_volume(gdouble percent)
return;
}
- sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
- pa_volume_t cached_volume = pa_cvolume_max(&s->volume);
- pa_volume_t new_volume = (pa_volume_t) ((percent * PA_VOLUME_NORM) / 100);
- pa_volume_t difference = 0;
-
- if( cached_volume > new_volume ){
- g_debug("I'm moving down down ...");
- difference = cached_volume - new_volume;
- pa_cvolume_dec(&s->volume, difference);
- }
- else if ( cached_volume < new_volume ){
- g_debug("I'm moving up up ...");
- difference = new_volume - cached_volume;
- pa_cvolume_inc(&s->volume, difference);
- }
+ sink_info *cached_sink = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
- g_debug("Calculated difference : %f", (gdouble)difference);
- g_debug("new_volume calculated from percentage input :%f", pa_sw_volume_to_linear(new_volume));
- g_debug("new volume calculated from resultant output :%f", pa_sw_volume_to_linear(pa_cvolume_max(&s->volume)));
+ 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);
+ pa_cvolume_set(&cached_sink->volume, cached_sink->channel_map.channels, new_volume_value);
- pa_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &s->volume, NULL, NULL));
+ pa_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &new_volume, NULL, NULL));
}