iOS: AudioUnit on iOS produces echo with in/out streams
Submitted by Elio Francesconi
Assigned to Ilya Konstantinov
Link to original bug (#732896)
Description
The osxaudiosrc plugin is Remote I/O unit it is not suited for VoIP purpose because no echo cancellator.
According to the Apple documentation, The Voice-Processing I/O unit extends the Remote I/O unit by adding acoustic echo cancelation for use in a VoIP or voice-chat application.
https://developer.apple.com/library/ios/documentation/MusicAudio/Conceptual/AudioUnitHostingGuide_iOS/AudioUnitHostingFundamentals/AudioUnitHostingFundamentals.html
To use Voice-rocessing I/O unit I did these changes:
in gstosxcoreaudioremoteio.c
static gboolean
gst_core_audio_open_impl (GstCoreAudio * core_audio)
{
return gst_core_audio_open_device (core_audio, kAudioUnitSubType_VoiceProcessingIO,
"VoiceProcessingIO");
//return gst_core_audio_open_device (core_audio, kAudioUnitSubType_RemoteIO,
// "RemoteIO");
}
This patch was not enough to solve the issue because I received status = -50 after some calls of AudioUnitRender in getosxaudiosrc.c, it seems AudioUnitRender modifies buf->core_audio->recBufferList->mBuffers[0].mDataByteSize based on data returned, so before call AudioUnitRender it requires to set mDataByteSize today I’ve created mine osxaudio plugin with these changes, hardcoding "bytes per frame” and “channels” and solved my problem, I did’d check the buffer allocated because it’s big enough.
buf->core_audio->recBufferList->mNumberBuffers=1;
buf->core_audio->recBufferList->mBuffers[0].mDataByteSize=inNumberFrames*4/where 4 is bytes per frame/;
buf->core_audio->recBufferList->mBuffers[0].mNumberChannels=1 /num of channels/;
status = AudioUnitRender (buf->core_audio->audiounit, ioActionFlags,
inTimeStamp, inBusNumber, inNumberFrames, buf->core_audio->recBufferList);
if (status) {
GST_WARNING_OBJECT (buf, "AudioUnitRender returned %d", (int) status);
return status;
}
Version: 1.x