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

View file

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