Re: sio_initpar() generates invalid parameters

From: Roman Bogorodskiy <bogorodskiy_at_gmail.com>
Date: Tue, 15 Jun 2021 19:14:49 +0400
  Alexandre Ratchov wrote:

> sio_initpar() fills all parameters with -1, which is a trap value
> meaning "don't change this parameter" (parameter is unset). In turn,
> the default should be used as you said.
> 
> The problem is that sio_oss_setpar() doesn't check if the channel
> number is unset (equals to the trap value) and tries to set it to ~0U.
> 
> I have no FreeBSD system right now, does this diff fix the problem?
> 
> diff --git a/libsndio/sio_oss.c b/libsndio/sio_oss.c
> index 6a171c1..22c37fc 100644
> --- a/libsndio/sio_oss.c
> +++ b/libsndio/sio_oss.c
> _at_@ -436,9 +436,9 @@ sio_oss_setpar(struct sio_hdl *sh, struct sio_par *par)
>  	if (hdl->rate > 192000)
>  		hdl->rate = 192000;
>  
> -	if (hdl->sio.mode & SIO_PLAY)
> +	if ((hdl->sio.mode & SIO_PLAY) && par->pchan != ~0U)
>  		hdl->chan = par->pchan;
> -	else if (hdl->sio.mode & SIO_REC)
> +	else if ((hdl->sio.mode & SIO_REC) && par->rchan != ~0U)
>  		hdl->chan = par->rchan;
>  
>  	if (ioctl(hdl->fd, SNDCTL_DSP_SETFMT, &hdl->fmt) == -1) {

Yes, with this patch things work fine without workarounds on mpg123
side.

Thanks,

Roman Bogorodskiy

Received on Tue Jun 15 2021 - 17:14:49 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 09 2022 - 16:23:51 CEST