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
24 #include <alsa/asoundlib.h>
25 #include "qemu-common.h"
26 #include "qemu-char.h"
29 #if QEMU_GNUC_PREREQ(4, 3)
30 #pragma GCC diagnostic ignored "-Waddress"
33 #define AUDIO_CAP "alsa"
34 #include "audio_int.h"
42 typedef struct ALSAVoiceOut {
46 struct pollhlp pollhlp;
49 typedef struct ALSAVoiceIn {
53 struct pollhlp pollhlp;
59 const char *pcm_name_in;
60 const char *pcm_name_out;
61 unsigned int buffer_size_in;
62 unsigned int period_size_in;
63 unsigned int buffer_size_out;
64 unsigned int period_size_out;
65 unsigned int threshold;
67 int buffer_size_in_overridden;
68 int period_size_in_overridden;
70 int buffer_size_out_overridden;
71 int period_size_out_overridden;
74 .buffer_size_out = 1024,
75 .pcm_name_out = "default",
76 .pcm_name_in = "default",
79 struct alsa_params_req {
85 unsigned int buffer_size;
86 unsigned int period_size;
89 struct alsa_params_obt {
94 snd_pcm_uframes_t samples;
97 static void GCC_FMT_ATTR (2, 3) alsa_logerr (int err, const char *fmt, ...)
102 AUD_vlog (AUDIO_CAP, fmt, ap);
105 AUD_log (AUDIO_CAP, "Reason: %s\n", snd_strerror (err));
108 static void GCC_FMT_ATTR (3, 4) alsa_logerr2 (
117 AUD_log (AUDIO_CAP, "Could not initialize %s\n", typ);
120 AUD_vlog (AUDIO_CAP, fmt, ap);
123 AUD_log (AUDIO_CAP, "Reason: %s\n", snd_strerror (err));
126 static void alsa_anal_close (snd_pcm_t **handlep)
128 int err = snd_pcm_close (*handlep);
130 alsa_logerr (err, "Failed to close PCM handle %p\n", *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 & POLLOUT)) {
183 dolog ("revents = %d\n", revents);
188 state = snd_pcm_state (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 ("alsa run (prepared)");
202 case SND_PCM_STATE_RUNNING:
203 audio_run ("alsa run (running)");
207 dolog ("Unexpected state %d\n", state);
211 static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp)
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 err = qemu_set_fd_handler (pfds[i].fd, alsa_poll_handler,
242 if (pfds[i].events & POLLOUT) {
244 dolog ("POLLOUT %d %d\n", i, pfds[i].fd);
246 err = qemu_set_fd_handler (pfds[i].fd, NULL,
247 alsa_poll_handler, hlp);
250 dolog ("Set handler events=%#x index=%d fd=%d err=%d\n",
251 pfds[i].events, i, pfds[i].fd, err);
255 dolog ("Failed to set handler events=%#x index=%d fd=%d err=%d\n",
256 pfds[i].events, i, pfds[i].fd, err);
259 qemu_set_fd_handler (pfds[i].fd, NULL, NULL, NULL);
267 hlp->handle = handle;
271 static int alsa_poll_out (HWVoiceOut *hw)
273 ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
275 return alsa_poll_helper (alsa->handle, &alsa->pollhlp);
278 static int alsa_poll_in (HWVoiceIn *hw)
280 ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
282 return alsa_poll_helper (alsa->handle, &alsa->pollhlp);
285 static int alsa_write (SWVoiceOut *sw, void *buf, int len)
287 return audio_pcm_sw_write (sw, buf, len);
290 static snd_pcm_format_t aud_to_alsafmt (audfmt_e fmt)
294 return SND_PCM_FORMAT_S8;
297 return SND_PCM_FORMAT_U8;
300 return SND_PCM_FORMAT_S16_LE;
303 return SND_PCM_FORMAT_U16_LE;
306 return SND_PCM_FORMAT_S32_LE;
309 return SND_PCM_FORMAT_U32_LE;
312 dolog ("Internal logic error: Bad audio format %d\n", fmt);
316 return SND_PCM_FORMAT_U8;
320 static int alsa_to_audfmt (snd_pcm_format_t alsafmt, audfmt_e *fmt,
324 case SND_PCM_FORMAT_S8:
329 case SND_PCM_FORMAT_U8:
334 case SND_PCM_FORMAT_S16_LE:
339 case SND_PCM_FORMAT_U16_LE:
344 case SND_PCM_FORMAT_S16_BE:
349 case SND_PCM_FORMAT_U16_BE:
354 case SND_PCM_FORMAT_S32_LE:
359 case SND_PCM_FORMAT_U32_LE:
364 case SND_PCM_FORMAT_S32_BE:
369 case SND_PCM_FORMAT_U32_BE:
375 dolog ("Unrecognized audio format %d\n", alsafmt);
382 static void alsa_dump_info (struct alsa_params_req *req,
383 struct alsa_params_obt *obt)
385 dolog ("parameter | requested value | obtained value\n");
386 dolog ("format | %10d | %10d\n", req->fmt, obt->fmt);
387 dolog ("channels | %10d | %10d\n",
388 req->nchannels, obt->nchannels);
389 dolog ("frequency | %10d | %10d\n", req->freq, obt->freq);
390 dolog ("============================================\n");
391 dolog ("requested: buffer size %d period size %d\n",
392 req->buffer_size, req->period_size);
393 dolog ("obtained: samples %ld\n", obt->samples);
396 static void alsa_set_threshold (snd_pcm_t *handle, snd_pcm_uframes_t threshold)
399 snd_pcm_sw_params_t *sw_params;
401 snd_pcm_sw_params_alloca (&sw_params);
403 err = snd_pcm_sw_params_current (handle, sw_params);
405 dolog ("Could not fully initialize DAC\n");
406 alsa_logerr (err, "Failed to get current software parameters\n");
410 err = snd_pcm_sw_params_set_start_threshold (handle, sw_params, threshold);
412 dolog ("Could not fully initialize DAC\n");
413 alsa_logerr (err, "Failed to set software threshold to %ld\n",
418 err = snd_pcm_sw_params (handle, sw_params);
420 dolog ("Could not fully initialize DAC\n");
421 alsa_logerr (err, "Failed to set software parameters\n");
426 static int alsa_open (int in, struct alsa_params_req *req,
427 struct alsa_params_obt *obt, snd_pcm_t **handlep)
430 snd_pcm_hw_params_t *hw_params;
433 unsigned int freq, nchannels;
434 const char *pcm_name = in ? conf.pcm_name_in : conf.pcm_name_out;
435 snd_pcm_uframes_t obt_buffer_size;
436 const char *typ = in ? "ADC" : "DAC";
437 snd_pcm_format_t obtfmt;
440 nchannels = req->nchannels;
441 size_in_usec = req->size_in_usec;
443 snd_pcm_hw_params_alloca (&hw_params);
448 in ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK,
452 alsa_logerr2 (err, typ, "Failed to open `%s':\n", pcm_name);
456 err = snd_pcm_hw_params_any (handle, hw_params);
458 alsa_logerr2 (err, typ, "Failed to initialize hardware parameters\n");
462 err = snd_pcm_hw_params_set_access (
465 SND_PCM_ACCESS_RW_INTERLEAVED
468 alsa_logerr2 (err, typ, "Failed to set access type\n");
472 err = snd_pcm_hw_params_set_format (handle, hw_params, req->fmt);
473 if (err < 0 && conf.verbose) {
474 alsa_logerr2 (err, typ, "Failed to set format %d\n", req->fmt);
477 err = snd_pcm_hw_params_set_rate_near (handle, hw_params, &freq, 0);
479 alsa_logerr2 (err, typ, "Failed to set frequency %d\n", req->freq);
483 err = snd_pcm_hw_params_set_channels_near (
489 alsa_logerr2 (err, typ, "Failed to set number of channels %d\n",
494 if (nchannels != 1 && nchannels != 2) {
495 alsa_logerr2 (err, typ,
496 "Can not handle obtained number of channels %d\n",
501 if (req->buffer_size) {
506 unsigned int btime = req->buffer_size;
508 err = snd_pcm_hw_params_set_buffer_time_near (
517 snd_pcm_uframes_t bsize = req->buffer_size;
519 err = snd_pcm_hw_params_set_buffer_size_near (
527 alsa_logerr2 (err, typ, "Failed to set buffer %s to %d\n",
528 size_in_usec ? "time" : "size", req->buffer_size);
532 if ((req->override_mask & 2) && (obt - req->buffer_size))
533 dolog ("Requested buffer %s %u was rejected, using %lu\n",
534 size_in_usec ? "time" : "size", req->buffer_size, obt);
537 if (req->period_size) {
542 unsigned int ptime = req->period_size;
544 err = snd_pcm_hw_params_set_period_time_near (
554 snd_pcm_uframes_t psize = req->period_size;
556 err = snd_pcm_hw_params_set_period_size_near (
566 alsa_logerr2 (err, typ, "Failed to set period %s to %d\n",
567 size_in_usec ? "time" : "size", req->period_size);
571 if ((req->override_mask & 1) && (obt - req->period_size))
572 dolog ("Requested period %s %u was rejected, using %lu\n",
573 size_in_usec ? "time" : "size", req->period_size, obt);
576 err = snd_pcm_hw_params (handle, hw_params);
578 alsa_logerr2 (err, typ, "Failed to apply audio parameters\n");
582 err = snd_pcm_hw_params_get_buffer_size (hw_params, &obt_buffer_size);
584 alsa_logerr2 (err, typ, "Failed to get buffer size\n");
588 err = snd_pcm_hw_params_get_format (hw_params, &obtfmt);
590 alsa_logerr2 (err, typ, "Failed to get format\n");
594 if (alsa_to_audfmt (obtfmt, &obt->fmt, &obt->endianness)) {
595 dolog ("Invalid format was returned %d\n", obtfmt);
599 err = snd_pcm_prepare (handle);
601 alsa_logerr2 (err, typ, "Could not prepare handle %p\n", handle);
605 if (!in && conf.threshold) {
606 snd_pcm_uframes_t threshold;
609 bytes_per_sec = freq << (nchannels == 2);
627 threshold = (conf.threshold * bytes_per_sec) / 1000;
628 alsa_set_threshold (handle, threshold);
631 obt->nchannels = nchannels;
633 obt->samples = obt_buffer_size;
638 (obt->fmt != req->fmt ||
639 obt->nchannels != req->nchannels ||
640 obt->freq != req->freq)) {
641 dolog ("Audio paramters for %s\n", typ);
642 alsa_dump_info (req, obt);
646 alsa_dump_info (req, obt);
651 alsa_anal_close (&handle);
655 static snd_pcm_sframes_t alsa_get_avail (snd_pcm_t *handle)
657 snd_pcm_sframes_t avail;
659 avail = snd_pcm_avail_update (handle);
661 if (avail == -EPIPE) {
662 if (!alsa_recover (handle)) {
663 avail = snd_pcm_avail_update (handle);
669 "Could not obtain number of available frames\n");
677 static int alsa_run_out (HWVoiceOut *hw)
679 ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
680 int rpos, live, decr;
683 struct st_sample *src;
684 snd_pcm_sframes_t avail;
686 live = audio_pcm_hw_get_live_out (hw);
691 avail = alsa_get_avail (alsa->handle);
693 dolog ("Could not get number of available playback frames\n");
697 decr = audio_MIN (live, avail);
701 int left_till_end_samples = hw->samples - rpos;
702 int len = audio_MIN (samples, left_till_end_samples);
703 snd_pcm_sframes_t written;
705 src = hw->mix_buf + rpos;
706 dst = advance (alsa->pcm_buf, rpos << hw->info.shift);
708 hw->clip (dst, src, len);
711 written = snd_pcm_writei (alsa->handle, dst, len);
717 dolog ("Failed to write %d frames (wrote zero)\n", len);
722 if (alsa_recover (alsa->handle)) {
723 alsa_logerr (written, "Failed to write %d frames\n",
728 dolog ("Recovering from playback xrun\n");
733 /* stream is suspended and waiting for an
734 application recovery */
735 if (alsa_resume (alsa->handle)) {
736 alsa_logerr (written, "Failed to write %d frames\n",
741 dolog ("Resuming suspended output stream\n");
749 alsa_logerr (written, "Failed to write %d frames to %p\n",
755 rpos = (rpos + written) % hw->samples;
758 dst = advance (dst, written << hw->info.shift);
768 static void alsa_fini_poll (struct pollhlp *hlp)
771 struct pollfd *pfds = hlp->pfds;
774 for (i = 0; i < hlp->count; ++i) {
775 qemu_set_fd_handler (pfds[i].fd, NULL, NULL, NULL);
784 static void alsa_fini_out (HWVoiceOut *hw)
786 ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
788 ldebug ("alsa_fini\n");
789 alsa_anal_close (&alsa->handle);
792 qemu_free (alsa->pcm_buf);
793 alsa->pcm_buf = NULL;
796 alsa_fini_poll (&alsa->pollhlp);
799 static int alsa_init_out (HWVoiceOut *hw, struct audsettings *as)
801 ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
802 struct alsa_params_req req;
803 struct alsa_params_obt obt;
805 struct audsettings obt_as;
807 req.fmt = aud_to_alsafmt (as->fmt);
809 req.nchannels = as->nchannels;
810 req.period_size = conf.period_size_out;
811 req.buffer_size = conf.buffer_size_out;
812 req.size_in_usec = conf.size_in_usec_out;
814 (conf.period_size_out_overridden ? 1 : 0) |
815 (conf.buffer_size_out_overridden ? 2 : 0);
817 if (alsa_open (0, &req, &obt, &handle)) {
821 obt_as.freq = obt.freq;
822 obt_as.nchannels = obt.nchannels;
823 obt_as.fmt = obt.fmt;
824 obt_as.endianness = obt.endianness;
826 audio_pcm_init_info (&hw->info, &obt_as);
827 hw->samples = obt.samples;
829 alsa->pcm_buf = audio_calloc (AUDIO_FUNC, obt.samples, 1 << hw->info.shift);
830 if (!alsa->pcm_buf) {
831 dolog ("Could not allocate DAC buffer (%d samples, each %d bytes)\n",
832 hw->samples, 1 << hw->info.shift);
833 alsa_anal_close (&handle);
837 alsa->handle = handle;
841 static int alsa_voice_ctl (snd_pcm_t *handle, const char *typ, int pause)
846 err = snd_pcm_drop (handle);
848 alsa_logerr (err, "Could not stop %s\n", typ);
853 err = snd_pcm_prepare (handle);
855 alsa_logerr (err, "Could not prepare handle for %s\n", typ);
863 static int alsa_ctl_out (HWVoiceOut *hw, int cmd, ...)
867 ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
870 poll_mode = va_arg (ap, int);
875 ldebug ("enabling voice\n");
876 if (poll_mode && alsa_poll_out (hw)) {
879 hw->poll_mode = poll_mode;
880 return alsa_voice_ctl (alsa->handle, "playback", 0);
883 ldebug ("disabling voice\n");
884 return alsa_voice_ctl (alsa->handle, "playback", 1);
890 static int alsa_init_in (HWVoiceIn *hw, struct audsettings *as)
892 ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
893 struct alsa_params_req req;
894 struct alsa_params_obt obt;
896 struct audsettings obt_as;
898 req.fmt = aud_to_alsafmt (as->fmt);
900 req.nchannels = as->nchannels;
901 req.period_size = conf.period_size_in;
902 req.buffer_size = conf.buffer_size_in;
903 req.size_in_usec = conf.size_in_usec_in;
905 (conf.period_size_in_overridden ? 1 : 0) |
906 (conf.buffer_size_in_overridden ? 2 : 0);
908 if (alsa_open (1, &req, &obt, &handle)) {
912 obt_as.freq = obt.freq;
913 obt_as.nchannels = obt.nchannels;
914 obt_as.fmt = obt.fmt;
915 obt_as.endianness = obt.endianness;
917 audio_pcm_init_info (&hw->info, &obt_as);
918 hw->samples = obt.samples;
920 alsa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
921 if (!alsa->pcm_buf) {
922 dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n",
923 hw->samples, 1 << hw->info.shift);
924 alsa_anal_close (&handle);
928 alsa->handle = handle;
932 static void alsa_fini_in (HWVoiceIn *hw)
934 ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
936 alsa_anal_close (&alsa->handle);
939 qemu_free (alsa->pcm_buf);
940 alsa->pcm_buf = NULL;
942 alsa_fini_poll (&alsa->pollhlp);
945 static int alsa_run_in (HWVoiceIn *hw)
947 ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
948 int hwshift = hw->info.shift;
950 int live = audio_pcm_hw_get_live_in (hw);
951 int dead = hw->samples - live;
957 { .add = hw->wpos, .len = 0 },
958 { .add = 0, .len = 0 }
960 snd_pcm_sframes_t avail;
961 snd_pcm_uframes_t read_samples = 0;
967 avail = alsa_get_avail (alsa->handle);
969 dolog ("Could not get number of captured frames\n");
974 snd_pcm_state_t state;
976 state = snd_pcm_state (alsa->handle);
978 case SND_PCM_STATE_PREPARED:
981 case SND_PCM_STATE_SUSPENDED:
982 /* stream is suspended and waiting for an application recovery */
983 if (alsa_resume (alsa->handle)) {
984 dolog ("Failed to resume suspended input stream\n");
988 dolog ("Resuming suspended input stream\n");
993 dolog ("No frames available and ALSA state is %d\n", state);
999 decr = audio_MIN (dead, avail);
1004 if (hw->wpos + decr > hw->samples) {
1005 bufs[0].len = (hw->samples - hw->wpos);
1006 bufs[1].len = (decr - (hw->samples - hw->wpos));
1012 for (i = 0; i < 2; ++i) {
1014 struct st_sample *dst;
1015 snd_pcm_sframes_t nread;
1016 snd_pcm_uframes_t len;
1020 src = advance (alsa->pcm_buf, bufs[i].add << hwshift);
1021 dst = hw->conv_buf + bufs[i].add;
1024 nread = snd_pcm_readi (alsa->handle, src, len);
1030 dolog ("Failed to read %ld frames (read zero)\n", len);
1035 if (alsa_recover (alsa->handle)) {
1036 alsa_logerr (nread, "Failed to read %ld frames\n", len);
1040 dolog ("Recovering from capture xrun\n");
1050 "Failed to read %ld frames from %p\n",
1058 hw->conv (dst, src, nread, &nominal_volume);
1060 src = advance (src, nread << hwshift);
1063 read_samples += nread;
1069 hw->wpos = (hw->wpos + read_samples) % hw->samples;
1070 return read_samples;
1073 static int alsa_read (SWVoiceIn *sw, void *buf, int size)
1075 return audio_pcm_sw_read (sw, buf, size);
1078 static int alsa_ctl_in (HWVoiceIn *hw, int cmd, ...)
1082 ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
1085 poll_mode = va_arg (ap, int);
1090 ldebug ("enabling voice\n");
1091 if (poll_mode && alsa_poll_in (hw)) {
1094 hw->poll_mode = poll_mode;
1096 return alsa_voice_ctl (alsa->handle, "capture", 0);
1099 ldebug ("disabling voice\n");
1100 if (hw->poll_mode) {
1102 alsa_fini_poll (&alsa->pollhlp);
1104 return alsa_voice_ctl (alsa->handle, "capture", 1);
1110 static void *alsa_audio_init (void)
1115 static void alsa_audio_fini (void *opaque)
1120 static struct audio_option alsa_options[] = {
1122 .name = "DAC_SIZE_IN_USEC",
1123 .tag = AUD_OPT_BOOL,
1124 .valp = &conf.size_in_usec_out,
1125 .descr = "DAC period/buffer size in microseconds (otherwise in frames)"
1128 .name = "DAC_PERIOD_SIZE",
1130 .valp = &conf.period_size_out,
1131 .descr = "DAC period size (0 to go with system default)",
1132 .overriddenp = &conf.period_size_out_overridden
1135 .name = "DAC_BUFFER_SIZE",
1137 .valp = &conf.buffer_size_out,
1138 .descr = "DAC buffer size (0 to go with system default)",
1139 .overriddenp = &conf.buffer_size_out_overridden
1142 .name = "ADC_SIZE_IN_USEC",
1143 .tag = AUD_OPT_BOOL,
1144 .valp = &conf.size_in_usec_in,
1146 "ADC period/buffer size in microseconds (otherwise in frames)"
1149 .name = "ADC_PERIOD_SIZE",
1151 .valp = &conf.period_size_in,
1152 .descr = "ADC period size (0 to go with system default)",
1153 .overriddenp = &conf.period_size_in_overridden
1156 .name = "ADC_BUFFER_SIZE",
1158 .valp = &conf.buffer_size_in,
1159 .descr = "ADC buffer size (0 to go with system default)",
1160 .overriddenp = &conf.buffer_size_in_overridden
1163 .name = "THRESHOLD",
1165 .valp = &conf.threshold,
1166 .descr = "(undocumented)"
1171 .valp = &conf.pcm_name_out,
1172 .descr = "DAC device name (for instance dmix)"
1177 .valp = &conf.pcm_name_in,
1178 .descr = "ADC device name"
1182 .tag = AUD_OPT_BOOL,
1183 .valp = &conf.verbose,
1184 .descr = "Behave in a more verbose way"
1186 { /* End of list */ }
1189 static struct audio_pcm_ops alsa_pcm_ops = {
1190 .init_out = alsa_init_out,
1191 .fini_out = alsa_fini_out,
1192 .run_out = alsa_run_out,
1193 .write = alsa_write,
1194 .ctl_out = alsa_ctl_out,
1196 .init_in = alsa_init_in,
1197 .fini_in = alsa_fini_in,
1198 .run_in = alsa_run_in,
1200 .ctl_in = alsa_ctl_in,
1203 struct audio_driver alsa_audio_driver = {
1205 .descr = "ALSA http://www.alsa-project.org",
1206 .options = alsa_options,
1207 .init = alsa_audio_init,
1208 .fini = alsa_audio_fini,
1209 .pcm_ops = &alsa_pcm_ops,
1210 .can_be_default = 1,
1211 .max_voices_out = INT_MAX,
1212 .max_voices_in = INT_MAX,
1213 .voice_size_out = sizeof (ALSAVoiceOut),
1214 .voice_size_in = sizeof (ALSAVoiceIn)