[MPlayer-dev-eng] [PATCH] ao_alsa volume conversion when min. volume not 0

Zsolt Barat joy at pingfm.org
Wed Jul 14 02:57:32 CEST 2004


Reimar Döffinger wrote:

> Hi,
> the volume calculations in ao_alsa are (and were even before my patch 
> was applied ;-) ) broken when the minimum volume is != 0.
> Attached patch should fixes, unless a knot in my brain let me think 
> wrong again...
>
> Greetings,
> Reimar Döffinger
>
>------------------------------------------------------------------------
>
>Index: libao2/ao_alsa.c
>===================================================================
>RCS file: /cvsroot/mplayer/main/libao2/ao_alsa.c,v
>retrieving revision 1.4
>diff -u -r1.4 ao_alsa.c
>--- libao2/ao_alsa.c	13 Jul 2004 15:47:16 -0000	1.4
>+++ libao2/ao_alsa.c	13 Jul 2004 18:51:26 -0000
>@@ -152,11 +152,11 @@
> 	}
> 
>       snd_mixer_selem_get_playback_volume_range(elem,&pmin,&pmax);
>-      f_multi = (100 / (float)pmax - pmin);
>+      f_multi = (100 / (float)(pmax - pmin));
> 
>       if (cmd == AOCONTROL_SET_VOLUME) {
> 
>-	set_vol = (vol->left + pmin) / f_multi + 0.5;
>+	set_vol = vol->left / f_multi + pmin + 0.5;
> 
> 	//setting channels
> 	if ((err = snd_mixer_selem_set_playback_volume(elem, 0, set_vol)) < 0) {
>@@ -166,7 +166,7 @@
> 	}
> 	mp_msg(MSGT_AO,MSGL_DBG2,"left=%li, ", set_vol);
> 
>-	set_vol = (vol->right + pmin) / f_multi + 0.5;
>+	set_vol = vol->right / f_multi + pmin + 0.5;
> 
> 	if ((err = snd_mixer_selem_set_playback_volume(elem, 1, set_vol)) < 0) {
> 	  mp_msg(MSGT_AO,MSGL_ERR,"alsa-control: error setting right channel, %s\n", 
>@@ -178,9 +178,9 @@
>       }
>       else {
> 	snd_mixer_selem_get_playback_volume(elem, 0, &get_vol);
>-	vol->left = (get_vol * f_multi) - pmin;
>+	vol->left = (get_vol - pmin) * f_multi;
> 	snd_mixer_selem_get_playback_volume(elem, 1, &get_vol);
>-	vol->right = (get_vol * f_multi) - pmin;
>+	vol->right = (get_vol - pmin) * f_multi;
> 
> 	mp_msg(MSGT_AO,MSGL_DBG2,"left=%f, right=%f\n",vol->left,vol->right);
>       }
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>MPlayer-dev-eng mailing list
>MPlayer-dev-eng at mplayerhq.hu
>http://mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
>  
>
applied.




More information about the MPlayer-dev-eng mailing list