client-sdk-unity icon indicating copy to clipboard operation
client-sdk-unity copied to clipboard

Android microphone audio not received by other participants (LiveKit Unity SDK v1.2.4)

Open Amirreza-Saiah opened this issue 7 months ago • 3 comments

I'm using the LiveKit Unity SDK to build a multi-peer voice chat application using the LiveKit SFU. I’ve tested the setup between Unity Editor and Android builds. The issue is that audio from Android clients is not heard by other participants.

What works: Android devices connect to the room successfully. Microphone permissions are requested and granted at runtime. The microphone is selected from Microphone.devices and used to publish the audio track. The track is successfully published on Android. Server logs confirm this. The same logic works fine when both participants are running in the Unity Editor. Android clients can hear other participants clearly.

What does not work: When a participant joins from an Android device, their audio is not heard by any other participant (Android or Editor). TrackSubscribed is triggered on other clients, and an AudioSource is created, but no sound is produced. The AudioSource.clip appears to be empty or silent, even though the track is subscribed. Audio is not heard from the Android user, but logs confirm that audio packets are received and RTP stats are logged on the server. Debug information: LiveKit server logs show the audio/red track is published correctly from Android. AudioStream is created using RemoteAudioTrack, but playback is silent. Only one microphone device appears on Android: Android audio input. MicrophoneSource.Start() is called after publishing the track. Setup: LiveKit Unity SDK (1.2.4) LiveKit Server v1.6.3 (self-hosted) Unity 6000

Tested on Android 15,13

Microphone permission is granted and confirmed at runtime

Reproduction steps: Run Unity Editor and Android builds simultaneously Connect both to the same room using valid tokens Publish microphone audio tracks from both clients

Observe that: Editor can hear Editor Android can hear Editor Editor cannot hear Android (also Android cannot hear Android)

Hypothesis: The microphone input on Android is not properly captured or encoded by MicrophoneSource Audio packets are sent but may contain silence or invalid frames This issue could be platform-specific to Android's audio pipeline or Unity's microphone handling on Android Please advise on how to further troubleshoot or resolve this. I can provide Unity project and full logs if needed.

Thank you.

Amirreza-Saiah avatar Jun 26 '25 13:06 Amirreza-Saiah

Maybe you can try setting MicrophoneSampleRate to 24000, which is mentioned in the related issue https://github.com/livekit/client-sdk-unity/issues/111#issuecomment-2970167185

cloudwebrtc avatar Jun 27 '25 08:06 cloudwebrtc

Maybe you can try setting MicrophoneSampleRate to 24000, which is mentioned in the related issue #111 (comment)

Thank you so much. I was about to give up on this 😊 You and LiveKit really saved my project.

Yes, it was set to 48,000 Hz by default in v1.2.4, and that’s why I couldn’t hear any audio from Android devices.

I also checked the SDK code and saw that the sample rate gets set to 24,000 Hz automatically on iOS, but there’s no similar logic for Android.

(And there’s no Configure function in the MicrophoneSource class in v1.2.4, and I couldn’t find any equivalent way to change the sample rate there.)

Amirreza-Saiah avatar Jun 28 '25 10:06 Amirreza-Saiah

Same problem here. I'm using a Samsung Galaxy S23 Ultra.

One particular thing is that if I use headphones on the remote device that receives the Android audio, you can hear it, but if you remove the headphones you can't hear it.

CosmopolitiWideverse avatar Jul 29 '25 15:07 CosmopolitiWideverse