2005-07-06 15:27:17 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2005 Wim Taymans <wim@fluendo.com>
|
|
|
|
*
|
2005-07-08 11:42:47 +00:00
|
|
|
* gstalsasrc.c:
|
2003-11-16 00:40:01 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2005-07-06 15:27:17 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2003-11-16 00:40:01 +00:00
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
2005-07-06 15:27:17 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
2003-11-16 00:40:01 +00:00
|
|
|
*/
|
|
|
|
|
2006-03-01 18:25:18 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-alsasrc
|
|
|
|
* @see_also: alsasink, alsamixer
|
|
|
|
*
|
|
|
|
* This element reads data from an audio card using the ALSA API.
|
2008-07-10 21:06:06 +00:00
|
|
|
*
|
|
|
|
* <refsect2>
|
2006-03-01 18:25:18 +00:00
|
|
|
* <title>Example pipelines</title>
|
2008-07-10 21:06:06 +00:00
|
|
|
* |[
|
2006-03-01 18:25:18 +00:00
|
|
|
* gst-launch -v alsasrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=alsasrc.ogg
|
2008-07-10 21:06:06 +00:00
|
|
|
* ]| Record from a sound card using ALSA and encode to Ogg/Vorbis.
|
2006-03-01 18:25:18 +00:00
|
|
|
* </refsect2>
|
|
|
|
*
|
|
|
|
* Last reviewed on 2006-03-01 (0.10.4)
|
|
|
|
*/
|
|
|
|
|
2003-11-16 00:40:01 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2005-07-06 15:27:17 +00:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <alsa/asoundlib.h>
|
|
|
|
|
2003-11-16 00:40:01 +00:00
|
|
|
#include "gstalsasrc.h"
|
2006-05-18 17:19:39 +00:00
|
|
|
#include "gstalsadeviceprobe.h"
|
2003-11-16 00:40:01 +00:00
|
|
|
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
#include <gst/gst-i18n-plugin.h>
|
|
|
|
|
2006-03-01 18:25:18 +00:00
|
|
|
#define DEFAULT_PROP_DEVICE "default"
|
|
|
|
#define DEFAULT_PROP_DEVICE_NAME ""
|
2010-08-18 14:45:37 +00:00
|
|
|
#define DEFAULT_PROP_CARD_NAME ""
|
2006-03-01 18:25:18 +00:00
|
|
|
|
2005-07-08 11:42:47 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_DEVICE,
|
2005-08-22 16:50:59 +00:00
|
|
|
PROP_DEVICE_NAME,
|
2010-08-18 14:45:37 +00:00
|
|
|
PROP_CARD_NAME,
|
|
|
|
PROP_LAST
|
2005-07-08 11:42:47 +00:00
|
|
|
};
|
|
|
|
|
2006-05-18 17:19:39 +00:00
|
|
|
static void gst_alsasrc_init_interfaces (GType type);
|
2011-04-19 12:11:32 +00:00
|
|
|
#define gst_alsasrc_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstAlsaSrc, gst_alsasrc,
|
|
|
|
GST_TYPE_AUDIO_SRC, gst_alsasrc_init_interfaces (g_define_type_id));
|
2005-08-22 15:11:31 +00:00
|
|
|
|
|
|
|
GST_IMPLEMENT_ALSA_MIXER_METHODS (GstAlsaSrc, gst_alsasrc_mixer);
|
|
|
|
|
2007-03-01 16:48:45 +00:00
|
|
|
static void gst_alsasrc_finalize (GObject * object);
|
2005-07-08 11:42:47 +00:00
|
|
|
static void gst_alsasrc_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_alsasrc_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
2005-07-06 15:27:17 +00:00
|
|
|
|
|
|
|
static GstCaps *gst_alsasrc_getcaps (GstBaseSrc * bsrc);
|
|
|
|
|
2005-08-22 15:11:31 +00:00
|
|
|
static gboolean gst_alsasrc_open (GstAudioSrc * asrc);
|
|
|
|
static gboolean gst_alsasrc_prepare (GstAudioSrc * asrc,
|
|
|
|
GstRingBufferSpec * spec);
|
|
|
|
static gboolean gst_alsasrc_unprepare (GstAudioSrc * asrc);
|
2005-07-06 15:27:17 +00:00
|
|
|
static gboolean gst_alsasrc_close (GstAudioSrc * asrc);
|
|
|
|
static guint gst_alsasrc_read (GstAudioSrc * asrc, gpointer data, guint length);
|
|
|
|
static guint gst_alsasrc_delay (GstAudioSrc * asrc);
|
|
|
|
static void gst_alsasrc_reset (GstAudioSrc * asrc);
|
|
|
|
|
|
|
|
/* AlsaSrc signals and args */
|
|
|
|
enum
|
2003-11-16 00:40:01 +00:00
|
|
|
{
|
2005-07-06 15:27:17 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2006-03-01 18:25:18 +00:00
|
|
|
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
|
|
|
|
# define ALSA_SRC_FACTORY_ENDIANNESS "LITTLE_ENDIAN, BIG_ENDIAN"
|
|
|
|
#else
|
|
|
|
# define ALSA_SRC_FACTORY_ENDIANNESS "BIG_ENDIAN, LITTLE_ENDIAN"
|
|
|
|
#endif
|
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
static GstStaticPadTemplate alsasrc_src_factory =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-raw-int, "
|
2006-07-02 11:08:58 +00:00
|
|
|
"endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, "
|
|
|
|
"signed = (boolean) { TRUE, FALSE }, "
|
|
|
|
"width = (int) 32, "
|
|
|
|
"depth = (int) 32, "
|
|
|
|
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
|
|
|
|
"audio/x-raw-int, "
|
2006-03-01 18:25:18 +00:00
|
|
|
"endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, "
|
2005-07-06 15:27:17 +00:00
|
|
|
"signed = (boolean) { TRUE, FALSE }, "
|
2007-08-24 15:28:33 +00:00
|
|
|
"width = (int) 32, "
|
|
|
|
"depth = (int) 24, "
|
|
|
|
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
|
|
|
|
"audio/x-raw-int, "
|
|
|
|
"endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, "
|
|
|
|
"signed = (boolean) { TRUE, FALSE }, "
|
|
|
|
"width = (int) 24, "
|
|
|
|
"depth = (int) 24, "
|
|
|
|
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
|
|
|
|
"audio/x-raw-int, "
|
|
|
|
"endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, "
|
|
|
|
"signed = (boolean) { TRUE, FALSE }, "
|
2005-07-06 15:27:17 +00:00
|
|
|
"width = (int) 16, "
|
|
|
|
"depth = (int) 16, "
|
2006-07-02 11:08:58 +00:00
|
|
|
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
|
2005-07-06 15:27:17 +00:00
|
|
|
"audio/x-raw-int, "
|
|
|
|
"signed = (boolean) { TRUE, FALSE }, "
|
|
|
|
"width = (int) 8, "
|
|
|
|
"depth = (int) 8, "
|
2006-07-02 11:08:58 +00:00
|
|
|
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
|
2005-07-06 15:27:17 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static void
|
2007-03-01 16:48:45 +00:00
|
|
|
gst_alsasrc_finalize (GObject * object)
|
2005-07-06 15:27:17 +00:00
|
|
|
{
|
2006-05-18 17:19:39 +00:00
|
|
|
GstAlsaSrc *src = GST_ALSA_SRC (object);
|
|
|
|
|
|
|
|
g_free (src->device);
|
2007-03-01 16:48:45 +00:00
|
|
|
g_mutex_free (src->alsa_lock);
|
2006-05-18 17:19:39 +00:00
|
|
|
|
2007-03-01 16:48:45 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
|
|
|
|
2006-05-18 17:19:39 +00:00
|
|
|
static gboolean
|
|
|
|
gst_alsasrc_interface_supported (GstAlsaSrc * this, GType interface_type)
|
|
|
|
{
|
|
|
|
/* only support this one interface (wrapped by GstImplementsInterface) */
|
|
|
|
g_assert (interface_type == GST_TYPE_MIXER);
|
|
|
|
|
|
|
|
return gst_alsasrc_mixer_supported (this, interface_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_implements_interface_init (GstImplementsInterfaceClass * klass)
|
|
|
|
{
|
|
|
|
klass->supported = (gpointer) gst_alsasrc_interface_supported;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_alsasrc_init_interfaces (GType type)
|
|
|
|
{
|
|
|
|
static const GInterfaceInfo implements_iface_info = {
|
|
|
|
(GInterfaceInitFunc) gst_implements_interface_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
static const GInterfaceInfo mixer_iface_info = {
|
|
|
|
(GInterfaceInitFunc) gst_alsasrc_mixer_interface_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE,
|
|
|
|
&implements_iface_info);
|
|
|
|
g_type_add_interface_static (type, GST_TYPE_MIXER, &mixer_iface_info);
|
|
|
|
|
|
|
|
gst_alsa_type_add_device_property_probe_interface (type);
|
|
|
|
}
|
|
|
|
|
2003-11-16 00:40:01 +00:00
|
|
|
static void
|
2005-07-06 15:27:17 +00:00
|
|
|
gst_alsasrc_class_init (GstAlsaSrcClass * klass)
|
2003-11-16 00:40:01 +00:00
|
|
|
{
|
2005-07-06 15:27:17 +00:00
|
|
|
GObjectClass *gobject_class;
|
2011-04-19 12:11:32 +00:00
|
|
|
GstElementClass *gstelement_class;
|
2005-07-06 15:27:17 +00:00
|
|
|
GstBaseSrcClass *gstbasesrc_class;
|
|
|
|
GstAudioSrcClass *gstaudiosrc_class;
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
2011-04-19 12:11:32 +00:00
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2005-07-06 15:27:17 +00:00
|
|
|
gstbasesrc_class = (GstBaseSrcClass *) klass;
|
|
|
|
gstaudiosrc_class = (GstAudioSrcClass *) klass;
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2009-10-28 00:59:35 +00:00
|
|
|
gobject_class->finalize = gst_alsasrc_finalize;
|
|
|
|
gobject_class->get_property = gst_alsasrc_get_property;
|
|
|
|
gobject_class->set_property = gst_alsasrc_set_property;
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2011-04-19 12:11:32 +00:00
|
|
|
gst_element_class_set_details_simple (gstelement_class,
|
|
|
|
"Audio source (ALSA)", "Source/Audio",
|
|
|
|
"Read from a sound card via ALSA", "Wim Taymans <wim@fluendo.com>");
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&alsasrc_src_factory));
|
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
gstbasesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_alsasrc_getcaps);
|
|
|
|
|
|
|
|
gstaudiosrc_class->open = GST_DEBUG_FUNCPTR (gst_alsasrc_open);
|
2005-08-22 15:11:31 +00:00
|
|
|
gstaudiosrc_class->prepare = GST_DEBUG_FUNCPTR (gst_alsasrc_prepare);
|
|
|
|
gstaudiosrc_class->unprepare = GST_DEBUG_FUNCPTR (gst_alsasrc_unprepare);
|
2005-07-06 15:27:17 +00:00
|
|
|
gstaudiosrc_class->close = GST_DEBUG_FUNCPTR (gst_alsasrc_close);
|
|
|
|
gstaudiosrc_class->read = GST_DEBUG_FUNCPTR (gst_alsasrc_read);
|
|
|
|
gstaudiosrc_class->delay = GST_DEBUG_FUNCPTR (gst_alsasrc_delay);
|
|
|
|
gstaudiosrc_class->reset = GST_DEBUG_FUNCPTR (gst_alsasrc_reset);
|
2005-07-08 11:42:47 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_DEVICE,
|
|
|
|
g_param_spec_string ("device", "Device",
|
|
|
|
"ALSA device, as defined in an asound configuration file",
|
2008-03-22 15:00:53 +00:00
|
|
|
DEFAULT_PROP_DEVICE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2005-08-22 16:50:59 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_DEVICE_NAME,
|
|
|
|
g_param_spec_string ("device-name", "Device name",
|
2006-03-01 18:25:18 +00:00
|
|
|
"Human-readable name of the sound device",
|
2008-03-22 15:00:53 +00:00
|
|
|
DEFAULT_PROP_DEVICE_NAME, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2010-08-18 14:45:37 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_CARD_NAME,
|
|
|
|
g_param_spec_string ("card-name", "Card name",
|
|
|
|
"Human-readable name of the sound card",
|
|
|
|
DEFAULT_PROP_CARD_NAME, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2005-07-08 11:42:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_alsasrc_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstAlsaSrc *src;
|
|
|
|
|
|
|
|
src = GST_ALSA_SRC (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_DEVICE:
|
2006-05-18 17:19:39 +00:00
|
|
|
g_free (src->device);
|
|
|
|
src->device = g_value_dup_string (value);
|
2006-08-16 11:38:52 +00:00
|
|
|
if (src->device == NULL) {
|
|
|
|
src->device = g_strdup (DEFAULT_PROP_DEVICE);
|
|
|
|
}
|
2005-07-08 11:42:47 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_alsasrc_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstAlsaSrc *src;
|
|
|
|
|
|
|
|
src = GST_ALSA_SRC (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_DEVICE:
|
|
|
|
g_value_set_string (value, src->device);
|
|
|
|
break;
|
2005-08-22 16:50:59 +00:00
|
|
|
case PROP_DEVICE_NAME:
|
2007-02-08 15:43:26 +00:00
|
|
|
g_value_take_string (value,
|
|
|
|
gst_alsa_find_device_name (GST_OBJECT_CAST (src),
|
|
|
|
src->device, src->handle, SND_PCM_STREAM_CAPTURE));
|
2005-08-22 16:50:59 +00:00
|
|
|
break;
|
2010-08-18 14:45:37 +00:00
|
|
|
case PROP_CARD_NAME:
|
|
|
|
g_value_take_string (value,
|
|
|
|
gst_alsa_find_card_name (GST_OBJECT_CAST (src),
|
|
|
|
src->device, SND_PCM_STREAM_CAPTURE));
|
|
|
|
break;
|
2005-07-08 11:42:47 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
2004-06-17 14:10:21 +00:00
|
|
|
|
2003-11-16 00:40:01 +00:00
|
|
|
static void
|
2011-04-19 12:11:32 +00:00
|
|
|
gst_alsasrc_init (GstAlsaSrc * alsasrc)
|
2003-11-16 00:40:01 +00:00
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_DEBUG_OBJECT (alsasrc, "initializing");
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2006-03-01 18:25:18 +00:00
|
|
|
alsasrc->device = g_strdup (DEFAULT_PROP_DEVICE);
|
2006-05-16 15:52:17 +00:00
|
|
|
alsasrc->cached_caps = NULL;
|
2007-03-01 16:48:45 +00:00
|
|
|
|
|
|
|
alsasrc->alsa_lock = g_mutex_new ();
|
2005-07-06 15:27:17 +00:00
|
|
|
}
|
2004-06-25 17:11:32 +00:00
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
#define CHECK(call, error) \
|
2005-12-06 19:42:02 +00:00
|
|
|
G_STMT_START { \
|
|
|
|
if ((err = call) < 0) \
|
|
|
|
goto error; \
|
2005-07-06 15:27:17 +00:00
|
|
|
} G_STMT_END;
|
2004-06-25 17:11:32 +00:00
|
|
|
|
2006-05-16 15:52:17 +00:00
|
|
|
|
|
|
|
static GstCaps *
|
|
|
|
gst_alsasrc_getcaps (GstBaseSrc * bsrc)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class;
|
|
|
|
GstPadTemplate *pad_template;
|
|
|
|
GstAlsaSrc *src;
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
src = GST_ALSA_SRC (bsrc);
|
|
|
|
|
|
|
|
if (src->handle == NULL) {
|
|
|
|
GST_DEBUG_OBJECT (src, "device not open, using template caps");
|
|
|
|
return NULL; /* base class will get template caps for us */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src->cached_caps) {
|
|
|
|
GST_LOG_OBJECT (src, "Returning cached caps");
|
|
|
|
return gst_caps_ref (src->cached_caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
element_class = GST_ELEMENT_GET_CLASS (src);
|
|
|
|
pad_template = gst_element_class_get_pad_template (element_class, "src");
|
|
|
|
g_return_val_if_fail (pad_template != NULL, NULL);
|
|
|
|
|
|
|
|
caps = gst_alsa_probe_supported_formats (GST_OBJECT (src), src->handle,
|
|
|
|
gst_pad_template_get_caps (pad_template));
|
|
|
|
|
|
|
|
if (caps) {
|
|
|
|
src->cached_caps = gst_caps_ref (caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_INFO_OBJECT (src, "returning caps %" GST_PTR_FORMAT, caps);
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
static int
|
|
|
|
set_hwparams (GstAlsaSrc * alsa)
|
|
|
|
{
|
|
|
|
guint rrate;
|
2010-08-12 12:26:08 +00:00
|
|
|
gint err;
|
2005-07-06 15:27:17 +00:00
|
|
|
snd_pcm_hw_params_t *params;
|
|
|
|
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_malloc (¶ms);
|
2005-07-06 15:27:17 +00:00
|
|
|
|
|
|
|
/* choose all parameters */
|
|
|
|
CHECK (snd_pcm_hw_params_any (alsa->handle, params), no_config);
|
|
|
|
/* set the interleaved read/write format */
|
|
|
|
CHECK (snd_pcm_hw_params_set_access (alsa->handle, params, alsa->access),
|
|
|
|
wrong_access);
|
|
|
|
/* set the sample format */
|
|
|
|
CHECK (snd_pcm_hw_params_set_format (alsa->handle, params, alsa->format),
|
|
|
|
no_sample_format);
|
|
|
|
/* set the count of channels */
|
|
|
|
CHECK (snd_pcm_hw_params_set_channels (alsa->handle, params, alsa->channels),
|
|
|
|
no_channels);
|
|
|
|
/* set the stream rate */
|
|
|
|
rrate = alsa->rate;
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
|
|
|
CHECK (snd_pcm_hw_params_set_rate_near (alsa->handle, params, &rrate, NULL),
|
2005-07-06 15:27:17 +00:00
|
|
|
no_rate);
|
|
|
|
if (rrate != alsa->rate)
|
|
|
|
goto rate_match;
|
|
|
|
|
|
|
|
if (alsa->buffer_time != -1) {
|
|
|
|
/* set the buffer time */
|
|
|
|
CHECK (snd_pcm_hw_params_set_buffer_time_near (alsa->handle, params,
|
2010-08-12 12:26:08 +00:00
|
|
|
&alsa->buffer_time, NULL), buffer_time);
|
2005-07-06 15:27:17 +00:00
|
|
|
}
|
|
|
|
if (alsa->period_time != -1) {
|
|
|
|
/* set the period time */
|
|
|
|
CHECK (snd_pcm_hw_params_set_period_time_near (alsa->handle, params,
|
2010-08-12 12:26:08 +00:00
|
|
|
&alsa->period_time, NULL), period_time);
|
2004-06-25 17:11:32 +00:00
|
|
|
}
|
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
/* write the parameters to device */
|
|
|
|
CHECK (snd_pcm_hw_params (alsa->handle, params), set_hw_params);
|
2004-06-25 17:11:32 +00:00
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
CHECK (snd_pcm_hw_params_get_buffer_size (params, &alsa->buffer_size),
|
|
|
|
buffer_size);
|
2004-06-25 17:11:32 +00:00
|
|
|
|
2010-08-12 12:26:08 +00:00
|
|
|
CHECK (snd_pcm_hw_params_get_period_size (params, &alsa->period_size, NULL),
|
2005-07-06 15:27:17 +00:00
|
|
|
period_size);
|
2004-06-25 17:11:32 +00:00
|
|
|
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return 0;
|
2004-06-23 18:08:26 +00:00
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
/* ERRORS */
|
|
|
|
no_config:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
2005-07-06 15:27:17 +00:00
|
|
|
("Broken configuration for recording: no configurations available: %s",
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
2005-07-06 15:27:17 +00:00
|
|
|
wrong_access:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Access type not available for recording: %s", snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
no_sample_format:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Sample format not available for recording: %s", snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
2005-07-06 15:27:17 +00:00
|
|
|
no_channels:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
gchar *msg = NULL;
|
|
|
|
|
|
|
|
if ((alsa->channels) == 1)
|
|
|
|
msg = g_strdup (_("Could not open device for recording in mono mode."));
|
|
|
|
if ((alsa->channels) == 2)
|
|
|
|
msg = g_strdup (_("Could not open device for recording in stereo mode."));
|
|
|
|
if ((alsa->channels) > 2)
|
|
|
|
msg =
|
|
|
|
g_strdup_printf (_
|
|
|
|
("Could not open device for recording in %d-channel mode"),
|
|
|
|
alsa->channels);
|
2010-04-08 00:26:09 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, ("%s", msg),
|
|
|
|
("%s", snd_strerror (err)));
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
g_free (msg);
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
2005-07-06 15:27:17 +00:00
|
|
|
no_rate:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
2005-07-06 15:27:17 +00:00
|
|
|
("Rate %iHz not available for recording: %s",
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
alsa->rate, snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
rate_match:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Rate doesn't match (requested %iHz, get %iHz)", alsa->rate, err));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
buffer_time:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
2005-07-06 15:27:17 +00:00
|
|
|
("Unable to set buffer time %i for recording: %s",
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
alsa->buffer_time, snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
buffer_size:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Unable to get buffer size for recording: %s", snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
period_time:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
2005-07-06 15:27:17 +00:00
|
|
|
("Unable to set period time %i for recording: %s", alsa->period_time,
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
period_size:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Unable to get period size for recording: %s", snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
set_hw_params:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Unable to set hw params for recording: %s", snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-06 15:27:17 +00:00
|
|
|
|
2003-11-16 00:40:01 +00:00
|
|
|
static int
|
2005-07-06 15:27:17 +00:00
|
|
|
set_swparams (GstAlsaSrc * alsa)
|
2003-11-16 00:40:01 +00:00
|
|
|
{
|
2005-07-06 15:27:17 +00:00
|
|
|
int err;
|
|
|
|
snd_pcm_sw_params_t *params;
|
|
|
|
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_sw_params_malloc (¶ms);
|
2005-07-06 15:27:17 +00:00
|
|
|
|
|
|
|
/* get the current swparams */
|
|
|
|
CHECK (snd_pcm_sw_params_current (alsa->handle, params), no_config);
|
|
|
|
/* allow the transfer when at least period_size samples can be processed */
|
|
|
|
CHECK (snd_pcm_sw_params_set_avail_min (alsa->handle, params,
|
|
|
|
alsa->period_size), set_avail);
|
2007-03-01 16:48:45 +00:00
|
|
|
/* start the transfer on first read */
|
|
|
|
CHECK (snd_pcm_sw_params_set_start_threshold (alsa->handle, params,
|
|
|
|
0), start_threshold);
|
2008-02-11 20:23:44 +00:00
|
|
|
|
|
|
|
#if GST_CHECK_ALSA_VERSION(1,0,16)
|
|
|
|
/* snd_pcm_sw_params_set_xfer_align() is deprecated, alignment is always 1 */
|
|
|
|
#else
|
2005-07-06 15:27:17 +00:00
|
|
|
/* align all transfers to 1 sample */
|
|
|
|
CHECK (snd_pcm_sw_params_set_xfer_align (alsa->handle, params, 1), set_align);
|
2008-02-11 20:23:44 +00:00
|
|
|
#endif
|
2005-07-06 15:27:17 +00:00
|
|
|
|
|
|
|
/* write the parameters to the recording device */
|
|
|
|
CHECK (snd_pcm_sw_params (alsa->handle, params), set_sw_params);
|
|
|
|
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_sw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
no_config:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Unable to determine current swparams for playback: %s",
|
|
|
|
snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_sw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
2005-07-06 15:27:17 +00:00
|
|
|
start_threshold:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Unable to set start threshold mode for playback: %s",
|
|
|
|
snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_sw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
set_avail:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Unable to set avail min for playback: %s", snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_sw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
|
|
|
}
|
2008-02-11 20:23:44 +00:00
|
|
|
#if !GST_CHECK_ALSA_VERSION(1,0,16)
|
2005-07-06 15:27:17 +00:00
|
|
|
set_align:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Unable to set transfer align for playback: %s", snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_sw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
|
|
|
}
|
2008-02-11 20:23:44 +00:00
|
|
|
#endif
|
2005-07-06 15:27:17 +00:00
|
|
|
set_sw_params:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Unable to set sw params for playback: %s", snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_sw_params_free (params);
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
static gboolean
|
|
|
|
alsasrc_parse_spec (GstAlsaSrc * alsa, GstRingBufferSpec * spec)
|
|
|
|
{
|
|
|
|
switch (spec->type) {
|
|
|
|
case GST_BUFTYPE_LINEAR:
|
|
|
|
alsa->format = snd_pcm_build_linear_format (spec->depth, spec->width,
|
|
|
|
spec->sign ? 0 : 1, spec->bigend ? 1 : 0);
|
|
|
|
break;
|
|
|
|
case GST_BUFTYPE_FLOAT:
|
|
|
|
switch (spec->format) {
|
|
|
|
case GST_FLOAT32_LE:
|
|
|
|
alsa->format = SND_PCM_FORMAT_FLOAT_LE;
|
|
|
|
break;
|
|
|
|
case GST_FLOAT32_BE:
|
|
|
|
alsa->format = SND_PCM_FORMAT_FLOAT_BE;
|
|
|
|
break;
|
|
|
|
case GST_FLOAT64_LE:
|
|
|
|
alsa->format = SND_PCM_FORMAT_FLOAT64_LE;
|
|
|
|
break;
|
|
|
|
case GST_FLOAT64_BE:
|
|
|
|
alsa->format = SND_PCM_FORMAT_FLOAT64_BE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_BUFTYPE_A_LAW:
|
|
|
|
alsa->format = SND_PCM_FORMAT_A_LAW;
|
|
|
|
break;
|
|
|
|
case GST_BUFTYPE_MU_LAW:
|
|
|
|
alsa->format = SND_PCM_FORMAT_MU_LAW;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto error;
|
2003-11-16 00:40:01 +00:00
|
|
|
|
|
|
|
}
|
2005-07-06 15:27:17 +00:00
|
|
|
alsa->rate = spec->rate;
|
|
|
|
alsa->channels = spec->channels;
|
|
|
|
alsa->buffer_time = spec->buffer_time;
|
|
|
|
alsa->period_time = spec->latency_time;
|
|
|
|
alsa->access = SND_PCM_ACCESS_RW_INTERLEAVED;
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
error:
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2003-11-16 00:40:01 +00:00
|
|
|
static gboolean
|
2005-08-22 15:11:31 +00:00
|
|
|
gst_alsasrc_open (GstAudioSrc * asrc)
|
2003-11-16 00:40:01 +00:00
|
|
|
{
|
2005-07-06 15:27:17 +00:00
|
|
|
GstAlsaSrc *alsa;
|
|
|
|
gint err;
|
|
|
|
|
|
|
|
alsa = GST_ALSA_SRC (asrc);
|
|
|
|
|
|
|
|
CHECK (snd_pcm_open (&alsa->handle, alsa->device, SND_PCM_STREAM_CAPTURE,
|
|
|
|
SND_PCM_NONBLOCK), open_error);
|
|
|
|
|
2005-08-22 15:11:31 +00:00
|
|
|
if (!alsa->mixer)
|
|
|
|
alsa->mixer = gst_alsa_mixer_new (alsa->device, GST_ALSA_MIXER_CAPTURE);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
open_error:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
if (err == -EBUSY) {
|
2007-11-03 10:39:21 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, BUSY,
|
|
|
|
(_("Could not open audio device for recording. "
|
|
|
|
"Device is being used by another application.")),
|
|
|
|
("Device '%s' is busy", alsa->device));
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
} else {
|
2007-11-03 10:39:21 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
|
|
|
|
(_("Could not open audio device for recording.")),
|
|
|
|
("Recording open error on device '%s': %s", alsa->device,
|
2006-08-16 11:38:52 +00:00
|
|
|
snd_strerror (err)));
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
}
|
2005-08-22 15:11:31 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_alsasrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
|
|
|
|
{
|
|
|
|
GstAlsaSrc *alsa;
|
|
|
|
gint err;
|
|
|
|
|
|
|
|
alsa = GST_ALSA_SRC (asrc);
|
|
|
|
|
|
|
|
if (!alsasrc_parse_spec (alsa, spec))
|
|
|
|
goto spec_parse;
|
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
CHECK (snd_pcm_nonblock (alsa->handle, 0), non_block);
|
|
|
|
|
|
|
|
CHECK (set_hwparams (alsa), hw_params_failed);
|
|
|
|
CHECK (set_swparams (alsa), sw_params_failed);
|
|
|
|
CHECK (snd_pcm_prepare (alsa->handle), prepare_failed);
|
|
|
|
|
|
|
|
alsa->bytes_per_sample = spec->bytes_per_sample;
|
|
|
|
spec->segsize = alsa->period_size * spec->bytes_per_sample;
|
|
|
|
spec->segtotal = alsa->buffer_size / alsa->period_size;
|
|
|
|
spec->silence_sample[0] = 0;
|
|
|
|
spec->silence_sample[1] = 0;
|
|
|
|
spec->silence_sample[2] = 0;
|
|
|
|
spec->silence_sample[3] = 0;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
spec_parse:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Error parsing spec"));
|
2005-07-06 15:27:17 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
non_block:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Could not set device to blocking: %s", snd_strerror (err)));
|
2005-07-06 15:27:17 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
hw_params_failed:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Setting of hwparams failed: %s", snd_strerror (err)));
|
2005-07-06 15:27:17 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
sw_params_failed:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Setting of swparams failed: %s", snd_strerror (err)));
|
2005-07-06 15:27:17 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
prepare_failed:
|
|
|
|
{
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Prepare failed: %s", snd_strerror (err)));
|
2005-07-06 15:27:17 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
static gboolean
|
2005-08-22 15:11:31 +00:00
|
|
|
gst_alsasrc_unprepare (GstAudioSrc * asrc)
|
2005-07-06 15:27:17 +00:00
|
|
|
{
|
|
|
|
GstAlsaSrc *alsa;
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
alsa = GST_ALSA_SRC (asrc);
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2010-04-04 19:18:04 +00:00
|
|
|
snd_pcm_drop (alsa->handle);
|
|
|
|
snd_pcm_hw_free (alsa->handle);
|
|
|
|
snd_pcm_nonblock (alsa->handle, 1);
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
return TRUE;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2005-08-22 15:11:31 +00:00
|
|
|
static gboolean
|
|
|
|
gst_alsasrc_close (GstAudioSrc * asrc)
|
|
|
|
{
|
|
|
|
GstAlsaSrc *alsa = GST_ALSA_SRC (asrc);
|
|
|
|
|
|
|
|
snd_pcm_close (alsa->handle);
|
2009-07-27 09:29:27 +00:00
|
|
|
alsa->handle = NULL;
|
2005-08-22 15:11:31 +00:00
|
|
|
|
|
|
|
if (alsa->mixer) {
|
|
|
|
gst_alsa_mixer_free (alsa->mixer);
|
|
|
|
alsa->mixer = NULL;
|
|
|
|
}
|
|
|
|
|
2006-05-16 15:52:17 +00:00
|
|
|
gst_caps_replace (&alsa->cached_caps, NULL);
|
|
|
|
|
2005-08-22 15:11:31 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2005-07-06 15:27:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Underrun and suspend recovery
|
|
|
|
*/
|
|
|
|
static gint
|
2006-09-15 09:09:00 +00:00
|
|
|
xrun_recovery (GstAlsaSrc * alsa, snd_pcm_t * handle, gint err)
|
2004-06-23 18:08:26 +00:00
|
|
|
{
|
2006-09-15 09:09:00 +00:00
|
|
|
GST_DEBUG_OBJECT (alsa, "xrun recovery %d", err);
|
2005-07-06 15:27:17 +00:00
|
|
|
|
|
|
|
if (err == -EPIPE) { /* under-run */
|
|
|
|
err = snd_pcm_prepare (handle);
|
|
|
|
if (err < 0)
|
2006-09-15 09:09:00 +00:00
|
|
|
GST_WARNING_OBJECT (alsa,
|
|
|
|
"Can't recovery from underrun, prepare failed: %s",
|
2005-07-06 15:27:17 +00:00
|
|
|
snd_strerror (err));
|
|
|
|
return 0;
|
|
|
|
} else if (err == -ESTRPIPE) {
|
|
|
|
while ((err = snd_pcm_resume (handle)) == -EAGAIN)
|
|
|
|
g_usleep (100); /* wait until the suspend flag is released */
|
|
|
|
|
|
|
|
if (err < 0) {
|
|
|
|
err = snd_pcm_prepare (handle);
|
|
|
|
if (err < 0)
|
2006-09-15 09:09:00 +00:00
|
|
|
GST_WARNING_OBJECT (alsa,
|
|
|
|
"Can't recovery from suspend, prepare failed: %s",
|
2005-07-06 15:27:17 +00:00
|
|
|
snd_strerror (err));
|
2004-06-23 18:08:26 +00:00
|
|
|
}
|
2005-07-06 15:27:17 +00:00
|
|
|
return 0;
|
2004-06-23 18:08:26 +00:00
|
|
|
}
|
2005-07-06 15:27:17 +00:00
|
|
|
return err;
|
2004-06-23 18:08:26 +00:00
|
|
|
}
|
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
static guint
|
|
|
|
gst_alsasrc_read (GstAudioSrc * asrc, gpointer data, guint length)
|
2003-11-16 00:40:01 +00:00
|
|
|
{
|
2005-07-06 15:27:17 +00:00
|
|
|
GstAlsaSrc *alsa;
|
|
|
|
gint err;
|
|
|
|
gint cptr;
|
|
|
|
gint16 *ptr;
|
|
|
|
|
|
|
|
alsa = GST_ALSA_SRC (asrc);
|
|
|
|
|
|
|
|
cptr = length / alsa->bytes_per_sample;
|
|
|
|
ptr = data;
|
|
|
|
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_ALSA_SRC_LOCK (asrc);
|
2005-07-06 15:27:17 +00:00
|
|
|
while (cptr > 0) {
|
|
|
|
if ((err = snd_pcm_readi (alsa->handle, ptr, cptr)) < 0) {
|
|
|
|
if (err == -EAGAIN) {
|
ext/alsa/: Update all error messages. All of them should either use the default translated message, or actually prov...
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
(set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
(gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
(set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
(gst_alsasrc_unprepare), (gst_alsasrc_read):
Update all error messages. All of them should either use
the default translated message, or actually provide a
translatable string.
Make the string for channel count problems meaningful.
2006-01-28 18:22:06 +00:00
|
|
|
GST_DEBUG_OBJECT (asrc, "Read error: %s", snd_strerror (err));
|
2005-07-06 15:27:17 +00:00
|
|
|
continue;
|
2006-09-15 09:09:00 +00:00
|
|
|
} else if (xrun_recovery (alsa, alsa->handle, err) < 0) {
|
2005-07-06 15:27:17 +00:00
|
|
|
goto read_error;
|
|
|
|
}
|
|
|
|
continue;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
ptr += err * alsa->channels;
|
|
|
|
cptr -= err;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_ALSA_SRC_UNLOCK (asrc);
|
|
|
|
|
2010-03-08 10:25:01 +00:00
|
|
|
return length - (cptr * alsa->bytes_per_sample);
|
2004-05-09 17:25:16 +00:00
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
read_error:
|
2004-06-17 14:10:21 +00:00
|
|
|
{
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_ALSA_SRC_UNLOCK (asrc);
|
2005-07-06 15:27:17 +00:00
|
|
|
return length; /* skip one period */
|
|
|
|
}
|
|
|
|
}
|
2004-06-17 14:10:21 +00:00
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
static guint
|
|
|
|
gst_alsasrc_delay (GstAudioSrc * asrc)
|
|
|
|
{
|
|
|
|
GstAlsaSrc *alsa;
|
|
|
|
snd_pcm_sframes_t delay;
|
2007-08-24 15:28:33 +00:00
|
|
|
int res;
|
2004-06-17 14:10:21 +00:00
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
alsa = GST_ALSA_SRC (asrc);
|
2004-06-17 14:10:21 +00:00
|
|
|
|
2007-08-24 15:28:33 +00:00
|
|
|
res = snd_pcm_delay (alsa->handle, &delay);
|
|
|
|
if (G_UNLIKELY (res < 0)) {
|
|
|
|
GST_DEBUG_OBJECT (alsa, "snd_pcm_delay returned %d", res);
|
|
|
|
delay = 0;
|
|
|
|
}
|
2004-06-17 14:10:21 +00:00
|
|
|
|
2006-02-09 11:36:18 +00:00
|
|
|
return CLAMP (delay, 0, alsa->buffer_size);
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-07-06 15:27:17 +00:00
|
|
|
gst_alsasrc_reset (GstAudioSrc * asrc)
|
2003-11-16 00:40:01 +00:00
|
|
|
{
|
2005-07-06 15:27:17 +00:00
|
|
|
GstAlsaSrc *alsa;
|
|
|
|
gint err;
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
alsa = GST_ALSA_SRC (asrc);
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_ALSA_SRC_LOCK (asrc);
|
|
|
|
GST_DEBUG_OBJECT (alsa, "drop");
|
2005-07-06 15:27:17 +00:00
|
|
|
CHECK (snd_pcm_drop (alsa->handle), drop_error);
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_DEBUG_OBJECT (alsa, "prepare");
|
2005-07-06 15:27:17 +00:00
|
|
|
CHECK (snd_pcm_prepare (alsa->handle), prepare_error);
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_DEBUG_OBJECT (alsa, "reset done");
|
|
|
|
GST_ALSA_SRC_UNLOCK (asrc);
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
return;
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2005-07-06 15:27:17 +00:00
|
|
|
/* ERRORS */
|
|
|
|
drop_error:
|
|
|
|
{
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_ERROR_OBJECT (alsa, "alsa-reset: pcm drop error: %s",
|
|
|
|
snd_strerror (err));
|
|
|
|
GST_ALSA_SRC_UNLOCK (asrc);
|
2005-07-06 15:27:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
prepare_error:
|
|
|
|
{
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_ERROR_OBJECT (alsa, "alsa-reset: pcm prepare error: %s",
|
|
|
|
snd_strerror (err));
|
|
|
|
GST_ALSA_SRC_UNLOCK (asrc);
|
2005-07-06 15:27:17 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|