ndk-samples icon indicating copy to clipboard operation
ndk-samples copied to clipboard

Changing the audio source in the audio-echo app from external mic to built-in mic

Open mahaju opened this issue 5 years ago • 2 comments

In the audio-echo app, if an external earphone without microphone is plugged in, the app takes audio input from the phone's built in microphone and the output to the external earphone speaker

If I connect an external headphone with built in microphone, now the input audio is taken from the external microphone and the output audio goes to the external headphone speaker

Is it possible to always force the app to take input from the phone's built in microphone and send output to the headphone's external speaker?

mahaju avatar Feb 20 '20 03:02 mahaju

Any updates ? i have same requirement

adhavalboy avatar Mar 17 '20 06:03 adhavalboy

You could try to install any app for manual switching between available mics and speakers (like AudioSwitch that I've just found). Android itself is lacking that option (at least older versions). Hope it works, I haven't tested such situation.

Kmitka avatar May 10 '20 18:05 Kmitka

https://developer.android.com/ndk/reference/group/audio#aaudiostreambuilder_setdeviceid maybe? I don't really know the audio APIs.

You might be better served looking for this functionality in https://github.com/google/oboe, and if you don't find it there, ask them to provide it. The sample you're asking about is using OpenSLES, which hasn't been supported in quite some time. The sample is probably due for rewriting with oboe.

DanAlbert avatar May 03 '24 22:05 DanAlbert