audio: rename internal audio ringbuffer

This commit is contained in:
Wim Taymans 2011-11-11 10:54:39 +01:00
parent ad8f694ec6
commit b81af23992
2 changed files with 166 additions and 153 deletions

View file

@ -74,30 +74,30 @@
GST_DEBUG_CATEGORY_STATIC (gst_audio_sink_debug);
#define GST_CAT_DEFAULT gst_audio_sink_debug
#define GST_TYPE_AUDIORING_BUFFER \
(gst_audioringbuffer_get_type())
#define GST_AUDIORING_BUFFER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIORING_BUFFER,GstAudioRingBuffer))
#define GST_AUDIORING_BUFFER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIORING_BUFFER,GstAudioRingBufferClass))
#define GST_AUDIORING_BUFFER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_AUDIORING_BUFFER, GstAudioRingBufferClass))
#define GST_AUDIORING_BUFFER_CAST(obj) \
((GstAudioRingBuffer *)obj)
#define GST_IS_AUDIORING_BUFFER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIORING_BUFFER))
#define GST_IS_AUDIORING_BUFFER_CLASS(klass)\
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIORING_BUFFER))
#define GST_TYPE_AUDIO_SINK_RING_BUFFER \
(gst_audio_sink_ring_buffer_get_type())
#define GST_AUDIO_SINK_RING_BUFFER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_SINK_RING_BUFFER,GstAudioSinkRingBuffer))
#define GST_AUDIO_SINK_RING_BUFFER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_SINK_RING_BUFFER,GstAudioSinkRingBufferClass))
#define GST_AUDIO_SINK_RING_BUFFER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_AUDIO_SINK_RING_BUFFER, GstAudioSinkRingBufferClass))
#define GST_AUDIO_SINK_RING_BUFFER_CAST(obj) \
((GstAudioSinkRingBuffer *)obj)
#define GST_IS_AUDIO_SINK_RING_BUFFER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_SINK_RING_BUFFER))
#define GST_IS_AUDIO_SINK_RING_BUFFER_CLASS(klass)\
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_SINK_RING_BUFFER))
typedef struct _GstAudioRingBuffer GstAudioRingBuffer;
typedef struct _GstAudioRingBufferClass GstAudioRingBufferClass;
typedef struct _GstAudioSinkRingBuffer GstAudioSinkRingBuffer;
typedef struct _GstAudioSinkRingBufferClass GstAudioSinkRingBufferClass;
#define GST_AUDIORING_BUFFER_GET_COND(buf) (((GstAudioRingBuffer *)buf)->cond)
#define GST_AUDIORING_BUFFER_WAIT(buf) (g_cond_wait (GST_AUDIORING_BUFFER_GET_COND (buf), GST_OBJECT_GET_LOCK (buf)))
#define GST_AUDIORING_BUFFER_SIGNAL(buf) (g_cond_signal (GST_AUDIORING_BUFFER_GET_COND (buf)))
#define GST_AUDIORING_BUFFER_BROADCAST(buf)(g_cond_broadcast (GST_AUDIORING_BUFFER_GET_COND (buf)))
#define GST_AUDIO_SINK_RING_BUFFER_GET_COND(buf) (((GstAudioSinkRingBuffer *)buf)->cond)
#define GST_AUDIO_SINK_RING_BUFFER_WAIT(buf) (g_cond_wait (GST_AUDIO_SINK_RING_BUFFER_GET_COND (buf), GST_OBJECT_GET_LOCK (buf)))
#define GST_AUDIO_SINK_RING_BUFFER_SIGNAL(buf) (g_cond_signal (GST_AUDIO_SINK_RING_BUFFER_GET_COND (buf)))
#define GST_AUDIO_SINK_RING_BUFFER_BROADCAST(buf)(g_cond_broadcast (GST_AUDIO_SINK_RING_BUFFER_GET_COND (buf)))
struct _GstAudioRingBuffer
struct _GstAudioSinkRingBuffer
{
GstRingBuffer object;
@ -107,48 +107,49 @@ struct _GstAudioRingBuffer
GCond *cond;
};
struct _GstAudioRingBufferClass
struct _GstAudioSinkRingBufferClass
{
GstRingBufferClass parent_class;
};
static void gst_audioringbuffer_class_init (GstAudioRingBufferClass * klass);
static void gst_audioringbuffer_init (GstAudioRingBuffer * ringbuffer,
GstAudioRingBufferClass * klass);
static void gst_audioringbuffer_dispose (GObject * object);
static void gst_audioringbuffer_finalize (GObject * object);
static void gst_audio_sink_ring_buffer_class_init (GstAudioSinkRingBufferClass *
klass);
static void gst_audio_sink_ring_buffer_init (GstAudioSinkRingBuffer *
ringbuffer, GstAudioSinkRingBufferClass * klass);
static void gst_audio_sink_ring_buffer_dispose (GObject * object);
static void gst_audio_sink_ring_buffer_finalize (GObject * object);
static GstRingBufferClass *ring_parent_class = NULL;
static gboolean gst_audioringbuffer_open_device (GstRingBuffer * buf);
static gboolean gst_audioringbuffer_close_device (GstRingBuffer * buf);
static gboolean gst_audioringbuffer_acquire (GstRingBuffer * buf,
static gboolean gst_audio_sink_ring_buffer_open_device (GstRingBuffer * buf);
static gboolean gst_audio_sink_ring_buffer_close_device (GstRingBuffer * buf);
static gboolean gst_audio_sink_ring_buffer_acquire (GstRingBuffer * buf,
GstRingBufferSpec * spec);
static gboolean gst_audioringbuffer_release (GstRingBuffer * buf);
static gboolean gst_audioringbuffer_start (GstRingBuffer * buf);
static gboolean gst_audioringbuffer_pause (GstRingBuffer * buf);
static gboolean gst_audioringbuffer_stop (GstRingBuffer * buf);
static guint gst_audioringbuffer_delay (GstRingBuffer * buf);
static gboolean gst_audioringbuffer_activate (GstRingBuffer * buf,
static gboolean gst_audio_sink_ring_buffer_release (GstRingBuffer * buf);
static gboolean gst_audio_sink_ring_buffer_start (GstRingBuffer * buf);
static gboolean gst_audio_sink_ring_buffer_pause (GstRingBuffer * buf);
static gboolean gst_audio_sink_ring_buffer_stop (GstRingBuffer * buf);
static guint gst_audio_sink_ring_buffer_delay (GstRingBuffer * buf);
static gboolean gst_audio_sink_ring_buffer_activate (GstRingBuffer * buf,
gboolean active);
/* ringbuffer abstract base class */
static GType
gst_audioringbuffer_get_type (void)
gst_audio_sink_ring_buffer_get_type (void)
{
static GType ringbuffer_type = 0;
if (!ringbuffer_type) {
static const GTypeInfo ringbuffer_info = {
sizeof (GstAudioRingBufferClass),
sizeof (GstAudioSinkRingBufferClass),
NULL,
NULL,
(GClassInitFunc) gst_audioringbuffer_class_init,
(GClassInitFunc) gst_audio_sink_ring_buffer_class_init,
NULL,
NULL,
sizeof (GstAudioRingBuffer),
sizeof (GstAudioSinkRingBuffer),
0,
(GInstanceInitFunc) gst_audioringbuffer_init,
(GInstanceInitFunc) gst_audio_sink_ring_buffer_init,
NULL
};
@ -160,7 +161,7 @@ gst_audioringbuffer_get_type (void)
}
static void
gst_audioringbuffer_class_init (GstAudioRingBufferClass * klass)
gst_audio_sink_ring_buffer_class_init (GstAudioSinkRingBufferClass * klass)
{
GObjectClass *gobject_class;
GstRingBufferClass *gstringbuffer_class;
@ -170,25 +171,30 @@ gst_audioringbuffer_class_init (GstAudioRingBufferClass * klass)
ring_parent_class = g_type_class_peek_parent (klass);
gobject_class->dispose = gst_audioringbuffer_dispose;
gobject_class->finalize = gst_audioringbuffer_finalize;
gobject_class->dispose = gst_audio_sink_ring_buffer_dispose;
gobject_class->finalize = gst_audio_sink_ring_buffer_finalize;
gstringbuffer_class->open_device =
GST_DEBUG_FUNCPTR (gst_audioringbuffer_open_device);
GST_DEBUG_FUNCPTR (gst_audio_sink_ring_buffer_open_device);
gstringbuffer_class->close_device =
GST_DEBUG_FUNCPTR (gst_audioringbuffer_close_device);
GST_DEBUG_FUNCPTR (gst_audio_sink_ring_buffer_close_device);
gstringbuffer_class->acquire =
GST_DEBUG_FUNCPTR (gst_audioringbuffer_acquire);
GST_DEBUG_FUNCPTR (gst_audio_sink_ring_buffer_acquire);
gstringbuffer_class->release =
GST_DEBUG_FUNCPTR (gst_audioringbuffer_release);
gstringbuffer_class->start = GST_DEBUG_FUNCPTR (gst_audioringbuffer_start);
gstringbuffer_class->pause = GST_DEBUG_FUNCPTR (gst_audioringbuffer_pause);
gstringbuffer_class->resume = GST_DEBUG_FUNCPTR (gst_audioringbuffer_start);
gstringbuffer_class->stop = GST_DEBUG_FUNCPTR (gst_audioringbuffer_stop);
GST_DEBUG_FUNCPTR (gst_audio_sink_ring_buffer_release);
gstringbuffer_class->start =
GST_DEBUG_FUNCPTR (gst_audio_sink_ring_buffer_start);
gstringbuffer_class->pause =
GST_DEBUG_FUNCPTR (gst_audio_sink_ring_buffer_pause);
gstringbuffer_class->resume =
GST_DEBUG_FUNCPTR (gst_audio_sink_ring_buffer_start);
gstringbuffer_class->stop =
GST_DEBUG_FUNCPTR (gst_audio_sink_ring_buffer_stop);
gstringbuffer_class->delay = GST_DEBUG_FUNCPTR (gst_audioringbuffer_delay);
gstringbuffer_class->delay =
GST_DEBUG_FUNCPTR (gst_audio_sink_ring_buffer_delay);
gstringbuffer_class->activate =
GST_DEBUG_FUNCPTR (gst_audioringbuffer_activate);
GST_DEBUG_FUNCPTR (gst_audio_sink_ring_buffer_activate);
}
typedef gint (*WriteFunc) (GstAudioSink * sink, gpointer data, guint length);
@ -203,7 +209,7 @@ audioringbuffer_thread_func (GstRingBuffer * buf)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
GstAudioRingBuffer *abuf = GST_AUDIORING_BUFFER_CAST (buf);
GstAudioSinkRingBuffer *abuf = GST_AUDIO_SINK_RING_BUFFER_CAST (buf);
WriteFunc writefunc;
GstMessage *message;
GValue val = { 0 };
@ -215,7 +221,7 @@ audioringbuffer_thread_func (GstRingBuffer * buf)
GST_OBJECT_LOCK (abuf);
GST_DEBUG_OBJECT (sink, "signal wait");
GST_AUDIORING_BUFFER_SIGNAL (buf);
GST_AUDIO_SINK_RING_BUFFER_SIGNAL (buf);
GST_OBJECT_UNLOCK (abuf);
writefunc = csink->write;
@ -271,9 +277,9 @@ audioringbuffer_thread_func (GstRingBuffer * buf)
continue;
}
GST_DEBUG_OBJECT (sink, "signal wait");
GST_AUDIORING_BUFFER_SIGNAL (buf);
GST_AUDIO_SINK_RING_BUFFER_SIGNAL (buf);
GST_DEBUG_OBJECT (sink, "wait for action");
GST_AUDIORING_BUFFER_WAIT (buf);
GST_AUDIO_SINK_RING_BUFFER_WAIT (buf);
GST_DEBUG_OBJECT (sink, "got signal");
if (!abuf->running)
goto stop_running;
@ -306,8 +312,8 @@ stop_running:
}
static void
gst_audioringbuffer_init (GstAudioRingBuffer * ringbuffer,
GstAudioRingBufferClass * g_class)
gst_audio_sink_ring_buffer_init (GstAudioSinkRingBuffer * ringbuffer,
GstAudioSinkRingBufferClass * g_class)
{
ringbuffer->running = FALSE;
ringbuffer->queuedseg = 0;
@ -316,15 +322,15 @@ gst_audioringbuffer_init (GstAudioRingBuffer * ringbuffer,
}
static void
gst_audioringbuffer_dispose (GObject * object)
gst_audio_sink_ring_buffer_dispose (GObject * object)
{
G_OBJECT_CLASS (ring_parent_class)->dispose (object);
}
static void
gst_audioringbuffer_finalize (GObject * object)
gst_audio_sink_ring_buffer_finalize (GObject * object)
{
GstAudioRingBuffer *ringbuffer = GST_AUDIORING_BUFFER_CAST (object);
GstAudioSinkRingBuffer *ringbuffer = GST_AUDIO_SINK_RING_BUFFER_CAST (object);
g_cond_free (ringbuffer->cond);
@ -332,7 +338,7 @@ gst_audioringbuffer_finalize (GObject * object)
}
static gboolean
gst_audioringbuffer_open_device (GstRingBuffer * buf)
gst_audio_sink_ring_buffer_open_device (GstRingBuffer * buf)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
@ -357,7 +363,7 @@ could_not_open:
}
static gboolean
gst_audioringbuffer_close_device (GstRingBuffer * buf)
gst_audio_sink_ring_buffer_close_device (GstRingBuffer * buf)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
@ -382,7 +388,8 @@ could_not_close:
}
static gboolean
gst_audioringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
gst_audio_sink_ring_buffer_acquire (GstRingBuffer * buf,
GstRingBufferSpec * spec)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
@ -413,14 +420,14 @@ could_not_prepare:
}
static gboolean
gst_audioringbuffer_activate (GstRingBuffer * buf, gboolean active)
gst_audio_sink_ring_buffer_activate (GstRingBuffer * buf, gboolean active)
{
GstAudioSink *sink;
GstAudioRingBuffer *abuf;
GstAudioSinkRingBuffer *abuf;
GError *error = NULL;
sink = GST_AUDIO_SINK (GST_OBJECT_PARENT (buf));
abuf = GST_AUDIORING_BUFFER_CAST (buf);
abuf = GST_AUDIO_SINK_RING_BUFFER_CAST (buf);
if (active) {
abuf->running = TRUE;
@ -434,12 +441,12 @@ gst_audioringbuffer_activate (GstRingBuffer * buf, gboolean active)
GST_DEBUG_OBJECT (sink, "waiting for thread");
/* the object lock is taken */
GST_AUDIORING_BUFFER_WAIT (buf);
GST_AUDIO_SINK_RING_BUFFER_WAIT (buf);
GST_DEBUG_OBJECT (sink, "thread is started");
} else {
abuf->running = FALSE;
GST_DEBUG_OBJECT (sink, "signal wait");
GST_AUDIORING_BUFFER_SIGNAL (buf);
GST_AUDIO_SINK_RING_BUFFER_SIGNAL (buf);
GST_OBJECT_UNLOCK (buf);
@ -463,7 +470,7 @@ thread_failed:
/* function is called with LOCK */
static gboolean
gst_audioringbuffer_release (GstRingBuffer * buf)
gst_audio_sink_ring_buffer_release (GstRingBuffer * buf)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
@ -494,20 +501,20 @@ could_not_unprepare:
}
static gboolean
gst_audioringbuffer_start (GstRingBuffer * buf)
gst_audio_sink_ring_buffer_start (GstRingBuffer * buf)
{
GstAudioSink *sink;
sink = GST_AUDIO_SINK (GST_OBJECT_PARENT (buf));
GST_DEBUG_OBJECT (sink, "start, sending signal");
GST_AUDIORING_BUFFER_SIGNAL (buf);
GST_AUDIO_SINK_RING_BUFFER_SIGNAL (buf);
return TRUE;
}
static gboolean
gst_audioringbuffer_pause (GstRingBuffer * buf)
gst_audio_sink_ring_buffer_pause (GstRingBuffer * buf)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
@ -526,7 +533,7 @@ gst_audioringbuffer_pause (GstRingBuffer * buf)
}
static gboolean
gst_audioringbuffer_stop (GstRingBuffer * buf)
gst_audio_sink_ring_buffer_stop (GstRingBuffer * buf)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
@ -543,7 +550,7 @@ gst_audioringbuffer_stop (GstRingBuffer * buf)
#if 0
if (abuf->running) {
GST_DEBUG_OBJECT (sink, "stop, waiting...");
GST_AUDIORING_BUFFER_WAIT (buf);
GST_AUDIO_SINK_RING_BUFFER_WAIT (buf);
GST_DEBUG_OBJECT (sink, "stopped");
}
#endif
@ -552,7 +559,7 @@ gst_audioringbuffer_stop (GstRingBuffer * buf)
}
static guint
gst_audioringbuffer_delay (GstRingBuffer * buf)
gst_audio_sink_ring_buffer_delay (GstRingBuffer * buf)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
@ -598,7 +605,7 @@ gst_audio_sink_class_init (GstAudioSinkClass * klass)
gstbaseaudiosink_class->create_ringbuffer =
GST_DEBUG_FUNCPTR (gst_audio_sink_create_ringbuffer);
g_type_class_ref (GST_TYPE_AUDIORING_BUFFER);
g_type_class_ref (GST_TYPE_AUDIO_SINK_RING_BUFFER);
}
static void
@ -612,7 +619,7 @@ gst_audio_sink_create_ringbuffer (GstBaseAudioSink * sink)
GstRingBuffer *buffer;
GST_DEBUG_OBJECT (sink, "creating ringbuffer");
buffer = g_object_new (GST_TYPE_AUDIORING_BUFFER, NULL);
buffer = g_object_new (GST_TYPE_AUDIO_SINK_RING_BUFFER, NULL);
GST_DEBUG_OBJECT (sink, "created ringbuffer @%p", buffer);
return buffer;

View file

@ -74,28 +74,28 @@
GST_DEBUG_CATEGORY_STATIC (gst_audio_src_debug);
#define GST_CAT_DEFAULT gst_audio_src_debug
#define GST_TYPE_AUDIORING_BUFFER \
(gst_audioringbuffer_get_type())
#define GST_AUDIORING_BUFFER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIORING_BUFFER,GstAudioRingBuffer))
#define GST_AUDIORING_BUFFER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIORING_BUFFER,GstAudioRingBufferClass))
#define GST_AUDIORING_BUFFER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_AUDIORING_BUFFER, GstAudioRingBufferClass))
#define GST_IS_AUDIORING_BUFFER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIORING_BUFFER))
#define GST_IS_AUDIORING_BUFFER_CLASS(klass)\
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIORING_BUFFER))
#define GST_TYPE_AUDIO_SRC_RING_BUFFER \
(gst_audio_src_ring_buffer_get_type())
#define GST_AUDIO_SRC_RING_BUFFER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_SRC_RING_BUFFER,GstAudioSrcRingBuffer))
#define GST_AUDIO_SRC_RING_BUFFER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_SRC_RING_BUFFER,GstAudioSrcRingBufferClass))
#define GST_AUDIO_SRC_RING_BUFFER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_AUDIO_SRC_RING_BUFFER, GstAudioSrcRingBufferClass))
#define GST_IS_AUDIO_SRC_RING_BUFFER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_SRC_RING_BUFFER))
#define GST_IS_AUDIO_SRC_RING_BUFFER_CLASS(klass)\
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_SRC_RING_BUFFER))
typedef struct _GstAudioRingBuffer GstAudioRingBuffer;
typedef struct _GstAudioRingBufferClass GstAudioRingBufferClass;
typedef struct _GstAudioSrcRingBuffer GstAudioSrcRingBuffer;
typedef struct _GstAudioSrcRingBufferClass GstAudioSrcRingBufferClass;
#define GST_AUDIORING_BUFFER_GET_COND(buf) (((GstAudioRingBuffer *)buf)->cond)
#define GST_AUDIORING_BUFFER_WAIT(buf) (g_cond_wait (GST_AUDIORING_BUFFER_GET_COND (buf), GST_OBJECT_GET_LOCK (buf)))
#define GST_AUDIORING_BUFFER_SIGNAL(buf) (g_cond_signal (GST_AUDIORING_BUFFER_GET_COND (buf)))
#define GST_AUDIORING_BUFFER_BROADCAST(buf)(g_cond_broadcast (GST_AUDIORING_BUFFER_GET_COND (buf)))
#define GST_AUDIO_SRC_RING_BUFFER_GET_COND(buf) (((GstAudioSrcRingBuffer *)buf)->cond)
#define GST_AUDIO_SRC_RING_BUFFER_WAIT(buf) (g_cond_wait (GST_AUDIO_SRC_RING_BUFFER_GET_COND (buf), GST_OBJECT_GET_LOCK (buf)))
#define GST_AUDIO_SRC_RING_BUFFER_SIGNAL(buf) (g_cond_signal (GST_AUDIO_SRC_RING_BUFFER_GET_COND (buf)))
#define GST_AUDIO_SRC_RING_BUFFER_BROADCAST(buf)(g_cond_broadcast (GST_AUDIO_SRC_RING_BUFFER_GET_COND (buf)))
struct _GstAudioRingBuffer
struct _GstAudioSrcRingBuffer
{
GstRingBuffer object;
@ -105,45 +105,46 @@ struct _GstAudioRingBuffer
GCond *cond;
};
struct _GstAudioRingBufferClass
struct _GstAudioSrcRingBufferClass
{
GstRingBufferClass parent_class;
};
static void gst_audioringbuffer_class_init (GstAudioRingBufferClass * klass);
static void gst_audioringbuffer_init (GstAudioRingBuffer * ringbuffer,
GstAudioRingBufferClass * klass);
static void gst_audioringbuffer_dispose (GObject * object);
static void gst_audioringbuffer_finalize (GObject * object);
static void gst_audio_src_ring_buffer_class_init (GstAudioSrcRingBufferClass *
klass);
static void gst_audio_src_ring_buffer_init (GstAudioSrcRingBuffer * ringbuffer,
GstAudioSrcRingBufferClass * klass);
static void gst_audio_src_ring_buffer_dispose (GObject * object);
static void gst_audio_src_ring_buffer_finalize (GObject * object);
static GstRingBufferClass *ring_parent_class = NULL;
static gboolean gst_audioringbuffer_open_device (GstRingBuffer * buf);
static gboolean gst_audioringbuffer_close_device (GstRingBuffer * buf);
static gboolean gst_audioringbuffer_acquire (GstRingBuffer * buf,
static gboolean gst_audio_src_ring_buffer_open_device (GstRingBuffer * buf);
static gboolean gst_audio_src_ring_buffer_close_device (GstRingBuffer * buf);
static gboolean gst_audio_src_ring_buffer_acquire (GstRingBuffer * buf,
GstRingBufferSpec * spec);
static gboolean gst_audioringbuffer_release (GstRingBuffer * buf);
static gboolean gst_audioringbuffer_start (GstRingBuffer * buf);
static gboolean gst_audioringbuffer_stop (GstRingBuffer * buf);
static guint gst_audioringbuffer_delay (GstRingBuffer * buf);
static gboolean gst_audio_src_ring_buffer_release (GstRingBuffer * buf);
static gboolean gst_audio_src_ring_buffer_start (GstRingBuffer * buf);
static gboolean gst_audio_src_ring_buffer_stop (GstRingBuffer * buf);
static guint gst_audio_src_ring_buffer_delay (GstRingBuffer * buf);
/* ringbuffer abstract base class */
static GType
gst_audioringbuffer_get_type (void)
gst_audio_src_ring_buffer_get_type (void)
{
static GType ringbuffer_type = 0;
if (!ringbuffer_type) {
static const GTypeInfo ringbuffer_info = {
sizeof (GstAudioRingBufferClass),
sizeof (GstAudioSrcRingBufferClass),
NULL,
NULL,
(GClassInitFunc) gst_audioringbuffer_class_init,
(GClassInitFunc) gst_audio_src_ring_buffer_class_init,
NULL,
NULL,
sizeof (GstAudioRingBuffer),
sizeof (GstAudioSrcRingBuffer),
0,
(GInstanceInitFunc) gst_audioringbuffer_init,
(GInstanceInitFunc) gst_audio_src_ring_buffer_init,
NULL
};
@ -155,7 +156,7 @@ gst_audioringbuffer_get_type (void)
}
static void
gst_audioringbuffer_class_init (GstAudioRingBufferClass * klass)
gst_audio_src_ring_buffer_class_init (GstAudioSrcRingBufferClass * klass)
{
GObjectClass *gobject_class;
GstRingBufferClass *gstringbuffer_class;
@ -165,22 +166,26 @@ gst_audioringbuffer_class_init (GstAudioRingBufferClass * klass)
ring_parent_class = g_type_class_peek_parent (klass);
gobject_class->dispose = gst_audioringbuffer_dispose;
gobject_class->finalize = gst_audioringbuffer_finalize;
gobject_class->dispose = gst_audio_src_ring_buffer_dispose;
gobject_class->finalize = gst_audio_src_ring_buffer_finalize;
gstringbuffer_class->open_device =
GST_DEBUG_FUNCPTR (gst_audioringbuffer_open_device);
GST_DEBUG_FUNCPTR (gst_audio_src_ring_buffer_open_device);
gstringbuffer_class->close_device =
GST_DEBUG_FUNCPTR (gst_audioringbuffer_close_device);
GST_DEBUG_FUNCPTR (gst_audio_src_ring_buffer_close_device);
gstringbuffer_class->acquire =
GST_DEBUG_FUNCPTR (gst_audioringbuffer_acquire);
GST_DEBUG_FUNCPTR (gst_audio_src_ring_buffer_acquire);
gstringbuffer_class->release =
GST_DEBUG_FUNCPTR (gst_audioringbuffer_release);
gstringbuffer_class->start = GST_DEBUG_FUNCPTR (gst_audioringbuffer_start);
gstringbuffer_class->resume = GST_DEBUG_FUNCPTR (gst_audioringbuffer_start);
gstringbuffer_class->stop = GST_DEBUG_FUNCPTR (gst_audioringbuffer_stop);
GST_DEBUG_FUNCPTR (gst_audio_src_ring_buffer_release);
gstringbuffer_class->start =
GST_DEBUG_FUNCPTR (gst_audio_src_ring_buffer_start);
gstringbuffer_class->resume =
GST_DEBUG_FUNCPTR (gst_audio_src_ring_buffer_start);
gstringbuffer_class->stop =
GST_DEBUG_FUNCPTR (gst_audio_src_ring_buffer_stop);
gstringbuffer_class->delay = GST_DEBUG_FUNCPTR (gst_audioringbuffer_delay);
gstringbuffer_class->delay =
GST_DEBUG_FUNCPTR (gst_audio_src_ring_buffer_delay);
}
typedef guint (*ReadFunc) (GstAudioSrc * src, gpointer data, guint length);
@ -195,7 +200,7 @@ audioringbuffer_thread_func (GstRingBuffer * buf)
{
GstAudioSrc *src;
GstAudioSrcClass *csrc;
GstAudioRingBuffer *abuf = GST_AUDIORING_BUFFER (buf);
GstAudioSrcRingBuffer *abuf = GST_AUDIO_SRC_RING_BUFFER (buf);
ReadFunc readfunc;
GstMessage *message;
GValue val = { 0 };
@ -253,9 +258,9 @@ audioringbuffer_thread_func (GstRingBuffer * buf)
continue;
}
GST_DEBUG_OBJECT (src, "signal wait");
GST_AUDIORING_BUFFER_SIGNAL (buf);
GST_AUDIO_SRC_RING_BUFFER_SIGNAL (buf);
GST_DEBUG_OBJECT (src, "wait for action");
GST_AUDIORING_BUFFER_WAIT (buf);
GST_AUDIO_SRC_RING_BUFFER_WAIT (buf);
GST_DEBUG_OBJECT (src, "got signal");
if (!abuf->running)
goto stop_running;
@ -288,8 +293,8 @@ stop_running:
}
static void
gst_audioringbuffer_init (GstAudioRingBuffer * ringbuffer,
GstAudioRingBufferClass * g_class)
gst_audio_src_ring_buffer_init (GstAudioSrcRingBuffer * ringbuffer,
GstAudioSrcRingBufferClass * g_class)
{
ringbuffer->running = FALSE;
ringbuffer->queuedseg = 0;
@ -298,9 +303,9 @@ gst_audioringbuffer_init (GstAudioRingBuffer * ringbuffer,
}
static void
gst_audioringbuffer_dispose (GObject * object)
gst_audio_src_ring_buffer_dispose (GObject * object)
{
GstAudioRingBuffer *ringbuffer = GST_AUDIORING_BUFFER (object);
GstAudioSrcRingBuffer *ringbuffer = GST_AUDIO_SRC_RING_BUFFER (object);
if (ringbuffer->cond) {
g_cond_free (ringbuffer->cond);
@ -311,13 +316,13 @@ gst_audioringbuffer_dispose (GObject * object)
}
static void
gst_audioringbuffer_finalize (GObject * object)
gst_audio_src_ring_buffer_finalize (GObject * object)
{
G_OBJECT_CLASS (ring_parent_class)->finalize (object);
}
static gboolean
gst_audioringbuffer_open_device (GstRingBuffer * buf)
gst_audio_src_ring_buffer_open_device (GstRingBuffer * buf)
{
GstAudioSrc *src;
GstAudioSrcClass *csrc;
@ -341,7 +346,7 @@ could_not_open:
}
static gboolean
gst_audioringbuffer_close_device (GstRingBuffer * buf)
gst_audio_src_ring_buffer_close_device (GstRingBuffer * buf)
{
GstAudioSrc *src;
GstAudioSrcClass *csrc;
@ -365,11 +370,12 @@ could_not_open:
}
static gboolean
gst_audioringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
gst_audio_src_ring_buffer_acquire (GstRingBuffer * buf,
GstRingBufferSpec * spec)
{
GstAudioSrc *src;
GstAudioSrcClass *csrc;
GstAudioRingBuffer *abuf;
GstAudioSrcRingBuffer *abuf;
gboolean result = FALSE;
src = GST_AUDIO_SRC (GST_OBJECT_PARENT (buf));
@ -384,13 +390,13 @@ gst_audioringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
buf->size = spec->segtotal * spec->segsize;
buf->memory = g_malloc0 (buf->size);
abuf = GST_AUDIORING_BUFFER (buf);
abuf = GST_AUDIO_SRC_RING_BUFFER (buf);
abuf->running = TRUE;
src->thread =
g_thread_create ((GThreadFunc) audioringbuffer_thread_func, buf, TRUE,
NULL);
GST_AUDIORING_BUFFER_WAIT (buf);
GST_AUDIO_SRC_RING_BUFFER_WAIT (buf);
return result;
@ -402,19 +408,19 @@ could_not_open:
/* function is called with LOCK */
static gboolean
gst_audioringbuffer_release (GstRingBuffer * buf)
gst_audio_src_ring_buffer_release (GstRingBuffer * buf)
{
GstAudioSrc *src;
GstAudioSrcClass *csrc;
GstAudioRingBuffer *abuf;
GstAudioSrcRingBuffer *abuf;
gboolean result = FALSE;
src = GST_AUDIO_SRC (GST_OBJECT_PARENT (buf));
csrc = GST_AUDIO_SRC_GET_CLASS (src);
abuf = GST_AUDIORING_BUFFER (buf);
abuf = GST_AUDIO_SRC_RING_BUFFER (buf);
abuf->running = FALSE;
GST_AUDIORING_BUFFER_SIGNAL (buf);
GST_AUDIO_SRC_RING_BUFFER_SIGNAL (buf);
GST_OBJECT_UNLOCK (buf);
/* join the thread */
@ -433,16 +439,16 @@ gst_audioringbuffer_release (GstRingBuffer * buf)
}
static gboolean
gst_audioringbuffer_start (GstRingBuffer * buf)
gst_audio_src_ring_buffer_start (GstRingBuffer * buf)
{
GST_DEBUG ("start, sending signal");
GST_AUDIORING_BUFFER_SIGNAL (buf);
GST_AUDIO_SRC_RING_BUFFER_SIGNAL (buf);
return TRUE;
}
static gboolean
gst_audioringbuffer_stop (GstRingBuffer * buf)
gst_audio_src_ring_buffer_stop (GstRingBuffer * buf)
{
GstAudioSrc *src;
GstAudioSrcClass *csrc;
@ -458,7 +464,7 @@ gst_audioringbuffer_stop (GstRingBuffer * buf)
}
#if 0
GST_DEBUG ("stop, waiting...");
GST_AUDIORING_BUFFER_WAIT (buf);
GST_AUDIO_SRC_RING_BUFFER_WAIT (buf);
GST_DEBUG ("stoped");
#endif
@ -466,7 +472,7 @@ gst_audioringbuffer_stop (GstRingBuffer * buf)
}
static guint
gst_audioringbuffer_delay (GstRingBuffer * buf)
gst_audio_src_ring_buffer_delay (GstRingBuffer * buf)
{
GstAudioSrc *src;
GstAudioSrcClass *csrc;
@ -511,7 +517,7 @@ gst_audio_src_class_init (GstAudioSrcClass * klass)
gstbaseaudiosrc_class->create_ringbuffer =
GST_DEBUG_FUNCPTR (gst_audio_src_create_ringbuffer);
g_type_class_ref (GST_TYPE_AUDIORING_BUFFER);
g_type_class_ref (GST_TYPE_AUDIO_SRC_RING_BUFFER);
}
static void
@ -525,7 +531,7 @@ gst_audio_src_create_ringbuffer (GstBaseAudioSrc * src)
GstRingBuffer *buffer;
GST_DEBUG ("creating ringbuffer");
buffer = g_object_new (GST_TYPE_AUDIORING_BUFFER, NULL);
buffer = g_object_new (GST_TYPE_AUDIO_SRC_RING_BUFFER, NULL);
GST_DEBUG ("created ringbuffer @%p", buffer);
return buffer;