media/libraries
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
..
cast Remove @DoNotInline annotations 2024-09-18 04:47:39 -07:00
common Fix underflow in Sonic#getOutputSize() after #queueEndOfStream() 2025-01-03 09:26:32 -08:00
common_ktx Add jvmTarget and kotlin-android plugin to common_ktx module 2024-08-15 10:36:10 -07:00
container Improve javadoc in Mp4LocationData and Mp4OrientationData class 2024-12-23 07:57:58 -08:00
database Enable lint errors in database tests 2024-12-04 03:55:33 -08:00
datasource Enable lint errors in datasource tests 2024-12-03 10:07:19 -08:00
datasource_cronet DataSourceContractTest: Tighten assertions around 'not found' URIs 2024-10-24 03:49:27 -07:00
datasource_okhttp DataSourceContractTest: Tighten assertions around 'not found' URIs 2024-10-24 03:49:27 -07:00
datasource_rtmp Remove exoplayer2-only javadoc machinery from media3 2023-06-05 09:47:58 +00:00
decoder MediaCodecVideoRenderer skips decoder inputs unused as reference 2024-07-09 03:43:06 -07:00
decoder_av1 Add missing DefaultRenderersFactoryTest for decoder extensions 2024-10-30 05:33:38 -07:00
decoder_ffmpeg Add 16 KB page support for decoder extensions on Android 15 2024-10-10 10:18:20 -07:00
decoder_flac Set container MIME type for audio-only extractors 2024-11-14 10:03:17 -08:00
decoder_iamf Enable lint errors in tests for remaining playback modules 2024-12-04 08:08:01 -08:00
decoder_midi Use ForwardingTrackOutput in MidiExtractor 2024-12-03 07:14:58 -08:00
decoder_mpegh Merge Issue: androidx/media#1826: add extension for MPEG-H decoding 2024-10-24 09:53:45 -07:00
decoder_opus Removed empty line 2024-12-11 14:47:04 +00:00
decoder_vp9 Add 16 KB page support for decoder extensions on Android 15 2024-10-10 10:18:20 -07:00
effect Log errors in BaseGlShaderProgram and QueueingGlShaderProgram. 2024-12-20 05:59:18 -08:00
exoplayer Repect Composition's HDR mode setting using OpenGL 2024-12-20 09:11:00 -08:00
exoplayer_dash Refactor CmcdData to handle object type determination internally 2024-12-12 04:36:16 -08:00
exoplayer_hls Add AdsMediaSourceFactory for HLS interstitials 2024-12-17 08:25:58 -08:00
exoplayer_ima Add client side post roll placeholder 2024-12-17 09:59:16 -08:00
exoplayer_rtsp Enable lint errors in tests for remaining playback modules 2024-12-04 08:08:01 -08:00
exoplayer_smoothstreaming Refactor CmcdData to handle object type determination internally 2024-12-12 04:36:16 -08:00
exoplayer_workmanager Remove exoplayer2-only javadoc machinery from media3 2023-06-05 09:47:58 +00:00
extractor Mp4Extractor: allow zero length NAL units 2025-01-03 05:21:10 -08:00
muxer Clarify the stream closing responsibility in muxer 2024-12-20 10:24:48 -08:00
session Reduce log severity to info for unhandled media buttons 2024-12-18 03:47:58 -08:00
test_data Mp4Extractor: allow zero length NAL units 2025-01-03 05:21:10 -08:00
test_exoplayer_playback Enable lint errors in tests for remaining playback modules 2024-12-04 08:08:01 -08:00
test_session_common Add media button preferences 2024-10-17 09:54:36 -07:00
test_session_current Align logic to ignore disabled and non-custom buttons in custom layout 2024-12-10 06:13:54 -08:00
test_utils Fix underflow in Sonic#getOutputSize() after #queueEndOfStream() 2025-01-03 09:26:32 -08:00
test_utils_robolectric Add TestPlayerRunHelper run(player).untilFullyBuffered 2024-11-06 02:45:51 -08:00
transformer Implement basic Metrics Collector in Transformer 2025-01-03 05:27:20 -08:00
ui Change lib-common dependency scope to api in lib-ui 2024-11-06 08:21:16 -08:00
ui_compose Remove publishing for media3-ui-compose temporarily 2024-12-19 09:54:59 -08:00
ui_leanback Bump effect and leanback minSdk to 19 2024-01-10 07:22:00 -08:00
lint.xml Enable lint in lib-common tests 2024-11-04 04:16:39 -08:00