GstAudioClock
GstAudioClockGetTimeFunc
gst_audio_clock_new
-gst_audio_clock_new_full
gst_audio_clock_adjust
gst_audio_clock_get_time
gst_audio_clock_reset
<SECTION>
<FILE>gstringbuffer</FILE>
<INCLUDE>gst/audio/gstringbuffer.h</INCLUDE>
-GstRingBuffer
-GstRingBufferClass
-GstRingBufferSpec
-GstRingBufferCallback
-GstRingBufferSegState
-GstRingBufferState
+GstAudioRingBuffer
+GstAudioRingBufferClass
+GstAudioRingBufferSpec
+GstAudioRingBufferCallback
+GstAudioRingBufferSegState
+GstAudioRingBufferState
GstBufferFormatType
-GST_RING_BUFFER_BROADCAST
-GST_RING_BUFFER_GET_COND
-GST_RING_BUFFER_SIGNAL
-GST_RING_BUFFER_WAIT
+GST_AUDIO_RING_BUFFER_BROADCAST
+GST_AUDIO_RING_BUFFER_GET_COND
+GST_AUDIO_RING_BUFFER_SIGNAL
+GST_AUDIO_RING_BUFFER_WAIT
-gst_ring_buffer_set_callback
+gst_audio_ring_buffer_set_callback
-gst_ring_buffer_acquire
-gst_ring_buffer_release
-gst_ring_buffer_is_acquired
+gst_audio_ring_buffer_acquire
+gst_audio_ring_buffer_release
+gst_audio_ring_buffer_is_acquired
-gst_ring_buffer_activate
-gst_ring_buffer_is_active
+gst_audio_ring_buffer_activate
+gst_audio_ring_buffer_is_active
-gst_ring_buffer_start
-gst_ring_buffer_pause
-gst_ring_buffer_stop
+gst_audio_ring_buffer_start
+gst_audio_ring_buffer_pause
+gst_audio_ring_buffer_stop
-gst_ring_buffer_delay
-gst_ring_buffer_samples_done
-gst_ring_buffer_set_sample
-gst_ring_buffer_commit
-gst_ring_buffer_commit_full
-gst_ring_buffer_convert
+gst_audio_ring_buffer_delay
+gst_audio_ring_buffer_samples_done
+gst_audio_ring_buffer_set_sample
+gst_audio_ring_buffer_commit
+gst_audio_ring_buffer_commit_full
+gst_audio_ring_buffer_convert
-gst_ring_buffer_prepare_read
-gst_ring_buffer_read
-gst_ring_buffer_clear
-gst_ring_buffer_clear_all
-gst_ring_buffer_advance
+gst_audio_ring_buffer_prepare_read
+gst_audio_ring_buffer_read
+gst_audio_ring_buffer_clear
+gst_audio_ring_buffer_clear_all
+gst_audio_ring_buffer_advance
-gst_ring_buffer_close_device
-gst_ring_buffer_open_device
-gst_ring_buffer_device_is_open
+gst_audio_ring_buffer_close_device
+gst_audio_ring_buffer_open_device
+gst_audio_ring_buffer_device_is_open
-gst_ring_buffer_may_start
-gst_ring_buffer_parse_caps
-gst_ring_buffer_set_flushing
+gst_audio_ring_buffer_may_start
+gst_audio_ring_buffer_parse_caps
+gst_audio_ring_buffer_set_flushing
<SUBSECTION Standard>
-GST_TYPE_RING_BUFFER
-GST_RING_BUFFER
-GST_RING_BUFFER_CLASS
-GST_RING_BUFFER_GET_CLASS
-GST_IS_RING_BUFFER
-GST_IS_RING_BUFFER_CLASS
-GST_RING_BUFFER_CAST
-gst_ring_buffer_get_type
-GST_TYPE_RING_BUFFER_SEG_STATE
-gst_ring_buffer_seg_state_get_type
-GST_TYPE_RING_BUFFER_STATE
-gst_ring_buffer_state_get_type
+GST_TYPE_AUDIO_RING_BUFFER
+GST_AUDIO_RING_BUFFER
+GST_AUDIO_RING_BUFFER_CLASS
+GST_AUDIO_RING_BUFFER_GET_CLASS
+GST_IS_AUDIO_RING_BUFFER
+GST_IS_AUDIO_RING_BUFFER_CLASS
+GST_AUDIO_RING_BUFFER_CAST
+gst_audio_ring_buffer_get_type
+GST_TYPE_AUDIO_RING_BUFFER_SEG_STATE
+gst_audio_ring_buffer_seg_state_get_type
+GST_TYPE_AUDIO_RING_BUFFER_STATE
+gst_audio_ring_buffer_state_get_type
<SUBSECTION Private>
-gst_ring_buffer_debug_spec_buff
-gst_ring_buffer_debug_spec_caps
+gst_audio_ring_buffer_debug_spec_buff
+gst_audio_ring_buffer_debug_spec_caps
</SECTION>
<SECTION>
#include <gst/audio/gstbaseaudiosrc.h>
gst_base_audio_src_get_type
#include <gst/audio/gstringbuffer.h>
-gst_ring_buffer_get_type
+gst_audio_ring_buffer_get_type
#include <gst/cdda/gstcddabasesrc.h>
static gboolean gst_alsasink_open (GstAudioSink * asink);
static gboolean gst_alsasink_prepare (GstAudioSink * asink,
- GstRingBufferSpec * spec);
+ GstAudioRingBufferSpec * spec);
static gboolean gst_alsasink_unprepare (GstAudioSink * asink);
static gboolean gst_alsasink_close (GstAudioSink * asink);
static gint gst_alsasink_write (GstAudioSink * asink, gpointer data,
}
static gboolean
-alsasink_parse_spec (GstAlsaSink * alsa, GstRingBufferSpec * spec)
+alsasink_parse_spec (GstAlsaSink * alsa, GstAudioRingBufferSpec * spec)
{
/* Initialize our boolean */
alsa->iec958 = FALSE;
}
static gboolean
-gst_alsasink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec)
+gst_alsasink_prepare (GstAudioSink * asink, GstAudioRingBufferSpec * spec)
{
GstAlsaSink *alsa;
gint err;
static gboolean gst_alsasrc_open (GstAudioSrc * asrc);
static gboolean gst_alsasrc_prepare (GstAudioSrc * asrc,
- GstRingBufferSpec * spec);
+ GstAudioRingBufferSpec * spec);
static gboolean gst_alsasrc_unprepare (GstAudioSrc * asrc);
static gboolean gst_alsasrc_close (GstAudioSrc * asrc);
static guint gst_alsasrc_read (GstAudioSrc * asrc, gpointer data, guint length);
}
static gboolean
-alsasrc_parse_spec (GstAlsaSrc * alsa, GstRingBufferSpec * spec)
+alsasrc_parse_spec (GstAlsaSrc * alsa, GstAudioRingBufferSpec * spec)
{
switch (spec->type) {
case GST_BUFTYPE_RAW:
}
static gboolean
-gst_alsasrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
+gst_alsasrc_prepare (GstAudioSrc * asrc, GstAudioRingBufferSpec * spec)
{
GstAlsaSrc *alsa;
gint err;
* Since: 0.10.36
*/
guint
-gst_audio_iec61937_frame_size (const GstRingBufferSpec * spec)
+gst_audio_iec61937_frame_size (const GstAudioRingBufferSpec * spec)
{
switch (spec->type) {
case GST_BUFTYPE_AC3:
*/
gboolean
gst_audio_iec61937_payload (const guint8 * src, guint src_n, guint8 * dst,
- guint dst_n, const GstRingBufferSpec * spec)
+ guint dst_n, const GstAudioRingBufferSpec * spec)
{
guint i, tmp;
#if G_BYTE_ORDER == G_BIG_ENDIAN
#include <gst/audio/gstringbuffer.h>
-guint gst_audio_iec61937_frame_size (const GstRingBufferSpec * spec);
+guint gst_audio_iec61937_frame_size (const GstAudioRingBufferSpec * spec);
gboolean gst_audio_iec61937_payload (const guint8 * src, guint src_n,
- guint8 * dst, guint dst_n, const GstRingBufferSpec * spec);
+ guint8 * dst, guint dst_n, const GstAudioRingBufferSpec * spec);
#endif /* __GST_AUDIO_IEC61937_H__ */
/**
* SECTION:gstaudiosink
* @short_description: Simple base class for audio sinks
- * @see_also: #GstBaseAudioSink, #GstRingBuffer, #GstAudioSink.
+ * @see_also: #GstBaseAudioSink, #GstAudioRingBuffer, #GstAudioSink.
*
* This is the most simple base class for audio sinks that only requires
* subclasses to implement a set of simple functions:
*
* All scheduling of samples and timestamps is done in this base class
* together with #GstBaseAudioSink using a default implementation of a
- * #GstRingBuffer that uses threads.
+ * #GstAudioRingBuffer that uses threads.
*
* Last reviewed on 2006-09-27 (0.10.12)
*/
struct _GstAudioSinkRingBuffer
{
- GstRingBuffer object;
+ GstAudioRingBuffer object;
gboolean running;
gint queuedseg;
struct _GstAudioSinkRingBufferClass
{
- GstRingBufferClass parent_class;
+ GstAudioRingBufferClass parent_class;
};
static void gst_audio_sink_ring_buffer_class_init (GstAudioSinkRingBufferClass *
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_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_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,
+static GstAudioRingBufferClass *ring_parent_class = NULL;
+
+static gboolean gst_audio_sink_ring_buffer_open_device (GstAudioRingBuffer *
+ buf);
+static gboolean gst_audio_sink_ring_buffer_close_device (GstAudioRingBuffer *
+ buf);
+static gboolean gst_audio_sink_ring_buffer_acquire (GstAudioRingBuffer * buf,
+ GstAudioRingBufferSpec * spec);
+static gboolean gst_audio_sink_ring_buffer_release (GstAudioRingBuffer * buf);
+static gboolean gst_audio_sink_ring_buffer_start (GstAudioRingBuffer * buf);
+static gboolean gst_audio_sink_ring_buffer_pause (GstAudioRingBuffer * buf);
+static gboolean gst_audio_sink_ring_buffer_stop (GstAudioRingBuffer * buf);
+static guint gst_audio_sink_ring_buffer_delay (GstAudioRingBuffer * buf);
+static gboolean gst_audio_sink_ring_buffer_activate (GstAudioRingBuffer * buf,
gboolean active);
/* ringbuffer abstract base class */
};
ringbuffer_type =
- g_type_register_static (GST_TYPE_RING_BUFFER, "GstAudioSinkRingBuffer",
- &ringbuffer_info, 0);
+ g_type_register_static (GST_TYPE_AUDIO_RING_BUFFER,
+ "GstAudioSinkRingBuffer", &ringbuffer_info, 0);
}
return ringbuffer_type;
}
gst_audio_sink_ring_buffer_class_init (GstAudioSinkRingBufferClass * klass)
{
GObjectClass *gobject_class;
- GstRingBufferClass *gstringbuffer_class;
+ GstAudioRingBufferClass *gstringbuffer_class;
gobject_class = (GObjectClass *) klass;
- gstringbuffer_class = (GstRingBufferClass *) klass;
+ gstringbuffer_class = (GstAudioRingBufferClass *) klass;
ring_parent_class = g_type_class_peek_parent (klass);
* The start/stop methods control the thread.
*/
static void
-audioringbuffer_thread_func (GstRingBuffer * buf)
+audioringbuffer_thread_func (GstAudioRingBuffer * buf)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
gint readseg;
/* buffer must be started */
- if (gst_ring_buffer_prepare_read (buf, &readseg, &readptr, &len)) {
+ if (gst_audio_ring_buffer_prepare_read (buf, &readseg, &readptr, &len)) {
gint written;
left = len;
} while (left > 0);
/* clear written samples */
- gst_ring_buffer_clear (buf, readseg);
+ gst_audio_ring_buffer_clear (buf, readseg);
/* we wrote one segment */
- gst_ring_buffer_advance (buf, 1);
+ gst_audio_ring_buffer_advance (buf, 1);
} else {
GST_OBJECT_LOCK (abuf);
if (!abuf->running)
goto stop_running;
if (G_UNLIKELY (g_atomic_int_get (&buf->state) ==
- GST_RING_BUFFER_STATE_STARTED)) {
+ GST_AUDIO_RING_BUFFER_STATE_STARTED)) {
GST_OBJECT_UNLOCK (abuf);
continue;
}
}
static gboolean
-gst_audio_sink_ring_buffer_open_device (GstRingBuffer * buf)
+gst_audio_sink_ring_buffer_open_device (GstAudioRingBuffer * buf)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
}
static gboolean
-gst_audio_sink_ring_buffer_close_device (GstRingBuffer * buf)
+gst_audio_sink_ring_buffer_close_device (GstAudioRingBuffer * buf)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
}
static gboolean
-gst_audio_sink_ring_buffer_acquire (GstRingBuffer * buf,
- GstRingBufferSpec * spec)
+gst_audio_sink_ring_buffer_acquire (GstAudioRingBuffer * buf,
+ GstAudioRingBufferSpec * spec)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
}
static gboolean
-gst_audio_sink_ring_buffer_activate (GstRingBuffer * buf, gboolean active)
+gst_audio_sink_ring_buffer_activate (GstAudioRingBuffer * buf, gboolean active)
{
GstAudioSink *sink;
GstAudioSinkRingBuffer *abuf;
/* function is called with LOCK */
static gboolean
-gst_audio_sink_ring_buffer_release (GstRingBuffer * buf)
+gst_audio_sink_ring_buffer_release (GstAudioRingBuffer * buf)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
}
static gboolean
-gst_audio_sink_ring_buffer_start (GstRingBuffer * buf)
+gst_audio_sink_ring_buffer_start (GstAudioRingBuffer * buf)
{
GstAudioSink *sink;
}
static gboolean
-gst_audio_sink_ring_buffer_pause (GstRingBuffer * buf)
+gst_audio_sink_ring_buffer_pause (GstAudioRingBuffer * buf)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
}
static gboolean
-gst_audio_sink_ring_buffer_stop (GstRingBuffer * buf)
+gst_audio_sink_ring_buffer_stop (GstAudioRingBuffer * buf)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
}
static guint
-gst_audio_sink_ring_buffer_delay (GstRingBuffer * buf)
+gst_audio_sink_ring_buffer_delay (GstAudioRingBuffer * buf)
{
GstAudioSink *sink;
GstAudioSinkClass *csink;
G_DEFINE_TYPE_WITH_CODE (GstAudioSink, gst_audio_sink,
GST_TYPE_BASE_AUDIO_SINK, _do_init);
-static GstRingBuffer *gst_audio_sink_create_ringbuffer (GstBaseAudioSink *
+static GstAudioRingBuffer *gst_audio_sink_create_ringbuffer (GstBaseAudioSink *
sink);
static void
{
}
-static GstRingBuffer *
+static GstAudioRingBuffer *
gst_audio_sink_create_ringbuffer (GstBaseAudioSink * sink)
{
- GstRingBuffer *buffer;
+ GstAudioRingBuffer *buffer;
GST_DEBUG_OBJECT (sink, "creating ringbuffer");
buffer = g_object_new (GST_TYPE_AUDIO_SINK_RING_BUFFER, NULL);
/* open the device with given specs */
gboolean (*open) (GstAudioSink *sink);
/* prepare resources and state to operate with the given specs */
- gboolean (*prepare) (GstAudioSink *sink, GstRingBufferSpec *spec);
+ gboolean (*prepare) (GstAudioSink *sink, GstAudioRingBufferSpec *spec);
/* undo anything that was done in prepare() */
gboolean (*unprepare) (GstAudioSink *sink);
/* close the device */
/**
* SECTION:gstaudiosrc
* @short_description: Simple base class for audio sources
- * @see_also: #GstBaseAudioSrc, #GstRingBuffer, #GstAudioSrc.
+ * @see_also: #GstBaseAudioSrc, #GstAudioRingBuffer, #GstAudioSrc.
*
* This is the most simple base class for audio sources that only requires
* subclasses to implement a set of simple functions:
*
* All scheduling of samples and timestamps is done in this base class
* together with #GstBaseAudioSrc using a default implementation of a
- * #GstRingBuffer that uses threads.
+ * #GstAudioRingBuffer that uses threads.
*
* Last reviewed on 2006-09-27 (0.10.12)
*/
struct _GstAudioSrcRingBuffer
{
- GstRingBuffer object;
+ GstAudioRingBuffer object;
gboolean running;
gint queuedseg;
struct _GstAudioSrcRingBufferClass
{
- GstRingBufferClass parent_class;
+ GstAudioRingBufferClass parent_class;
};
static void gst_audio_src_ring_buffer_class_init (GstAudioSrcRingBufferClass *
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 GstAudioRingBufferClass *ring_parent_class = NULL;
-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_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);
+static gboolean gst_audio_src_ring_buffer_open_device (GstAudioRingBuffer *
+ buf);
+static gboolean gst_audio_src_ring_buffer_close_device (GstAudioRingBuffer *
+ buf);
+static gboolean gst_audio_src_ring_buffer_acquire (GstAudioRingBuffer * buf,
+ GstAudioRingBufferSpec * spec);
+static gboolean gst_audio_src_ring_buffer_release (GstAudioRingBuffer * buf);
+static gboolean gst_audio_src_ring_buffer_start (GstAudioRingBuffer * buf);
+static gboolean gst_audio_src_ring_buffer_stop (GstAudioRingBuffer * buf);
+static guint gst_audio_src_ring_buffer_delay (GstAudioRingBuffer * buf);
/* ringbuffer abstract base class */
static GType
};
ringbuffer_type =
- g_type_register_static (GST_TYPE_RING_BUFFER, "GstAudioSrcRingBuffer",
- &ringbuffer_info, 0);
+ g_type_register_static (GST_TYPE_AUDIO_RING_BUFFER,
+ "GstAudioSrcRingBuffer", &ringbuffer_info, 0);
}
return ringbuffer_type;
}
gst_audio_src_ring_buffer_class_init (GstAudioSrcRingBufferClass * klass)
{
GObjectClass *gobject_class;
- GstRingBufferClass *gstringbuffer_class;
+ GstAudioRingBufferClass *gstringbuffer_class;
gobject_class = (GObjectClass *) klass;
- gstringbuffer_class = (GstRingBufferClass *) klass;
+ gstringbuffer_class = (GstAudioRingBufferClass *) klass;
ring_parent_class = g_type_class_peek_parent (klass);
* The start/stop methods control the thread.
*/
static void
-audioringbuffer_thread_func (GstRingBuffer * buf)
+audioringbuffer_thread_func (GstAudioRingBuffer * buf)
{
GstAudioSrc *src;
GstAudioSrcClass *csrc;
guint8 *readptr;
gint readseg;
- if (gst_ring_buffer_prepare_read (buf, &readseg, &readptr, &len)) {
+ if (gst_audio_ring_buffer_prepare_read (buf, &readseg, &readptr, &len)) {
gint read;
left = len;
} while (left > 0);
/* we read one segment */
- gst_ring_buffer_advance (buf, 1);
+ gst_audio_ring_buffer_advance (buf, 1);
} else {
GST_OBJECT_LOCK (abuf);
if (!abuf->running)
goto stop_running;
if (G_UNLIKELY (g_atomic_int_get (&buf->state) ==
- GST_RING_BUFFER_STATE_STARTED)) {
+ GST_AUDIO_RING_BUFFER_STATE_STARTED)) {
GST_OBJECT_UNLOCK (abuf);
continue;
}
}
static gboolean
-gst_audio_src_ring_buffer_open_device (GstRingBuffer * buf)
+gst_audio_src_ring_buffer_open_device (GstAudioRingBuffer * buf)
{
GstAudioSrc *src;
GstAudioSrcClass *csrc;
}
static gboolean
-gst_audio_src_ring_buffer_close_device (GstRingBuffer * buf)
+gst_audio_src_ring_buffer_close_device (GstAudioRingBuffer * buf)
{
GstAudioSrc *src;
GstAudioSrcClass *csrc;
}
static gboolean
-gst_audio_src_ring_buffer_acquire (GstRingBuffer * buf,
- GstRingBufferSpec * spec)
+gst_audio_src_ring_buffer_acquire (GstAudioRingBuffer * buf,
+ GstAudioRingBufferSpec * spec)
{
GstAudioSrc *src;
GstAudioSrcClass *csrc;
/* function is called with LOCK */
static gboolean
-gst_audio_src_ring_buffer_release (GstRingBuffer * buf)
+gst_audio_src_ring_buffer_release (GstAudioRingBuffer * buf)
{
GstAudioSrc *src;
GstAudioSrcClass *csrc;
}
static gboolean
-gst_audio_src_ring_buffer_start (GstRingBuffer * buf)
+gst_audio_src_ring_buffer_start (GstAudioRingBuffer * buf)
{
GST_DEBUG ("start, sending signal");
GST_AUDIO_SRC_RING_BUFFER_SIGNAL (buf);
}
static gboolean
-gst_audio_src_ring_buffer_stop (GstRingBuffer * buf)
+gst_audio_src_ring_buffer_stop (GstAudioRingBuffer * buf)
{
GstAudioSrc *src;
GstAudioSrcClass *csrc;
}
static guint
-gst_audio_src_ring_buffer_delay (GstRingBuffer * buf)
+gst_audio_src_ring_buffer_delay (GstAudioRingBuffer * buf)
{
GstAudioSrc *src;
GstAudioSrcClass *csrc;
G_DEFINE_TYPE_WITH_CODE (GstAudioSrc, gst_audio_src,
GST_TYPE_BASE_AUDIO_SRC, _do_init);
-static GstRingBuffer *gst_audio_src_create_ringbuffer (GstBaseAudioSrc * src);
+static GstAudioRingBuffer *gst_audio_src_create_ringbuffer (GstBaseAudioSrc *
+ src);
static void
gst_audio_src_class_init (GstAudioSrcClass * klass)
{
}
-static GstRingBuffer *
+static GstAudioRingBuffer *
gst_audio_src_create_ringbuffer (GstBaseAudioSrc * src)
{
- GstRingBuffer *buffer;
+ GstAudioRingBuffer *buffer;
GST_DEBUG ("creating ringbuffer");
buffer = g_object_new (GST_TYPE_AUDIO_SRC_RING_BUFFER, NULL);
/* open the device with given specs */
gboolean (*open) (GstAudioSrc *src);
/* prepare resources and state to operate with the given specs */
- gboolean (*prepare) (GstAudioSrc *src, GstRingBufferSpec *spec);
+ gboolean (*prepare) (GstAudioSrc *src, GstAudioRingBufferSpec *spec);
/* undo anything that was done in prepare() */
gboolean (*unprepare) (GstAudioSrc *src);
/* close the device */
/**
* SECTION:gstbaseaudiosink
* @short_description: Base class for audio sinks
- * @see_also: #GstAudioSink, #GstRingBuffer.
+ * @see_also: #GstAudioSink, #GstAudioRingBuffer.
*
* This is the base class for audio sinks. Subclasses need to implement the
* ::create_ringbuffer vmethod. This base class will then take care of
static GstClock *gst_base_audio_sink_provide_clock (GstElement * elem);
static GstClockTime gst_base_audio_sink_get_time (GstClock * clock,
GstBaseAudioSink * sink);
-static void gst_base_audio_sink_callback (GstRingBuffer * rbuf, guint8 * data,
- guint len, gpointer user_data);
+static void gst_base_audio_sink_callback (GstAudioRingBuffer * rbuf,
+ guint8 * data, guint len, gpointer user_data);
static GstFlowReturn gst_base_audio_sink_preroll (GstBaseSink * bsink,
GstBuffer * buffer);
/* ref class from a thread-safe context to work around missing bit of
* thread-safety in GObject */
g_type_class_ref (GST_TYPE_AUDIO_CLOCK);
- g_type_class_ref (GST_TYPE_RING_BUFFER);
+ g_type_class_ref (GST_TYPE_AUDIO_RING_BUFFER);
}
if (sink->ringbuffer == NULL)
goto wrong_state;
- if (!gst_ring_buffer_is_acquired (sink->ringbuffer))
+ if (!gst_audio_ring_buffer_is_acquired (sink->ringbuffer))
goto wrong_state;
GST_OBJECT_LOCK (sink);
if (basesink->ringbuffer) {
gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, NULL);
- res = gst_ring_buffer_convert (basesink->ringbuffer, src_fmt, src_val,
- dest_fmt, &dest_val);
+ res =
+ gst_audio_ring_buffer_convert (basesink->ringbuffer, src_fmt,
+ src_val, dest_fmt, &dest_val);
if (res) {
gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
}
/* we and upstream are both live, adjust the min_latency */
if (live && us_live) {
- GstRingBufferSpec *spec;
+ GstAudioRingBufferSpec *spec;
GST_OBJECT_LOCK (basesink);
if (!basesink->ringbuffer || !basesink->ringbuffer->spec.info.rate) {
if (basesink->ringbuffer) {
gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, NULL);
- res = gst_ring_buffer_convert (basesink->ringbuffer, src_fmt, src_val,
- dest_fmt, &dest_val);
+ res =
+ gst_audio_ring_buffer_convert (basesink->ringbuffer, src_fmt,
+ src_val, dest_fmt, &dest_val);
if (res) {
gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
}
return GST_CLOCK_TIME_NONE;
/* our processed samples are always increasing */
- raw = samples = gst_ring_buffer_samples_done (sink->ringbuffer);
+ raw = samples = gst_audio_ring_buffer_samples_done (sink->ringbuffer);
/* the number of samples not yet processed, this is still queued in the
* device (not played for playback). */
- delay = gst_ring_buffer_delay (sink->ringbuffer);
+ delay = gst_audio_ring_buffer_delay (sink->ringbuffer);
if (G_LIKELY (samples >= delay))
samples -= delay;
gst_base_audio_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
{
GstBaseAudioSink *sink = GST_BASE_AUDIO_SINK (bsink);
- GstRingBufferSpec *spec;
+ GstAudioRingBufferSpec *spec;
GstClockTime now;
GstClockTime crate_num, crate_denom;
GST_DEBUG_OBJECT (sink, "time was %" GST_TIME_FORMAT, GST_TIME_ARGS (now));
/* release old ringbuffer */
- gst_ring_buffer_pause (sink->ringbuffer);
- gst_ring_buffer_activate (sink->ringbuffer, FALSE);
- gst_ring_buffer_release (sink->ringbuffer);
+ gst_audio_ring_buffer_pause (sink->ringbuffer);
+ gst_audio_ring_buffer_activate (sink->ringbuffer, FALSE);
+ gst_audio_ring_buffer_release (sink->ringbuffer);
GST_DEBUG_OBJECT (sink, "parse caps");
spec->latency_time = sink->latency_time;
/* parse new caps */
- if (!gst_ring_buffer_parse_caps (spec, caps))
+ if (!gst_audio_ring_buffer_parse_caps (spec, caps))
goto parse_error;
- gst_ring_buffer_debug_spec_buff (spec);
+ gst_audio_ring_buffer_debug_spec_buff (spec);
GST_DEBUG_OBJECT (sink, "acquire ringbuffer");
- if (!gst_ring_buffer_acquire (sink->ringbuffer, spec))
+ if (!gst_audio_ring_buffer_acquire (sink->ringbuffer, spec))
goto acquire_error;
if (bsink->pad_mode == GST_PAD_ACTIVATE_PUSH) {
GST_DEBUG_OBJECT (sink, "activate ringbuffer");
- gst_ring_buffer_activate (sink->ringbuffer, TRUE);
+ gst_audio_ring_buffer_activate (sink->ringbuffer, TRUE);
}
/* due to possible changes in the spec file we should recalibrate the clock */
spec->buffer_time = spec->segtotal * spec->latency_time;
- gst_ring_buffer_debug_spec_buff (spec);
+ gst_audio_ring_buffer_debug_spec_buff (spec);
return TRUE;
/* need to start playback before we can drain, but only when
* we have successfully negotiated a format and thus acquired the
* ringbuffer. */
- if (gst_ring_buffer_is_acquired (sink->ringbuffer))
- gst_ring_buffer_start (sink->ringbuffer);
+ if (gst_audio_ring_buffer_is_acquired (sink->ringbuffer))
+ gst_audio_ring_buffer_start (sink->ringbuffer);
if (sink->priv->eos_time != -1) {
GST_DEBUG_OBJECT (sink,
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
if (sink->ringbuffer)
- gst_ring_buffer_set_flushing (sink->ringbuffer, TRUE);
+ gst_audio_ring_buffer_set_flushing (sink->ringbuffer, TRUE);
break;
case GST_EVENT_FLUSH_STOP:
/* always resync on sample after a flush */
sink->priv->eos_time = -1;
sink->priv->discont_time = -1;
if (sink->ringbuffer)
- gst_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
+ gst_audio_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
break;
case GST_EVENT_EOS:
/* now wait till we played everything */
{
GstBaseAudioSink *sink = GST_BASE_AUDIO_SINK (bsink);
- if (!gst_ring_buffer_is_acquired (sink->ringbuffer))
+ if (!gst_audio_ring_buffer_is_acquired (sink->ringbuffer))
goto wrong_state;
/* we don't really do anything when prerolling. We could make a
}
/* start ringbuffer so we can start slaving right away when we need to */
- gst_ring_buffer_start (sink->ringbuffer);
+ gst_audio_ring_buffer_start (sink->ringbuffer);
GST_DEBUG_OBJECT (sink,
"internal time: %" GST_TIME_FORMAT " external time: %" GST_TIME_FORMAT,
gst_base_audio_sink_get_alignment (GstBaseAudioSink * sink,
GstClockTime sample_offset)
{
- GstRingBuffer *ringbuf = sink->ringbuffer;
+ GstAudioRingBuffer *ringbuf = sink->ringbuffer;
gint64 align;
gint64 sample_diff;
gint64 max_sample_diff;
GstClockTimeDiff sync_offset, ts_offset;
GstBaseAudioSinkClass *bclass;
GstBaseAudioSink *sink;
- GstRingBuffer *ringbuf;
+ GstAudioRingBuffer *ringbuf;
gint64 diff, align;
guint64 ctime, cstop;
gsize offset;
ringbuf = sink->ringbuffer;
/* can't do anything when we don't have the device */
- if (G_UNLIKELY (!gst_ring_buffer_is_acquired (ringbuf)))
+ if (G_UNLIKELY (!gst_audio_ring_buffer_is_acquired (ringbuf)))
goto wrong_state;
/* Wait for upstream latency before starting the ringbuffer, we do this so
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
do {
written =
- gst_ring_buffer_commit_full (ringbuf, &sample_offset, data + offset,
- samples, out_samples, &accum);
+ gst_audio_ring_buffer_commit_full (ringbuf, &sample_offset,
+ data + offset, samples, out_samples, &accum);
GST_DEBUG_OBJECT (sink, "wrote %u of %u", written, samples);
/* if we wrote all, we're done */
if (GST_CLOCK_TIME_IS_VALID (stop) && stop >= bsink->segment.stop) {
GST_DEBUG_OBJECT (sink,
"start playback because we are at the end of segment");
- gst_ring_buffer_start (ringbuf);
+ gst_audio_ring_buffer_start (ringbuf);
}
ret = GST_FLOW_OK;
* gst_base_audio_sink_create_ringbuffer:
* @sink: a #GstBaseAudioSink.
*
- * Create and return the #GstRingBuffer for @sink. This function will call the
+ * Create and return the #GstAudioRingBuffer for @sink. This function will call the
* ::create_ringbuffer vmethod and will set @sink as the parent of the returned
* buffer (see gst_object_set_parent()).
*
* Returns: The new ringbuffer of @sink.
*/
-GstRingBuffer *
+GstAudioRingBuffer *
gst_base_audio_sink_create_ringbuffer (GstBaseAudioSink * sink)
{
GstBaseAudioSinkClass *bclass;
- GstRingBuffer *buffer = NULL;
+ GstAudioRingBuffer *buffer = NULL;
bclass = GST_BASE_AUDIO_SINK_GET_CLASS (sink);
if (bclass->create_ringbuffer)
}
static void
-gst_base_audio_sink_callback (GstRingBuffer * rbuf, guint8 * data, guint len,
- gpointer user_data)
+gst_base_audio_sink_callback (GstAudioRingBuffer * rbuf, guint8 * data,
+ guint len, gpointer user_data)
{
GstBaseSink *basesink;
GstBaseAudioSink *sink;
{
GST_WARNING_OBJECT (basesink, "Got flow '%s' but can't return it: %d",
gst_flow_get_name (ret), ret);
- gst_ring_buffer_pause (rbuf);
+ gst_audio_ring_buffer_pause (rbuf);
GST_PAD_STREAM_UNLOCK (basesink->sinkpad);
return;
}
* set segment.stop and segment.duration to the last sample or so */
GST_DEBUG_OBJECT (sink, "EOS");
gst_base_audio_sink_drain (sink);
- gst_ring_buffer_pause (rbuf);
+ gst_audio_ring_buffer_pause (rbuf);
gst_element_post_message (GST_ELEMENT_CAST (sink),
gst_message_new_eos (GST_OBJECT_CAST (sink)));
GST_PAD_STREAM_UNLOCK (basesink->sinkpad);
flushing:
{
GST_DEBUG_OBJECT (sink, "we are flushing");
- gst_ring_buffer_pause (rbuf);
+ gst_audio_ring_buffer_pause (rbuf);
GST_BASE_SINK_PREROLL_UNLOCK (basesink);
GST_PAD_STREAM_UNLOCK (basesink->sinkpad);
return;
preroll_error:
{
GST_DEBUG_OBJECT (sink, "error %s", gst_flow_get_name (ret));
- gst_ring_buffer_pause (rbuf);
+ gst_audio_ring_buffer_pause (rbuf);
GST_BASE_SINK_PREROLL_UNLOCK (basesink);
GST_PAD_STREAM_UNLOCK (basesink->sinkpad);
return;
if (active) {
GST_DEBUG_OBJECT (basesink, "activating pull");
- gst_ring_buffer_set_callback (sink->ringbuffer,
+ gst_audio_ring_buffer_set_callback (sink->ringbuffer,
gst_base_audio_sink_callback, sink);
- ret = gst_ring_buffer_activate (sink->ringbuffer, TRUE);
+ ret = gst_audio_ring_buffer_activate (sink->ringbuffer, TRUE);
} else {
GST_DEBUG_OBJECT (basesink, "deactivating pull");
- gst_ring_buffer_set_callback (sink->ringbuffer, NULL, NULL);
- ret = gst_ring_buffer_activate (sink->ringbuffer, FALSE);
+ gst_audio_ring_buffer_set_callback (sink->ringbuffer, NULL, NULL);
+ ret = gst_audio_ring_buffer_activate (sink->ringbuffer, FALSE);
}
return ret;
GST_DEBUG_OBJECT (sink, "ringbuffer may start now");
sink->priv->sync_latency = TRUE;
- gst_ring_buffer_may_start (sink->ringbuffer, TRUE);
+ gst_audio_ring_buffer_may_start (sink->ringbuffer, TRUE);
if (basesink->pad_mode == GST_PAD_ACTIVATE_PULL) {
/* we always start the ringbuffer in pull mode immediatly */
- gst_ring_buffer_start (sink->ringbuffer);
+ gst_audio_ring_buffer_start (sink->ringbuffer);
}
return GST_STATE_CHANGE_SUCCESS;
gst_audio_clock_reset (GST_AUDIO_CLOCK (sink->provided_clock), 0);
sink->ringbuffer = gst_base_audio_sink_create_ringbuffer (sink);
}
- if (!gst_ring_buffer_open_device (sink->ringbuffer))
+ if (!gst_audio_ring_buffer_open_device (sink->ringbuffer))
goto open_failed;
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
sink->priv->last_align = -1;
sink->priv->eos_time = -1;
sink->priv->discont_time = -1;
- gst_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
- gst_ring_buffer_may_start (sink->ringbuffer, FALSE);
+ gst_audio_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
+ gst_audio_ring_buffer_may_start (sink->ringbuffer, FALSE);
/* Only post clock-provide messages if this is the clock that
* we've created. If the subclass has overriden it the subclass
eos = GST_BASE_SINK (sink)->eos;
GST_OBJECT_UNLOCK (sink);
- gst_ring_buffer_may_start (sink->ringbuffer, TRUE);
+ gst_audio_ring_buffer_may_start (sink->ringbuffer, TRUE);
if (GST_BASE_SINK_CAST (sink)->pad_mode == GST_PAD_ACTIVATE_PULL ||
g_atomic_int_get (&sink->eos_rendering) || eos) {
/* we always start the ringbuffer in pull mode immediatly */
/* sync rendering on eos needs running clock,
* and others need running clock when finished rendering eos */
- gst_ring_buffer_start (sink->ringbuffer);
+ gst_audio_ring_buffer_start (sink->ringbuffer);
}
break;
}
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
/* ringbuffer cannot start anymore */
- gst_ring_buffer_may_start (sink->ringbuffer, FALSE);
- gst_ring_buffer_pause (sink->ringbuffer);
+ gst_audio_ring_buffer_may_start (sink->ringbuffer, FALSE);
+ gst_audio_ring_buffer_pause (sink->ringbuffer);
GST_OBJECT_LOCK (sink);
sink->priv->sync_latency = FALSE;
/* make sure we unblock before calling the parent state change
* so it can grab the STREAM_LOCK */
- gst_ring_buffer_set_flushing (sink->ringbuffer, TRUE);
+ gst_audio_ring_buffer_set_flushing (sink->ringbuffer, TRUE);
break;
default:
break;
gst_clock_set_master (sink->provided_clock, NULL);
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
- gst_ring_buffer_activate (sink->ringbuffer, FALSE);
- gst_ring_buffer_release (sink->ringbuffer);
+ gst_audio_ring_buffer_activate (sink->ringbuffer, FALSE);
+ gst_audio_ring_buffer_release (sink->ringbuffer);
break;
case GST_STATE_CHANGE_READY_TO_NULL:
/* we release again here because the aqcuire happens when setting the
* caps, which happens before we commit the state to PAUSED and thus the
* PAUSED->READY state change (see above, where we release the ringbuffer)
* might not be called when we get here. */
- gst_ring_buffer_activate (sink->ringbuffer, FALSE);
- gst_ring_buffer_release (sink->ringbuffer);
- gst_ring_buffer_close_device (sink->ringbuffer);
+ gst_audio_ring_buffer_activate (sink->ringbuffer, FALSE);
+ gst_audio_ring_buffer_release (sink->ringbuffer);
+ gst_audio_ring_buffer_close_device (sink->ringbuffer);
GST_OBJECT_LOCK (sink);
gst_object_unparent (GST_OBJECT_CAST (sink->ringbuffer));
sink->ringbuffer = NULL;
* function will be used to perform a pull_range() on the sinkpad.
* The thread scheduling the callback can be a real-time thread.
*
- * Subclasses must implement a GstRingBuffer in addition to overriding
+ * Subclasses must implement a GstAudioRingBuffer in addition to overriding
* the methods in GstBaseSink and this class.
*/
* Opaque #GstBaseAudioSink.
*/
struct _GstBaseAudioSink {
- GstBaseSink element;
+ GstBaseSink element;
/*< protected >*/ /* with LOCK */
/* our ringbuffer */
- GstRingBuffer *ringbuffer;
+ GstAudioRingBuffer *ringbuffer;
/* required buffer and latency in microseconds */
- guint64 buffer_time;
- guint64 latency_time;
+ guint64 buffer_time;
+ guint64 latency_time;
/* the next sample to write */
- guint64 next_sample;
+ guint64 next_sample;
/* clock */
- gboolean provide_clock;
- GstClock *provided_clock;
+ gboolean provide_clock;
+ GstClock *provided_clock;
/* with g_atomic_; currently rendering eos */
- gboolean eos_rendering;
+ gboolean eos_rendering;
/*< private >*/
GstBaseAudioSinkPrivate *priv;
/**
* GstBaseAudioSinkClass:
* @parent_class: the parent class.
- * @create_ringbuffer: create and return a #GstRingBuffer to write to.
+ * @create_ringbuffer: create and return a #GstAudioRingBuffer to write to.
* @payload: payload data in a format suitable to write to the sink. If no
* payloading is required, returns a reffed copy of the original
* buffer, else returns the payloaded buffer with all other metadata
* functionality.
*/
struct _GstBaseAudioSinkClass {
- GstBaseSinkClass parent_class;
+ GstBaseSinkClass parent_class;
/* subclass ringbuffer allocation */
- GstRingBuffer* (*create_ringbuffer) (GstBaseAudioSink *sink);
+ GstAudioRingBuffer* (*create_ringbuffer) (GstBaseAudioSink *sink);
/* subclass payloader */
- GstBuffer* (*payload) (GstBaseAudioSink *sink,
- GstBuffer *buffer);
+ GstBuffer* (*payload) (GstBaseAudioSink *sink,
+ GstBuffer *buffer);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
GType gst_base_audio_sink_get_type(void);
GType gst_base_audio_sink_slave_method_get_type (void);
-GstRingBuffer *gst_base_audio_sink_create_ringbuffer (GstBaseAudioSink *sink);
+GstAudioRingBuffer *
+ gst_base_audio_sink_create_ringbuffer (GstBaseAudioSink *sink);
-void gst_base_audio_sink_set_provide_clock (GstBaseAudioSink *sink, gboolean provide);
-gboolean gst_base_audio_sink_get_provide_clock (GstBaseAudioSink *sink);
+void gst_base_audio_sink_set_provide_clock (GstBaseAudioSink *sink, gboolean provide);
+gboolean gst_base_audio_sink_get_provide_clock (GstBaseAudioSink *sink);
-void gst_base_audio_sink_set_slave_method (GstBaseAudioSink *sink,
- GstBaseAudioSinkSlaveMethod method);
+void gst_base_audio_sink_set_slave_method (GstBaseAudioSink *sink,
+ GstBaseAudioSinkSlaveMethod method);
GstBaseAudioSinkSlaveMethod
- gst_base_audio_sink_get_slave_method (GstBaseAudioSink *sink);
+ gst_base_audio_sink_get_slave_method (GstBaseAudioSink *sink);
-void gst_base_audio_sink_set_drift_tolerance (GstBaseAudioSink *sink,
- gint64 drift_tolerance);
-gint64 gst_base_audio_sink_get_drift_tolerance (GstBaseAudioSink *sink);
+void gst_base_audio_sink_set_drift_tolerance (GstBaseAudioSink *sink,
+ gint64 drift_tolerance);
+gint64 gst_base_audio_sink_get_drift_tolerance (GstBaseAudioSink *sink);
void gst_base_audio_sink_set_alignment_threshold (GstBaseAudioSink * sink,
GstClockTime alignment_threshold);
GstClockTime
gst_base_audio_sink_get_alignment_threshold (GstBaseAudioSink * sink);
-void gst_base_audio_sink_set_discont_wait (GstBaseAudioSink * sink,
- GstClockTime discont_wait);
+void gst_base_audio_sink_set_discont_wait (GstBaseAudioSink * sink,
+ GstClockTime discont_wait);
GstClockTime
- gst_base_audio_sink_get_discont_wait (GstBaseAudioSink * sink);
+ gst_base_audio_sink_get_discont_wait (GstBaseAudioSink * sink);
G_END_DECLS
/**
* SECTION:gstbaseaudiosrc
* @short_description: Base class for audio sources
- * @see_also: #GstAudioSrc, #GstRingBuffer.
+ * @see_also: #GstAudioSrc, #GstAudioRingBuffer.
*
* This is the base class for audio sources. Subclasses need to implement the
* ::create_ringbuffer vmethod. This base class will then take care of
/* ref class from a thread-safe context to work around missing bit of
* thread-safety in GObject */
g_type_class_ref (GST_TYPE_AUDIO_CLOCK);
- g_type_class_ref (GST_TYPE_RING_BUFFER);
+ g_type_class_ref (GST_TYPE_AUDIO_RING_BUFFER);
}
static void
if (src->ringbuffer == NULL)
goto wrong_state;
- if (!gst_ring_buffer_is_acquired (src->ringbuffer))
+ if (!gst_audio_ring_buffer_is_acquired (src->ringbuffer))
goto wrong_state;
GST_OBJECT_LOCK (src);
|| src->ringbuffer->spec.info.rate == 0))
return GST_CLOCK_TIME_NONE;
- raw = samples = gst_ring_buffer_samples_done (src->ringbuffer);
+ raw = samples = gst_audio_ring_buffer_samples_done (src->ringbuffer);
/* the number of samples not yet processed, this is still queued in the
* device (not yet read for capture). */
- delay = gst_ring_buffer_delay (src->ringbuffer);
+ delay = gst_audio_ring_buffer_delay (src->ringbuffer);
samples += delay;
gst_base_audio_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps)
{
GstBaseAudioSrc *src = GST_BASE_AUDIO_SRC (bsrc);
- GstRingBufferSpec *spec;
+ GstAudioRingBufferSpec *spec;
gint bpf, rate;
spec = &src->ringbuffer->spec;
spec->latency_time = src->latency_time;
GST_OBJECT_LOCK (src);
- if (!gst_ring_buffer_parse_caps (spec, caps)) {
+ if (!gst_audio_ring_buffer_parse_caps (spec, caps)) {
GST_OBJECT_UNLOCK (src);
goto parse_error;
}
GST_DEBUG ("release old ringbuffer");
- gst_ring_buffer_release (src->ringbuffer);
+ gst_audio_ring_buffer_release (src->ringbuffer);
- gst_ring_buffer_debug_spec_buff (spec);
+ gst_audio_ring_buffer_debug_spec_buff (spec);
GST_DEBUG ("acquire new ringbuffer");
- if (!gst_ring_buffer_acquire (src->ringbuffer, spec))
+ if (!gst_audio_ring_buffer_acquire (src->ringbuffer, spec))
goto acquire_error;
/* calculate actual latency and buffer times */
spec->buffer_time =
spec->segtotal * spec->segsize * GST_MSECOND / (rate * bpf);
- gst_ring_buffer_debug_spec_buff (spec);
+ gst_audio_ring_buffer_debug_spec_buff (spec);
g_object_notify (G_OBJECT (src), "actual-buffer-time");
g_object_notify (G_OBJECT (src), "actual-latency-time");
case GST_QUERY_LATENCY:
{
GstClockTime min_latency, max_latency;
- GstRingBufferSpec *spec;
+ GstAudioRingBufferSpec *spec;
gint bpf, rate;
GST_OBJECT_LOCK (src);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
GST_DEBUG_OBJECT (bsrc, "flush-start");
- gst_ring_buffer_pause (src->ringbuffer);
- gst_ring_buffer_clear_all (src->ringbuffer);
+ gst_audio_ring_buffer_pause (src->ringbuffer);
+ gst_audio_ring_buffer_clear_all (src->ringbuffer);
break;
case GST_EVENT_FLUSH_STOP:
GST_DEBUG_OBJECT (bsrc, "flush-stop");
/* always resync on sample after a flush */
src->next_sample = -1;
- gst_ring_buffer_clear_all (src->ringbuffer);
+ gst_audio_ring_buffer_clear_all (src->ringbuffer);
break;
case GST_EVENT_SEEK:
GST_DEBUG_OBJECT (bsrc, "refuse to seek");
guint samples, total_samples;
guint64 sample;
gint bpf, rate;
- GstRingBuffer *ringbuffer;
- GstRingBufferSpec *spec;
+ GstAudioRingBuffer *ringbuffer;
+ GstAudioRingBufferSpec *spec;
guint read;
GstClockTime timestamp, duration;
GstClock *clock;
ringbuffer = src->ringbuffer;
spec = &ringbuffer->spec;
- if (G_UNLIKELY (!gst_ring_buffer_is_acquired (ringbuffer)))
+ if (G_UNLIKELY (!gst_audio_ring_buffer_is_acquired (ringbuffer)))
goto wrong_state;
bpf = GST_AUDIO_INFO_BPF (&spec->info);
data = ptr = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
do {
- read = gst_ring_buffer_read (ringbuffer, sample, ptr, samples);
+ read = gst_audio_ring_buffer_read (ringbuffer, sample, ptr, samples);
GST_DEBUG_OBJECT (src, "read %u of %u", read, samples);
/* if we read all, we're done */
if (read == samples)
segment_diff = running_time_segment - last_written_segment;
/* advance the ringbuffer */
- gst_ring_buffer_advance (ringbuffer, segment_diff);
+ gst_audio_ring_buffer_advance (ringbuffer, segment_diff);
/* we move the new read segment to the last known written segment */
new_read_segment =
* gst_base_audio_src_create_ringbuffer:
* @src: a #GstBaseAudioSrc.
*
- * Create and return the #GstRingBuffer for @src. This function will call the
+ * Create and return the #GstAudioRingBuffer for @src. This function will call the
* ::create_ringbuffer vmethod and will set @src as the parent of the returned
* buffer (see gst_object_set_parent()).
*
* Returns: The new ringbuffer of @src.
*/
-GstRingBuffer *
+GstAudioRingBuffer *
gst_base_audio_src_create_ringbuffer (GstBaseAudioSrc * src)
{
GstBaseAudioSrcClass *bclass;
- GstRingBuffer *buffer = NULL;
+ GstAudioRingBuffer *buffer = NULL;
bclass = GST_BASE_AUDIO_SRC_GET_CLASS (src);
if (bclass->create_ringbuffer)
src->ringbuffer = gst_base_audio_src_create_ringbuffer (src);
}
GST_OBJECT_UNLOCK (src);
- if (!gst_ring_buffer_open_device (src->ringbuffer))
+ if (!gst_audio_ring_buffer_open_device (src->ringbuffer))
goto open_failed;
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
GST_DEBUG_OBJECT (src, "READY->PAUSED");
src->next_sample = -1;
- gst_ring_buffer_set_flushing (src->ringbuffer, FALSE);
- gst_ring_buffer_may_start (src->ringbuffer, FALSE);
+ gst_audio_ring_buffer_set_flushing (src->ringbuffer, FALSE);
+ gst_audio_ring_buffer_may_start (src->ringbuffer, FALSE);
/* Only post clock-provide messages if this is the clock that
* we've created. If the subclass has overriden it the subclass
* should post this messages whenever necessary */
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
GST_DEBUG_OBJECT (src, "PAUSED->PLAYING");
- gst_ring_buffer_may_start (src->ringbuffer, TRUE);
+ gst_audio_ring_buffer_may_start (src->ringbuffer, TRUE);
break;
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
GST_DEBUG_OBJECT (src, "PLAYING->PAUSED");
- gst_ring_buffer_may_start (src->ringbuffer, FALSE);
- gst_ring_buffer_pause (src->ringbuffer);
+ gst_audio_ring_buffer_may_start (src->ringbuffer, FALSE);
+ gst_audio_ring_buffer_pause (src->ringbuffer);
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
GST_DEBUG_OBJECT (src, "PAUSED->READY");
(GstAudioClockGetTimeFunc) gst_base_audio_src_get_time)
gst_element_post_message (element,
gst_message_new_clock_lost (GST_OBJECT_CAST (element), src->clock));
- gst_ring_buffer_set_flushing (src->ringbuffer, TRUE);
+ gst_audio_ring_buffer_set_flushing (src->ringbuffer, TRUE);
break;
default:
break;
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY:
GST_DEBUG_OBJECT (src, "PAUSED->READY");
- gst_ring_buffer_release (src->ringbuffer);
+ gst_audio_ring_buffer_release (src->ringbuffer);
break;
case GST_STATE_CHANGE_READY_TO_NULL:
GST_DEBUG_OBJECT (src, "READY->NULL");
- gst_ring_buffer_close_device (src->ringbuffer);
+ gst_audio_ring_buffer_close_device (src->ringbuffer);
GST_OBJECT_LOCK (src);
gst_object_unparent (GST_OBJECT_CAST (src->ringbuffer));
src->ringbuffer = NULL;
* Opaque #GstBaseAudioSrc.
*/
struct _GstBaseAudioSrc {
- GstPushSrc element;
+ GstPushSrc element;
/*< protected >*/ /* with LOCK */
/* our ringbuffer */
- GstRingBuffer *ringbuffer;
+ GstAudioRingBuffer *ringbuffer;
/* required buffer and latency */
- GstClockTime buffer_time;
- GstClockTime latency_time;
+ GstClockTime buffer_time;
+ GstClockTime latency_time;
/* the next sample to write */
- guint64 next_sample;
+ guint64 next_sample;
/* clock */
- GstClock *clock;
+ GstClock *clock;
/*< private >*/
GstBaseAudioSrcPrivate *priv;
/**
* GstBaseAudioSrcClass:
* @parent_class: the parent class.
- * @create_ringbuffer: create and return a #GstRingBuffer to read from.
+ * @create_ringbuffer: create and return a #GstAudioRingBuffer to read from.
*
* #GstBaseAudioSrc class. Override the vmethod to implement
* functionality.
*/
struct _GstBaseAudioSrcClass {
- GstPushSrcClass parent_class;
+ GstPushSrcClass parent_class;
/* subclass ringbuffer allocation */
- GstRingBuffer* (*create_ringbuffer) (GstBaseAudioSrc *src);
+ GstAudioRingBuffer* (*create_ringbuffer) (GstBaseAudioSrc *src);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
GType gst_base_audio_src_get_type(void);
GType gst_base_audio_src_slave_method_get_type (void);
-GstRingBuffer *gst_base_audio_src_create_ringbuffer (GstBaseAudioSrc *src);
+GstAudioRingBuffer *
+ gst_base_audio_src_create_ringbuffer (GstBaseAudioSrc *src);
void gst_base_audio_src_set_provide_clock (GstBaseAudioSrc *src, gboolean provide);
gboolean gst_base_audio_src_get_provide_clock (GstBaseAudioSrc *src);
#include "gstringbuffer.h"
-GST_DEBUG_CATEGORY_STATIC (gst_ring_buffer_debug);
-#define GST_CAT_DEFAULT gst_ring_buffer_debug
+GST_DEBUG_CATEGORY_STATIC (gst_audio_ring_buffer_debug);
+#define GST_CAT_DEFAULT gst_audio_ring_buffer_debug
-static void gst_ring_buffer_dispose (GObject * object);
-static void gst_ring_buffer_finalize (GObject * object);
+static void gst_audio_ring_buffer_dispose (GObject * object);
+static void gst_audio_ring_buffer_finalize (GObject * object);
-static gboolean gst_ring_buffer_pause_unlocked (GstRingBuffer * buf);
-static void default_clear_all (GstRingBuffer * buf);
-static guint default_commit (GstRingBuffer * buf, guint64 * sample,
+static gboolean gst_audio_ring_buffer_pause_unlocked (GstAudioRingBuffer * buf);
+static void default_clear_all (GstAudioRingBuffer * buf);
+static guint default_commit (GstAudioRingBuffer * buf, guint64 * sample,
guchar * data, gint in_samples, gint out_samples, gint * accum);
/* ringbuffer abstract base class */
-G_DEFINE_ABSTRACT_TYPE (GstRingBuffer, gst_ring_buffer, GST_TYPE_OBJECT);
+G_DEFINE_ABSTRACT_TYPE (GstAudioRingBuffer, gst_audio_ring_buffer,
+ GST_TYPE_OBJECT);
static void
-gst_ring_buffer_class_init (GstRingBufferClass * klass)
+gst_audio_ring_buffer_class_init (GstAudioRingBufferClass * klass)
{
GObjectClass *gobject_class;
- GstRingBufferClass *gstringbuffer_class;
+ GstAudioRingBufferClass *gstringbuffer_class;
gobject_class = (GObjectClass *) klass;
- gstringbuffer_class = (GstRingBufferClass *) klass;
+ gstringbuffer_class = (GstAudioRingBufferClass *) klass;
- GST_DEBUG_CATEGORY_INIT (gst_ring_buffer_debug, "ringbuffer", 0,
+ GST_DEBUG_CATEGORY_INIT (gst_audio_ring_buffer_debug, "ringbuffer", 0,
"ringbuffer class");
- gobject_class->dispose = gst_ring_buffer_dispose;
- gobject_class->finalize = gst_ring_buffer_finalize;
+ gobject_class->dispose = gst_audio_ring_buffer_dispose;
+ gobject_class->finalize = gst_audio_ring_buffer_finalize;
gstringbuffer_class->clear_all = GST_DEBUG_FUNCPTR (default_clear_all);
gstringbuffer_class->commit = GST_DEBUG_FUNCPTR (default_commit);
}
static void
-gst_ring_buffer_init (GstRingBuffer * ringbuffer)
+gst_audio_ring_buffer_init (GstAudioRingBuffer * ringbuffer)
{
ringbuffer->open = FALSE;
ringbuffer->acquired = FALSE;
- ringbuffer->state = GST_RING_BUFFER_STATE_STOPPED;
+ ringbuffer->state = GST_AUDIO_RING_BUFFER_STATE_STOPPED;
ringbuffer->cond = g_cond_new ();
ringbuffer->waiting = 0;
ringbuffer->empty_seg = NULL;
}
static void
-gst_ring_buffer_dispose (GObject * object)
+gst_audio_ring_buffer_dispose (GObject * object)
{
- GstRingBuffer *ringbuffer = GST_RING_BUFFER (object);
+ GstAudioRingBuffer *ringbuffer = GST_AUDIO_RING_BUFFER (object);
gst_caps_replace (&ringbuffer->spec.caps, NULL);
- G_OBJECT_CLASS (gst_ring_buffer_parent_class)->dispose (G_OBJECT
+ G_OBJECT_CLASS (gst_audio_ring_buffer_parent_class)->dispose (G_OBJECT
(ringbuffer));
}
static void
-gst_ring_buffer_finalize (GObject * object)
+gst_audio_ring_buffer_finalize (GObject * object)
{
- GstRingBuffer *ringbuffer = GST_RING_BUFFER (object);
+ GstAudioRingBuffer *ringbuffer = GST_AUDIO_RING_BUFFER (object);
g_cond_free (ringbuffer->cond);
g_free (ringbuffer->empty_seg);
- G_OBJECT_CLASS (gst_ring_buffer_parent_class)->finalize (G_OBJECT
+ G_OBJECT_CLASS (gst_audio_ring_buffer_parent_class)->finalize (G_OBJECT
(ringbuffer));
}
#endif
/**
- * gst_ring_buffer_debug_spec_caps:
+ * gst_audio_ring_buffer_debug_spec_caps:
* @spec: the spec to debug
*
* Print debug info about the parsed caps in @spec to the debug log.
*/
void
-gst_ring_buffer_debug_spec_caps (GstRingBufferSpec * spec)
+gst_audio_ring_buffer_debug_spec_caps (GstAudioRingBufferSpec * spec)
{
#if 0
gint i, bytes;
}
/**
- * gst_ring_buffer_debug_spec_buff:
+ * gst_audio_ring_buffer_debug_spec_buff:
* @spec: the spec to debug
*
* Print debug info about the buffer sized in @spec to the debug log.
*/
void
-gst_ring_buffer_debug_spec_buff (GstRingBufferSpec * spec)
+gst_audio_ring_buffer_debug_spec_buff (GstAudioRingBufferSpec * spec)
{
gint bpf = GST_AUDIO_INFO_BPF (&spec->info);
}
/**
- * gst_ring_buffer_parse_caps:
+ * gst_audio_ring_buffer_parse_caps:
* @spec: a spec
* @caps: a #GstCaps
*
* Returns: TRUE if the caps could be parsed.
*/
gboolean
-gst_ring_buffer_parse_caps (GstRingBufferSpec * spec, GstCaps * caps)
+gst_audio_ring_buffer_parse_caps (GstAudioRingBufferSpec * spec, GstCaps * caps)
{
const gchar *mimetype;
GstStructure *structure;
spec->info = info;
- gst_ring_buffer_debug_spec_caps (spec);
- gst_ring_buffer_debug_spec_buff (spec);
+ gst_audio_ring_buffer_debug_spec_caps (spec);
+ gst_audio_ring_buffer_debug_spec_buff (spec);
return TRUE;
}
/**
- * gst_ring_buffer_convert:
- * @buf: the #GstRingBuffer
+ * gst_audio_ring_buffer_convert:
+ * @buf: the #GstAudioRingBuffer
* @src_fmt: the source format
* @src_val: the source value
* @dest_fmt: the destination format
* Since: 0.10.22.
*/
gboolean
-gst_ring_buffer_convert (GstRingBuffer * buf,
+gst_audio_ring_buffer_convert (GstAudioRingBuffer * buf,
GstFormat src_fmt, gint64 src_val, GstFormat dest_fmt, gint64 * dest_val)
{
gboolean res;
}
/**
- * gst_ring_buffer_set_callback:
- * @buf: the #GstRingBuffer to set the callback on
+ * gst_audio_ring_buffer_set_callback:
+ * @buf: the #GstAudioRingBuffer to set the callback on
* @cb: the callback to set
* @user_data: user data passed to the callback
*
* MT safe.
*/
void
-gst_ring_buffer_set_callback (GstRingBuffer * buf, GstRingBufferCallback cb,
- gpointer user_data)
+gst_audio_ring_buffer_set_callback (GstAudioRingBuffer * buf,
+ GstAudioRingBufferCallback cb, gpointer user_data)
{
- g_return_if_fail (GST_IS_RING_BUFFER (buf));
+ g_return_if_fail (GST_IS_AUDIO_RING_BUFFER (buf));
GST_OBJECT_LOCK (buf);
buf->callback = cb;
/**
- * gst_ring_buffer_open_device:
- * @buf: the #GstRingBuffer
+ * gst_audio_ring_buffer_open_device:
+ * @buf: the #GstAudioRingBuffer
*
* Open the audio device associated with the ring buffer. Does not perform any
* setup on the device. You must open the device before acquiring the ring
* MT safe.
*/
gboolean
-gst_ring_buffer_open_device (GstRingBuffer * buf)
+gst_audio_ring_buffer_open_device (GstAudioRingBuffer * buf)
{
gboolean res = TRUE;
- GstRingBufferClass *rclass;
+ GstAudioRingBufferClass *rclass;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), FALSE);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), FALSE);
GST_DEBUG_OBJECT (buf, "opening device");
/* if this fails, something is wrong in this file */
g_assert (!buf->acquired);
- rclass = GST_RING_BUFFER_GET_CLASS (buf);
+ rclass = GST_AUDIO_RING_BUFFER_GET_CLASS (buf);
if (G_LIKELY (rclass->open_device))
res = rclass->open_device (buf);
}
/**
- * gst_ring_buffer_close_device:
- * @buf: the #GstRingBuffer
+ * gst_audio_ring_buffer_close_device:
+ * @buf: the #GstAudioRingBuffer
*
* Close the audio device associated with the ring buffer. The ring buffer
- * should already have been released via gst_ring_buffer_release().
+ * should already have been released via gst_audio_ring_buffer_release().
*
* Returns: TRUE if the device could be closed, FALSE on error.
*
* MT safe.
*/
gboolean
-gst_ring_buffer_close_device (GstRingBuffer * buf)
+gst_audio_ring_buffer_close_device (GstAudioRingBuffer * buf)
{
gboolean res = TRUE;
- GstRingBufferClass *rclass;
+ GstAudioRingBufferClass *rclass;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), FALSE);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), FALSE);
GST_DEBUG_OBJECT (buf, "closing device");
buf->open = FALSE;
- rclass = GST_RING_BUFFER_GET_CLASS (buf);
+ rclass = GST_AUDIO_RING_BUFFER_GET_CLASS (buf);
if (G_LIKELY (rclass->close_device))
res = rclass->close_device (buf);
}
/**
- * gst_ring_buffer_device_is_open:
- * @buf: the #GstRingBuffer
+ * gst_audio_ring_buffer_device_is_open:
+ * @buf: the #GstAudioRingBuffer
*
* Checks the status of the device associated with the ring buffer.
*
* MT safe.
*/
gboolean
-gst_ring_buffer_device_is_open (GstRingBuffer * buf)
+gst_audio_ring_buffer_device_is_open (GstAudioRingBuffer * buf)
{
gboolean res = TRUE;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), FALSE);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), FALSE);
GST_OBJECT_LOCK (buf);
res = buf->open;
}
/**
- * gst_ring_buffer_acquire:
- * @buf: the #GstRingBuffer to acquire
+ * gst_audio_ring_buffer_acquire:
+ * @buf: the #GstAudioRingBuffer to acquire
* @spec: the specs of the buffer
*
* Allocate the resources for the ringbuffer. This function fills
* MT safe.
*/
gboolean
-gst_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
+gst_audio_ring_buffer_acquire (GstAudioRingBuffer * buf,
+ GstAudioRingBufferSpec * spec)
{
gboolean res = FALSE;
- GstRingBufferClass *rclass;
+ GstAudioRingBufferClass *rclass;
gint segsize, bpf;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), FALSE);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), FALSE);
GST_DEBUG_OBJECT (buf, "acquiring device %p", buf);
buf->acquired = TRUE;
- rclass = GST_RING_BUFFER_GET_CLASS (buf);
+ rclass = GST_AUDIO_RING_BUFFER_GET_CLASS (buf);
if (G_LIKELY (rclass->acquire))
res = rclass->acquire (buf, spec);
}
/**
- * gst_ring_buffer_release:
- * @buf: the #GstRingBuffer to release
+ * gst_audio_ring_buffer_release:
+ * @buf: the #GstAudioRingBuffer to release
*
* Free the resources of the ringbuffer.
*
* MT safe.
*/
gboolean
-gst_ring_buffer_release (GstRingBuffer * buf)
+gst_audio_ring_buffer_release (GstAudioRingBuffer * buf)
{
gboolean res = FALSE;
- GstRingBufferClass *rclass;
+ GstAudioRingBufferClass *rclass;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), FALSE);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), FALSE);
GST_DEBUG_OBJECT (buf, "releasing device");
- gst_ring_buffer_stop (buf);
+ gst_audio_ring_buffer_stop (buf);
GST_OBJECT_LOCK (buf);
if (G_UNLIKELY (!buf->acquired))
/* if this fails, something is wrong in this file */
g_assert (buf->open == TRUE);
- rclass = GST_RING_BUFFER_GET_CLASS (buf);
+ rclass = GST_AUDIO_RING_BUFFER_GET_CLASS (buf);
if (G_LIKELY (rclass->release))
res = rclass->release (buf);
/* signal any waiters */
GST_DEBUG_OBJECT (buf, "signal waiter");
- GST_RING_BUFFER_SIGNAL (buf);
+ GST_AUDIO_RING_BUFFER_SIGNAL (buf);
if (G_UNLIKELY (!res))
goto release_failed;
}
/**
- * gst_ring_buffer_is_acquired:
- * @buf: the #GstRingBuffer to check
+ * gst_audio_ring_buffer_is_acquired:
+ * @buf: the #GstAudioRingBuffer to check
*
* Check if the ringbuffer is acquired and ready to use.
*
* MT safe.
*/
gboolean
-gst_ring_buffer_is_acquired (GstRingBuffer * buf)
+gst_audio_ring_buffer_is_acquired (GstAudioRingBuffer * buf)
{
gboolean res;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), FALSE);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), FALSE);
GST_OBJECT_LOCK (buf);
res = buf->acquired;
}
/**
- * gst_ring_buffer_activate:
- * @buf: the #GstRingBuffer to activate
+ * gst_audio_ring_buffer_activate:
+ * @buf: the #GstAudioRingBuffer to activate
* @active: the new mode
*
* Activate @buf to start or stop pulling data.
* Since: 0.10.22.
*/
gboolean
-gst_ring_buffer_activate (GstRingBuffer * buf, gboolean active)
+gst_audio_ring_buffer_activate (GstAudioRingBuffer * buf, gboolean active)
{
gboolean res = FALSE;
- GstRingBufferClass *rclass;
+ GstAudioRingBufferClass *rclass;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), FALSE);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), FALSE);
GST_DEBUG_OBJECT (buf, "activate device");
if (G_UNLIKELY (buf->active == active))
goto was_active;
- rclass = GST_RING_BUFFER_GET_CLASS (buf);
+ rclass = GST_AUDIO_RING_BUFFER_GET_CLASS (buf);
/* if there is no activate function we assume it was started/released
* in the acquire method */
if (G_LIKELY (rclass->activate))
}
/**
- * gst_ring_buffer_is_active:
- * @buf: the #GstRingBuffer
+ * gst_audio_ring_buffer_is_active:
+ * @buf: the #GstAudioRingBuffer
*
* Check if @buf is activated.
*
* Since: 0.10.22.
*/
gboolean
-gst_ring_buffer_is_active (GstRingBuffer * buf)
+gst_audio_ring_buffer_is_active (GstAudioRingBuffer * buf)
{
gboolean res;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), FALSE);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), FALSE);
GST_OBJECT_LOCK (buf);
res = buf->active;
/**
- * gst_ring_buffer_set_flushing:
- * @buf: the #GstRingBuffer to flush
+ * gst_audio_ring_buffer_set_flushing:
+ * @buf: the #GstAudioRingBuffer to flush
* @flushing: the new mode
*
* Set the ringbuffer to flushing mode or normal mode.
* MT safe.
*/
void
-gst_ring_buffer_set_flushing (GstRingBuffer * buf, gboolean flushing)
+gst_audio_ring_buffer_set_flushing (GstAudioRingBuffer * buf, gboolean flushing)
{
- g_return_if_fail (GST_IS_RING_BUFFER (buf));
+ g_return_if_fail (GST_IS_AUDIO_RING_BUFFER (buf));
GST_OBJECT_LOCK (buf);
buf->flushing = flushing;
if (flushing) {
- gst_ring_buffer_pause_unlocked (buf);
+ gst_audio_ring_buffer_pause_unlocked (buf);
} else {
- gst_ring_buffer_clear_all (buf);
+ gst_audio_ring_buffer_clear_all (buf);
}
GST_OBJECT_UNLOCK (buf);
}
/**
- * gst_ring_buffer_start:
- * @buf: the #GstRingBuffer to start
+ * gst_audio_ring_buffer_start:
+ * @buf: the #GstAudioRingBuffer to start
*
* Start processing samples from the ringbuffer.
*
* MT safe.
*/
gboolean
-gst_ring_buffer_start (GstRingBuffer * buf)
+gst_audio_ring_buffer_start (GstAudioRingBuffer * buf)
{
gboolean res = FALSE;
- GstRingBufferClass *rclass;
+ GstAudioRingBufferClass *rclass;
gboolean resume = FALSE;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), FALSE);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), FALSE);
GST_DEBUG_OBJECT (buf, "starting ringbuffer");
/* if stopped, set to started */
res = g_atomic_int_compare_and_exchange (&buf->state,
- GST_RING_BUFFER_STATE_STOPPED, GST_RING_BUFFER_STATE_STARTED);
+ GST_AUDIO_RING_BUFFER_STATE_STOPPED, GST_AUDIO_RING_BUFFER_STATE_STARTED);
if (!res) {
GST_DEBUG_OBJECT (buf, "was not stopped, try paused");
/* was not stopped, try from paused */
res = g_atomic_int_compare_and_exchange (&buf->state,
- GST_RING_BUFFER_STATE_PAUSED, GST_RING_BUFFER_STATE_STARTED);
+ GST_AUDIO_RING_BUFFER_STATE_PAUSED,
+ GST_AUDIO_RING_BUFFER_STATE_STARTED);
if (!res) {
/* was not paused either, must be started then */
res = TRUE;
GST_DEBUG_OBJECT (buf, "resuming");
}
- rclass = GST_RING_BUFFER_GET_CLASS (buf);
+ rclass = GST_AUDIO_RING_BUFFER_GET_CLASS (buf);
if (resume) {
if (G_LIKELY (rclass->resume))
res = rclass->resume (buf);
}
if (G_UNLIKELY (!res)) {
- buf->state = GST_RING_BUFFER_STATE_PAUSED;
+ buf->state = GST_AUDIO_RING_BUFFER_STATE_PAUSED;
GST_DEBUG_OBJECT (buf, "failed to start");
} else {
GST_DEBUG_OBJECT (buf, "started");
}
static gboolean
-gst_ring_buffer_pause_unlocked (GstRingBuffer * buf)
+gst_audio_ring_buffer_pause_unlocked (GstAudioRingBuffer * buf)
{
gboolean res = FALSE;
- GstRingBufferClass *rclass;
+ GstAudioRingBufferClass *rclass;
GST_DEBUG_OBJECT (buf, "pausing ringbuffer");
/* if started, set to paused */
res = g_atomic_int_compare_and_exchange (&buf->state,
- GST_RING_BUFFER_STATE_STARTED, GST_RING_BUFFER_STATE_PAUSED);
+ GST_AUDIO_RING_BUFFER_STATE_STARTED, GST_AUDIO_RING_BUFFER_STATE_PAUSED);
if (!res)
goto not_started;
/* signal any waiters */
GST_DEBUG_OBJECT (buf, "signal waiter");
- GST_RING_BUFFER_SIGNAL (buf);
+ GST_AUDIO_RING_BUFFER_SIGNAL (buf);
- rclass = GST_RING_BUFFER_GET_CLASS (buf);
+ rclass = GST_AUDIO_RING_BUFFER_GET_CLASS (buf);
if (G_LIKELY (rclass->pause))
res = rclass->pause (buf);
if (G_UNLIKELY (!res)) {
- buf->state = GST_RING_BUFFER_STATE_STARTED;
+ buf->state = GST_AUDIO_RING_BUFFER_STATE_STARTED;
GST_DEBUG_OBJECT (buf, "failed to pause");
} else {
GST_DEBUG_OBJECT (buf, "paused");
}
/**
- * gst_ring_buffer_pause:
- * @buf: the #GstRingBuffer to pause
+ * gst_audio_ring_buffer_pause:
+ * @buf: the #GstAudioRingBuffer to pause
*
* Pause processing samples from the ringbuffer.
*
* MT safe.
*/
gboolean
-gst_ring_buffer_pause (GstRingBuffer * buf)
+gst_audio_ring_buffer_pause (GstAudioRingBuffer * buf)
{
gboolean res = FALSE;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), FALSE);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), FALSE);
GST_OBJECT_LOCK (buf);
if (G_UNLIKELY (buf->flushing))
if (G_UNLIKELY (!buf->acquired))
goto not_acquired;
- res = gst_ring_buffer_pause_unlocked (buf);
+ res = gst_audio_ring_buffer_pause_unlocked (buf);
GST_OBJECT_UNLOCK (buf);
return res;
}
/**
- * gst_ring_buffer_stop:
- * @buf: the #GstRingBuffer to stop
+ * gst_audio_ring_buffer_stop:
+ * @buf: the #GstAudioRingBuffer to stop
*
* Stop processing samples from the ringbuffer.
*
* MT safe.
*/
gboolean
-gst_ring_buffer_stop (GstRingBuffer * buf)
+gst_audio_ring_buffer_stop (GstAudioRingBuffer * buf)
{
gboolean res = FALSE;
- GstRingBufferClass *rclass;
+ GstAudioRingBufferClass *rclass;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), FALSE);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), FALSE);
GST_DEBUG_OBJECT (buf, "stopping");
/* if started, set to stopped */
res = g_atomic_int_compare_and_exchange (&buf->state,
- GST_RING_BUFFER_STATE_STARTED, GST_RING_BUFFER_STATE_STOPPED);
+ GST_AUDIO_RING_BUFFER_STATE_STARTED, GST_AUDIO_RING_BUFFER_STATE_STOPPED);
if (!res) {
GST_DEBUG_OBJECT (buf, "was not started, try paused");
/* was not started, try from paused */
res = g_atomic_int_compare_and_exchange (&buf->state,
- GST_RING_BUFFER_STATE_PAUSED, GST_RING_BUFFER_STATE_STOPPED);
+ GST_AUDIO_RING_BUFFER_STATE_PAUSED,
+ GST_AUDIO_RING_BUFFER_STATE_STOPPED);
if (!res) {
/* was not paused either, must have been stopped then */
res = TRUE;
/* signal any waiters */
GST_DEBUG_OBJECT (buf, "signal waiter");
- GST_RING_BUFFER_SIGNAL (buf);
+ GST_AUDIO_RING_BUFFER_SIGNAL (buf);
- rclass = GST_RING_BUFFER_GET_CLASS (buf);
+ rclass = GST_AUDIO_RING_BUFFER_GET_CLASS (buf);
if (G_LIKELY (rclass->stop))
res = rclass->stop (buf);
if (G_UNLIKELY (!res)) {
- buf->state = GST_RING_BUFFER_STATE_STARTED;
+ buf->state = GST_AUDIO_RING_BUFFER_STATE_STARTED;
GST_DEBUG_OBJECT (buf, "failed to stop");
} else {
GST_DEBUG_OBJECT (buf, "stopped");
}
/**
- * gst_ring_buffer_delay:
- * @buf: the #GstRingBuffer to query
+ * gst_audio_ring_buffer_delay:
+ * @buf: the #GstAudioRingBuffer to query
*
* Get the number of samples queued in the audio device. This is
* usually less than the segment size but can be bigger when the
* MT safe.
*/
guint
-gst_ring_buffer_delay (GstRingBuffer * buf)
+gst_audio_ring_buffer_delay (GstAudioRingBuffer * buf)
{
- GstRingBufferClass *rclass;
+ GstAudioRingBufferClass *rclass;
guint res;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), 0);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), 0);
/* buffer must be acquired */
- if (G_UNLIKELY (!gst_ring_buffer_is_acquired (buf)))
+ if (G_UNLIKELY (!gst_audio_ring_buffer_is_acquired (buf)))
goto not_acquired;
- rclass = GST_RING_BUFFER_GET_CLASS (buf);
+ rclass = GST_AUDIO_RING_BUFFER_GET_CLASS (buf);
if (G_LIKELY (rclass->delay))
res = rclass->delay (buf);
else
}
/**
- * gst_ring_buffer_samples_done:
- * @buf: the #GstRingBuffer to query
+ * gst_audio_ring_buffer_samples_done:
+ * @buf: the #GstAudioRingBuffer to query
*
* Get the number of samples that were processed by the ringbuffer
* since it was last started. This does not include the number of samples not
- * yet processed (see gst_ring_buffer_delay()).
+ * yet processed (see gst_audio_ring_buffer_delay()).
*
* Returns: The number of samples processed by the ringbuffer.
*
* MT safe.
*/
guint64
-gst_ring_buffer_samples_done (GstRingBuffer * buf)
+gst_audio_ring_buffer_samples_done (GstAudioRingBuffer * buf)
{
gint segdone;
guint64 samples;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), 0);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), 0);
/* get the amount of segments we processed */
segdone = g_atomic_int_get (&buf->segdone);
}
/**
- * gst_ring_buffer_set_sample:
- * @buf: the #GstRingBuffer to use
+ * gst_audio_ring_buffer_set_sample:
+ * @buf: the #GstAudioRingBuffer to use
* @sample: the sample number to set
*
* Make sure that the next sample written to the device is
* MT safe.
*/
void
-gst_ring_buffer_set_sample (GstRingBuffer * buf, guint64 sample)
+gst_audio_ring_buffer_set_sample (GstAudioRingBuffer * buf, guint64 sample)
{
- g_return_if_fail (GST_IS_RING_BUFFER (buf));
+ g_return_if_fail (GST_IS_AUDIO_RING_BUFFER (buf));
if (sample == -1)
sample = 0;
* offset when calculating the processed samples. */
buf->segbase = buf->segdone - sample / buf->samples_per_seg;
- gst_ring_buffer_clear_all (buf);
+ gst_audio_ring_buffer_clear_all (buf);
GST_DEBUG_OBJECT (buf, "set sample to %" G_GUINT64_FORMAT ", segbase %d",
sample, buf->segbase);
}
static void
-default_clear_all (GstRingBuffer * buf)
+default_clear_all (GstAudioRingBuffer * buf)
{
gint i;
GST_DEBUG_OBJECT (buf, "clear all segments");
for (i = 0; i < buf->spec.segtotal; i++) {
- gst_ring_buffer_clear (buf, i);
+ gst_audio_ring_buffer_clear (buf, i);
}
}
/**
- * gst_ring_buffer_clear_all:
- * @buf: the #GstRingBuffer to clear
+ * gst_audio_ring_buffer_clear_all:
+ * @buf: the #GstAudioRingBuffer to clear
*
* Fill the ringbuffer with silence.
*
* MT safe.
*/
void
-gst_ring_buffer_clear_all (GstRingBuffer * buf)
+gst_audio_ring_buffer_clear_all (GstAudioRingBuffer * buf)
{
- GstRingBufferClass *rclass;
+ GstAudioRingBufferClass *rclass;
- g_return_if_fail (GST_IS_RING_BUFFER (buf));
+ g_return_if_fail (GST_IS_AUDIO_RING_BUFFER (buf));
- rclass = GST_RING_BUFFER_GET_CLASS (buf);
+ rclass = GST_AUDIO_RING_BUFFER_GET_CLASS (buf);
if (G_LIKELY (rclass->clear_all))
rclass->clear_all (buf);
static gboolean
-wait_segment (GstRingBuffer * buf)
+wait_segment (GstAudioRingBuffer * buf)
{
gint segments;
gboolean wait = TRUE;
/* buffer must be started now or we deadlock since nobody is reading */
if (G_UNLIKELY (g_atomic_int_get (&buf->state) !=
- GST_RING_BUFFER_STATE_STARTED)) {
+ GST_AUDIO_RING_BUFFER_STATE_STARTED)) {
/* see if we are allowed to start it */
if (G_UNLIKELY (g_atomic_int_get (&buf->may_start) == FALSE))
goto no_start;
GST_DEBUG_OBJECT (buf, "start!");
segments = g_atomic_int_get (&buf->segdone);
- gst_ring_buffer_start (buf);
+ gst_audio_ring_buffer_start (buf);
/* After starting, the writer may have wrote segments already and then we
* don't need to wait anymore */
goto flushing;
if (G_UNLIKELY (g_atomic_int_get (&buf->state) !=
- GST_RING_BUFFER_STATE_STARTED))
+ GST_AUDIO_RING_BUFFER_STATE_STARTED))
goto not_started;
if (G_LIKELY (wait)) {
if (g_atomic_int_compare_and_exchange (&buf->waiting, 0, 1)) {
GST_DEBUG_OBJECT (buf, "waiting..");
- GST_RING_BUFFER_WAIT (buf);
+ GST_AUDIO_RING_BUFFER_WAIT (buf);
if (G_UNLIKELY (buf->flushing))
goto flushing;
if (G_UNLIKELY (g_atomic_int_get (&buf->state) !=
- GST_RING_BUFFER_STATE_STARTED))
+ GST_AUDIO_RING_BUFFER_STATE_STARTED))
goto not_started;
}
}
} G_STMT_END
static guint
-default_commit (GstRingBuffer * buf, guint64 * sample,
+default_commit (GstAudioRingBuffer * buf, guint64 * sample,
guchar * data, gint in_samples, gint out_samples, gint * accum)
{
gint segdone;
}
/**
- * gst_ring_buffer_commit_full:
- * @buf: the #GstRingBuffer to commit
+ * gst_audio_ring_buffer_commit_full:
+ * @buf: the #GstAudioRingBuffer to commit
* @sample: the sample position of the data
* @data: the data to commit
* @in_samples: the number of samples in the data to commit
* Since: 0.10.11.
*/
guint
-gst_ring_buffer_commit_full (GstRingBuffer * buf, guint64 * sample,
+gst_audio_ring_buffer_commit_full (GstAudioRingBuffer * buf, guint64 * sample,
guchar * data, gint in_samples, gint out_samples, gint * accum)
{
- GstRingBufferClass *rclass;
+ GstAudioRingBufferClass *rclass;
guint res = -1;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), -1);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), -1);
if (G_UNLIKELY (in_samples == 0 || out_samples == 0))
return in_samples;
- rclass = GST_RING_BUFFER_GET_CLASS (buf);
+ rclass = GST_AUDIO_RING_BUFFER_GET_CLASS (buf);
if (G_LIKELY (rclass->commit))
res = rclass->commit (buf, sample, data, in_samples, out_samples, accum);
}
/**
- * gst_ring_buffer_commit:
- * @buf: the #GstRingBuffer to commit
+ * gst_audio_ring_buffer_commit:
+ * @buf: the #GstAudioRingBuffer to commit
* @sample: the sample position of the data
* @data: the data to commit
* @len: the number of samples in the data to commit
*
- * Same as gst_ring_buffer_commit_full() but with a in_samples and out_samples
+ * Same as gst_audio_ring_buffer_commit_full() but with a in_samples and out_samples
* equal to @len, ignoring accum.
*
* Returns: The number of samples written to the ringbuffer or -1 on
* MT safe.
*/
guint
-gst_ring_buffer_commit (GstRingBuffer * buf, guint64 sample, guchar * data,
- guint len)
+gst_audio_ring_buffer_commit (GstAudioRingBuffer * buf, guint64 sample,
+ guchar * data, guint len)
{
guint res;
guint64 samplep = sample;
- res = gst_ring_buffer_commit_full (buf, &samplep, data, len, len, NULL);
+ res = gst_audio_ring_buffer_commit_full (buf, &samplep, data, len, len, NULL);
return res;
}
/**
- * gst_ring_buffer_read:
- * @buf: the #GstRingBuffer to read from
+ * gst_audio_ring_buffer_read:
+ * @buf: the #GstAudioRingBuffer to read from
* @sample: the sample position of the data
* @data: where the data should be read
* @len: the number of samples in data to read
* MT safe.
*/
guint
-gst_ring_buffer_read (GstRingBuffer * buf, guint64 sample, guchar * data,
- guint len)
+gst_audio_ring_buffer_read (GstAudioRingBuffer * buf, guint64 sample,
+ guchar * data, guint len)
{
gint segdone;
gint segsize, segtotal, bpf, sps;
guint8 *dest;
guint to_read;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), -1);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), -1);
g_return_val_if_fail (buf->memory != NULL, -1);
g_return_val_if_fail (data != NULL, -1);
}
/**
- * gst_ring_buffer_prepare_read:
- * @buf: the #GstRingBuffer to read from
+ * gst_audio_ring_buffer_prepare_read:
+ * @buf: the #GstAudioRingBuffer to read from
* @segment: the segment to read
* @readptr: the pointer to the memory where samples can be read
* @len: the number of bytes to read
* MT safe.
*/
gboolean
-gst_ring_buffer_prepare_read (GstRingBuffer * buf, gint * segment,
+gst_audio_ring_buffer_prepare_read (GstAudioRingBuffer * buf, gint * segment,
guint8 ** readptr, gint * len)
{
guint8 *data;
gint segdone;
- g_return_val_if_fail (GST_IS_RING_BUFFER (buf), FALSE);
+ g_return_val_if_fail (GST_IS_AUDIO_RING_BUFFER (buf), FALSE);
if (buf->callback == NULL) {
/* push mode, fail when nothing is started */
- if (g_atomic_int_get (&buf->state) != GST_RING_BUFFER_STATE_STARTED)
+ if (g_atomic_int_get (&buf->state) != GST_AUDIO_RING_BUFFER_STATE_STARTED)
return FALSE;
}
}
/**
- * gst_ring_buffer_advance:
- * @buf: the #GstRingBuffer to advance
+ * gst_audio_ring_buffer_advance:
+ * @buf: the #GstAudioRingBuffer to advance
* @advance: the number of segments written
*
* Subclasses should call this function to notify the fact that
* MT safe.
*/
void
-gst_ring_buffer_advance (GstRingBuffer * buf, guint advance)
+gst_audio_ring_buffer_advance (GstAudioRingBuffer * buf, guint advance)
{
- g_return_if_fail (GST_IS_RING_BUFFER (buf));
+ g_return_if_fail (GST_IS_AUDIO_RING_BUFFER (buf));
/* update counter */
g_atomic_int_add (&buf->segdone, advance);
if (g_atomic_int_compare_and_exchange (&buf->waiting, 1, 0)) {
GST_OBJECT_LOCK (buf);
GST_DEBUG_OBJECT (buf, "signal waiter");
- GST_RING_BUFFER_SIGNAL (buf);
+ GST_AUDIO_RING_BUFFER_SIGNAL (buf);
GST_OBJECT_UNLOCK (buf);
}
}
/**
- * gst_ring_buffer_clear:
- * @buf: the #GstRingBuffer to clear
+ * gst_audio_ring_buffer_clear:
+ * @buf: the #GstAudioRingBuffer to clear
* @segment: the segment to clear
*
* Clear the given segment of the buffer with silence samples.
* MT safe.
*/
void
-gst_ring_buffer_clear (GstRingBuffer * buf, gint segment)
+gst_audio_ring_buffer_clear (GstAudioRingBuffer * buf, gint segment)
{
guint8 *data;
- g_return_if_fail (GST_IS_RING_BUFFER (buf));
+ g_return_if_fail (GST_IS_AUDIO_RING_BUFFER (buf));
/* no data means it's already cleared */
if (G_UNLIKELY (buf->memory == NULL))
}
/**
- * gst_ring_buffer_may_start:
- * @buf: the #GstRingBuffer
+ * gst_audio_ring_buffer_may_start:
+ * @buf: the #GstAudioRingBuffer
* @allowed: the new value
*
* Tell the ringbuffer that it is allowed to start playback when
* Since: 0.10.6
*/
void
-gst_ring_buffer_may_start (GstRingBuffer * buf, gboolean allowed)
+gst_audio_ring_buffer_may_start (GstAudioRingBuffer * buf, gboolean allowed)
{
- g_return_if_fail (GST_IS_RING_BUFFER (buf));
+ g_return_if_fail (GST_IS_AUDIO_RING_BUFFER (buf));
GST_LOG_OBJECT (buf, "may start: %d", allowed);
g_atomic_int_set (&buf->may_start, allowed);
* Boston, MA 02111-1307, USA.
*/
-#ifndef __GST_RING_BUFFER_H__
-#define __GST_RING_BUFFER_H__
+#ifndef __GST_AUDIO_RING_BUFFER_H__
+#define __GST_AUDIO_RING_BUFFER_H__
#include <gst/gst.h>
#include <gst/audio/audio.h>
G_BEGIN_DECLS
-#define GST_TYPE_RING_BUFFER (gst_ring_buffer_get_type())
-#define GST_RING_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RING_BUFFER,GstRingBuffer))
-#define GST_RING_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RING_BUFFER,GstRingBufferClass))
-#define GST_RING_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RING_BUFFER, GstRingBufferClass))
-#define GST_RING_BUFFER_CAST(obj) ((GstRingBuffer *)obj)
-#define GST_IS_RING_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RING_BUFFER))
-#define GST_IS_RING_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RING_BUFFER))
+#define GST_TYPE_AUDIO_RING_BUFFER (gst_audio_ring_buffer_get_type())
+#define GST_AUDIO_RING_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_RING_BUFFER,GstAudioRingBuffer))
+#define GST_AUDIO_RING_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_RING_BUFFER,GstAudioRingBufferClass))
+#define GST_AUDIO_RING_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_AUDIO_RING_BUFFER, GstAudioRingBufferClass))
+#define GST_AUDIO_RING_BUFFER_CAST(obj) ((GstAudioRingBuffer *)obj)
+#define GST_IS_AUDIO_RING_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_RING_BUFFER))
+#define GST_IS_AUDIO_RING_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_RING_BUFFER))
-typedef struct _GstRingBuffer GstRingBuffer;
-typedef struct _GstRingBufferClass GstRingBufferClass;
-typedef struct _GstRingBufferSpec GstRingBufferSpec;
+typedef struct _GstAudioRingBuffer GstAudioRingBuffer;
+typedef struct _GstAudioRingBufferClass GstAudioRingBufferClass;
+typedef struct _GstAudioRingBufferSpec GstAudioRingBufferSpec;
/**
- * GstRingBufferCallback:
- * @rbuf: a #GstRingBuffer
+ * GstAudioRingBufferCallback:
+ * @rbuf: a #GstAudioRingBuffer
* @data: target to fill
* @len: amount to fill
* @user_data: user data
*
- * This function is set with gst_ring_buffer_set_callback() and is
+ * This function is set with gst_audio_ring_buffer_set_callback() and is
* called to fill the memory at @data with @len bytes of samples.
*/
-typedef void (*GstRingBufferCallback) (GstRingBuffer *rbuf, guint8* data, guint len, gpointer user_data);
+typedef void (*GstAudioRingBufferCallback) (GstAudioRingBuffer *rbuf, guint8* data, guint len, gpointer user_data);
/**
- * GstRingBufferState:
- * @GST_RING_BUFFER_STATE_STOPPED: The ringbuffer is stopped
- * @GST_RING_BUFFER_STATE_PAUSED: The ringbuffer is paused
- * @GST_RING_BUFFER_STATE_STARTED: The ringbuffer is started
+ * GstAudioRingBufferState:
+ * @GST_AUDIO_RING_BUFFER_STATE_STOPPED: The ringbuffer is stopped
+ * @GST_AUDIO_RING_BUFFER_STATE_PAUSED: The ringbuffer is paused
+ * @GST_AUDIO_RING_BUFFER_STATE_STARTED: The ringbuffer is started
*
* The state of the ringbuffer.
*/
typedef enum {
- GST_RING_BUFFER_STATE_STOPPED,
- GST_RING_BUFFER_STATE_PAUSED,
- GST_RING_BUFFER_STATE_STARTED
-} GstRingBufferState;
+ GST_AUDIO_RING_BUFFER_STATE_STOPPED,
+ GST_AUDIO_RING_BUFFER_STATE_PAUSED,
+ GST_AUDIO_RING_BUFFER_STATE_STARTED
+} GstAudioRingBufferState;
/**
- * GstRingBufferSegState:
+ * GstAudioRingBufferSegState:
* @GST_SEGSTATE_INVALID: The content of the segment is invalid
* @GST_SEGSTATE_EMPTY: The segment is empty
* @GST_SEGSTATE_FILLED: The segment contains valid data
GST_SEGSTATE_EMPTY,
GST_SEGSTATE_FILLED,
GST_SEGSTATE_PARTIAL
-} GstRingBufferSegState;
+} GstAudioRingBufferSegState;
/**
* GstBufferFormatType:
} GstBufferFormatType;
/**
- * GstRingBufferSpec:
+ * GstAudioRingBufferSpec:
* @caps: The caps that generated the Spec.
* @type: the sample type
* @info: the #GstAudioInfo
*
* The structure containing the format specification of the ringbuffer.
*/
-struct _GstRingBufferSpec
+struct _GstAudioRingBufferSpec
{
/*< public >*/
/* in */
gpointer _gst_reserved[GST_PADDING];
};
-#define GST_RING_BUFFER_GET_COND(buf) (((GstRingBuffer *)buf)->cond)
-#define GST_RING_BUFFER_WAIT(buf) (g_cond_wait (GST_RING_BUFFER_GET_COND (buf), GST_OBJECT_GET_LOCK (buf)))
-#define GST_RING_BUFFER_SIGNAL(buf) (g_cond_signal (GST_RING_BUFFER_GET_COND (buf)))
-#define GST_RING_BUFFER_BROADCAST(buf)(g_cond_broadcast (GST_RING_BUFFER_GET_COND (buf)))
+#define GST_AUDIO_RING_BUFFER_GET_COND(buf) (((GstAudioRingBuffer *)buf)->cond)
+#define GST_AUDIO_RING_BUFFER_WAIT(buf) (g_cond_wait (GST_AUDIO_RING_BUFFER_GET_COND (buf), GST_OBJECT_GET_LOCK (buf)))
+#define GST_AUDIO_RING_BUFFER_SIGNAL(buf) (g_cond_signal (GST_AUDIO_RING_BUFFER_GET_COND (buf)))
+#define GST_AUDIO_RING_BUFFER_BROADCAST(buf)(g_cond_broadcast (GST_AUDIO_RING_BUFFER_GET_COND (buf)))
/**
- * GstRingBuffer:
+ * GstAudioRingBuffer:
* @cond: used to signal start/stop/pause/resume actions
* @open: boolean indicating that the ringbuffer is open
* @acquired: boolean indicating that the ringbuffer is acquired
*
* The ringbuffer base class structure.
*/
-struct _GstRingBuffer {
- GstObject object;
+struct _GstAudioRingBuffer {
+ GstObject object;
/*< public >*/ /* with LOCK */
- GCond *cond;
- gboolean open;
- gboolean acquired;
- guint8 *memory;
- gsize size;
- GstRingBufferSpec spec;
- GstRingBufferSegState *segstate;
- gint samples_per_seg;
- guint8 *empty_seg;
+ GCond *cond;
+ gboolean open;
+ gboolean acquired;
+ guint8 *memory;
+ gsize size;
+ GstAudioRingBufferSpec spec;
+ GstAudioRingBufferSegState *segstate;
+ gint samples_per_seg;
+ guint8 *empty_seg;
/*< public >*/ /* ATOMIC */
- gint state;
- gint segdone;
- gint segbase;
- gint waiting;
+ gint state;
+ gint segdone;
+ gint segbase;
+ gint waiting;
/*< private >*/
- GstRingBufferCallback callback;
- gpointer cb_data;
+ GstAudioRingBufferCallback callback;
+ gpointer cb_data;
- gboolean flushing;
+ gboolean flushing;
/* ATOMIC */
- gint may_start;
- gboolean active;
+ gint may_start;
+ gboolean active;
/*< private >*/
- gpointer _gst_reserved[GST_PADDING + 0];
+ gpointer _gst_reserved[GST_PADDING];
};
/**
- * GstRingBufferClass:
+ * GstAudioRingBufferClass:
* @parent_class: parent class
* @open_device: open the device, don't set any params or allocate anything
* @acquire: allocate the resources for the ringbuffer using the given spec
*
* The vmethods that subclasses can override to implement the ringbuffer.
*/
-struct _GstRingBufferClass {
+struct _GstAudioRingBufferClass {
GstObjectClass parent_class;
/*< public >*/
- gboolean (*open_device) (GstRingBuffer *buf);
- gboolean (*acquire) (GstRingBuffer *buf, GstRingBufferSpec *spec);
- gboolean (*release) (GstRingBuffer *buf);
- gboolean (*close_device) (GstRingBuffer *buf);
+ gboolean (*open_device) (GstAudioRingBuffer *buf);
+ gboolean (*acquire) (GstAudioRingBuffer *buf, GstAudioRingBufferSpec *spec);
+ gboolean (*release) (GstAudioRingBuffer *buf);
+ gboolean (*close_device) (GstAudioRingBuffer *buf);
- gboolean (*start) (GstRingBuffer *buf);
- gboolean (*pause) (GstRingBuffer *buf);
- gboolean (*resume) (GstRingBuffer *buf);
- gboolean (*stop) (GstRingBuffer *buf);
+ gboolean (*start) (GstAudioRingBuffer *buf);
+ gboolean (*pause) (GstAudioRingBuffer *buf);
+ gboolean (*resume) (GstAudioRingBuffer *buf);
+ gboolean (*stop) (GstAudioRingBuffer *buf);
- guint (*delay) (GstRingBuffer *buf);
+ guint (*delay) (GstAudioRingBuffer *buf);
/* ABI added */
- gboolean (*activate) (GstRingBuffer *buf, gboolean active);
+ gboolean (*activate) (GstAudioRingBuffer *buf, gboolean active);
- guint (*commit) (GstRingBuffer * buf, guint64 *sample,
+ guint (*commit) (GstAudioRingBuffer * buf, guint64 *sample,
guchar * data, gint in_samples,
gint out_samples, gint * accum);
- void (*clear_all) (GstRingBuffer * buf);
+ void (*clear_all) (GstAudioRingBuffer * buf);
/*< private >*/
- gpointer _gst_reserved[GST_PADDING - 3];
+ gpointer _gst_reserved[GST_PADDING];
};
-GType gst_ring_buffer_get_type(void);
+GType gst_audio_ring_buffer_get_type(void);
/* callback stuff */
-void gst_ring_buffer_set_callback (GstRingBuffer *buf, GstRingBufferCallback cb,
- gpointer user_data);
+void gst_audio_ring_buffer_set_callback (GstAudioRingBuffer *buf,
+ GstAudioRingBufferCallback cb,
+ gpointer user_data);
-gboolean gst_ring_buffer_parse_caps (GstRingBufferSpec *spec, GstCaps *caps);
-void gst_ring_buffer_debug_spec_caps (GstRingBufferSpec *spec);
-void gst_ring_buffer_debug_spec_buff (GstRingBufferSpec *spec);
+gboolean gst_audio_ring_buffer_parse_caps (GstAudioRingBufferSpec *spec, GstCaps *caps);
+void gst_audio_ring_buffer_debug_spec_caps (GstAudioRingBufferSpec *spec);
+void gst_audio_ring_buffer_debug_spec_buff (GstAudioRingBufferSpec *spec);
-gboolean gst_ring_buffer_convert (GstRingBuffer * buf, GstFormat src_fmt,
- gint64 src_val, GstFormat dest_fmt,
- gint64 * dest_val);
+gboolean gst_audio_ring_buffer_convert (GstAudioRingBuffer * buf, GstFormat src_fmt,
+ gint64 src_val, GstFormat dest_fmt,
+ gint64 * dest_val);
/* device state */
-gboolean gst_ring_buffer_open_device (GstRingBuffer *buf);
-gboolean gst_ring_buffer_close_device (GstRingBuffer *buf);
+gboolean gst_audio_ring_buffer_open_device (GstAudioRingBuffer *buf);
+gboolean gst_audio_ring_buffer_close_device (GstAudioRingBuffer *buf);
-gboolean gst_ring_buffer_device_is_open (GstRingBuffer *buf);
+gboolean gst_audio_ring_buffer_device_is_open (GstAudioRingBuffer *buf);
/* allocate resources */
-gboolean gst_ring_buffer_acquire (GstRingBuffer *buf, GstRingBufferSpec *spec);
-gboolean gst_ring_buffer_release (GstRingBuffer *buf);
+gboolean gst_audio_ring_buffer_acquire (GstAudioRingBuffer *buf, GstAudioRingBufferSpec *spec);
+gboolean gst_audio_ring_buffer_release (GstAudioRingBuffer *buf);
-gboolean gst_ring_buffer_is_acquired (GstRingBuffer *buf);
+gboolean gst_audio_ring_buffer_is_acquired (GstAudioRingBuffer *buf);
/* activating */
-gboolean gst_ring_buffer_activate (GstRingBuffer *buf, gboolean active);
-gboolean gst_ring_buffer_is_active (GstRingBuffer *buf);
+gboolean gst_audio_ring_buffer_activate (GstAudioRingBuffer *buf, gboolean active);
+gboolean gst_audio_ring_buffer_is_active (GstAudioRingBuffer *buf);
/* flushing */
-void gst_ring_buffer_set_flushing (GstRingBuffer *buf, gboolean flushing);
+void gst_audio_ring_buffer_set_flushing (GstAudioRingBuffer *buf, gboolean flushing);
/* playback/pause */
-gboolean gst_ring_buffer_start (GstRingBuffer *buf);
-gboolean gst_ring_buffer_pause (GstRingBuffer *buf);
-gboolean gst_ring_buffer_stop (GstRingBuffer *buf);
+gboolean gst_audio_ring_buffer_start (GstAudioRingBuffer *buf);
+gboolean gst_audio_ring_buffer_pause (GstAudioRingBuffer *buf);
+gboolean gst_audio_ring_buffer_stop (GstAudioRingBuffer *buf);
/* get status */
-guint gst_ring_buffer_delay (GstRingBuffer *buf);
-guint64 gst_ring_buffer_samples_done (GstRingBuffer *buf);
+guint gst_audio_ring_buffer_delay (GstAudioRingBuffer *buf);
+guint64 gst_audio_ring_buffer_samples_done (GstAudioRingBuffer *buf);
-void gst_ring_buffer_set_sample (GstRingBuffer *buf, guint64 sample);
+void gst_audio_ring_buffer_set_sample (GstAudioRingBuffer *buf, guint64 sample);
/* clear all segments */
-void gst_ring_buffer_clear_all (GstRingBuffer *buf);
+void gst_audio_ring_buffer_clear_all (GstAudioRingBuffer *buf);
/* commit samples */
-guint gst_ring_buffer_commit (GstRingBuffer *buf, guint64 sample,
- guchar *data, guint len);
-guint gst_ring_buffer_commit_full (GstRingBuffer * buf, guint64 *sample,
- guchar * data, gint in_samples,
- gint out_samples, gint * accum);
+guint gst_audio_ring_buffer_commit (GstAudioRingBuffer *buf, guint64 sample,
+ guchar *data, guint len);
+guint gst_audio_ring_buffer_commit_full (GstAudioRingBuffer * buf, guint64 *sample,
+ guchar * data, gint in_samples,
+ gint out_samples, gint * accum);
/* read samples */
-guint gst_ring_buffer_read (GstRingBuffer *buf, guint64 sample,
- guchar *data, guint len);
+guint gst_audio_ring_buffer_read (GstAudioRingBuffer *buf, guint64 sample,
+ guchar *data, guint len);
/* mostly protected */
/* not yet implemented
-gboolean gst_ring_buffer_prepare_write (GstRingBuffer *buf, gint *segment, guint8 **writeptr, gint *len);
+gboolean gst_audio_ring_buffer_prepare_write (GstAudioRingBuffer *buf, gint *segment, guint8 **writeptr, gint *len);
*/
-gboolean gst_ring_buffer_prepare_read (GstRingBuffer *buf, gint *segment, guint8 **readptr, gint *len);
-void gst_ring_buffer_clear (GstRingBuffer *buf, gint segment);
-void gst_ring_buffer_advance (GstRingBuffer *buf, guint advance);
-
-void gst_ring_buffer_may_start (GstRingBuffer *buf, gboolean allowed);
+gboolean gst_audio_ring_buffer_prepare_read (GstAudioRingBuffer *buf, gint *segment,
+ guint8 **readptr, gint *len);
+void gst_audio_ring_buffer_clear (GstAudioRingBuffer *buf, gint segment);
+void gst_audio_ring_buffer_advance (GstAudioRingBuffer *buf, guint advance);
+void gst_audio_ring_buffer_may_start (GstAudioRingBuffer *buf, gboolean allowed);
G_END_DECLS
-#endif /* __GST_RING_BUFFER_H__ */
+#endif /* __GST_AUDIO_RING_BUFFER_H__ */