Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix audio input gets muted after a while on android #93200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AndreiPetrov890
Copy link

@AndreiPetrov890 AndreiPetrov890 commented Jun 15, 2024

Fix the buffer underrun situation, which leads to unexpected mute of mic input in android application.

Original bug report: (#86428)

I personally encountered the same problem on my own project.

My solution is to delete mixed_frames correction in AudioStreamMicrophone. In other places of code this correction is used as sign of end of sound source (melody or recordings). But it's mic, folks. Mic stream must work until I stop it by myself, recording ambient sound. So no need to check the end of sound source. Mic source have no end.

Big thanks to @leoyanis, who ponts to problem, and great thanks to @kus04e4ek, who points to roots of the problem.

@AndreiPetrov890 AndreiPetrov890 requested a review from a team as a code owner June 15, 2024 17:24
@AThousandShips
Copy link
Member

AThousandShips commented Jun 15, 2024

@AThousandShips AThousandShips added this to the 4.3 milestone Jun 15, 2024
@AThousandShips AThousandShips requested a review from a team June 15, 2024 17:27
@AThousandShips AThousandShips changed the title fix - Audio input gets muted after a while on android #86428 Fix audio input gets muted after a while on android Jun 15, 2024
@kus04e4ek
Copy link
Contributor

kus04e4ek commented Jun 16, 2024

I don't really like this approach, if this code gets triggered, that means that AudioStremPlaybackMicrophone tries to read data that's not yet written (at least that's when this code is supposed to be executing), this should never happen and if it does that means that safety measures against it should be rethought (input buffer size and playback_delay) or AudioDriver implementation does something wrong. This was however triggered not by the AudioDriver implementation being wrong or safety measures not working, it was triggered by this: #93125. I think this check should stay, as otherwise reading from the input buffer would randomly fail and you would hear silence for a second, which is not ideal. In the PRs AThousandShips linked I added an error message if something like this happens, IMO users should report the error message and not silence, if something goes wrong

@AndreiPetrov890
Copy link
Author

if this code gets triggered, that means that AudioStremPlaybackMicrophone tries to read data that's not yet written (at least that's when this code is supposed to be executing), this should never happen

100%, dude!

I guess this happens occasionly due to noise suppressor working in android, which stops recording instead of recording silence. I'm not sure, but that might be the case.

However, this patch works in my project and anyone can use it until a new version of the engine comes out, which I hope will include your patch for this issue.

Best regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Audio input gets muted after a while on android
4 participants