Handle playToEndOfStream called before configuring the audio sink
ExoPlayer sometimes calls AudioSink.playToEndOfStream before configuring the sink. Before this CL, the composition player was failing if this happened. PiperOrigin-RevId: 634306592
This commit is contained in:
parent
a4faf4db6f
commit
e23cc756e2
@ -122,7 +122,7 @@ import java.util.Objects;
|
|||||||
EditedMediaItem editedMediaItem = checkStateNotNull(currentEditedMediaItemInfo).editedMediaItem;
|
EditedMediaItem editedMediaItem = checkStateNotNull(currentEditedMediaItemInfo).editedMediaItem;
|
||||||
// TODO(b/303029969): Evaluate throwing vs ignoring for null outputChannels.
|
// TODO(b/303029969): Evaluate throwing vs ignoring for null outputChannels.
|
||||||
checkArgument(outputChannels == null);
|
checkArgument(outputChannels == null);
|
||||||
this.currentInputFormat = inputFormat;
|
currentInputFormat = inputFormat;
|
||||||
if (outputGraphInput == null) {
|
if (outputGraphInput == null) {
|
||||||
try {
|
try {
|
||||||
outputGraphInput = controller.getAudioGraphInput(editedMediaItem, currentInputFormat);
|
outputGraphInput = controller.getAudioGraphInput(editedMediaItem, currentInputFormat);
|
||||||
@ -137,6 +137,9 @@ import java.util.Objects;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnded() {
|
public boolean isEnded() {
|
||||||
|
if (currentInputFormat == null) { // Sink not configured.
|
||||||
|
return inputStreamEnded;
|
||||||
|
}
|
||||||
// If we are playing the last media item in the sequence, we must also check that the controller
|
// If we are playing the last media item in the sequence, we must also check that the controller
|
||||||
// is ended.
|
// is ended.
|
||||||
return inputStreamEnded
|
return inputStreamEnded
|
||||||
@ -154,6 +157,9 @@ import java.util.Objects;
|
|||||||
@Override
|
@Override
|
||||||
public void playToEndOfStream() {
|
public void playToEndOfStream() {
|
||||||
inputStreamEnded = true;
|
inputStreamEnded = true;
|
||||||
|
if (currentInputFormat == null) { // Sink not configured.
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Queue end-of-stream only if playing the last media item in the sequence.
|
// Queue end-of-stream only if playing the last media item in the sequence.
|
||||||
if (!signalledEndOfStream && checkStateNotNull(currentEditedMediaItemInfo).isLastInSequence) {
|
if (!signalledEndOfStream && checkStateNotNull(currentEditedMediaItemInfo).isLastInSequence) {
|
||||||
signalledEndOfStream =
|
signalledEndOfStream =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user