Fix a bug that makes ClippingMediaSource not stop in some occasions.

If ClippingMediaSource contains a child MediaSource with embedded metadata
stream, and the embedded stream is being used, it can lead to
ClippingMediaSource not be able to stop after the clipping end point. The
reason being the metadata stream cannot read anymore sample, but it's also not
end of source at that point. This CL fix this by changing the condition to
check if the child stream cannot read anymore sample and it has read past the
clipping end point.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179918038
This commit is contained in:
hoangtc 2017-12-22 05:33:11 -08:00 committed by Oliver Woodman
parent 6f4110f3f8
commit 35d4cbf99f

View File

@ -299,9 +299,10 @@ public final class ClippingMediaPeriod implements MediaPeriod, MediaPeriod.Callb
formatHolder.format = format.copyWithGaplessInfo(encoderDelay, encoderPadding); formatHolder.format = format.copyWithGaplessInfo(encoderDelay, encoderPadding);
return C.RESULT_FORMAT_READ; return C.RESULT_FORMAT_READ;
} }
if (endUs != C.TIME_END_OF_SOURCE && ((result == C.RESULT_BUFFER_READ if (endUs != C.TIME_END_OF_SOURCE
&& buffer.timeUs >= endUs) || (result == C.RESULT_NOTHING_READ && ((result == C.RESULT_BUFFER_READ && buffer.timeUs >= endUs)
&& mediaPeriod.getBufferedPositionUs() == C.TIME_END_OF_SOURCE))) { || (result == C.RESULT_NOTHING_READ
&& getBufferedPositionUs() == C.TIME_END_OF_SOURCE))) {
buffer.clear(); buffer.clear();
buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM); buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
sentEos = true; sentEos = true;