1. MixerHost
* AudioBufferList
Declaration: struct AudioBufferList {
UInt32 mNumberBuffers;
AudioBuffer mBuffers[1];
};
Q:WHY AudioBuffer[1]? WHY NOT AudioBuffer *? seems the same ?
注:参见此文对指针与数据区别的分析:http://wenku.baidu.com/view/93fc57202f60ddccda38a0b5.html
mBuffers只是标明一个buffer array的起始地址,具体空间大小由mNumberBuffers决定。
另外,在本程序里,mNumberBuffers为1/2,分别表示mono/stereo,而每个buffer本身只有一个channel
* AudioBuffer
struct AudioBuffer { UInt32 mNumberChannels; UInt32 mDataByteSize; void *mData; }; typedef struct AudioBuffer AudioBuffer;
Q: 跟踪发现,mNumberChannels总是1,什么原因?是否因为right channel的data在另一个buffer中?和interleaved及non-interleaved之间有什么关系?
A: 此struct用于多种场景,某些情况下在一个buffer中会有多个channel的数据,有些情况下只有一个channel的数据。与AudioBufferList配合使用。
* InputRenderCallback()
// Audio unit input render callbacks are invoked on a realtime priority thread (the highest
// priority on the system). To work well, to not make the system unresponsive, and to avoid
// audio artifacts, a render callback must not:
//
// * allocate memory
// * access the file system or a network connection
// * take locks
// * waste time
//
// In addition, it's usually best to avoid sending Objective-C messages in a render callback.
//
2. My own Audio Unit code in conference project
* inside InputRenderCallback()
// get audio data from audio engine
readAudioData(buffer, length) // length should be 1280=320*4 bytes
// fill the buffer handed to me
// Fill the buffer or buffers pointed at by *ioData with the requested number of samples
// of audio from the sound stored in memory.
for (UInt32 frameNumber = 0; frameNumber < inNumberFrames; ++frameNumber) {
outSamplesChannelLeft[frameNumber] = dataInLeft[sampleNumber];
}
3. 调试Conference程序使用G711
* playback
errors as follows:
(gdb) continue
2012-03-12 18:03:26.217 test555[1369:207] AQBufferCallback...
2012-03-12 18:03:27.395 test555[1369:207] audio data ready
2012-03-12 18:03:27.395 test555[1369:207] AQBufferCallback...
[Switching to process 1369]
Program received signal: “EXC_BAD_ACCESS”.
other erros:
2012-03-12 18:16:03.056 test555[1475:207] AQBufferCallback...
mi_cmd_exec_interrupt: Inferior not executing.
mi_cmd_exec_interrupt: Inferior not executing.
(gdb) continue
(gdb) continue
2012-03-12 18:16:03.976 test555[1475:207] audio data ready
test555(1475,0xb024f000) malloc: *** error for object 0x551bde4: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Program received signal: “SIGABRT”.
(gdb) continue
Program received signal: “SIGABRT”.