2 * Copyright (C) 2005 Wim Taymans <wim@fluendo.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 * SECTION:element-alsasrc
24 * @see_also: alsasink, alsamixer
26 * This element reads data from an audio card using the ALSA API.
29 * <title>Example pipelines</title>
31 * gst-launch -v alsasrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=alsasrc.ogg
32 * ]| Record from a sound card using ALSA and encode to Ogg/Vorbis.
35 * Last reviewed on 2006-03-01 (0.10.4)
41 #include <sys/ioctl.h>
47 #include <alsa/asoundlib.h>
49 #include "gstalsasrc.h"
50 #include "gstalsadeviceprobe.h"
52 #include <gst/gst-i18n-plugin.h>
54 #define DEFAULT_PROP_DEVICE "default"
55 #define DEFAULT_PROP_DEVICE_NAME ""
64 static void gst_alsasrc_init_interfaces (GType type);
66 GST_BOILERPLATE_FULL (GstAlsaSrc, gst_alsasrc, GstAudioSrc,
67 GST_TYPE_AUDIO_SRC, gst_alsasrc_init_interfaces);
69 GST_IMPLEMENT_ALSA_MIXER_METHODS (GstAlsaSrc, gst_alsasrc_mixer);
71 static void gst_alsasrc_finalize (GObject * object);
72 static void gst_alsasrc_set_property (GObject * object,
73 guint prop_id, const GValue * value, GParamSpec * pspec);
74 static void gst_alsasrc_get_property (GObject * object,
75 guint prop_id, GValue * value, GParamSpec * pspec);
77 static GstCaps *gst_alsasrc_getcaps (GstBaseSrc * bsrc);
79 static gboolean gst_alsasrc_open (GstAudioSrc * asrc);
80 static gboolean gst_alsasrc_prepare (GstAudioSrc * asrc,
81 GstRingBufferSpec * spec);
82 static gboolean gst_alsasrc_unprepare (GstAudioSrc * asrc);
83 static gboolean gst_alsasrc_close (GstAudioSrc * asrc);
84 static guint gst_alsasrc_read (GstAudioSrc * asrc, gpointer data, guint length);
85 static guint gst_alsasrc_delay (GstAudioSrc * asrc);
86 static void gst_alsasrc_reset (GstAudioSrc * asrc);
88 /* AlsaSrc signals and args */
94 #if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
95 # define ALSA_SRC_FACTORY_ENDIANNESS "LITTLE_ENDIAN, BIG_ENDIAN"
97 # define ALSA_SRC_FACTORY_ENDIANNESS "BIG_ENDIAN, LITTLE_ENDIAN"
100 static GstStaticPadTemplate alsasrc_src_factory =
101 GST_STATIC_PAD_TEMPLATE ("src",
104 GST_STATIC_CAPS ("audio/x-raw-int, "
105 "endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, "
106 "signed = (boolean) { TRUE, FALSE }, "
109 "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
111 "endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, "
112 "signed = (boolean) { TRUE, FALSE }, "
115 "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
117 "endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, "
118 "signed = (boolean) { TRUE, FALSE }, "
121 "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
123 "endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, "
124 "signed = (boolean) { TRUE, FALSE }, "
127 "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
129 "signed = (boolean) { TRUE, FALSE }, "
132 "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
136 gst_alsasrc_finalize (GObject * object)
138 GstAlsaSrc *src = GST_ALSA_SRC (object);
140 g_free (src->device);
141 g_mutex_free (src->alsa_lock);
143 G_OBJECT_CLASS (parent_class)->finalize (object);
147 gst_alsasrc_interface_supported (GstAlsaSrc * this, GType interface_type)
149 /* only support this one interface (wrapped by GstImplementsInterface) */
150 g_assert (interface_type == GST_TYPE_MIXER);
152 return gst_alsasrc_mixer_supported (this, interface_type);
156 gst_implements_interface_init (GstImplementsInterfaceClass * klass)
158 klass->supported = (gpointer) gst_alsasrc_interface_supported;
162 gst_alsasrc_init_interfaces (GType type)
164 static const GInterfaceInfo implements_iface_info = {
165 (GInterfaceInitFunc) gst_implements_interface_init,
169 static const GInterfaceInfo mixer_iface_info = {
170 (GInterfaceInitFunc) gst_alsasrc_mixer_interface_init,
175 g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE,
176 &implements_iface_info);
177 g_type_add_interface_static (type, GST_TYPE_MIXER, &mixer_iface_info);
179 gst_alsa_type_add_device_property_probe_interface (type);
183 gst_alsasrc_base_init (gpointer g_class)
185 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
187 gst_element_class_set_details_simple (element_class,
188 "Audio source (ALSA)", "Source/Audio",
189 "Read from a sound card via ALSA", "Wim Taymans <wim@fluendo.com>");
191 gst_element_class_add_pad_template (element_class,
192 gst_static_pad_template_get (&alsasrc_src_factory));
196 gst_alsasrc_class_init (GstAlsaSrcClass * klass)
198 GObjectClass *gobject_class;
199 GstBaseSrcClass *gstbasesrc_class;
200 GstAudioSrcClass *gstaudiosrc_class;
202 gobject_class = (GObjectClass *) klass;
203 gstbasesrc_class = (GstBaseSrcClass *) klass;
204 gstaudiosrc_class = (GstAudioSrcClass *) klass;
206 gobject_class->finalize = gst_alsasrc_finalize;
207 gobject_class->get_property = gst_alsasrc_get_property;
208 gobject_class->set_property = gst_alsasrc_set_property;
210 gstbasesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_alsasrc_getcaps);
212 gstaudiosrc_class->open = GST_DEBUG_FUNCPTR (gst_alsasrc_open);
213 gstaudiosrc_class->prepare = GST_DEBUG_FUNCPTR (gst_alsasrc_prepare);
214 gstaudiosrc_class->unprepare = GST_DEBUG_FUNCPTR (gst_alsasrc_unprepare);
215 gstaudiosrc_class->close = GST_DEBUG_FUNCPTR (gst_alsasrc_close);
216 gstaudiosrc_class->read = GST_DEBUG_FUNCPTR (gst_alsasrc_read);
217 gstaudiosrc_class->delay = GST_DEBUG_FUNCPTR (gst_alsasrc_delay);
218 gstaudiosrc_class->reset = GST_DEBUG_FUNCPTR (gst_alsasrc_reset);
220 g_object_class_install_property (gobject_class, PROP_DEVICE,
221 g_param_spec_string ("device", "Device",
222 "ALSA device, as defined in an asound configuration file",
223 DEFAULT_PROP_DEVICE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
225 g_object_class_install_property (gobject_class, PROP_DEVICE_NAME,
226 g_param_spec_string ("device-name", "Device name",
227 "Human-readable name of the sound device",
228 DEFAULT_PROP_DEVICE_NAME, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
232 gst_alsasrc_set_property (GObject * object, guint prop_id,
233 const GValue * value, GParamSpec * pspec)
237 src = GST_ALSA_SRC (object);
241 g_free (src->device);
242 src->device = g_value_dup_string (value);
243 if (src->device == NULL) {
244 src->device = g_strdup (DEFAULT_PROP_DEVICE);
248 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
254 gst_alsasrc_get_property (GObject * object, guint prop_id,
255 GValue * value, GParamSpec * pspec)
259 src = GST_ALSA_SRC (object);
263 g_value_set_string (value, src->device);
265 case PROP_DEVICE_NAME:
266 g_value_take_string (value,
267 gst_alsa_find_device_name (GST_OBJECT_CAST (src),
268 src->device, src->handle, SND_PCM_STREAM_CAPTURE));
271 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
277 gst_alsasrc_init (GstAlsaSrc * alsasrc, GstAlsaSrcClass * g_class)
279 GST_DEBUG_OBJECT (alsasrc, "initializing");
281 alsasrc->device = g_strdup (DEFAULT_PROP_DEVICE);
282 alsasrc->cached_caps = NULL;
284 alsasrc->alsa_lock = g_mutex_new ();
287 #define CHECK(call, error) \
289 if ((err = call) < 0) \
295 gst_alsasrc_getcaps (GstBaseSrc * bsrc)
297 GstElementClass *element_class;
298 GstPadTemplate *pad_template;
302 src = GST_ALSA_SRC (bsrc);
304 if (src->handle == NULL) {
305 GST_DEBUG_OBJECT (src, "device not open, using template caps");
306 return NULL; /* base class will get template caps for us */
309 if (src->cached_caps) {
310 GST_LOG_OBJECT (src, "Returning cached caps");
311 return gst_caps_ref (src->cached_caps);
314 element_class = GST_ELEMENT_GET_CLASS (src);
315 pad_template = gst_element_class_get_pad_template (element_class, "src");
316 g_return_val_if_fail (pad_template != NULL, NULL);
318 caps = gst_alsa_probe_supported_formats (GST_OBJECT (src), src->handle,
319 gst_pad_template_get_caps (pad_template));
322 src->cached_caps = gst_caps_ref (caps);
325 GST_INFO_OBJECT (src, "returning caps %" GST_PTR_FORMAT, caps);
331 set_hwparams (GstAlsaSrc * alsa)
335 snd_pcm_hw_params_t *params;
337 snd_pcm_hw_params_malloc (¶ms);
339 /* choose all parameters */
340 CHECK (snd_pcm_hw_params_any (alsa->handle, params), no_config);
341 /* set the interleaved read/write format */
342 CHECK (snd_pcm_hw_params_set_access (alsa->handle, params, alsa->access),
344 /* set the sample format */
345 CHECK (snd_pcm_hw_params_set_format (alsa->handle, params, alsa->format),
347 /* set the count of channels */
348 CHECK (snd_pcm_hw_params_set_channels (alsa->handle, params, alsa->channels),
350 /* set the stream rate */
352 CHECK (snd_pcm_hw_params_set_rate_near (alsa->handle, params, &rrate, NULL),
354 if (rrate != alsa->rate)
357 if (alsa->buffer_time != -1) {
358 /* set the buffer time */
359 CHECK (snd_pcm_hw_params_set_buffer_time_near (alsa->handle, params,
360 &alsa->buffer_time, &dir), buffer_time);
362 if (alsa->period_time != -1) {
363 /* set the period time */
364 CHECK (snd_pcm_hw_params_set_period_time_near (alsa->handle, params,
365 &alsa->period_time, &dir), period_time);
368 /* write the parameters to device */
369 CHECK (snd_pcm_hw_params (alsa->handle, params), set_hw_params);
371 CHECK (snd_pcm_hw_params_get_buffer_size (params, &alsa->buffer_size),
374 CHECK (snd_pcm_hw_params_get_period_size (params, &alsa->period_size, &dir),
377 snd_pcm_hw_params_free (params);
383 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
384 ("Broken configuration for recording: no configurations available: %s",
385 snd_strerror (err)));
386 snd_pcm_hw_params_free (params);
391 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
392 ("Access type not available for recording: %s", snd_strerror (err)));
393 snd_pcm_hw_params_free (params);
398 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
399 ("Sample format not available for recording: %s", snd_strerror (err)));
400 snd_pcm_hw_params_free (params);
407 if ((alsa->channels) == 1)
408 msg = g_strdup (_("Could not open device for recording in mono mode."));
409 if ((alsa->channels) == 2)
410 msg = g_strdup (_("Could not open device for recording in stereo mode."));
411 if ((alsa->channels) > 2)
414 ("Could not open device for recording in %d-channel mode"),
416 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (msg), (snd_strerror (err)));
418 snd_pcm_hw_params_free (params);
423 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
424 ("Rate %iHz not available for recording: %s",
425 alsa->rate, snd_strerror (err)));
426 snd_pcm_hw_params_free (params);
431 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
432 ("Rate doesn't match (requested %iHz, get %iHz)", alsa->rate, err));
433 snd_pcm_hw_params_free (params);
438 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
439 ("Unable to set buffer time %i for recording: %s",
440 alsa->buffer_time, snd_strerror (err)));
441 snd_pcm_hw_params_free (params);
446 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
447 ("Unable to get buffer size for recording: %s", snd_strerror (err)));
448 snd_pcm_hw_params_free (params);
453 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
454 ("Unable to set period time %i for recording: %s", alsa->period_time,
455 snd_strerror (err)));
456 snd_pcm_hw_params_free (params);
461 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
462 ("Unable to get period size for recording: %s", snd_strerror (err)));
463 snd_pcm_hw_params_free (params);
468 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
469 ("Unable to set hw params for recording: %s", snd_strerror (err)));
470 snd_pcm_hw_params_free (params);
476 set_swparams (GstAlsaSrc * alsa)
479 snd_pcm_sw_params_t *params;
481 snd_pcm_sw_params_malloc (¶ms);
483 /* get the current swparams */
484 CHECK (snd_pcm_sw_params_current (alsa->handle, params), no_config);
485 /* allow the transfer when at least period_size samples can be processed */
486 CHECK (snd_pcm_sw_params_set_avail_min (alsa->handle, params,
487 alsa->period_size), set_avail);
488 /* start the transfer on first read */
489 CHECK (snd_pcm_sw_params_set_start_threshold (alsa->handle, params,
490 0), start_threshold);
492 #if GST_CHECK_ALSA_VERSION(1,0,16)
493 /* snd_pcm_sw_params_set_xfer_align() is deprecated, alignment is always 1 */
495 /* align all transfers to 1 sample */
496 CHECK (snd_pcm_sw_params_set_xfer_align (alsa->handle, params, 1), set_align);
499 /* write the parameters to the recording device */
500 CHECK (snd_pcm_sw_params (alsa->handle, params), set_sw_params);
502 snd_pcm_sw_params_free (params);
508 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
509 ("Unable to determine current swparams for playback: %s",
510 snd_strerror (err)));
511 snd_pcm_sw_params_free (params);
516 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
517 ("Unable to set start threshold mode for playback: %s",
518 snd_strerror (err)));
519 snd_pcm_sw_params_free (params);
524 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
525 ("Unable to set avail min for playback: %s", snd_strerror (err)));
526 snd_pcm_sw_params_free (params);
529 #if !GST_CHECK_ALSA_VERSION(1,0,16)
532 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
533 ("Unable to set transfer align for playback: %s", snd_strerror (err)));
534 snd_pcm_sw_params_free (params);
540 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
541 ("Unable to set sw params for playback: %s", snd_strerror (err)));
542 snd_pcm_sw_params_free (params);
548 alsasrc_parse_spec (GstAlsaSrc * alsa, GstRingBufferSpec * spec)
550 switch (spec->type) {
551 case GST_BUFTYPE_LINEAR:
552 alsa->format = snd_pcm_build_linear_format (spec->depth, spec->width,
553 spec->sign ? 0 : 1, spec->bigend ? 1 : 0);
555 case GST_BUFTYPE_FLOAT:
556 switch (spec->format) {
558 alsa->format = SND_PCM_FORMAT_FLOAT_LE;
561 alsa->format = SND_PCM_FORMAT_FLOAT_BE;
564 alsa->format = SND_PCM_FORMAT_FLOAT64_LE;
567 alsa->format = SND_PCM_FORMAT_FLOAT64_BE;
573 case GST_BUFTYPE_A_LAW:
574 alsa->format = SND_PCM_FORMAT_A_LAW;
576 case GST_BUFTYPE_MU_LAW:
577 alsa->format = SND_PCM_FORMAT_MU_LAW;
583 alsa->rate = spec->rate;
584 alsa->channels = spec->channels;
585 alsa->buffer_time = spec->buffer_time;
586 alsa->period_time = spec->latency_time;
587 alsa->access = SND_PCM_ACCESS_RW_INTERLEAVED;
599 gst_alsasrc_open (GstAudioSrc * asrc)
604 alsa = GST_ALSA_SRC (asrc);
606 CHECK (snd_pcm_open (&alsa->handle, alsa->device, SND_PCM_STREAM_CAPTURE,
607 SND_PCM_NONBLOCK), open_error);
610 alsa->mixer = gst_alsa_mixer_new (alsa->device, GST_ALSA_MIXER_CAPTURE);
618 GST_ELEMENT_ERROR (alsa, RESOURCE, BUSY,
619 (_("Could not open audio device for recording. "
620 "Device is being used by another application.")),
621 ("Device '%s' is busy", alsa->device));
623 GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
624 (_("Could not open audio device for recording.")),
625 ("Recording open error on device '%s': %s", alsa->device,
626 snd_strerror (err)));
633 gst_alsasrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
638 alsa = GST_ALSA_SRC (asrc);
640 if (!alsasrc_parse_spec (alsa, spec))
643 CHECK (snd_pcm_nonblock (alsa->handle, 0), non_block);
645 CHECK (set_hwparams (alsa), hw_params_failed);
646 CHECK (set_swparams (alsa), sw_params_failed);
647 CHECK (snd_pcm_prepare (alsa->handle), prepare_failed);
649 alsa->bytes_per_sample = spec->bytes_per_sample;
650 spec->segsize = alsa->period_size * spec->bytes_per_sample;
651 spec->segtotal = alsa->buffer_size / alsa->period_size;
652 spec->silence_sample[0] = 0;
653 spec->silence_sample[1] = 0;
654 spec->silence_sample[2] = 0;
655 spec->silence_sample[3] = 0;
662 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
663 ("Error parsing spec"));
668 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
669 ("Could not set device to blocking: %s", snd_strerror (err)));
674 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
675 ("Setting of hwparams failed: %s", snd_strerror (err)));
680 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
681 ("Setting of swparams failed: %s", snd_strerror (err)));
686 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
687 ("Prepare failed: %s", snd_strerror (err)));
693 gst_alsasrc_unprepare (GstAudioSrc * asrc)
697 alsa = GST_ALSA_SRC (asrc);
699 snd_pcm_drop (alsa->handle);
700 snd_pcm_hw_free (alsa->handle);
701 snd_pcm_nonblock (alsa->handle, 1);
707 gst_alsasrc_close (GstAudioSrc * asrc)
709 GstAlsaSrc *alsa = GST_ALSA_SRC (asrc);
711 snd_pcm_close (alsa->handle);
715 gst_alsa_mixer_free (alsa->mixer);
719 gst_caps_replace (&alsa->cached_caps, NULL);
725 * Underrun and suspend recovery
728 xrun_recovery (GstAlsaSrc * alsa, snd_pcm_t * handle, gint err)
730 GST_DEBUG_OBJECT (alsa, "xrun recovery %d", err);
732 if (err == -EPIPE) { /* under-run */
733 err = snd_pcm_prepare (handle);
735 GST_WARNING_OBJECT (alsa,
736 "Can't recovery from underrun, prepare failed: %s",
739 } else if (err == -ESTRPIPE) {
740 while ((err = snd_pcm_resume (handle)) == -EAGAIN)
741 g_usleep (100); /* wait until the suspend flag is released */
744 err = snd_pcm_prepare (handle);
746 GST_WARNING_OBJECT (alsa,
747 "Can't recovery from suspend, prepare failed: %s",
756 gst_alsasrc_read (GstAudioSrc * asrc, gpointer data, guint length)
763 alsa = GST_ALSA_SRC (asrc);
765 cptr = length / alsa->bytes_per_sample;
768 GST_ALSA_SRC_LOCK (asrc);
770 if ((err = snd_pcm_readi (alsa->handle, ptr, cptr)) < 0) {
771 if (err == -EAGAIN) {
772 GST_DEBUG_OBJECT (asrc, "Read error: %s", snd_strerror (err));
774 } else if (xrun_recovery (alsa, alsa->handle, err) < 0) {
780 ptr += err * alsa->channels;
783 GST_ALSA_SRC_UNLOCK (asrc);
785 return length - (cptr * alsa->bytes_per_sample);
789 GST_ALSA_SRC_UNLOCK (asrc);
790 return length; /* skip one period */
795 gst_alsasrc_delay (GstAudioSrc * asrc)
798 snd_pcm_sframes_t delay;
801 alsa = GST_ALSA_SRC (asrc);
803 res = snd_pcm_delay (alsa->handle, &delay);
804 if (G_UNLIKELY (res < 0)) {
805 GST_DEBUG_OBJECT (alsa, "snd_pcm_delay returned %d", res);
809 return CLAMP (delay, 0, alsa->buffer_size);
813 gst_alsasrc_reset (GstAudioSrc * asrc)
818 alsa = GST_ALSA_SRC (asrc);
820 GST_ALSA_SRC_LOCK (asrc);
821 GST_DEBUG_OBJECT (alsa, "drop");
822 CHECK (snd_pcm_drop (alsa->handle), drop_error);
823 GST_DEBUG_OBJECT (alsa, "prepare");
824 CHECK (snd_pcm_prepare (alsa->handle), prepare_error);
825 GST_DEBUG_OBJECT (alsa, "reset done");
826 GST_ALSA_SRC_UNLOCK (asrc);
833 GST_ERROR_OBJECT (alsa, "alsa-reset: pcm drop error: %s",
835 GST_ALSA_SRC_UNLOCK (asrc);
840 GST_ERROR_OBJECT (alsa, "alsa-reset: pcm prepare error: %s",
842 GST_ALSA_SRC_UNLOCK (asrc);