FFmpeg
audiotoolbox.m
Go to the documentation of this file.
1 /*
2  * AudioToolbox output device
3  * Copyright (c) 2020 Thilo Borgmann <thilo.borgmann@mail.de>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * AudioToolbox output device
25  * @author Thilo Borgmann <thilo.borgmann@mail.de>
26  */
27 
28 #import <AudioToolbox/AudioToolbox.h>
29 #include <pthread.h>
30 
31 #include "libavutil/opt.h"
32 #include "libavformat/internal.h"
33 #include "libavformat/mux.h"
34 #include "libavutil/internal.h"
35 #include "avdevice.h"
36 
37 typedef struct
38 {
39  AVClass *class;
40 
41  AudioQueueBufferRef buffer[2];
42  pthread_mutex_t buffer_lock[2];
43  int cur_buf;
44  AudioQueueRef queue;
45 
48 
49 } ATContext;
50 
51 static int check_status(AVFormatContext *avctx, OSStatus *status, const char *msg)
52 {
53  if (*status != noErr) {
54  av_log(avctx, AV_LOG_ERROR, "Error: %s (%i)\n", msg, *status);
55  return 1;
56  } else {
57  av_log(avctx, AV_LOG_DEBUG, " OK : %s\n", msg);
58  return 0;
59  }
60 }
61 
62 static void queue_callback(void* atctx, AudioQueueRef inAQ,
63  AudioQueueBufferRef inBuffer)
64 {
65  // unlock the buffer that has just been consumed
66  ATContext *ctx = (ATContext*)atctx;
67  for (int i = 0; i < 2; i++) {
68  if (inBuffer == ctx->buffer[i]) {
69  pthread_mutex_unlock(&ctx->buffer_lock[i]);
70  }
71  }
72 }
73 
75 {
76  ATContext *ctx = (ATContext*)avctx->priv_data;
77  OSStatus err = noErr;
78  CFStringRef device_UID = NULL;
79  AudioDeviceID *devices;
80  int num_devices;
81 
82 
83  // get devices
84  UInt32 data_size = 0;
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"))
91  return AVERROR(EINVAL);
92 
93  num_devices = data_size / sizeof(AudioDeviceID);
94 
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")) {
98  av_freep(&devices);
99  return AVERROR(EINVAL);
100  }
101 
102  // list devices
103  if (ctx->list_devices) {
104  CFStringRef device_name = NULL;
105  prop.mScope = kAudioDevicePropertyScopeInput;
106 
107  av_log(ctx, AV_LOG_INFO, "CoreAudio devices:\n");
108  for(UInt32 i = 0; i < num_devices; ++i) {
109  // UID
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"))
114  continue;
115 
116  // name
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"))
121  continue;
122 
123  av_log(ctx, AV_LOG_INFO, "[%d] %30s, %s\n", i,
124  CFStringGetCStringPtr(device_name, kCFStringEncodingMacRoman),
125  CFStringGetCStringPtr(device_UID, kCFStringEncodingMacRoman));
126  }
127  }
128 
129  // get user-defined device UID or use default device
130  // -audio_device_index overrides any URL given
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);
134  }
135 
136  if (ctx->audio_device_index >= 0) {
137  // get UID of selected device
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")) {
142  av_freep(&devices);
143  return AVERROR(EINVAL);
144  }
145  } else {
146  // use default device
147  device_UID = NULL;
148  }
149 
150  av_log(ctx, AV_LOG_DEBUG, "stream_name: %s\n", stream_name);
151  av_log(ctx, AV_LOG_DEBUG, "audio_device_idnex: %i\n", ctx->audio_device_index);
152  av_log(ctx, AV_LOG_DEBUG, "UID: %s\n", CFStringGetCStringPtr(device_UID, kCFStringEncodingMacRoman));
153 
154  // check input stream
155  if (avctx->nb_streams != 1 || avctx->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) {
156  av_log(ctx, AV_LOG_ERROR, "Only a single audio stream is supported.\n");
157  return AVERROR(EINVAL);
158  }
159 
160  av_freep(&devices);
161  AVCodecParameters *codecpar = avctx->streams[0]->codecpar;
162 
163  // audio format
164  AudioStreamBasicDescription device_format = {0};
165  device_format.mSampleRate = codecpar->sample_rate;
166  device_format.mFormatID = kAudioFormatLinearPCM;
167  device_format.mFormatFlags |= (codecpar->format == AV_SAMPLE_FMT_FLT) ? kLinearPCMFormatFlagIsFloat : 0;
168  device_format.mFormatFlags |= (codecpar->codec_id == AV_CODEC_ID_PCM_S8) ? kLinearPCMFormatFlagIsSignedInteger : 0;
169  device_format.mFormatFlags |= (codecpar->codec_id == AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE)) ? kLinearPCMFormatFlagIsSignedInteger : 0;
170  device_format.mFormatFlags |= (codecpar->codec_id == AV_NE(AV_CODEC_ID_PCM_S24BE, AV_CODEC_ID_PCM_S24LE)) ? kLinearPCMFormatFlagIsSignedInteger : 0;
171  device_format.mFormatFlags |= (codecpar->codec_id == AV_NE(AV_CODEC_ID_PCM_S32BE, AV_CODEC_ID_PCM_S32LE)) ? kLinearPCMFormatFlagIsSignedInteger : 0;
172  device_format.mFormatFlags |= (av_sample_fmt_is_planar(codecpar->format)) ? kAudioFormatFlagIsNonInterleaved : 0;
173  device_format.mFormatFlags |= (codecpar->codec_id == AV_CODEC_ID_PCM_F32BE) ? kAudioFormatFlagIsBigEndian : 0;
174  device_format.mFormatFlags |= (codecpar->codec_id == AV_CODEC_ID_PCM_S16BE) ? kAudioFormatFlagIsBigEndian : 0;
175  device_format.mFormatFlags |= (codecpar->codec_id == AV_CODEC_ID_PCM_S24BE) ? kAudioFormatFlagIsBigEndian : 0;
176  device_format.mFormatFlags |= (codecpar->codec_id == AV_CODEC_ID_PCM_S32BE) ? kAudioFormatFlagIsBigEndian : 0;
177  device_format.mChannelsPerFrame = codecpar->ch_layout.nb_channels;
178  device_format.mBitsPerChannel = (codecpar->codec_id == AV_NE(AV_CODEC_ID_PCM_S24BE, AV_CODEC_ID_PCM_S24LE)) ? 24 : (av_get_bytes_per_sample(codecpar->format) << 3);
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;
183 
184  av_log(ctx, AV_LOG_DEBUG, "device_format.mSampleRate = %i\n", codecpar->sample_rate);
185  av_log(ctx, AV_LOG_DEBUG, "device_format.mFormatID = %s\n", "kAudioFormatLinearPCM");
186  av_log(ctx, AV_LOG_DEBUG, "device_format.mFormatFlags |= %s\n", (codecpar->format == AV_SAMPLE_FMT_FLT) ? "kLinearPCMFormatFlagIsFloat" : "0");
187  av_log(ctx, AV_LOG_DEBUG, "device_format.mFormatFlags |= %s\n", (codecpar->codec_id == AV_CODEC_ID_PCM_S8) ? "kLinearPCMFormatFlagIsSignedInteger" : "0");
188  av_log(ctx, AV_LOG_DEBUG, "device_format.mFormatFlags |= %s\n", (codecpar->codec_id == AV_NE(AV_CODEC_ID_PCM_S32BE, AV_CODEC_ID_PCM_S32LE)) ? "kLinearPCMFormatFlagIsSignedInteger" : "0");
189  av_log(ctx, AV_LOG_DEBUG, "device_format.mFormatFlags |= %s\n", (codecpar->codec_id == AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE)) ? "kLinearPCMFormatFlagIsSignedInteger" : "0");
190  av_log(ctx, AV_LOG_DEBUG, "device_format.mFormatFlags |= %s\n", (codecpar->codec_id == AV_NE(AV_CODEC_ID_PCM_S24BE, AV_CODEC_ID_PCM_S24LE)) ? "kLinearPCMFormatFlagIsSignedInteger" : "0");
191  av_log(ctx, AV_LOG_DEBUG, "device_format.mFormatFlags |= %s\n", (av_sample_fmt_is_planar(codecpar->format)) ? "kAudioFormatFlagIsNonInterleaved" : "0");
192  av_log(ctx, AV_LOG_DEBUG, "device_format.mFormatFlags |= %s\n", (codecpar->codec_id == AV_CODEC_ID_PCM_F32BE) ? "kAudioFormatFlagIsBigEndian" : "0");
193  av_log(ctx, AV_LOG_DEBUG, "device_format.mFormatFlags |= %s\n", (codecpar->codec_id == AV_CODEC_ID_PCM_S16BE) ? "kAudioFormatFlagIsBigEndian" : "0");
194  av_log(ctx, AV_LOG_DEBUG, "device_format.mFormatFlags |= %s\n", (codecpar->codec_id == AV_CODEC_ID_PCM_S24BE) ? "kAudioFormatFlagIsBigEndian" : "0");
195  av_log(ctx, AV_LOG_DEBUG, "device_format.mFormatFlags |= %s\n", (codecpar->codec_id == AV_CODEC_ID_PCM_S32BE) ? "kAudioFormatFlagIsBigEndian" : "0");
196  av_log(ctx, AV_LOG_DEBUG, "device_format.mFormatFlags == %i\n", device_format.mFormatFlags);
197  av_log(ctx, AV_LOG_DEBUG, "device_format.mChannelsPerFrame = %i\n", codecpar->ch_layout.nb_channels);
198  av_log(ctx, AV_LOG_DEBUG, "device_format.mBitsPerChannel = %i\n", av_get_bytes_per_sample(codecpar->format) << 3);
199  av_log(ctx, AV_LOG_DEBUG, "device_format.mBytesPerFrame = %i\n", (device_format.mBitsPerChannel >> 3) * codecpar->ch_layout.nb_channels);
200  av_log(ctx, AV_LOG_DEBUG, "device_format.mBytesPerPacket = %i\n", device_format.mBytesPerFrame);
201  av_log(ctx, AV_LOG_DEBUG, "device_format.mFramesPerPacket = %i\n", 1);
202  av_log(ctx, AV_LOG_DEBUG, "device_format.mReserved = %i\n", 0);
203 
204  // create new output queue for the device
205  err = AudioQueueNewOutput(&device_format, queue_callback, ctx,
206  NULL, kCFRunLoopCommonModes,
207  0, &ctx->queue);
208  if (check_status(avctx, &err, "AudioQueueNewOutput")) {
209  if (err == kAudioFormatUnsupportedDataFormatError)
210  av_log(ctx, AV_LOG_ERROR, "Unsupported output format.\n");
211  return AVERROR(EINVAL);
212  }
213 
214  // set user-defined device or leave untouched for default
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"))
218  return AVERROR(EINVAL);
219  }
220 
221  // start the queue
222  err = AudioQueueStart(ctx->queue, NULL);
223  if (check_status(avctx, &err, "AudioQueueStart"))
224  return AVERROR(EINVAL);
225 
226  // init the mutexes for double-buffering
227  pthread_mutex_init(&ctx->buffer_lock[0], NULL);
228  pthread_mutex_init(&ctx->buffer_lock[1], NULL);
229 
230  return 0;
231 }
232 
234 {
235  ATContext *ctx = (ATContext*)avctx->priv_data;
236  OSStatus err = noErr;
237 
238  // use the other buffer
239  ctx->cur_buf = !ctx->cur_buf;
240 
241  // lock for writing or wait for the buffer to be available
242  // will be unlocked by queue callback
243  pthread_mutex_lock(&ctx->buffer_lock[ctx->cur_buf]);
244 
245  // (re-)allocate the buffer if not existant or of different size
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")) {
249  pthread_mutex_unlock(&ctx->buffer_lock[ctx->cur_buf]);
250  return AVERROR(ENOMEM);
251  }
252  }
253 
254  AudioQueueBufferRef buf = ctx->buffer[ctx->cur_buf];
255 
256  // copy audio data into buffer and enqueue the buffer
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")) {
261  pthread_mutex_unlock(&ctx->buffer_lock[ctx->cur_buf]);
262  return AVERROR(EINVAL);
263  }
264 
265  return 0;
266 }
267 
269 {
270  ATContext *ctx = (ATContext*)avctx->priv_data;
271  OSStatus err = noErr;
272 
273  pthread_mutex_destroy(&ctx->buffer_lock[0]);
274  pthread_mutex_destroy(&ctx->buffer_lock[1]);
275 
276  err = AudioQueueFlush(ctx->queue);
277  check_status(avctx, &err, "AudioQueueFlush");
278  err = AudioQueueDispose(ctx->queue, true);
279  check_status(avctx, &err, "AudioQueueDispose");
280 
281  return 0;
282 }
283 
284 static const AVOption options[] = {
285  { "list_devices", "list available audio devices", offsetof(ATContext, list_devices), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
286  { "audio_device_index", "select audio device by index (starts at 0)", offsetof(ATContext, audio_device_index), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
287  { NULL },
288 };
289 
290 static const AVClass at_class = {
291  .class_name = "AudioToolbox",
292  .item_name = av_default_item_name,
293  .option = options,
294  .version = LIBAVUTIL_VERSION_INT,
296 };
297 
299  .p.name = "audiotoolbox",
300  .p.long_name = NULL_IF_CONFIG_SMALL("AudioToolbox output device"),
301  .priv_data_size = sizeof(ATContext),
303  .p.video_codec = AV_CODEC_ID_NONE,
304  .write_header = at_write_header,
305  .write_packet = at_write_packet,
306  .write_trailer = at_write_trailer,
307  .p.flags = AVFMT_NOFILE,
308  .p.priv_class = &at_class,
309 };
AV_CODEC_ID_PCM_S16LE
@ AV_CODEC_ID_PCM_S16LE
Definition: codec_id.h:326
pthread_mutex_t
_fmutex pthread_mutex_t
Definition: os2threads.h:53
at_write_trailer
static av_cold int at_write_trailer(AVFormatContext *avctx)
Definition: audiotoolbox.m:268
AV_CODEC_ID_PCM_F32BE
@ AV_CODEC_ID_PCM_F32BE
Definition: codec_id.h:346
status
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
AVOutputFormat::name
const char * name
Definition: avformat.h:508
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:58
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:54
ATContext::cur_buf
int cur_buf
Definition: audiotoolbox.m:43
pthread_mutex_init
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
Definition: os2threads.h:104
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1172
AVPacket::data
uint8_t * data
Definition: packet.h:374
AVOption
AVOption.
Definition: opt.h:251
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:311
FFOutputFormat::p
AVOutputFormat p
The public AVOutputFormat.
Definition: mux.h:34
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
at_write_packet
static int at_write_packet(AVFormatContext *avctx, AVPacket *pkt)
Definition: audiotoolbox.m:233
AV_CODEC_ID_PCM_S16BE
@ AV_CODEC_ID_PCM_S16BE
Definition: codec_id.h:327
ff_audiotoolbox_muxer
const FFOutputFormat ff_audiotoolbox_muxer
Definition: audiotoolbox.m:298
AV_CODEC_ID_PCM_S8
@ AV_CODEC_ID_PCM_S8
Definition: codec_id.h:330
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
AV_NE
#define AV_NE(be, le)
Definition: macros.h:33
AV_OPT_FLAG_ENCODING_PARAM
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
Definition: opt.h:281
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
av_sample_fmt_is_planar
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
Definition: samplefmt.c:114
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AVFormatContext
Format I/O context.
Definition: avformat.h:1104
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:861
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
ATContext::list_devices
int list_devices
Definition: audiotoolbox.m:46
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
FFOutputFormat
Definition: mux.h:30
AVCodecParameters::ch_layout
AVChannelLayout ch_layout
Audio only.
Definition: codec_par.h:213
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:178
pthread_mutex_unlock
#define pthread_mutex_unlock(a)
Definition: ffprobe.c:79
AVFormatContext::nb_streams
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1160
at_class
static const AVClass at_class
Definition: audiotoolbox.m:290
AV_CODEC_ID_PCM_S24LE
@ AV_CODEC_ID_PCM_S24LE
Definition: codec_id.h:338
at_write_header
static av_cold int at_write_header(AVFormatContext *avctx)
Definition: audiotoolbox.m:74
AVPacket::size
int size
Definition: packet.h:375
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:115
queue_callback
static void queue_callback(void *atctx, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer)
Definition: audiotoolbox.m:62
AVFormatContext::url
char * url
input or output URL.
Definition: avformat.h:1187
AVFMT_NOFILE
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:468
ATContext
Definition: audiotoolbox.m:37
avdevice.h
ATContext::queue
AudioQueueRef queue
Definition: audiotoolbox.m:44
check_status
static int check_status(AVFormatContext *avctx, OSStatus *status, const char *msg)
Definition: audiotoolbox.m:51
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
pthread_mutex_destroy
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
Definition: os2threads.h:112
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
av_get_bytes_per_sample
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition: samplefmt.c:108
internal.h
AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT
@ AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT
Definition: log.h:42
AV_CODEC_ID_PCM_S32BE
@ AV_CODEC_ID_PCM_S32BE
Definition: codec_id.h:335
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
options
static const AVOption options[]
Definition: audiotoolbox.m:284
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AV_CODEC_ID_PCM_S32LE
@ AV_CODEC_ID_PCM_S32LE
Definition: codec_id.h:334
AVCodecParameters::format
int format
Definition: codec_par.h:86
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:62
AVPacket
This structure stores compressed data.
Definition: packet.h:351
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ATContext::audio_device_index
int audio_device_index
Definition: audiotoolbox.m:47
AVFormatContext::priv_data
void * priv_data
Format private data.
Definition: avformat.h:1132
AV_CODEC_ID_PCM_S24BE
@ AV_CODEC_ID_PCM_S24BE
Definition: codec_id.h:339
AV_SAMPLE_FMT_FLT
@ AV_SAMPLE_FMT_FLT
float
Definition: samplefmt.h:60
pthread_mutex_lock
#define pthread_mutex_lock(a)
Definition: ffprobe.c:75
mux.h