diff options
author | 2010-04-25 18:25:07 +0000 | |
---|---|---|
committer | 2010-04-25 18:25:07 +0000 | |
commit | 5a577ed2444bccc91e925f805097c6378ad28f21 (patch) | |
tree | dc1b9bee200166907f0759e849d6ac41caab66b9 /lib/libsndio | |
parent | Do not include <machine/intr.h> from <sh/psl.h>, and fix <sh/cpu.h> which (diff) | |
download | wireguard-openbsd-5a577ed2444bccc91e925f805097c6378ad28f21.tar.xz wireguard-openbsd-5a577ed2444bccc91e925f805097c6378ad28f21.zip |
when probing for a encoding/channels/rate combination, ensure that
play parameters are set only if playback is enabled, and record
parameters are set only if recording is enabled. Fixes
sun_getcap() on devices whose play and record parameters are not
independent.
Diffstat (limited to 'lib/libsndio')
-rw-r--r-- | lib/libsndio/sun.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/lib/libsndio/sun.c b/lib/libsndio/sun.c index c59faba3f8a..f43b34a59f6 100644 --- a/lib/libsndio/sun.c +++ b/lib/libsndio/sun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sun.c,v 1.31 2010/04/24 14:13:34 ratchov Exp $ */ +/* $OpenBSD: sun.c,v 1.32 2010/04/25 18:25:07 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -154,35 +154,31 @@ sun_tryinfo(struct sun_hdl *hdl, struct sio_enc *enc, unsigned pchan, unsigned rchan, unsigned rate) { struct audio_info aui; + struct audio_prinfo *pr; + + pr = (hdl->sio.mode & SIO_PLAY) ? &aui.play : &aui.record; AUDIO_INITINFO(&aui); if (enc) { if (enc->le && enc->sig) { - aui.play.encoding = AUDIO_ENCODING_SLINEAR_LE; - aui.record.encoding = AUDIO_ENCODING_SLINEAR_LE; + pr->encoding = AUDIO_ENCODING_SLINEAR_LE; } else if (!enc->le && enc->sig) { - aui.play.encoding = AUDIO_ENCODING_SLINEAR_BE; - aui.record.encoding = AUDIO_ENCODING_SLINEAR_BE; + pr->encoding = AUDIO_ENCODING_SLINEAR_BE; } else if (enc->le && !enc->sig) { - aui.play.encoding = AUDIO_ENCODING_ULINEAR_LE; - aui.record.encoding = AUDIO_ENCODING_ULINEAR_LE; + pr->encoding = AUDIO_ENCODING_ULINEAR_LE; } else { - aui.play.encoding = AUDIO_ENCODING_ULINEAR_BE; - aui.record.encoding = AUDIO_ENCODING_ULINEAR_BE; + pr->encoding = AUDIO_ENCODING_ULINEAR_BE; } - aui.play.precision = enc->bits; - aui.record.precision = enc->bits; + pr->precision = enc->bits; } - if (pchan) + if (rate) + pr->sample_rate = rate; + if ((hdl->sio.mode & (SIO_PLAY | SIO_REC)) == (SIO_PLAY | SIO_REC)) + aui.record = aui.play; + if (pchan && (hdl->sio.mode & SIO_PLAY)) aui.play.channels = pchan; - if (rchan) + if (rchan && (hdl->sio.mode & SIO_REC)) aui.record.channels = rchan; - if (rate) { - if (hdl->sio.mode & SIO_PLAY) - aui.play.sample_rate = rate; - if (hdl->sio.mode & SIO_REC) - aui.record.sample_rate = rate; - } if (ioctl(hdl->fd, AUDIO_SETINFO, &aui) < 0) { if (errno == EINVAL) return 0; |