I am having sound issues using a USB audio device with WebRTC. When I try to play a sound outside of WebRTC with the USB audio device, the audio is routed through the device as expected. Also, without the USB audio device, sound in WebRTC works well both ways. However, when I try to use WebRTC with the USB audio device plugged in there is no audio in or out from the USB audio device or the Android devices' builtin microphone and speakers. What I would like is to use the builtin microphone to input the audio and the USB audio device for output.
I was able to use the builtin mic with the USB audio device plugged in by using:
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS);
for (AudioDeviceInfo device : devices) {
if (device.getType() == AudioDeviceInfo.TYPE_BUILTIN_MIC) {
audioDeviceModule.setPreferredInputDevice(device);
break;
}
}
This works well, unfortunately there is no setPreferredOutputDevice
inside the JavaAudioDeviceModule
class. How do I make WebRTC use the USB audio device for playback?