Repository navigation
fix(chat): wait for the music of another app to stop before a voice recording starts - #6930
Open
ToteMeiSter wants to merge 1 commit into
Open
ToteMeiSter wants to merge 1 commit into
ToteMeiSter wants to merge 1 commit into
Conversation
…ecording starts The recording asked for the audio focus and opened the microphone in the same call. The player of another app pauses some time after it lost the focus, so the first moments of a voice message contained the end of the music from the speaker. After the focus is granted, the start of the recording now waits until AudioManager.isMusicActive is false, for at most one second; without music there is no delay. Giving the focus back drops a start that still waits, and a recording that was released before it started is not sent. Assisted-by: Claude-Code:claude-sonnet-5-5 Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
Contributor
📱 QA build
The QA build installs alongside a released Nextcloud app, so you can keep Downloading the file requires a GitHub account, so open this link on the |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the end of another app's music being recorded in the first moments of a voice message.
Recording a voice message asks for the audio focus and opens the microphone in the same call. The music player of another app pauses some time after it lost the focus, so the first second of the message contains the end of the music from the speaker.
AudioFocusRequestManager.audioFocusRequestgetswaitForOtherAudio. After the focus is granted the callback waits untilAudioManager.isMusicActiveis false (MusicSilenceGate: polls every 50 ms, at most 1 s). Without music there is no delay. Voice recording (ChatViewModel.startAudioRecording) and the mic visualizer (MessageInputViewModel.startMicInput) use it. Giving the focus back drops a start that still waits, andstopAndSendAudioRecordingdoes not send a recording that was released before it started.Known limit: with music the recording starts up to 1 s later. The "too short" check counts from the press, so a very short hold while music plays may send nothing.
To test: play music in another app, hold the voice record button for about 3 s, say a phrase, release. The music pauses at the press, the message does not contain the music, and the music comes back after sending.
Unit tests:
MusicSilenceBeforeCaptureTest(6 tests, fail without the change). Real capture cannot be tested in unit tests.Tested on: Huawei DEL-LX9 (Android 12), on a develop build of the fork that includes this fix.
🖼️ Screenshots
No UI change.
🚧 TODO
🏁 Checklist
/backport to stable-xx.x🤖 AI (if applicable)
🤖 Generated with Claude Code