oss: Fix sio_setpar() when channel number is not set

The trap value set by sio_initpar() was interpreted as a channel
number, causing sio_setpar() to fail.

Found and analysed by Roman Bogorodskiy <bogorodskiy at gmail.com>,
thanks
This commit is contained in:
Alexandre Ratchov 2021-06-15 17:15:24 +02:00
parent 4d63a3b185
commit aac840d9f9
1 changed files with 2 additions and 2 deletions

View File

@ -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) {