Monday, 26 August 2019

Audio Stops Recording After a Minute

I am trying to do WebRTC, all is working fine but there seems to be an issue, that is, if the screen remains off for more than a minute the audio stops recording, meaning the audio from device stops until I switch the screen on once again.

What I have tried?

1) I have tried setting webSettings.setMediaPlaybackRequiresUserGesture(false); it does no good to the problem.

2) I have also tried adding a wakelock in the activity in which I am doing WebRTC but it also didn't work.

Here are the permissions declared in Manifest:

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

Here in activity, I am granting permission for the microphone in WebChromeClient:

        @Override
        public void onPermissionRequest(final PermissionRequest request) {
            request.grant(request.getResources());
      }

What I want?

I want to be able to continue call without disrupting the user to turn screen back on again. Please point me in right direction.

Thanks!

Update: I tried loading the WebRTC url in Chrome and the same thing is happening, that is, audio stops recording from my device.

Update 2: Adding log when audio stops coming from the device.

2019-08-06 17:18:47.266 4332-22405/? V/APM_AudioPolicyManager: getAudioPolicyConfig: audioParam;outDevice
2019-08-06 17:18:47.266 4332-22405/? V/APM_AudioPolicyManager: getNewOutputDevice() selected device 2
2019-08-06 17:18:47.266 4332-22405/? V/APM_AudioPolicyManager: ### curdevice : 2
2019-08-06 17:18:47.307 4332-22405/? V/APM_AudioPolicyManager: AudioPolicyManager:setRecordSilenced(uid:99066, silenced:1)
2019-08-06 17:18:47.308 4332-22405/? V/APM_AudioPolicyManager: AudioPolicyManager:setRecordSilenced(uid:11556, silenced:1)



from Audio Stops Recording After a Minute

1 comment:

  1. This is NOT just a webRTC problem. It seems to be a general problem - at least for Android 9 on a Galaxy Note 8. I am making an app that listens
    (records) continuously, but manifests same problem: cut off 1 min after screen off. My record callback begins to receive silence data and we see in the log...
    V/APM_AudioPolicyManager: getAudioPolicyConfig: audioParam;outDevice
    V/APM_AudioPolicyManager: getNewOutputDevice() selected device 2
    V/APM_AudioPolicyManager: ### curdevice : 2
    V/APM_AudioPolicyManager: AudioPolicyManager:setRecordSilenced(uid:99066, silenced:1)
    V/APM_AudioPolicyManager: AudioPolicyManager:setRecordSilenced(uid:11556, silenced:1)

    My app has all the correct permissions, it holds the WAKE LOCK, etc. etc.
    This is not a problem with battery optimization and indeed it is clear that I continue to have the CPU and continue to get my audio callbacks. It is just that they start returning silence. I am using AAudio in native code (C++).
    If I keep the screen on, no problem. It will run all day and night if I want.

    ReplyDelete