Bug 844951 - Setting playbackRate and mozPreservesPitch before the decoder creation should work. r=kinetik
authorPaul Adenot <paul@paul.cx>
Tue, 26 Feb 2013 09:52:23 +0100
changeset 122999 0d0eadfaa41ddf4382a2e43046b8bf1920c0020a
parent 122998 2d843af0b0c79fc68ba14c8e08c7b2776e0be33b
child 123000 7ec9cda146fb1a015ee2714e67a3adcaecc399c8
push id1387
push userphilringnalda@gmail.com
push dateTue, 26 Feb 2013 22:32:56 +0000
treeherderfx-team@ad4cc4e97774 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs844951
milestone22.0a1
Bug 844951 - Setting playbackRate and mozPreservesPitch before the decoder creation should work. r=kinetik
content/html/content/src/nsHTMLMediaElement.cpp
content/media/MediaDecoder.cpp
content/media/MediaDecoder.h
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -2354,16 +2354,19 @@ nsresult nsHTMLMediaElement::FinishDecod
   // The new stream has not been suspended by us.
   mPausedForInactiveDocumentOrChannel = false;
   mEventDeliveryPaused = false;
   mPendingEvents.Clear();
 
   aDecoder->SetAudioChannelType(mAudioChannelType);
   aDecoder->SetAudioCaptured(mAudioCaptured);
   aDecoder->SetVolume(mMuted ? 0.0 : mVolume);
+  aDecoder->SetPreservesPitch(mPreservesPitch);
+  aDecoder->SetPlaybackRate(mPlaybackRate);
+
   for (uint32_t i = 0; i < mOutputStreams.Length(); ++i) {
     OutputMediaStream* ms = &mOutputStreams[i];
     aDecoder->AddOutputStream(ms->mStream->GetStream()->AsProcessedStream(),
         ms->mFinishWhenEnded);
   }
 
   nsresult rv = aDecoder->Load(aStream, aListener, aCloneDonor);
   if (NS_FAILED(rv)) {
--- a/content/media/MediaDecoder.cpp
+++ b/content/media/MediaDecoder.cpp
@@ -322,16 +322,18 @@ bool MediaDecoder::IsInfinite()
   return mInfiniteStream;
 }
 
 MediaDecoder::MediaDecoder() :
   mDecoderPosition(0),
   mPlaybackPosition(0),
   mCurrentTime(0.0),
   mInitialVolume(0.0),
+  mInitialPlaybackRate(1.0),
+  mInitialPreservesPitch(true),
   mRequestedSeekTime(-1.0),
   mDuration(-1),
   mTransportSeekable(true),
   mMediaSeekable(true),
   mReentrantMonitor("media.decoder"),
   mPlayState(PLAY_STATE_PAUSED),
   mNextState(PLAY_STATE_PAUSED),
   mCalledResourceLoaded(false),
@@ -463,16 +465,18 @@ nsresult MediaDecoder::InitializeStateMa
   }
   {
     ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
     mDecoderStateMachine->SetTransportSeekable(mTransportSeekable);
     mDecoderStateMachine->SetMediaSeekable(mMediaSeekable);
     mDecoderStateMachine->SetDuration(mDuration);
     mDecoderStateMachine->SetVolume(mInitialVolume);
     mDecoderStateMachine->SetAudioCaptured(mInitialAudioCaptured);
+    SetPlaybackRate(mInitialPlaybackRate);
+    mDecoderStateMachine->SetPreservesPitch(mInitialPreservesPitch);
 
     if (mFrameBufferLength > 0) {
       // The valid mFrameBufferLength value was specified earlier
       mDecoderStateMachine->SetFrameBufferLength(mFrameBufferLength);
     }
   }
 
   ChangeState(PLAY_STATE_LOADING);
@@ -1396,23 +1400,27 @@ void MediaDecoder::SetPlaybackRate(doubl
     if (mOwner && !mOwner->GetPaused()) {
       Play();
     }
     mPausedForPlaybackRateNull = false;
   }
 
   if (mDecoderStateMachine) {
     mDecoderStateMachine->SetPlaybackRate(aPlaybackRate);
+  } else {
+    mInitialPlaybackRate = aPlaybackRate;
   }
 }
 
 void MediaDecoder::SetPreservesPitch(bool aPreservesPitch)
 {
   if (mDecoderStateMachine) {
     mDecoderStateMachine->SetPreservesPitch(aPreservesPitch);
+  } else {
+    mInitialPreservesPitch = aPreservesPitch;
   }
 }
 
 bool MediaDecoder::OnDecodeThread() const {
   NS_WARN_IF_FALSE(mDecoderStateMachine, "mDecoderStateMachine is null");
   return mDecoderStateMachine ? mDecoderStateMachine->OnDecodeThread() : false;
 }
 
--- a/content/media/MediaDecoder.h
+++ b/content/media/MediaDecoder.h
@@ -896,16 +896,21 @@ public:
   // video (if it is a video) or the callback period of the audio.
   // It is read and written from the main thread only.
   double mCurrentTime;
 
   // Volume that playback should start at.  0.0 = muted. 1.0 = full
   // volume.  Readable/Writeable from the main thread.
   double mInitialVolume;
 
+  // PlaybackRate and pitch preservation status we should start at.
+  // Readable/Writeable from the main thread.
+  double mInitialPlaybackRate;
+  bool mInitialPreservesPitch;
+
   // Position to seek to when the seek notification is received by the
   // decode thread. Written by the main thread and read via the
   // decode thread. Synchronised using mReentrantMonitor. If the
   // value is negative then no seek has been requested. When a seek is
   // started this is reset to negative.
   double mRequestedSeekTime;
 
   // Duration of the media resource. Set to -1 if unknown.