mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-04 01:32:42 +00:00
ringbuffer: add vmethod to clear the ringbuffer
Add a vmethod so that subclasses can be notified when they should clear the data in the ringbuffer.
This commit is contained in:
parent
a9097080a3
commit
8601862e27
2 changed files with 28 additions and 11 deletions
|
@ -52,6 +52,7 @@ static void gst_ring_buffer_dispose (GObject * object);
|
|||
static void gst_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,
|
||||
guchar * data, gint in_samples, gint out_samples, gint * accum);
|
||||
|
||||
|
@ -102,6 +103,7 @@ gst_ring_buffer_class_init (GstRingBufferClass * klass)
|
|||
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_ring_buffer_dispose);
|
||||
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_ring_buffer_finalize);
|
||||
|
||||
gstringbuffer_class->clear_all = GST_DEBUG_FUNCPTR (default_clear_all);
|
||||
gstringbuffer_class->commit = GST_DEBUG_FUNCPTR (default_commit);
|
||||
}
|
||||
|
||||
|
@ -1014,9 +1016,10 @@ gst_ring_buffer_set_flushing (GstRingBuffer * buf, gboolean flushing)
|
|||
GST_OBJECT_LOCK (buf);
|
||||
buf->abidata.ABI.flushing = flushing;
|
||||
|
||||
gst_ring_buffer_clear_all (buf);
|
||||
if (flushing) {
|
||||
gst_ring_buffer_pause_unlocked (buf);
|
||||
} else {
|
||||
gst_ring_buffer_clear_all (buf);
|
||||
}
|
||||
GST_OBJECT_UNLOCK (buf);
|
||||
}
|
||||
|
@ -1357,6 +1360,22 @@ gst_ring_buffer_set_sample (GstRingBuffer * buf, guint64 sample)
|
|||
buf->segbase);
|
||||
}
|
||||
|
||||
static void
|
||||
default_clear_all (GstRingBuffer * buf)
|
||||
{
|
||||
gint i;
|
||||
|
||||
/* not fatal, we just are not negotiated yet */
|
||||
if (G_UNLIKELY (buf->spec.segtotal <= 0))
|
||||
return;
|
||||
|
||||
GST_DEBUG_OBJECT (buf, "clear all segments");
|
||||
|
||||
for (i = 0; i < buf->spec.segtotal; i++) {
|
||||
gst_ring_buffer_clear (buf, i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_ring_buffer_clear_all:
|
||||
* @buf: the #GstRingBuffer to clear
|
||||
|
@ -1368,19 +1387,14 @@ gst_ring_buffer_set_sample (GstRingBuffer * buf, guint64 sample)
|
|||
void
|
||||
gst_ring_buffer_clear_all (GstRingBuffer * buf)
|
||||
{
|
||||
gint i;
|
||||
GstRingBufferClass *rclass;
|
||||
|
||||
g_return_if_fail (GST_IS_RING_BUFFER (buf));
|
||||
|
||||
/* not fatal, we just are not negotiated yet */
|
||||
if (G_UNLIKELY (buf->spec.segtotal <= 0))
|
||||
return;
|
||||
rclass = GST_RING_BUFFER_GET_CLASS (buf);
|
||||
|
||||
GST_DEBUG_OBJECT (buf, "clear all segments");
|
||||
|
||||
for (i = 0; i < buf->spec.segtotal; i++) {
|
||||
gst_ring_buffer_clear (buf, i);
|
||||
}
|
||||
if (G_LIKELY (rclass->clear_all))
|
||||
rclass->clear_all (buf);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -301,6 +301,7 @@ struct _GstRingBuffer {
|
|||
* @activate: activate the thread that starts pulling and monitoring the
|
||||
* consumed segments in the device. Since 0.10.22
|
||||
* @commit: write samples into the ringbuffer
|
||||
* @clear_all: clear the entire ringbuffer Since 0.10.24
|
||||
*
|
||||
* The vmethods that subclasses can override to implement the ringbuffer.
|
||||
*/
|
||||
|
@ -327,8 +328,10 @@ struct _GstRingBufferClass {
|
|||
guchar * data, gint in_samples,
|
||||
gint out_samples, gint * accum);
|
||||
|
||||
void (*clear_all) (GstRingBuffer * buf);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING - 2];
|
||||
gpointer _gst_reserved[GST_PADDING - 3];
|
||||
};
|
||||
|
||||
GType gst_ring_buffer_get_type(void);
|
||||
|
|
Loading…
Reference in a new issue