Commit 98064ed9 authored by Evan Nemerson's avatar Evan Nemerson Committed by Tim-Philipp Müller

audioringbuffer: add set_callback_full() for g-i

https://bugzilla.gnome.org/show_bug.cgi?id=678301
parent 07646dd1
......@@ -593,6 +593,7 @@ GST_AUDIO_RING_BUFFER_SIGNAL
GST_AUDIO_RING_BUFFER_WAIT
gst_audio_ring_buffer_set_callback
gst_audio_ring_buffer_set_callback_full
gst_audio_ring_buffer_acquire
gst_audio_ring_buffer_release
......
......@@ -109,6 +109,9 @@ gst_audio_ring_buffer_finalize (GObject * object)
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));
}
......@@ -356,9 +359,9 @@ gst_audio_ring_buffer_convert (GstAudioRingBuffer * buf,
}
/**
* 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
......@@ -370,12 +373,44 @@ void
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);
}
}
......
......@@ -205,8 +205,10 @@ struct _GstAudioRingBuffer {
gint may_start;
gboolean active;
GDestroyNotify cb_data_notify;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
gpointer _gst_reserved[GST_PADDING - 1];
};
/**
......@@ -260,9 +262,13 @@ struct _GstAudioRingBufferClass {
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);
......
......@@ -197,6 +197,7 @@ EXPORTS
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment