For anyone who wants to handle the same thing without patching the libWebRTC. The library actually expose the functionality to reset the audio device via the VoEHardware interface. All you need to do in your application is to subscribe to audio session interrupted notifications, and when the interruption is over, just call the
int VoEHardwareImpl::ResetAudioDevice()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"ResetAudioDevice()");
ANDROID_NOT_SUPPORTED(_shared->statistics());
if (!_shared->statistics().Initialized())
{
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
#if defined(WEBRTC_IOS)
if (_shared->audio_device()->ResetAudioDevice() < 0)
{
_shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceError,
" Failed to reset sound device");
return -1;
}
#else
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
" no support for resetting sound device");
return -1;
#endif
return 0;
}