mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
ext/alsa/gstalsasink.*: Remove unused dispose function.
Original commit message from CVS: * ext/alsa/gstalsasink.c: (gst_alsasink_class_init), (gst_alsasink_write), (gst_alsasink_reset): * ext/alsa/gstalsasink.h: Remove unused dispose function. Rename lock to not interfere with alsasrc lock. * ext/alsa/gstalsasrc.c: (gst_alsasrc_finalize), (gst_alsasrc_class_init), (gst_alsasrc_init), (set_swparams), (gst_alsasrc_read), (gst_alsasrc_reset): * ext/alsa/gstalsasrc.h: Implement finalize function. Use lock to protect alsa access. Implement _reset. Fine tune sw params.
This commit is contained in:
parent
9b36a57eaf
commit
1d0e1586d8
5 changed files with 59 additions and 40 deletions
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
|||
2007-03-01 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* ext/alsa/gstalsasink.c: (gst_alsasink_class_init),
|
||||
(gst_alsasink_write), (gst_alsasink_reset):
|
||||
* ext/alsa/gstalsasink.h:
|
||||
Remove unused dispose function.
|
||||
Rename lock to not interfere with alsasrc lock.
|
||||
|
||||
* ext/alsa/gstalsasrc.c: (gst_alsasrc_finalize),
|
||||
(gst_alsasrc_class_init), (gst_alsasrc_init), (set_swparams),
|
||||
(gst_alsasrc_read), (gst_alsasrc_reset):
|
||||
* ext/alsa/gstalsasrc.h:
|
||||
Implement finalize function.
|
||||
Use lock to protect alsa access.
|
||||
Implement _reset.
|
||||
Fine tune sw params.
|
||||
|
||||
2007-02-28 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* configure.ac:
|
||||
|
|
|
@ -80,7 +80,6 @@ static void gst_alsasink_init_interfaces (GType type);
|
|||
GST_BOILERPLATE_FULL (GstAlsaSink, gst_alsasink, GstAudioSink,
|
||||
GST_TYPE_AUDIO_SINK, gst_alsasink_init_interfaces);
|
||||
|
||||
static void gst_alsasink_dispose (GObject * object);
|
||||
static void gst_alsasink_finalise (GObject * object);
|
||||
static void gst_alsasink_set_property (GObject * object,
|
||||
guint prop_id, const GValue * value, GParamSpec * pspec);
|
||||
|
@ -133,12 +132,6 @@ static GstStaticPadTemplate alsasink_sink_factory =
|
|||
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
|
||||
);
|
||||
|
||||
static void
|
||||
gst_alsasink_dispose (GObject * object)
|
||||
{
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_alsasink_finalise (GObject * object)
|
||||
{
|
||||
|
@ -191,7 +184,6 @@ gst_alsasink_class_init (GstAlsaSinkClass * klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_alsasink_dispose);
|
||||
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_alsasink_finalise);
|
||||
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_alsasink_get_property);
|
||||
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_alsasink_set_property);
|
||||
|
@ -788,7 +780,7 @@ gst_alsasink_write (GstAudioSink * asink, gpointer data, guint length)
|
|||
cptr = length / alsa->bytes_per_sample;
|
||||
ptr = data;
|
||||
|
||||
GST_ALSA_LOCK (asink);
|
||||
GST_ALSA_SINK_LOCK (asink);
|
||||
while (cptr > 0) {
|
||||
err = snd_pcm_writei (alsa->handle, ptr, cptr);
|
||||
|
||||
|
@ -806,13 +798,13 @@ gst_alsasink_write (GstAudioSink * asink, gpointer data, guint length)
|
|||
ptr += err * alsa->channels;
|
||||
cptr -= err;
|
||||
}
|
||||
GST_ALSA_UNLOCK (asink);
|
||||
GST_ALSA_SINK_UNLOCK (asink);
|
||||
|
||||
return length - cptr;
|
||||
|
||||
write_error:
|
||||
{
|
||||
GST_ALSA_UNLOCK (asink);
|
||||
GST_ALSA_SINK_UNLOCK (asink);
|
||||
return length; /* skip one period */
|
||||
}
|
||||
}
|
||||
|
@ -838,13 +830,13 @@ gst_alsasink_reset (GstAudioSink * asink)
|
|||
|
||||
alsa = GST_ALSA_SINK (asink);
|
||||
|
||||
GST_ALSA_LOCK (asink);
|
||||
GST_ALSA_SINK_LOCK (asink);
|
||||
GST_DEBUG_OBJECT (alsa, "drop");
|
||||
CHECK (snd_pcm_drop (alsa->handle), drop_error);
|
||||
GST_DEBUG_OBJECT (alsa, "prepare");
|
||||
CHECK (snd_pcm_prepare (alsa->handle), prepare_error);
|
||||
GST_DEBUG_OBJECT (alsa, "reset done");
|
||||
GST_ALSA_UNLOCK (asink);
|
||||
GST_ALSA_SINK_UNLOCK (asink);
|
||||
|
||||
return;
|
||||
|
||||
|
@ -853,14 +845,14 @@ drop_error:
|
|||
{
|
||||
GST_ERROR_OBJECT (alsa, "alsa-reset: pcm drop error: %s",
|
||||
snd_strerror (err));
|
||||
GST_ALSA_UNLOCK (asink);
|
||||
GST_ALSA_SINK_UNLOCK (asink);
|
||||
return;
|
||||
}
|
||||
prepare_error:
|
||||
{
|
||||
GST_ERROR_OBJECT (alsa, "alsa-reset: pcm prepare error: %s",
|
||||
snd_strerror (err));
|
||||
GST_ALSA_UNLOCK (asink);
|
||||
GST_ALSA_SINK_UNLOCK (asink);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@ G_BEGIN_DECLS
|
|||
typedef struct _GstAlsaSink GstAlsaSink;
|
||||
typedef struct _GstAlsaSinkClass GstAlsaSinkClass;
|
||||
|
||||
#define GST_ALSA_GET_LOCK(obj) (GST_ALSA_SINK_CAST (obj)->alsa_lock)
|
||||
#define GST_ALSA_LOCK(obj) (g_mutex_lock (GST_ALSA_GET_LOCK (obj)))
|
||||
#define GST_ALSA_UNLOCK(obj) (g_mutex_unlock (GST_ALSA_GET_LOCK (obj)))
|
||||
#define GST_ALSA_SINK_GET_LOCK(obj) (GST_ALSA_SINK_CAST (obj)->alsa_lock)
|
||||
#define GST_ALSA_SINK_LOCK(obj) (g_mutex_lock (GST_ALSA_SINK_GET_LOCK (obj)))
|
||||
#define GST_ALSA_SINK_UNLOCK(obj) (g_mutex_unlock (GST_ALSA_SINK_GET_LOCK (obj)))
|
||||
|
||||
/**
|
||||
* GstAlsaSink:
|
||||
|
|
|
@ -80,7 +80,7 @@ GST_BOILERPLATE_FULL (GstAlsaSrc, gst_alsasrc, GstAudioSrc,
|
|||
|
||||
GST_IMPLEMENT_ALSA_MIXER_METHODS (GstAlsaSrc, gst_alsasrc_mixer);
|
||||
|
||||
static void gst_alsasrc_dispose (GObject * object);
|
||||
static void gst_alsasrc_finalize (GObject * object);
|
||||
static void gst_alsasrc_set_property (GObject * object,
|
||||
guint prop_id, const GValue * value, GParamSpec * pspec);
|
||||
static void gst_alsasrc_get_property (GObject * object,
|
||||
|
@ -133,14 +133,14 @@ static GstStaticPadTemplate alsasrc_src_factory =
|
|||
);
|
||||
|
||||
static void
|
||||
gst_alsasrc_dispose (GObject * object)
|
||||
gst_alsasrc_finalize (GObject * object)
|
||||
{
|
||||
GstAlsaSrc *src = GST_ALSA_SRC (object);
|
||||
|
||||
g_free (src->device);
|
||||
src->device = NULL;
|
||||
g_mutex_free (src->alsa_lock);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -205,7 +205,7 @@ gst_alsasrc_class_init (GstAlsaSrcClass * klass)
|
|||
gstbaseaudiosrc_class = (GstBaseAudioSrcClass *) klass;
|
||||
gstaudiosrc_class = (GstAudioSrcClass *) klass;
|
||||
|
||||
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_alsasrc_dispose);
|
||||
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_alsasrc_finalize);
|
||||
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_alsasrc_get_property);
|
||||
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_alsasrc_set_property);
|
||||
|
||||
|
@ -282,6 +282,8 @@ gst_alsasrc_init (GstAlsaSrc * alsasrc, GstAlsaSrcClass * g_class)
|
|||
|
||||
alsasrc->device = g_strdup (DEFAULT_PROP_DEVICE);
|
||||
alsasrc->cached_caps = NULL;
|
||||
|
||||
alsasrc->alsa_lock = g_mutex_new ();
|
||||
}
|
||||
|
||||
#define CHECK(call, error) \
|
||||
|
@ -470,17 +472,12 @@ set_swparams (GstAlsaSrc * alsa)
|
|||
|
||||
/* 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 */
|
||||
#if 0
|
||||
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);
|
||||
#endif
|
||||
/* start the transfer on first read */
|
||||
CHECK (snd_pcm_sw_params_set_start_threshold (alsa->handle, params,
|
||||
0), start_threshold);
|
||||
/* align all transfers to 1 sample */
|
||||
CHECK (snd_pcm_sw_params_set_xfer_align (alsa->handle, params, 1), set_align);
|
||||
|
||||
|
@ -497,7 +494,6 @@ no_config:
|
|||
snd_strerror (err)));
|
||||
return err;
|
||||
}
|
||||
#if 0
|
||||
start_threshold:
|
||||
{
|
||||
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
||||
|
@ -511,7 +507,6 @@ set_avail:
|
|||
("Unable to set avail min for playback: %s", snd_strerror (err)));
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
set_align:
|
||||
{
|
||||
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
|
||||
|
@ -766,6 +761,7 @@ gst_alsasrc_read (GstAudioSrc * asrc, gpointer data, guint length)
|
|||
cptr = length / alsa->bytes_per_sample;
|
||||
ptr = data;
|
||||
|
||||
GST_ALSA_SRC_LOCK (asrc);
|
||||
while (cptr > 0) {
|
||||
if ((err = snd_pcm_readi (alsa->handle, ptr, cptr)) < 0) {
|
||||
if (err == -EAGAIN) {
|
||||
|
@ -780,10 +776,13 @@ gst_alsasrc_read (GstAudioSrc * asrc, gpointer data, guint length)
|
|||
ptr += err * alsa->channels;
|
||||
cptr -= err;
|
||||
}
|
||||
GST_ALSA_SRC_UNLOCK (asrc);
|
||||
|
||||
return length - cptr;
|
||||
|
||||
read_error:
|
||||
{
|
||||
GST_ALSA_SRC_UNLOCK (asrc);
|
||||
return length; /* skip one period */
|
||||
}
|
||||
}
|
||||
|
@ -804,30 +803,34 @@ gst_alsasrc_delay (GstAudioSrc * asrc)
|
|||
static void
|
||||
gst_alsasrc_reset (GstAudioSrc * asrc)
|
||||
{
|
||||
|
||||
#if 0
|
||||
GstAlsaSrc *alsa;
|
||||
gint err;
|
||||
|
||||
alsa = GST_ALSA_SRC (asrc);
|
||||
|
||||
GST_ALSA_SRC_LOCK (asrc);
|
||||
GST_DEBUG_OBJECT (alsa, "drop");
|
||||
CHECK (snd_pcm_drop (alsa->handle), drop_error);
|
||||
GST_DEBUG_OBJECT (alsa, "prepare");
|
||||
CHECK (snd_pcm_prepare (alsa->handle), prepare_error);
|
||||
GST_DEBUG_OBJECT (alsa, "reset done");
|
||||
GST_ALSA_SRC_UNLOCK (asrc);
|
||||
|
||||
return;
|
||||
|
||||
/* ERRORS */
|
||||
drop_error:
|
||||
{
|
||||
GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
|
||||
("alsa-reset: pcm drop error: %s", snd_strerror (err)), (NULL));
|
||||
GST_ERROR_OBJECT (alsa, "alsa-reset: pcm drop error: %s",
|
||||
snd_strerror (err));
|
||||
GST_ALSA_SRC_UNLOCK (asrc);
|
||||
return;
|
||||
}
|
||||
prepare_error:
|
||||
{
|
||||
GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
|
||||
("alsa-reset: pcm prepare error: %s", snd_strerror (err)), (NULL));
|
||||
GST_ERROR_OBJECT (alsa, "alsa-reset: pcm prepare error: %s",
|
||||
snd_strerror (err));
|
||||
GST_ALSA_SRC_UNLOCK (asrc);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -34,6 +34,11 @@ G_BEGIN_DECLS
|
|||
#define GST_ALSA_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_SRC,GstAlsaSrcClass))
|
||||
#define GST_IS_ALSA_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_SRC))
|
||||
#define GST_IS_ALSA_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_SRC))
|
||||
#define GST_ALSA_SRC_CAST(obj) ((GstAlsaSrc *)(obj))
|
||||
|
||||
#define GST_ALSA_SRC_GET_LOCK(obj) (GST_ALSA_SRC_CAST (obj)->alsa_lock)
|
||||
#define GST_ALSA_SRC_LOCK(obj) (g_mutex_lock (GST_ALSA_SRC_GET_LOCK (obj)))
|
||||
#define GST_ALSA_SRC_UNLOCK(obj) (g_mutex_unlock (GST_ALSA_SRC_GET_LOCK (obj)))
|
||||
|
||||
typedef struct _GstAlsaSrc GstAlsaSrc;
|
||||
typedef struct _GstAlsaSrcClass GstAlsaSrcClass;
|
||||
|
@ -66,6 +71,8 @@ struct _GstAlsaSrc {
|
|||
snd_pcm_uframes_t period_size;
|
||||
|
||||
GstAlsaMixer *mixer;
|
||||
|
||||
GMutex *alsa_lock;
|
||||
};
|
||||
|
||||
struct _GstAlsaSrcClass {
|
||||
|
|
Loading…
Reference in a new issue