Fix Opus BufferStream end clicks #344
Open
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.
Description
Fix "click" sound at the end of OGG Opus files (#343):
pre_skip, granule position, and declared sample rate/channelspre_skip, and trimmed the PCM buffer to the raw granule position, which cut off real samples and produced the audible clickpre_skipframes before emitting PCM, and stop only after the expected sample count; the existing 5 ms fade now smooths the true tail instead of hiding a truncation✋ WARNING: the changes and commit were generated with the Codex CLI; I’m not an audio-domain expert, so please give this a thorough review! I don't know if all of the changes in the commit are absolutely necessary, but when I tried to simplify the changes or patch less (again, with little personal expertise and the help of AI), the clicks came back. Would be happy if this gets either merged or closed and just used as inspiration for a better fix! 😄
Also, this doesn't touch the Vorbis stream decoder, which might need its own patch?
Type of Change
Testing
setBufferStream+addAudioDataStreamin my own Flutter app using these changes patched locally toflutter_soloud. The clicks at the end of the audio are gone.