Bug 496456. When we seek to the end, we should only fire end stuff if we're not playing, otherwise playing should be responsible for ending. Set the current frame time at the end of the stream to the duration, if it's longer than our end time estimate, because the duration can include more than one frame-time's worth of audio. Also, don't replicate a frame of audio in DecodeToFrame when seeking. r=cpearce,sr=roc

--HG--
extra : rebase_source : e34cc28482e2b0ced5ec0774ce73865501400ca6
This commit is contained in:
Chris Double 2009-06-12 14:14:28 +12:00
parent 734ebb107c
commit 828918bcb5

View File

@ -1332,6 +1332,11 @@ void nsOggDecodeStateMachine::DecodeToFrame(nsAutoMonitor& aMonitor,
float audioTime = 0;
nsTArray<float> audioData;
do {
if (frame) {
audioData.AppendElements(frame->mAudioData);
audioTime += frame->mAudioData.Length() /
(float)mAudioRate / (float)mAudioChannels;
}
do {
aMonitor.Exit();
r = DecodeFrame();
@ -1349,10 +1354,6 @@ void nsOggDecodeStateMachine::DecodeToFrame(nsAutoMonitor& aMonitor,
delete frame;
frame = nextFrame;
audioData.AppendElements(frame->mAudioData);
audioTime += frame->mAudioData.Length() /
(float)mAudioRate / (float)mAudioChannels;
} while (frame->mDecodedFrameTime < target);
if (mState == DECODER_STATE_SHUTDOWN) {
@ -1737,6 +1738,9 @@ nsresult nsOggDecodeStateMachine::Run()
// Set the right current time
mCurrentFrameTime += mCallbackPeriod;
if (mDuration >= 0) {
mCurrentFrameTime = PR_MAX(mCurrentFrameTime, mDuration / 1000.0);
}
mon.Exit();
nsCOMPtr<nsIRunnable> event =
@ -2382,8 +2386,8 @@ void nsOggDecoder::SeekingStoppedAtEnd()
if (mRequestedSeekTime >= 0.0) {
ChangeState(PLAY_STATE_SEEKING);
} else {
ChangeState(PLAY_STATE_ENDED);
fireEnded = PR_TRUE;
fireEnded = mNextState != PLAY_STATE_PLAYING;
ChangeState(fireEnded ? PLAY_STATE_ENDED : mNextState);
}
}