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 * @short_description: capture audio from an alsa device
25 * @see_also: alsasink, alsamixer
29 * This element reads data from an audio card using the ALSA API.
31 * <title>Example pipelines</title>
33 * Record from a sound card using ALSA and encode to Ogg/Vorbis.
36 * gst-launch -v alsasrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=alsasrc.ogg
40 * Last reviewed on 2006-03-01 (0.10.4)
46 #include <sys/ioctl.h>
52 #include <alsa/asoundlib.h>
54 #include "gstalsasrc.h"
55 #include "gstalsadeviceprobe.h"
57 #include <gst/gst-i18n-plugin.h>
59 /* elementfactory information */
60 static const GstElementDetails gst_alsasrc_details =
61 GST_ELEMENT_DETAILS ("Audio source (ALSA)",
63 "Read from a sound card via ALSA",
64 "Wim Taymans <wim@fluendo.com>");
66 #define DEFAULT_PROP_DEVICE "default"
67 #define DEFAULT_PROP_DEVICE_NAME ""
76 static void gst_alsasrc_init_interfaces (GType type);
78 GST_BOILERPLATE_FULL (GstAlsaSrc, gst_alsasrc, GstAudioSrc,
79 GST_TYPE_AUDIO_SRC, gst_alsasrc_init_interfaces);
81 GST_IMPLEMENT_ALSA_MIXER_METHODS (GstAlsaSrc, gst_alsasrc_mixer);
83 static void gst_alsasrc_finalize (GObject * object);
84 static void gst_alsasrc_set_property (GObject * object,
85 guint prop_id, const GValue * value, GParamSpec * pspec);
86 static void gst_alsasrc_get_property (GObject * object,
87 guint prop_id, GValue * value, GParamSpec * pspec);
89 static GstCaps *gst_alsasrc_getcaps (GstBaseSrc * bsrc);
91 static gboolean gst_alsasrc_open (GstAudioSrc * asrc);
92 static gboolean gst_alsasrc_prepare (GstAudioSrc * asrc,
93 GstRingBufferSpec * spec);
94 static gboolean gst_alsasrc_unprepare (GstAudioSrc * asrc);
95 static gboolean gst_alsasrc_close (GstAudioSrc * asrc);
96 static guint gst_alsasrc_read (GstAudioSrc * asrc, gpointer data, guint length);
97 static guint gst_alsasrc_delay (GstAudioSrc * asrc);
98 static void gst_alsasrc_reset (GstAudioSrc * asrc);
100 /* AlsaSrc signals and args */
106 #if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
107 # define ALSA_SRC_FACTORY_ENDIANNESS "LITTLE_ENDIAN, BIG_ENDIAN"
109 # define ALSA_SRC_FACTORY_ENDIANNESS "BIG_ENDIAN, LITTLE_ENDIAN"
112 static GstStaticPadTemplate alsasrc_src_factory =
113 GST_STATIC_PAD_TEMPLATE ("src",
116 GST_STATIC_CAPS ("audio/x-raw-int, "
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 "endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, "
130 "signed = (boolean) { TRUE, FALSE }, "
133 "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
135 "endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, "
136 "signed = (boolean) { TRUE, FALSE }, "
139 "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
141 "signed = (boolean) { TRUE, FALSE }, "
144 "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
148 gst_alsasrc_finalize (GObject * object)
150 GstAlsaSrc *src = GST_ALSA_SRC (object);
152 g_free (src->device);
153 g_mutex_free (src->alsa_lock);
155 G_OBJECT_CLASS (parent_class)->finalize (object);
159 gst_alsasrc_interface_supported (GstAlsaSrc * this, GType interface_type)
161 /* only support this one interface (wrapped by GstImplementsInterface) */
162 g_assert (interface_type == GST_TYPE_MIXER);
164 return gst_alsasrc_mixer_supported (this, interface_type);
168 gst_implements_interface_init (GstImplementsInterfaceClass * klass)
170 klass->supported = (gpointer) gst_alsasrc_interface_supported;
174 gst_alsasrc_init_interfaces (GType type)
176 static const GInterfaceInfo implements_iface_info = {
177 (GInterfaceInitFunc) gst_implements_interface_init,
181 static const GInterfaceInfo mixer_iface_info = {
182 (GInterfaceInitFunc) gst_alsasrc_mixer_interface_init,
187 g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE,
188 &implements_iface_info);
189 g_type_add_interface_static (type, GST_TYPE_MIXER, &mixer_iface_info);
191 gst_alsa_type_add_device_property_probe_interface (type);
195 gst_alsasrc_base_init (gpointer g_class)
197 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
199 gst_element_class_set_details (element_class, &gst_alsasrc_details);
201 gst_element_class_add_pad_template (element_class,
202 gst_static_pad_template_get (&alsasrc_src_factory));
206 gst_alsasrc_class_init (GstAlsaSrcClass * klass)
208 GObjectClass *gobject_class;
209 GstElementClass *gstelement_class;
210 GstBaseSrcClass *gstbasesrc_class;
211 GstBaseAudioSrcClass *gstbaseaudiosrc_class;
212 GstAudioSrcClass *gstaudiosrc_class;
214 gobject_class = (GObjectClass *) klass;
215 gstelement_class = (GstElementClass *) klass;
216 gstbasesrc_class = (GstBaseSrcClass *) klass;
217 gstbaseaudiosrc_class = (GstBaseAudioSrcClass *) klass;
218 gstaudiosrc_class = (GstAudioSrcClass *) klass;
220 gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_alsasrc_finalize);
221 gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_alsasrc_get_property);
222 gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_alsasrc_set_property);
224 gstbasesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_alsasrc_getcaps);
226 gstaudiosrc_class->open = GST_DEBUG_FUNCPTR (gst_alsasrc_open);
227 gstaudiosrc_class->prepare = GST_DEBUG_FUNCPTR (gst_alsasrc_prepare);
228 gstaudiosrc_class->unprepare = GST_DEBUG_FUNCPTR (gst_alsasrc_unprepare);
229 gstaudiosrc_class->close = GST_DEBUG_FUNCPTR (gst_alsasrc_close);
230 gstaudiosrc_class->read = GST_DEBUG_FUNCPTR (gst_alsasrc_read);
231 gstaudiosrc_class->delay = GST_DEBUG_FUNCPTR (gst_alsasrc_delay);
232 gstaudiosrc_class->reset = GST_DEBUG_FUNCPTR (gst_alsasrc_reset);
234 g_object_class_install_property (gobject_class, PROP_DEVICE,
235 g_param_spec_string ("device", "Device",
236 "ALSA device, as defined in an asound configuration file",
237 DEFAULT_PROP_DEVICE, G_PARAM_READWRITE));
239 g_object_class_install_property (gobject_class, PROP_DEVICE_NAME,
240 g_param_spec_string ("device-name", "Device name",
241 "Human-readable name of the sound device",
242 DEFAULT_PROP_DEVICE_NAME, G_PARAM_READABLE));
246 gst_alsasrc_set_property (GObject * object, guint prop_id,
247 const GValue * value, GParamSpec * pspec)
251 src = GST_ALSA_SRC (object);
255 g_free (src->device);
256 src->device = g_value_dup_string (value);
257 if (src->device == NULL) {
258 src->device = g_strdup (DEFAULT_PROP_DEVICE);
262 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
268 gst_alsasrc_get_property (GObject * object, guint prop_id,
269 GValue * value, GParamSpec * pspec)
273 src = GST_ALSA_SRC (object);
277 g_value_set_string (value, src->device);
279 case PROP_DEVICE_NAME:
280 g_value_take_string (value,
281 gst_alsa_find_device_name (GST_OBJECT_CAST (src),
282 src->device, src->handle, SND_PCM_STREAM_CAPTURE));
285 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
291 gst_alsasrc_init (GstAlsaSrc * alsasrc, GstAlsaSrcClass * g_class)
293 GST_DEBUG_OBJECT (alsasrc, "initializing");
295 alsasrc->device = g_strdup (DEFAULT_PROP_DEVICE);
296 alsasrc->cached_caps = NULL;
298 alsasrc->alsa_lock = g_mutex_new ();
301 #define CHECK(call, error) \
303 if ((err = call) < 0) \
309 gst_alsasrc_getcaps (GstBaseSrc * bsrc)
311 GstElementClass *element_class;
312 GstPadTemplate *pad_template;
316 src = GST_ALSA_SRC (bsrc);
318 if (src->handle == NULL) {
319 GST_DEBUG_OBJECT (src, "device not open, using template caps");
320 return NULL; /* base class will get template caps for us */
323 if (src->cached_caps) {
324 GST_LOG_OBJECT (src, "Returning cached caps");
325 return gst_caps_ref (src->cached_caps);
328 element_class = GST_ELEMENT_GET_CLASS (src);
329 pad_template = gst_element_class_get_pad_template (element_class, "src");
330 g_return_val_if_fail (pad_template != NULL, NULL);
332 caps = gst_alsa_probe_supported_formats (GST_OBJECT (src), src->handle,
333 gst_pad_template_get_caps (pad_template));
336 src->cached_caps = gst_caps_ref (caps);
339 GST_INFO_OBJECT (src, "returning caps %" GST_PTR_FORMAT, caps);
345 set_hwparams (GstAlsaSrc * alsa)
349 snd_pcm_hw_params_t *params;
351 snd_pcm_hw_params_malloc (¶ms);
353 /* choose all parameters */
354 CHECK (snd_pcm_hw_params_any (alsa->handle, params), no_config);
355 /* set the interleaved read/write format */
356 CHECK (snd_pcm_hw_params_set_access (alsa->handle, params, alsa->access),
358 /* set the sample format */
359 CHECK (snd_pcm_hw_params_set_format (alsa->handle, params, alsa->format),
361 /* set the count of channels */
362 CHECK (snd_pcm_hw_params_set_channels (alsa->handle, params, alsa->channels),
364 /* set the stream rate */
366 CHECK (snd_pcm_hw_params_set_rate_near (alsa->handle, params, &rrate, 0),
368 if (rrate != alsa->rate)
371 if (alsa->buffer_time != -1) {
372 /* set the buffer time */
373 CHECK (snd_pcm_hw_params_set_buffer_time_near (alsa->handle, params,
374 &alsa->buffer_time, &dir), buffer_time);
376 if (alsa->period_time != -1) {
377 /* set the period time */
378 CHECK (snd_pcm_hw_params_set_period_time_near (alsa->handle, params,
379 &alsa->period_time, &dir), period_time);
382 /* write the parameters to device */
383 CHECK (snd_pcm_hw_params (alsa->handle, params), set_hw_params);
385 CHECK (snd_pcm_hw_params_get_buffer_size (params, &alsa->buffer_size),
388 CHECK (snd_pcm_hw_params_get_period_size (params, &alsa->period_size, &dir),
391 snd_pcm_hw_params_free (params);
397 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
398 ("Broken configuration for recording: no configurations available: %s",
399 snd_strerror (err)));
400 snd_pcm_hw_params_free (params);
405 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
406 ("Access type not available for recording: %s", snd_strerror (err)));
407 snd_pcm_hw_params_free (params);
412 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
413 ("Sample format not available for recording: %s", snd_strerror (err)));
414 snd_pcm_hw_params_free (params);
421 if ((alsa->channels) == 1)
422 msg = g_strdup (_("Could not open device for recording in mono mode."));
423 if ((alsa->channels) == 2)
424 msg = g_strdup (_("Could not open device for recording in stereo mode."));
425 if ((alsa->channels) > 2)
428 ("Could not open device for recording in %d-channel mode"),
430 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (msg), (snd_strerror (err)));
432 snd_pcm_hw_params_free (params);
437 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
438 ("Rate %iHz not available for recording: %s",
439 alsa->rate, snd_strerror (err)));
440 snd_pcm_hw_params_free (params);
445 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
446 ("Rate doesn't match (requested %iHz, get %iHz)", alsa->rate, err));
447 snd_pcm_hw_params_free (params);
452 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
453 ("Unable to set buffer time %i for recording: %s",
454 alsa->buffer_time, snd_strerror (err)));
455 snd_pcm_hw_params_free (params);
460 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
461 ("Unable to get buffer size for recording: %s", snd_strerror (err)));
462 snd_pcm_hw_params_free (params);
467 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
468 ("Unable to set period time %i for recording: %s", alsa->period_time,
469 snd_strerror (err)));
470 snd_pcm_hw_params_free (params);
475 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
476 ("Unable to get period size for recording: %s", snd_strerror (err)));
477 snd_pcm_hw_params_free (params);
482 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
483 ("Unable to set hw params for recording: %s", snd_strerror (err)));
484 snd_pcm_hw_params_free (params);
490 set_swparams (GstAlsaSrc * alsa)
493 snd_pcm_sw_params_t *params;
495 snd_pcm_sw_params_malloc (¶ms);
497 /* get the current swparams */
498 CHECK (snd_pcm_sw_params_current (alsa->handle, params), no_config);
499 /* allow the transfer when at least period_size samples can be processed */
500 CHECK (snd_pcm_sw_params_set_avail_min (alsa->handle, params,
501 alsa->period_size), set_avail);
502 /* start the transfer on first read */
503 CHECK (snd_pcm_sw_params_set_start_threshold (alsa->handle, params,
504 0), start_threshold);
505 /* align all transfers to 1 sample */
506 CHECK (snd_pcm_sw_params_set_xfer_align (alsa->handle, params, 1), set_align);
508 /* write the parameters to the recording device */
509 CHECK (snd_pcm_sw_params (alsa->handle, params), set_sw_params);
511 snd_pcm_sw_params_free (params);
517 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
518 ("Unable to determine current swparams for playback: %s",
519 snd_strerror (err)));
520 snd_pcm_sw_params_free (params);
525 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
526 ("Unable to set start threshold mode for playback: %s",
527 snd_strerror (err)));
528 snd_pcm_sw_params_free (params);
533 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
534 ("Unable to set avail min for playback: %s", snd_strerror (err)));
535 snd_pcm_sw_params_free (params);
540 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
541 ("Unable to set transfer align for playback: %s", snd_strerror (err)));
542 snd_pcm_sw_params_free (params);
547 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
548 ("Unable to set sw params for playback: %s", snd_strerror (err)));
549 snd_pcm_sw_params_free (params);
555 alsasrc_parse_spec (GstAlsaSrc * alsa, GstRingBufferSpec * spec)
557 switch (spec->type) {
558 case GST_BUFTYPE_LINEAR:
559 alsa->format = snd_pcm_build_linear_format (spec->depth, spec->width,
560 spec->sign ? 0 : 1, spec->bigend ? 1 : 0);
562 case GST_BUFTYPE_FLOAT:
563 switch (spec->format) {
565 alsa->format = SND_PCM_FORMAT_FLOAT_LE;
568 alsa->format = SND_PCM_FORMAT_FLOAT_BE;
571 alsa->format = SND_PCM_FORMAT_FLOAT64_LE;
574 alsa->format = SND_PCM_FORMAT_FLOAT64_BE;
580 case GST_BUFTYPE_A_LAW:
581 alsa->format = SND_PCM_FORMAT_A_LAW;
583 case GST_BUFTYPE_MU_LAW:
584 alsa->format = SND_PCM_FORMAT_MU_LAW;
590 alsa->rate = spec->rate;
591 alsa->channels = spec->channels;
592 alsa->buffer_time = spec->buffer_time;
593 alsa->period_time = spec->latency_time;
594 alsa->access = SND_PCM_ACCESS_RW_INTERLEAVED;
606 gst_alsasrc_open (GstAudioSrc * asrc)
611 alsa = GST_ALSA_SRC (asrc);
613 CHECK (snd_pcm_open (&alsa->handle, alsa->device, SND_PCM_STREAM_CAPTURE,
614 SND_PCM_NONBLOCK), open_error);
617 alsa->mixer = gst_alsa_mixer_new (alsa->device, GST_ALSA_MIXER_CAPTURE);
625 GST_ELEMENT_ERROR (alsa, RESOURCE, BUSY,
626 (_("Could not open audio device for recording. "
627 "Device is being used by another application.")),
628 ("Device '%s' is busy", alsa->device));
630 GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
631 (_("Could not open audio device for recording.")),
632 ("Recording open error on device '%s': %s", alsa->device,
633 snd_strerror (err)));
640 gst_alsasrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
645 alsa = GST_ALSA_SRC (asrc);
647 if (!alsasrc_parse_spec (alsa, spec))
650 CHECK (snd_pcm_nonblock (alsa->handle, 0), non_block);
652 CHECK (set_hwparams (alsa), hw_params_failed);
653 CHECK (set_swparams (alsa), sw_params_failed);
654 CHECK (snd_pcm_prepare (alsa->handle), prepare_failed);
656 alsa->bytes_per_sample = spec->bytes_per_sample;
657 spec->segsize = alsa->period_size * spec->bytes_per_sample;
658 spec->segtotal = alsa->buffer_size / alsa->period_size;
659 spec->silence_sample[0] = 0;
660 spec->silence_sample[1] = 0;
661 spec->silence_sample[2] = 0;
662 spec->silence_sample[3] = 0;
669 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
670 ("Error parsing spec"));
675 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
676 ("Could not set device to blocking: %s", snd_strerror (err)));
681 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
682 ("Setting of hwparams failed: %s", snd_strerror (err)));
687 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
688 ("Setting of swparams failed: %s", snd_strerror (err)));
693 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
694 ("Prepare failed: %s", snd_strerror (err)));
700 gst_alsasrc_unprepare (GstAudioSrc * asrc)
705 alsa = GST_ALSA_SRC (asrc);
707 CHECK (snd_pcm_drop (alsa->handle), drop);
709 CHECK (snd_pcm_hw_free (alsa->handle), hw_free);
711 CHECK (snd_pcm_nonblock (alsa->handle, 1), non_block);
718 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
719 ("Could not drop samples: %s", snd_strerror (err)));
724 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
725 ("Could not free hw params: %s", snd_strerror (err)));
730 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
731 ("Could not set device to nonblocking: %s", snd_strerror (err)));
737 gst_alsasrc_close (GstAudioSrc * asrc)
739 GstAlsaSrc *alsa = GST_ALSA_SRC (asrc);
741 snd_pcm_close (alsa->handle);
744 gst_alsa_mixer_free (alsa->mixer);
748 gst_caps_replace (&alsa->cached_caps, NULL);
754 * Underrun and suspend recovery
757 xrun_recovery (GstAlsaSrc * alsa, snd_pcm_t * handle, gint err)
759 GST_DEBUG_OBJECT (alsa, "xrun recovery %d", err);
761 if (err == -EPIPE) { /* under-run */
762 err = snd_pcm_prepare (handle);
764 GST_WARNING_OBJECT (alsa,
765 "Can't recovery from underrun, prepare failed: %s",
768 } else if (err == -ESTRPIPE) {
769 while ((err = snd_pcm_resume (handle)) == -EAGAIN)
770 g_usleep (100); /* wait until the suspend flag is released */
773 err = snd_pcm_prepare (handle);
775 GST_WARNING_OBJECT (alsa,
776 "Can't recovery from suspend, prepare failed: %s",
785 gst_alsasrc_read (GstAudioSrc * asrc, gpointer data, guint length)
792 alsa = GST_ALSA_SRC (asrc);
794 cptr = length / alsa->bytes_per_sample;
797 GST_ALSA_SRC_LOCK (asrc);
799 if ((err = snd_pcm_readi (alsa->handle, ptr, cptr)) < 0) {
800 if (err == -EAGAIN) {
801 GST_DEBUG_OBJECT (asrc, "Read error: %s", snd_strerror (err));
803 } else if (xrun_recovery (alsa, alsa->handle, err) < 0) {
809 ptr += err * alsa->channels;
812 GST_ALSA_SRC_UNLOCK (asrc);
814 return length - cptr;
818 GST_ALSA_SRC_UNLOCK (asrc);
819 return length; /* skip one period */
824 gst_alsasrc_delay (GstAudioSrc * asrc)
827 snd_pcm_sframes_t delay;
830 alsa = GST_ALSA_SRC (asrc);
832 res = snd_pcm_delay (alsa->handle, &delay);
833 if (G_UNLIKELY (res < 0)) {
834 GST_DEBUG_OBJECT (alsa, "snd_pcm_delay returned %d", res);
838 return CLAMP (delay, 0, alsa->buffer_size);
842 gst_alsasrc_reset (GstAudioSrc * asrc)
847 alsa = GST_ALSA_SRC (asrc);
849 GST_ALSA_SRC_LOCK (asrc);
850 GST_DEBUG_OBJECT (alsa, "drop");
851 CHECK (snd_pcm_drop (alsa->handle), drop_error);
852 GST_DEBUG_OBJECT (alsa, "prepare");
853 CHECK (snd_pcm_prepare (alsa->handle), prepare_error);
854 GST_DEBUG_OBJECT (alsa, "reset done");
855 GST_ALSA_SRC_UNLOCK (asrc);
862 GST_ERROR_OBJECT (alsa, "alsa-reset: pcm drop error: %s",
864 GST_ALSA_SRC_UNLOCK (asrc);
869 GST_ERROR_OBJECT (alsa, "alsa-reset: pcm prepare error: %s",
871 GST_ALSA_SRC_UNLOCK (asrc);