2 * QEMU ALSA audio driver
4 * Copyright (c) 2005 Vassili Karpov (malc)
6 * 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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
25 #include "qemu/osdep.h"
26 #include <alsa/asoundlib.h>
27 #include "qemu/main-loop.h"
28 #include "qemu/module.h"
32 #pragma GCC diagnostic ignored "-Waddress"
34 #define AUDIO_CAP "alsa"
35 #include "audio_int.h"
47 typedef struct ALSAVoiceOut
{
50 struct pollhlp pollhlp
;
54 typedef struct ALSAVoiceIn
{
57 struct pollhlp pollhlp
;
61 struct alsa_params_req
{
67 struct alsa_params_obt
{
72 snd_pcm_uframes_t samples
;
75 static void GCC_FMT_ATTR (2, 3) alsa_logerr (int err
, const char *fmt
, ...)
80 AUD_vlog (AUDIO_CAP
, fmt
, ap
);
83 AUD_log (AUDIO_CAP
, "Reason: %s\n", snd_strerror (err
));
86 static void GCC_FMT_ATTR (3, 4) alsa_logerr2 (
95 AUD_log (AUDIO_CAP
, "Could not initialize %s\n", typ
);
98 AUD_vlog (AUDIO_CAP
, fmt
, ap
);
101 AUD_log (AUDIO_CAP
, "Reason: %s\n", snd_strerror (err
));
104 static void alsa_fini_poll (struct pollhlp
*hlp
)
107 struct pollfd
*pfds
= hlp
->pfds
;
110 for (i
= 0; i
< hlp
->count
; ++i
) {
111 qemu_set_fd_handler (pfds
[i
].fd
, NULL
, NULL
, NULL
);
120 static void alsa_anal_close1 (snd_pcm_t
**handlep
)
122 int err
= snd_pcm_close (*handlep
);
124 alsa_logerr (err
, "Failed to close PCM handle %p\n", *handlep
);
129 static void alsa_anal_close (snd_pcm_t
**handlep
, struct pollhlp
*hlp
)
131 alsa_fini_poll (hlp
);
132 alsa_anal_close1 (handlep
);
135 static int alsa_recover (snd_pcm_t
*handle
)
137 int err
= snd_pcm_prepare (handle
);
139 alsa_logerr (err
, "Failed to prepare handle %p\n", handle
);
145 static int alsa_resume (snd_pcm_t
*handle
)
147 int err
= snd_pcm_resume (handle
);
149 alsa_logerr (err
, "Failed to resume handle %p\n", handle
);
155 static void alsa_poll_handler (void *opaque
)
158 snd_pcm_state_t state
;
159 struct pollhlp
*hlp
= opaque
;
160 unsigned short revents
;
162 count
= poll (hlp
->pfds
, hlp
->count
, 0);
164 dolog ("alsa_poll_handler: poll %s\n", strerror (errno
));
172 /* XXX: ALSA example uses initial count, not the one returned by
174 err
= snd_pcm_poll_descriptors_revents (hlp
->handle
, hlp
->pfds
,
175 hlp
->count
, &revents
);
177 alsa_logerr (err
, "snd_pcm_poll_descriptors_revents");
181 if (!(revents
& hlp
->mask
)) {
182 trace_alsa_revents(revents
);
186 state
= snd_pcm_state (hlp
->handle
);
188 case SND_PCM_STATE_SETUP
:
189 alsa_recover (hlp
->handle
);
192 case SND_PCM_STATE_XRUN
:
193 alsa_recover (hlp
->handle
);
196 case SND_PCM_STATE_SUSPENDED
:
197 alsa_resume (hlp
->handle
);
200 case SND_PCM_STATE_PREPARED
:
201 audio_run(hlp
->s
, "alsa run (prepared)");
204 case SND_PCM_STATE_RUNNING
:
205 audio_run(hlp
->s
, "alsa run (running)");
209 dolog ("Unexpected state %d\n", state
);
213 static int alsa_poll_helper (snd_pcm_t
*handle
, struct pollhlp
*hlp
, int mask
)
218 count
= snd_pcm_poll_descriptors_count (handle
);
220 dolog ("Could not initialize poll mode\n"
221 "Invalid number of poll descriptors %d\n", count
);
225 pfds
= audio_calloc ("alsa_poll_helper", count
, sizeof (*pfds
));
227 dolog ("Could not initialize poll mode\n");
231 err
= snd_pcm_poll_descriptors (handle
, pfds
, count
);
233 alsa_logerr (err
, "Could not initialize poll mode\n"
234 "Could not obtain poll descriptors\n");
239 for (i
= 0; i
< count
; ++i
) {
240 if (pfds
[i
].events
& POLLIN
) {
241 qemu_set_fd_handler (pfds
[i
].fd
, alsa_poll_handler
, NULL
, hlp
);
243 if (pfds
[i
].events
& POLLOUT
) {
244 trace_alsa_pollout(i
, pfds
[i
].fd
);
245 qemu_set_fd_handler (pfds
[i
].fd
, NULL
, alsa_poll_handler
, hlp
);
247 trace_alsa_set_handler(pfds
[i
].events
, i
, pfds
[i
].fd
, err
);
252 hlp
->handle
= handle
;
257 static int alsa_poll_out (HWVoiceOut
*hw
)
259 ALSAVoiceOut
*alsa
= (ALSAVoiceOut
*) hw
;
261 return alsa_poll_helper (alsa
->handle
, &alsa
->pollhlp
, POLLOUT
);
264 static int alsa_poll_in (HWVoiceIn
*hw
)
266 ALSAVoiceIn
*alsa
= (ALSAVoiceIn
*) hw
;
268 return alsa_poll_helper (alsa
->handle
, &alsa
->pollhlp
, POLLIN
);
271 static snd_pcm_format_t
aud_to_alsafmt (AudioFormat fmt
, int endianness
)
274 case AUDIO_FORMAT_S8
:
275 return SND_PCM_FORMAT_S8
;
277 case AUDIO_FORMAT_U8
:
278 return SND_PCM_FORMAT_U8
;
280 case AUDIO_FORMAT_S16
:
282 return SND_PCM_FORMAT_S16_BE
;
284 return SND_PCM_FORMAT_S16_LE
;
287 case AUDIO_FORMAT_U16
:
289 return SND_PCM_FORMAT_U16_BE
;
291 return SND_PCM_FORMAT_U16_LE
;
294 case AUDIO_FORMAT_S32
:
296 return SND_PCM_FORMAT_S32_BE
;
298 return SND_PCM_FORMAT_S32_LE
;
301 case AUDIO_FORMAT_U32
:
303 return SND_PCM_FORMAT_U32_BE
;
305 return SND_PCM_FORMAT_U32_LE
;
308 case AUDIO_FORMAT_F32
:
310 return SND_PCM_FORMAT_FLOAT_BE
;
312 return SND_PCM_FORMAT_FLOAT_LE
;
316 dolog ("Internal logic error: Bad audio format %d\n", fmt
);
320 return SND_PCM_FORMAT_U8
;
324 static int alsa_to_audfmt (snd_pcm_format_t alsafmt
, AudioFormat
*fmt
,
328 case SND_PCM_FORMAT_S8
:
330 *fmt
= AUDIO_FORMAT_S8
;
333 case SND_PCM_FORMAT_U8
:
335 *fmt
= AUDIO_FORMAT_U8
;
338 case SND_PCM_FORMAT_S16_LE
:
340 *fmt
= AUDIO_FORMAT_S16
;
343 case SND_PCM_FORMAT_U16_LE
:
345 *fmt
= AUDIO_FORMAT_U16
;
348 case SND_PCM_FORMAT_S16_BE
:
350 *fmt
= AUDIO_FORMAT_S16
;
353 case SND_PCM_FORMAT_U16_BE
:
355 *fmt
= AUDIO_FORMAT_U16
;
358 case SND_PCM_FORMAT_S32_LE
:
360 *fmt
= AUDIO_FORMAT_S32
;
363 case SND_PCM_FORMAT_U32_LE
:
365 *fmt
= AUDIO_FORMAT_U32
;
368 case SND_PCM_FORMAT_S32_BE
:
370 *fmt
= AUDIO_FORMAT_S32
;
373 case SND_PCM_FORMAT_U32_BE
:
375 *fmt
= AUDIO_FORMAT_U32
;
378 case SND_PCM_FORMAT_FLOAT_LE
:
380 *fmt
= AUDIO_FORMAT_F32
;
383 case SND_PCM_FORMAT_FLOAT_BE
:
385 *fmt
= AUDIO_FORMAT_F32
;
389 dolog ("Unrecognized audio format %d\n", alsafmt
);
396 static void alsa_dump_info (struct alsa_params_req
*req
,
397 struct alsa_params_obt
*obt
,
398 snd_pcm_format_t obtfmt
,
399 AudiodevAlsaPerDirectionOptions
*apdo
)
401 dolog("parameter | requested value | obtained value\n");
402 dolog("format | %10d | %10d\n", req
->fmt
, obtfmt
);
403 dolog("channels | %10d | %10d\n",
404 req
->nchannels
, obt
->nchannels
);
405 dolog("frequency | %10d | %10d\n", req
->freq
, obt
->freq
);
406 dolog("============================================\n");
407 dolog("requested: buffer len %" PRId32
" period len %" PRId32
"\n",
408 apdo
->buffer_length
, apdo
->period_length
);
409 dolog("obtained: samples %ld\n", obt
->samples
);
412 static void alsa_set_threshold (snd_pcm_t
*handle
, snd_pcm_uframes_t threshold
)
415 snd_pcm_sw_params_t
*sw_params
;
417 snd_pcm_sw_params_alloca (&sw_params
);
419 err
= snd_pcm_sw_params_current (handle
, sw_params
);
421 dolog ("Could not fully initialize DAC\n");
422 alsa_logerr (err
, "Failed to get current software parameters\n");
426 err
= snd_pcm_sw_params_set_start_threshold (handle
, sw_params
, threshold
);
428 dolog ("Could not fully initialize DAC\n");
429 alsa_logerr (err
, "Failed to set software threshold to %ld\n",
434 err
= snd_pcm_sw_params (handle
, sw_params
);
436 dolog ("Could not fully initialize DAC\n");
437 alsa_logerr (err
, "Failed to set software parameters\n");
442 static int alsa_open(bool in
, struct alsa_params_req
*req
,
443 struct alsa_params_obt
*obt
, snd_pcm_t
**handlep
,
446 AudiodevAlsaOptions
*aopts
= &dev
->u
.alsa
;
447 AudiodevAlsaPerDirectionOptions
*apdo
= in
? aopts
->in
: aopts
->out
;
449 snd_pcm_hw_params_t
*hw_params
;
451 unsigned int freq
, nchannels
;
452 const char *pcm_name
= apdo
->has_dev
? apdo
->dev
: "default";
453 snd_pcm_uframes_t obt_buffer_size
;
454 const char *typ
= in
? "ADC" : "DAC";
455 snd_pcm_format_t obtfmt
;
458 nchannels
= req
->nchannels
;
460 snd_pcm_hw_params_alloca (&hw_params
);
465 in
? SND_PCM_STREAM_CAPTURE
: SND_PCM_STREAM_PLAYBACK
,
469 alsa_logerr2 (err
, typ
, "Failed to open `%s':\n", pcm_name
);
473 err
= snd_pcm_hw_params_any (handle
, hw_params
);
475 alsa_logerr2 (err
, typ
, "Failed to initialize hardware parameters\n");
479 err
= snd_pcm_hw_params_set_access (
482 SND_PCM_ACCESS_RW_INTERLEAVED
485 alsa_logerr2 (err
, typ
, "Failed to set access type\n");
489 err
= snd_pcm_hw_params_set_format (handle
, hw_params
, req
->fmt
);
491 alsa_logerr2 (err
, typ
, "Failed to set format %d\n", req
->fmt
);
494 err
= snd_pcm_hw_params_set_rate_near (handle
, hw_params
, &freq
, 0);
496 alsa_logerr2 (err
, typ
, "Failed to set frequency %d\n", req
->freq
);
500 err
= snd_pcm_hw_params_set_channels_near (
506 alsa_logerr2 (err
, typ
, "Failed to set number of channels %d\n",
511 if (apdo
->buffer_length
) {
513 unsigned int btime
= apdo
->buffer_length
;
515 err
= snd_pcm_hw_params_set_buffer_time_near(
516 handle
, hw_params
, &btime
, &dir
);
519 alsa_logerr2(err
, typ
, "Failed to set buffer time to %" PRId32
"\n",
520 apdo
->buffer_length
);
524 if (apdo
->has_buffer_length
&& btime
!= apdo
->buffer_length
) {
525 dolog("Requested buffer time %" PRId32
526 " was rejected, using %u\n", apdo
->buffer_length
, btime
);
530 if (apdo
->period_length
) {
532 unsigned int ptime
= apdo
->period_length
;
534 err
= snd_pcm_hw_params_set_period_time_near(handle
, hw_params
, &ptime
,
538 alsa_logerr2(err
, typ
, "Failed to set period time to %" PRId32
"\n",
539 apdo
->period_length
);
543 if (apdo
->has_period_length
&& ptime
!= apdo
->period_length
) {
544 dolog("Requested period time %" PRId32
" was rejected, using %d\n",
545 apdo
->period_length
, ptime
);
549 err
= snd_pcm_hw_params (handle
, hw_params
);
551 alsa_logerr2 (err
, typ
, "Failed to apply audio parameters\n");
555 err
= snd_pcm_hw_params_get_buffer_size (hw_params
, &obt_buffer_size
);
557 alsa_logerr2 (err
, typ
, "Failed to get buffer size\n");
561 err
= snd_pcm_hw_params_get_format (hw_params
, &obtfmt
);
563 alsa_logerr2 (err
, typ
, "Failed to get format\n");
567 if (alsa_to_audfmt (obtfmt
, &obt
->fmt
, &obt
->endianness
)) {
568 dolog ("Invalid format was returned %d\n", obtfmt
);
572 err
= snd_pcm_prepare (handle
);
574 alsa_logerr2 (err
, typ
, "Could not prepare handle %p\n", handle
);
578 if (!in
&& aopts
->has_threshold
&& aopts
->threshold
) {
579 struct audsettings as
= { .freq
= freq
};
582 audio_buffer_frames(qapi_AudiodevAlsaPerDirectionOptions_base(apdo
),
583 &as
, aopts
->threshold
));
586 obt
->nchannels
= nchannels
;
588 obt
->samples
= obt_buffer_size
;
592 if (DEBUG_ALSA
|| obtfmt
!= req
->fmt
||
593 obt
->nchannels
!= req
->nchannels
|| obt
->freq
!= req
->freq
) {
594 dolog ("Audio parameters for %s\n", typ
);
595 alsa_dump_info(req
, obt
, obtfmt
, apdo
);
601 alsa_anal_close1 (&handle
);
605 static size_t alsa_write(HWVoiceOut
*hw
, void *buf
, size_t len
)
607 ALSAVoiceOut
*alsa
= (ALSAVoiceOut
*) hw
;
609 size_t len_frames
= len
/ hw
->info
.bytes_per_frame
;
612 char *src
= advance(buf
, pos
);
613 snd_pcm_sframes_t written
;
615 written
= snd_pcm_writei(alsa
->handle
, src
, len_frames
);
620 trace_alsa_wrote_zero(len_frames
);
624 if (alsa_recover(alsa
->handle
)) {
625 alsa_logerr(written
, "Failed to write %zu frames\n",
629 trace_alsa_xrun_out();
634 * stream is suspended and waiting for an application
637 if (alsa_resume(alsa
->handle
)) {
638 alsa_logerr(written
, "Failed to write %zu frames\n",
642 trace_alsa_resume_out();
649 alsa_logerr(written
, "Failed to write %zu frames from %p\n",
655 pos
+= written
* hw
->info
.bytes_per_frame
;
656 if (written
< len_frames
) {
659 len_frames
-= written
;
665 static void alsa_fini_out (HWVoiceOut
*hw
)
667 ALSAVoiceOut
*alsa
= (ALSAVoiceOut
*) hw
;
669 ldebug ("alsa_fini\n");
670 alsa_anal_close (&alsa
->handle
, &alsa
->pollhlp
);
673 static int alsa_init_out(HWVoiceOut
*hw
, struct audsettings
*as
,
676 ALSAVoiceOut
*alsa
= (ALSAVoiceOut
*) hw
;
677 struct alsa_params_req req
;
678 struct alsa_params_obt obt
;
680 struct audsettings obt_as
;
681 Audiodev
*dev
= drv_opaque
;
683 req
.fmt
= aud_to_alsafmt (as
->fmt
, as
->endianness
);
685 req
.nchannels
= as
->nchannels
;
687 if (alsa_open(0, &req
, &obt
, &handle
, dev
)) {
691 obt_as
.freq
= obt
.freq
;
692 obt_as
.nchannels
= obt
.nchannels
;
693 obt_as
.fmt
= obt
.fmt
;
694 obt_as
.endianness
= obt
.endianness
;
696 audio_pcm_init_info (&hw
->info
, &obt_as
);
697 hw
->samples
= obt
.samples
;
699 alsa
->pollhlp
.s
= hw
->s
;
700 alsa
->handle
= handle
;
705 #define VOICE_CTL_PAUSE 0
706 #define VOICE_CTL_PREPARE 1
707 #define VOICE_CTL_START 2
709 static int alsa_voice_ctl (snd_pcm_t
*handle
, const char *typ
, int ctl
)
713 if (ctl
== VOICE_CTL_PAUSE
) {
714 err
= snd_pcm_drop (handle
);
716 alsa_logerr (err
, "Could not stop %s\n", typ
);
720 err
= snd_pcm_prepare (handle
);
722 alsa_logerr (err
, "Could not prepare handle for %s\n", typ
);
725 if (ctl
== VOICE_CTL_START
) {
726 err
= snd_pcm_start(handle
);
728 alsa_logerr (err
, "Could not start handle for %s\n", typ
);
737 static void alsa_enable_out(HWVoiceOut
*hw
, bool enable
)
739 ALSAVoiceOut
*alsa
= (ALSAVoiceOut
*) hw
;
740 AudiodevAlsaPerDirectionOptions
*apdo
= alsa
->dev
->u
.alsa
.out
;
743 bool poll_mode
= apdo
->try_poll
;
745 ldebug("enabling voice\n");
746 if (poll_mode
&& alsa_poll_out(hw
)) {
749 hw
->poll_mode
= poll_mode
;
750 alsa_voice_ctl(alsa
->handle
, "playback", VOICE_CTL_PREPARE
);
752 ldebug("disabling voice\n");
755 alsa_fini_poll(&alsa
->pollhlp
);
757 alsa_voice_ctl(alsa
->handle
, "playback", VOICE_CTL_PAUSE
);
761 static int alsa_init_in(HWVoiceIn
*hw
, struct audsettings
*as
, void *drv_opaque
)
763 ALSAVoiceIn
*alsa
= (ALSAVoiceIn
*) hw
;
764 struct alsa_params_req req
;
765 struct alsa_params_obt obt
;
767 struct audsettings obt_as
;
768 Audiodev
*dev
= drv_opaque
;
770 req
.fmt
= aud_to_alsafmt (as
->fmt
, as
->endianness
);
772 req
.nchannels
= as
->nchannels
;
774 if (alsa_open(1, &req
, &obt
, &handle
, dev
)) {
778 obt_as
.freq
= obt
.freq
;
779 obt_as
.nchannels
= obt
.nchannels
;
780 obt_as
.fmt
= obt
.fmt
;
781 obt_as
.endianness
= obt
.endianness
;
783 audio_pcm_init_info (&hw
->info
, &obt_as
);
784 hw
->samples
= obt
.samples
;
786 alsa
->pollhlp
.s
= hw
->s
;
787 alsa
->handle
= handle
;
792 static void alsa_fini_in (HWVoiceIn
*hw
)
794 ALSAVoiceIn
*alsa
= (ALSAVoiceIn
*) hw
;
796 alsa_anal_close (&alsa
->handle
, &alsa
->pollhlp
);
799 static size_t alsa_read(HWVoiceIn
*hw
, void *buf
, size_t len
)
801 ALSAVoiceIn
*alsa
= (ALSAVoiceIn
*) hw
;
805 void *dst
= advance(buf
, pos
);
806 snd_pcm_sframes_t nread
;
808 nread
= snd_pcm_readi(
809 alsa
->handle
, dst
, len
/ hw
->info
.bytes_per_frame
);
814 trace_alsa_read_zero(len
);
818 if (alsa_recover(alsa
->handle
)) {
819 alsa_logerr(nread
, "Failed to read %zu frames\n", len
);
822 trace_alsa_xrun_in();
829 alsa_logerr(nread
, "Failed to read %zu frames to %p\n",
835 pos
+= nread
* hw
->info
.bytes_per_frame
;
836 len
-= nread
* hw
->info
.bytes_per_frame
;
842 static void alsa_enable_in(HWVoiceIn
*hw
, bool enable
)
844 ALSAVoiceIn
*alsa
= (ALSAVoiceIn
*) hw
;
845 AudiodevAlsaPerDirectionOptions
*apdo
= alsa
->dev
->u
.alsa
.in
;
848 bool poll_mode
= apdo
->try_poll
;
850 ldebug("enabling voice\n");
851 if (poll_mode
&& alsa_poll_in(hw
)) {
854 hw
->poll_mode
= poll_mode
;
856 alsa_voice_ctl(alsa
->handle
, "capture", VOICE_CTL_START
);
858 ldebug ("disabling voice\n");
861 alsa_fini_poll(&alsa
->pollhlp
);
863 alsa_voice_ctl(alsa
->handle
, "capture", VOICE_CTL_PAUSE
);
867 static void alsa_init_per_direction(AudiodevAlsaPerDirectionOptions
*apdo
)
869 if (!apdo
->has_try_poll
) {
870 apdo
->try_poll
= true;
871 apdo
->has_try_poll
= true;
875 static void *alsa_audio_init(Audiodev
*dev
)
877 AudiodevAlsaOptions
*aopts
;
878 assert(dev
->driver
== AUDIODEV_DRIVER_ALSA
);
880 aopts
= &dev
->u
.alsa
;
881 alsa_init_per_direction(aopts
->in
);
882 alsa_init_per_direction(aopts
->out
);
885 * need to define them, as otherwise alsa produces no sound
886 * doesn't set has_* so alsa_open can identify it wasn't set by the user
888 if (!dev
->u
.alsa
.out
->has_period_length
) {
889 /* 1024 frames assuming 44100Hz */
890 dev
->u
.alsa
.out
->period_length
= 1024 * 1000000 / 44100;
892 if (!dev
->u
.alsa
.out
->has_buffer_length
) {
893 /* 4096 frames assuming 44100Hz */
894 dev
->u
.alsa
.out
->buffer_length
= 4096ll * 1000000 / 44100;
898 * OptsVisitor sets unspecified optional fields to zero, but do not depend
901 if (!dev
->u
.alsa
.in
->has_period_length
) {
902 dev
->u
.alsa
.in
->period_length
= 0;
904 if (!dev
->u
.alsa
.in
->has_buffer_length
) {
905 dev
->u
.alsa
.in
->buffer_length
= 0;
911 static void alsa_audio_fini (void *opaque
)
915 static struct audio_pcm_ops alsa_pcm_ops
= {
916 .init_out
= alsa_init_out
,
917 .fini_out
= alsa_fini_out
,
919 .run_buffer_out
= audio_generic_run_buffer_out
,
920 .enable_out
= alsa_enable_out
,
922 .init_in
= alsa_init_in
,
923 .fini_in
= alsa_fini_in
,
925 .run_buffer_in
= audio_generic_run_buffer_in
,
926 .enable_in
= alsa_enable_in
,
929 static struct audio_driver alsa_audio_driver
= {
931 .descr
= "ALSA http://www.alsa-project.org",
932 .init
= alsa_audio_init
,
933 .fini
= alsa_audio_fini
,
934 .pcm_ops
= &alsa_pcm_ops
,
936 .max_voices_out
= INT_MAX
,
937 .max_voices_in
= INT_MAX
,
938 .voice_size_out
= sizeof (ALSAVoiceOut
),
939 .voice_size_in
= sizeof (ALSAVoiceIn
)
942 static void register_audio_alsa(void)
944 audio_driver_register(&alsa_audio_driver
);
946 type_init(register_audio_alsa
);