1

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.

GPS
  • 1,322
  • 1
  • 18
  • 40

1 Answers1

1

Voice apps are reading audio from AUDIO_DEVICE_IN_BUILTIN_MIC (or Android routes their input audio from HAL that implements this device) (UPDATE: This is implemented in Audio Policy Manager. Some APMs don't do it this way, e.g. Nexus player. For them APM also needs to be modified.)

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

[Update2]

If AudioTrack is used to feed audio, then audio output of system will also be fed to hal. I later switched to using unix socket to feed audio to my HAL to avoid this.

Community
  • 1
  • 1
GPS
  • 1,322
  • 1
  • 18
  • 40