mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 08:41:07 +00:00
osxaudiosink: Add support for SPDIF output
A big refactoring to allow passthrough AC3/DTS over SPDIF. Several random cleanups and minor fixes.
This commit is contained in:
parent
fe45881a0f
commit
59191412eb
6 changed files with 1858 additions and 455 deletions
|
@ -20,7 +20,8 @@ libgstosxaudio_la_LIBTOOLFLAGS = --tag=disable-static
|
|||
noinst_HEADERS = gstosxaudiosink.h \
|
||||
gstosxaudioelement.h \
|
||||
gstosxringbuffer.h \
|
||||
gstosxaudiosrc.h
|
||||
gstosxaudiosrc.h \
|
||||
gstosxcoreaudio.h
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* GStreamer
|
||||
* Copyright (C) 2005,2006 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
||||
* Copyright (C) 2007,2008 Pioneers of the Inevitable <songbird@songbirdnest.com>
|
||||
* Copyright (C) 2012 Fluendo S.A. <support@fluendo.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -71,9 +72,13 @@
|
|||
#include "gstosxaudiosink.h"
|
||||
#include "gstosxaudioelement.h"
|
||||
|
||||
#include <gst/audio/gstaudioiec61937.h>
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (osx_audiosink_debug);
|
||||
#define GST_CAT_DEFAULT osx_audiosink_debug
|
||||
|
||||
#include "gstosxcoreaudio.h"
|
||||
|
||||
/* Filter signals and args */
|
||||
enum
|
||||
{
|
||||
|
@ -126,7 +131,9 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
|||
"signed = (boolean) { TRUE }, "
|
||||
"width = (int) 8, "
|
||||
"depth = (int) 8, "
|
||||
"rate = (int) [1, MAX], " "channels = (int) [1, MAX]")
|
||||
"rate = (int) [1, MAX], " "channels = (int) [1, MAX];"
|
||||
"audio/x-ac3, framed = (boolean) true;"
|
||||
"audio/x-dts, framed = (boolean) true")
|
||||
);
|
||||
|
||||
static void gst_osx_audio_sink_set_property (GObject * object, guint prop_id,
|
||||
|
@ -134,11 +141,17 @@ 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_stop (GstBaseSink * base);
|
||||
static GstCaps *gst_osx_audio_sink_getcaps (GstBaseSink * base);
|
||||
static gboolean gst_osx_audio_sink_acceptcaps (GstPad * pad, GstCaps * caps);
|
||||
|
||||
static GstBuffer *gst_osx_audio_sink_sink_payload (GstBaseAudioSink * sink,
|
||||
GstBuffer * buf);
|
||||
static GstRingBuffer *gst_osx_audio_sink_create_ringbuffer (GstBaseAudioSink *
|
||||
sink);
|
||||
static void gst_osx_audio_sink_osxelement_init (gpointer g_iface,
|
||||
gpointer iface_data);
|
||||
static void gst_osx_audio_sink_select_device (GstOsxAudioSink * osxsink);
|
||||
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,
|
||||
|
@ -205,8 +218,13 @@ gst_osx_audio_sink_class_init (GstOsxAudioSinkClass * klass)
|
|||
g_param_spec_double ("volume", "Volume", "Volume of this stream",
|
||||
0, 1.0, 1.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
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 =
|
||||
GST_DEBUG_FUNCPTR (gst_osx_audio_sink_create_ringbuffer);
|
||||
gstbaseaudiosink_class->payload =
|
||||
GST_DEBUG_FUNCPTR (gst_osx_audio_sink_sink_payload);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -215,7 +233,12 @@ gst_osx_audio_sink_init (GstOsxAudioSink * sink, GstOsxAudioSinkClass * gclass)
|
|||
GST_DEBUG ("Initialising object");
|
||||
|
||||
sink->device_id = kAudioDeviceUnknown;
|
||||
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
|
||||
|
@ -256,6 +279,178 @@ gst_osx_audio_sink_get_property (GObject * object, guint prop_id,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_osx_audio_sink_stop (GstBaseSink * base)
|
||||
{
|
||||
GstOsxAudioSink *sink = GST_OSX_AUDIO_SINK (base);
|
||||
|
||||
if (sink->cached_caps) {
|
||||
gst_caps_unref (sink->cached_caps);
|
||||
sink->cached_caps = NULL;
|
||||
}
|
||||
|
||||
return GST_CALL_PARENT_WITH_DEFAULT (GST_BASE_SINK_CLASS, stop, (base), TRUE);
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_osx_audio_sink_getcaps (GstBaseSink * base)
|
||||
{
|
||||
GstOsxAudioSink *sink = GST_OSX_AUDIO_SINK (base);
|
||||
GstOsxRingBuffer *osxbuf;
|
||||
GstElementClass *element_class;
|
||||
GstPadTemplate *pad_template;
|
||||
GstCaps *caps;
|
||||
gchar *caps_string = NULL;
|
||||
|
||||
osxbuf = GST_OSX_RING_BUFFER (GST_BASE_AUDIO_SINK (sink)->ringbuffer);
|
||||
|
||||
if (!osxbuf) {
|
||||
GST_DEBUG_OBJECT (sink, "device not open, using template caps");
|
||||
return NULL; /* base class will get template caps for us */
|
||||
}
|
||||
|
||||
if (sink->cached_caps) {
|
||||
caps_string = gst_caps_to_string (sink->cached_caps);
|
||||
GST_DEBUG_OBJECT (sink, "using cached caps: %s", caps_string);
|
||||
g_free (caps_string);
|
||||
return gst_caps_ref (sink->cached_caps);
|
||||
}
|
||||
|
||||
element_class = GST_ELEMENT_GET_CLASS (sink);
|
||||
pad_template = gst_element_class_get_pad_template (element_class, "sink");
|
||||
g_return_val_if_fail (pad_template != NULL, NULL);
|
||||
|
||||
caps = gst_caps_copy (gst_pad_template_get_caps (pad_template));
|
||||
|
||||
if (caps) {
|
||||
if (!osxbuf->is_spdif_capable) {
|
||||
GstCaps *sub_caps, *orig_caps = caps;
|
||||
|
||||
sub_caps = gst_caps_from_string ("audio/x-ac3;audio/x-dts");
|
||||
caps = gst_caps_subtract (orig_caps, sub_caps);
|
||||
gst_caps_unref (sub_caps);
|
||||
gst_caps_unref (orig_caps);
|
||||
}
|
||||
sink->cached_caps = gst_caps_ref (caps);
|
||||
caps_string = gst_caps_to_string (caps);
|
||||
GST_DEBUG_OBJECT (sink, "cached caps: %s", caps_string);
|
||||
g_free (caps_string);
|
||||
}
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_osx_audio_sink_acceptcaps (GstPad * pad, GstCaps * caps)
|
||||
{
|
||||
GstOsxAudioSink *sink = GST_OSX_AUDIO_SINK (gst_pad_get_parent_element (pad));
|
||||
GstOsxRingBuffer *osxbuf;
|
||||
GstCaps *pad_caps;
|
||||
GstStructure *st;
|
||||
gboolean ret = FALSE;
|
||||
GstRingBufferSpec spec = { 0 };
|
||||
gchar *caps_string = NULL;
|
||||
|
||||
osxbuf = GST_OSX_RING_BUFFER (GST_BASE_AUDIO_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_reffed (pad);
|
||||
if (pad_caps) {
|
||||
gboolean cret = gst_caps_can_intersect (pad_caps, caps);
|
||||
gst_caps_unref (pad_caps);
|
||||
if (!cret)
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* If we've not got fixed caps, creating a stream might fail,
|
||||
* so let's just return from here with default acceptcaps
|
||||
* behaviour */
|
||||
if (!gst_caps_is_fixed (caps))
|
||||
goto done;
|
||||
|
||||
/* 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))
|
||||
goto done;
|
||||
|
||||
/* Make sure input is framed and can be payloaded */
|
||||
switch (spec.type) {
|
||||
case GST_BUFTYPE_AC3:
|
||||
{
|
||||
gboolean framed = FALSE;
|
||||
|
||||
if (!osxbuf->is_spdif_capable)
|
||||
goto done;
|
||||
|
||||
st = gst_caps_get_structure (caps, 0);
|
||||
|
||||
gst_structure_get_boolean (st, "framed", &framed);
|
||||
if (!framed || gst_audio_iec61937_frame_size (&spec) <= 0)
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
case GST_BUFTYPE_DTS:
|
||||
{
|
||||
gboolean parsed = FALSE;
|
||||
|
||||
if (!osxbuf->is_spdif_capable)
|
||||
goto done;
|
||||
|
||||
st = gst_caps_get_structure (caps, 0);
|
||||
|
||||
gst_structure_get_boolean (st, "parsed", &parsed);
|
||||
if (!parsed || gst_audio_iec61937_frame_size (&spec) <= 0)
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
gst_object_unref (sink);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GstBuffer *
|
||||
gst_osx_audio_sink_sink_payload (GstBaseAudioSink * sink, GstBuffer * buf)
|
||||
{
|
||||
GstOsxAudioSink *osxsink;
|
||||
|
||||
osxsink = GST_OSX_AUDIO_SINK (sink);
|
||||
|
||||
if (RINGBUFFER_IS_SPDIF (sink->ringbuffer->spec.type)) {
|
||||
gint framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec);
|
||||
GstBuffer *out;
|
||||
|
||||
if (framesize <= 0)
|
||||
return NULL;
|
||||
|
||||
out = gst_buffer_new_and_alloc (framesize);
|
||||
|
||||
if (!gst_audio_iec61937_payload (GST_BUFFER_DATA (buf),
|
||||
GST_BUFFER_SIZE (buf), GST_BUFFER_DATA (out),
|
||||
GST_BUFFER_SIZE (out), &sink->ringbuffer->spec)) {
|
||||
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));
|
||||
return out;
|
||||
} else {
|
||||
return gst_buffer_ref (buf);
|
||||
}
|
||||
}
|
||||
|
||||
static GstRingBuffer *
|
||||
gst_osx_audio_sink_create_ringbuffer (GstBaseAudioSink * sink)
|
||||
{
|
||||
|
@ -264,11 +459,13 @@ gst_osx_audio_sink_create_ringbuffer (GstBaseAudioSink * sink)
|
|||
|
||||
osxsink = GST_OSX_AUDIO_SINK (sink);
|
||||
|
||||
gst_osx_audio_sink_select_device (osxsink);
|
||||
if (!gst_osx_audio_sink_select_device (osxsink)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GST_DEBUG ("Creating ringbuffer");
|
||||
ringbuffer = g_object_new (GST_TYPE_OSX_RING_BUFFER, NULL);
|
||||
GST_DEBUG ("osx sink 0x%p element 0x%p ioproc 0x%p", osxsink,
|
||||
GST_DEBUG ("osx sink %p element %p ioproc %p", osxsink,
|
||||
GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsink),
|
||||
(void *) gst_osx_audio_sink_io_proc);
|
||||
|
||||
|
@ -280,10 +477,10 @@ gst_osx_audio_sink_create_ringbuffer (GstBaseAudioSink * sink)
|
|||
return GST_RING_BUFFER (ringbuffer);
|
||||
}
|
||||
|
||||
/* HALOutput AudioUnit will request fairly arbitrarily-sized chunks of data,
|
||||
* not of a fixed size. So, we keep track of where in the current ringbuffer
|
||||
* segment we are, and only advance the segment once we've read the whole
|
||||
* thing */
|
||||
/* HALOutput AudioUnit will request fairly arbitrarily-sized chunks
|
||||
* of data, not of a fixed size. So, we keep track of where in
|
||||
* 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,
|
||||
AudioUnitRenderActionFlags * ioActionFlags,
|
||||
|
@ -293,7 +490,8 @@ gst_osx_audio_sink_io_proc (GstOsxRingBuffer * buf,
|
|||
guint8 *readptr;
|
||||
gint readseg;
|
||||
gint len;
|
||||
gint remaining = bufferList->mBuffers[0].mDataByteSize;
|
||||
gint stream_idx = buf->stream_idx;
|
||||
gint remaining = bufferList->mBuffers[stream_idx].mDataByteSize;
|
||||
gint offset = 0;
|
||||
|
||||
while (remaining) {
|
||||
|
@ -306,7 +504,7 @@ gst_osx_audio_sink_io_proc (GstOsxRingBuffer * buf,
|
|||
if (len > remaining)
|
||||
len = remaining;
|
||||
|
||||
memcpy ((char *) bufferList->mBuffers[0].mData + offset,
|
||||
memcpy ((char *) bufferList->mBuffers[stream_idx].mData + offset,
|
||||
readptr + buf->segoffset, len);
|
||||
|
||||
buf->segoffset += len;
|
||||
|
@ -344,34 +542,95 @@ gst_osx_audio_sink_set_volume (GstOsxAudioSink * sink)
|
|||
kAudioUnitScope_Global, 0, (float) sink->volume, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
static inline void
|
||||
_dump_channel_layout (AudioChannelLayout * channel_layout)
|
||||
{
|
||||
UInt32 i;
|
||||
|
||||
GST_DEBUG ("mChannelLayoutTag: 0x%lx",
|
||||
(unsigned long) channel_layout->mChannelLayoutTag);
|
||||
GST_DEBUG ("mChannelBitmap: 0x%lx",
|
||||
(unsigned long) channel_layout->mChannelBitmap);
|
||||
GST_DEBUG ("mNumberChannelDescriptions: %lu",
|
||||
(unsigned long) channel_layout->mNumberChannelDescriptions);
|
||||
for (i = 0; i < channel_layout->mNumberChannelDescriptions; i++) {
|
||||
AudioChannelDescription *channel_desc =
|
||||
&channel_layout->mChannelDescriptions[i];
|
||||
GST_DEBUG (" mChannelLabel: 0x%lx mChannelFlags: 0x%lx "
|
||||
"mCoordinates[0]: %f mCoordinates[1]: %f "
|
||||
"mCoordinates[2]: %f",
|
||||
(unsigned long) channel_desc->mChannelLabel,
|
||||
(unsigned long) channel_desc->mChannelFlags,
|
||||
channel_desc->mCoordinates[0], channel_desc->mCoordinates[1],
|
||||
channel_desc->mCoordinates[2]);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_osx_audio_sink_select_device (GstOsxAudioSink * osxsink)
|
||||
{
|
||||
OSStatus status;
|
||||
UInt32 propertySize;
|
||||
AudioDeviceID *devices = NULL;
|
||||
AudioDeviceID default_device_id = 0;
|
||||
AudioChannelLayout *channel_layout;
|
||||
gint i, ndevices = 0;
|
||||
gboolean res = FALSE;
|
||||
|
||||
if (osxsink->device_id == kAudioDeviceUnknown) {
|
||||
/* If no specific device has been selected by the user, then pick the
|
||||
* default device */
|
||||
GST_DEBUG_OBJECT (osxsink, "Selecting device for OSXAudioSink");
|
||||
propertySize = sizeof (osxsink->device_id);
|
||||
status =
|
||||
AudioHardwareGetProperty (kAudioHardwarePropertyDefaultOutputDevice,
|
||||
&propertySize, &osxsink->device_id);
|
||||
devices = _audio_system_get_devices (&ndevices);
|
||||
|
||||
if (status) {
|
||||
GST_WARNING_OBJECT (osxsink,
|
||||
"AudioHardwareGetProperty returned %d", (int) status);
|
||||
if (ndevices < 1) {
|
||||
GST_ERROR_OBJECT (osxsink, "no audio output devices found");
|
||||
goto done;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (osxsink, "found %d audio device(s)", ndevices);
|
||||
|
||||
for (i = 0; i < ndevices; i++) {
|
||||
gchar *device_name;
|
||||
|
||||
if ((device_name = _audio_device_get_name (devices[i]))) {
|
||||
if (!_audio_device_has_output (devices[i])) {
|
||||
GST_DEBUG_OBJECT (osxsink, "Input Device ID: %u Name: %s",
|
||||
(unsigned) devices[i], device_name);
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (osxsink, "AudioHardwareGetProperty returned 0");
|
||||
GST_DEBUG_OBJECT (osxsink, "Output Device ID: %u Name: %s",
|
||||
(unsigned) devices[i], device_name);
|
||||
|
||||
channel_layout = _audio_device_get_channel_layout (devices[i]);
|
||||
if (channel_layout) {
|
||||
_dump_channel_layout (channel_layout);
|
||||
g_free (channel_layout);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (device_name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the ID of the default output device */
|
||||
default_device_id = _audio_system_get_default_output ();
|
||||
|
||||
/* Here we decide if selected device is valid or autoselect
|
||||
* the default one when required */
|
||||
if (osxsink->device_id == kAudioDeviceUnknown) {
|
||||
GST_WARNING_OBJECT (osxsink,
|
||||
"AudioHardwareGetProperty: device_id is kAudioDeviceUnknown");
|
||||
if (default_device_id != kAudioDeviceUnknown) {
|
||||
osxsink->device_id = default_device_id;
|
||||
res = TRUE;
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < ndevices; i++) {
|
||||
if (osxsink->device_id == devices[i]) {
|
||||
res = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (osxsink, "AudioHardwareGetProperty: device_id is %lu",
|
||||
(long) osxsink->device_id);
|
||||
if (res && !_audio_device_is_alive (osxsink->device_id)) {
|
||||
GST_ERROR_OBJECT (osxsink, "Requested device not usable");
|
||||
res = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
g_free (devices);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* GStreamer
|
||||
* Copyright (C) 2005-2006 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
||||
* Copyright (C) 2007 Pioneers of the Inevitable <songbird@songbirdnest.com>
|
||||
* Copyright (C) 2012 Fluendo S.A. <support@fluendo.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -72,6 +73,7 @@ struct _GstOsxAudioSink
|
|||
AudioDeviceID device_id;
|
||||
AudioUnit audiounit;
|
||||
double volume;
|
||||
GstCaps *cached_caps;
|
||||
};
|
||||
|
||||
struct _GstOsxAudioSinkClass
|
||||
|
@ -84,3 +86,4 @@ GType gst_osx_audio_sink_get_type (void);
|
|||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_OSXAUDIOSINK_H__ */
|
||||
|
||||
|
|
576
sys/osxaudio/gstosxcoreaudio.h
Normal file
576
sys/osxaudio/gstosxcoreaudio.h
Normal file
|
@ -0,0 +1,576 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2012 Fluendo S.A. <support@fluendo.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* GNU Lesser General Public License Version 2.1 (the "LGPL"), in
|
||||
* which case the following provisions apply instead of the ones
|
||||
* mentioned above:
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The development of this code was made possible due to the involvement of
|
||||
* Pioneers of the Inevitable, the creators of the Songbird Music player
|
||||
*
|
||||
*/
|
||||
|
||||
#define CORE_AUDIO_FORMAT "FormatID: %" GST_FOURCC_FORMAT " rate: %f flags: 0x%x BytesPerPacket: %u FramesPerPacket: %u BytesPerFrame: %u ChannelsPerFrame: %u BitsPerChannel: %u"
|
||||
#define CORE_AUDIO_FORMAT_ARGS(f) GST_FOURCC_ARGS((f).mFormatID),(f).mSampleRate,(unsigned)(f).mFormatFlags,(unsigned)(f).mBytesPerPacket,(unsigned)(f).mFramesPerPacket,(unsigned)(f).mBytesPerFrame,(unsigned)(f).mChannelsPerFrame,(unsigned)(f).mBitsPerChannel
|
||||
|
||||
#define CORE_AUDIO_FORMAT_IS_SPDIF(f) ((f).mFormat.mFormatID == 'IAC3' || (f).mFormat.mFormatID == 'iac3' || (f).mFormat.mFormatID == kAudioFormat60958AC3 || (f).mFormat.mFormatID == kAudioFormatAC3)
|
||||
|
||||
static inline gboolean
|
||||
_audio_system_set_runloop (CFRunLoopRef runLoop)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
|
||||
gboolean res = FALSE;
|
||||
|
||||
AudioObjectPropertyAddress runloopAddress = {
|
||||
kAudioHardwarePropertyRunLoop,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
status = AudioObjectSetPropertyData (kAudioObjectSystemObject,
|
||||
&runloopAddress, 0, NULL, sizeof (CFRunLoopRef), &runLoop);
|
||||
if (status == noErr) {
|
||||
res = TRUE;
|
||||
} else {
|
||||
GST_ERROR ("failed to set runloop to %p: %" GST_FOURCC_FORMAT,
|
||||
runLoop, GST_FOURCC_ARGS (status));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline AudioDeviceID
|
||||
_audio_system_get_default_output (void)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
UInt32 propertySize = sizeof (AudioDeviceID);
|
||||
AudioDeviceID device_id = kAudioDeviceUnknown;
|
||||
|
||||
AudioObjectPropertyAddress defaultDeviceAddress = {
|
||||
kAudioHardwarePropertyDefaultOutputDevice,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
status = AudioObjectGetPropertyData (kAudioObjectSystemObject,
|
||||
&defaultDeviceAddress, 0, NULL, &propertySize, &device_id);
|
||||
if (status != noErr) {
|
||||
GST_ERROR ("failed getting default output device: %"
|
||||
GST_FOURCC_FORMAT, GST_FOURCC_ARGS (status));
|
||||
}
|
||||
|
||||
return device_id;
|
||||
}
|
||||
|
||||
static inline AudioDeviceID *
|
||||
_audio_system_get_devices (gint * ndevices)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
UInt32 propertySize = 0;
|
||||
AudioDeviceID *devices = NULL;
|
||||
|
||||
AudioObjectPropertyAddress audioDevicesAddress = {
|
||||
kAudioHardwarePropertyDevices,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
status = AudioObjectGetPropertyDataSize (kAudioObjectSystemObject,
|
||||
&audioDevicesAddress, 0, NULL, &propertySize);
|
||||
if (status != noErr) {
|
||||
GST_WARNING ("failed getting number of devices: %"
|
||||
GST_FOURCC_FORMAT, GST_FOURCC_ARGS (status));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*ndevices = propertySize / sizeof (AudioDeviceID);
|
||||
|
||||
devices = (AudioDeviceID *) g_malloc (propertySize);
|
||||
if (devices) {
|
||||
status = AudioObjectGetPropertyData (kAudioObjectSystemObject,
|
||||
&audioDevicesAddress, 0, NULL, &propertySize, devices);
|
||||
if (status != noErr) {
|
||||
GST_WARNING ("failed getting the list of devices: %"
|
||||
GST_FOURCC_FORMAT, GST_FOURCC_ARGS (status));
|
||||
g_free (devices);
|
||||
*ndevices = 0;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return devices;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_audio_device_is_alive (AudioDeviceID device_id)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
int alive = FALSE;
|
||||
UInt32 propertySize = sizeof (alive);
|
||||
|
||||
AudioObjectPropertyAddress audioDeviceAliveAddress = {
|
||||
kAudioDevicePropertyDeviceIsAlive,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
status = AudioObjectGetPropertyData (device_id,
|
||||
&audioDeviceAliveAddress, 0, NULL, &propertySize, &alive);
|
||||
if (status != noErr) {
|
||||
alive = FALSE;
|
||||
}
|
||||
|
||||
return alive;
|
||||
}
|
||||
|
||||
static inline guint
|
||||
_audio_device_get_latency (AudioDeviceID device_id)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
UInt32 latency = 0;
|
||||
UInt32 propertySize = sizeof (latency);
|
||||
|
||||
AudioObjectPropertyAddress audioDeviceLatencyAddress = {
|
||||
kAudioDevicePropertyLatency,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
status = AudioObjectGetPropertyData (device_id,
|
||||
&audioDeviceLatencyAddress, 0, NULL, &propertySize, &latency);
|
||||
if (status != noErr) {
|
||||
GST_ERROR ("failed to get latency: %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (status));
|
||||
latency = -1;
|
||||
}
|
||||
|
||||
return latency;
|
||||
}
|
||||
|
||||
static inline pid_t
|
||||
_audio_device_get_hog (AudioDeviceID device_id)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
pid_t hog_pid;
|
||||
UInt32 propertySize = sizeof (hog_pid);
|
||||
|
||||
AudioObjectPropertyAddress audioDeviceHogModeAddress = {
|
||||
kAudioDevicePropertyHogMode,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
status = AudioObjectGetPropertyData (device_id,
|
||||
&audioDeviceHogModeAddress, 0, NULL, &propertySize, &hog_pid);
|
||||
if (status != noErr) {
|
||||
GST_ERROR ("failed to get hog: %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (status));
|
||||
hog_pid = -1;
|
||||
}
|
||||
|
||||
return hog_pid;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_audio_device_set_hog (AudioDeviceID device_id, pid_t hog_pid)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
UInt32 propertySize = sizeof (hog_pid);
|
||||
gboolean res = FALSE;
|
||||
|
||||
AudioObjectPropertyAddress audioDeviceHogModeAddress = {
|
||||
kAudioDevicePropertyHogMode,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
status = AudioObjectSetPropertyData (device_id,
|
||||
&audioDeviceHogModeAddress, 0, NULL, propertySize, &hog_pid);
|
||||
|
||||
if (status == noErr) {
|
||||
res = TRUE;
|
||||
} else {
|
||||
GST_ERROR ("failed to set hog: %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (status));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_audio_device_set_mixing (AudioDeviceID device_id, gboolean enable_mix)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
UInt32 propertySize = 0, can_mix = enable_mix;
|
||||
Boolean writable = FALSE;
|
||||
gboolean res = FALSE;
|
||||
|
||||
AudioObjectPropertyAddress audioDeviceSupportsMixingAddress = {
|
||||
kAudioDevicePropertySupportsMixing,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
if (AudioObjectHasProperty (device_id, &audioDeviceSupportsMixingAddress)) {
|
||||
/* Set mixable to false if we are allowed to */
|
||||
status = AudioObjectIsPropertySettable (device_id,
|
||||
&audioDeviceSupportsMixingAddress, &writable);
|
||||
if (status) {
|
||||
GST_DEBUG ("AudioObjectIsPropertySettable: %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (status));
|
||||
}
|
||||
status = AudioObjectGetPropertyDataSize (device_id,
|
||||
&audioDeviceSupportsMixingAddress, 0, NULL, &propertySize);
|
||||
if (status) {
|
||||
GST_DEBUG ("AudioObjectGetPropertyDataSize: %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (status));
|
||||
}
|
||||
status = AudioObjectGetPropertyData (device_id,
|
||||
&audioDeviceSupportsMixingAddress, 0, NULL, &propertySize, &can_mix);
|
||||
if (status) {
|
||||
GST_DEBUG ("AudioObjectGetPropertyData: %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (status));
|
||||
}
|
||||
|
||||
if (status == noErr && writable) {
|
||||
can_mix = enable_mix;
|
||||
status = AudioObjectSetPropertyData (device_id,
|
||||
&audioDeviceSupportsMixingAddress, 0, NULL, propertySize, &can_mix);
|
||||
res = TRUE;
|
||||
}
|
||||
|
||||
if (status != noErr) {
|
||||
GST_ERROR ("failed to set mixmode: %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (status));
|
||||
}
|
||||
} else {
|
||||
GST_DEBUG ("property not found, mixing coudln't be changed");
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline gchar *
|
||||
_audio_device_get_name (AudioDeviceID device_id)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
UInt32 propertySize = 0;
|
||||
gchar *device_name = NULL;
|
||||
|
||||
AudioObjectPropertyAddress deviceNameAddress = {
|
||||
kAudioDevicePropertyDeviceName,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
/* Get the length of the device name */
|
||||
status = AudioObjectGetPropertyDataSize (device_id,
|
||||
&deviceNameAddress, 0, NULL, &propertySize);
|
||||
if (status != noErr) {
|
||||
goto beach;
|
||||
}
|
||||
|
||||
/* Get the name of the device */
|
||||
device_name = (gchar *) g_malloc (propertySize);
|
||||
status = AudioObjectGetPropertyData (device_id,
|
||||
&deviceNameAddress, 0, NULL, &propertySize, device_name);
|
||||
if (status != noErr) {
|
||||
g_free (device_name);
|
||||
device_name = NULL;
|
||||
}
|
||||
|
||||
beach:
|
||||
return device_name;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_audio_device_has_output (AudioDeviceID device_id)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
UInt32 propertySize;
|
||||
|
||||
AudioObjectPropertyAddress streamsAddress = {
|
||||
kAudioDevicePropertyStreams,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
status = AudioObjectGetPropertyDataSize (device_id,
|
||||
&streamsAddress, 0, NULL, &propertySize);
|
||||
if (status != noErr) {
|
||||
return FALSE;
|
||||
}
|
||||
if (propertySize == 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline AudioChannelLayout *
|
||||
_audio_device_get_channel_layout (AudioDeviceID device_id)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
UInt32 propertySize = 0;
|
||||
AudioChannelLayout *channel_layout = NULL;
|
||||
|
||||
AudioObjectPropertyAddress channelLayoutAddress = {
|
||||
kAudioDevicePropertyPreferredChannelLayout,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
/* Get the length of the default channel layout structure */
|
||||
status = AudioObjectGetPropertyDataSize (device_id,
|
||||
&channelLayoutAddress, 0, NULL, &propertySize);
|
||||
if (status != noErr) {
|
||||
goto beach;
|
||||
}
|
||||
|
||||
/* Get the default channel layout of the device */
|
||||
channel_layout = (AudioChannelLayout *) g_malloc (propertySize);
|
||||
status = AudioObjectGetPropertyData (device_id,
|
||||
&channelLayoutAddress, 0, NULL, &propertySize, channel_layout);
|
||||
if (status != noErr) {
|
||||
g_free (channel_layout);
|
||||
channel_layout = NULL;
|
||||
}
|
||||
|
||||
beach:
|
||||
return channel_layout;
|
||||
}
|
||||
|
||||
static inline AudioStreamID *
|
||||
_audio_device_get_streams (AudioDeviceID device_id, gint * nstreams)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
UInt32 propertySize = 0;
|
||||
AudioStreamID *streams = NULL;
|
||||
|
||||
AudioObjectPropertyAddress streamsAddress = {
|
||||
kAudioDevicePropertyStreams,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
status = AudioObjectGetPropertyDataSize (device_id,
|
||||
&streamsAddress, 0, NULL, &propertySize);
|
||||
if (status != noErr) {
|
||||
GST_WARNING ("failed getting number of streams: %"
|
||||
GST_FOURCC_FORMAT, GST_FOURCC_ARGS (status));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*nstreams = propertySize / sizeof (AudioStreamID);
|
||||
streams = (AudioStreamID *) g_malloc (propertySize);
|
||||
|
||||
if (streams) {
|
||||
status = AudioObjectGetPropertyData (device_id,
|
||||
&streamsAddress, 0, NULL, &propertySize, streams);
|
||||
if (status != noErr) {
|
||||
GST_WARNING ("failed getting the list of streams: %"
|
||||
GST_FOURCC_FORMAT, GST_FOURCC_ARGS (status));
|
||||
g_free (streams);
|
||||
*nstreams = 0;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return streams;
|
||||
}
|
||||
|
||||
static inline guint
|
||||
_audio_stream_get_latency (AudioStreamID stream_id)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
UInt32 latency;
|
||||
UInt32 propertySize = sizeof (latency);
|
||||
|
||||
AudioObjectPropertyAddress latencyAddress = {
|
||||
kAudioStreamPropertyLatency,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
status = AudioObjectGetPropertyData (stream_id,
|
||||
&latencyAddress, 0, NULL, &propertySize, &latency);
|
||||
if (status != noErr) {
|
||||
GST_ERROR ("failed to get latency: %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (status));
|
||||
latency = -1;
|
||||
}
|
||||
|
||||
return latency;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_audio_stream_get_current_format (AudioStreamID stream_id,
|
||||
AudioStreamBasicDescription * format)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
UInt32 propertySize = sizeof (AudioStreamBasicDescription);
|
||||
|
||||
AudioObjectPropertyAddress formatAddress = {
|
||||
kAudioStreamPropertyPhysicalFormat,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
status = AudioObjectGetPropertyData (stream_id,
|
||||
&formatAddress, 0, NULL, &propertySize, format);
|
||||
if (status != noErr) {
|
||||
GST_ERROR ("failed to get current format: %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (status));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_audio_stream_set_current_format (AudioStreamID stream_id,
|
||||
AudioStreamBasicDescription format)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
UInt32 propertySize = sizeof (AudioStreamBasicDescription);
|
||||
|
||||
AudioObjectPropertyAddress formatAddress = {
|
||||
kAudioStreamPropertyPhysicalFormat,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
status = AudioObjectSetPropertyData (stream_id,
|
||||
&formatAddress, 0, NULL, propertySize, &format);
|
||||
if (status != noErr) {
|
||||
GST_ERROR ("failed to set current format: %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (status));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline AudioStreamRangedDescription *
|
||||
_audio_stream_get_formats (AudioStreamID stream_id, gint * nformats)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
UInt32 propertySize = 0;
|
||||
AudioStreamRangedDescription *formats = NULL;
|
||||
|
||||
AudioObjectPropertyAddress formatsAddress = {
|
||||
kAudioStreamPropertyAvailablePhysicalFormats,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
status = AudioObjectGetPropertyDataSize (stream_id,
|
||||
&formatsAddress, 0, NULL, &propertySize);
|
||||
if (status != noErr) {
|
||||
GST_WARNING ("failed getting number of stream formats: %"
|
||||
GST_FOURCC_FORMAT, GST_FOURCC_ARGS (status));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*nformats = propertySize / sizeof (AudioStreamRangedDescription);
|
||||
|
||||
formats = (AudioStreamRangedDescription *) g_malloc (propertySize);
|
||||
if (formats) {
|
||||
status = AudioObjectGetPropertyData (stream_id,
|
||||
&formatsAddress, 0, NULL, &propertySize, formats);
|
||||
if (status != noErr) {
|
||||
GST_WARNING ("failed getting the list of stream formats: %"
|
||||
GST_FOURCC_FORMAT, GST_FOURCC_ARGS (status));
|
||||
g_free (formats);
|
||||
*nformats = 0;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return formats;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_audio_stream_is_spdif_avail (AudioStreamID stream_id)
|
||||
{
|
||||
AudioStreamRangedDescription *formats;
|
||||
gint i, nformats = 0;
|
||||
gboolean res = FALSE;
|
||||
|
||||
formats = _audio_stream_get_formats (stream_id, &nformats);
|
||||
GST_DEBUG ("found %d stream formats", nformats);
|
||||
|
||||
if (formats) {
|
||||
GST_DEBUG ("formats supported on stream ID: %u",
|
||||
(unsigned) stream_id);
|
||||
|
||||
for (i = 0; i < nformats; i++) {
|
||||
GST_DEBUG (" " CORE_AUDIO_FORMAT,
|
||||
CORE_AUDIO_FORMAT_ARGS (formats[i].mFormat));
|
||||
|
||||
if (CORE_AUDIO_FORMAT_IS_SPDIF (formats[i])) {
|
||||
res = TRUE;
|
||||
}
|
||||
}
|
||||
g_free (formats);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_audio_device_is_spdif_avail (AudioDeviceID device_id)
|
||||
{
|
||||
AudioStreamID *streams = NULL;
|
||||
gint i, nstreams = 0;
|
||||
gboolean res = FALSE;
|
||||
|
||||
streams = _audio_device_get_streams (device_id, &nstreams);
|
||||
GST_DEBUG ("found %d streams", nstreams);
|
||||
if (streams) {
|
||||
for (i = 0; i < nstreams; i++) {
|
||||
if (_audio_stream_is_spdif_avail (streams[i])) {
|
||||
res = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
g_free (streams);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2006 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
||||
* Copyright (C) 2012 Fluendo S.A. <support@fluendo.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -64,6 +65,8 @@ G_BEGIN_DECLS
|
|||
#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;
|
||||
|
||||
|
@ -71,15 +74,31 @@ struct _GstOsxRingBuffer
|
|||
{
|
||||
GstRingBuffer object;
|
||||
|
||||
gboolean is_spdif_capable;
|
||||
gboolean is_src;
|
||||
AudioUnit audiounit;
|
||||
gboolean is_passthrough;
|
||||
gint stream_idx;
|
||||
|
||||
AudioDeviceID device_id;
|
||||
gboolean io_proc_active;
|
||||
gboolean io_proc_needs_deactivation;
|
||||
guint buffer_len;
|
||||
guint segoffset;
|
||||
AudioBufferList * recBufferList;
|
||||
|
||||
GstOsxAudioElementInterface *element;
|
||||
|
||||
/* For LPCM in/out */
|
||||
AudioUnit audiounit;
|
||||
AudioBufferList *recBufferList;
|
||||
|
||||
/* For SPDIF out */
|
||||
pid_t hog_pid;
|
||||
gboolean disabled_mixing;
|
||||
AudioStreamID stream_id;
|
||||
gboolean revert_format;
|
||||
AudioStreamBasicDescription stream_format;
|
||||
AudioStreamBasicDescription original_format;
|
||||
AudioDeviceIOProcID procID;
|
||||
};
|
||||
|
||||
struct _GstOsxRingBufferClass
|
||||
|
@ -92,3 +111,4 @@ GType gst_osx_ring_buffer_get_type (void);
|
|||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_OSX_RING_BUFFER_H__ */
|
||||
|
||||
|
|
Loading…
Reference in a new issue