Bug 1123882 - Fix case where offset != 0. r=derf, a=2.0+
authorByron Campen [:bwc] <docfaraday@gmail.com>
Wed, 21 Jan 2015 08:56:36 -0800
changeset 204419 85138cc0dc50484831f32980d1176f354c25d445
parent 204418 e5316e2d159e0444f65d176cb445f6eddda14c0f
child 204420 8e9744a33b760e7ad786b2569f06a7b0b6b1e937
push id632
push userryanvm@gmail.com
push dateTue, 27 Jan 2015 03:04:56 +0000
treeherdermozilla-b2g32_v2_0@09b7b1f86aba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersderf, 2
bugs1123882
milestone32.0
Bug 1123882 - Fix case where offset != 0. r=derf, a=2.0+
content/media/MediaDecoderStateMachine.cpp
--- a/content/media/MediaDecoderStateMachine.cpp
+++ b/content/media/MediaDecoderStateMachine.cpp
@@ -326,27 +326,30 @@ void MediaDecoderStateMachine::SendStrea
   } else {
     // Write the entire packet.
     offset = 0;
   }
 
   if (offset >= aAudio->mFrames)
     return;
 
+  size_t framesToWrite = aAudio->mFrames - offset;
+
   aAudio->EnsureAudioBuffer();
   nsRefPtr<SharedBuffer> buffer = aAudio->mAudioBuffer;
   AudioDataValue* bufferData = static_cast<AudioDataValue*>(buffer->Data());
   nsAutoTArray<const AudioDataValue*,2> channels;
   for (uint32_t i = 0; i < aAudio->mChannels; ++i) {
     channels.AppendElement(bufferData + i*aAudio->mFrames + offset);
   }
-  aOutput->AppendFrames(buffer.forget(), channels, aAudio->mFrames);
-  VERBOSE_LOG("writing %d frames of data to MediaStream for AudioData at %lld",
-              aAudio->mFrames - int32_t(offset), aAudio->mTime);
-  aStream->mAudioFramesWritten += aAudio->mFrames - int32_t(offset);
+  aOutput->AppendFrames(buffer.forget(), channels, framesToWrite);
+  VERBOSE_LOG("writing %u frames of data to MediaStream for AudioData at %lld",
+              static_cast<unsigned>(framesToWrite),
+              aAudio->mTime);
+  aStream->mAudioFramesWritten += framesToWrite;
 }
 
 static void WriteVideoToMediaStream(layers::Image* aImage,
                                     int64_t aDuration,
                                     const IntSize& aIntrinsicSize,
                                     VideoSegment* aOutput)
 {
   nsRefPtr<layers::Image> image = aImage;