Bug 1125776: Part9. Always attempt to create a new decoder if we don't have one. r=mattwoodrow a=lmandel
YouTube continues to call appendBuffer even when the previous call failed.
So we attempt to re-create a decoder where we can should it be a temporary
failure.
--- a/dom/media/mediasource/TrackBuffer.cpp
+++ b/dom/media/mediasource/TrackBuffer.cpp
@@ -211,24 +211,22 @@ TrackBuffer::AppendData(LargeDataBuffer*
(mCurrentDecoder && mCurrentDecoder->WasTrimmed()))) {
MSE_DEBUG("TrackBuffer(%p)::AppendData: Data last=[%lld, %lld] overlaps [%lld, %lld]",
this, mLastStartTimestamp, mLastEndTimestamp.value(), start, end);
if (!newInitData) {
// This data is earlier in the timeline than data we have already
// processed or not continuous, so we must create a new decoder
// to handle the decoding.
- if (!decoders.NewDecoder(aTimestampOffset)) {
+ if (!hadCompleteInitData || !decoders.NewDecoder(aTimestampOffset)) {
mInitializationPromise.Reject(NS_ERROR_FAILURE, __func__);
return p;
}
- if (hadCompleteInitData) {
- MSE_DEBUG("TrackBuffer(%p)::AppendData: Decoder marked as initialized.", this);
- AppendDataToCurrentResource(oldInit, 0);
- }
+ MSE_DEBUG("TrackBuffer(%p)::AppendData: Decoder marked as initialized.", this);
+ AppendDataToCurrentResource(oldInit, 0);
}
mLastStartTimestamp = start;
} else {
MSE_DEBUG("TrackBuffer(%p)::AppendData: Segment last=[%lld, %lld] [%lld, %lld]",
this, mLastStartTimestamp, mLastEndTimestamp ? mLastEndTimestamp.value() : 0, start, end);
}
mLastEndTimestamp.reset();
mLastEndTimestamp.emplace(end);