Bug 1125776: Part9. Always attempt to create a new decoder if we don't have one. r=mattwoodrow a=lmandel
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 04 Feb 2015 20:20:16 +1100
changeset 247740 cb47d8fa838fcfb834d2a74278895b535975213c
parent 247739 7764d48b0a2773b65051601e7a673e943dbe7821
child 247741 378dac73d66dd37fc4bb794800ffff7ba46549f0
push id889
push usergijskruitbosch@gmail.com
push dateTue, 03 Mar 2015 18:12:54 +0000
reviewersmattwoodrow, lmandel
bugs1125776
milestone37.0a2
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.
dom/media/mediasource/TrackBuffer.cpp
--- 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);