ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #01442
Re: [Merge] lp:~cjcurran/indicator-sound/volume_setting_code_refactor into lp:indicator-sound
Review: Approve
review approve
On Thu, 2010-04-22 at 18:30 +0000, Conor Curran wrote:
> Conor Curran has proposed merging lp:~cjcurran/indicator-sound/volume_setting_code_refactor into lp:indicator-sound.
>
> Requested reviews:
> Indicator Applet Developers (indicator-applet-developers)
>
>
> Greatly simplified the volume setting code. Basically on setting the volume init a mono volume. This will preserve balance and removes the cruft which was there from early this afternoon.
>
> differences between files attachment (review-diff.txt)
> === modified file 'src/pulse-manager.c'
> --- src/pulse-manager.c 2010-04-22 16:58:50 +0000
> +++ src/pulse-manager.c 2010-04-22 18:30:29 +0000
> @@ -242,27 +242,16 @@
> 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);
> - }
> -
> - 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_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &s->volume, NULL, NULL));
> + sink_info *cached_sink = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
> +
> + 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, &new_volume, NULL, NULL));
> }
>
>
>
--
https://code.launchpad.net/~cjcurran/indicator-sound/volume_setting_code_refactor/+merge/23953
Your team ayatana-commits is subscribed to branch lp:indicator-sound.
References