Bug 1119119: Do not abort when calling appendBuffer with no data. r=cajbir a=sledru
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 16 Jan 2015 23:48:24 +1100
changeset 242909 4fe580b632e5
parent 242908 7cd63f89473b
child 242910 a1a315b3ff6b
push id4338
push userrgiles@mozilla.com
push date2015-01-20 00:26 +0000
treeherdermozilla-beta@7dd701f60492 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscajbir, sledru
bugs1119119
milestone36.0
Bug 1119119: Do not abort when calling appendBuffer with no data. r=cajbir a=sledru
dom/media/mediasource/SourceBuffer.cpp
--- a/dom/media/mediasource/SourceBuffer.cpp
+++ b/dom/media/mediasource/SourceBuffer.cpp
@@ -342,30 +342,32 @@ SourceBuffer::AppendData(const uint8_t* 
   MSE_DEBUG("SourceBuffer(%p)::AppendData(aLength=%u)", this, aLength);
   if (!PrepareAppend(aRv)) {
     return;
   }
   StartUpdating();
 
   MOZ_ASSERT(mAppendMode == SourceBufferAppendMode::Segments,
              "We don't handle timestampOffset for sequence mode yet");
-  if (!mTrackBuffer->AppendData(aData, aLength, mTimestampOffset * USECS_PER_S)) {
-    Optional<MediaSourceEndOfStreamError> decodeError(MediaSourceEndOfStreamError::Decode);
-    ErrorResult dummy;
-    mMediaSource->EndOfStream(decodeError, dummy);
-    aRv.Throw(NS_ERROR_FAILURE);
-    return;
+  if (aLength) {
+    if (!mTrackBuffer->AppendData(aData, aLength, mTimestampOffset * USECS_PER_S)) {
+      Optional<MediaSourceEndOfStreamError> decodeError(MediaSourceEndOfStreamError::Decode);
+      ErrorResult dummy;
+      mMediaSource->EndOfStream(decodeError, dummy);
+      aRv.Throw(NS_ERROR_FAILURE);
+      return;
+    }
+
+    if (mTrackBuffer->HasInitSegment()) {
+      mMediaSource->QueueInitializationEvent();
+    }
+
+    CheckEndTime();
   }
 
-  if (mTrackBuffer->HasInitSegment()) {
-    mMediaSource->QueueInitializationEvent();
-  }
-
-  CheckEndTime();
-
   // Run the final step of the buffer append algorithm asynchronously to
   // ensure the SourceBuffer's updating flag transition behaves as required
   // by the spec.
   nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &SourceBuffer::StopUpdating);
   NS_DispatchToMainThread(event);
 }
 
 bool