Bug 844951 - Setting playbackRate and mozPreservesPitch before the decoder creation should work. r=kinetik

This commit is contained in:
Paul Adenot 2013-02-26 09:52:23 +01:00
parent 4f2efc2090
commit e3f9f4377e
3 changed files with 16 additions and 0 deletions

View File

@ -2359,6 +2359,9 @@ nsresult nsHTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder,
aDecoder->SetAudioChannelType(mAudioChannelType); aDecoder->SetAudioChannelType(mAudioChannelType);
aDecoder->SetAudioCaptured(mAudioCaptured); aDecoder->SetAudioCaptured(mAudioCaptured);
aDecoder->SetVolume(mMuted ? 0.0 : mVolume); aDecoder->SetVolume(mMuted ? 0.0 : mVolume);
aDecoder->SetPreservesPitch(mPreservesPitch);
aDecoder->SetPlaybackRate(mPlaybackRate);
for (uint32_t i = 0; i < mOutputStreams.Length(); ++i) { for (uint32_t i = 0; i < mOutputStreams.Length(); ++i) {
OutputMediaStream* ms = &mOutputStreams[i]; OutputMediaStream* ms = &mOutputStreams[i];
aDecoder->AddOutputStream(ms->mStream->GetStream()->AsProcessedStream(), aDecoder->AddOutputStream(ms->mStream->GetStream()->AsProcessedStream(),

View File

@ -327,6 +327,8 @@ MediaDecoder::MediaDecoder() :
mPlaybackPosition(0), mPlaybackPosition(0),
mCurrentTime(0.0), mCurrentTime(0.0),
mInitialVolume(0.0), mInitialVolume(0.0),
mInitialPlaybackRate(1.0),
mInitialPreservesPitch(true),
mRequestedSeekTime(-1.0), mRequestedSeekTime(-1.0),
mDuration(-1), mDuration(-1),
mTransportSeekable(true), mTransportSeekable(true),
@ -468,6 +470,8 @@ nsresult MediaDecoder::InitializeStateMachine(MediaDecoder* aCloneDonor)
mDecoderStateMachine->SetDuration(mDuration); mDecoderStateMachine->SetDuration(mDuration);
mDecoderStateMachine->SetVolume(mInitialVolume); mDecoderStateMachine->SetVolume(mInitialVolume);
mDecoderStateMachine->SetAudioCaptured(mInitialAudioCaptured); mDecoderStateMachine->SetAudioCaptured(mInitialAudioCaptured);
SetPlaybackRate(mInitialPlaybackRate);
mDecoderStateMachine->SetPreservesPitch(mInitialPreservesPitch);
if (mFrameBufferLength > 0) { if (mFrameBufferLength > 0) {
// The valid mFrameBufferLength value was specified earlier // The valid mFrameBufferLength value was specified earlier
@ -1401,6 +1405,8 @@ void MediaDecoder::SetPlaybackRate(double aPlaybackRate)
if (mDecoderStateMachine) { if (mDecoderStateMachine) {
mDecoderStateMachine->SetPlaybackRate(aPlaybackRate); mDecoderStateMachine->SetPlaybackRate(aPlaybackRate);
} else {
mInitialPlaybackRate = aPlaybackRate;
} }
} }
@ -1408,6 +1414,8 @@ void MediaDecoder::SetPreservesPitch(bool aPreservesPitch)
{ {
if (mDecoderStateMachine) { if (mDecoderStateMachine) {
mDecoderStateMachine->SetPreservesPitch(aPreservesPitch); mDecoderStateMachine->SetPreservesPitch(aPreservesPitch);
} else {
mInitialPreservesPitch = aPreservesPitch;
} }
} }

View File

@ -901,6 +901,11 @@ public:
// volume. Readable/Writeable from the main thread. // volume. Readable/Writeable from the main thread.
double mInitialVolume; 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 // 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. Written by the main thread and read via the
// decode thread. Synchronised using mReentrantMonitor. If the // decode thread. Synchronised using mReentrantMonitor. If the