| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ossaudio.c,v 1.59 2020/10/30 21:44:49 nia Exp $ */ | | 1 | /* $NetBSD: ossaudio.c,v 1.60 2020/11/03 08:24:33 nia Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. | | 26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __RCSID("$NetBSD: ossaudio.c,v 1.59 2020/10/30 21:44:49 nia Exp $"); | | 30 | __RCSID("$NetBSD: ossaudio.c,v 1.60 2020/11/03 08:24:33 nia Exp $"); |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * This is an Open Sound System compatibility layer, which provides | | 33 | * This is an Open Sound System compatibility layer, which provides |
34 | * fairly complete ioctl emulation for OSSv3 and some of OSSv4. | | 34 | * fairly complete ioctl emulation for OSSv3 and some of OSSv4. |
35 | * | | 35 | * |
36 | * The canonical OSS specification is available at | | 36 | * The canonical OSS specification is available at |
37 | * http://manuals.opensound.com/developer/ | | 37 | * http://manuals.opensound.com/developer/ |
38 | * | | 38 | * |
39 | * This file is similar to sys/compat/ossaudio.c with additional OSSv4 | | 39 | * This file is similar to sys/compat/ossaudio.c with additional OSSv4 |
40 | * compatibility. | | 40 | * compatibility. |
41 | */ | | 41 | */ |
42 | | | 42 | |
43 | #include <string.h> | | 43 | #include <string.h> |
| @@ -177,29 +177,29 @@ audio_ioctl(int fd, unsigned long com, v | | | @@ -177,29 +177,29 @@ audio_ioctl(int fd, unsigned long com, v |
177 | break; | | 177 | break; |
178 | case SNDCTL_DSP_POST: | | 178 | case SNDCTL_DSP_POST: |
179 | /* This call is merely advisory, and may be a nop. */ | | 179 | /* This call is merely advisory, and may be a nop. */ |
180 | break; | | 180 | break; |
181 | case SNDCTL_DSP_SPEED: | | 181 | case SNDCTL_DSP_SPEED: |
182 | AUDIO_INITINFO(&tmpinfo); | | 182 | AUDIO_INITINFO(&tmpinfo); |
183 | /* Conform to kernel limits. */ | | 183 | /* Conform to kernel limits. */ |
184 | if (INTARG < 1000) | | 184 | if (INTARG < 1000) |
185 | INTARG = 1000; | | 185 | INTARG = 1000; |
186 | if (INTARG > 192000) | | 186 | if (INTARG > 192000) |
187 | INTARG = 192000; | | 187 | INTARG = 192000; |
188 | tmpinfo.play.sample_rate = | | 188 | tmpinfo.play.sample_rate = |
189 | tmpinfo.record.sample_rate = INTARG; | | 189 | tmpinfo.record.sample_rate = INTARG; |
190 | if (ioctl(fd, AUDIO_SETINFO, &tmpinfo) < 0) { | | 190 | retval = ioctl(fd, AUDIO_SETINFO, &tmpinfo); |
| | | 191 | if (retval < 0) |
191 | return retval; | | 192 | return retval; |
192 | } | | | |
193 | /* FALLTHRU */ | | 193 | /* FALLTHRU */ |
194 | case SOUND_PCM_READ_RATE: | | 194 | case SOUND_PCM_READ_RATE: |
195 | retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo); | | 195 | retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo); |
196 | if (retval < 0) | | 196 | if (retval < 0) |
197 | return retval; | | 197 | return retval; |
198 | INTARG = GETPRINFO(&tmpinfo, sample_rate); | | 198 | INTARG = GETPRINFO(&tmpinfo, sample_rate); |
199 | break; | | 199 | break; |
200 | case SNDCTL_DSP_STEREO: | | 200 | case SNDCTL_DSP_STEREO: |
201 | AUDIO_INITINFO(&tmpinfo); | | 201 | AUDIO_INITINFO(&tmpinfo); |
202 | tmpinfo.play.channels = | | 202 | tmpinfo.play.channels = |
203 | tmpinfo.record.channels = INTARG ? 2 : 1; | | 203 | tmpinfo.record.channels = INTARG ? 2 : 1; |
204 | (void) ioctl(fd, AUDIO_SETINFO, &tmpinfo); | | 204 | (void) ioctl(fd, AUDIO_SETINFO, &tmpinfo); |
205 | retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo); | | 205 | retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo); |