g_cond_clear (&ringbuffer->cond);
g_free (ringbuffer->empty_seg);
+ if (ringbuffer->cb_data_notify != NULL)
+ ringbuffer->cb_data_notify (ringbuffer->cb_data);
+
G_OBJECT_CLASS (gst_audio_ring_buffer_parent_class)->finalize (G_OBJECT
(ringbuffer));
}
}
/**
- * gst_audio_ring_buffer_set_callback:
+ * gst_audio_ring_buffer_set_callback: (skip)
* @buf: the #GstAudioRingBuffer to set the callback on
- * @cb: (scope async): the callback to set
+ * @cb: (allow-none): the callback to set
* @user_data: user data passed to the callback
*
* Sets the given callback function on the buffer. This function
gst_audio_ring_buffer_set_callback (GstAudioRingBuffer * buf,
GstAudioRingBufferCallback cb, gpointer user_data)
{
+ gst_audio_ring_buffer_set_callback_full (buf, cb, user_data, NULL);
+}
+
+/**
+ * gst_audio_ring_buffer_set_callback_full: (rename-to gst_audio_ring_buffer_set_callback)
+ * @buf: the #GstAudioRingBuffer to set the callback on
+ * @cb: (allow-none): the callback to set
+ * @user_data: user data passed to the callback
+ * @notify: function to be called when @user_data is no longer needed
+ *
+ * Sets the given callback function on the buffer. This function
+ * will be called every time a segment has been written to a device.
+ *
+ * MT safe.
+ *
+ * Since: 1.12
+ */
+void
+gst_audio_ring_buffer_set_callback_full (GstAudioRingBuffer * buf,
+ GstAudioRingBufferCallback cb, gpointer user_data, GDestroyNotify notify)
+{
+ gpointer old_data = NULL;
+ GDestroyNotify old_notify;
+
g_return_if_fail (GST_IS_AUDIO_RING_BUFFER (buf));
GST_OBJECT_LOCK (buf);
+ old_notify = buf->cb_data_notify;
+ old_data = buf->cb_data;
+
buf->callback = cb;
buf->cb_data = user_data;
+ buf->cb_data_notify = notify;
GST_OBJECT_UNLOCK (buf);
+
+ if (old_notify) {
+ old_notify (old_data);
+ }
}
gint may_start;
gboolean active;
+ GDestroyNotify cb_data_notify;
+
/*< private >*/
- gpointer _gst_reserved[GST_PADDING];
+ gpointer _gst_reserved[GST_PADDING - 1];
};
/**
GType gst_audio_ring_buffer_get_type(void);
/* callback stuff */
-void gst_audio_ring_buffer_set_callback (GstAudioRingBuffer *buf,
- GstAudioRingBufferCallback cb,
- gpointer user_data);
+void gst_audio_ring_buffer_set_callback (GstAudioRingBuffer *buf,
+ GstAudioRingBufferCallback cb,
+ gpointer user_data);
+void gst_audio_ring_buffer_set_callback_full (GstAudioRingBuffer *buf,
+ GstAudioRingBufferCallback cb,
+ gpointer user_data,
+ GDestroyNotify notify);
gboolean gst_audio_ring_buffer_parse_caps (GstAudioRingBufferSpec *spec, GstCaps *caps);
void gst_audio_ring_buffer_debug_spec_caps (GstAudioRingBufferSpec *spec);
gst_audio_ring_buffer_release
gst_audio_ring_buffer_samples_done
gst_audio_ring_buffer_set_callback
+ gst_audio_ring_buffer_set_callback_full
gst_audio_ring_buffer_set_channel_positions
gst_audio_ring_buffer_set_flushing
gst_audio_ring_buffer_set_sample