summaryrefslogtreecommitdiff
path: root/sys/opensles
diff options
context:
space:
mode:
Diffstat (limited to 'sys/opensles')
-rw-r--r--sys/opensles/Makefile.am5
-rw-r--r--sys/opensles/opensles.c2
-rw-r--r--sys/opensles/openslesringbuffer.c127
-rw-r--r--sys/opensles/openslesringbuffer.h16
-rw-r--r--sys/opensles/openslessink.c72
-rw-r--r--sys/opensles/openslessink.h6
-rw-r--r--sys/opensles/openslessrc.c63
-rw-r--r--sys/opensles/openslessrc.h6
8 files changed, 130 insertions, 167 deletions
diff --git a/sys/opensles/Makefile.am b/sys/opensles/Makefile.am
index dda503277..c0ef4ec98 100644
--- a/sys/opensles/Makefile.am
+++ b/sys/opensles/Makefile.am
@@ -9,13 +9,12 @@ libgstopensles_la_SOURCES = openslesringbuffer.c \
libgstopensles_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \
-Wno-deprecated-declarations
libgstopensles_la_LIBADD = \
- -lgstinterfaces-@GST_MAJORMINOR@ \
- -lgstaudio-@GST_MAJORMINOR@ \
+ -lgstaudio-@GST_API_VERSION@ \
$(GST_PLUGINS_BASE_LIBS) \
$(GST_BASE_LIBS) \
$(GST_LIBS)
libgstopensles_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -lOpenSLES
-libgstopensles_la_LIBTOOLFLAGS = --tag=disable-static --tag=CC
+libgstopensles_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)
noinst_HEADERS = openslesringbuffer.h \
openslessink.h \
diff --git a/sys/opensles/opensles.c b/sys/opensles/opensles.c
index 03af1d3a4..5f331be31 100644
--- a/sys/opensles/opensles.c
+++ b/sys/opensles/opensles.c
@@ -39,7 +39,7 @@ plugin_init (GstPlugin * plugin)
return TRUE;
}
-GST_PLUGIN_DEFINE2 (GST_VERSION_MAJOR,
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
opensles,
"OpenSL ES support for GStreamer",
diff --git a/sys/opensles/openslesringbuffer.c b/sys/opensles/openslesringbuffer.c
index 8038821a0..9db86c6e2 100644
--- a/sys/opensles/openslesringbuffer.c
+++ b/sys/opensles/openslesringbuffer.c
@@ -26,17 +26,13 @@
GST_DEBUG_CATEGORY_STATIC (opensles_ringbuffer_debug);
#define GST_CAT_DEFAULT opensles_ringbuffer_debug
-static GstRingBufferClass *ring_parent_class = NULL;
-
-static void
-_do_init (GType type)
-{
- GST_DEBUG_CATEGORY_INIT (opensles_ringbuffer_debug,
+#define _do_init \
+ GST_DEBUG_CATEGORY_INIT (opensles_ringbuffer_debug, \
"opensles_ringbuffer", 0, "OpenSL ES ringbuffer");
-}
-GST_BOILERPLATE_FULL (GstOpenSLESRingBuffer, gst_opensles_ringbuffer,
- GstRingBuffer, GST_TYPE_RING_BUFFER, _do_init);
+#define parent_class gst_opensles_ringbuffer_parent_class
+G_DEFINE_TYPE_WITH_CODE (GstOpenSLESRingBuffer, gst_opensles_ringbuffer,
+ GST_TYPE_AUDIO_RING_BUFFER, _do_init);
/*
* Some generic helper functions
@@ -78,9 +74,9 @@ _opensles_sample_rate (guint rate)
}
static inline SLuint32
-_opensles_channel_mask (GstRingBufferSpec * spec)
+_opensles_channel_mask (GstAudioRingBufferSpec * spec)
{
- switch (spec->channels) {
+ switch (spec->info.channels) {
case 1:
return (SL_SPEAKER_FRONT_CENTER);
case 2:
@@ -91,16 +87,17 @@ _opensles_channel_mask (GstRingBufferSpec * spec)
}
static inline void
-_opensles_format (GstRingBufferSpec * spec, SLDataFormat_PCM * format)
+_opensles_format (GstAudioRingBufferSpec * spec, SLDataFormat_PCM * format)
{
format->formatType = SL_DATAFORMAT_PCM;
- format->numChannels = spec->channels;
- format->samplesPerSec = _opensles_sample_rate (spec->rate);
- format->bitsPerSample = spec->depth;
- format->containerSize = spec->width;
+ format->numChannels = spec->info.channels;
+ format->samplesPerSec = _opensles_sample_rate (spec->info.rate);
+ format->bitsPerSample = spec->info.finfo->depth;
+ format->containerSize = spec->info.finfo->width;
format->channelMask = _opensles_channel_mask (spec);
format->endianness =
- (spec->bigend ? SL_BYTEORDER_BIGENDIAN : SL_BYTEORDER_LITTLEENDIAN);
+ ((spec->info.finfo->endianness ==
+ G_BIG_ENDIAN) ? SL_BYTEORDER_BIGENDIAN : SL_BYTEORDER_LITTLEENDIAN);
}
/*
@@ -108,7 +105,8 @@ _opensles_format (GstRingBufferSpec * spec, SLDataFormat_PCM * format)
*/
static gboolean
-_opensles_recorder_acquire (GstRingBuffer * rb, GstRingBufferSpec * spec)
+_opensles_recorder_acquire (GstAudioRingBuffer * rb,
+ GstAudioRingBufferSpec * spec)
{
GstOpenSLESRingBuffer *thiz = GST_OPENSLES_RING_BUFFER_CAST (rb);
SLresult result;
@@ -185,7 +183,7 @@ failed:
static void
_opensles_recorder_cb (SLAndroidSimpleBufferQueueItf bufferQueue, void *context)
{
- GstRingBuffer *rb = GST_RING_BUFFER_CAST (context);
+ GstAudioRingBuffer *rb = GST_AUDIO_RING_BUFFER_CAST (context);
GstOpenSLESRingBuffer *thiz = GST_OPENSLES_RING_BUFFER_CAST (rb);
SLresult result;
guint8 *ptr;
@@ -194,11 +192,11 @@ _opensles_recorder_cb (SLAndroidSimpleBufferQueueItf bufferQueue, void *context)
/* Advance only when we are called by the callback function */
if (bufferQueue) {
- gst_ring_buffer_advance (rb, 1);
+ gst_audio_ring_buffer_advance (rb, 1);
}
/* Get a segment form the GStreamer ringbuffer to write in */
- if (!gst_ring_buffer_prepare_read (rb, &seg, &ptr, &len)) {
+ if (!gst_audio_ring_buffer_prepare_read (rb, &seg, &ptr, &len)) {
GST_WARNING_OBJECT (rb, "No segment available");
return;
}
@@ -215,7 +213,7 @@ _opensles_recorder_cb (SLAndroidSimpleBufferQueueItf bufferQueue, void *context)
}
static gboolean
-_opensles_recorder_start (GstRingBuffer * rb)
+_opensles_recorder_start (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz = GST_OPENSLES_RING_BUFFER_CAST (rb);
SLresult result;
@@ -249,7 +247,7 @@ _opensles_recorder_start (GstRingBuffer * rb)
}
static gboolean
-_opensles_recorder_stop (GstRingBuffer * rb)
+_opensles_recorder_stop (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz = GST_OPENSLES_RING_BUFFER_CAST (rb);
SLresult result;
@@ -290,7 +288,7 @@ _opensles_recorder_stop (GstRingBuffer * rb)
*/
static gboolean
-_opensles_player_change_volume (GstRingBuffer * rb)
+_opensles_player_change_volume (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz;
SLresult result;
@@ -313,7 +311,7 @@ _opensles_player_change_volume (GstRingBuffer * rb)
}
static gboolean
-_opensles_player_change_mute (GstRingBuffer * rb)
+_opensles_player_change_mute (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz;
SLresult result;
@@ -351,7 +349,8 @@ _opensles_player_event_cb (SLPlayItf caller, void *context, SLuint32 event)
}
static gboolean
-_opensles_player_acquire (GstRingBuffer * rb, GstRingBufferSpec * spec)
+_opensles_player_acquire (GstAudioRingBuffer * rb,
+ GstAudioRingBufferSpec * spec)
{
GstOpenSLESRingBuffer *thiz = GST_OPENSLES_RING_BUFFER_CAST (rb);
SLresult result;
@@ -478,7 +477,7 @@ failed:
static void
_opensles_player_cb (SLAndroidSimpleBufferQueueItf bufferQueue, void *context)
{
- GstRingBuffer *rb = GST_RING_BUFFER_CAST (context);
+ GstAudioRingBuffer *rb = GST_AUDIO_RING_BUFFER_CAST (context);
GstOpenSLESRingBuffer *thiz = GST_OPENSLES_RING_BUFFER_CAST (rb);
SLresult result;
guint8 *ptr, *cur;
@@ -486,7 +485,7 @@ _opensles_player_cb (SLAndroidSimpleBufferQueueItf bufferQueue, void *context)
gint len;
/* Get a segment form the GStreamer ringbuffer to read some samples */
- if (!gst_ring_buffer_prepare_read (rb, &seg, &ptr, &len)) {
+ if (!gst_audio_ring_buffer_prepare_read (rb, &seg, &ptr, &len)) {
GST_WARNING_OBJECT (rb, "No segment available");
return;
}
@@ -510,13 +509,13 @@ _opensles_player_cb (SLAndroidSimpleBufferQueueItf bufferQueue, void *context)
}
/* Fill with silence samples the segment of the GStreamer ringbuffer */
- gst_ring_buffer_clear (rb, seg);
+ gst_audio_ring_buffer_clear (rb, seg);
/* Make the segment reusable */
- gst_ring_buffer_advance (rb, 1);
+ gst_audio_ring_buffer_advance (rb, 1);
}
static gboolean
-_opensles_player_start (GstRingBuffer * rb)
+_opensles_player_start (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz = GST_OPENSLES_RING_BUFFER_CAST (rb);
SLresult result;
@@ -556,7 +555,7 @@ _opensles_player_start (GstRingBuffer * rb)
}
static gboolean
-_opensles_player_pause (GstRingBuffer * rb)
+_opensles_player_pause (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz = GST_OPENSLES_RING_BUFFER_CAST (rb);
SLresult result;
@@ -573,7 +572,7 @@ _opensles_player_pause (GstRingBuffer * rb)
}
static gboolean
-_opensles_player_stop (GstRingBuffer * rb)
+_opensles_player_stop (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz = GST_OPENSLES_RING_BUFFER_CAST (rb);
SLresult result;
@@ -617,7 +616,7 @@ _opensles_player_stop (GstRingBuffer * rb)
* OpenSL ES ringbuffer wrapper
*/
-GstRingBuffer *
+GstAudioRingBuffer *
gst_opensles_ringbuffer_new (RingBufferMode mode)
{
GstOpenSLESRingBuffer *thiz;
@@ -645,11 +644,11 @@ gst_opensles_ringbuffer_new (RingBufferMode mode)
GST_DEBUG_OBJECT (thiz, "ringbuffer created");
- return GST_RING_BUFFER (thiz);
+ return GST_AUDIO_RING_BUFFER (thiz);
}
void
-gst_opensles_ringbuffer_set_volume (GstRingBuffer * rb, gfloat volume)
+gst_opensles_ringbuffer_set_volume (GstAudioRingBuffer * rb, gfloat volume)
{
GstOpenSLESRingBuffer *thiz;
@@ -663,7 +662,7 @@ gst_opensles_ringbuffer_set_volume (GstRingBuffer * rb, gfloat volume)
}
void
-gst_opensles_ringbuffer_set_mute (GstRingBuffer * rb, gboolean mute)
+gst_opensles_ringbuffer_set_mute (GstAudioRingBuffer * rb, gboolean mute)
{
GstOpenSLESRingBuffer *thiz;
@@ -677,7 +676,7 @@ gst_opensles_ringbuffer_set_mute (GstRingBuffer * rb, gboolean mute)
}
static gboolean
-gst_opensles_ringbuffer_open_device (GstRingBuffer * rb)
+gst_opensles_ringbuffer_open_device (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz;
SLresult result;
@@ -758,7 +757,7 @@ failed:
}
static gboolean
-gst_opensles_ringbuffer_close_device (GstRingBuffer * rb)
+gst_opensles_ringbuffer_close_device (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz;
@@ -784,7 +783,8 @@ gst_opensles_ringbuffer_close_device (GstRingBuffer * rb)
}
static gboolean
-gst_opensles_ringbuffer_acquire (GstRingBuffer * rb, GstRingBufferSpec * spec)
+gst_opensles_ringbuffer_acquire (GstAudioRingBuffer * rb,
+ GstAudioRingBufferSpec * spec)
{
GstOpenSLESRingBuffer *thiz;
@@ -796,15 +796,15 @@ gst_opensles_ringbuffer_acquire (GstRingBuffer * rb, GstRingBufferSpec * spec)
}
/* Initialize our ringbuffer memory region */
- rb->data = gst_buffer_new_and_alloc (spec->segtotal * spec->segsize);
- memset (GST_BUFFER_DATA (rb->data), 0, GST_BUFFER_SIZE (rb->data));
+ rb->size = spec->segtotal * spec->segsize;
+ rb->memory = g_malloc0 (rb->size);
GST_DEBUG_OBJECT (thiz, "ringbuffer acquired");
return TRUE;
}
static gboolean
-gst_opensles_ringbuffer_release (GstRingBuffer * rb)
+gst_opensles_ringbuffer_release (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz;
@@ -830,9 +830,10 @@ gst_opensles_ringbuffer_release (GstRingBuffer * rb)
thiz->data = NULL;
}
- if (rb->data) {
- gst_buffer_unref (rb->data);
- rb->data = NULL;
+ if (rb->memory) {
+ g_free (rb->memory);
+ rb->memory = NULL;
+ rb->size = 0;
}
GST_DEBUG_OBJECT (thiz, "ringbuffer released");
@@ -840,7 +841,7 @@ gst_opensles_ringbuffer_release (GstRingBuffer * rb)
}
static gboolean
-gst_opensles_ringbuffer_start (GstRingBuffer * rb)
+gst_opensles_ringbuffer_start (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz;
gboolean res;
@@ -853,7 +854,7 @@ gst_opensles_ringbuffer_start (GstRingBuffer * rb)
}
static gboolean
-gst_opensles_ringbuffer_pause (GstRingBuffer * rb)
+gst_opensles_ringbuffer_pause (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz;
gboolean res;
@@ -866,7 +867,7 @@ gst_opensles_ringbuffer_pause (GstRingBuffer * rb)
}
static gboolean
-gst_opensles_ringbuffer_stop (GstRingBuffer * rb)
+gst_opensles_ringbuffer_stop (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz;
gboolean res;
@@ -879,7 +880,7 @@ gst_opensles_ringbuffer_stop (GstRingBuffer * rb)
}
static guint
-gst_opensles_ringbuffer_delay (GstRingBuffer * rb)
+gst_opensles_ringbuffer_delay (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz;
guint res = 0;
@@ -893,7 +894,8 @@ gst_opensles_ringbuffer_delay (GstRingBuffer * rb)
(*thiz->playerPlay)->GetPlayState (thiz->playerPlay, &state);
if (state == SL_PLAYSTATE_PLAYING) {
(*thiz->playerPlay)->GetPosition (thiz->playerPlay, &position);
- playedpos = gst_util_uint64_scale_round (position, rb->spec.rate, 1000);
+ playedpos =
+ gst_util_uint64_scale_round (position, rb->spec.info.rate, 1000);
queuedpos = g_atomic_int_get (&thiz->segqueued) * rb->samples_per_seg;
res = queuedpos - playedpos;
}
@@ -907,7 +909,7 @@ gst_opensles_ringbuffer_delay (GstRingBuffer * rb)
}
static void
-gst_opensles_ringbuffer_clear_all (GstRingBuffer * rb)
+gst_opensles_ringbuffer_clear_all (GstAudioRingBuffer * rb)
{
GstOpenSLESRingBuffer *thiz;
@@ -928,37 +930,29 @@ gst_opensles_ringbuffer_clear_all (GstRingBuffer * rb)
g_atomic_int_set (&thiz->is_prerolled, 0);
}
- GST_CALL_PARENT (GST_RING_BUFFER_CLASS, clear_all, (rb));
+ GST_CALL_PARENT (GST_AUDIO_RING_BUFFER_CLASS, clear_all, (rb));
}
static void
gst_opensles_ringbuffer_dispose (GObject * object)
{
- G_OBJECT_CLASS (ring_parent_class)->dispose (object);
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gst_opensles_ringbuffer_finalize (GObject * object)
{
- G_OBJECT_CLASS (ring_parent_class)->finalize (object);
-}
-
-static void
-gst_opensles_ringbuffer_base_init (gpointer g_class)
-{
- /* Nothing to do right now */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gst_opensles_ringbuffer_class_init (GstOpenSLESRingBufferClass * klass)
{
GObjectClass *gobject_class;
- GstRingBufferClass *gstringbuffer_class;
+ GstAudioRingBufferClass *gstringbuffer_class;
gobject_class = (GObjectClass *) klass;
- gstringbuffer_class = (GstRingBufferClass *) klass;
-
- ring_parent_class = g_type_class_peek_parent (klass);
+ gstringbuffer_class = (GstAudioRingBufferClass *) klass;
gobject_class->dispose = gst_opensles_ringbuffer_dispose;
gobject_class->finalize = gst_opensles_ringbuffer_finalize;
@@ -985,8 +979,7 @@ gst_opensles_ringbuffer_class_init (GstOpenSLESRingBufferClass * klass)
}
static void
-gst_opensles_ringbuffer_init (GstOpenSLESRingBuffer * thiz,
- GstOpenSLESRingBufferClass * g_class)
+gst_opensles_ringbuffer_init (GstOpenSLESRingBuffer * thiz)
{
thiz->mode = RB_MODE_NONE;
thiz->engineObject = NULL;
diff --git a/sys/opensles/openslesringbuffer.h b/sys/opensles/openslesringbuffer.h
index 7da6563d8..6343bd792 100644
--- a/sys/opensles/openslesringbuffer.h
+++ b/sys/opensles/openslesringbuffer.h
@@ -21,7 +21,7 @@
#define __OPENSLESRINGBUFFER_H__
#include <gst/gst.h>
-#include <gst/audio/gstringbuffer.h>
+#include <gst/audio/gstaudioringbuffer.h>
#include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h>
@@ -54,15 +54,15 @@ typedef enum
RB_MODE_LAST
} RingBufferMode;
-typedef gboolean (*AcquireFunc) (GstRingBuffer * rb, GstRingBufferSpec * spec);
-typedef gboolean (*StateFunc) (GstRingBuffer * rb);
+typedef gboolean (*AcquireFunc) (GstAudioRingBuffer * rb, GstAudioRingBufferSpec * spec);
+typedef gboolean (*StateFunc) (GstAudioRingBuffer * rb);
typedef struct _GstOpenSLESRingBuffer GstOpenSLESRingBuffer;
typedef struct _GstOpenSLESRingBufferClass GstOpenSLESRingBufferClass;
struct _GstOpenSLESRingBuffer
{
- GstRingBuffer object;
+ GstAudioRingBuffer object;
RingBufferMode mode;
@@ -105,13 +105,13 @@ struct _GstOpenSLESRingBuffer
struct _GstOpenSLESRingBufferClass
{
- GstRingBufferClass parent_class;
+ GstAudioRingBufferClass parent_class;
};
GType gst_opensles_ringbuffer_get_type (void);
-GstRingBuffer *gst_opensles_ringbuffer_new (RingBufferMode mode);
-void gst_opensles_ringbuffer_set_volume (GstRingBuffer * rb, gfloat volume);
-void gst_opensles_ringbuffer_set_mute (GstRingBuffer * rb, gboolean mute);
+GstAudioRingBuffer *gst_opensles_ringbuffer_new (RingBufferMode mode);
+void gst_opensles_ringbuffer_set_volume (GstAudioRingBuffer * rb, gfloat volume);
+void gst_opensles_ringbuffer_set_mute (GstAudioRingBuffer * rb, gboolean mute);
G_END_DECLS
#endif /* __OPENSLESRINGBUFFER_H__ */
diff --git a/sys/opensles/openslessink.c b/sys/opensles/openslessink.c
index 625fc0911..60deb1815 100644
--- a/sys/opensles/openslessink.c
+++ b/sys/opensles/openslessink.c
@@ -62,49 +62,23 @@ enum
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, "
- "signed = (boolean) { TRUE }, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) { " RATES "}, "
- "channels = (int) [1, 2];"
- "audio/x-raw-int, "
- "endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, "
- "signed = (boolean) { FALSE }, "
- "width = (int) 8, "
- "depth = (int) 8, "
+ GST_STATIC_CAPS ("audio/x-raw, "
+ "format = (string) { " GST_AUDIO_NE (S16) ", " GST_AUDIO_NE (U8) "}, "
"rate = (int) { " RATES "}, " "channels = (int) [1, 2]")
);
-static void
-_do_init (GType type)
-{
- GST_DEBUG_CATEGORY_INIT (opensles_sink_debug, "opensles_sink", 0,
+#define _do_init \
+ GST_DEBUG_CATEGORY_INIT (opensles_sink_debug, "opensles_sink", 0, \
"OpenSL ES Sink");
-}
+#define parent_class gst_opensles_sink_parent_class
+G_DEFINE_TYPE_WITH_CODE (GstOpenSLESSink, gst_opensles_sink,
+ GST_TYPE_AUDIO_BASE_SINK, _do_init);
-GST_BOILERPLATE_FULL (GstOpenSLESSink, gst_opensles_sink, GstBaseAudioSink,
- GST_TYPE_BASE_AUDIO_SINK, _do_init);
-
-static void
-gst_opensles_sink_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_static_pad_template (element_class, &sink_factory);
-
- gst_element_class_set_details_simple (element_class, "OpenSL ES Sink",
- "Sink/Audio",
- "Output sound using the OpenSL ES APIs",
- "Josep Torra <support@fluendo.com>");
-}
-
-static GstRingBuffer *
-gst_opensles_sink_create_ringbuffer (GstBaseAudioSink * base)
+static GstAudioRingBuffer *
+gst_opensles_sink_create_ringbuffer (GstAudioBaseSink * base)
{
GstOpenSLESSink *sink = GST_OPENSLES_SINK (base);
- GstRingBuffer *rb;
+ GstAudioRingBuffer *rb;
rb = gst_opensles_ringbuffer_new (RB_MODE_SINK_PCM);
gst_opensles_ringbuffer_set_volume (rb, sink->volume);
@@ -208,7 +182,7 @@ gst_opensles_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstOpenSLESSink *sink = GST_OPENSLES_SINK (object);
- GstRingBuffer *rb = GST_BASE_AUDIO_SINK (sink)->ringbuffer;
+ GstAudioRingBuffer *rb = GST_AUDIO_BASE_SINK (sink)->ringbuffer;
switch (prop_id) {
case PROP_VOLUME:
@@ -251,12 +225,12 @@ static void
gst_opensles_sink_class_init (GstOpenSLESSinkClass * klass)
{
GObjectClass *gobject_class;
- GstBaseAudioSinkClass *gstbaseaudiosink_class;
+ GstElementClass *gstelement_class;
+ GstAudioBaseSinkClass *gstbaseaudiosink_class;
gobject_class = (GObjectClass *) klass;
- gstbaseaudiosink_class = (GstBaseAudioSinkClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
+ gstelement_class = (GstElementClass *) klass;
+ gstbaseaudiosink_class = (GstAudioBaseSinkClass *) klass;
gobject_class->set_property = gst_opensles_sink_set_property;
gobject_class->get_property = gst_opensles_sink_get_property;
@@ -269,21 +243,29 @@ gst_opensles_sink_class_init (GstOpenSLESSinkClass * klass)
g_param_spec_boolean ("mute", "Mute", "Mute state of this stream",
DEFAULT_MUTE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&sink_factory));
+
+ gst_element_class_set_static_metadata (gstelement_class, "OpenSL ES Sink",
+ "Sink/Audio",
+ "Output sound using the OpenSL ES APIs",
+ "Josep Torra <support@fluendo.com>");
+
gstbaseaudiosink_class->create_ringbuffer =
GST_DEBUG_FUNCPTR (gst_opensles_sink_create_ringbuffer);
}
static void
-gst_opensles_sink_init (GstOpenSLESSink * sink, GstOpenSLESSinkClass * gclass)
+gst_opensles_sink_init (GstOpenSLESSink * sink)
{
sink->volume = DEFAULT_VOLUME;
sink->mute = DEFAULT_MUTE;
_opensles_query_capabilities (sink);
- gst_base_audio_sink_set_provide_clock (GST_BASE_AUDIO_SINK (sink), TRUE);
+ gst_audio_base_sink_set_provide_clock (GST_AUDIO_BASE_SINK (sink), TRUE);
/* Override some default values to fit on the AudioFlinger behaviour of
* processing 20ms buffers as minimum buffer size. */
- GST_BASE_AUDIO_SINK (sink)->buffer_time = 400000;
- GST_BASE_AUDIO_SINK (sink)->latency_time = 20000;
+ GST_AUDIO_BASE_SINK (sink)->buffer_time = 400000;
+ GST_AUDIO_BASE_SINK (sink)->latency_time = 20000;
}
diff --git a/sys/opensles/openslessink.h b/sys/opensles/openslessink.h
index da9e6064b..0a1760249 100644
--- a/sys/opensles/openslessink.h
+++ b/sys/opensles/openslessink.h
@@ -21,7 +21,7 @@
#define __OPENSLESSINK_H__
#include <gst/gst.h>
-#include <gst/audio/gstbaseaudiosink.h>
+#include <gst/audio/gstaudiobasesink.h>
#include "openslesringbuffer.h"
G_BEGIN_DECLS
@@ -38,7 +38,7 @@ typedef struct _GstOpenSLESSinkClass GstOpenSLESSinkClass;
struct _GstOpenSLESSink
{
- GstBaseAudioSink sink;
+ GstAudioBaseSink sink;
gfloat volume;
gboolean mute;
@@ -46,7 +46,7 @@ struct _GstOpenSLESSink
struct _GstOpenSLESSinkClass
{
- GstBaseAudioSinkClass parent_class;
+ GstAudioBaseSinkClass parent_class;
};
GType gst_opensles_sink_get_type (void);
diff --git a/sys/opensles/openslessrc.c b/sys/opensles/openslessrc.c
index df697aba1..748e4f0a6 100644
--- a/sys/opensles/openslessrc.c
+++ b/sys/opensles/openslessrc.c
@@ -45,43 +45,24 @@ GST_DEBUG_CATEGORY_STATIC (opensles_src_debug);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, "
- "signed = (boolean) { TRUE }, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) 16000, "
+ GST_STATIC_CAPS ("audio/x-raw, "
+ "format = (string) " GST_AUDIO_NE (S16) ", "
+ "rate = (int) { 16000 }, "
"channels = (int) 1")
);
/* *INDENT-ON* */
-static void
-_do_init (GType type)
-{
- GST_DEBUG_CATEGORY_INIT (opensles_src_debug, "opensles_src", 0,
+#define _do_init \
+ GST_DEBUG_CATEGORY_INIT (opensles_src_debug, "opensles_src", 0, \
"OpenSL ES Src");
-}
+#define parent_class gst_opensles_src_parent_class
+G_DEFINE_TYPE_WITH_CODE (GstOpenSLESSrc, gst_opensles_src,
+ GST_TYPE_AUDIO_BASE_SRC, _do_init);
-GST_BOILERPLATE_FULL (GstOpenSLESSrc, gst_opensles_src, GstBaseAudioSrc,
- GST_TYPE_BASE_AUDIO_SRC, _do_init);
-
-static void
-gst_opensles_src_base_init (gpointer g_class)
+static GstAudioRingBuffer *
+gst_opensles_src_create_ringbuffer (GstAudioBaseSrc * base)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_static_pad_template (element_class, &src_factory);
-
- gst_element_class_set_details_simple (element_class, "OpenSL ES Src",
- "Src/Audio",
- "Input sound using the OpenSL ES APIs",
- "Josep Torra <support@fluendo.com>");
-}
-
-static GstRingBuffer *
-gst_opensles_src_create_ringbuffer (GstBaseAudioSrc * base)
-{
- GstRingBuffer *rb;
+ GstAudioRingBuffer *rb;
rb = gst_opensles_ringbuffer_new (RB_MODE_SRC);
@@ -91,21 +72,29 @@ gst_opensles_src_create_ringbuffer (GstBaseAudioSrc * base)
static void
gst_opensles_src_class_init (GstOpenSLESSrcClass * klass)
{
- GstBaseAudioSrcClass *gstbaseaudiosrc_class;
+ GstElementClass *gstelement_class;
+ GstAudioBaseSrcClass *gstaudiobasesrc_class;
- gstbaseaudiosrc_class = (GstBaseAudioSrcClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstaudiobasesrc_class = (GstAudioBaseSrcClass *) klass;
- parent_class = g_type_class_peek_parent (klass);
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&src_factory));
+
+ gst_element_class_set_static_metadata (gstelement_class, "OpenSL ES Src",
+ "Src/Audio",
+ "Input sound using the OpenSL ES APIs",
+ "Josep Torra <support@fluendo.com>");
- gstbaseaudiosrc_class->create_ringbuffer =
+ gstaudiobasesrc_class->create_ringbuffer =
GST_DEBUG_FUNCPTR (gst_opensles_src_create_ringbuffer);
}
static void
-gst_opensles_src_init (GstOpenSLESSrc * src, GstOpenSLESSrcClass * gclass)
+gst_opensles_src_init (GstOpenSLESSrc * src)
{
/* Override some default values to fit on the AudioFlinger behaviour of
* processing 20ms buffers as minimum buffer size. */
- GST_BASE_AUDIO_SRC (src)->buffer_time = 400000;
- GST_BASE_AUDIO_SRC (src)->latency_time = 20000;
+ GST_AUDIO_BASE_SRC (src)->buffer_time = 400000;
+ GST_AUDIO_BASE_SRC (src)->latency_time = 20000;
}
diff --git a/sys/opensles/openslessrc.h b/sys/opensles/openslessrc.h
index 9f57c9338..ed75a3ed9 100644
--- a/sys/opensles/openslessrc.h
+++ b/sys/opensles/openslessrc.h
@@ -21,7 +21,7 @@
#define __OPENSLESSRC_H__
#include <gst/gst.h>
-#include <gst/audio/gstbaseaudiosrc.h>
+#include <gst/audio/gstaudiobasesrc.h>
#include "openslesringbuffer.h"
G_BEGIN_DECLS
@@ -38,12 +38,12 @@ typedef struct _GstOpenSLESSrcClass GstOpenSLESSrcClass;
struct _GstOpenSLESSrc
{
- GstBaseAudioSrc src;
+ GstAudioBaseSrc src;
};
struct _GstOpenSLESSrcClass
{
- GstBaseAudioSrcClass parent_class;
+ GstAudioBaseSrcClass parent_class;
};
GType gst_opensles_src_get_type (void);