b=463968 test_wav_ended1.html can fail on slow machines with no audio hardware. r+sr=roc

This commit is contained in:
Matthew Gregan 2008-11-11 11:45:09 +13:00
Родитель e75fbc9baf
Коммит f259195e79
2 изменённых файлов: 15 добавлений и 2 удалений

Просмотреть файл

@ -41,6 +41,7 @@
#include "prmem.h"
#include "nsAutoPtr.h"
#include "nsAudioStream.h"
#include "nsAlgorithm.h"
extern "C" {
#include "sydneyaudio/sydney_audio.h"
}
@ -255,8 +256,14 @@ double nsAudioStream::GetTime()
{
// If the audio backend failed to open, emulate the current playback
// position using the system clock.
if (!mAudioHandle)
return mPaused ? mPauseTime : CurrentTimeInSeconds() - mStartTime;
if (!mAudioHandle) {
if (mPaused) {
return mPauseTime;
}
float curTime = CurrentTimeInSeconds() - mStartTime;
float maxTime = float(mSamplesBuffered) / mRate / mChannels;
return NS_MIN(curTime, maxTime);
}
int64_t bytes = 0;
#if defined(WIN32)

Просмотреть файл

@ -606,8 +606,14 @@ nsWaveStateMachine::Run()
monitor.Exit();
mAudioStream->Drain();
monitor.Enter();
mTimeOffset = mAudioStream->GetTime();
}
// Dispose the audio stream early (before SHUTDOWN) so that
// GetCurrentTime no longer attempts to query the audio backend for
// stream time.
CloseAudioStream();
if (mState != STATE_SHUTDOWN) {
nsCOMPtr<nsIRunnable> event =
NS_NEW_RUNNABLE_METHOD(nsWaveDecoder, mDecoder, PlaybackEnded);