diff options
author | Conor Curran <conor.curran@canonical.com> | 2010-04-23 09:24:05 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2010-04-23 09:24:05 +0100 |
commit | 164f6fe4575215d00a935b20152c222e1d356fda (patch) | |
tree | b845a3a0357e9a91f37b16b5fc7f37593f32b31f /src/pulse-manager.c | |
parent | 632922b21c8b6d0d313bdd2711b4865b876ad1e7 (diff) | |
parent | f39d4f300543d4b5717b39e45e47fbbb51c96a97 (diff) | |
download | ayatana-indicator-sound-164f6fe4575215d00a935b20152c222e1d356fda.tar.gz ayatana-indicator-sound-164f6fe4575215d00a935b20152c222e1d356fda.tar.bz2 ayatana-indicator-sound-164f6fe4575215d00a935b20152c222e1d356fda.zip |
merged code to greatly simplify volume managment preserving spatialisation
Diffstat (limited to 'src/pulse-manager.c')
-rw-r--r-- | src/pulse-manager.c | 27 |
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)); } |