[Mplayer-cvslog] CVS: main/libao2 ao_alsa.c,1.3,1.4

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Jul 13 20:47:25 CEST 2004


Hi,
> -      f_multi = (100 / (float)pmax);
> +      f_multi = (100 / (float)pmax - pmin);
>  
>        if (cmd == AOCONTROL_SET_VOLUME) {
>  
> -	diff = (vol->left+vol->right) / 2;
> -	set_vol = rint(diff / f_multi);
> -	
> -	if (set_vol < 0)
> -	  set_vol = 0;
> -	else if (set_vol > pmax)
> -	  set_vol = pmax;
> +	set_vol = (vol->left + pmin) / f_multi + 0.5;
>  
>  	//setting channels
>  	if ((err = snd_mixer_selem_set_playback_volume(elem, 0, set_vol)) < 0) {
> @@ -170,23 +164,25 @@
>  		 snd_strerror(err));
>  	  return CONTROL_ERROR;
>  	}
> +	mp_msg(MSGT_AO,MSGL_DBG2,"left=%li, ", set_vol);
> +
> +	set_vol = (vol->right + pmin) / f_multi + 0.5;
> +

It obviously was too late when I wrote that code. Those volume 
calculations are wrong, e.g. it should be
set_vol = vol->right / f_multi + p_min + 0.5;
I will write a patch for that. pmin will be zero in most cases, and in 
all other cases the old code was broken as well, but it still should be 
fixed ;-)

> -    if (str_status != "running")
> +    if (snd_pcm_status_get_state(status) == SND_PCM_STATE_RUNNING)

are you sure you don't want to use my strcmp variant? Maybe the state 
could change in between those two calls to snd_pcm_status_get_state.
Ok, probably only a theoretical problem...
But it still should be != not ==, shouldn't it?

Greetings,
Reimar Döffinger




More information about the MPlayer-cvslog mailing list