79 CFStringRef device_UID =
NULL;
80 AudioDeviceID *devices;
86 AudioObjectPropertyAddress prop;
87 prop.mSelector = kAudioHardwarePropertyDevices;
88 prop.mScope = kAudioObjectPropertyScopeGlobal;
89#if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000
90 prop.mElement = kAudioObjectPropertyElementMain;
92 prop.mElement = kAudioObjectPropertyElementMaster;
94 err = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0,
NULL, &data_size);
95 if (
check_status(avctx, &err,
"AudioObjectGetPropertyDataSize devices"))
98 num_devices = data_size /
sizeof(AudioDeviceID);
100 devices = (AudioDeviceID*)(
av_malloc(data_size));
101 err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &prop, 0,
NULL, &data_size, devices);
102 if (
check_status(avctx, &err,
"AudioObjectGetPropertyData devices")) {
108 if (
ctx->list_devices) {
109 CFStringRef device_name =
NULL;
110 prop.mScope = kAudioDevicePropertyScopeInput;
113 for(UInt32
i = 0;
i < num_devices; ++
i) {
115 data_size =
sizeof(device_UID);
116 prop.mSelector = kAudioDevicePropertyDeviceUID;
117 err = AudioObjectGetPropertyData(devices[
i], &prop, 0,
NULL, &data_size, &device_UID);
118 if (
check_status(avctx, &err,
"AudioObjectGetPropertyData UID"))
122 data_size =
sizeof(device_name);
123 prop.mSelector = kAudioDevicePropertyDeviceNameCFString;
124 err = AudioObjectGetPropertyData(devices[
i], &prop, 0,
NULL, &data_size, &device_name);
125 if (
check_status(avctx, &err,
"AudioObjecTGetPropertyData name"))
129 CFStringGetCStringPtr(device_name, kCFStringEncodingMacRoman),
130 CFStringGetCStringPtr(device_UID, kCFStringEncodingMacRoman));
136 const char *stream_name = avctx->
url;
137 if (stream_name &&
ctx->audio_device_index == -1) {
138 sscanf(stream_name,
"%d", &
ctx->audio_device_index);
141 if (
ctx->audio_device_index >= 0) {
143 data_size =
sizeof(device_UID);
144 prop.mSelector = kAudioDevicePropertyDeviceUID;
145 err = AudioObjectGetPropertyData(devices[
ctx->audio_device_index], &prop, 0,
NULL, &data_size, &device_UID);
146 if (
check_status(avctx, &err,
"AudioObjecTGetPropertyData UID")) {
157 av_log(
ctx,
AV_LOG_DEBUG,
"UID: %s\n", CFStringGetCStringPtr(device_UID, kCFStringEncodingMacRoman));
169 AudioStreamBasicDescription device_format = {0};
171 device_format.mFormatID = kAudioFormatLinearPCM;
184 device_format.mBytesPerFrame = (device_format.mBitsPerChannel >> 3) * device_format.mChannelsPerFrame;
185 device_format.mFramesPerPacket = 1;
186 device_format.mBytesPerPacket = device_format.mBytesPerFrame * device_format.mFramesPerPacket;
187 device_format.mReserved = 0;
211 NULL, kCFRunLoopCommonModes,
214 if (err == kAudioFormatUnsupportedDataFormatError)
220 if (device_UID !=
NULL) {
221 err = AudioQueueSetProperty(
ctx->queue, kAudioQueueProperty_CurrentDevice, &device_UID,
sizeof(device_UID));
222 if (
check_status(avctx, &err,
"AudioQueueSetProperty output UID"))
227 err = AudioQueueStart(
ctx->queue,
NULL);
pthread_mutex_t buffer_lock[2]
AudioQueueBufferRef buffer[2]