How to avoid audio output switching from remote_submix to speaker when the microphone is turned on?

44 Views Asked by At

Background

I have two Android phones. One is the Server and the other is the Client. I can flash my own images on these two phones by modifying the aosp source code. So I can record from device remote_submix.

Server: record from remote_submix and send audio data to client.

Client: play audio data from server.

Problem

When I open the microphone on the server, the sounds will be played on the server's device speaker and the Client lost sound.

By use dumpsys audio find that the Devices of STREAM_SYSTEM, STREAM_MUSIC, STREAM_XXX are changed from remote_submix to speaker, and the mode changed from MODE_NORMAL to MODE_IN_COMMUNICATION.

I think this problem may be related to AudioPolicy. However, Android's audio system is so large and complicated and I couldn't figure it out for a long time.

How to avoid audio output switching from remote_submix to speaker when the microphone is turned on?

Does anyone know any clue about it? Thanks a lot.

0

There are 0 best solutions below