GPS GPS - 1 year ago 145
Android Question

How to route audio for other apps

I have a networked app/service on a stationary Android box that receives audio from a remote handheld device.

I need Android box's voice recognition apps (e.g. Google App) to process this audio. These apps read audio from microphone.

How can I route audio available in my app/service so it appears to be coming in from microphone?

I believe DEVICE_OUT_REMOTE_SUBMIX in AudioSystem has something to do with it, but I cannot find any documentation on this.

Answer Source

Voice apps are reading audio from AUDIO_DEVICE_IN_BUILTIN_MIC (or Android routes their input audio from HAL that implements this device)

I wrote a Audio HAL for Android, and configured it to implement AUDIO_DEVICE_IN_BUILTIN_MIC while I removed primary HAL's conf for this input. This is sufficient for other mic-input apps to read audio from my HAL.

I feed the audio to HAL through another AudioTrack to AUDIO_DEVICE_OUT_LINE which my HAL implements but I could also switch it over to unix-socket if required in future.

More details on config were discussed here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download