-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix underflow in Sonic#getOutputSize() after #queueEndOfStream()
For the [0.5; 1) speed range, the combination of having a "slow down" speed (i.e. more output frames than input frames), and Sonic potentially needing to copy more input frames that are available in the input buffer can lead to an unexpected underflow. Specifically, the underflow happens in Sonic#queueEndOfStream() when the following conditions are met (skipping some minor ones): 1. `inputFrameCount < remainingInputToCopyFrameCount` 2. `0.5f <= speed < 1`. 3. `outputFrameCount < (inputFrameCount / remainingInputToCopyFrameCount) / 2`. This underflow caused `SonicAudioProcessor#isEnded()` to return a false negative (because `getOutputSize() != 0`), which would stall the `DefaultAudioSink` waiting for processing to end after EOS. In practical terms, the underflow is relatively easy to reproduce if we consume all of Sonic's output and then immediately queue EOS without queueing any more input in between. This should cause both `inputFrameCount` and `outputFrameCount` to drop to 0. PiperOrigin-RevId: 711773565
- Loading branch information
1 parent
cd5d5bd
commit 7ecaebe
Showing
7 changed files
with
167 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.