media/libraries/common
ivanbuper 7ecaebe3d6 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
2025-01-03 09:26:32 -08:00
..
src Fix underflow in Sonic#getOutputSize() after #queueEndOfStream() 2025-01-03 09:26:32 -08:00
build.gradle Enable lint in tests for modules that require no fixes 2024-11-05 05:40:03 -08:00
lint-baseline.xml Add lint base to make gradle lint run without errors 2022-06-15 15:27:34 +00:00
proguard-rules.txt Update to androidx.media3 2021-10-27 09:12:46 +01:00
README.md Fix javadoc links in media README files 2023-03-30 17:26:40 +00:00

Common module

Provides common code and utilities used by other media modules. Application code will not normally need to depend on this module directly.