WebRTC implementation on Android keeps device awake with AudioMix wakelock

Skip to first unread message

Sebastian Kleu

Nov 16, 2023, 4:25:19 PM11/16/23
to discuss-webrtc

I have webrtc integrated with my Android device.
I realized that when connected, the device is always on and never goes into sleep/doze.
The only way I was able to release the wakelock was by using the following after I received and played audio for the first time:
However, this method completely stops the AudioTrackThread as can be viewed with the logs below:
[org.webrtc.Logging] WebRtcAudioTrackExternal: stopPlayout
[org.webrtc.Logging] WebRtcAudioTrackExternal: underrun count: 0
[org.webrtc.Logging] WebRtcAudioTrackExternal: stopThread
[org.webrtc.Logging] WebRtcAudioTrackExternal: Stopping the AudioTrackThread...
[org.webrtc.Logging] WebRtcAudioTrackExternal: AudioTrackThread has now been stopped.
[org.webrtc.Logging] WebRtcAudioTrackExternal: Calling AudioTrack.stop...
[org.webrtc.Logging] WebRtcAudioTrackExternal: AudioTrack.stop is done.
[org.webrtc.Logging] WebRtcAudioTrackExternal: doAudioTrackStateCallback: 1
[org.webrtc.Logging] WebRtcAudioTrackExternal: releaseAudioResources

When I receive new audio, I set the Audio playout to true again but no audio is then playing as I can only assume that setting it back to true does not start the AudioTrackThread again.

I would like my device to be connected to a peer and be allowed to go to sleep. Could somebody provide me with some pointers to achieve this?



Henrik Andreasson

Nov 17, 2023, 3:20:31 AM11/17/23
to discuss...@googlegroups.com
You could try to extend the injected ADM [1] instead of using SetAudioPlayout() since it will give you a better control of the complete audio flow.
SetAudioPlayout() is mainly intended for caching/delaying a previous StartPlayout call and making it have an effect when an additional condition is fulfilled (e.g. when a ring tone has stopped playing).
The SetAudioPlayout API was mainly designed to fix rather specific audio issues. Since then we have made the ADM injectable to give the user full control of the audio path.

This list falls under the WebRTC Code of Conduct - https://webrtc.org/support/code-of-conduct.
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/71ee6fa0-13b3-45fc-b2cb-92229981f609n%40googlegroups.com.
Reply all
Reply to author
0 new messages