osxaudio: Move device selection to ringbuffer->open_device()
This is conceptually the right thing to do, and allows us to correctly catch errors in device selection as well, which we could not do while creating the ringbuffer. https://bugzilla.gnome.org/show_bug.cgi?id=740987
This commit is contained in:
parent
199461bb2e
commit
b06ae28061
@ -148,9 +148,11 @@ gst_osx_audio_ring_buffer_finalize (GObject * object)
|
|||||||
static gboolean
|
static gboolean
|
||||||
gst_osx_audio_ring_buffer_open_device (GstAudioRingBuffer * buf)
|
gst_osx_audio_ring_buffer_open_device (GstAudioRingBuffer * buf)
|
||||||
{
|
{
|
||||||
GstOsxAudioRingBuffer *osxbuf;
|
GstOsxAudioRingBuffer *osxbuf = GST_OSX_AUDIO_RING_BUFFER (buf);;
|
||||||
|
GstElement *parent = GST_ELEMENT_CAST (GST_OBJECT_PARENT (buf));
|
||||||
|
|
||||||
osxbuf = GST_OSX_AUDIO_RING_BUFFER (buf);
|
if (!osxbuf->select_device (parent, osxbuf))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
return gst_core_audio_open (osxbuf->core_audio);
|
return gst_core_audio_open (osxbuf->core_audio);
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,9 @@ struct _GstOsxAudioRingBuffer
|
|||||||
|
|
||||||
GstCoreAudio *core_audio;
|
GstCoreAudio *core_audio;
|
||||||
|
|
||||||
|
/* Set by the parent to select the required device */
|
||||||
|
gboolean (*select_device) (GstElement * element, GstOsxAudioRingBuffer * buf);
|
||||||
|
|
||||||
guint buffer_len;
|
guint buffer_len;
|
||||||
guint segoffset;
|
guint segoffset;
|
||||||
};
|
};
|
||||||
|
@ -130,7 +130,8 @@ static GstAudioRingBuffer
|
|||||||
* gst_osx_audio_sink_create_ringbuffer (GstAudioBaseSink * sink);
|
* gst_osx_audio_sink_create_ringbuffer (GstAudioBaseSink * sink);
|
||||||
static void gst_osx_audio_sink_osxelement_init (gpointer g_iface,
|
static void gst_osx_audio_sink_osxelement_init (gpointer g_iface,
|
||||||
gpointer iface_data);
|
gpointer iface_data);
|
||||||
static gboolean gst_osx_audio_sink_select_device (GstOsxAudioSink * osxsink);
|
static gboolean gst_osx_audio_sink_select_device (GstElement * sink,
|
||||||
|
GstOsxAudioRingBuffer * ringbuffer);
|
||||||
static void gst_osx_audio_sink_set_volume (GstOsxAudioSink * sink);
|
static void gst_osx_audio_sink_set_volume (GstOsxAudioSink * sink);
|
||||||
|
|
||||||
static OSStatus gst_osx_audio_sink_io_proc (GstOsxAudioRingBuffer * buf,
|
static OSStatus gst_osx_audio_sink_io_proc (GstOsxAudioRingBuffer * buf,
|
||||||
@ -434,24 +435,21 @@ gst_osx_audio_sink_create_ringbuffer (GstAudioBaseSink * sink)
|
|||||||
|
|
||||||
osxsink = GST_OSX_AUDIO_SINK (sink);
|
osxsink = GST_OSX_AUDIO_SINK (sink);
|
||||||
|
|
||||||
if (!gst_osx_audio_sink_select_device (osxsink)) {
|
|
||||||
GST_ERROR_OBJECT (sink, "Could not select device");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (sink, "Creating ringbuffer");
|
GST_DEBUG_OBJECT (sink, "Creating ringbuffer");
|
||||||
ringbuffer = g_object_new (GST_TYPE_OSX_AUDIO_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_DEBUG_OBJECT (sink, "osx sink %p element %p ioproc %p", osxsink,
|
||||||
GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsink),
|
GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsink),
|
||||||
(void *) gst_osx_audio_sink_io_proc);
|
(void *) gst_osx_audio_sink_io_proc);
|
||||||
|
|
||||||
gst_osx_audio_sink_set_volume (osxsink);
|
ringbuffer->select_device =
|
||||||
|
GST_DEBUG_FUNCPTR (gst_osx_audio_sink_select_device);
|
||||||
|
|
||||||
ringbuffer->core_audio->element =
|
ringbuffer->core_audio->element =
|
||||||
GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsink);
|
GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsink);
|
||||||
ringbuffer->core_audio->device_id = osxsink->device_id;
|
|
||||||
ringbuffer->core_audio->is_src = FALSE;
|
ringbuffer->core_audio->is_src = FALSE;
|
||||||
|
|
||||||
|
gst_osx_audio_sink_set_volume (osxsink);
|
||||||
|
|
||||||
return GST_AUDIO_RING_BUFFER (ringbuffer);
|
return GST_AUDIO_RING_BUFFER (ringbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,13 +643,18 @@ gst_osx_audio_sink_allowed_caps (GstOsxAudioSink * osxsink)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_osx_audio_sink_select_device (GstOsxAudioSink * osxsink)
|
gst_osx_audio_sink_select_device (GstElement * sink,
|
||||||
|
GstOsxAudioRingBuffer * ringbuffer)
|
||||||
{
|
{
|
||||||
|
GstOsxAudioSink *osxsink = GST_OSX_AUDIO_SINK (sink);
|
||||||
gboolean res = FALSE;
|
gboolean res = FALSE;
|
||||||
|
|
||||||
if (!gst_core_audio_select_device (&osxsink->device_id, TRUE))
|
if (!gst_core_audio_select_device (&osxsink->device_id, TRUE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
res = gst_osx_audio_sink_allowed_caps (osxsink);
|
res = gst_osx_audio_sink_allowed_caps (osxsink);
|
||||||
|
|
||||||
|
ringbuffer->core_audio->device_id = osxsink->device_id;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,8 @@ static OSStatus gst_osx_audio_src_io_proc (GstOsxAudioRingBuffer * buf,
|
|||||||
AudioUnitRenderActionFlags * ioActionFlags,
|
AudioUnitRenderActionFlags * ioActionFlags,
|
||||||
const AudioTimeStamp * inTimeStamp, UInt32 inBusNumber,
|
const AudioTimeStamp * inTimeStamp, UInt32 inBusNumber,
|
||||||
UInt32 inNumberFrames, AudioBufferList * bufferList);
|
UInt32 inNumberFrames, AudioBufferList * bufferList);
|
||||||
static gboolean gst_osx_audio_src_select_device (GstOsxAudioSrc * osxsrc);
|
static gboolean gst_osx_audio_src_select_device (GstElement * src,
|
||||||
|
GstOsxAudioRingBuffer * ringbuffer);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_osx_audio_src_do_init (GType type)
|
gst_osx_audio_src_do_init (GType type)
|
||||||
@ -251,21 +252,18 @@ gst_osx_audio_src_create_ringbuffer (GstAudioBaseSrc * src)
|
|||||||
|
|
||||||
osxsrc = GST_OSX_AUDIO_SRC (src);
|
osxsrc = GST_OSX_AUDIO_SRC (src);
|
||||||
|
|
||||||
if (!gst_osx_audio_src_select_device (osxsrc)) {
|
|
||||||
GST_ERROR_OBJECT (src, "Could not select device");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (osxsrc, "Creating ringbuffer");
|
GST_DEBUG_OBJECT (osxsrc, "Creating ringbuffer");
|
||||||
ringbuffer = g_object_new (GST_TYPE_OSX_AUDIO_RING_BUFFER, NULL);
|
ringbuffer = g_object_new (GST_TYPE_OSX_AUDIO_RING_BUFFER, NULL);
|
||||||
GST_DEBUG_OBJECT (osxsrc, "osx src 0x%p element 0x%p ioproc 0x%p", osxsrc,
|
GST_DEBUG_OBJECT (osxsrc, "osx src 0x%p element 0x%p ioproc 0x%p", osxsrc,
|
||||||
GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsrc),
|
GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsrc),
|
||||||
(void *) gst_osx_audio_src_io_proc);
|
(void *) gst_osx_audio_src_io_proc);
|
||||||
|
|
||||||
|
ringbuffer->select_device =
|
||||||
|
GST_DEBUG_FUNCPTR (gst_osx_audio_src_select_device);
|
||||||
|
|
||||||
ringbuffer->core_audio->element =
|
ringbuffer->core_audio->element =
|
||||||
GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsrc);
|
GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsrc);
|
||||||
ringbuffer->core_audio->is_src = TRUE;
|
ringbuffer->core_audio->is_src = TRUE;
|
||||||
ringbuffer->core_audio->device_id = osxsrc->device_id;
|
|
||||||
|
|
||||||
return GST_AUDIO_RING_BUFFER (ringbuffer);
|
return GST_AUDIO_RING_BUFFER (ringbuffer);
|
||||||
}
|
}
|
||||||
@ -332,5 +330,12 @@ gst_osx_audio_src_osxelement_init (gpointer g_iface, gpointer iface_data)
|
|||||||
static gboolean
|
static gboolean
|
||||||
gst_osx_audio_src_select_device (GstOsxAudioSrc * osxsrc)
|
gst_osx_audio_src_select_device (GstOsxAudioSrc * osxsrc)
|
||||||
{
|
{
|
||||||
return gst_core_audio_select_device (&osxsrc->device_id, FALSE);
|
GstOsxAudioSrc *osxsrc = GST_OSX_AUDIO_SRC (element);
|
||||||
|
|
||||||
|
if (!gst_core_audio_select_device (&osxsrc->device_id, FALSE))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
ringbuffer->core_audio->device_id = osxsrc->device_id;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user