From aac840d9f91c52a1dc3dcbdbfc3c628a80a717a1 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Tue, 15 Jun 2021 17:15:24 +0200 Subject: [PATCH] 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 , thanks --- libsndio/sio_oss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 @@ -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) {