Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audio Stops Recording After a Minute

Tags:

java

android

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)

Update 3: Tried initializing WebView in a Foreground Service still same result.

Update 4: Tried a demo call on https://appr.tc/ using Chrome(76.0.3809.132). Observed the same result.

Update 5: Tried a demo call using Firefox and it worked FLAWLESSLY which lets me thinking that is it a Chromium bug?

Update 6: Filled a bug report

like image 840
Mustansir Avatar asked Aug 05 '19 17:08

Mustansir


People also ask

Why does my recording keeps stopping?

If your SD card storage space is full, it thereby implies that there will be no space for any more recording, hence leading to a stop in video recording. A corrupt SD card can cause the movie recording to stop automatically.

Why does Audacity stop recording?

If you have Sound Activated Recording checked, Audacity will stop working if the sound drops below a certain volume. Transport > Transport Options > Sound Activated Recording.

Does Audacity have a recording time limit?

Audacity lets you record for as long and as often as you need, subject to the disk space you have available.


1 Answers

Android will automatically destroy your activity on a few minutes after leaving foreground that will cause the audio recording to turn off.

I have working with webrtc on android, if you want to create call and video call with webrtc on Android, I suggest to use native webrtc and implement everything related to webrtc on foreground service. Foreground service will ensure your recorder and camera to keep running event when activity is destroyed.

For reference, here the google sample for implementing webrtc native https://webrtc.googlesource.com/src/+/master/examples/androidapp/src/org/appspot/apprtc

like image 86
flx_h Avatar answered Sep 30 '22 05:09

flx_h