From e3f9f4377e2a8a96a2f878309235b1c598a8534e Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Tue, 26 Feb 2013 09:52:23 +0100 Subject: [PATCH] Bug 844951 - Setting playbackRate and mozPreservesPitch before the decoder creation should work. r=kinetik --- content/html/content/src/nsHTMLMediaElement.cpp | 3 +++ content/media/MediaDecoder.cpp | 8 ++++++++ content/media/MediaDecoder.h | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp index aff18cf2535..3cc663cccde 100644 --- a/content/html/content/src/nsHTMLMediaElement.cpp +++ b/content/html/content/src/nsHTMLMediaElement.cpp @@ -2359,6 +2359,9 @@ nsresult nsHTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder, 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(), diff --git a/content/media/MediaDecoder.cpp b/content/media/MediaDecoder.cpp index 0010d8314b3..ac770fe27c8 100644 --- a/content/media/MediaDecoder.cpp +++ b/content/media/MediaDecoder.cpp @@ -327,6 +327,8 @@ MediaDecoder::MediaDecoder() : mPlaybackPosition(0), mCurrentTime(0.0), mInitialVolume(0.0), + mInitialPlaybackRate(1.0), + mInitialPreservesPitch(true), mRequestedSeekTime(-1.0), mDuration(-1), mTransportSeekable(true), @@ -468,6 +470,8 @@ nsresult MediaDecoder::InitializeStateMachine(MediaDecoder* aCloneDonor) mDecoderStateMachine->SetDuration(mDuration); mDecoderStateMachine->SetVolume(mInitialVolume); mDecoderStateMachine->SetAudioCaptured(mInitialAudioCaptured); + SetPlaybackRate(mInitialPlaybackRate); + mDecoderStateMachine->SetPreservesPitch(mInitialPreservesPitch); if (mFrameBufferLength > 0) { // The valid mFrameBufferLength value was specified earlier @@ -1401,6 +1405,8 @@ void MediaDecoder::SetPlaybackRate(double aPlaybackRate) if (mDecoderStateMachine) { mDecoderStateMachine->SetPlaybackRate(aPlaybackRate); + } else { + mInitialPlaybackRate = aPlaybackRate; } } @@ -1408,6 +1414,8 @@ void MediaDecoder::SetPreservesPitch(bool aPreservesPitch) { if (mDecoderStateMachine) { mDecoderStateMachine->SetPreservesPitch(aPreservesPitch); + } else { + mInitialPreservesPitch = aPreservesPitch; } } diff --git a/content/media/MediaDecoder.h b/content/media/MediaDecoder.h index 0466ef20b47..f11b5e36723 100644 --- a/content/media/MediaDecoder.h +++ b/content/media/MediaDecoder.h @@ -901,6 +901,11 @@ public: // 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