mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
audioringbuffer: add set_callback_full() for g-i
https://bugzilla.gnome.org/show_bug.cgi?id=678301
This commit is contained in:
parent
07646dd11b
commit
98064ed9bf
4 changed files with 49 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue