Handle metadata failing to decode in MetadataRenderer

Issue: #5149
PiperOrigin-RevId: 223121651
This commit is contained in:
andrewlewis 2018-11-28 08:26:41 +00:00 committed by Oliver Woodman
parent 017923ed81
commit 15d13bdccd
2 changed files with 8 additions and 3 deletions

View File

@ -20,6 +20,8 @@
([#4690](https://github.com/google/ExoPlayer/issues/4690)).
* Fix issue with applying the `show_buffering` attribute in `PlayerView`
([#5139](https://github.com/google/ExoPlayer/issues/5139)).
* Fix issue where null `Metadata` was output when it failed to decode
([#5149](https://github.com/google/ExoPlayer/issues/5149)).
### 2.9.1 ###

View File

@ -129,9 +129,12 @@ public final class MetadataRenderer extends BaseRenderer implements Callback {
buffer.subsampleOffsetUs = formatHolder.format.subsampleOffsetUs;
buffer.flip();
int index = (pendingMetadataIndex + pendingMetadataCount) % MAX_PENDING_METADATA_COUNT;
pendingMetadata[index] = decoder.decode(buffer);
pendingMetadataTimestamps[index] = buffer.timeUs;
pendingMetadataCount++;
Metadata metadata = decoder.decode(buffer);
if (metadata != null) {
pendingMetadata[index] = metadata;
pendingMetadataTimestamps[index] = buffer.timeUs;
pendingMetadataCount++;
}
}
}
}