I am using playing audio as soon as we received any input from microphone. I am using OSStatus for recording and playing audio. As the recording and playing are working fine.
I have to active left side headphone, right side headphone or center as per user select. As I research AudioBuffer, we have to set mNumberChannels for left, right and center headphone. Here is my code for playing audio.
AudioBuffer buffer;
// // 1 - Left
// // 2 - Right
// // 3 - Center
//
buffer.mNumberChannels = 0;
buffer.mDataByteSize = inNumberFrames * 2;
buffer.mData = malloc( inNumberFrames * 2 );
// Put buffer in a AudioBufferList
AudioBufferList bufferList;
bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0] = buffer;
// Obtain recorded samples
OSStatus status;
status = AudioUnitRender([iosAudio audioUnit],
ioActionFlags,
inTimeStamp,
inBusNumber,
inNumberFrames,
&bufferList);
checkStatus(status);
// Now, we have the samples we just read sitting in buffers in bufferList
// Process the new data
[audioProcess processAudio:&bufferList];
free(bufferList.mBuffers[0].mData);
return noErr;
But I am not able to enable left, right or center if I changed mNumberChannels. Can anyone help to point out my mistake?