summaryrefslogtreecommitdiffstats
path: root/sys/osxaudio
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2007-03-15 11:39:53 +0000
committerEdward Hervey <bilboed@bilboed.com>2007-03-15 11:39:53 +0000
commit4d0df9433c3a9ba3345c4d394b7ec20653ee6044 (patch)
tree075dbaaf00bbc7b14de4a6d87dc7519c4d90bfb9 /sys/osxaudio
parent1be3219c706bf105acde3efcafe20b962def928d (diff)
Activate osxaudio in gst-plugins-good with proper build setup.
Original commit message from CVS: * configure.ac: * sys/Makefile.am: * sys/osxaudio/Makefile.am: * sys/osxaudio/gstosxaudio.c: * sys/osxaudio/gstosxaudiosink.c: (gst_osx_audio_sink_osxelement_do_init), (gst_osx_audio_sink_init), (gst_osx_audio_sink_getcaps), (gst_osx_audio_sink_create_ringbuffer), (plugin_init): * sys/osxaudio/gstosxaudiosrc.c: (gst_osx_audio_src_osxelement_do_init), (gst_osx_audio_src_init), (gst_osx_audio_src_create_ringbuffer): * sys/osxaudio/gstosxringbuffer.c: (gst_osx_ring_buffer_get_type), (gst_osx_ring_buffer_class_init), (gst_osx_ring_buffer_init), (gst_osx_ring_buffer_acquire), (gst_osx_ring_buffer_start), (gst_osx_ring_buffer_pause), (gst_osx_ring_buffer_stop): * sys/osxaudio/gstosxringbuffer.h: Activate osxaudio in gst-plugins-good with proper build setup. Add inlined documentation. Fix debug statements Fix ringbuffer when pausing. Fixes #323471
Diffstat (limited to 'sys/osxaudio')
-rw-r--r--sys/osxaudio/Makefile.am8
-rw-r--r--sys/osxaudio/gstosxaudio.c21
-rw-r--r--sys/osxaudio/gstosxaudiosink.c19
-rw-r--r--sys/osxaudio/gstosxaudiosrc.c8
-rw-r--r--sys/osxaudio/gstosxringbuffer.c79
-rw-r--r--sys/osxaudio/gstosxringbuffer.h3
6 files changed, 90 insertions, 48 deletions
diff --git a/sys/osxaudio/Makefile.am b/sys/osxaudio/Makefile.am
index 58a19dc1..4ea2114c 100644
--- a/sys/osxaudio/Makefile.am
+++ b/sys/osxaudio/Makefile.am
@@ -5,8 +5,12 @@ libgstosxaudio_la_SOURCES = gstosxringbuffer.c \
gstosxaudiosink.c \
gstosxaudiosrc.c
-libgstosxaudio_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GSTPB_BASE_FLAGS)
-libgstosxaudio_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(GSTPB_BASE_LIBS) -lgstaudio-@GST_MAJORMINOR@
+libgstosxaudio_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
+libgstosxaudio_la_LIBADD = \
+ -lgstinterfaces-@GST_MAJORMINOR@ \
+ -lgstaudio-@GST_MAJORMINOR@ \
+ $(GST_PLUGINS_BASE_LIBS) \
+ $(GST_LIBS)
libgstosxaudio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -Wl,-framework -Wl,CoreAudio
noinst_HEADERS = gstosxaudiosink.h \
diff --git a/sys/osxaudio/gstosxaudio.c b/sys/osxaudio/gstosxaudio.c
index 6e9b87bf..8a79bed2 100644
--- a/sys/osxaudio/gstosxaudio.c
+++ b/sys/osxaudio/gstosxaudio.c
@@ -20,6 +20,27 @@
*
*/
+/**
+ * SECTION:element-osxaudiosink
+ * @short_description: play audio to an CoreAudio device
+ *
+ * <refsect2>
+ * <para>
+ * This element renders raw audio samples using the CoreAudio api.
+ * </para>
+ * <title>Example pipelines</title>
+ * <para>
+ * Play an Ogg/Vorbis file.
+ * </para>
+ * <programlisting>
+ * gst-launch -v filesrc location=sine.ogg ! oggdemux ! vorbisdec ! audioconvert ! audioresample ! osxaudiosink
+ * </programlisting>
+ * </refsect2>
+ *
+ * Last reviewed on 2006-03-01 (0.10.4)
+ */
+
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/sys/osxaudio/gstosxaudiosink.c b/sys/osxaudio/gstosxaudiosink.c
index 43bcbdfb..222056c8 100644
--- a/sys/osxaudio/gstosxaudiosink.c
+++ b/sys/osxaudio/gstosxaudiosink.c
@@ -129,7 +129,7 @@ gst_osx_audio_sink_osxelement_do_init (GType type)
GST_DEBUG_CATEGORY_INIT (osx_audiosink_debug, "osxaudiosink", 0,
"OSX Audio Sink");
- GST_DEBUG ("Adding static interface\n");
+ GST_DEBUG ("Adding static interface");
g_type_add_interface_static (type, GST_OSX_AUDIO_ELEMENT_TYPE,
&osxelement_info);
}
@@ -190,9 +190,9 @@ gst_osx_audio_sink_init (GstOsxAudioSink * sink, GstOsxAudioSinkClass * gclass)
{
/* GstElementClass *klass = GST_ELEMENT_GET_CLASS (sink); */
sink->ringbuffer = NULL;
- GST_DEBUG ("Initialising object\n");
- gst_osx_audio_sink_create_ringbuffer (sink);
+ GST_DEBUG ("Initialising object");
+ gst_osx_audio_sink_create_ringbuffer (GST_BASE_AUDIO_SINK (sink));
}
static void
@@ -256,11 +256,12 @@ gst_osx_audio_sink_getcaps (GstBaseSink * sink)
kAudioDevicePropertyAvailableNominalSampleRates, &propertySize, &rates);
GST_DEBUG
- ("Getting available sample rates: Status: %d number of ranges: %d\n",
+ ("Getting available sample rates: Status: %ld number of ranges: %lu",
status, propertySize / sizeof (AudioValueRange));
for (i = 0; i < propertySize / sizeof (AudioValueRange); i++) {
- g_print ("Range from %f to %f\n", rates[i].mMinimum, rates[i].mMaximum);
+ GST_LOG_OBJECT (osxsink, "Range from %f to %f", rates[i].mMinimum,
+ rates[i].mMaximum);
}
return caps;
@@ -274,9 +275,9 @@ gst_osx_audio_sink_create_ringbuffer (GstBaseAudioSink * sink)
osxsink = GST_OSX_AUDIO_SINK (sink);
if (!osxsink->ringbuffer) {
- GST_DEBUG ("Creating ringbuffer\n");
+ GST_DEBUG ("Creating ringbuffer");
osxsink->ringbuffer = g_object_new (GST_TYPE_OSX_RING_BUFFER, NULL);
- GST_DEBUG ("osx sink 0x%x element 0x%x ioproc 0x%x\n", osxsink,
+ GST_DEBUG ("osx sink 0x%p element 0x%p ioproc 0x%p", osxsink,
GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsink),
(void *) gst_osx_audio_sink_io_proc);
osxsink->ringbuffer->element =
@@ -333,9 +334,9 @@ plugin_init (GstPlugin * plugin)
gboolean ret;
ret = gst_element_register (plugin, "osxaudiosink",
- GST_RANK_NONE, GST_TYPE_OSX_AUDIO_SINK);
+ GST_RANK_PRIMARY, GST_TYPE_OSX_AUDIO_SINK);
return ret && gst_element_register (plugin, "osxaudiosrc",
- GST_RANK_NONE, GST_TYPE_OSX_AUDIO_SRC);
+ GST_RANK_PRIMARY, GST_TYPE_OSX_AUDIO_SRC);
}
/* this is the structure that gstreamer looks for to register plugins
diff --git a/sys/osxaudio/gstosxaudiosrc.c b/sys/osxaudio/gstosxaudiosrc.c
index 5fc6ba09..5e2b2c2f 100644
--- a/sys/osxaudio/gstosxaudiosrc.c
+++ b/sys/osxaudio/gstosxaudiosrc.c
@@ -122,7 +122,7 @@ gst_osx_audio_src_osxelement_do_init (GType type)
GST_DEBUG_CATEGORY_INIT (osx_audiosrc_debug, "osxaudiosrc", 0,
"OSX Audio Src");
- GST_DEBUG ("Adding static interface\n");
+ GST_DEBUG ("Adding static interface");
g_type_add_interface_static (type, GST_OSX_AUDIO_ELEMENT_TYPE,
&osxelement_info);
}
@@ -181,7 +181,7 @@ gst_osx_audio_src_init (GstOsxAudioSrc * src, GstOsxAudioSrcClass * gclass)
/* GstElementClass *klass = GST_ELEMENT_GET_CLASS (sink); */
gst_base_src_set_live (GST_BASE_SRC (src), TRUE);
src->ringbuffer = NULL;
- GST_DEBUG ("Initialising object\n");
+ GST_DEBUG ("Initialising object");
gst_osx_audio_src_create_ringbuffer (GST_BASE_AUDIO_SRC (src));
}
@@ -233,9 +233,9 @@ gst_osx_audio_src_create_ringbuffer (GstBaseAudioSrc * src)
osxsrc = GST_OSX_AUDIO_SRC (src);
if (!osxsrc->ringbuffer) {
- GST_DEBUG ("Creating ringbuffer\n");
+ GST_DEBUG ("Creating ringbuffer");
osxsrc->ringbuffer = g_object_new (GST_TYPE_OSX_RING_BUFFER, NULL);
- GST_DEBUG ("osx src 0x%x element 0x%x ioproc 0x%x\n", osxsrc,
+ 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);
osxsrc->ringbuffer->element = GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsrc);
diff --git a/sys/osxaudio/gstosxringbuffer.c b/sys/osxaudio/gstosxringbuffer.c
index 3f8fd3be..428c3806 100644
--- a/sys/osxaudio/gstosxringbuffer.c
+++ b/sys/osxaudio/gstosxringbuffer.c
@@ -90,7 +90,7 @@ gst_osx_ring_buffer_get_type (void)
};
GST_DEBUG_CATEGORY_INIT (osx_audio_debug, "osxaudio", 0,
"OSX Audio Elements");
- GST_DEBUG ("Creating osx ring buffer type\n");
+ GST_DEBUG ("Creating osx ring buffer type");
ringbuffer_type =
g_type_register_static (GST_TYPE_RING_BUFFER, "GstOsxRingBuffer",
@@ -130,7 +130,7 @@ gst_osx_ring_buffer_class_init (GstOsxRingBufferClass * klass)
gstringbuffer_class->delay = GST_DEBUG_FUNCPTR (gst_osx_ring_buffer_delay);
- GST_DEBUG ("osx ring buffer class init\n");
+ GST_DEBUG ("osx ring buffer class init");
}
static void
@@ -141,21 +141,21 @@ gst_osx_ring_buffer_init (GstOsxRingBuffer * ringbuffer,
UInt32 propertySize;
/* currently do bugger all */
- GST_DEBUG ("osx ring buffer init\n");
+ GST_DEBUG ("osx ring buffer init");
propertySize = sizeof (ringbuffer->device_id);
status =
AudioHardwareGetProperty (kAudioHardwarePropertyDefaultOutputDevice,
&propertySize, &(ringbuffer->device_id));
- GST_DEBUG ("osx ring buffer called AudioHardwareGetProperty\n");
+ GST_DEBUG ("osx ring buffer called AudioHardwareGetProperty");
if (status) {
- GST_DEBUG ("AudioHardwareGetProperty returned %d\n", (int) status);
+ GST_WARNING ("AudioHardwareGetProperty returned %d", (int) status);
} else {
- GST_DEBUG ("AudioHardwareGetProperty returned 0\n");
+ GST_DEBUG ("AudioHardwareGetProperty returned 0");
}
if (ringbuffer->device_id == kAudioDeviceUnknown) {
- GST_DEBUG ("AudioHardwareGetProperty: device_id is kAudioDeviceUnknown\n");
+ GST_DEBUG ("AudioHardwareGetProperty: device_id is kAudioDeviceUnknown");
}
- GST_DEBUG ("AudioHardwareGetProperty: device_id is %d\n",
+ GST_DEBUG ("AudioHardwareGetProperty: device_id is %lu",
ringbuffer->device_id);
/* get requested buffer length */
propertySize = sizeof (ringbuffer->buffer_len);
@@ -163,11 +163,11 @@ gst_osx_ring_buffer_init (GstOsxRingBuffer * ringbuffer,
AudioDeviceGetProperty (ringbuffer->device_id, 0, false,
kAudioDevicePropertyBufferSize, &propertySize, &ringbuffer->buffer_len);
if (status) {
- GST_DEBUG
- ("AudioDeviceGetProperty returned %d when getting kAudioDevicePropertyBufferSize\n",
+ GST_WARNING
+ ("AudioDeviceGetProperty returned %d when getting kAudioDevicePropertyBufferSize",
(int) status);
}
- GST_DEBUG ("%5d ringbuffer->buffer_len\n", (int) ringbuffer->buffer_len);
+ GST_DEBUG ("%5d ringbuffer->buffer_len", (int) ringbuffer->buffer_len);
}
static void
@@ -207,7 +207,7 @@ gst_osx_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
spec->segsize = osxbuf->buffer_len;
spec->segtotal = 16;
- GST_DEBUG ("osx ring buffer acquire\n");
+ GST_DEBUG ("osx ring buffer acquire");
buf->data = gst_buffer_new_and_alloc (spec->segtotal * spec->segsize);
memset (GST_BUFFER_DATA (buf->data), 0, GST_BUFFER_SIZE (buf->data));
@@ -233,24 +233,29 @@ static gboolean
gst_osx_ring_buffer_start (GstRingBuffer * buf)
{
/* stub */
- OSErr status;
+ OSStatus status;
GstOsxRingBuffer *osxbuf;
osxbuf = GST_OSX_RING_BUFFER (buf);
- GST_DEBUG ("osx ring buffer start ioproc: 0x%x device_id %d\n",
+ GST_DEBUG ("osx ring buffer start ioproc: 0x%p device_id %lu",
osxbuf->element->io_proc, osxbuf->device_id);
- status =
- AudioDeviceAddIOProc (osxbuf->device_id, osxbuf->element->io_proc,
- osxbuf);
-
- if (status) {
- GST_DEBUG ("AudioDeviceAddIOProc returned %d\n", (int) status);
- return FALSE;
+ if (!osxbuf->io_proc_active) {
+ status =
+ AudioDeviceAddIOProc (osxbuf->device_id, osxbuf->element->io_proc,
+ osxbuf);
+
+ if (status) {
+ GST_WARNING ("AudioDeviceAddIOProc returned %" GST_FOURCC_FORMAT,
+ GST_FOURCC_ARGS (status));
+ return FALSE;
+ }
+ osxbuf->io_proc_active = TRUE;
}
+
status = AudioDeviceStart (osxbuf->device_id, osxbuf->element->io_proc);
if (status) {
- GST_DEBUG ("AudioDeviceStart returned %d\n", (int) status);
+ GST_WARNING ("AudioDeviceStart returned %d", (int) status);
return FALSE;
}
return TRUE;
@@ -264,9 +269,15 @@ gst_osx_ring_buffer_pause (GstRingBuffer * buf)
OSErr status;
GstOsxRingBuffer *osxbuf = GST_OSX_RING_BUFFER (buf);
- status = AudioDeviceStop (osxbuf->device_id, osxbuf->element->io_proc);
- if (status)
- GST_DEBUG ("AudioDeviceStop returned %d\n", (int) status);
+ GST_DEBUG ("osx ring buffer pause ioproc: 0x%p device_id %lu",
+ osxbuf->element->io_proc, osxbuf->device_id);
+ if (osxbuf->io_proc_active) {
+ status =
+ AudioDeviceRemoveIOProc (osxbuf->device_id, osxbuf->element->io_proc);
+ if (status)
+ GST_WARNING ("AudioDeviceRemoveIOProc " "returned %d", (int) status);
+ osxbuf->io_proc_active = FALSE;
+ }
return TRUE;
}
@@ -279,16 +290,20 @@ gst_osx_ring_buffer_stop (GstRingBuffer * buf)
osxbuf = GST_OSX_RING_BUFFER (buf);
+ GST_DEBUG ("osx ring buffer stop ioproc: 0x%p device_id %lu",
+ osxbuf->element->io_proc, osxbuf->device_id);
/* stop callback */
status = AudioDeviceStop (osxbuf->device_id, osxbuf->element->io_proc);
if (status)
- GST_DEBUG ("AudioDeviceStop returned %d\n", (int) status);
-
- status =
- AudioDeviceRemoveIOProc (osxbuf->device_id, osxbuf->element->io_proc);
- if (status)
- GST_DEBUG ("AudioDeviceRemoveIOProc " "returned %d\n", (int) status);
-
+ GST_WARNING ("AudioDeviceStop returned %d", (int) status);
+
+ if (osxbuf->io_proc_active) {
+ status =
+ AudioDeviceRemoveIOProc (osxbuf->device_id, osxbuf->element->io_proc);
+ if (status)
+ GST_WARNING ("AudioDeviceRemoveIOProc " "returned %d", (int) status);
+ osxbuf->io_proc_active = FALSE;
+ }
return TRUE;
}
diff --git a/sys/osxaudio/gstosxringbuffer.h b/sys/osxaudio/gstosxringbuffer.h
index 5c0e9b72..bc8d5524 100644
--- a/sys/osxaudio/gstosxringbuffer.h
+++ b/sys/osxaudio/gstosxringbuffer.h
@@ -67,6 +67,7 @@ struct _GstOsxRingBuffer {
GstRingBuffer object;
AudioDeviceID device_id;
+ gboolean io_proc_active;
guint buffer_len;
GstOsxAudioElementInterface* element;
};
@@ -78,4 +79,4 @@ struct _GstOsxRingBufferClass {
GType gst_osx_ring_buffer_get_type (void);
G_END_DECLS
-#endif \ No newline at end of file
+#endif