Bug 1123882 - Fix case where offset != 0. r=derf, a=bkerensa
authorByron Campen [:bwc] <docfaraday@gmail.com>
Wed, 21 Jan 2015 08:56:36 -0800
changeset 200539 08e90874cdf5c2ff6e9d25f5aaf92761cadfe4f2
parent 200538 ac9cfa44ecfdfb60be12118e81c8270a97044644
child 200540 891f9e72b4c2bb9dd06617024f2b21b406180ffc
push id178
push userryanvm@gmail.com
push dateMon, 26 Jan 2015 22:33:03 +0000
treeherdermozilla-esr31@891f9e72b4c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersderf, bkerensa
bugs1123882
milestone31.4.0
Bug 1123882 - Fix case where offset != 0. r=derf, a=bkerensa
content/media/MediaDecoderStateMachine.cpp
--- a/content/media/MediaDecoderStateMachine.cpp
+++ b/content/media/MediaDecoderStateMachine.cpp
@@ -323,27 +323,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;