blob: 6c69622b4c7e89178236d6f3e02c4073fd535f22 [file] [log] [blame]
bellard85571bc2004-11-07 18:04:02 +00001/*
bellard1d14ffa2005-10-30 18:58:22 +00002 * QEMU OSS audio driver
3 *
4 * Copyright (c) 2003-2005 Vassili Karpov (malc)
5 *
bellard85571bc2004-11-07 18:04:02 +00006 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
Peter Maydell6086a562016-01-18 17:33:52 +000024#include "qemu/osdep.h"
bellard85571bc2004-11-07 18:04:02 +000025#include <sys/ioctl.h>
26#include <sys/soundcard.h>
pbrook87ecb682007-11-17 17:14:51 +000027#include "qemu-common.h"
Paolo Bonzini1de7afc2012-12-17 18:20:00 +010028#include "qemu/main-loop.h"
29#include "qemu/host-utils.h"
pbrook87ecb682007-11-17 17:14:51 +000030#include "audio.h"
Kővágó, Zoltánd95d7d82015-06-12 14:33:07 +020031#include "trace.h"
bellard85571bc2004-11-07 18:04:02 +000032
bellard1d14ffa2005-10-30 18:58:22 +000033#define AUDIO_CAP "oss"
34#include "audio_int.h"
bellardfb065182004-11-09 23:09:44 +000035
malc78d93562010-01-09 00:28:40 +030036#if defined OSS_GETVERSION && defined SNDCTL_DSP_POLICY
37#define USE_DSP_POLICY
38#endif
39
Kővágó, Zoltán4045a852015-06-03 23:03:50 +020040typedef struct OSSConf {
41 int try_mmap;
42 int nfrags;
43 int fragsize;
44 const char *devpath_out;
45 const char *devpath_in;
Kővágó, Zoltán4045a852015-06-03 23:03:50 +020046 int exclusive;
47 int policy;
48} OSSConf;
49
bellard1d14ffa2005-10-30 18:58:22 +000050typedef struct OSSVoiceOut {
51 HWVoiceOut hw;
bellardfb065182004-11-09 23:09:44 +000052 void *pcm_buf;
53 int fd;
malc9d168972009-09-18 10:59:54 +040054 int wpos;
bellardfb065182004-11-09 23:09:44 +000055 int nfrags;
56 int fragsize;
57 int mmapped;
malc9d168972009-09-18 10:59:54 +040058 int pending;
Kővágó, Zoltán4045a852015-06-03 23:03:50 +020059 OSSConf *conf;
bellard1d14ffa2005-10-30 18:58:22 +000060} OSSVoiceOut;
bellardfb065182004-11-09 23:09:44 +000061
bellard1d14ffa2005-10-30 18:58:22 +000062typedef struct OSSVoiceIn {
63 HWVoiceIn hw;
64 void *pcm_buf;
65 int fd;
66 int nfrags;
67 int fragsize;
Kővágó, Zoltán4045a852015-06-03 23:03:50 +020068 OSSConf *conf;
bellard1d14ffa2005-10-30 18:58:22 +000069} OSSVoiceIn;
bellard85571bc2004-11-07 18:04:02 +000070
bellard85571bc2004-11-07 18:04:02 +000071struct oss_params {
72 int freq;
73 audfmt_e fmt;
74 int nchannels;
75 int nfrags;
76 int fragsize;
77};
78
bellard1d14ffa2005-10-30 18:58:22 +000079static void GCC_FMT_ATTR (2, 3) oss_logerr (int err, const char *fmt, ...)
bellard85571bc2004-11-07 18:04:02 +000080{
bellard1d14ffa2005-10-30 18:58:22 +000081 va_list ap;
82
bellard1d14ffa2005-10-30 18:58:22 +000083 va_start (ap, fmt);
bellard571ec3d2005-11-20 16:24:34 +000084 AUD_vlog (AUDIO_CAP, fmt, ap);
bellard1d14ffa2005-10-30 18:58:22 +000085 va_end (ap);
bellard571ec3d2005-11-20 16:24:34 +000086
87 AUD_log (AUDIO_CAP, "Reason: %s\n", strerror (err));
bellard85571bc2004-11-07 18:04:02 +000088}
89
bellard1d14ffa2005-10-30 18:58:22 +000090static void GCC_FMT_ATTR (3, 4) oss_logerr2 (
91 int err,
92 const char *typ,
93 const char *fmt,
94 ...
95 )
96{
97 va_list ap;
98
bellardc0fe3822005-11-05 18:55:28 +000099 AUD_log (AUDIO_CAP, "Could not initialize %s\n", typ);
bellard1d14ffa2005-10-30 18:58:22 +0000100
101 va_start (ap, fmt);
102 AUD_vlog (AUDIO_CAP, fmt, ap);
103 va_end (ap);
104
105 AUD_log (AUDIO_CAP, "Reason: %s\n", strerror (err));
106}
107
108static void oss_anal_close (int *fdp)
109{
malc6ebfda12009-09-14 03:51:48 +0400110 int err;
111
112 qemu_set_fd_handler (*fdp, NULL, NULL, NULL);
113 err = close (*fdp);
bellard1d14ffa2005-10-30 18:58:22 +0000114 if (err) {
115 oss_logerr (errno, "Failed to close file(fd=%d)\n", *fdp);
116 }
117 *fdp = -1;
118}
119
malcdd8a5642009-09-12 02:29:16 +0400120static void oss_helper_poll_out (void *opaque)
121{
122 (void) opaque;
123 audio_run ("oss_poll_out");
124}
125
126static void oss_helper_poll_in (void *opaque)
127{
128 (void) opaque;
129 audio_run ("oss_poll_in");
130}
131
Fam Zhengb027a532015-06-04 14:45:21 +0800132static void oss_poll_out (HWVoiceOut *hw)
malcdd8a5642009-09-12 02:29:16 +0400133{
134 OSSVoiceOut *oss = (OSSVoiceOut *) hw;
135
Fam Zhengb027a532015-06-04 14:45:21 +0800136 qemu_set_fd_handler (oss->fd, NULL, oss_helper_poll_out, NULL);
malcdd8a5642009-09-12 02:29:16 +0400137}
138
Fam Zhengb027a532015-06-04 14:45:21 +0800139static void oss_poll_in (HWVoiceIn *hw)
malcdd8a5642009-09-12 02:29:16 +0400140{
141 OSSVoiceIn *oss = (OSSVoiceIn *) hw;
142
Fam Zhengb027a532015-06-04 14:45:21 +0800143 qemu_set_fd_handler (oss->fd, oss_helper_poll_in, NULL, NULL);
malcdd8a5642009-09-12 02:29:16 +0400144}
145
bellard1d14ffa2005-10-30 18:58:22 +0000146static int oss_write (SWVoiceOut *sw, void *buf, int len)
147{
148 return audio_pcm_sw_write (sw, buf, len);
149}
150
Michael Walleb6c9c942011-01-08 17:53:29 +0100151static int aud_to_ossfmt (audfmt_e fmt, int endianness)
bellard85571bc2004-11-07 18:04:02 +0000152{
153 switch (fmt) {
bellard1d14ffa2005-10-30 18:58:22 +0000154 case AUD_FMT_S8:
155 return AFMT_S8;
156
157 case AUD_FMT_U8:
158 return AFMT_U8;
159
160 case AUD_FMT_S16:
Michael Walleb6c9c942011-01-08 17:53:29 +0100161 if (endianness) {
162 return AFMT_S16_BE;
163 }
164 else {
165 return AFMT_S16_LE;
166 }
bellard1d14ffa2005-10-30 18:58:22 +0000167
168 case AUD_FMT_U16:
Michael Walleb6c9c942011-01-08 17:53:29 +0100169 if (endianness) {
170 return AFMT_U16_BE;
171 }
172 else {
173 return AFMT_U16_LE;
174 }
bellard1d14ffa2005-10-30 18:58:22 +0000175
bellard85571bc2004-11-07 18:04:02 +0000176 default:
bellard1d14ffa2005-10-30 18:58:22 +0000177 dolog ("Internal logic error: Bad audio format %d\n", fmt);
178#ifdef DEBUG_AUDIO
179 abort ();
180#endif
181 return AFMT_U8;
bellard85571bc2004-11-07 18:04:02 +0000182 }
183}
184
bellard1d14ffa2005-10-30 18:58:22 +0000185static int oss_to_audfmt (int ossfmt, audfmt_e *fmt, int *endianness)
bellard85571bc2004-11-07 18:04:02 +0000186{
bellard1d14ffa2005-10-30 18:58:22 +0000187 switch (ossfmt) {
188 case AFMT_S8:
balrogca9cc282008-01-14 04:24:29 +0000189 *endianness = 0;
bellard1d14ffa2005-10-30 18:58:22 +0000190 *fmt = AUD_FMT_S8;
191 break;
192
193 case AFMT_U8:
194 *endianness = 0;
195 *fmt = AUD_FMT_U8;
196 break;
197
198 case AFMT_S16_LE:
199 *endianness = 0;
200 *fmt = AUD_FMT_S16;
201 break;
202
203 case AFMT_U16_LE:
204 *endianness = 0;
205 *fmt = AUD_FMT_U16;
206 break;
207
208 case AFMT_S16_BE:
209 *endianness = 1;
210 *fmt = AUD_FMT_S16;
211 break;
212
213 case AFMT_U16_BE:
214 *endianness = 1;
215 *fmt = AUD_FMT_U16;
216 break;
217
bellard85571bc2004-11-07 18:04:02 +0000218 default:
bellard1d14ffa2005-10-30 18:58:22 +0000219 dolog ("Unrecognized audio format %d\n", ossfmt);
220 return -1;
bellard85571bc2004-11-07 18:04:02 +0000221 }
bellard1d14ffa2005-10-30 18:58:22 +0000222
223 return 0;
bellard85571bc2004-11-07 18:04:02 +0000224}
225
bellardc0fe3822005-11-05 18:55:28 +0000226#if defined DEBUG_MISMATCHES || defined DEBUG
bellard1d14ffa2005-10-30 18:58:22 +0000227static void oss_dump_info (struct oss_params *req, struct oss_params *obt)
bellard85571bc2004-11-07 18:04:02 +0000228{
229 dolog ("parameter | requested value | obtained value\n");
230 dolog ("format | %10d | %10d\n", req->fmt, obt->fmt);
bellard1d14ffa2005-10-30 18:58:22 +0000231 dolog ("channels | %10d | %10d\n",
232 req->nchannels, obt->nchannels);
bellard85571bc2004-11-07 18:04:02 +0000233 dolog ("frequency | %10d | %10d\n", req->freq, obt->freq);
234 dolog ("nfrags | %10d | %10d\n", req->nfrags, obt->nfrags);
bellard1d14ffa2005-10-30 18:58:22 +0000235 dolog ("fragsize | %10d | %10d\n",
236 req->fragsize, obt->fragsize);
bellard85571bc2004-11-07 18:04:02 +0000237}
238#endif
239
Juergen Lock72ff25e2010-01-12 23:48:04 +0100240#ifdef USE_DSP_POLICY
241static int oss_get_version (int fd, int *version, const char *typ)
242{
243 if (ioctl (fd, OSS_GETVERSION, &version)) {
244#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
245 /*
246 * Looks like atm (20100109) FreeBSD knows OSS_GETVERSION
247 * since 7.x, but currently only on the mixer device (or in
248 * the Linuxolator), and in the native version that part of
249 * the code is in fact never reached so the ioctl fails anyway.
250 * Until this is fixed, just check the errno and if its what
251 * FreeBSD's sound drivers return atm assume they are new enough.
252 */
253 if (errno == EINVAL) {
254 *version = 0x040000;
255 return 0;
256 }
257#endif
258 oss_logerr2 (errno, typ, "Failed to get OSS version\n");
259 return -1;
260 }
261 return 0;
262}
263#endif
264
bellard1d14ffa2005-10-30 18:58:22 +0000265static int oss_open (int in, struct oss_params *req,
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200266 struct oss_params *obt, int *pfd, OSSConf* conf)
bellard85571bc2004-11-07 18:04:02 +0000267{
268 int fd;
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200269 int oflags = conf->exclusive ? O_EXCL : 0;
bellard85571bc2004-11-07 18:04:02 +0000270 audio_buf_info abinfo;
271 int fmt, freq, nchannels;
malc3d709fe2010-01-09 18:06:54 +0300272 int setfragment = 1;
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200273 const char *dspname = in ? conf->devpath_in : conf->devpath_out;
bellard1d14ffa2005-10-30 18:58:22 +0000274 const char *typ = in ? "ADC" : "DAC";
bellard85571bc2004-11-07 18:04:02 +0000275
malc21823492009-09-11 10:13:55 +0400276 /* Kludge needed to have working mmap on Linux */
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200277 oflags |= conf->try_mmap ? O_RDWR : (in ? O_RDONLY : O_WRONLY);
malc0b3652b2009-09-13 08:17:47 +0400278
malc21823492009-09-11 10:13:55 +0400279 fd = open (dspname, oflags | O_NONBLOCK);
bellard85571bc2004-11-07 18:04:02 +0000280 if (-1 == fd) {
bellard1d14ffa2005-10-30 18:58:22 +0000281 oss_logerr2 (errno, typ, "Failed to open `%s'\n", dspname);
bellard85571bc2004-11-07 18:04:02 +0000282 return -1;
283 }
284
285 freq = req->freq;
286 nchannels = req->nchannels;
287 fmt = req->fmt;
288
289 if (ioctl (fd, SNDCTL_DSP_SAMPLESIZE, &fmt)) {
bellard1d14ffa2005-10-30 18:58:22 +0000290 oss_logerr2 (errno, typ, "Failed to set sample size %d\n", req->fmt);
bellard85571bc2004-11-07 18:04:02 +0000291 goto err;
292 }
293
294 if (ioctl (fd, SNDCTL_DSP_CHANNELS, &nchannels)) {
bellard1d14ffa2005-10-30 18:58:22 +0000295 oss_logerr2 (errno, typ, "Failed to set number of channels %d\n",
296 req->nchannels);
bellard85571bc2004-11-07 18:04:02 +0000297 goto err;
298 }
299
300 if (ioctl (fd, SNDCTL_DSP_SPEED, &freq)) {
bellard1d14ffa2005-10-30 18:58:22 +0000301 oss_logerr2 (errno, typ, "Failed to set frequency %d\n", req->freq);
bellard85571bc2004-11-07 18:04:02 +0000302 goto err;
303 }
304
malc902e2b52008-07-02 18:03:12 +0000305 if (ioctl (fd, SNDCTL_DSP_NONBLOCK, NULL)) {
bellard1d14ffa2005-10-30 18:58:22 +0000306 oss_logerr2 (errno, typ, "Failed to set non-blocking mode\n");
bellard85571bc2004-11-07 18:04:02 +0000307 goto err;
308 }
309
malc78d93562010-01-09 00:28:40 +0300310#ifdef USE_DSP_POLICY
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200311 if (conf->policy >= 0) {
malc6d246522010-01-09 17:54:07 +0300312 int version;
malc0b3652b2009-09-13 08:17:47 +0400313
Juergen Lock72ff25e2010-01-12 23:48:04 +0100314 if (!oss_get_version (fd, &version, typ)) {
Kővágó, Zoltánd95d7d82015-06-12 14:33:07 +0200315 trace_oss_version(version);
malc0b3652b2009-09-13 08:17:47 +0400316
malc3d709fe2010-01-09 18:06:54 +0300317 if (version >= 0x040000) {
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200318 int policy = conf->policy;
malc3d709fe2010-01-09 18:06:54 +0300319 if (ioctl (fd, SNDCTL_DSP_POLICY, &policy)) {
320 oss_logerr2 (errno, typ,
321 "Failed to set timing policy to %d\n",
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200322 conf->policy);
malc3d709fe2010-01-09 18:06:54 +0300323 goto err;
324 }
325 setfragment = 0;
malc6d246522010-01-09 17:54:07 +0300326 }
malc0b3652b2009-09-13 08:17:47 +0400327 }
328 }
malc0b3652b2009-09-13 08:17:47 +0400329#endif
malc3d709fe2010-01-09 18:06:54 +0300330
331 if (setfragment) {
malc0b3652b2009-09-13 08:17:47 +0400332 int mmmmssss = (req->nfrags << 16) | ctz32 (req->fragsize);
333 if (ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &mmmmssss)) {
334 oss_logerr2 (errno, typ, "Failed to set buffer length (%d, %d)\n",
335 req->nfrags, req->fragsize);
336 goto err;
337 }
bellard85571bc2004-11-07 18:04:02 +0000338 }
339
bellard1d14ffa2005-10-30 18:58:22 +0000340 if (ioctl (fd, in ? SNDCTL_DSP_GETISPACE : SNDCTL_DSP_GETOSPACE, &abinfo)) {
341 oss_logerr2 (errno, typ, "Failed to get buffer length\n");
bellard85571bc2004-11-07 18:04:02 +0000342 goto err;
343 }
344
malc29ddf272008-06-08 04:27:56 +0000345 if (!abinfo.fragstotal || !abinfo.fragsize) {
346 AUD_log (AUDIO_CAP, "Returned bogus buffer information(%d, %d) for %s\n",
347 abinfo.fragstotal, abinfo.fragsize, typ);
348 goto err;
349 }
350
bellard85571bc2004-11-07 18:04:02 +0000351 obt->fmt = fmt;
352 obt->nchannels = nchannels;
353 obt->freq = freq;
354 obt->nfrags = abinfo.fragstotal;
355 obt->fragsize = abinfo.fragsize;
356 *pfd = fd;
357
bellardc0fe3822005-11-05 18:55:28 +0000358#ifdef DEBUG_MISMATCHES
bellard85571bc2004-11-07 18:04:02 +0000359 if ((req->fmt != obt->fmt) ||
360 (req->nchannels != obt->nchannels) ||
361 (req->freq != obt->freq) ||
362 (req->fragsize != obt->fragsize) ||
363 (req->nfrags != obt->nfrags)) {
bellard85571bc2004-11-07 18:04:02 +0000364 dolog ("Audio parameters mismatch\n");
bellard1d14ffa2005-10-30 18:58:22 +0000365 oss_dump_info (req, obt);
bellard85571bc2004-11-07 18:04:02 +0000366 }
bellardc0fe3822005-11-05 18:55:28 +0000367#endif
bellard85571bc2004-11-07 18:04:02 +0000368
bellard1d14ffa2005-10-30 18:58:22 +0000369#ifdef DEBUG
370 oss_dump_info (req, obt);
bellard85571bc2004-11-07 18:04:02 +0000371#endif
372 return 0;
373
bellard1d14ffa2005-10-30 18:58:22 +0000374 err:
375 oss_anal_close (&fd);
bellard85571bc2004-11-07 18:04:02 +0000376 return -1;
377}
378
malc9d168972009-09-18 10:59:54 +0400379static void oss_write_pending (OSSVoiceOut *oss)
380{
381 HWVoiceOut *hw = &oss->hw;
382
383 if (oss->mmapped) {
384 return;
385 }
386
387 while (oss->pending) {
388 int samples_written;
389 ssize_t bytes_written;
390 int samples_till_end = hw->samples - oss->wpos;
391 int samples_to_write = audio_MIN (oss->pending, samples_till_end);
392 int bytes_to_write = samples_to_write << hw->info.shift;
393 void *pcm = advance (oss->pcm_buf, oss->wpos << hw->info.shift);
394
395 bytes_written = write (oss->fd, pcm, bytes_to_write);
396 if (bytes_written < 0) {
397 if (errno != EAGAIN) {
398 oss_logerr (errno, "failed to write %d bytes\n",
399 bytes_to_write);
400 }
401 break;
402 }
403
404 if (bytes_written & hw->info.align) {
405 dolog ("misaligned write asked for %d, but got %zd\n",
406 bytes_to_write, bytes_written);
407 return;
408 }
409
410 samples_written = bytes_written >> hw->info.shift;
411 oss->pending -= samples_written;
412 oss->wpos = (oss->wpos + samples_written) % hw->samples;
413 if (bytes_written - bytes_to_write) {
414 break;
415 }
416 }
417}
418
malcbdff2532009-09-18 11:37:39 +0400419static int oss_run_out (HWVoiceOut *hw, int live)
bellard85571bc2004-11-07 18:04:02 +0000420{
bellard1d14ffa2005-10-30 18:58:22 +0000421 OSSVoiceOut *oss = (OSSVoiceOut *) hw;
malcbdff2532009-09-18 11:37:39 +0400422 int err, decr;
bellard85571bc2004-11-07 18:04:02 +0000423 struct audio_buf_info abinfo;
424 struct count_info cntinfo;
bellardc0fe3822005-11-05 18:55:28 +0000425 int bufsize;
bellard85571bc2004-11-07 18:04:02 +0000426
bellardc0fe3822005-11-05 18:55:28 +0000427 bufsize = hw->samples << hw->info.shift;
428
bellard85571bc2004-11-07 18:04:02 +0000429 if (oss->mmapped) {
malc54762b72009-09-13 08:47:30 +0400430 int bytes, pos;
bellard85571bc2004-11-07 18:04:02 +0000431
432 err = ioctl (oss->fd, SNDCTL_DSP_GETOPTR, &cntinfo);
433 if (err < 0) {
bellard1d14ffa2005-10-30 18:58:22 +0000434 oss_logerr (errno, "SNDCTL_DSP_GETOPTR failed\n");
435 return 0;
bellard85571bc2004-11-07 18:04:02 +0000436 }
437
malc54762b72009-09-13 08:47:30 +0400438 pos = hw->rpos << hw->info.shift;
439 bytes = audio_ring_dist (cntinfo.ptr, pos, bufsize);
bellard1d14ffa2005-10-30 18:58:22 +0000440 decr = audio_MIN (bytes >> hw->info.shift, live);
bellard85571bc2004-11-07 18:04:02 +0000441 }
442 else {
443 err = ioctl (oss->fd, SNDCTL_DSP_GETOSPACE, &abinfo);
444 if (err < 0) {
bellard1d14ffa2005-10-30 18:58:22 +0000445 oss_logerr (errno, "SNDCTL_DSP_GETOPTR failed\n");
446 return 0;
bellard85571bc2004-11-07 18:04:02 +0000447 }
448
bellard8ead62c2006-07-04 16:51:32 +0000449 if (abinfo.bytes > bufsize) {
Kővágó, Zoltánd95d7d82015-06-12 14:33:07 +0200450 trace_oss_invalid_available_size(abinfo.bytes, bufsize);
bellard8ead62c2006-07-04 16:51:32 +0000451 abinfo.bytes = bufsize;
452 }
453
454 if (abinfo.bytes < 0) {
Kővágó, Zoltánd95d7d82015-06-12 14:33:07 +0200455 trace_oss_invalid_available_size(abinfo.bytes, bufsize);
bellard1d14ffa2005-10-30 18:58:22 +0000456 return 0;
457 }
458
459 decr = audio_MIN (abinfo.bytes >> hw->info.shift, live);
460 if (!decr) {
461 return 0;
462 }
bellard85571bc2004-11-07 18:04:02 +0000463 }
464
malc9d168972009-09-18 10:59:54 +0400465 decr = audio_pcm_hw_clip_out (hw, oss->pcm_buf, decr, oss->pending);
466 oss->pending += decr;
467 oss_write_pending (oss);
bellard85571bc2004-11-07 18:04:02 +0000468
bellard1d14ffa2005-10-30 18:58:22 +0000469 return decr;
bellard85571bc2004-11-07 18:04:02 +0000470}
471
bellard1d14ffa2005-10-30 18:58:22 +0000472static void oss_fini_out (HWVoiceOut *hw)
bellard85571bc2004-11-07 18:04:02 +0000473{
474 int err;
bellard1d14ffa2005-10-30 18:58:22 +0000475 OSSVoiceOut *oss = (OSSVoiceOut *) hw;
bellard85571bc2004-11-07 18:04:02 +0000476
bellard1d14ffa2005-10-30 18:58:22 +0000477 ldebug ("oss_fini\n");
478 oss_anal_close (&oss->fd);
bellard85571bc2004-11-07 18:04:02 +0000479
480 if (oss->pcm_buf) {
481 if (oss->mmapped) {
bellardc0fe3822005-11-05 18:55:28 +0000482 err = munmap (oss->pcm_buf, hw->samples << hw->info.shift);
bellard85571bc2004-11-07 18:04:02 +0000483 if (err) {
bellard1d14ffa2005-10-30 18:58:22 +0000484 oss_logerr (errno, "Failed to unmap buffer %p, size %d\n",
bellardc0fe3822005-11-05 18:55:28 +0000485 oss->pcm_buf, hw->samples << hw->info.shift);
bellard85571bc2004-11-07 18:04:02 +0000486 }
487 }
488 else {
Anthony Liguori7267c092011-08-20 22:09:37 -0500489 g_free (oss->pcm_buf);
bellard85571bc2004-11-07 18:04:02 +0000490 }
491 oss->pcm_buf = NULL;
492 }
493}
494
Kővágó, Zoltán5706db12015-06-03 23:03:47 +0200495static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,
496 void *drv_opaque)
bellard85571bc2004-11-07 18:04:02 +0000497{
bellard1d14ffa2005-10-30 18:58:22 +0000498 OSSVoiceOut *oss = (OSSVoiceOut *) hw;
bellard85571bc2004-11-07 18:04:02 +0000499 struct oss_params req, obt;
bellard1d14ffa2005-10-30 18:58:22 +0000500 int endianness;
501 int err;
502 int fd;
503 audfmt_e effective_fmt;
malc1ea879e2008-12-03 22:48:44 +0000504 struct audsettings obt_as;
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200505 OSSConf *conf = drv_opaque;
bellard85571bc2004-11-07 18:04:02 +0000506
bellard571ec3d2005-11-20 16:24:34 +0000507 oss->fd = -1;
508
Michael Walleb6c9c942011-01-08 17:53:29 +0100509 req.fmt = aud_to_ossfmt (as->fmt, as->endianness);
bellardc0fe3822005-11-05 18:55:28 +0000510 req.freq = as->freq;
511 req.nchannels = as->nchannels;
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200512 req.fragsize = conf->fragsize;
513 req.nfrags = conf->nfrags;
bellard85571bc2004-11-07 18:04:02 +0000514
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200515 if (oss_open (0, &req, &obt, &fd, conf)) {
bellard85571bc2004-11-07 18:04:02 +0000516 return -1;
bellard1d14ffa2005-10-30 18:58:22 +0000517 }
bellard85571bc2004-11-07 18:04:02 +0000518
bellard1d14ffa2005-10-30 18:58:22 +0000519 err = oss_to_audfmt (obt.fmt, &effective_fmt, &endianness);
520 if (err) {
521 oss_anal_close (&fd);
522 return -1;
523 }
bellard85571bc2004-11-07 18:04:02 +0000524
bellardc0fe3822005-11-05 18:55:28 +0000525 obt_as.freq = obt.freq;
526 obt_as.nchannels = obt.nchannels;
527 obt_as.fmt = effective_fmt;
bellardd929eba2006-07-04 21:47:22 +0000528 obt_as.endianness = endianness;
bellardc0fe3822005-11-05 18:55:28 +0000529
bellardd929eba2006-07-04 21:47:22 +0000530 audio_pcm_init_info (&hw->info, &obt_as);
bellard85571bc2004-11-07 18:04:02 +0000531 oss->nfrags = obt.nfrags;
532 oss->fragsize = obt.fragsize;
bellardc0fe3822005-11-05 18:55:28 +0000533
534 if (obt.nfrags * obt.fragsize & hw->info.align) {
535 dolog ("warning: Misaligned DAC buffer, size %d, alignment %d\n",
536 obt.nfrags * obt.fragsize, hw->info.align + 1);
537 }
538
539 hw->samples = (obt.nfrags * obt.fragsize) >> hw->info.shift;
bellard85571bc2004-11-07 18:04:02 +0000540
541 oss->mmapped = 0;
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200542 if (conf->try_mmap) {
bellardc0fe3822005-11-05 18:55:28 +0000543 oss->pcm_buf = mmap (
Blue Swirl660f11b2009-07-31 21:16:51 +0000544 NULL,
bellardc0fe3822005-11-05 18:55:28 +0000545 hw->samples << hw->info.shift,
546 PROT_READ | PROT_WRITE,
547 MAP_SHARED,
548 fd,
549 0
550 );
bellard85571bc2004-11-07 18:04:02 +0000551 if (oss->pcm_buf == MAP_FAILED) {
bellard1d14ffa2005-10-30 18:58:22 +0000552 oss_logerr (errno, "Failed to map %d bytes of DAC\n",
bellardc0fe3822005-11-05 18:55:28 +0000553 hw->samples << hw->info.shift);
malc54762b72009-09-13 08:47:30 +0400554 }
555 else {
bellard85571bc2004-11-07 18:04:02 +0000556 int err;
557 int trig = 0;
bellard1d14ffa2005-10-30 18:58:22 +0000558 if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
559 oss_logerr (errno, "SNDCTL_DSP_SETTRIGGER 0 failed\n");
bellard44a095a2004-11-14 16:02:51 +0000560 }
561 else {
562 trig = PCM_ENABLE_OUTPUT;
bellard1d14ffa2005-10-30 18:58:22 +0000563 if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
564 oss_logerr (
565 errno,
566 "SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n"
567 );
bellard44a095a2004-11-14 16:02:51 +0000568 }
569 else {
570 oss->mmapped = 1;
571 }
bellard85571bc2004-11-07 18:04:02 +0000572 }
573
bellard44a095a2004-11-14 16:02:51 +0000574 if (!oss->mmapped) {
bellardc0fe3822005-11-05 18:55:28 +0000575 err = munmap (oss->pcm_buf, hw->samples << hw->info.shift);
bellard44a095a2004-11-14 16:02:51 +0000576 if (err) {
bellard1d14ffa2005-10-30 18:58:22 +0000577 oss_logerr (errno, "Failed to unmap buffer %p size %d\n",
bellardc0fe3822005-11-05 18:55:28 +0000578 oss->pcm_buf, hw->samples << hw->info.shift);
bellard44a095a2004-11-14 16:02:51 +0000579 }
bellard85571bc2004-11-07 18:04:02 +0000580 }
581 }
582 }
583
584 if (!oss->mmapped) {
Alistair Francis470bcab2018-02-03 09:43:02 +0100585 oss->pcm_buf = audio_calloc(__func__,
586 hw->samples,
587 1 << hw->info.shift);
bellard85571bc2004-11-07 18:04:02 +0000588 if (!oss->pcm_buf) {
bellardb41cffb2005-11-11 00:02:25 +0000589 dolog (
590 "Could not allocate DAC buffer (%d samples, each %d bytes)\n",
591 hw->samples,
592 1 << hw->info.shift
593 );
bellard1d14ffa2005-10-30 18:58:22 +0000594 oss_anal_close (&fd);
bellard85571bc2004-11-07 18:04:02 +0000595 return -1;
596 }
597 }
598
bellard1d14ffa2005-10-30 18:58:22 +0000599 oss->fd = fd;
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200600 oss->conf = conf;
bellard85571bc2004-11-07 18:04:02 +0000601 return 0;
602}
603
bellard1d14ffa2005-10-30 18:58:22 +0000604static int oss_ctl_out (HWVoiceOut *hw, int cmd, ...)
bellard85571bc2004-11-07 18:04:02 +0000605{
606 int trig;
bellard1d14ffa2005-10-30 18:58:22 +0000607 OSSVoiceOut *oss = (OSSVoiceOut *) hw;
bellard85571bc2004-11-07 18:04:02 +0000608
bellard85571bc2004-11-07 18:04:02 +0000609 switch (cmd) {
610 case VOICE_ENABLE:
malc301901b2009-10-02 02:37:40 +0400611 {
612 va_list ap;
613 int poll_mode;
malcdd8a5642009-09-12 02:29:16 +0400614
malc301901b2009-10-02 02:37:40 +0400615 va_start (ap, cmd);
616 poll_mode = va_arg (ap, int);
617 va_end (ap);
malcdd8a5642009-09-12 02:29:16 +0400618
malc301901b2009-10-02 02:37:40 +0400619 ldebug ("enabling voice\n");
Fam Zhengb027a532015-06-04 14:45:21 +0800620 if (poll_mode) {
621 oss_poll_out (hw);
malc301901b2009-10-02 02:37:40 +0400622 poll_mode = 0;
623 }
624 hw->poll_mode = poll_mode;
625
626 if (!oss->mmapped) {
627 return 0;
628 }
629
630 audio_pcm_info_clear_buf (&hw->info, oss->pcm_buf, hw->samples);
631 trig = PCM_ENABLE_OUTPUT;
632 if (ioctl (oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
633 oss_logerr (
634 errno,
635 "SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n"
636 );
637 return -1;
638 }
bellard85571bc2004-11-07 18:04:02 +0000639 }
640 break;
641
642 case VOICE_DISABLE:
malcdd8a5642009-09-12 02:29:16 +0400643 if (hw->poll_mode) {
644 qemu_set_fd_handler (oss->fd, NULL, NULL, NULL);
645 hw->poll_mode = 0;
646 }
647
648 if (!oss->mmapped) {
649 return 0;
650 }
651
bellard85571bc2004-11-07 18:04:02 +0000652 ldebug ("disabling voice\n");
653 trig = 0;
654 if (ioctl (oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
bellard1d14ffa2005-10-30 18:58:22 +0000655 oss_logerr (errno, "SNDCTL_DSP_SETTRIGGER 0 failed\n");
bellard85571bc2004-11-07 18:04:02 +0000656 return -1;
657 }
658 break;
659 }
660 return 0;
661}
662
Kővágó, Zoltán5706db12015-06-03 23:03:47 +0200663static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
bellard1d14ffa2005-10-30 18:58:22 +0000664{
665 OSSVoiceIn *oss = (OSSVoiceIn *) hw;
666 struct oss_params req, obt;
667 int endianness;
668 int err;
669 int fd;
670 audfmt_e effective_fmt;
malc1ea879e2008-12-03 22:48:44 +0000671 struct audsettings obt_as;
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200672 OSSConf *conf = drv_opaque;
bellard1d14ffa2005-10-30 18:58:22 +0000673
bellard571ec3d2005-11-20 16:24:34 +0000674 oss->fd = -1;
675
Michael Walleb6c9c942011-01-08 17:53:29 +0100676 req.fmt = aud_to_ossfmt (as->fmt, as->endianness);
bellardc0fe3822005-11-05 18:55:28 +0000677 req.freq = as->freq;
678 req.nchannels = as->nchannels;
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200679 req.fragsize = conf->fragsize;
680 req.nfrags = conf->nfrags;
681 if (oss_open (1, &req, &obt, &fd, conf)) {
bellard1d14ffa2005-10-30 18:58:22 +0000682 return -1;
683 }
684
685 err = oss_to_audfmt (obt.fmt, &effective_fmt, &endianness);
686 if (err) {
687 oss_anal_close (&fd);
688 return -1;
689 }
690
bellardc0fe3822005-11-05 18:55:28 +0000691 obt_as.freq = obt.freq;
692 obt_as.nchannels = obt.nchannels;
693 obt_as.fmt = effective_fmt;
bellardd929eba2006-07-04 21:47:22 +0000694 obt_as.endianness = endianness;
bellardc0fe3822005-11-05 18:55:28 +0000695
bellardd929eba2006-07-04 21:47:22 +0000696 audio_pcm_init_info (&hw->info, &obt_as);
bellard1d14ffa2005-10-30 18:58:22 +0000697 oss->nfrags = obt.nfrags;
698 oss->fragsize = obt.fragsize;
bellardc0fe3822005-11-05 18:55:28 +0000699
700 if (obt.nfrags * obt.fragsize & hw->info.align) {
701 dolog ("warning: Misaligned ADC buffer, size %d, alignment %d\n",
702 obt.nfrags * obt.fragsize, hw->info.align + 1);
703 }
704
705 hw->samples = (obt.nfrags * obt.fragsize) >> hw->info.shift;
Alistair Francis470bcab2018-02-03 09:43:02 +0100706 oss->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
bellard1d14ffa2005-10-30 18:58:22 +0000707 if (!oss->pcm_buf) {
bellardb41cffb2005-11-11 00:02:25 +0000708 dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n",
709 hw->samples, 1 << hw->info.shift);
bellard1d14ffa2005-10-30 18:58:22 +0000710 oss_anal_close (&fd);
711 return -1;
712 }
713
714 oss->fd = fd;
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200715 oss->conf = conf;
bellard1d14ffa2005-10-30 18:58:22 +0000716 return 0;
717}
718
719static void oss_fini_in (HWVoiceIn *hw)
720{
721 OSSVoiceIn *oss = (OSSVoiceIn *) hw;
722
723 oss_anal_close (&oss->fd);
724
Markus Armbrusterfb7da622014-06-06 18:35:13 +0200725 g_free(oss->pcm_buf);
726 oss->pcm_buf = NULL;
bellard1d14ffa2005-10-30 18:58:22 +0000727}
728
729static int oss_run_in (HWVoiceIn *hw)
730{
731 OSSVoiceIn *oss = (OSSVoiceIn *) hw;
732 int hwshift = hw->info.shift;
733 int i;
734 int live = audio_pcm_hw_get_live_in (hw);
735 int dead = hw->samples - live;
736 size_t read_samples = 0;
737 struct {
738 int add;
739 int len;
740 } bufs[2] = {
malc98f9f482009-08-11 20:48:02 +0400741 { .add = hw->wpos, .len = 0 },
742 { .add = 0, .len = 0 }
bellard1d14ffa2005-10-30 18:58:22 +0000743 };
744
745 if (!dead) {
746 return 0;
747 }
748
749 if (hw->wpos + dead > hw->samples) {
750 bufs[0].len = (hw->samples - hw->wpos) << hwshift;
751 bufs[1].len = (dead - (hw->samples - hw->wpos)) << hwshift;
752 }
753 else {
754 bufs[0].len = dead << hwshift;
755 }
756
bellard1d14ffa2005-10-30 18:58:22 +0000757 for (i = 0; i < 2; ++i) {
758 ssize_t nread;
759
760 if (bufs[i].len) {
761 void *p = advance (oss->pcm_buf, bufs[i].add << hwshift);
762 nread = read (oss->fd, p, bufs[i].len);
763
764 if (nread > 0) {
765 if (nread & hw->info.align) {
bellardb41cffb2005-11-11 00:02:25 +0000766 dolog ("warning: Misaligned read %zd (requested %d), "
bellard1d14ffa2005-10-30 18:58:22 +0000767 "alignment %d\n", nread, bufs[i].add << hwshift,
768 hw->info.align + 1);
769 }
770 read_samples += nread >> hwshift;
Michael Walle00e07672011-01-05 01:05:47 +0100771 hw->conv (hw->conv_buf + bufs[i].add, p, nread >> hwshift);
bellard1d14ffa2005-10-30 18:58:22 +0000772 }
773
774 if (bufs[i].len - nread) {
775 if (nread == -1) {
776 switch (errno) {
777 case EINTR:
778 case EAGAIN:
779 break;
780 default:
781 oss_logerr (
782 errno,
783 "Failed to read %d bytes of audio (to %p)\n",
784 bufs[i].len, p
785 );
786 break;
787 }
788 }
789 break;
790 }
791 }
792 }
793
794 hw->wpos = (hw->wpos + read_samples) % hw->samples;
795 return read_samples;
796}
797
798static int oss_read (SWVoiceIn *sw, void *buf, int size)
799{
800 return audio_pcm_sw_read (sw, buf, size);
801}
802
803static int oss_ctl_in (HWVoiceIn *hw, int cmd, ...)
804{
malcdd8a5642009-09-12 02:29:16 +0400805 OSSVoiceIn *oss = (OSSVoiceIn *) hw;
806
malcdd8a5642009-09-12 02:29:16 +0400807 switch (cmd) {
808 case VOICE_ENABLE:
malca628b862009-10-03 03:30:06 +0400809 {
810 va_list ap;
811 int poll_mode;
812
813 va_start (ap, cmd);
814 poll_mode = va_arg (ap, int);
815 va_end (ap);
816
Fam Zhengb027a532015-06-04 14:45:21 +0800817 if (poll_mode) {
818 oss_poll_in (hw);
malca628b862009-10-03 03:30:06 +0400819 poll_mode = 0;
820 }
821 hw->poll_mode = poll_mode;
malcdd8a5642009-09-12 02:29:16 +0400822 }
malcdd8a5642009-09-12 02:29:16 +0400823 break;
824
825 case VOICE_DISABLE:
826 if (hw->poll_mode) {
827 hw->poll_mode = 0;
828 qemu_set_fd_handler (oss->fd, NULL, NULL, NULL);
829 }
830 break;
831 }
bellard1d14ffa2005-10-30 18:58:22 +0000832 return 0;
833}
834
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200835static OSSConf glob_conf = {
836 .try_mmap = 0,
837 .nfrags = 4,
838 .fragsize = 4096,
839 .devpath_out = "/dev/dsp",
840 .devpath_in = "/dev/dsp",
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200841 .exclusive = 0,
842 .policy = 5
843};
844
bellard85571bc2004-11-07 18:04:02 +0000845static void *oss_audio_init (void)
846{
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200847 OSSConf *conf = g_malloc(sizeof(OSSConf));
848 *conf = glob_conf;
849
850 if (access(conf->devpath_in, R_OK | W_OK) < 0 ||
851 access(conf->devpath_out, R_OK | W_OK) < 0) {
Gonglei2828a302015-06-23 09:01:10 +0800852 g_free(conf);
Gerd Hoffmann73204cf2013-11-07 12:24:41 +0100853 return NULL;
854 }
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200855 return conf;
bellard85571bc2004-11-07 18:04:02 +0000856}
857
858static void oss_audio_fini (void *opaque)
859{
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200860 g_free(opaque);
bellard85571bc2004-11-07 18:04:02 +0000861}
862
bellard1d14ffa2005-10-30 18:58:22 +0000863static struct audio_option oss_options[] = {
malc98f9f482009-08-11 20:48:02 +0400864 {
865 .name = "FRAGSIZE",
866 .tag = AUD_OPT_INT,
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200867 .valp = &glob_conf.fragsize,
malc98f9f482009-08-11 20:48:02 +0400868 .descr = "Fragment size in bytes"
869 },
870 {
871 .name = "NFRAGS",
872 .tag = AUD_OPT_INT,
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200873 .valp = &glob_conf.nfrags,
malc98f9f482009-08-11 20:48:02 +0400874 .descr = "Number of fragments"
875 },
876 {
877 .name = "MMAP",
878 .tag = AUD_OPT_BOOL,
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200879 .valp = &glob_conf.try_mmap,
malc98f9f482009-08-11 20:48:02 +0400880 .descr = "Try using memory mapped access"
881 },
882 {
883 .name = "DAC_DEV",
884 .tag = AUD_OPT_STR,
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200885 .valp = &glob_conf.devpath_out,
malc98f9f482009-08-11 20:48:02 +0400886 .descr = "Path to DAC device"
887 },
888 {
889 .name = "ADC_DEV",
890 .tag = AUD_OPT_STR,
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200891 .valp = &glob_conf.devpath_in,
malc98f9f482009-08-11 20:48:02 +0400892 .descr = "Path to ADC device"
893 },
894 {
malc0b3652b2009-09-13 08:17:47 +0400895 .name = "EXCLUSIVE",
896 .tag = AUD_OPT_BOOL,
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200897 .valp = &glob_conf.exclusive,
Stefan Weilcb8d4c82016-03-23 15:59:57 +0100898 .descr = "Open device in exclusive mode (vmix won't work)"
malc0b3652b2009-09-13 08:17:47 +0400899 },
malc78d93562010-01-09 00:28:40 +0300900#ifdef USE_DSP_POLICY
malc0b3652b2009-09-13 08:17:47 +0400901 {
902 .name = "POLICY",
903 .tag = AUD_OPT_INT,
Kővágó, Zoltán4045a852015-06-03 23:03:50 +0200904 .valp = &glob_conf.policy,
malc0b3652b2009-09-13 08:17:47 +0400905 .descr = "Set the timing policy of the device, -1 to use fragment mode",
906 },
907#endif
Juan Quintela2700efa2009-08-11 02:31:16 +0200908 { /* End of list */ }
bellard85571bc2004-11-07 18:04:02 +0000909};
910
blueswir135f4b582008-10-06 18:08:30 +0000911static struct audio_pcm_ops oss_pcm_ops = {
Juan Quintela1dd3e4d2009-08-11 02:31:15 +0200912 .init_out = oss_init_out,
913 .fini_out = oss_fini_out,
914 .run_out = oss_run_out,
915 .write = oss_write,
916 .ctl_out = oss_ctl_out,
bellard1d14ffa2005-10-30 18:58:22 +0000917
Juan Quintela1dd3e4d2009-08-11 02:31:15 +0200918 .init_in = oss_init_in,
919 .fini_in = oss_fini_in,
920 .run_in = oss_run_in,
921 .read = oss_read,
922 .ctl_in = oss_ctl_in
bellard1d14ffa2005-10-30 18:58:22 +0000923};
924
Gerd Hoffmannd3893a32018-03-06 08:40:47 +0100925static struct audio_driver oss_audio_driver = {
Juan Quintelabee37f32009-08-11 02:31:14 +0200926 .name = "oss",
927 .descr = "OSS http://www.opensound.com",
928 .options = oss_options,
929 .init = oss_audio_init,
930 .fini = oss_audio_fini,
931 .pcm_ops = &oss_pcm_ops,
Gerd Hoffmann926de752013-11-07 12:25:02 +0100932 .can_be_default = 1,
Juan Quintelabee37f32009-08-11 02:31:14 +0200933 .max_voices_out = INT_MAX,
934 .max_voices_in = INT_MAX,
935 .voice_size_out = sizeof (OSSVoiceOut),
936 .voice_size_in = sizeof (OSSVoiceIn)
bellard85571bc2004-11-07 18:04:02 +0000937};
Gerd Hoffmannd3893a32018-03-06 08:40:47 +0100938
939static void register_audio_oss(void)
940{
941 audio_driver_register(&oss_audio_driver);
942}
943type_init(register_audio_oss);