gboolean gst_core_audio_open (GstCoreAudio * core_audio) { if (!gst_core_audio_open_impl (core_audio)) return FALSE; if (core_audio->is_src) { AudioStreamBasicDescription asbd_in; UInt32 propertySize; OSStatus status; GstOsxAudioSrc *src = GST_OSX_AUDIO_SRC (GST_OBJECT_PARENT (core_audio->osxbuf)); propertySize = sizeof (asbd_in); status = AudioUnitGetProperty (core_audio->audiounit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 1, &asbd_in, &propertySize); if (status) { AudioComponentInstanceDispose (core_audio->audiounit); core_audio->audiounit = NULL; GST_WARNING_OBJECT (core_audio, "Unable to obtain device properties: %d", (int) status); return FALSE; } else { src->deviceChannels = asbd_in.mChannelsPerFrame; } } return TRUE; }
static void gst_osx_audio_src_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { GstOsxAudioSrc *src = GST_OSX_AUDIO_SRC (object); switch (prop_id) { case ARG_DEVICE: g_value_set_int (value, src->device_id); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static GstRingBuffer * gst_osx_audio_src_create_ringbuffer (GstBaseAudioSrc * src) { GstOsxAudioSrc *osxsrc; GstOsxRingBuffer *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); 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); ringbuffer->element = GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsrc); ringbuffer->is_src = TRUE; ringbuffer->device_id = osxsrc->device_id; return GST_RING_BUFFER (ringbuffer); }
static GstCaps * gst_osx_audio_src_get_caps (GstBaseSrc * src) { GstElementClass *gstelement_class; GstOsxAudioSrc *osxsrc; GstPadTemplate *pad_template; GstCaps *caps; gint min, max; gstelement_class = GST_ELEMENT_GET_CLASS (src); osxsrc = GST_OSX_AUDIO_SRC (src); if (osxsrc->deviceChannels == -1) { /* -1 means we don't know the number of channels yet. for now, return * template caps. */ return NULL; } max = osxsrc->deviceChannels; if (max < 1) max = 1; /* 0 channels means 1 channel? */ min = MIN (1, max); pad_template = gst_element_class_get_pad_template (gstelement_class, "src"); g_return_val_if_fail (pad_template != NULL, NULL); caps = gst_caps_copy (gst_pad_template_get_caps (pad_template)); if (min == max) { gst_caps_set_simple (caps, "channels", G_TYPE_INT, max, NULL); } else { gst_caps_set_simple (caps, "channels", GST_TYPE_INT_RANGE, min, max, NULL); } return caps; }