audiosink: Keep baseclass extensible

Add a structure for future extension.

Fixes: https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/716
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/547>
This commit is contained in:
Seungha Yang 2020-01-22 00:14:14 +09:00 committed by Seungha Yang
parent e945b3706c
commit 4a774e878f
2 changed files with 24 additions and 9 deletions

View file

@ -623,9 +623,9 @@ gst_audio_sink_ring_buffer_clear_all (GstAudioRingBuffer * buf)
sink = GST_AUDIO_SINK (GST_OBJECT_PARENT (buf));
csink = GST_AUDIO_SINK_GET_CLASS (sink);
if (csink->clear_all) {
if (csink->extension->clear_all) {
GST_DEBUG_OBJECT (sink, "clear all");
csink->clear_all (sink);
csink->extension->clear_all (sink);
}
/* chain up to the parent implementation */
@ -645,7 +645,9 @@ enum
};
#define _do_init \
GST_DEBUG_CATEGORY_INIT (gst_audio_sink_debug, "audiosink", 0, "audiosink element");
GST_DEBUG_CATEGORY_INIT (gst_audio_sink_debug, "audiosink", 0, "audiosink element"); \
g_type_add_class_private (g_define_type_id, \
sizeof (GstAudioSinkClassExtension));
#define gst_audio_sink_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstAudioSink, gst_audio_sink,
GST_TYPE_AUDIO_BASE_SINK, _do_init);
@ -664,6 +666,9 @@ gst_audio_sink_class_init (GstAudioSinkClass * klass)
GST_DEBUG_FUNCPTR (gst_audio_sink_create_ringbuffer);
g_type_class_ref (GST_TYPE_AUDIO_SINK_RING_BUFFER);
klass->extension = G_TYPE_CLASS_GET_PRIVATE (klass,
GST_TYPE_AUDIO_SINK, GstAudioSinkClassExtension);
}
static void

View file

@ -41,6 +41,7 @@ G_BEGIN_DECLS
typedef struct _GstAudioSink GstAudioSink;
typedef struct _GstAudioSinkClass GstAudioSinkClass;
typedef struct _GstAudioSinkClassExtension GstAudioSinkClassExtension;
/**
* GstAudioSink:
@ -76,13 +77,13 @@ struct _GstAudioSink {
* This vmethod is deprecated. Please provide pause and stop instead.
* @pause: Pause the device and unblock write as fast as possible.
* For retro compatibility, the audio sink will fallback
* to calling reset if this vmethod is not provided.
* @resume: Resume the device.
* to calling reset if this vmethod is not provided. Since: 1.18
* @resume: Resume the device. Since: 1.18
* @stop: Stop the device and unblock write as fast as possible.
* Pending samples are flushed from the device.
* For retro compatibility, the audio sink will fallback
* to calling reset if this vmethod is not provided.
* @clear-all: Clear the device.
* to calling reset if this vmethod is not provided. Since: 1.18
* @extension: class extension structure. Since: 1.18
*/
struct _GstAudioSinkClass {
GstAudioBaseSinkClass parent_class;
@ -109,11 +110,20 @@ struct _GstAudioSinkClass {
void (*resume) (GstAudioSink *sink);
/* stop the audio device, unblock from a write */
void (*stop) (GstAudioSink *sink);
GstAudioSinkClassExtension *extension;
};
/**
* GstAudioSinkClassExtension:
* @clear-all: Clear the device. Since: 1.18
*/
struct _GstAudioSinkClassExtension
{
/* clear the audio device */
void (*clear_all) (GstAudioSink *sink);
/*< private >*/
gpointer _gst_reserved[GST_PADDING - 4];
/* no padding needed */
};
GST_AUDIO_API