28 #import <AudioToolbox/AudioToolbox.h> 
   63                            AudioQueueBufferRef inBuffer)
 
   67     for (
int i = 0; 
i < 2; 
i++) {
 
   68         if (inBuffer == 
ctx->buffer[
i]) {
 
   78     CFStringRef device_UID = 
NULL;
 
   79     AudioDeviceID *devices;
 
   85     AudioObjectPropertyAddress prop;
 
   86     prop.mSelector = kAudioHardwarePropertyDevices;
 
   87     prop.mScope    = kAudioObjectPropertyScopeGlobal;
 
   88     prop.mElement  = kAudioObjectPropertyElementMaster;
 
   89     err = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0, 
NULL, &data_size);
 
   90     if (
check_status(avctx, &err, 
"AudioObjectGetPropertyDataSize devices"))
 
   93     num_devices = data_size / 
sizeof(AudioDeviceID);
 
   95     devices = (AudioDeviceID*)(
av_malloc(data_size));
 
   96     err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &prop, 0, 
NULL, &data_size, devices);
 
   97     if (
check_status(avctx, &err, 
"AudioObjectGetPropertyData devices")) {
 
  103     if (
ctx->list_devices) {
 
  104         CFStringRef device_name = 
NULL;
 
  105         prop.mScope = kAudioDevicePropertyScopeInput;
 
  108         for(UInt32 
i = 0; 
i < num_devices; ++
i) {
 
  110             data_size = 
sizeof(device_UID);
 
  111             prop.mSelector = kAudioDevicePropertyDeviceUID;
 
  112             err = AudioObjectGetPropertyData(devices[
i], &prop, 0, 
NULL, &data_size, &device_UID);
 
  113             if (
check_status(avctx, &err, 
"AudioObjectGetPropertyData UID"))
 
  117             data_size = 
sizeof(device_name);
 
  118             prop.mSelector = kAudioDevicePropertyDeviceNameCFString;
 
  119             err = AudioObjectGetPropertyData(devices[
i], &prop, 0, 
NULL, &data_size, &device_name);
 
  120             if (
check_status(avctx, &err, 
"AudioObjecTGetPropertyData name"))
 
  124                    CFStringGetCStringPtr(device_name, kCFStringEncodingMacRoman),
 
  125                    CFStringGetCStringPtr(device_UID, kCFStringEncodingMacRoman));
 
  131     const char *stream_name = avctx->
url;
 
  132     if (stream_name && 
ctx->audio_device_index == -1) {
 
  133         sscanf(stream_name, 
"%d", &
ctx->audio_device_index);
 
  136     if (
ctx->audio_device_index >= 0) {
 
  138         data_size = 
sizeof(device_UID);
 
  139         prop.mSelector = kAudioDevicePropertyDeviceUID;
 
  140         err = AudioObjectGetPropertyData(devices[
ctx->audio_device_index], &prop, 0, 
NULL, &data_size, &device_UID);
 
  141         if (
check_status(avctx, &err, 
"AudioObjecTGetPropertyData UID")) {
 
  152     av_log(
ctx, 
AV_LOG_DEBUG, 
"UID:                %s\n", CFStringGetCStringPtr(device_UID, kCFStringEncodingMacRoman));
 
  164     AudioStreamBasicDescription device_format = {0};
 
  166     device_format.mFormatID          = kAudioFormatLinearPCM;
 
  179     device_format.mBytesPerFrame     = (device_format.mBitsPerChannel >> 3) * device_format.mChannelsPerFrame;
 
  180     device_format.mFramesPerPacket   = 1;
 
  181     device_format.mBytesPerPacket    = device_format.mBytesPerFrame * device_format.mFramesPerPacket;
 
  182     device_format.mReserved          = 0;
 
  206                               NULL, kCFRunLoopCommonModes,
 
  209         if (err == kAudioFormatUnsupportedDataFormatError)
 
  215     if (device_UID != 
NULL) {
 
  216         err = AudioQueueSetProperty(
ctx->queue, kAudioQueueProperty_CurrentDevice, &device_UID, 
sizeof(device_UID));
 
  217         if (
check_status(avctx, &err, 
"AudioQueueSetProperty output UID"))
 
  222     err = AudioQueueStart(
ctx->queue, 
NULL);
 
  236     OSStatus err = noErr;
 
  239     ctx->cur_buf = !
ctx->cur_buf;
 
  246     if (!
ctx->buffer[
ctx->cur_buf] || 
ctx->buffer[
ctx->cur_buf]->mAudioDataBytesCapacity != 
pkt->
size) {
 
  247         err = AudioQueueAllocateBuffer(
ctx->queue, 
pkt->
size, &
ctx->buffer[
ctx->cur_buf]);
 
  248         if (
check_status(avctx, &err, 
"AudioQueueAllocateBuffer")) {
 
  254     AudioQueueBufferRef buf = 
ctx->buffer[ctx->
cur_buf];
 
  257     memcpy(buf->mAudioData, 
pkt->
data, buf->mAudioDataBytesCapacity);
 
  258     buf->mAudioDataByteSize = buf->mAudioDataBytesCapacity;
 
  259     err = AudioQueueEnqueueBuffer(
ctx->queue, buf, 0, 
NULL);
 
  260     if (
check_status(avctx, &err, 
"AudioQueueEnqueueBuffer")) {
 
  271     OSStatus err = noErr;
 
  276     err = AudioQueueFlush(
ctx->queue);
 
  278     err = AudioQueueDispose(
ctx->queue, 
true);
 
  299     .
p.
name         = 
"audiotoolbox",