[MPlayer-dev-eng] [PATCH] ALSA AO, attempt both chunk sizes before failing

Clemens Ladisch cladisch at fastmail.net
Thu Aug 30 13:50:09 CEST 2007


Andrew Calkin wrote:
> The attached patch has been sitting in the GeeXboX development tree
> since antiquity. Basically if it fails to set the period size with one
> of the values (1024 or 512), then it tries the other before bailing out.

>  	if ((err = snd_pcm_hw_params_set_period_size_near(alsa_handler, alsa_hwparams, 
>  							  &chunk_size, NULL)) < 0)

When it is not possible to set the given period size, this function just
sets a value that is as near as possible to the given value ("*_near").
This function fails only if cannot set _any_ value for the period size.

>  	  {
> -	    mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetPeriodSize,
> -			    chunk_size, snd_strerror(err));
> +	    chunk_size = 512 + 1024 - chunk_size;
> +	    if ((err = snd_pcm_hw_params_set_period_size(alsa_handler, alsa_hwparams, 
> +	                                                 chunk_size, 0)) < 0) {
> +	      mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetPeriodSize,
> +	      chunk_size, snd_strerror(err));
> +	    }
>  	    return 0;

This "return 0" will abort even if the second call succeeded.

Was there any situation where this patch was observed to make any difference?


Regards,
Clemens



More information about the MPlayer-dev-eng mailing list