audioringbuffer: add set_callback_full() for g-i
authorEvan Nemerson <evan@nemerson.com>
Fri, 27 Jun 2014 01:01:06 +0000 (18:01 -0700)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 22 Dec 2016 15:34:58 +0000 (15:34 +0000)
https://bugzilla.gnome.org/show_bug.cgi?id=678301

docs/libs/gst-plugins-base-libs-sections.txt
gst-libs/gst/audio/gstaudioringbuffer.c
gst-libs/gst/audio/gstaudioringbuffer.h
win32/common/libgstaudio.def

index 961c876821118b5511f80f65803027e6ef9fcc68..58781a0e8a7feb01e129d37e2269040b63625418 100644 (file)
@@ -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
index 1302c282c9a8c3e1ab1fc287f9375c4aaa342308..fb254e5c015401f04424aa16f28c875b43e3d849 100644 (file)
@@ -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);
+  }
 }
 
 
index b0e3e9b36d620a7830523c9353806f101e273e1f..4ddc8e16131204678977fee5abc6816575d428b9 100644 (file)
@@ -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);
index 0590d87de15f71b152197405958a39cc565b11cc..6fa0756e51ef26cb6e8d97e7440d6a5e03ee2ddb 100644 (file)
@@ -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