Bug 1123882 - Fix case where offset != 0. r=derf, a=abillings
authorByron Campen [:bwc] <docfaraday@gmail.com>
Wed, 21 Jan 2015 08:56:36 -0800
changeset 243036 228ee06444b5
parent 243035 a160dd7b5dda
child 243037 12972395700a
push id4370
push userryanvm@gmail.com
push date2015-01-26 15:57 +0000
treeherdermozilla-beta@bf8644a5c52a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersderf, abillings
bugs1123882
milestone36.0
Bug 1123882 - Fix case where offset != 0. r=derf, a=abillings
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -352,27 +352,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;
   aOutput->ApplyVolume(mVolume);
 }
 
 static void WriteVideoToMediaStream(MediaStream* aStream,
                                     layers::Image* aImage,
                                     int64_t aEndMicroseconds,
                                     int64_t aStartMicroseconds,
                                     const IntSize& aIntrinsicSize,