diff options
author | ted-n <ted.nakajima@gmail.com> | 2013-03-30 22:49:34 +0900 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2013-04-18 09:19:28 +0200 |
commit | 8321149390b2b6329bcf9f88a1d87856ffffe547 (patch) | |
tree | 56597516898c2fa9712a2be7ab6980274da6adfb | |
parent | c90e215cefb4fb2d1d3f5cccbbc3a871a0a57f99 (diff) |
osxaudio: port to v.1.0
-rw-r--r-- | sys/osxaudio/Makefile.am | 5 | ||||
-rw-r--r-- | sys/osxaudio/gstosxaudioelement.c | 1 | ||||
-rw-r--r-- | sys/osxaudio/gstosxaudioringbuffer.c (renamed from sys/osxaudio/gstosxringbuffer.c) | 184 | ||||
-rw-r--r-- | sys/osxaudio/gstosxaudioringbuffer.h (renamed from sys/osxaudio/gstosxringbuffer.h) | 50 | ||||
-rw-r--r-- | sys/osxaudio/gstosxaudiosink.c | 230 | ||||
-rw-r--r-- | sys/osxaudio/gstosxaudiosink.h | 8 | ||||
-rw-r--r-- | sys/osxaudio/gstosxaudiosrc.c | 65 | ||||
-rw-r--r-- | sys/osxaudio/gstosxaudiosrc.h | 8 | ||||
-rw-r--r-- | sys/osxaudio/gstosxcoreaudiocommon.c | 13 | ||||
-rw-r--r-- | sys/osxaudio/gstosxcoreaudiocommon.h | 4 |
10 files changed, 281 insertions, 287 deletions
diff --git a/sys/osxaudio/Makefile.am b/sys/osxaudio/Makefile.am index 3203043c7..12b7d03fd 100644 --- a/sys/osxaudio/Makefile.am +++ b/sys/osxaudio/Makefile.am @@ -1,6 +1,6 @@ plugin_LTLIBRARIES = libgstosxaudio.la -libgstosxaudio_la_SOURCES = gstosxringbuffer.c \ +libgstosxaudio_la_SOURCES = gstosxaudioringbuffer.c \ gstosxaudioelement.c \ gstosxaudiosink.c \ gstosxaudiosrc.c \ @@ -11,7 +11,6 @@ libgstosxaudio_la_SOURCES = gstosxringbuffer.c \ libgstosxaudio_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \ -Wno-deprecated-declarations libgstosxaudio_la_LIBADD = \ - -lgstinterfaces-@GST_API_VERSION@ \ -lgstaudio-@GST_API_VERSION@ \ $(GST_PLUGINS_BASE_LIBS) \ $(GST_BASE_LIBS) \ @@ -27,7 +26,7 @@ libgstosxaudio_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS) --tag=CC noinst_HEADERS = gstosxaudiosink.h \ gstosxaudioelement.h \ - gstosxringbuffer.h \ + gstosxaudioringbuffer.h \ gstosxaudiosrc.h \ gstosxcoreaudiocommon.h \ gstosxcoreaudio.h \ diff --git a/sys/osxaudio/gstosxaudioelement.c b/sys/osxaudio/gstosxaudioelement.c index b62550101..0442b1d3d 100644 --- a/sys/osxaudio/gstosxaudioelement.c +++ b/sys/osxaudio/gstosxaudioelement.c @@ -47,6 +47,7 @@ */ #include "gstosxaudioelement.h" +#include <gst/gst.h> static void gst_osx_audio_element_interface_init (GstOsxAudioElementInterface * iface); diff --git a/sys/osxaudio/gstosxringbuffer.c b/sys/osxaudio/gstosxaudioringbuffer.c index 82da79913..29053dda0 100644 --- a/sys/osxaudio/gstosxringbuffer.c +++ b/sys/osxaudio/gstosxaudioringbuffer.c @@ -48,8 +48,8 @@ #endif #include <gst/gst.h> -#include <gst/audio/multichannel.h> -#include "gstosxringbuffer.h" +#include <gst/audio/audio-channels.h> +#include "gstosxaudioringbuffer.h" #include "gstosxaudiosink.h" #include "gstosxaudiosrc.h" @@ -60,84 +60,79 @@ GST_DEBUG_CATEGORY_STATIC (osx_audio_debug); #include "gstosxcoreaudio.h" -static void gst_osx_ring_buffer_dispose (GObject * object); -static void gst_osx_ring_buffer_finalize (GObject * object); -static gboolean gst_osx_ring_buffer_open_device (GstRingBuffer * buf); -static gboolean gst_osx_ring_buffer_close_device (GstRingBuffer * buf); +static void gst_osx_audio_ring_buffer_dispose (GObject * object); +static void gst_osx_audio_ring_buffer_finalize (GObject * object); +static gboolean gst_osx_audio_ring_buffer_open_device (GstAudioRingBuffer * + buf); +static gboolean gst_osx_audio_ring_buffer_close_device (GstAudioRingBuffer * + buf); -static gboolean gst_osx_ring_buffer_acquire (GstRingBuffer * buf, - GstRingBufferSpec * spec); -static gboolean gst_osx_ring_buffer_release (GstRingBuffer * buf); +static gboolean gst_osx_audio_ring_buffer_acquire (GstAudioRingBuffer * buf, + GstAudioRingBufferSpec * spec); +static gboolean gst_osx_audio_ring_buffer_release (GstAudioRingBuffer * buf); -static gboolean gst_osx_ring_buffer_start (GstRingBuffer * buf); -static gboolean gst_osx_ring_buffer_pause (GstRingBuffer * buf); -static gboolean gst_osx_ring_buffer_stop (GstRingBuffer * buf); -static guint gst_osx_ring_buffer_delay (GstRingBuffer * buf); -static GstRingBufferClass *ring_parent_class = NULL; +static gboolean gst_osx_audio_ring_buffer_start (GstAudioRingBuffer * buf); +static gboolean gst_osx_audio_ring_buffer_pause (GstAudioRingBuffer * buf); +static gboolean gst_osx_audio_ring_buffer_stop (GstAudioRingBuffer * buf); +static guint gst_osx_audio_ring_buffer_delay (GstAudioRingBuffer * buf); +static GstAudioRingBufferClass *ring_parent_class = NULL; -static void -gst_osx_ring_buffer_do_init (GType type) -{ - GST_DEBUG_CATEGORY_INIT (osx_audio_debug, "osxaudio", 0, - "OSX Audio Elements"); -} +#define gst_osx_audio_ring_buffer_do_init \ + GST_DEBUG_CATEGORY_INIT (osx_audio_debug, "osxaudio", 0, "OSX Audio Elements"); -GST_BOILERPLATE_FULL (GstOsxRingBuffer, gst_osx_ring_buffer, - GstRingBuffer, GST_TYPE_RING_BUFFER, gst_osx_ring_buffer_do_init); +G_DEFINE_TYPE_WITH_CODE (GstOsxAudioRingBuffer, gst_osx_audio_ring_buffer, + GST_TYPE_AUDIO_RING_BUFFER, gst_osx_audio_ring_buffer_do_init); static void -gst_osx_ring_buffer_base_init (gpointer g_class) -{ - /* Nothing to do right now */ -} - -static void -gst_osx_ring_buffer_class_init (GstOsxRingBufferClass * klass) +gst_osx_audio_ring_buffer_class_init (GstOsxAudioRingBufferClass * klass) { GObjectClass *gobject_class; GstObjectClass *gstobject_class; - GstRingBufferClass *gstringbuffer_class; + GstAudioRingBufferClass *gstringbuffer_class; gobject_class = (GObjectClass *) klass; gstobject_class = (GstObjectClass *) klass; - gstringbuffer_class = (GstRingBufferClass *) klass; + gstringbuffer_class = (GstAudioRingBufferClass *) klass; ring_parent_class = g_type_class_peek_parent (klass); - gobject_class->dispose = gst_osx_ring_buffer_dispose; - gobject_class->finalize = gst_osx_ring_buffer_finalize; + gobject_class->dispose = gst_osx_audio_ring_buffer_dispose; + gobject_class->finalize = gst_osx_audio_ring_buffer_finalize; gstringbuffer_class->open_device = - GST_DEBUG_FUNCPTR (gst_osx_ring_buffer_open_device); + GST_DEBUG_FUNCPTR (gst_osx_audio_ring_buffer_open_device); gstringbuffer_class->close_device = - GST_DEBUG_FUNCPTR (gst_osx_ring_buffer_close_device); + GST_DEBUG_FUNCPTR (gst_osx_audio_ring_buffer_close_device); gstringbuffer_class->acquire = - GST_DEBUG_FUNCPTR (gst_osx_ring_buffer_acquire); + GST_DEBUG_FUNCPTR (gst_osx_audio_ring_buffer_acquire); gstringbuffer_class->release = - GST_DEBUG_FUNCPTR (gst_osx_ring_buffer_release); - gstringbuffer_class->start = GST_DEBUG_FUNCPTR (gst_osx_ring_buffer_start); - gstringbuffer_class->pause = GST_DEBUG_FUNCPTR (gst_osx_ring_buffer_pause); - gstringbuffer_class->resume = GST_DEBUG_FUNCPTR (gst_osx_ring_buffer_start); - gstringbuffer_class->stop = GST_DEBUG_FUNCPTR (gst_osx_ring_buffer_stop); - - gstringbuffer_class->delay = GST_DEBUG_FUNCPTR (gst_osx_ring_buffer_delay); - - GST_DEBUG ("osx ring buffer class init"); + GST_DEBUG_FUNCPTR (gst_osx_audio_ring_buffer_release); + gstringbuffer_class->start = + GST_DEBUG_FUNCPTR (gst_osx_audio_ring_buffer_start); + gstringbuffer_class->pause = + GST_DEBUG_FUNCPTR (gst_osx_audio_ring_buffer_pause); + gstringbuffer_class->resume = + GST_DEBUG_FUNCPTR (gst_osx_audio_ring_buffer_start); + gstringbuffer_class->stop = + GST_DEBUG_FUNCPTR (gst_osx_audio_ring_buffer_stop); + gstringbuffer_class->delay = + GST_DEBUG_FUNCPTR (gst_osx_audio_ring_buffer_delay); + + GST_DEBUG ("osx audio ring buffer class init"); } static void -gst_osx_ring_buffer_init (GstOsxRingBuffer * ringbuffer, - GstOsxRingBufferClass * g_class) +gst_osx_audio_ring_buffer_init (GstOsxAudioRingBuffer * ringbuffer) { ringbuffer->core_audio = gst_core_audio_new (GST_OBJECT (ringbuffer)); } static void -gst_osx_ring_buffer_dispose (GObject * object) +gst_osx_audio_ring_buffer_dispose (GObject * object) { - GstOsxRingBuffer *osxbuf; + GstOsxAudioRingBuffer *osxbuf; - osxbuf = GST_OSX_RING_BUFFER (object); + osxbuf = GST_OSX_AUDIO_RING_BUFFER (object); if (osxbuf->core_audio) { g_object_unref (osxbuf->core_audio); @@ -147,42 +142,43 @@ gst_osx_ring_buffer_dispose (GObject * object) } static void -gst_osx_ring_buffer_finalize (GObject * object) +gst_osx_audio_ring_buffer_finalize (GObject * object) { G_OBJECT_CLASS (ring_parent_class)->finalize (object); } static gboolean -gst_osx_ring_buffer_open_device (GstRingBuffer * buf) +gst_osx_audio_ring_buffer_open_device (GstAudioRingBuffer * buf) { - GstOsxRingBuffer *osxbuf; + GstOsxAudioRingBuffer *osxbuf; - osxbuf = GST_OSX_RING_BUFFER (buf); + osxbuf = GST_OSX_AUDIO_RING_BUFFER (buf); return gst_core_audio_open (osxbuf->core_audio); } static gboolean -gst_osx_ring_buffer_close_device (GstRingBuffer * buf) +gst_osx_audio_ring_buffer_close_device (GstAudioRingBuffer * buf) { - GstOsxRingBuffer *osxbuf; - osxbuf = GST_OSX_RING_BUFFER (buf); + GstOsxAudioRingBuffer *osxbuf; + osxbuf = GST_OSX_AUDIO_RING_BUFFER (buf); return gst_core_audio_close (osxbuf->core_audio); } static gboolean -gst_osx_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec) +gst_osx_audio_ring_buffer_acquire (GstAudioRingBuffer * buf, + GstAudioRingBufferSpec * spec) { gboolean ret = FALSE, is_passthrough = FALSE; - GstOsxRingBuffer *osxbuf; + GstOsxAudioRingBuffer *osxbuf; AudioStreamBasicDescription format; - osxbuf = GST_OSX_RING_BUFFER (buf); + osxbuf = GST_OSX_AUDIO_RING_BUFFER (buf); if (RINGBUFFER_IS_SPDIF (spec->type)) { format.mFormatID = kAudioFormat60958AC3; - format.mSampleRate = (double) spec->rate; + format.mSampleRate = (double) spec->info.rate; format.mChannelsPerFrame = 2; format.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked | kAudioFormatFlagIsNonMixable; @@ -198,32 +194,32 @@ gst_osx_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec) int width, depth; /* Fill out the audio description we're going to be using */ format.mFormatID = kAudioFormatLinearPCM; - format.mSampleRate = (double) spec->rate; - format.mChannelsPerFrame = spec->channels; - if (spec->type == GST_BUFTYPE_FLOAT) { + format.mSampleRate = (double) spec->info.rate; + format.mChannelsPerFrame = spec->info.channels; + if (spec->type == GST_AUDIO_FORMAT_F32) { format.mFormatFlags = kAudioFormatFlagsNativeFloatPacked; - width = depth = spec->width; + width = depth = spec->info.finfo->width; } else { format.mFormatFlags = kAudioFormatFlagIsSignedInteger; - width = spec->width; - depth = spec->depth; + width = spec->info.finfo->width; + depth = spec->info.finfo->depth; if (width == depth) { format.mFormatFlags |= kAudioFormatFlagIsPacked; } else { format.mFormatFlags |= kAudioFormatFlagIsAlignedHigh; } - if (spec->bigend) { + if (spec->info.finfo->endianness == G_BIG_ENDIAN) { format.mFormatFlags |= kAudioFormatFlagIsBigEndian; } } - format.mBytesPerFrame = spec->channels * (width >> 3); + format.mBytesPerFrame = spec->info.channels * (width >> 3); format.mBitsPerChannel = depth; - format.mBytesPerPacket = spec->channels * (width >> 3); + format.mBytesPerPacket = spec->info.channels * (width >> 3); format.mFramesPerPacket = 1; format.mReserved = 0; spec->segsize = - (spec->latency_time * spec->rate / G_USEC_PER_SEC) * - spec->bytes_per_sample; + (spec->latency_time * spec->info.rate / G_USEC_PER_SEC) * + spec->info.bpf; spec->segtotal = spec->buffer_time / spec->latency_time; is_passthrough = FALSE; } @@ -231,15 +227,16 @@ gst_osx_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec) GST_DEBUG_OBJECT (osxbuf, "Format: " CORE_AUDIO_FORMAT, CORE_AUDIO_FORMAT_ARGS (format)); - buf->data = gst_buffer_new_and_alloc (spec->segtotal * spec->segsize); - memset (GST_BUFFER_DATA (buf->data), 0, GST_BUFFER_SIZE (buf->data)); + buf->size = spec->segtotal * spec->segsize; + buf->memory = g_malloc0 (buf->size); ret = gst_core_audio_initialize (osxbuf->core_audio, format, spec->caps, is_passthrough); if (!ret) { - gst_buffer_unref (buf->data); - buf->data = NULL; + g_free (buf->memory); + buf->memory = NULL; + buf->size = 0; } osxbuf->segoffset = 0; @@ -248,45 +245,46 @@ gst_osx_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec) } static gboolean -gst_osx_ring_buffer_release (GstRingBuffer * buf) +gst_osx_audio_ring_buffer_release (GstAudioRingBuffer * buf) { - GstOsxRingBuffer *osxbuf; + GstOsxAudioRingBuffer *osxbuf; - osxbuf = GST_OSX_RING_BUFFER (buf); + osxbuf = GST_OSX_AUDIO_RING_BUFFER (buf); gst_core_audio_unitialize (osxbuf->core_audio); - gst_buffer_unref (buf->data); - buf->data = NULL; + g_free (buf->memory); + buf->memory = NULL; + buf->size = 0; return TRUE; } static gboolean -gst_osx_ring_buffer_start (GstRingBuffer * buf) +gst_osx_audio_ring_buffer_start (GstAudioRingBuffer * buf) { - GstOsxRingBuffer *osxbuf; + GstOsxAudioRingBuffer *osxbuf; - osxbuf = GST_OSX_RING_BUFFER (buf); + osxbuf = GST_OSX_AUDIO_RING_BUFFER (buf); return gst_core_audio_start_processing (osxbuf->core_audio); } static gboolean -gst_osx_ring_buffer_pause (GstRingBuffer * buf) +gst_osx_audio_ring_buffer_pause (GstAudioRingBuffer * buf) { - GstOsxRingBuffer *osxbuf = GST_OSX_RING_BUFFER (buf); + GstOsxAudioRingBuffer *osxbuf = GST_OSX_AUDIO_RING_BUFFER (buf); return gst_core_audio_pause_processing (osxbuf->core_audio); } static gboolean -gst_osx_ring_buffer_stop (GstRingBuffer * buf) +gst_osx_audio_ring_buffer_stop (GstAudioRingBuffer * buf) { - GstOsxRingBuffer *osxbuf; + GstOsxAudioRingBuffer *osxbuf; - osxbuf = GST_OSX_RING_BUFFER (buf); + osxbuf = GST_OSX_AUDIO_RING_BUFFER (buf); gst_core_audio_stop_processing (osxbuf->core_audio); @@ -294,16 +292,16 @@ gst_osx_ring_buffer_stop (GstRingBuffer * buf) } static guint -gst_osx_ring_buffer_delay (GstRingBuffer * buf) +gst_osx_audio_ring_buffer_delay (GstAudioRingBuffer * buf) { - GstOsxRingBuffer *osxbuf; + GstOsxAudioRingBuffer *osxbuf; double latency; guint samples; - osxbuf = GST_OSX_RING_BUFFER (buf); + osxbuf = GST_OSX_AUDIO_RING_BUFFER (buf); if (!gst_core_audio_get_samples_and_latency (osxbuf->core_audio, - GST_RING_BUFFER (buf)->spec.rate, &samples, &latency)) { + GST_AUDIO_RING_BUFFER (buf)->spec.info.rate, &samples, &latency)) { return 0; } GST_DEBUG_OBJECT (buf, "Got latency: %f seconds -> %d samples", diff --git a/sys/osxaudio/gstosxringbuffer.h b/sys/osxaudio/gstosxaudioringbuffer.h index 3f24d386b..ca0dc7bd7 100644 --- a/sys/osxaudio/gstosxringbuffer.h +++ b/sys/osxaudio/gstosxaudioringbuffer.h @@ -50,33 +50,33 @@ #endif #include <gst/gst.h> -#include <gst/audio/gstringbuffer.h> +#include <gst/audio/gstaudioringbuffer.h> #include <gstosxcoreaudio.h> G_BEGIN_DECLS -#define GST_TYPE_OSX_RING_BUFFER \ - (gst_osx_ring_buffer_get_type()) -#define GST_OSX_RING_BUFFER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OSX_RING_BUFFER,GstOsxRingBuffer)) -#define GST_OSX_RING_BUFFER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OSX_RING_BUFFER,GstOsxRingBufferClass)) -#define GST_OSX_RING_BUFFER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OSX_RING_BUFFER,GstOsxRingBufferClass)) -#define GST_IS_OSX_RING_BUFFER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OSX_RING_BUFFER)) -#define GST_IS_OSX_RING_BUFFER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OSX_RING_BUFFER)) - -#define RINGBUFFER_IS_SPDIF(t) ((t) == GST_BUFTYPE_AC3 || (t) == GST_BUFTYPE_DTS) - -typedef struct _GstOsxRingBuffer GstOsxRingBuffer; -typedef struct _GstOsxRingBufferClass GstOsxRingBufferClass; - -struct _GstOsxRingBuffer +#define GST_TYPE_OSX_AUDIO_RING_BUFFER \ + (gst_osx_audio_ring_buffer_get_type()) +#define GST_OSX_AUDIO_RING_BUFFER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OSX_AUDIO_RING_BUFFER,GstOsxAudioRingBuffer)) +#define GST_OSX_AUDIO_RING_BUFFER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OSX_AUDIO_RING_BUFFER,GstOsxAudioRingBufferClass)) +#define GST_OSX_AUDIO_RING_BUFFER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OSX_AUDIO_RING_BUFFER,GstOsxAudioRingBufferClass)) +#define GST_IS_OSX_AUDIO_RING_BUFFER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OSX_AUDIO_RING_BUFFER)) +#define GST_IS_OSX_AUDIO_RING_BUFFER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OSX_AUDIO_RING_BUFFER)) + +#define RINGBUFFER_IS_SPDIF(t) ((t) == GST_AUDIO_RING_BUFFER_FORMAT_TYPE_AC3 || (t) == GST_AUDIO_RING_BUFFER_FORMAT_TYPE_DTS) + +typedef struct _GstOsxAudioRingBuffer GstOsxAudioRingBuffer; +typedef struct _GstOsxAudioRingBufferClass GstOsxAudioRingBufferClass; + +struct _GstOsxAudioRingBuffer { - GstRingBuffer object; + GstAudioRingBuffer object; GstCoreAudio *core_audio; @@ -84,14 +84,14 @@ struct _GstOsxRingBuffer guint segoffset; }; -struct _GstOsxRingBufferClass +struct _GstOsxAudioRingBufferClass { - GstRingBufferClass parent_class; + GstAudioRingBufferClass parent_class; }; -GType gst_osx_ring_buffer_get_type (void); +GType gst_osx_audio_ring_buffer_get_type (void); G_END_DECLS -#endif /* __GST_OSX_RING_BUFFER_H__ */ +#endif /* __GST_OSX_AUDIO_RING_BUFFER_H__ */ diff --git a/sys/osxaudio/gstosxaudiosink.c b/sys/osxaudio/gstosxaudiosink.c index e1281c3a3..c7f2e4cb4 100644 --- a/sys/osxaudio/gstosxaudiosink.c +++ b/sys/osxaudio/gstosxaudiosink.c @@ -67,7 +67,7 @@ #endif #include <gst/gst.h> -#include <gst/audio/multichannel.h> +#include <gst/audio/audio-channels.h> #include <gst/audio/gstaudioiec61937.h> #include "gstosxaudiosink.h" @@ -94,43 +94,20 @@ enum #define DEFAULT_VOLUME 1.0 +#if (G_BYTE_ORDER == G_LITTLE_ENDIAN) +# define FORMATS "{ S32LE, S24LE, S16LE, U8 }" +#else +# define FORMATS "{ S32BE, S24BE, S16BE, U8 }" +#endif + static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-float, " - "endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, " - "signed = (boolean) { TRUE }, " - "width = (int) 32, " - "depth = (int) 32, " - "rate = (int) [1, MAX], " - "channels = (int) [1, 9];" - "audio/x-raw-int, " - "endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, " - "signed = (boolean) { TRUE }, " - "width = (int) 32, " - "depth = (int) 32, " - "rate = (int) [1, MAX], " - "channels = (int) [1, 9];" - "audio/x-raw-int, " - "endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, " - "signed = (boolean) { TRUE }, " - "width = (int) 24, " - "depth = (int) 24, " + GST_STATIC_CAPS ("audio/x-raw, " + "format = (string) " FORMATS ", " + "layout = (string) interleaved, " "rate = (int) [1, MAX], " "channels = (int) [1, 9];" - "audio/x-raw-int, " - "endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, " - "signed = (boolean) { TRUE }, " - "width = (int) 16, " - "depth = (int) 16, " - "rate = (int) [1, MAX], " - "channels = (int) [1, 9];" - "audio/x-raw-int, " - "endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, " - "signed = (boolean) { TRUE }, " - "width = (int) 8, " - "depth = (int) 8, " - "rate = (int) [1, MAX], " "channels = (int) [1, MAX];" "audio/x-ac3, framed = (boolean) true;" "audio/x-dts, framed = (boolean) true") ); @@ -140,20 +117,24 @@ static void gst_osx_audio_sink_set_property (GObject * object, guint prop_id, static void gst_osx_audio_sink_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); +static gboolean gst_osx_audio_sink_query (GstBaseSink * base, GstQuery * query); + static gboolean gst_osx_audio_sink_stop (GstBaseSink * base); -static GstCaps *gst_osx_audio_sink_getcaps (GstBaseSink * base); -static gboolean gst_osx_audio_sink_acceptcaps (GstPad * pad, GstCaps * caps); +static GstCaps *gst_osx_audio_sink_getcaps (GstBaseSink * base, + GstCaps * filter); +static gboolean gst_osx_audio_sink_acceptcaps (GstOsxAudioSink * sink, + GstCaps * caps); -static GstBuffer *gst_osx_audio_sink_sink_payload (GstBaseAudioSink * sink, +static GstBuffer *gst_osx_audio_sink_sink_payload (GstAudioBaseSink * sink, GstBuffer * buf); -static GstRingBuffer *gst_osx_audio_sink_create_ringbuffer (GstBaseAudioSink * - sink); +static GstAudioRingBuffer + * gst_osx_audio_sink_create_ringbuffer (GstAudioBaseSink * sink); static void gst_osx_audio_sink_osxelement_init (gpointer g_iface, gpointer iface_data); static gboolean gst_osx_audio_sink_select_device (GstOsxAudioSink * osxsink); static void gst_osx_audio_sink_set_volume (GstOsxAudioSink * sink); -static OSStatus gst_osx_audio_sink_io_proc (GstOsxRingBuffer * buf, +static OSStatus gst_osx_audio_sink_io_proc (GstOsxAudioRingBuffer * buf, AudioUnitRenderActionFlags * ioActionFlags, const AudioTimeStamp * inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList * bufferList); @@ -175,22 +156,10 @@ gst_osx_audio_sink_do_init (GType type) &osxelement_info); } -GST_BOILERPLATE_FULL (GstOsxAudioSink, gst_osx_audio_sink, GstBaseAudioSink, - GST_TYPE_BASE_AUDIO_SINK, gst_osx_audio_sink_do_init); - -static void -gst_osx_audio_sink_base_init (gpointer g_class) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&sink_factory)); - - gst_element_class_set_static_metadata (element_class, "Audio Sink (OSX)", - "Sink/Audio", - "Output to a sound card in OS X", - "Zaheer Abbas Merali <zaheerabbas at merali dot org>"); -} +#define gst_osx_audio_sink_parent_class parent_class +G_DEFINE_TYPE_WITH_CODE (GstOsxAudioSink, gst_osx_audio_sink, + GST_TYPE_AUDIO_BASE_SINK, + gst_osx_audio_sink_do_init (GST_TYPE_AUDIO_BASE_SINK)); static void gst_osx_audio_sink_class_init (GstOsxAudioSinkClass * klass) @@ -198,12 +167,12 @@ gst_osx_audio_sink_class_init (GstOsxAudioSinkClass * klass) GObjectClass *gobject_class; GstElementClass *gstelement_class; GstBaseSinkClass *gstbasesink_class; - GstBaseAudioSinkClass *gstbaseaudiosink_class; + GstAudioBaseSinkClass *gstaudiobasesink_class; gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; gstbasesink_class = (GstBaseSinkClass *) klass; - gstbaseaudiosink_class = (GstBaseAudioSinkClass *) klass; + gstaudiobasesink_class = (GstAudioBaseSinkClass *) klass; parent_class = g_type_class_peek_parent (klass); @@ -216,6 +185,8 @@ gst_osx_audio_sink_class_init (GstOsxAudioSinkClass * klass) 0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); #endif + gstbasesink_class->query = GST_DEBUG_FUNCPTR (gst_osx_audio_sink_query); + g_object_class_install_property (gobject_class, ARG_VOLUME, g_param_spec_double ("volume", "Volume", "Volume of this stream", 0, 1.0, 1.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); @@ -223,14 +194,22 @@ gst_osx_audio_sink_class_init (GstOsxAudioSinkClass * klass) gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_osx_audio_sink_getcaps); gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_osx_audio_sink_stop); - gstbaseaudiosink_class->create_ringbuffer = + gstaudiobasesink_class->create_ringbuffer = GST_DEBUG_FUNCPTR (gst_osx_audio_sink_create_ringbuffer); - gstbaseaudiosink_class->payload = + gstaudiobasesink_class->payload = GST_DEBUG_FUNCPTR (gst_osx_audio_sink_sink_payload); + + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&sink_factory)); + + gst_element_class_set_static_metadata (gstelement_class, "Audio Sink (OSX)", + "Sink/Audio", + "Output to a sound card in OS X", + "Zaheer Abbas Merali <zaheerabbas at merali dot org>"); } static void -gst_osx_audio_sink_init (GstOsxAudioSink * sink, GstOsxAudioSinkClass * gclass) +gst_osx_audio_sink_init (GstOsxAudioSink * sink) { GST_DEBUG ("Initialising object"); @@ -238,9 +217,6 @@ gst_osx_audio_sink_init (GstOsxAudioSink * sink, GstOsxAudioSinkClass * gclass) sink->cached_caps = NULL; sink->volume = DEFAULT_VOLUME; - - gst_pad_set_acceptcaps_function (GST_BASE_SINK (sink)->sinkpad, - GST_DEBUG_FUNCPTR (gst_osx_audio_sink_acceptcaps)); } static void @@ -286,6 +262,30 @@ gst_osx_audio_sink_get_property (GObject * object, guint prop_id, } static gboolean +gst_osx_audio_sink_query (GstBaseSink * base, GstQuery * query) +{ + GstOsxAudioSink *sink = GST_OSX_AUDIO_SINK (base); + gboolean ret = FALSE; + + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_ACCEPT_CAPS: + { + GstCaps *caps = NULL; + + gst_query_parse_accept_caps (query, &caps); + ret = gst_osx_audio_sink_acceptcaps (sink, caps); + gst_query_set_accept_caps_result (query, ret); + ret = TRUE; + break; + } + default: + ret = GST_BASE_SINK_CLASS (parent_class)->query (base, query); + break; + } + return ret; +} + +static gboolean gst_osx_audio_sink_stop (GstBaseSink * base) { GstOsxAudioSink *sink = GST_OSX_AUDIO_SINK (base); @@ -299,7 +299,7 @@ gst_osx_audio_sink_stop (GstBaseSink * base) } static GstCaps * -gst_osx_audio_sink_getcaps (GstBaseSink * base) +gst_osx_audio_sink_getcaps (GstBaseSink * base, GstCaps * filter) { GstOsxAudioSink *sink = GST_OSX_AUDIO_SINK (base); gchar *caps_string = NULL; @@ -316,23 +316,22 @@ gst_osx_audio_sink_getcaps (GstBaseSink * base) } static gboolean -gst_osx_audio_sink_acceptcaps (GstPad * pad, GstCaps * caps) +gst_osx_audio_sink_acceptcaps (GstOsxAudioSink * sink, GstCaps * caps) { - GstOsxAudioSink *sink = GST_OSX_AUDIO_SINK (gst_pad_get_parent_element (pad)); - GstOsxRingBuffer *osxbuf; + GstOsxAudioRingBuffer *osxbuf = NULL; GstCaps *pad_caps; GstStructure *st; gboolean ret = FALSE; - GstRingBufferSpec spec = { 0 }; + GstAudioRingBufferSpec spec = { 0 }; gchar *caps_string = NULL; - osxbuf = GST_OSX_RING_BUFFER (GST_BASE_AUDIO_SINK (sink)->ringbuffer); + osxbuf = GST_OSX_AUDIO_RING_BUFFER (GST_AUDIO_BASE_SINK (sink)->ringbuffer); caps_string = gst_caps_to_string (caps); GST_DEBUG_OBJECT (sink, "acceptcaps called with %s", caps_string); g_free (caps_string); - pad_caps = gst_pad_get_caps (pad); + pad_caps = gst_pad_query_caps (GST_BASE_SINK_PAD (sink), caps); if (pad_caps) { gboolean cret = gst_caps_can_intersect (pad_caps, caps); gst_caps_unref (pad_caps); @@ -349,12 +348,12 @@ gst_osx_audio_sink_acceptcaps (GstPad * pad, GstCaps * caps) /* parse helper expects this set, so avoid nasty warning * will be set properly later on anyway */ spec.latency_time = GST_SECOND; - if (!gst_ring_buffer_parse_caps (&spec, caps)) + if (!gst_audio_ring_buffer_parse_caps (&spec, caps)) goto done; /* Make sure input is framed and can be payloaded */ switch (spec.type) { - case GST_BUFTYPE_AC3: + case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_AC3: { gboolean framed = FALSE; @@ -365,7 +364,7 @@ gst_osx_audio_sink_acceptcaps (GstPad * pad, GstCaps * caps) goto done; break; } - case GST_BUFTYPE_DTS: + case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_DTS: { gboolean parsed = FALSE; @@ -382,12 +381,11 @@ gst_osx_audio_sink_acceptcaps (GstPad * pad, GstCaps * caps) ret = TRUE; done: - gst_object_unref (sink); return ret; } static GstBuffer * -gst_osx_audio_sink_sink_payload (GstBaseAudioSink * sink, GstBuffer * buf) +gst_osx_audio_sink_sink_payload (GstAudioBaseSink * sink, GstBuffer * buf) { GstOsxAudioSink *osxsink; @@ -396,36 +394,42 @@ gst_osx_audio_sink_sink_payload (GstBaseAudioSink * sink, GstBuffer * buf) if (RINGBUFFER_IS_SPDIF (sink->ringbuffer->spec.type)) { gint framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec); GstBuffer *out; + GstMapInfo inmap, outmap; + gboolean res; if (framesize <= 0) return NULL; out = gst_buffer_new_and_alloc (framesize); + gst_buffer_map (buf, &inmap, GST_MAP_READ); + gst_buffer_map (out, &outmap, GST_MAP_WRITE); + /* FIXME: the endianness needs to be queried and then set */ - if (!gst_audio_iec61937_payload (GST_BUFFER_DATA (buf), - GST_BUFFER_SIZE (buf), GST_BUFFER_DATA (out), - GST_BUFFER_SIZE (out), &sink->ringbuffer->spec, G_BYTE_ORDER)) { + res = gst_audio_iec61937_payload (inmap.data, inmap.size, + outmap.data, outmap.size, &sink->ringbuffer->spec, G_BIG_ENDIAN); + + gst_buffer_unmap (buf, &inmap); + gst_buffer_unmap (out, &outmap); + + if (!res) { gst_buffer_unref (out); return NULL; } - gst_buffer_copy_metadata (out, buf, GST_BUFFER_COPY_ALL); - - /* Fix endianness */ - swab ((gchar *) GST_BUFFER_DATA (buf), - (gchar *) GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); + gst_buffer_copy_into (out, buf, GST_BUFFER_COPY_METADATA, 0, -1); return out; + } else { return gst_buffer_ref (buf); } } -static GstRingBuffer * -gst_osx_audio_sink_create_ringbuffer (GstBaseAudioSink * sink) +static GstAudioRingBuffer * +gst_osx_audio_sink_create_ringbuffer (GstAudioBaseSink * sink) { GstOsxAudioSink *osxsink; - GstOsxRingBuffer *ringbuffer; + GstOsxAudioRingBuffer *ringbuffer; osxsink = GST_OSX_AUDIO_SINK (sink); @@ -435,7 +439,7 @@ gst_osx_audio_sink_create_ringbuffer (GstBaseAudioSink * sink) } GST_DEBUG_OBJECT (sink, "Creating ringbuffer"); - ringbuffer = g_object_new (GST_TYPE_OSX_RING_BUFFER, NULL); + ringbuffer = g_object_new (GST_TYPE_OSX_AUDIO_RING_BUFFER, NULL); GST_DEBUG_OBJECT (sink, "osx sink %p element %p ioproc %p", osxsink, GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsink), (void *) gst_osx_audio_sink_io_proc); @@ -447,7 +451,7 @@ gst_osx_audio_sink_create_ringbuffer (GstBaseAudioSink * sink) ringbuffer->core_audio->device_id = osxsink->device_id; ringbuffer->core_audio->is_src = FALSE; - return GST_RING_BUFFER (ringbuffer); + return GST_AUDIO_RING_BUFFER (ringbuffer); } /* HALOutput AudioUnit will request fairly arbitrarily-sized chunks @@ -455,7 +459,7 @@ gst_osx_audio_sink_create_ringbuffer (GstBaseAudioSink * sink) * the current ringbuffer segment we are, and only advance the segment * once we've read the whole thing */ static OSStatus -gst_osx_audio_sink_io_proc (GstOsxRingBuffer * buf, +gst_osx_audio_sink_io_proc (GstOsxAudioRingBuffer * buf, AudioUnitRenderActionFlags * ioActionFlags, const AudioTimeStamp * inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList * bufferList) @@ -468,7 +472,7 @@ gst_osx_audio_sink_io_proc (GstOsxRingBuffer * buf, gint offset = 0; while (remaining) { - if (!gst_ring_buffer_prepare_read (GST_RING_BUFFER (buf), + if (!gst_audio_ring_buffer_prepare_read (GST_AUDIO_RING_BUFFER (buf), &readseg, &readptr, &len)) return 0; @@ -484,12 +488,12 @@ gst_osx_audio_sink_io_proc (GstOsxRingBuffer * buf, offset += len; remaining -= len; - if ((gint) buf->segoffset == GST_RING_BUFFER (buf)->spec.segsize) { + if ((gint) buf->segoffset == GST_AUDIO_RING_BUFFER (buf)->spec.segsize) { /* clear written samples */ - gst_ring_buffer_clear (GST_RING_BUFFER (buf), readseg); + gst_audio_ring_buffer_clear (GST_AUDIO_RING_BUFFER (buf), readseg); /* we wrote one segment */ - gst_ring_buffer_advance (GST_RING_BUFFER (buf), 1); + gst_audio_ring_buffer_advance (GST_AUDIO_RING_BUFFER (buf), 1); buf->segoffset = 0; } @@ -508,9 +512,9 @@ gst_osx_audio_sink_osxelement_init (gpointer g_iface, gpointer iface_data) static void gst_osx_audio_sink_set_volume (GstOsxAudioSink * sink) { - GstOsxRingBuffer *osxbuf; + GstOsxAudioRingBuffer *osxbuf; - osxbuf = GST_OSX_RING_BUFFER (GST_BASE_AUDIO_SINK (sink)->ringbuffer); + osxbuf = GST_OSX_AUDIO_RING_BUFFER (GST_AUDIO_BASE_SINK (sink)->ringbuffer); if (!osxbuf) return; @@ -527,17 +531,7 @@ gst_osx_audio_sink_allowed_caps (GstOsxAudioSink * osxsink) GstPadTemplate *pad_template; GstCaps *caps, *in_caps; - GstAudioChannelPosition pos[9] = { - GST_AUDIO_CHANNEL_POSITION_INVALID, - GST_AUDIO_CHANNEL_POSITION_INVALID, - GST_AUDIO_CHANNEL_POSITION_INVALID, - GST_AUDIO_CHANNEL_POSITION_INVALID, - GST_AUDIO_CHANNEL_POSITION_INVALID, - GST_AUDIO_CHANNEL_POSITION_INVALID, - GST_AUDIO_CHANNEL_POSITION_INVALID, - GST_AUDIO_CHANNEL_POSITION_INVALID, - GST_AUDIO_CHANNEL_POSITION_INVALID - }; + guint64 channel_mask = 0; /* First collect info about the HW capabilites and preferences */ spdif_allowed = @@ -561,31 +555,31 @@ gst_osx_audio_sink_allowed_caps (GstOsxAudioSink * osxsink) for (i = 0; i < max_channels; i++) { switch (layout->mChannelDescriptions[i].mChannelLabel) { case kAudioChannelLabel_Left: - pos[i] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT; + channel_mask |= GST_AUDIO_CHANNEL_POSITION_MASK (FRONT_LEFT); break; case kAudioChannelLabel_Right: - pos[i] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT; + channel_mask |= GST_AUDIO_CHANNEL_POSITION_MASK (FRONT_RIGHT); break; case kAudioChannelLabel_Center: - pos[i] = GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER; + channel_mask |= GST_AUDIO_CHANNEL_POSITION_MASK (FRONT_CENTER); break; case kAudioChannelLabel_LFEScreen: - pos[i] = GST_AUDIO_CHANNEL_POSITION_LFE; + channel_mask |= GST_AUDIO_CHANNEL_POSITION_MASK (LFE1); break; case kAudioChannelLabel_LeftSurround: - pos[i] = GST_AUDIO_CHANNEL_POSITION_REAR_LEFT; + channel_mask |= GST_AUDIO_CHANNEL_POSITION_MASK (REAR_LEFT); break; case kAudioChannelLabel_RightSurround: - pos[i] = GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT; + channel_mask |= GST_AUDIO_CHANNEL_POSITION_MASK (REAR_RIGHT); break; case kAudioChannelLabel_RearSurroundLeft: - pos[i] = GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT; + channel_mask |= GST_AUDIO_CHANNEL_POSITION_MASK (SIDE_LEFT); break; case kAudioChannelLabel_RearSurroundRight: - pos[i] = GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT; + channel_mask |= GST_AUDIO_CHANNEL_POSITION_MASK (SIDE_RIGHT); break; case kAudioChannelLabel_CenterSurround: - pos[i] = GST_AUDIO_CHANNEL_POSITION_REAR_CENTER; + channel_mask |= GST_AUDIO_CHANNEL_POSITION_MASK (REAR_CENTER); break; default: GST_WARNING_OBJECT (osxsink, "unrecognized channel: %d", @@ -619,12 +613,12 @@ gst_osx_audio_sink_allowed_caps (GstOsxAudioSink * osxsink) if (max_channels > 2 && use_positions) { out_s = gst_structure_copy (in_s); gst_structure_remove_field (out_s, "channels"); - gst_structure_set (out_s, "channels", G_TYPE_INT, max_channels, NULL); - gst_audio_set_channel_positions (out_s, pos); + gst_structure_set (out_s, "channels", G_TYPE_INT, max_channels, + "channel-mask", GST_TYPE_BITMASK, channel_mask, NULL); gst_caps_append_structure (caps, out_s); } out_s = gst_structure_copy (in_s); - gst_structure_remove_field (out_s, "channels"); + gst_structure_remove_fields (out_s, "channels", "channel-mask", NULL); gst_structure_set (out_s, "channels", GST_TYPE_INT_RANGE, 1, 2, NULL); gst_caps_append_structure (caps, out_s); } diff --git a/sys/osxaudio/gstosxaudiosink.h b/sys/osxaudio/gstosxaudiosink.h index e3aaec3f7..36daac68c 100644 --- a/sys/osxaudio/gstosxaudiosink.h +++ b/sys/osxaudio/gstosxaudiosink.h @@ -51,8 +51,8 @@ #define __GST_OSXAUDIOSINK_H__ #include <gst/gst.h> -#include <gst/audio/gstbaseaudiosink.h> -#include "gstosxringbuffer.h" +#include <gst/audio/gstaudiobasesink.h> +#include "gstosxaudioringbuffer.h" G_BEGIN_DECLS @@ -68,7 +68,7 @@ typedef struct _GstOsxAudioSinkClass GstOsxAudioSinkClass; struct _GstOsxAudioSink { - GstBaseAudioSink sink; + GstAudioBaseSink sink; AudioDeviceID device_id; @@ -79,7 +79,7 @@ struct _GstOsxAudioSink struct _GstOsxAudioSinkClass { - GstBaseAudioSinkClass parent_class; + GstAudioBaseSinkClass parent_class; }; GType gst_osx_audio_sink_get_type (void); diff --git a/sys/osxaudio/gstosxaudiosrc.c b/sys/osxaudio/gstosxaudiosrc.c index 6f17cd78d..198b00663 100644 --- a/sys/osxaudio/gstosxaudiosrc.c +++ b/sys/osxaudio/gstosxaudiosrc.c @@ -95,13 +95,13 @@ static void gst_osx_audio_src_set_property (GObject * object, guint prop_id, static void gst_osx_audio_src_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static GstCaps *gst_osx_audio_src_get_caps (GstBaseSrc * src); +static GstCaps *gst_osx_audio_src_get_caps (GstBaseSrc * src, GstCaps * filter); -static GstRingBuffer *gst_osx_audio_src_create_ringbuffer (GstBaseAudioSrc * - src); +static GstAudioRingBuffer *gst_osx_audio_src_create_ringbuffer (GstAudioBaseSrc + * src); static void gst_osx_audio_src_osxelement_init (gpointer g_iface, gpointer iface_data); -static OSStatus gst_osx_audio_src_io_proc (GstOsxRingBuffer * buf, +static OSStatus gst_osx_audio_src_io_proc (GstOsxAudioRingBuffer * buf, AudioUnitRenderActionFlags * ioActionFlags, const AudioTimeStamp * inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList * bufferList); @@ -123,22 +123,9 @@ gst_osx_audio_src_do_init (GType type) &osxelement_info); } -GST_BOILERPLATE_FULL (GstOsxAudioSrc, gst_osx_audio_src, GstBaseAudioSrc, - GST_TYPE_BASE_AUDIO_SRC, gst_osx_audio_src_do_init); - -static void -gst_osx_audio_src_base_init (gpointer g_class) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&src_factory)); - - gst_element_class_set_static_metadata (element_class, "Audio Source (OSX)", - "Source/Audio", - "Input from a sound card in OS X", - "Zaheer Abbas Merali <zaheerabbas at merali dot org>"); -} +G_DEFINE_TYPE_WITH_CODE (GstOsxAudioSrc, gst_osx_audio_src, + GST_TYPE_AUDIO_BASE_SRC, + gst_osx_audio_src_do_init (GST_TYPE_AUDIO_BASE_SRC)); static void gst_osx_audio_src_class_init (GstOsxAudioSrcClass * klass) @@ -146,14 +133,12 @@ gst_osx_audio_src_class_init (GstOsxAudioSrcClass * klass) GObjectClass *gobject_class; GstElementClass *gstelement_class; GstBaseSrcClass *gstbasesrc_class; - GstBaseAudioSrcClass *gstbaseaudiosrc_class; + GstAudioBaseSrcClass *gstaudiobasesrc_class; gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; gstbasesrc_class = (GstBaseSrcClass *) klass; - gstbaseaudiosrc_class = (GstBaseAudioSrcClass *) klass; - - parent_class = g_type_class_peek_parent (klass); + gstaudiobasesrc_class = (GstAudioBaseSrcClass *) klass; gobject_class->set_property = gst_osx_audio_src_set_property; gobject_class->get_property = gst_osx_audio_src_get_property; @@ -164,12 +149,20 @@ gst_osx_audio_src_class_init (GstOsxAudioSrcClass * klass) g_param_spec_int ("device", "Device ID", "Device ID of input device", 0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - gstbaseaudiosrc_class->create_ringbuffer = + gstaudiobasesrc_class->create_ringbuffer = GST_DEBUG_FUNCPTR (gst_osx_audio_src_create_ringbuffer); + + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&src_factory)); + + gst_element_class_set_static_metadata (gstelement_class, "Audio Source (OSX)", + "Source/Audio", + "Input from a sound card in OS X", + "Zaheer Abbas Merali <zaheerabbas at merali dot org>"); } static void -gst_osx_audio_src_init (GstOsxAudioSrc * src, GstOsxAudioSrcClass * gclass) +gst_osx_audio_src_init (GstOsxAudioSrc * src) { gst_base_src_set_live (GST_BASE_SRC (src), TRUE); @@ -210,7 +203,7 @@ gst_osx_audio_src_get_property (GObject * object, guint prop_id, } static GstCaps * -gst_osx_audio_src_get_caps (GstBaseSrc * src) +gst_osx_audio_src_get_caps (GstBaseSrc * src, GstCaps * filter) { GstElementClass *gstelement_class; GstOsxAudioSrc *osxsrc; @@ -248,18 +241,18 @@ gst_osx_audio_src_get_caps (GstBaseSrc * src) return caps; } -static GstRingBuffer * -gst_osx_audio_src_create_ringbuffer (GstBaseAudioSrc * src) +static GstAudioRingBuffer * +gst_osx_audio_src_create_ringbuffer (GstAudioBaseSrc * src) { GstOsxAudioSrc *osxsrc; - GstOsxRingBuffer *ringbuffer; + GstOsxAudioRingBuffer *ringbuffer; osxsrc = GST_OSX_AUDIO_SRC (src); gst_osx_audio_src_select_device (osxsrc); GST_DEBUG ("Creating ringbuffer"); - ringbuffer = g_object_new (GST_TYPE_OSX_RING_BUFFER, NULL); + ringbuffer = g_object_new (GST_TYPE_OSX_AUDIO_RING_BUFFER, NULL); GST_DEBUG ("osx src 0x%p element 0x%p ioproc 0x%p", osxsrc, GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsrc), (void *) gst_osx_audio_src_io_proc); @@ -269,11 +262,11 @@ gst_osx_audio_src_create_ringbuffer (GstBaseAudioSrc * src) ringbuffer->core_audio->is_src = TRUE; ringbuffer->core_audio->device_id = osxsrc->device_id; - return GST_RING_BUFFER (ringbuffer); + return GST_AUDIO_RING_BUFFER (ringbuffer); } static OSStatus -gst_osx_audio_src_io_proc (GstOsxRingBuffer * buf, +gst_osx_audio_src_io_proc (GstOsxAudioRingBuffer * buf, AudioUnitRenderActionFlags * ioActionFlags, const AudioTimeStamp * inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList * bufferList) @@ -296,7 +289,7 @@ gst_osx_audio_src_io_proc (GstOsxRingBuffer * buf, remaining = buf->core_audio->recBufferList->mBuffers[0].mDataByteSize; while (remaining) { - if (!gst_ring_buffer_prepare_read (GST_RING_BUFFER (buf), + if (!gst_audio_ring_buffer_prepare_read (GST_AUDIO_RING_BUFFER (buf), &writeseg, &writeptr, &len)) return 0; @@ -313,9 +306,9 @@ gst_osx_audio_src_io_proc (GstOsxRingBuffer * buf, offset += len; remaining -= len; - if ((gint) buf->segoffset == GST_RING_BUFFER (buf)->spec.segsize) { + if ((gint) buf->segoffset == GST_AUDIO_RING_BUFFER (buf)->spec.segsize) { /* we wrote one segment */ - gst_ring_buffer_advance (GST_RING_BUFFER (buf), 1); + gst_audio_ring_buffer_advance (GST_AUDIO_RING_BUFFER (buf), 1); buf->segoffset = 0; } diff --git a/sys/osxaudio/gstosxaudiosrc.h b/sys/osxaudio/gstosxaudiosrc.h index a812d9efe..237b59871 100644 --- a/sys/osxaudio/gstosxaudiosrc.h +++ b/sys/osxaudio/gstosxaudiosrc.h @@ -45,8 +45,8 @@ #define __GST_OSXAUDIOSRC_H__ #include <gst/gst.h> -#include <gst/audio/gstbaseaudiosrc.h> -#include "gstosxringbuffer.h" +#include <gst/audio/gstaudiobasesrc.h> +#include "gstosxaudioringbuffer.h" G_BEGIN_DECLS @@ -62,7 +62,7 @@ typedef struct _GstOsxAudioSrcClass GstOsxAudioSrcClass; struct _GstOsxAudioSrc { - GstBaseAudioSrc src; + GstAudioBaseSrc src; AudioDeviceID device_id; @@ -72,7 +72,7 @@ struct _GstOsxAudioSrc struct _GstOsxAudioSrcClass { - GstBaseAudioSrcClass parent_class; + GstAudioBaseSrcClass parent_class; }; GType gst_osx_audio_src_get_type (void); diff --git a/sys/osxaudio/gstosxcoreaudiocommon.c b/sys/osxaudio/gstosxcoreaudiocommon.c index 5200b2ea1..a9689af6b 100644 --- a/sys/osxaudio/gstosxcoreaudiocommon.c +++ b/sys/osxaudio/gstosxcoreaudiocommon.c @@ -222,7 +222,8 @@ gst_core_audio_set_channels_layout (GstCoreAudio * core_audio, int layoutSize, element, i; AudioUnitScope scope; GstStructure *structure; - GstAudioChannelPosition *positions; + GstAudioChannelPosition *positions = NULL; + guint64 channel_mask; /* Describe channels */ layoutSize = sizeof (AudioChannelLayout) + @@ -230,7 +231,11 @@ gst_core_audio_set_channels_layout (GstCoreAudio * core_audio, layout = g_malloc (layoutSize); structure = gst_caps_get_structure (caps, 0); - positions = gst_audio_get_channel_positions (structure); + if (gst_structure_get (structure, "channel-mask", GST_TYPE_BITMASK, + &channel_mask, NULL)) { + positions = g_new (GstAudioChannelPosition, channels); + gst_audio_channel_positions_from_mask (channels, channel_mask, positions); + } layout->mChannelLayoutTag = kAudioChannelLayoutTag_UseChannelDescriptions; layout->mChannelBitmap = 0; /* Not used */ @@ -377,7 +382,7 @@ gst_audio_channel_position_to_coreaudio_channel_label (GstAudioChannelPosition switch (position) { case GST_AUDIO_CHANNEL_POSITION_NONE: return kAudioChannelLabel_Discrete_0 | channel; - case GST_AUDIO_CHANNEL_POSITION_FRONT_MONO: + case GST_AUDIO_CHANNEL_POSITION_MONO: return kAudioChannelLabel_Mono; case GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT: return kAudioChannelLabel_Left; @@ -389,7 +394,7 @@ gst_audio_channel_position_to_coreaudio_channel_label (GstAudioChannelPosition return kAudioChannelLabel_LeftSurround; case GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT: return kAudioChannelLabel_RightSurround; - case GST_AUDIO_CHANNEL_POSITION_LFE: + case GST_AUDIO_CHANNEL_POSITION_LFE1: return kAudioChannelLabel_LFEScreen; case GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER: return kAudioChannelLabel_Center; diff --git a/sys/osxaudio/gstosxcoreaudiocommon.h b/sys/osxaudio/gstosxcoreaudiocommon.h index 7b6a53db2..4fade0d96 100644 --- a/sys/osxaudio/gstosxcoreaudiocommon.h +++ b/sys/osxaudio/gstosxcoreaudiocommon.h @@ -22,7 +22,11 @@ */ #include "gstosxcoreaudio.h" +<<<<<<< #include <gst/audio/multichannel.h> +======= +#include <gst/audio/audio-channels.h> +>>>>>>> typedef struct { |