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"
45 typedef struct ALSAVoiceOut
{
48 struct pollhlp pollhlp
;
52 typedef struct ALSAVoiceIn
{
55 struct pollhlp pollhlp
;
59 struct alsa_params_req
{
65 struct alsa_params_obt
{
70 snd_pcm_uframes_t samples
;
73 static void GCC_FMT_ATTR (2, 3) alsa_logerr (int err
, const char *fmt
, ...)
78 AUD_vlog (AUDIO_CAP
, fmt
, ap
);
81 AUD_log (AUDIO_CAP
, "Reason: %s\n", snd_strerror (err
));
84 static void GCC_FMT_ATTR (3, 4) alsa_logerr2 (
93 AUD_log (AUDIO_CAP
, "Could not initialize %s\n", typ
);
96 AUD_vlog (AUDIO_CAP
, fmt
, ap
);
99 AUD_log (AUDIO_CAP
, "Reason: %s\n", snd_strerror (err
));
102 static void alsa_fini_poll (struct pollhlp
*hlp
)
105 struct pollfd
*pfds
= hlp
->pfds
;
108 for (i
= 0; i
< hlp
->count
; ++i
) {
109 qemu_set_fd_handler (pfds
[i
].fd
, NULL
, NULL
, NULL
);
118 static void alsa_anal_close1 (snd_pcm_t
**handlep
)
120 int err
= snd_pcm_close (*handlep
);
122 alsa_logerr (err
, "Failed to close PCM handle %p\n", *handlep
);
127 static void alsa_anal_close (snd_pcm_t
**handlep
, struct pollhlp
*hlp
)
129 alsa_fini_poll (hlp
);
130 alsa_anal_close1 (handlep
);
133 static int alsa_recover (snd_pcm_t
*handle
)
135 int err
= snd_pcm_prepare (handle
);
137 alsa_logerr (err
, "Failed to prepare handle %p\n", handle
);
143 static int alsa_resume (snd_pcm_t
*handle
)
145 int err
= snd_pcm_resume (handle
);
147 alsa_logerr (err
, "Failed to resume handle %p\n", handle
);
153 static void alsa_poll_handler (void *opaque
)
156 snd_pcm_state_t state
;
157 struct pollhlp
*hlp
= opaque
;
158 unsigned short revents
;
160 count
= poll (hlp
->pfds
, hlp
->count
, 0);
162 dolog ("alsa_poll_handler: poll %s\n", strerror (errno
));
170 /* XXX: ALSA example uses initial count, not the one returned by
172 err
= snd_pcm_poll_descriptors_revents (hlp
->handle
, hlp
->pfds
,
173 hlp
->count
, &revents
);
175 alsa_logerr (err
, "snd_pcm_poll_descriptors_revents");
179 if (!(revents
& hlp
->mask
)) {
180 trace_alsa_revents(revents
);
184 state
= snd_pcm_state (hlp
->handle
);
186 case SND_PCM_STATE_SETUP
:
187 alsa_recover (hlp
->handle
);
190 case SND_PCM_STATE_XRUN
:
191 alsa_recover (hlp
->handle
);
194 case SND_PCM_STATE_SUSPENDED
:
195 alsa_resume (hlp
->handle
);
198 case SND_PCM_STATE_PREPARED
:
199 audio_run(hlp
->s
, "alsa run (prepared)");
202 case SND_PCM_STATE_RUNNING
:
203 audio_run(hlp
->s
, "alsa run (running)");
207 dolog ("Unexpected state %d\n", state
);
211 static int alsa_poll_helper (snd_pcm_t
*handle
, struct pollhlp
*hlp
, int mask
)
216 count
= snd_pcm_poll_descriptors_count (handle
);
218 dolog ("Could not initialize poll mode\n"
219 "Invalid number of poll descriptors %d\n", count
);
223 pfds
= audio_calloc ("alsa_poll_helper", count
, sizeof (*pfds
));
225 dolog ("Could not initialize poll mode\n");
229 err
= snd_pcm_poll_descriptors (handle
, pfds
, count
);
231 alsa_logerr (err
, "Could not initialize poll mode\n"
232 "Could not obtain poll descriptors\n");
237 for (i
= 0; i
< count
; ++i
) {
238 if (pfds
[i
].events
& POLLIN
) {
239 qemu_set_fd_handler (pfds
[i
].fd
, alsa_poll_handler
, NULL
, hlp
);
241 if (pfds
[i
].events
& POLLOUT
) {
242 trace_alsa_pollout(i
, pfds
[i
].fd
);
243 qemu_set_fd_handler (pfds
[i
].fd
, NULL
, alsa_poll_handler
, hlp
);
245 trace_alsa_set_handler(pfds
[i
].events
, i
, pfds
[i
].fd
, err
);
250 hlp
->handle
= handle
;
255 static int alsa_poll_out (HWVoiceOut
*hw
)
257 ALSAVoiceOut
*alsa
= (ALSAVoiceOut
*) hw
;
259 return alsa_poll_helper (alsa
->handle
, &alsa
->pollhlp
, POLLOUT
);
262 static int alsa_poll_in (HWVoiceIn
*hw
)
264 ALSAVoiceIn
*alsa
= (ALSAVoiceIn
*) hw
;
266 return alsa_poll_helper (alsa
->handle
, &alsa
->pollhlp
, POLLIN
);
269 static snd_pcm_format_t
aud_to_alsafmt (AudioFormat fmt
, int endianness
)
272 case AUDIO_FORMAT_S8
:
273 return SND_PCM_FORMAT_S8
;
275 case AUDIO_FORMAT_U8
:
276 return SND_PCM_FORMAT_U8
;
278 case AUDIO_FORMAT_S16
:
280 return SND_PCM_FORMAT_S16_BE
;
282 return SND_PCM_FORMAT_S16_LE
;
285 case AUDIO_FORMAT_U16
:
287 return SND_PCM_FORMAT_U16_BE
;
289 return SND_PCM_FORMAT_U16_LE
;
292 case AUDIO_FORMAT_S32
:
294 return SND_PCM_FORMAT_S32_BE
;
296 return SND_PCM_FORMAT_S32_LE
;
299 case AUDIO_FORMAT_U32
:
301 return SND_PCM_FORMAT_U32_BE
;
303 return SND_PCM_FORMAT_U32_LE
;
306 case AUDIO_FORMAT_F32
:
308 return SND_PCM_FORMAT_FLOAT_BE
;
310 return SND_PCM_FORMAT_FLOAT_LE
;
314 dolog ("Internal logic error: Bad audio format %d\n", fmt
);
318 return SND_PCM_FORMAT_U8
;
322 static int alsa_to_audfmt (snd_pcm_format_t alsafmt
, AudioFormat
*fmt
,
326 case SND_PCM_FORMAT_S8
:
328 *fmt
= AUDIO_FORMAT_S8
;
331 case SND_PCM_FORMAT_U8
:
333 *fmt
= AUDIO_FORMAT_U8
;
336 case SND_PCM_FORMAT_S16_LE
:
338 *fmt
= AUDIO_FORMAT_S16
;
341 case SND_PCM_FORMAT_U16_LE
:
343 *fmt
= AUDIO_FORMAT_U16
;
346 case SND_PCM_FORMAT_S16_BE
:
348 *fmt
= AUDIO_FORMAT_S16
;
351 case SND_PCM_FORMAT_U16_BE
:
353 *fmt
= AUDIO_FORMAT_U16
;
356 case SND_PCM_FORMAT_S32_LE
:
358 *fmt
= AUDIO_FORMAT_S32
;
361 case SND_PCM_FORMAT_U32_LE
:
363 *fmt
= AUDIO_FORMAT_U32
;
366 case SND_PCM_FORMAT_S32_BE
:
368 *fmt
= AUDIO_FORMAT_S32
;
371 case SND_PCM_FORMAT_U32_BE
:
373 *fmt
= AUDIO_FORMAT_U32
;
376 case SND_PCM_FORMAT_FLOAT_LE
:
378 *fmt
= AUDIO_FORMAT_F32
;
381 case SND_PCM_FORMAT_FLOAT_BE
:
383 *fmt
= AUDIO_FORMAT_F32
;
387 dolog ("Unrecognized audio format %d\n", alsafmt
);
394 static void alsa_dump_info (struct alsa_params_req
*req
,
395 struct alsa_params_obt
*obt
,
396 snd_pcm_format_t obtfmt
,
397 AudiodevAlsaPerDirectionOptions
*apdo
)
399 dolog("parameter | requested value | obtained value\n");
400 dolog("format | %10d | %10d\n", req
->fmt
, obtfmt
);
401 dolog("channels | %10d | %10d\n",
402 req
->nchannels
, obt
->nchannels
);
403 dolog("frequency | %10d | %10d\n", req
->freq
, obt
->freq
);
404 dolog("============================================\n");
405 dolog("requested: buffer len %" PRId32
" period len %" PRId32
"\n",
406 apdo
->buffer_length
, apdo
->period_length
);
407 dolog("obtained: samples %ld\n", obt
->samples
);
410 static void alsa_set_threshold (snd_pcm_t
*handle
, snd_pcm_uframes_t threshold
)
413 snd_pcm_sw_params_t
*sw_params
;
415 snd_pcm_sw_params_alloca (&sw_params
);
417 err
= snd_pcm_sw_params_current (handle
, sw_params
);
419 dolog ("Could not fully initialize DAC\n");
420 alsa_logerr (err
, "Failed to get current software parameters\n");
424 err
= snd_pcm_sw_params_set_start_threshold (handle
, sw_params
, threshold
);
426 dolog ("Could not fully initialize DAC\n");
427 alsa_logerr (err
, "Failed to set software threshold to %ld\n",
432 err
= snd_pcm_sw_params (handle
, sw_params
);
434 dolog ("Could not fully initialize DAC\n");
435 alsa_logerr (err
, "Failed to set software parameters\n");
440 static int alsa_open(bool in
, struct alsa_params_req
*req
,
441 struct alsa_params_obt
*obt
, snd_pcm_t
**handlep
,
444 AudiodevAlsaOptions
*aopts
= &dev
->u
.alsa
;
445 AudiodevAlsaPerDirectionOptions
*apdo
= in
? aopts
->in
: aopts
->out
;
447 snd_pcm_hw_params_t
*hw_params
;
449 unsigned int freq
, nchannels
;
450 const char *pcm_name
= apdo
->has_dev
? apdo
->dev
: "default";
451 snd_pcm_uframes_t obt_buffer_size
;
452 const char *typ
= in
? "ADC" : "DAC";
453 snd_pcm_format_t obtfmt
;
456 nchannels
= req
->nchannels
;
458 snd_pcm_hw_params_alloca (&hw_params
);
463 in
? SND_PCM_STREAM_CAPTURE
: SND_PCM_STREAM_PLAYBACK
,
467 alsa_logerr2 (err
, typ
, "Failed to open `%s':\n", pcm_name
);
471 err
= snd_pcm_hw_params_any (handle
, hw_params
);
473 alsa_logerr2 (err
, typ
, "Failed to initialize hardware parameters\n");
477 err
= snd_pcm_hw_params_set_access (
480 SND_PCM_ACCESS_RW_INTERLEAVED
483 alsa_logerr2 (err
, typ
, "Failed to set access type\n");
487 err
= snd_pcm_hw_params_set_format (handle
, hw_params
, req
->fmt
);
489 alsa_logerr2 (err
, typ
, "Failed to set format %d\n", req
->fmt
);
492 err
= snd_pcm_hw_params_set_rate_near (handle
, hw_params
, &freq
, 0);
494 alsa_logerr2 (err
, typ
, "Failed to set frequency %d\n", req
->freq
);
498 err
= snd_pcm_hw_params_set_channels_near (
504 alsa_logerr2 (err
, typ
, "Failed to set number of channels %d\n",
509 if (apdo
->buffer_length
) {
511 unsigned int btime
= apdo
->buffer_length
;
513 err
= snd_pcm_hw_params_set_buffer_time_near(
514 handle
, hw_params
, &btime
, &dir
);
517 alsa_logerr2(err
, typ
, "Failed to set buffer time to %" PRId32
"\n",
518 apdo
->buffer_length
);
522 if (apdo
->has_buffer_length
&& btime
!= apdo
->buffer_length
) {
523 dolog("Requested buffer time %" PRId32
524 " was rejected, using %u\n", apdo
->buffer_length
, btime
);
528 if (apdo
->period_length
) {
530 unsigned int ptime
= apdo
->period_length
;
532 err
= snd_pcm_hw_params_set_period_time_near(handle
, hw_params
, &ptime
,
536 alsa_logerr2(err
, typ
, "Failed to set period time to %" PRId32
"\n",
537 apdo
->period_length
);
541 if (apdo
->has_period_length
&& ptime
!= apdo
->period_length
) {
542 dolog("Requested period time %" PRId32
" was rejected, using %d\n",
543 apdo
->period_length
, ptime
);
547 err
= snd_pcm_hw_params (handle
, hw_params
);
549 alsa_logerr2 (err
, typ
, "Failed to apply audio parameters\n");
553 err
= snd_pcm_hw_params_get_buffer_size (hw_params
, &obt_buffer_size
);
555 alsa_logerr2 (err
, typ
, "Failed to get buffer size\n");
559 err
= snd_pcm_hw_params_get_format (hw_params
, &obtfmt
);
561 alsa_logerr2 (err
, typ
, "Failed to get format\n");
565 if (alsa_to_audfmt (obtfmt
, &obt
->fmt
, &obt
->endianness
)) {
566 dolog ("Invalid format was returned %d\n", obtfmt
);
570 err
= snd_pcm_prepare (handle
);
572 alsa_logerr2 (err
, typ
, "Could not prepare handle %p\n", handle
);
576 if (!in
&& aopts
->has_threshold
&& aopts
->threshold
) {
577 struct audsettings as
= { .freq
= freq
};
580 audio_buffer_frames(qapi_AudiodevAlsaPerDirectionOptions_base(apdo
),
581 &as
, aopts
->threshold
));
584 obt
->nchannels
= nchannels
;
586 obt
->samples
= obt_buffer_size
;
590 if (obtfmt
!= req
->fmt
||
591 obt
->nchannels
!= req
->nchannels
||
592 obt
->freq
!= req
->freq
) {
593 dolog ("Audio parameters for %s\n", typ
);
594 alsa_dump_info(req
, obt
, obtfmt
, apdo
);
598 alsa_dump_info(req
, obt
, obtfmt
, apdo
);
603 alsa_anal_close1 (&handle
);
607 static size_t alsa_write(HWVoiceOut
*hw
, void *buf
, size_t len
)
609 ALSAVoiceOut
*alsa
= (ALSAVoiceOut
*) hw
;
611 size_t len_frames
= len
/ hw
->info
.bytes_per_frame
;
614 char *src
= advance(buf
, pos
);
615 snd_pcm_sframes_t written
;
617 written
= snd_pcm_writei(alsa
->handle
, src
, len_frames
);
622 trace_alsa_wrote_zero(len_frames
);
626 if (alsa_recover(alsa
->handle
)) {
627 alsa_logerr(written
, "Failed to write %zu frames\n",
631 trace_alsa_xrun_out();
636 * stream is suspended and waiting for an application
639 if (alsa_resume(alsa
->handle
)) {
640 alsa_logerr(written
, "Failed to write %zu frames\n",
644 trace_alsa_resume_out();
651 alsa_logerr(written
, "Failed to write %zu frames from %p\n",
657 pos
+= written
* hw
->info
.bytes_per_frame
;
658 if (written
< len_frames
) {
661 len_frames
-= written
;
667 static void alsa_fini_out (HWVoiceOut
*hw
)
669 ALSAVoiceOut
*alsa
= (ALSAVoiceOut
*) hw
;
671 ldebug ("alsa_fini\n");
672 alsa_anal_close (&alsa
->handle
, &alsa
->pollhlp
);
675 static int alsa_init_out(HWVoiceOut
*hw
, struct audsettings
*as
,
678 ALSAVoiceOut
*alsa
= (ALSAVoiceOut
*) hw
;
679 struct alsa_params_req req
;
680 struct alsa_params_obt obt
;
682 struct audsettings obt_as
;
683 Audiodev
*dev
= drv_opaque
;
685 req
.fmt
= aud_to_alsafmt (as
->fmt
, as
->endianness
);
687 req
.nchannels
= as
->nchannels
;
689 if (alsa_open(0, &req
, &obt
, &handle
, dev
)) {
693 obt_as
.freq
= obt
.freq
;
694 obt_as
.nchannels
= obt
.nchannels
;
695 obt_as
.fmt
= obt
.fmt
;
696 obt_as
.endianness
= obt
.endianness
;
698 audio_pcm_init_info (&hw
->info
, &obt_as
);
699 hw
->samples
= obt
.samples
;
701 alsa
->pollhlp
.s
= hw
->s
;
702 alsa
->handle
= handle
;
707 #define VOICE_CTL_PAUSE 0
708 #define VOICE_CTL_PREPARE 1
709 #define VOICE_CTL_START 2
711 static int alsa_voice_ctl (snd_pcm_t
*handle
, const char *typ
, int ctl
)
715 if (ctl
== VOICE_CTL_PAUSE
) {
716 err
= snd_pcm_drop (handle
);
718 alsa_logerr (err
, "Could not stop %s\n", typ
);
722 err
= snd_pcm_prepare (handle
);
724 alsa_logerr (err
, "Could not prepare handle for %s\n", typ
);
727 if (ctl
== VOICE_CTL_START
) {
728 err
= snd_pcm_start(handle
);
730 alsa_logerr (err
, "Could not start handle for %s\n", typ
);
739 static void alsa_enable_out(HWVoiceOut
*hw
, bool enable
)
741 ALSAVoiceOut
*alsa
= (ALSAVoiceOut
*) hw
;
742 AudiodevAlsaPerDirectionOptions
*apdo
= alsa
->dev
->u
.alsa
.out
;
745 bool poll_mode
= apdo
->try_poll
;
747 ldebug("enabling voice\n");
748 if (poll_mode
&& alsa_poll_out(hw
)) {
751 hw
->poll_mode
= poll_mode
;
752 alsa_voice_ctl(alsa
->handle
, "playback", VOICE_CTL_PREPARE
);
754 ldebug("disabling voice\n");
757 alsa_fini_poll(&alsa
->pollhlp
);
759 alsa_voice_ctl(alsa
->handle
, "playback", VOICE_CTL_PAUSE
);
763 static int alsa_init_in(HWVoiceIn
*hw
, struct audsettings
*as
, void *drv_opaque
)
765 ALSAVoiceIn
*alsa
= (ALSAVoiceIn
*) hw
;
766 struct alsa_params_req req
;
767 struct alsa_params_obt obt
;
769 struct audsettings obt_as
;
770 Audiodev
*dev
= drv_opaque
;
772 req
.fmt
= aud_to_alsafmt (as
->fmt
, as
->endianness
);
774 req
.nchannels
= as
->nchannels
;
776 if (alsa_open(1, &req
, &obt
, &handle
, dev
)) {
780 obt_as
.freq
= obt
.freq
;
781 obt_as
.nchannels
= obt
.nchannels
;
782 obt_as
.fmt
= obt
.fmt
;
783 obt_as
.endianness
= obt
.endianness
;
785 audio_pcm_init_info (&hw
->info
, &obt_as
);
786 hw
->samples
= obt
.samples
;
788 alsa
->pollhlp
.s
= hw
->s
;
789 alsa
->handle
= handle
;
794 static void alsa_fini_in (HWVoiceIn
*hw
)
796 ALSAVoiceIn
*alsa
= (ALSAVoiceIn
*) hw
;
798 alsa_anal_close (&alsa
->handle
, &alsa
->pollhlp
);
801 static size_t alsa_read(HWVoiceIn
*hw
, void *buf
, size_t len
)
803 ALSAVoiceIn
*alsa
= (ALSAVoiceIn
*) hw
;
807 void *dst
= advance(buf
, pos
);
808 snd_pcm_sframes_t nread
;
810 nread
= snd_pcm_readi(
811 alsa
->handle
, dst
, len
/ hw
->info
.bytes_per_frame
);
816 trace_alsa_read_zero(len
);
820 if (alsa_recover(alsa
->handle
)) {
821 alsa_logerr(nread
, "Failed to read %zu frames\n", len
);
824 trace_alsa_xrun_in();
831 alsa_logerr(nread
, "Failed to read %zu frames to %p\n",
837 pos
+= nread
* hw
->info
.bytes_per_frame
;
838 len
-= nread
* hw
->info
.bytes_per_frame
;
844 static void alsa_enable_in(HWVoiceIn
*hw
, bool enable
)
846 ALSAVoiceIn
*alsa
= (ALSAVoiceIn
*) hw
;
847 AudiodevAlsaPerDirectionOptions
*apdo
= alsa
->dev
->u
.alsa
.in
;
850 bool poll_mode
= apdo
->try_poll
;
852 ldebug("enabling voice\n");
853 if (poll_mode
&& alsa_poll_in(hw
)) {
856 hw
->poll_mode
= poll_mode
;
858 alsa_voice_ctl(alsa
->handle
, "capture", VOICE_CTL_START
);
860 ldebug ("disabling voice\n");
863 alsa_fini_poll(&alsa
->pollhlp
);
865 alsa_voice_ctl(alsa
->handle
, "capture", VOICE_CTL_PAUSE
);
869 static void alsa_init_per_direction(AudiodevAlsaPerDirectionOptions
*apdo
)
871 if (!apdo
->has_try_poll
) {
872 apdo
->try_poll
= true;
873 apdo
->has_try_poll
= true;
877 static void *alsa_audio_init(Audiodev
*dev
)
879 AudiodevAlsaOptions
*aopts
;
880 assert(dev
->driver
== AUDIODEV_DRIVER_ALSA
);
882 aopts
= &dev
->u
.alsa
;
883 alsa_init_per_direction(aopts
->in
);
884 alsa_init_per_direction(aopts
->out
);
887 * need to define them, as otherwise alsa produces no sound
888 * doesn't set has_* so alsa_open can identify it wasn't set by the user
890 if (!dev
->u
.alsa
.out
->has_period_length
) {
891 /* 1024 frames assuming 44100Hz */
892 dev
->u
.alsa
.out
->period_length
= 1024 * 1000000 / 44100;
894 if (!dev
->u
.alsa
.out
->has_buffer_length
) {
895 /* 4096 frames assuming 44100Hz */
896 dev
->u
.alsa
.out
->buffer_length
= 4096ll * 1000000 / 44100;
900 * OptsVisitor sets unspecified optional fields to zero, but do not depend
903 if (!dev
->u
.alsa
.in
->has_period_length
) {
904 dev
->u
.alsa
.in
->period_length
= 0;
906 if (!dev
->u
.alsa
.in
->has_buffer_length
) {
907 dev
->u
.alsa
.in
->buffer_length
= 0;
913 static void alsa_audio_fini (void *opaque
)
917 static struct audio_pcm_ops alsa_pcm_ops
= {
918 .init_out
= alsa_init_out
,
919 .fini_out
= alsa_fini_out
,
921 .run_buffer_out
= audio_generic_run_buffer_out
,
922 .enable_out
= alsa_enable_out
,
924 .init_in
= alsa_init_in
,
925 .fini_in
= alsa_fini_in
,
927 .run_buffer_in
= audio_generic_run_buffer_in
,
928 .enable_in
= alsa_enable_in
,
931 static struct audio_driver alsa_audio_driver
= {
933 .descr
= "ALSA http://www.alsa-project.org",
934 .init
= alsa_audio_init
,
935 .fini
= alsa_audio_fini
,
936 .pcm_ops
= &alsa_pcm_ops
,
938 .max_voices_out
= INT_MAX
,
939 .max_voices_in
= INT_MAX
,
940 .voice_size_out
= sizeof (ALSAVoiceOut
),
941 .voice_size_in
= sizeof (ALSAVoiceIn
)
944 static void register_audio_alsa(void)
946 audio_driver_register(&alsa_audio_driver
);
948 type_init(register_audio_alsa
);