ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2005 Wim Taymans <wim@fluendo.com>
|
2006-05-15 17:17:22 +00:00
|
|
|
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
*
|
2005-07-08 11:42:47 +00:00
|
|
|
* gstalsasink.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
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +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
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2003-11-16 00:40:01 +00:00
|
|
|
*/
|
|
|
|
|
2006-03-01 18:25:18 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-alsasink
|
2017-01-23 19:36:11 +00:00
|
|
|
* @title: alsasink
|
2012-04-13 09:01:03 +00:00
|
|
|
* @see_also: alsasrc
|
2006-03-01 18:25:18 +00:00
|
|
|
*
|
2016-01-25 13:00:30 +00:00
|
|
|
* This element renders audio samples using the ALSA audio API.
|
2008-07-10 21:06:06 +00:00
|
|
|
*
|
2017-01-23 19:36:11 +00:00
|
|
|
* ## Example pipelines
|
2008-07-10 21:06:06 +00:00
|
|
|
* |[
|
2015-05-09 21:33:26 +00:00
|
|
|
* gst-launch-1.0 -v uridecodebin uri=file:///path/to/audio.ogg ! audioconvert ! audioresample ! autoaudiosink
|
2017-01-23 19:36:11 +00:00
|
|
|
* ]|
|
|
|
|
*
|
|
|
|
* Play an Ogg/Vorbis file and output audio via ALSA.
|
|
|
|
*
|
2006-03-01 18:25:18 +00:00
|
|
|
*/
|
|
|
|
|
2003-11-16 00:40:01 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <getopt.h>
|
2005-05-05 15:06:40 +00:00
|
|
|
#include <alsa/asoundlib.h>
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
|
2020-10-16 12:35:04 +00:00
|
|
|
#include "gstalsaelements.h"
|
2005-08-08 10:16:34 +00:00
|
|
|
#include "gstalsa.h"
|
2003-11-16 00:40:01 +00:00
|
|
|
#include "gstalsasink.h"
|
|
|
|
|
2012-04-27 08:19:15 +00:00
|
|
|
#include <gst/audio/gstaudioiec61937.h>
|
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>
|
|
|
|
|
2014-12-01 08:50:24 +00:00
|
|
|
#ifndef ESTRPIPE
|
|
|
|
#define ESTRPIPE EPIPE
|
|
|
|
#endif
|
|
|
|
|
2006-02-03 12:51:47 +00:00
|
|
|
#define DEFAULT_DEVICE "default"
|
|
|
|
#define DEFAULT_DEVICE_NAME ""
|
2010-08-18 14:45:37 +00:00
|
|
|
#define DEFAULT_CARD_NAME ""
|
2008-02-29 18:44:36 +00:00
|
|
|
#define SPDIF_PERIOD_SIZE 1536
|
|
|
|
#define SPDIF_BUFFER_SIZE 15360
|
2006-02-03 12:51:47 +00:00
|
|
|
|
2005-07-08 11:42:47 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_DEVICE,
|
2010-08-18 14:45:37 +00:00
|
|
|
PROP_DEVICE_NAME,
|
|
|
|
PROP_CARD_NAME,
|
|
|
|
PROP_LAST
|
2005-07-08 11:42:47 +00:00
|
|
|
};
|
|
|
|
|
2020-10-16 12:35:04 +00:00
|
|
|
#define _do_init \
|
|
|
|
ret |= alsa_element_init (plugin);
|
2011-04-19 12:11:32 +00:00
|
|
|
#define gst_alsasink_parent_class parent_class
|
2020-10-16 12:35:04 +00:00
|
|
|
G_DEFINE_TYPE (GstAlsaSink, gst_alsasink, GST_TYPE_AUDIO_SINK);
|
|
|
|
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (alsasink, "alsasink", GST_RANK_PRIMARY,
|
|
|
|
GST_TYPE_ALSA_SINK, _do_init);
|
2006-05-18 17:19:39 +00:00
|
|
|
|
2006-01-27 01:36:01 +00:00
|
|
|
static void gst_alsasink_finalise (GObject * object);
|
2005-07-08 11:42:47 +00:00
|
|
|
static void gst_alsasink_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_alsasink_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2011-05-16 10:17:49 +00:00
|
|
|
static GstCaps *gst_alsasink_getcaps (GstBaseSink * bsink, GstCaps * filter);
|
2012-04-27 08:19:15 +00:00
|
|
|
static gboolean gst_alsasink_query (GstBaseSink * bsink, GstQuery * query);
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2005-08-08 16:42:10 +00:00
|
|
|
static gboolean gst_alsasink_open (GstAudioSink * asink);
|
|
|
|
static gboolean gst_alsasink_prepare (GstAudioSink * asink,
|
2011-11-11 10:21:41 +00:00
|
|
|
GstAudioRingBufferSpec * spec);
|
2005-08-08 16:42:10 +00:00
|
|
|
static gboolean gst_alsasink_unprepare (GstAudioSink * asink);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
static gboolean gst_alsasink_close (GstAudioSink * asink);
|
2011-06-21 16:13:48 +00:00
|
|
|
static gint gst_alsasink_write (GstAudioSink * asink, gpointer data,
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
guint length);
|
|
|
|
static guint gst_alsasink_delay (GstAudioSink * asink);
|
2018-06-18 08:49:28 +00:00
|
|
|
static void gst_alsasink_pause (GstAudioSink * asink);
|
|
|
|
static void gst_alsasink_resume (GstAudioSink * asink);
|
|
|
|
static void gst_alsasink_stop (GstAudioSink * asink);
|
2012-04-27 08:19:15 +00:00
|
|
|
static gboolean gst_alsasink_acceptcaps (GstAlsaSink * alsa, GstCaps * caps);
|
|
|
|
static GstBuffer *gst_alsasink_payload (GstAudioBaseSink * sink,
|
|
|
|
GstBuffer * buf);
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2006-05-15 16:46:44 +00:00
|
|
|
static gint output_ref; /* 0 */
|
|
|
|
static snd_output_t *output; /* NULL */
|
2012-01-22 22:52:28 +00:00
|
|
|
static GMutex output_mutex;
|
2006-05-15 16:46:44 +00:00
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
static GstStaticPadTemplate alsasink_sink_factory =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2011-08-18 17:15:03 +00:00
|
|
|
GST_STATIC_CAPS ("audio/x-raw, "
|
2011-12-23 00:54:43 +00:00
|
|
|
"format = (string) " GST_AUDIO_FORMATS_ALL ", "
|
2011-12-31 13:25:09 +00:00
|
|
|
"layout = (string) interleaved, "
|
2007-08-24 15:28:33 +00:00
|
|
|
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
|
2012-04-27 08:19:15 +00:00
|
|
|
PASSTHROUGH_CAPS)
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
);
|
|
|
|
|
2006-01-27 01:36:01 +00:00
|
|
|
static void
|
|
|
|
gst_alsasink_finalise (GObject * object)
|
|
|
|
{
|
|
|
|
GstAlsaSink *sink = GST_ALSA_SINK (object);
|
|
|
|
|
|
|
|
g_free (sink->device);
|
2012-09-10 00:06:51 +00:00
|
|
|
g_mutex_clear (&sink->alsa_lock);
|
2012-11-15 08:31:47 +00:00
|
|
|
g_mutex_clear (&sink->delay_lock);
|
2006-03-15 17:59:05 +00:00
|
|
|
|
2012-01-22 22:52:28 +00:00
|
|
|
g_mutex_lock (&output_mutex);
|
2006-05-15 16:46:44 +00:00
|
|
|
--output_ref;
|
|
|
|
if (output_ref == 0) {
|
|
|
|
snd_output_close (output);
|
|
|
|
output = NULL;
|
|
|
|
}
|
2012-01-22 22:52:28 +00:00
|
|
|
g_mutex_unlock (&output_mutex);
|
2006-05-15 16:46:44 +00:00
|
|
|
|
2006-03-15 17:59:05 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2006-01-27 01:36:01 +00:00
|
|
|
}
|
|
|
|
|
2003-11-16 00:40:01 +00:00
|
|
|
static void
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
gst_alsasink_class_init (GstAlsaSinkClass * klass)
|
2003-11-16 00:40:01 +00:00
|
|
|
{
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
GObjectClass *gobject_class;
|
2011-04-19 12:11:32 +00:00
|
|
|
GstElementClass *gstelement_class;
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
GstBaseSinkClass *gstbasesink_class;
|
2012-04-27 08:19:15 +00:00
|
|
|
GstAudioBaseSinkClass *gstbaseaudiosink_class;
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
GstAudioSinkClass *gstaudiosink_class;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
2011-04-19 12:11:32 +00:00
|
|
|
gstelement_class = (GstElementClass *) klass;
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
gstbasesink_class = (GstBaseSinkClass *) klass;
|
2012-04-27 08:19:15 +00:00
|
|
|
gstbaseaudiosink_class = (GstAudioBaseSinkClass *) klass;
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
gstaudiosink_class = (GstAudioSinkClass *) klass;
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2006-02-16 21:01:23 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2009-10-28 00:59:35 +00:00
|
|
|
gobject_class->finalize = gst_alsasink_finalise;
|
|
|
|
gobject_class->get_property = gst_alsasink_get_property;
|
|
|
|
gobject_class->set_property = gst_alsasink_set_property;
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2012-04-09 23:45:16 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class,
|
2011-04-19 12:11:32 +00:00
|
|
|
"Audio sink (ALSA)", "Sink/Audio",
|
|
|
|
"Output to a sound card via ALSA", "Wim Taymans <wim@fluendo.com>");
|
|
|
|
|
2016-03-03 07:46:24 +00:00
|
|
|
gst_element_class_add_static_pad_template (gstelement_class,
|
|
|
|
&alsasink_sink_factory);
|
2011-04-19 12:11:32 +00:00
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_alsasink_getcaps);
|
2012-04-27 08:19:15 +00:00
|
|
|
gstbasesink_class->query = GST_DEBUG_FUNCPTR (gst_alsasink_query);
|
|
|
|
|
|
|
|
gstbaseaudiosink_class->payload = GST_DEBUG_FUNCPTR (gst_alsasink_payload);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
gstaudiosink_class->open = GST_DEBUG_FUNCPTR (gst_alsasink_open);
|
2005-08-08 16:42:10 +00:00
|
|
|
gstaudiosink_class->prepare = GST_DEBUG_FUNCPTR (gst_alsasink_prepare);
|
|
|
|
gstaudiosink_class->unprepare = GST_DEBUG_FUNCPTR (gst_alsasink_unprepare);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
gstaudiosink_class->close = GST_DEBUG_FUNCPTR (gst_alsasink_close);
|
|
|
|
gstaudiosink_class->write = GST_DEBUG_FUNCPTR (gst_alsasink_write);
|
|
|
|
gstaudiosink_class->delay = GST_DEBUG_FUNCPTR (gst_alsasink_delay);
|
2018-06-18 08:49:28 +00:00
|
|
|
gstaudiosink_class->stop = GST_DEBUG_FUNCPTR (gst_alsasink_stop);
|
|
|
|
gstaudiosink_class->pause = GST_DEBUG_FUNCPTR (gst_alsasink_pause);
|
|
|
|
gstaudiosink_class->resume = GST_DEBUG_FUNCPTR (gst_alsasink_resume);
|
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_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-02-03 12:51:47 +00:00
|
|
|
"Human-readable name of the sound device", DEFAULT_DEVICE_NAME,
|
2008-03-22 15:00:53 +00:00
|
|
|
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_CARD_NAME,
|
2018-11-11 22:03:33 +00:00
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS |
|
|
|
|
GST_PARAM_DOC_SHOW_DEFAULT));
|
2005-07-08 11:42:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_alsasink_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstAlsaSink *sink;
|
|
|
|
|
|
|
|
sink = GST_ALSA_SINK (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_DEVICE:
|
2006-08-16 11:38:52 +00:00
|
|
|
g_free (sink->device);
|
|
|
|
sink->device = g_value_dup_string (value);
|
|
|
|
/* setting NULL restores the default device */
|
|
|
|
if (sink->device == NULL) {
|
|
|
|
sink->device = g_strdup (DEFAULT_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_alsasink_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstAlsaSink *sink;
|
|
|
|
|
|
|
|
sink = GST_ALSA_SINK (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_DEVICE:
|
|
|
|
g_value_set_string (value, sink->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 (sink),
|
|
|
|
sink->device, sink->handle, SND_PCM_STREAM_PLAYBACK));
|
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 (sink),
|
|
|
|
sink->device, SND_PCM_STREAM_PLAYBACK));
|
|
|
|
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
|
|
|
}
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
|
2003-11-16 00:40:01 +00:00
|
|
|
static void
|
2011-04-19 12:11:32 +00:00
|
|
|
gst_alsasink_init (GstAlsaSink * alsasink)
|
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 (alsasink, "initializing alsasink");
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
|
2006-02-03 12:51:47 +00:00
|
|
|
alsasink->device = g_strdup (DEFAULT_DEVICE);
|
2005-10-18 11:07:26 +00:00
|
|
|
alsasink->handle = NULL;
|
2006-02-16 21:01:23 +00:00
|
|
|
alsasink->cached_caps = NULL;
|
2018-06-18 08:49:28 +00:00
|
|
|
alsasink->is_paused = FALSE;
|
|
|
|
alsasink->after_paused = FALSE;
|
|
|
|
alsasink->hw_support_pause = FALSE;
|
2012-09-10 00:06:51 +00:00
|
|
|
g_mutex_init (&alsasink->alsa_lock);
|
2012-11-15 08:31:47 +00:00
|
|
|
g_mutex_init (&alsasink->delay_lock);
|
2006-02-03 12:51:47 +00:00
|
|
|
|
2012-01-22 22:52:28 +00:00
|
|
|
g_mutex_lock (&output_mutex);
|
2006-05-15 16:46:44 +00:00
|
|
|
if (output_ref == 0) {
|
|
|
|
snd_output_stdio_attach (&output, stdout, 0);
|
|
|
|
++output_ref;
|
|
|
|
}
|
2012-01-22 22:52:28 +00:00
|
|
|
g_mutex_unlock (&output_mutex);
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
#define CHECK(call, error) \
|
2012-01-16 11:40:16 +00:00
|
|
|
G_STMT_START { \
|
|
|
|
if ((err = call) < 0) { \
|
|
|
|
GST_WARNING_OBJECT (alsa, "Error %d (%s) calling " #call, err, snd_strerror (err)); \
|
|
|
|
goto error; \
|
|
|
|
} \
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
} G_STMT_END;
|
|
|
|
|
2006-02-16 21:01:23 +00:00
|
|
|
static GstCaps *
|
2011-05-16 10:17:49 +00:00
|
|
|
gst_alsasink_getcaps (GstBaseSink * bsink, GstCaps * filter)
|
2006-02-16 21:01:23 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class;
|
|
|
|
GstPadTemplate *pad_template;
|
|
|
|
GstAlsaSink *sink = GST_ALSA_SINK (bsink);
|
2011-05-17 11:01:39 +00:00
|
|
|
GstCaps *caps, *templ_caps;
|
2006-02-16 21:01:23 +00:00
|
|
|
|
alsasink: fix occasional crash intersecting invalid values
When a pipeline using alsasink and push mode upstream fails
to preroll, the following state will be the case:
- A loop upstream will be PAUSED, pushing a first buffer
- alsasink will be READY, pending PAUSED, because async
On error, the pipeline will switch to NULL. alsasink is in
READY, so goes to NULL immediately. It zeroes its cached
caps. Meanwhile, the upstream loop can cause a caps query,
conccurent with the state change. This will use those cached
caps. If the zeroing happens between the NULL test and the
dereferencing, GStreamer will critical down in the GstValue
code.
Since it appears that such a gap between states (PAUSED
and pushing upstream, and NULL downstream) is expected, we
need to protect the read/write access to the cached caps.
This fixes the critical.
See https://bugzilla.gnome.org/show_bug.cgi?id=731121
2014-06-03 14:10:33 +00:00
|
|
|
GST_OBJECT_LOCK (sink);
|
2006-02-16 21:01:23 +00:00
|
|
|
if (sink->handle == NULL) {
|
alsasink: fix occasional crash intersecting invalid values
When a pipeline using alsasink and push mode upstream fails
to preroll, the following state will be the case:
- A loop upstream will be PAUSED, pushing a first buffer
- alsasink will be READY, pending PAUSED, because async
On error, the pipeline will switch to NULL. alsasink is in
READY, so goes to NULL immediately. It zeroes its cached
caps. Meanwhile, the upstream loop can cause a caps query,
conccurent with the state change. This will use those cached
caps. If the zeroing happens between the NULL test and the
dereferencing, GStreamer will critical down in the GstValue
code.
Since it appears that such a gap between states (PAUSED
and pushing upstream, and NULL downstream) is expected, we
need to protect the read/write access to the cached caps.
This fixes the critical.
See https://bugzilla.gnome.org/show_bug.cgi?id=731121
2014-06-03 14:10:33 +00:00
|
|
|
GST_OBJECT_UNLOCK (sink);
|
2006-02-16 21:01:23 +00:00
|
|
|
GST_DEBUG_OBJECT (sink, "device not open, using template caps");
|
|
|
|
return NULL; /* base class will get template caps for us */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sink->cached_caps) {
|
2012-10-17 23:04:06 +00:00
|
|
|
if (filter) {
|
|
|
|
caps = gst_caps_intersect_full (filter, sink->cached_caps,
|
2011-05-16 10:17:49 +00:00
|
|
|
GST_CAPS_INTERSECT_FIRST);
|
alsasink: fix occasional crash intersecting invalid values
When a pipeline using alsasink and push mode upstream fails
to preroll, the following state will be the case:
- A loop upstream will be PAUSED, pushing a first buffer
- alsasink will be READY, pending PAUSED, because async
On error, the pipeline will switch to NULL. alsasink is in
READY, so goes to NULL immediately. It zeroes its cached
caps. Meanwhile, the upstream loop can cause a caps query,
conccurent with the state change. This will use those cached
caps. If the zeroing happens between the NULL test and the
dereferencing, GStreamer will critical down in the GstValue
code.
Since it appears that such a gap between states (PAUSED
and pushing upstream, and NULL downstream) is expected, we
need to protect the read/write access to the cached caps.
This fixes the critical.
See https://bugzilla.gnome.org/show_bug.cgi?id=731121
2014-06-03 14:10:33 +00:00
|
|
|
GST_OBJECT_UNLOCK (sink);
|
2012-10-17 23:04:06 +00:00
|
|
|
GST_LOG_OBJECT (sink, "Returning cached caps %" GST_PTR_FORMAT " with "
|
|
|
|
"filter %" GST_PTR_FORMAT " applied: %" GST_PTR_FORMAT,
|
|
|
|
sink->cached_caps, filter, caps);
|
|
|
|
return caps;
|
|
|
|
} else {
|
alsasink: fix occasional crash intersecting invalid values
When a pipeline using alsasink and push mode upstream fails
to preroll, the following state will be the case:
- A loop upstream will be PAUSED, pushing a first buffer
- alsasink will be READY, pending PAUSED, because async
On error, the pipeline will switch to NULL. alsasink is in
READY, so goes to NULL immediately. It zeroes its cached
caps. Meanwhile, the upstream loop can cause a caps query,
conccurent with the state change. This will use those cached
caps. If the zeroing happens between the NULL test and the
dereferencing, GStreamer will critical down in the GstValue
code.
Since it appears that such a gap between states (PAUSED
and pushing upstream, and NULL downstream) is expected, we
need to protect the read/write access to the cached caps.
This fixes the critical.
See https://bugzilla.gnome.org/show_bug.cgi?id=731121
2014-06-03 14:10:33 +00:00
|
|
|
caps = gst_caps_ref (sink->cached_caps);
|
|
|
|
GST_OBJECT_UNLOCK (sink);
|
|
|
|
GST_LOG_OBJECT (sink, "Returning cached caps %" GST_PTR_FORMAT, caps);
|
|
|
|
return caps;
|
2012-10-17 23:04:06 +00:00
|
|
|
}
|
2006-02-16 21:01:23 +00:00
|
|
|
}
|
|
|
|
|
2006-03-17 13:11:45 +00:00
|
|
|
element_class = GST_ELEMENT_GET_CLASS (sink);
|
|
|
|
pad_template = gst_element_class_get_pad_template (element_class, "sink");
|
alsasink: fix occasional crash intersecting invalid values
When a pipeline using alsasink and push mode upstream fails
to preroll, the following state will be the case:
- A loop upstream will be PAUSED, pushing a first buffer
- alsasink will be READY, pending PAUSED, because async
On error, the pipeline will switch to NULL. alsasink is in
READY, so goes to NULL immediately. It zeroes its cached
caps. Meanwhile, the upstream loop can cause a caps query,
conccurent with the state change. This will use those cached
caps. If the zeroing happens between the NULL test and the
dereferencing, GStreamer will critical down in the GstValue
code.
Since it appears that such a gap between states (PAUSED
and pushing upstream, and NULL downstream) is expected, we
need to protect the read/write access to the cached caps.
This fixes the critical.
See https://bugzilla.gnome.org/show_bug.cgi?id=731121
2014-06-03 14:10:33 +00:00
|
|
|
if (pad_template == NULL) {
|
|
|
|
GST_OBJECT_UNLOCK (sink);
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-02-16 21:01:23 +00:00
|
|
|
|
2011-05-17 11:01:39 +00:00
|
|
|
templ_caps = gst_pad_template_get_caps (pad_template);
|
2012-05-15 17:21:15 +00:00
|
|
|
caps = gst_alsa_probe_supported_formats (GST_OBJECT (sink), sink->device,
|
|
|
|
sink->handle, templ_caps);
|
2011-05-17 11:01:39 +00:00
|
|
|
gst_caps_unref (templ_caps);
|
2006-02-16 21:01:23 +00:00
|
|
|
|
2006-05-16 15:52:17 +00:00
|
|
|
if (caps) {
|
|
|
|
sink->cached_caps = gst_caps_ref (caps);
|
2006-05-15 17:17:22 +00:00
|
|
|
}
|
|
|
|
|
alsasink: fix occasional crash intersecting invalid values
When a pipeline using alsasink and push mode upstream fails
to preroll, the following state will be the case:
- A loop upstream will be PAUSED, pushing a first buffer
- alsasink will be READY, pending PAUSED, because async
On error, the pipeline will switch to NULL. alsasink is in
READY, so goes to NULL immediately. It zeroes its cached
caps. Meanwhile, the upstream loop can cause a caps query,
conccurent with the state change. This will use those cached
caps. If the zeroing happens between the NULL test and the
dereferencing, GStreamer will critical down in the GstValue
code.
Since it appears that such a gap between states (PAUSED
and pushing upstream, and NULL downstream) is expected, we
need to protect the read/write access to the cached caps.
This fixes the critical.
See https://bugzilla.gnome.org/show_bug.cgi?id=731121
2014-06-03 14:10:33 +00:00
|
|
|
GST_OBJECT_UNLOCK (sink);
|
|
|
|
|
2006-05-16 15:52:17 +00:00
|
|
|
GST_INFO_OBJECT (sink, "returning caps %" GST_PTR_FORMAT, caps);
|
2006-02-16 21:01:23 +00:00
|
|
|
|
2011-05-16 10:17:49 +00:00
|
|
|
if (filter) {
|
|
|
|
GstCaps *intersection;
|
|
|
|
|
|
|
|
intersection =
|
|
|
|
gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
return intersection;
|
|
|
|
} else {
|
|
|
|
return caps;
|
|
|
|
}
|
2006-02-16 21:01:23 +00:00
|
|
|
}
|
|
|
|
|
2012-04-27 08:19:15 +00:00
|
|
|
static gboolean
|
|
|
|
gst_alsasink_acceptcaps (GstAlsaSink * alsa, GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstPad *pad = GST_BASE_SINK (alsa)->sinkpad;
|
|
|
|
GstCaps *pad_caps;
|
|
|
|
GstStructure *st;
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
GstAudioRingBufferSpec spec = { 0 };
|
|
|
|
|
|
|
|
pad_caps = gst_pad_query_caps (pad, caps);
|
|
|
|
if (!pad_caps || gst_caps_is_empty (pad_caps)) {
|
|
|
|
if (pad_caps)
|
|
|
|
gst_caps_unref (pad_caps);
|
|
|
|
ret = FALSE;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
gst_caps_unref (pad_caps);
|
|
|
|
|
|
|
|
/* If we've not got fixed caps, creating a stream might fail, so let's just
|
|
|
|
* return from here with default acceptcaps behaviour */
|
|
|
|
if (!gst_caps_is_fixed (caps))
|
|
|
|
goto done;
|
|
|
|
|
2012-05-08 15:35:45 +00:00
|
|
|
/* parse helper expects this set, so avoid nasty warning
|
|
|
|
* will be set properly later on anyway */
|
|
|
|
spec.latency_time = GST_SECOND;
|
|
|
|
if (!gst_audio_ring_buffer_parse_caps (&spec, caps))
|
2012-04-27 08:19:15 +00:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* Make sure input is framed (one frame per buffer) and can be payloaded */
|
2012-05-08 15:35:45 +00:00
|
|
|
switch (spec.type) {
|
2012-04-27 08:19:15 +00:00
|
|
|
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_AC3:
|
|
|
|
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_EAC3:
|
|
|
|
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_DTS:
|
|
|
|
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG:
|
|
|
|
{
|
|
|
|
gboolean framed = FALSE, parsed = FALSE;
|
|
|
|
st = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
gst_structure_get_boolean (st, "framed", &framed);
|
|
|
|
gst_structure_get_boolean (st, "parsed", &parsed);
|
|
|
|
if ((!framed && !parsed) || gst_audio_iec61937_frame_size (&spec) <= 0)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
default:{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
done:
|
2012-10-20 10:38:55 +00:00
|
|
|
gst_caps_replace (&spec.caps, NULL);
|
2012-04-27 08:19:15 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_alsasink_query (GstBaseSink * sink, GstQuery * query)
|
|
|
|
{
|
|
|
|
GstAlsaSink *alsa = GST_ALSA_SINK (sink);
|
|
|
|
gboolean ret;
|
|
|
|
|
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_ACCEPT_CAPS:
|
|
|
|
{
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
gst_query_parse_accept_caps (query, &caps);
|
|
|
|
ret = gst_alsasink_acceptcaps (alsa, caps);
|
|
|
|
gst_query_set_accept_caps_result (query, ret);
|
|
|
|
ret = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
ret = GST_BASE_SINK_CLASS (parent_class)->query (sink, query);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
static int
|
|
|
|
set_hwparams (GstAlsaSink * alsa)
|
2003-11-16 00:40:01 +00:00
|
|
|
{
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
guint rrate;
|
2010-08-12 12:26:08 +00:00
|
|
|
gint err;
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
snd_pcm_hw_params_t *params;
|
2006-06-16 11:04:21 +00:00
|
|
|
guint period_time, buffer_time;
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_malloc (¶ms);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
|
2008-02-29 18:44:36 +00:00
|
|
|
GST_DEBUG_OBJECT (alsa, "Negotiating to %d channels @ %d Hz (format = %s) "
|
|
|
|
"SPDIF (%d)", alsa->channels, alsa->rate,
|
|
|
|
snd_pcm_format_name (alsa->format), alsa->iec958);
|
2005-08-08 10:16:34 +00:00
|
|
|
|
2006-06-16 11:04:21 +00:00
|
|
|
/* start with requested values, if we cannot configure alsa for those values,
|
|
|
|
* we set these values to -1, which will leave the default alsa values */
|
|
|
|
buffer_time = alsa->buffer_time;
|
|
|
|
period_time = alsa->period_time;
|
|
|
|
|
|
|
|
retry:
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +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 */
|
2008-02-29 18:44:36 +00:00
|
|
|
if (alsa->iec958) {
|
|
|
|
/* Try to use big endian first else fallback to le and swap bytes */
|
|
|
|
if (snd_pcm_hw_params_set_format (alsa->handle, params, alsa->format) < 0) {
|
|
|
|
alsa->format = SND_PCM_FORMAT_S16_LE;
|
|
|
|
alsa->need_swap = TRUE;
|
|
|
|
GST_DEBUG_OBJECT (alsa, "falling back to little endian with swapping");
|
|
|
|
} else {
|
|
|
|
alsa->need_swap = FALSE;
|
|
|
|
}
|
|
|
|
}
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
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),
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
no_rate);
|
|
|
|
|
2010-08-12 12:26:08 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
2006-06-16 11:04:21 +00:00
|
|
|
/* get and dump some limits */
|
|
|
|
{
|
|
|
|
guint min, max;
|
|
|
|
|
2010-08-12 12:26:08 +00:00
|
|
|
snd_pcm_hw_params_get_buffer_time_min (params, &min, NULL);
|
|
|
|
snd_pcm_hw_params_get_buffer_time_max (params, &max, NULL);
|
2006-06-16 11:04:21 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (alsa, "buffer time %u, min %u, max %u",
|
|
|
|
alsa->buffer_time, min, max);
|
|
|
|
|
2010-08-12 12:26:08 +00:00
|
|
|
snd_pcm_hw_params_get_period_time_min (params, &min, NULL);
|
|
|
|
snd_pcm_hw_params_get_period_time_max (params, &max, NULL);
|
2006-06-16 11:04:21 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (alsa, "period time %u, min %u, max %u",
|
|
|
|
alsa->period_time, min, max);
|
|
|
|
|
2010-08-12 12:26:08 +00:00
|
|
|
snd_pcm_hw_params_get_periods_min (params, &min, NULL);
|
|
|
|
snd_pcm_hw_params_get_periods_max (params, &max, NULL);
|
2006-06-16 11:04:21 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (alsa, "periods min %u, max %u", min, max);
|
|
|
|
}
|
2010-08-12 12:26:08 +00:00
|
|
|
#endif
|
2006-06-16 11:04:21 +00:00
|
|
|
|
|
|
|
/* now try to configure the buffer time and period time, if one
|
|
|
|
* of those fail, we fall back to the defaults and emit a warning. */
|
2008-02-29 18:44:36 +00:00
|
|
|
if (buffer_time != -1 && !alsa->iec958) {
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
/* set the buffer time */
|
2006-06-16 11:04:21 +00:00
|
|
|
if ((err = snd_pcm_hw_params_set_buffer_time_near (alsa->handle, params,
|
2010-08-12 12:26:08 +00:00
|
|
|
&buffer_time, NULL)) < 0) {
|
2006-06-16 11:04:21 +00:00
|
|
|
GST_ELEMENT_WARNING (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Unable to set buffer time %i for playback: %s",
|
|
|
|
buffer_time, snd_strerror (err)));
|
|
|
|
/* disable buffer_time the next round */
|
|
|
|
buffer_time = -1;
|
|
|
|
goto retry;
|
|
|
|
}
|
2008-02-13 14:34:55 +00:00
|
|
|
GST_DEBUG_OBJECT (alsa, "buffer time %u", buffer_time);
|
2013-05-29 14:39:17 +00:00
|
|
|
alsa->buffer_time = buffer_time;
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
}
|
2008-02-29 18:44:36 +00:00
|
|
|
if (period_time != -1 && !alsa->iec958) {
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
/* set the period time */
|
2006-06-16 11:04:21 +00:00
|
|
|
if ((err = snd_pcm_hw_params_set_period_time_near (alsa->handle, params,
|
2010-08-12 12:26:08 +00:00
|
|
|
&period_time, NULL)) < 0) {
|
2006-06-16 11:04:21 +00:00
|
|
|
GST_ELEMENT_WARNING (alsa, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Unable to set period time %i for playback: %s",
|
|
|
|
period_time, snd_strerror (err)));
|
|
|
|
/* disable period_time the next round */
|
|
|
|
period_time = -1;
|
|
|
|
goto retry;
|
|
|
|
}
|
2008-02-13 14:34:55 +00:00
|
|
|
GST_DEBUG_OBJECT (alsa, "period time %u", period_time);
|
2013-05-29 14:39:17 +00:00
|
|
|
alsa->period_time = period_time;
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
}
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2008-02-29 18:44:36 +00:00
|
|
|
/* Set buffer size and period size manually for SPDIF */
|
|
|
|
if (G_UNLIKELY (alsa->iec958)) {
|
|
|
|
snd_pcm_uframes_t buffer_size = SPDIF_BUFFER_SIZE;
|
|
|
|
snd_pcm_uframes_t period_size = SPDIF_PERIOD_SIZE;
|
|
|
|
|
|
|
|
CHECK (snd_pcm_hw_params_set_buffer_size_near (alsa->handle, params,
|
|
|
|
&buffer_size), buffer_size);
|
|
|
|
CHECK (snd_pcm_hw_params_set_period_size_near (alsa->handle, params,
|
|
|
|
&period_size, NULL), period_size);
|
|
|
|
}
|
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
/* write the parameters to device */
|
|
|
|
CHECK (snd_pcm_hw_params (alsa->handle, params), set_hw_params);
|
|
|
|
|
2006-06-16 11:04:21 +00:00
|
|
|
/* now get the configured values */
|
2005-05-31 11:22:33 +00:00
|
|
|
CHECK (snd_pcm_hw_params_get_buffer_size (params, &alsa->buffer_size),
|
|
|
|
buffer_size);
|
2010-08-12 12:26:08 +00:00
|
|
|
CHECK (snd_pcm_hw_params_get_period_size (params, &alsa->period_size, NULL),
|
2005-05-31 11:22:33 +00:00
|
|
|
period_size);
|
|
|
|
|
2006-10-05 15:55:21 +00:00
|
|
|
GST_DEBUG_OBJECT (alsa, "buffer size %lu, period size %lu", alsa->buffer_size,
|
2006-06-16 11:04:21 +00:00
|
|
|
alsa->period_size);
|
|
|
|
|
2018-06-18 08:49:28 +00:00
|
|
|
/* Check if hardware supports pause */
|
|
|
|
alsa->hw_support_pause = snd_pcm_hw_params_can_pause (params);
|
|
|
|
GST_DEBUG_OBJECT (alsa, "Hw support pause: %s",
|
|
|
|
alsa->hw_support_pause ? "yes" : "no");
|
|
|
|
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +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),
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
("Broken configuration for playback: 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);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
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 playback: %s", snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +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 playback: %s", snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
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 playback in mono mode."));
|
|
|
|
if ((alsa->channels) == 2)
|
|
|
|
msg = g_strdup (_("Could not open device for playback in stereo mode."));
|
|
|
|
if ((alsa->channels) > 2)
|
|
|
|
msg =
|
|
|
|
g_strdup_printf (_
|
|
|
|
("Could not open device for playback 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);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
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),
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
("Rate %iHz not available for playback: %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)));
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +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 playback: %s", snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +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 playback: %s", snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +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 playback: %s", snd_strerror (err)));
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_hw_params_free (params);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
set_swparams (GstAlsaSink * alsa)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
snd_pcm_sw_params_t *params;
|
|
|
|
|
2007-09-16 01:56:21 +00:00
|
|
|
snd_pcm_sw_params_malloc (¶ms);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
|
|
|
|
/* get the current swparams */
|
|
|
|
CHECK (snd_pcm_sw_params_current (alsa->handle, params), no_config);
|
|
|
|
/* start the transfer when the buffer is almost full: */
|
|
|
|
/* (buffer_size / avail_min) * avail_min */
|
|
|
|
CHECK (snd_pcm_sw_params_set_start_threshold (alsa->handle, params,
|
|
|
|
(alsa->buffer_size / alsa->period_size) * alsa->period_size),
|
|
|
|
start_threshold);
|
|
|
|
|
|
|
|
/* 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);
|
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
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +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
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
|
|
|
|
/* write the parameters to the playback 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);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +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),
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
("Unable to determine current swparams for playback: %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_sw_params_free (params);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
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),
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
("Unable to set start threshold mode for playback: %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_sw_params_free (params);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +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);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return err;
|
|
|
|
}
|
2008-02-11 20:23:44 +00:00
|
|
|
#if !GST_CHECK_ALSA_VERSION(1,0,16)
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +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);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return err;
|
|
|
|
}
|
2008-02-11 20:23:44 +00:00
|
|
|
#endif
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +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);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return err;
|
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
|
2011-11-11 10:21:41 +00:00
|
|
|
alsasink_parse_spec (GstAlsaSink * alsa, GstAudioRingBufferSpec * spec)
|
2003-11-16 00:40:01 +00:00
|
|
|
{
|
2008-02-29 18:44:36 +00:00
|
|
|
/* Initialize our boolean */
|
|
|
|
alsa->iec958 = FALSE;
|
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
switch (spec->type) {
|
2011-12-25 21:38:21 +00:00
|
|
|
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_RAW:
|
2011-08-18 17:15:03 +00:00
|
|
|
switch (GST_AUDIO_INFO_FORMAT (&spec->info)) {
|
|
|
|
case GST_AUDIO_FORMAT_U8:
|
|
|
|
alsa->format = SND_PCM_FORMAT_U8;
|
|
|
|
break;
|
|
|
|
case GST_AUDIO_FORMAT_S8:
|
|
|
|
alsa->format = SND_PCM_FORMAT_S8;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_S16LE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_S16_LE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_S16BE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_S16_BE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_U16LE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_U16_LE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_U16BE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_U16_BE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_S24_32LE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_S24_LE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_S24_32BE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_S24_BE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_U24_32LE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_U24_LE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_U24_32BE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_U24_BE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_S32LE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_S32_LE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_S32BE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_S32_BE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_U32LE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_U32_LE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_U32BE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_U32_BE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_S24LE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_S24_3LE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_S24BE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_S24_3BE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_U24LE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_U24_3LE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_U24BE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_U24_3BE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_S20LE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_S20_3LE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_S20BE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_S20_3BE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_U20LE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_U20_3LE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_U20BE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_U20_3BE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_S18LE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_S18_3LE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_S18BE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_S18_3BE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_U18LE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_U18_3LE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_U18BE:
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_U18_3BE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_F32LE:
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_FLOAT_LE;
|
2004-03-15 19:32:28 +00:00
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_F32BE:
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_FLOAT_BE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_F64LE:
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_FLOAT64_LE;
|
|
|
|
break;
|
2011-09-06 10:06:39 +00:00
|
|
|
case GST_AUDIO_FORMAT_F64BE:
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_FLOAT64_BE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto error;
|
2005-02-08 13:06:41 +00:00
|
|
|
}
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
break;
|
2011-12-25 21:38:21 +00:00
|
|
|
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_A_LAW:
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_A_LAW;
|
|
|
|
break;
|
2011-12-25 21:38:21 +00:00
|
|
|
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MU_LAW:
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_MU_LAW;
|
|
|
|
break;
|
2012-04-27 08:19:15 +00:00
|
|
|
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_AC3:
|
|
|
|
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_EAC3:
|
|
|
|
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_DTS:
|
|
|
|
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG:
|
2008-02-29 18:44:36 +00:00
|
|
|
alsa->format = SND_PCM_FORMAT_S16_BE;
|
2008-03-12 12:39:13 +00:00
|
|
|
alsa->iec958 = TRUE;
|
2008-02-29 18:44:36 +00:00
|
|
|
break;
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
default:
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
}
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->rate = GST_AUDIO_INFO_RATE (&spec->info);
|
|
|
|
alsa->channels = GST_AUDIO_INFO_CHANNELS (&spec->info);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
alsa->buffer_time = spec->buffer_time;
|
|
|
|
alsa->period_time = spec->latency_time;
|
|
|
|
alsa->access = SND_PCM_ACCESS_RW_INTERLEAVED;
|
|
|
|
|
2011-12-20 10:44:27 +00:00
|
|
|
if (spec->type == GST_AUDIO_RING_BUFFER_FORMAT_TYPE_RAW && alsa->channels < 9)
|
|
|
|
gst_audio_ring_buffer_set_channel_positions (GST_AUDIO_BASE_SINK
|
|
|
|
(alsa)->ringbuffer, alsa_position[alsa->channels - 1]);
|
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
error:
|
|
|
|
{
|
|
|
|
return FALSE;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
|
|
|
}
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
|
|
|
|
static gboolean
|
2005-08-08 16:42:10 +00:00
|
|
|
gst_alsasink_open (GstAudioSink * asink)
|
2003-11-16 00:40:01 +00:00
|
|
|
{
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
GstAlsaSink *alsa;
|
|
|
|
gint err;
|
2003-11-16 00:40:01 +00:00
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
alsa = GST_ALSA_SINK (asink);
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2008-11-03 15:30:14 +00:00
|
|
|
/* open in non-blocking mode, we'll use snd_pcm_wait() for space to become
|
|
|
|
* available. */
|
2005-05-25 11:57:45 +00:00
|
|
|
CHECK (snd_pcm_open (&alsa->handle, alsa->device, SND_PCM_STREAM_PLAYBACK,
|
|
|
|
SND_PCM_NONBLOCK), open_error);
|
2007-03-08 12:53:51 +00:00
|
|
|
GST_LOG_OBJECT (alsa, "Opened device %s", alsa->device);
|
2005-05-25 11:57:45 +00:00
|
|
|
|
2005-08-08 16:42:10 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
open_error:
|
|
|
|
{
|
2005-11-10 18:47:20 +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 playback. "
|
|
|
|
"Device is being used by another application.")),
|
|
|
|
("Device '%s' is busy", alsa->device));
|
2005-11-10 18:47:20 +00:00
|
|
|
} else {
|
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_WRITE,
|
2007-11-03 10:39:21 +00:00
|
|
|
(_("Could not open audio device for playback.")),
|
|
|
|
("Playback open error on device '%s': %s", alsa->device,
|
2006-08-16 11:38:52 +00:00
|
|
|
snd_strerror (err)));
|
2005-11-10 18:47:20 +00:00
|
|
|
}
|
2005-08-08 16:42:10 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-11 10:21:41 +00:00
|
|
|
gst_alsasink_prepare (GstAudioSink * asink, GstAudioRingBufferSpec * spec)
|
2005-08-08 16:42:10 +00:00
|
|
|
{
|
|
|
|
GstAlsaSink *alsa;
|
|
|
|
gint err;
|
|
|
|
|
|
|
|
alsa = GST_ALSA_SINK (asink);
|
|
|
|
|
2012-05-15 17:21:15 +00:00
|
|
|
if (alsa->iec958) {
|
2008-02-29 18:44:36 +00:00
|
|
|
snd_pcm_close (alsa->handle);
|
2012-05-15 17:21:15 +00:00
|
|
|
alsa->handle = gst_alsa_open_iec958_pcm (GST_OBJECT (alsa), alsa->device);
|
2008-02-29 18:44:36 +00:00
|
|
|
if (G_UNLIKELY (!alsa->handle)) {
|
|
|
|
goto no_iec958;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-08 16:42:10 +00:00
|
|
|
if (!alsasink_parse_spec (alsa, spec))
|
|
|
|
goto spec_parse;
|
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
CHECK (set_hwparams (alsa), hw_params_failed);
|
|
|
|
CHECK (set_swparams (alsa), sw_params_failed);
|
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
alsa->bpf = GST_AUDIO_INFO_BPF (&spec->info);
|
|
|
|
spec->segsize = alsa->period_size * alsa->bpf;
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
spec->segtotal = alsa->buffer_size / alsa->period_size;
|
|
|
|
|
2008-02-29 18:44:36 +00:00
|
|
|
{
|
|
|
|
snd_output_t *out_buf = NULL;
|
|
|
|
char *msg = NULL;
|
|
|
|
|
|
|
|
snd_output_buffer_open (&out_buf);
|
|
|
|
snd_pcm_dump_hw_setup (alsa->handle, out_buf);
|
|
|
|
snd_output_buffer_string (out_buf, &msg);
|
|
|
|
GST_DEBUG_OBJECT (alsa, "Hardware setup: \n%s", msg);
|
|
|
|
snd_output_close (out_buf);
|
|
|
|
snd_output_buffer_open (&out_buf);
|
|
|
|
snd_pcm_dump_sw_setup (alsa->handle, out_buf);
|
|
|
|
snd_output_buffer_string (out_buf, &msg);
|
|
|
|
GST_DEBUG_OBJECT (alsa, "Software setup: \n%s", msg);
|
|
|
|
snd_output_close (out_buf);
|
|
|
|
}
|
|
|
|
|
2013-10-08 15:07:02 +00:00
|
|
|
#ifdef SND_CHMAP_API_VERSION
|
2016-03-21 09:09:10 +00:00
|
|
|
alsa_detect_channels_mapping (GST_OBJECT (alsa), alsa->handle, spec,
|
|
|
|
alsa->channels, GST_AUDIO_BASE_SINK (alsa)->ringbuffer);
|
2013-10-08 15:07:02 +00:00
|
|
|
#endif /* SND_CHMAP_API_VERSION */
|
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
2008-02-29 18:44:36 +00:00
|
|
|
no_iec958:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_WRITE, (NULL),
|
|
|
|
("Could not open IEC958 (SPDIF) device for playback"));
|
|
|
|
return FALSE;
|
|
|
|
}
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
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"));
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return FALSE;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
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)));
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +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)));
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return FALSE;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
}
|
2003-11-16 00:40:01 +00:00
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
static gboolean
|
2005-08-08 16:42:10 +00:00
|
|
|
gst_alsasink_unprepare (GstAudioSink * asink)
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
{
|
|
|
|
GstAlsaSink *alsa;
|
|
|
|
|
|
|
|
alsa = GST_ALSA_SINK (asink);
|
|
|
|
|
2010-04-04 19:18:04 +00:00
|
|
|
snd_pcm_drop (alsa->handle);
|
|
|
|
snd_pcm_hw_free (alsa->handle);
|
2005-08-08 16:42:10 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_alsasink_close (GstAudioSink * asink)
|
|
|
|
{
|
|
|
|
GstAlsaSink *alsa = GST_ALSA_SINK (asink);
|
|
|
|
|
alsasink: fix occasional crash intersecting invalid values
When a pipeline using alsasink and push mode upstream fails
to preroll, the following state will be the case:
- A loop upstream will be PAUSED, pushing a first buffer
- alsasink will be READY, pending PAUSED, because async
On error, the pipeline will switch to NULL. alsasink is in
READY, so goes to NULL immediately. It zeroes its cached
caps. Meanwhile, the upstream loop can cause a caps query,
conccurent with the state change. This will use those cached
caps. If the zeroing happens between the NULL test and the
dereferencing, GStreamer will critical down in the GstValue
code.
Since it appears that such a gap between states (PAUSED
and pushing upstream, and NULL downstream) is expected, we
need to protect the read/write access to the cached caps.
This fixes the critical.
See https://bugzilla.gnome.org/show_bug.cgi?id=731121
2014-06-03 14:10:33 +00:00
|
|
|
GST_OBJECT_LOCK (asink);
|
2008-02-29 18:44:36 +00:00
|
|
|
if (alsa->handle) {
|
2010-04-04 19:18:04 +00:00
|
|
|
snd_pcm_close (alsa->handle);
|
2008-02-29 18:44:36 +00:00
|
|
|
alsa->handle = NULL;
|
|
|
|
}
|
2006-02-16 21:01:23 +00:00
|
|
|
gst_caps_replace (&alsa->cached_caps, NULL);
|
alsasink: fix occasional crash intersecting invalid values
When a pipeline using alsasink and push mode upstream fails
to preroll, the following state will be the case:
- A loop upstream will be PAUSED, pushing a first buffer
- alsasink will be READY, pending PAUSED, because async
On error, the pipeline will switch to NULL. alsasink is in
READY, so goes to NULL immediately. It zeroes its cached
caps. Meanwhile, the upstream loop can cause a caps query,
conccurent with the state change. This will use those cached
caps. If the zeroing happens between the NULL test and the
dereferencing, GStreamer will critical down in the GstValue
code.
Since it appears that such a gap between states (PAUSED
and pushing upstream, and NULL downstream) is expected, we
need to protect the read/write access to the cached caps.
This fixes the critical.
See https://bugzilla.gnome.org/show_bug.cgi?id=731121
2014-06-03 14:10:33 +00:00
|
|
|
GST_OBJECT_UNLOCK (asink);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Underrun and suspend recovery
|
|
|
|
*/
|
|
|
|
static gint
|
2006-09-15 09:09:00 +00:00
|
|
|
xrun_recovery (GstAlsaSink * alsa, snd_pcm_t * handle, gint err)
|
2003-11-16 00:40:01 +00:00
|
|
|
{
|
2014-06-16 09:46:18 +00:00
|
|
|
GST_WARNING_OBJECT (alsa, "xrun recovery %d: %s", err, g_strerror (-err));
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +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,
|
2014-05-19 12:57:41 +00:00
|
|
|
"Can't recover from underrun, prepare failed: %s",
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
snd_strerror (err));
|
2013-12-09 17:46:14 +00:00
|
|
|
gst_audio_base_sink_report_device_failure (GST_AUDIO_BASE_SINK (alsa));
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
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,
|
2014-05-19 12:57:41 +00:00
|
|
|
"Can't recover from suspend, prepare failed: %s",
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
snd_strerror (err));
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
2013-12-09 17:46:14 +00:00
|
|
|
if (err == 0)
|
|
|
|
gst_audio_base_sink_report_device_failure (GST_AUDIO_BASE_SINK (alsa));
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return 0;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-06-21 16:13:48 +00:00
|
|
|
static gint
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
gst_alsasink_write (GstAudioSink * asink, gpointer data, guint length)
|
|
|
|
{
|
|
|
|
GstAlsaSink *alsa;
|
|
|
|
gint err;
|
|
|
|
gint cptr;
|
2015-10-13 21:32:11 +00:00
|
|
|
guint8 *ptr = data;
|
2003-11-16 00:40:01 +00:00
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
alsa = GST_ALSA_SINK (asink);
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2008-02-29 18:44:36 +00:00
|
|
|
if (alsa->iec958 && alsa->need_swap) {
|
|
|
|
guint i;
|
2015-10-13 21:32:11 +00:00
|
|
|
guint16 *ptr_tmp = (guint16 *) ptr;
|
2008-02-29 18:44:36 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (asink, "swapping bytes");
|
2008-03-12 12:39:13 +00:00
|
|
|
for (i = 0; i < length / 2; i++) {
|
2015-10-13 21:32:11 +00:00
|
|
|
ptr_tmp[i] = GUINT16_SWAP_LE_BE (ptr_tmp[i]);
|
2008-02-29 18:44:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (asink, "received audio samples buffer of %u bytes", length);
|
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
cptr = length / alsa->bpf;
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_ALSA_SINK_LOCK (asink);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
while (cptr > 0) {
|
2008-11-03 15:30:14 +00:00
|
|
|
/* start by doing a blocking wait for free space. Set the timeout
|
|
|
|
* to 4 times the period time */
|
|
|
|
err = snd_pcm_wait (alsa->handle, (4 * alsa->period_time / 1000));
|
|
|
|
if (err < 0) {
|
2009-01-23 10:23:09 +00:00
|
|
|
GST_DEBUG_OBJECT (asink, "wait error, %d", err);
|
2009-08-08 13:54:41 +00:00
|
|
|
} else {
|
2012-11-15 08:31:47 +00:00
|
|
|
GST_DELAY_SINK_LOCK (asink);
|
2008-11-03 15:30:14 +00:00
|
|
|
err = snd_pcm_writei (alsa->handle, ptr, cptr);
|
2012-11-15 08:31:47 +00:00
|
|
|
GST_DELAY_SINK_UNLOCK (asink);
|
2008-11-03 15:30:14 +00:00
|
|
|
}
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2008-02-29 18:44:36 +00:00
|
|
|
GST_DEBUG_OBJECT (asink, "written %d frames out of %d", err, cptr);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
if (err < 0) {
|
2006-02-03 12:51:47 +00:00
|
|
|
GST_DEBUG_OBJECT (asink, "Write error: %s", snd_strerror (err));
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
if (err == -EAGAIN) {
|
2004-03-15 19:32:28 +00:00
|
|
|
continue;
|
2012-12-15 19:36:56 +00:00
|
|
|
} else if (err == -ENODEV) {
|
|
|
|
goto device_disappeared;
|
2006-09-15 09:09:00 +00:00
|
|
|
} else if (xrun_recovery (alsa, alsa->handle, err) < 0) {
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
goto write_error;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
continue;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 18:44:36 +00:00
|
|
|
ptr += snd_pcm_frames_to_bytes (alsa->handle, err);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
cptr -= err;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_ALSA_SINK_UNLOCK (asink);
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
return length - (cptr * alsa->bpf);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
|
|
|
|
write_error:
|
|
|
|
{
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_ALSA_SINK_UNLOCK (asink);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return length; /* skip one period */
|
|
|
|
}
|
2012-12-15 19:36:56 +00:00
|
|
|
device_disappeared:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (asink, RESOURCE, WRITE,
|
|
|
|
(_("Error outputting to audio device. "
|
|
|
|
"The device has been disconnected.")), (NULL));
|
|
|
|
goto write_error;
|
|
|
|
}
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
static guint
|
|
|
|
gst_alsasink_delay (GstAudioSink * asink)
|
2003-11-16 00:40:01 +00:00
|
|
|
{
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
GstAlsaSink *alsa;
|
|
|
|
snd_pcm_sframes_t delay;
|
2018-06-18 08:49:28 +00:00
|
|
|
int res = 0;
|
2003-11-16 00:40:01 +00:00
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
alsa = GST_ALSA_SINK (asink);
|
2003-11-16 00:40:01 +00:00
|
|
|
|
2012-11-15 08:31:47 +00:00
|
|
|
GST_DELAY_SINK_LOCK (asink);
|
2018-06-18 08:49:28 +00:00
|
|
|
if (alsa->is_paused == TRUE) {
|
|
|
|
delay = alsa->pos_in_buffer;
|
|
|
|
alsa->is_paused = FALSE;
|
|
|
|
alsa->after_paused = TRUE;
|
|
|
|
} else {
|
|
|
|
if (alsa->after_paused == TRUE) {
|
|
|
|
delay = alsa->pos_in_buffer;
|
|
|
|
alsa->after_paused = FALSE;
|
|
|
|
} else {
|
|
|
|
res = snd_pcm_delay (alsa->handle, &delay);
|
|
|
|
}
|
|
|
|
}
|
2012-11-15 08:31:47 +00:00
|
|
|
GST_DELAY_SINK_UNLOCK (asink);
|
2007-08-24 15:28:33 +00:00
|
|
|
if (G_UNLIKELY (res < 0)) {
|
2008-02-13 14:34:55 +00:00
|
|
|
/* on errors, report 0 delay */
|
2007-08-24 15:28:33 +00:00
|
|
|
GST_DEBUG_OBJECT (alsa, "snd_pcm_delay returned %d", res);
|
|
|
|
delay = 0;
|
|
|
|
}
|
2008-02-13 14:34:55 +00:00
|
|
|
if (G_UNLIKELY (delay < 0)) {
|
|
|
|
/* make sure we never return a negative delay */
|
|
|
|
GST_WARNING_OBJECT (alsa, "snd_pcm_delay returned negative delay");
|
|
|
|
delay = 0;
|
|
|
|
}
|
2003-11-16 00:40:01 +00:00
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return delay;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
|
|
|
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
static void
|
2018-06-18 08:49:28 +00:00
|
|
|
gst_alsasink_pause (GstAudioSink * asink)
|
|
|
|
{
|
|
|
|
GstAlsaSink *alsa;
|
|
|
|
gint err;
|
|
|
|
snd_pcm_sframes_t delay;
|
|
|
|
|
|
|
|
alsa = GST_ALSA_SINK (asink);
|
|
|
|
|
|
|
|
if (alsa->hw_support_pause == TRUE) {
|
|
|
|
GST_ALSA_SINK_LOCK (asink);
|
|
|
|
snd_pcm_delay (alsa->handle, &delay);
|
|
|
|
alsa->pos_in_buffer = delay;
|
|
|
|
CHECK (snd_pcm_pause (alsa->handle, 1), pause_error);
|
|
|
|
GST_DEBUG_OBJECT (alsa, "pause done");
|
|
|
|
alsa->is_paused = TRUE;
|
|
|
|
GST_ALSA_SINK_UNLOCK (asink);
|
|
|
|
} else {
|
|
|
|
gst_alsasink_stop (asink);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
pause_error:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (alsa, "alsa-pause: pcm pause error: %s",
|
|
|
|
snd_strerror (err));
|
|
|
|
GST_ALSA_SINK_UNLOCK (asink);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_alsasink_resume (GstAudioSink * asink)
|
|
|
|
{
|
|
|
|
GstAlsaSink *alsa;
|
|
|
|
gint err;
|
|
|
|
|
|
|
|
alsa = GST_ALSA_SINK (asink);
|
|
|
|
|
|
|
|
if (alsa->hw_support_pause == TRUE) {
|
|
|
|
GST_ALSA_SINK_LOCK (asink);
|
|
|
|
CHECK (snd_pcm_pause (alsa->handle, 0), resume_error);
|
|
|
|
GST_DEBUG_OBJECT (alsa, "resume done");
|
|
|
|
GST_ALSA_SINK_UNLOCK (asink);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
resume_error:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (alsa, "alsa-resume: pcm resume error: %s",
|
|
|
|
snd_strerror (err));
|
|
|
|
GST_ALSA_SINK_UNLOCK (asink);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_alsasink_stop (GstAudioSink * asink)
|
2003-11-16 00:40:01 +00:00
|
|
|
{
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
GstAlsaSink *alsa;
|
|
|
|
gint err;
|
|
|
|
|
|
|
|
alsa = GST_ALSA_SINK (asink);
|
|
|
|
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_ALSA_SINK_LOCK (asink);
|
2006-02-03 12:51:47 +00:00
|
|
|
GST_DEBUG_OBJECT (alsa, "drop");
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
CHECK (snd_pcm_drop (alsa->handle), drop_error);
|
2006-02-03 12:51:47 +00:00
|
|
|
GST_DEBUG_OBJECT (alsa, "prepare");
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
CHECK (snd_pcm_prepare (alsa->handle), prepare_error);
|
2018-06-18 08:49:28 +00:00
|
|
|
GST_DEBUG_OBJECT (alsa, "stop done");
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_ALSA_SINK_UNLOCK (asink);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
drop_error:
|
|
|
|
{
|
2018-06-18 08:49:28 +00:00
|
|
|
GST_ERROR_OBJECT (alsa, "alsa-stop: pcm drop error: %s",
|
2007-02-15 11:59:41 +00:00
|
|
|
snd_strerror (err));
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_ALSA_SINK_UNLOCK (asink);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return;
|
2004-05-16 02:51:29 +00:00
|
|
|
}
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
prepare_error:
|
|
|
|
{
|
2018-06-18 08:49:28 +00:00
|
|
|
GST_ERROR_OBJECT (alsa, "alsa-stop: pcm prepare error: %s",
|
2007-02-15 11:59:41 +00:00
|
|
|
snd_strerror (err));
|
2007-03-01 16:48:45 +00:00
|
|
|
GST_ALSA_SINK_UNLOCK (asink);
|
ext/alsa/: Implement alsasink with simple open/write/close API.
Original commit message from CVS:
* ext/alsa/Makefile.am:
* ext/alsa/gstalsa.c: (gst_alsa_init), (gst_alsa_get_caps),
(gst_alsa_fixate_to_mimetype), (gst_alsa_fixate_field_nearest_int),
(gst_alsa_link), (gst_alsa_close_audio):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/alsa/gstalsasink.c: (gst_alsasink_get_type),
(gst_alsasink_dispose), (gst_alsasink_base_init),
(gst_alsasink_class_init), (gst_alsasink_init),
(gst_alsasink_getcaps), (set_hwparams), (set_swparams),
(alsasink_parse_spec), (gst_alsasink_open), (gst_alsasink_close),
(xrun_recovery), (gst_alsasink_write), (gst_alsasink_delay),
(gst_alsasink_reset):
* ext/alsa/gstalsasink.h:
Implement alsasink with simple open/write/close API.
Make alsa dir build by disabling compilation of code.
2005-04-28 16:19:06 +00:00
|
|
|
return;
|
2003-11-16 00:40:01 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-27 08:19:15 +00:00
|
|
|
|
|
|
|
static GstBuffer *
|
|
|
|
gst_alsasink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
|
|
|
|
{
|
|
|
|
GstAlsaSink *alsa;
|
|
|
|
|
|
|
|
alsa = GST_ALSA_SINK (sink);
|
|
|
|
|
|
|
|
if (alsa->iec958) {
|
|
|
|
GstBuffer *out;
|
|
|
|
gint framesize;
|
|
|
|
GstMapInfo iinfo, oinfo;
|
|
|
|
|
|
|
|
framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec);
|
|
|
|
if (framesize <= 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
out = gst_buffer_new_and_alloc (framesize);
|
|
|
|
|
|
|
|
gst_buffer_map (buf, &iinfo, GST_MAP_READ);
|
|
|
|
gst_buffer_map (out, &oinfo, GST_MAP_WRITE);
|
|
|
|
|
|
|
|
if (!gst_audio_iec61937_payload (iinfo.data, iinfo.size,
|
2012-09-19 03:22:45 +00:00
|
|
|
oinfo.data, oinfo.size, &sink->ringbuffer->spec, G_BIG_ENDIAN)) {
|
2017-09-25 05:12:33 +00:00
|
|
|
gst_buffer_unmap (buf, &iinfo);
|
|
|
|
gst_buffer_unmap (out, &oinfo);
|
2012-04-27 08:19:15 +00:00
|
|
|
gst_buffer_unref (out);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_buffer_unmap (buf, &iinfo);
|
|
|
|
gst_buffer_unmap (out, &oinfo);
|
|
|
|
|
|
|
|
gst_buffer_copy_into (out, buf, GST_BUFFER_COPY_METADATA, 0, -1);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
return gst_buffer_ref (buf);
|
|
|
|
}
|