Clear TextRenderer.streamError when disabling or changing stream

Previously a stream error from one playlist item was incorrectly
preserved when switching to the next one, resulting in playback hanging.

Issue: androidx/media#2328
PiperOrigin-RevId: 752624979
This commit is contained in:
ibaker 2025-04-29 01:03:42 -07:00 committed by Copybara-Service
parent 4d7046c187
commit ecfd9d1e92
2 changed files with 5 additions and 0 deletions

View File

@ -42,6 +42,9 @@
* Text: * Text:
* Fix SSA and SubRip to display an in-progress cue when enabling subtitles * Fix SSA and SubRip to display an in-progress cue when enabling subtitles
([#2309](https://github.com/androidx/media/issues/2309)). ([#2309](https://github.com/androidx/media/issues/2309)).
* Fix playback getting stuck when switching from a stream with a subtitle
error to a live stream with an empty subtitle track
([#2328](https://github.com/androidx/media/issues/2328)).
* Metadata: * Metadata:
* Image: * Image:
* DataSource: * DataSource:

View File

@ -208,6 +208,7 @@ public final class TextRenderer extends BaseRenderer implements Callback {
long offsetUs, long offsetUs,
MediaSource.MediaPeriodId mediaPeriodId) { MediaSource.MediaPeriodId mediaPeriodId) {
streamFormat = formats[0]; streamFormat = formats[0];
streamError = null;
if (!isCuesWithTiming(streamFormat)) { if (!isCuesWithTiming(streamFormat)) {
assertLegacyDecodingEnabledIfRequired(); assertLegacyDecodingEnabledIfRequired();
if (subtitleDecoder != null) { if (subtitleDecoder != null) {
@ -460,6 +461,7 @@ public final class TextRenderer extends BaseRenderer implements Callback {
@Override @Override
protected void onDisabled() { protected void onDisabled() {
streamFormat = null; streamFormat = null;
streamError = null;
finalStreamEndPositionUs = C.TIME_UNSET; finalStreamEndPositionUs = C.TIME_UNSET;
clearOutput(); clearOutput();
lastRendererPositionUs = C.TIME_UNSET; lastRendererPositionUs = C.TIME_UNSET;