Backout 1abf4c88f8f1 (bug 793274) on suspicion of causing win pgo-only mochitest-1 media test timeouts

This commit is contained in:
Ed Morley 2013-01-16 10:44:06 +00:00
Родитель 55247edf86
Коммит 0ad8fd55a8
4 изменённых файлов: 14 добавлений и 96 удалений

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

@ -176,9 +176,6 @@ nsHTMLAudioElement::MozWriteAudio(const JS::Value& aData, JSContext* aCx, uint32
// AudioDataValue is 'float', but it's not worth it for this deprecated API. // AudioDataValue is 'float', but it's not worth it for this deprecated API.
nsAutoArrayPtr<AudioDataValue> audioData(new AudioDataValue[writeLen * mChannels]); nsAutoArrayPtr<AudioDataValue> audioData(new AudioDataValue[writeLen * mChannels]);
ConvertAudioSamples(frames, audioData.get(), writeLen * mChannels); ConvertAudioSamples(frames, audioData.get(), writeLen * mChannels);
if (!mAudioStream->IsStarted()) {
mAudioStream->Start();
}
nsresult rv = mAudioStream->Write(audioData.get(), writeLen); nsresult rv = mAudioStream->Write(audioData.get(), writeLen);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {

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

@ -59,8 +59,6 @@ class NativeAudioStream : public AudioStream
uint32_t Available(); uint32_t Available();
void SetVolume(double aVolume); void SetVolume(double aVolume);
void Drain(); void Drain();
nsresult Start();
bool IsStarted();
void Pause(); void Pause();
void Resume(); void Resume();
int64_t GetPosition(); int64_t GetPosition();
@ -183,7 +181,6 @@ AudioStream::AudioStream()
: mInRate(0), : mInRate(0),
mOutRate(0), mOutRate(0),
mChannels(0), mChannels(0),
mWritten(0),
mAudioClock(this) mAudioClock(this)
{} {}
@ -279,11 +276,6 @@ nsresult AudioStream::SetPreservesPitch(bool aPreservesPitch)
return NS_OK; return NS_OK;
} }
int64_t AudioStream::GetWritten()
{
return mWritten;
}
NativeAudioStream::NativeAudioStream() : NativeAudioStream::NativeAudioStream() :
mVolume(1.0), mVolume(1.0),
mAudioHandle(0), mAudioHandle(0),
@ -394,8 +386,6 @@ nsresult NativeAudioStream::Write(const AudioDataValue* aBuf, uint32_t aFrames)
written = WriteToBackend(aBuf, samples); written = WriteToBackend(aBuf, samples);
} }
mWritten += aFrames;
if (written == -1) { if (written == -1) {
PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("NativeAudioStream: sa_stream_write error")); PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("NativeAudioStream: sa_stream_write error"));
mInError = true; mInError = true;
@ -465,19 +455,6 @@ void NativeAudioStream::Drain()
} }
} }
nsresult NativeAudioStream::Start()
{
// Since sydneyaudio is a push API, the playback is started when enough frames
// have been written. Hence, Start() is a noop.
return NS_OK;
}
bool NativeAudioStream::IsStarted()
{
// See the comment for the |Start()| method.
return true;
}
void NativeAudioStream::Pause() void NativeAudioStream::Pause()
{ {
if (mInError) if (mInError)
@ -620,8 +597,6 @@ class BufferedAudioStream : public AudioStream
uint32_t Available(); uint32_t Available();
void SetVolume(double aVolume); void SetVolume(double aVolume);
void Drain(); void Drain();
nsresult Start();
bool IsStarted();
void Pause(); void Pause();
void Resume(); void Resume();
int64_t GetPosition(); int64_t GetPosition();
@ -807,19 +782,24 @@ BufferedAudioStream::Write(const AudioDataValue* aBuf, uint32_t aFrames)
src += available; src += available;
bytesToCopy -= available; bytesToCopy -= available;
if (bytesToCopy > 0) { if (mState != STARTED) {
// If we are not playing, but our buffer is full, start playing to make int r;
// room for soon-to-be-decoded data. {
if (!IsStarted()) {
MonitorAutoUnlock mon(mMonitor); MonitorAutoUnlock mon(mMonitor);
Start(); r = cubeb_stream_start(mCubebStream);
} }
mState = r == CUBEB_OK ? STARTED : ERRORED;
}
if (mState != STARTED) {
return NS_ERROR_FAILURE;
}
if (bytesToCopy > 0) {
mon.Wait(); mon.Wait();
} }
} }
mWritten += aFrames;
return NS_OK; return NS_OK;
} }
@ -858,26 +838,6 @@ BufferedAudioStream::Drain()
} }
} }
nsresult
BufferedAudioStream::Start()
{
if (!mCubebStream) {
return NS_ERROR_FAILURE;
}
if (mState != STARTED) {
int r = cubeb_stream_start(mCubebStream);
mState = r == CUBEB_OK ? STARTED : ERRORED;
return mState == STARTED ? NS_OK : NS_ERROR_FAILURE;
}
return NS_OK;
}
bool
BufferedAudioStream::IsStarted()
{
return mState == STARTED ? true : false;
}
void void
BufferedAudioStream::Pause() BufferedAudioStream::Pause()
{ {

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

@ -44,8 +44,6 @@ class AudioClock
// Get the current pitch preservation state. // Get the current pitch preservation state.
// Called on the audio thread. // Called on the audio thread.
bool GetPreservesPitch(); bool GetPreservesPitch();
// Get the number of frames written to the backend.
int64_t GetWritten();
private: private:
// This AudioStream holds a strong reference to this AudioClock. This // This AudioStream holds a strong reference to this AudioClock. This
// pointer is garanteed to always be valid. // pointer is garanteed to always be valid.
@ -130,20 +128,10 @@ public:
// Block until buffered audio data has been consumed. // Block until buffered audio data has been consumed.
virtual void Drain() = 0; virtual void Drain() = 0;
// Start the stream. // Pause audio playback
virtual nsresult Start() = 0;
// Check if the stream is started.
virtual bool IsStarted() = 0;
// Return the number of frames written so far in the stream. This allow the
// caller to check if it is safe to start the stream, if needed.
virtual int64_t GetWritten();
// Pause audio playback.
virtual void Pause() = 0; virtual void Pause() = 0;
// Resume audio playback. // Resume audio playback
virtual void Resume() = 0; virtual void Resume() = 0;
// Return the position in microseconds of the audio frame being played by // Return the position in microseconds of the audio frame being played by
@ -183,8 +171,6 @@ protected:
// Output rate in Hz (characteristic of the playback rate) // Output rate in Hz (characteristic of the playback rate)
int mOutRate; int mOutRate;
int mChannels; int mChannels;
// Number of frames written to the buffers.
int64_t mWritten;
AudioClock mAudioClock; AudioClock mAudioClock;
nsAutoPtr<soundtouch::SoundTouch> mTimeStretcher; nsAutoPtr<soundtouch::SoundTouch> mTimeStretcher;
}; };

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

@ -109,9 +109,6 @@ static const uint32_t QUICK_BUFFERING_LOW_DATA_USECS = 1000000;
// QUICK_BUFFERING_LOW_DATA_USECS. // QUICK_BUFFERING_LOW_DATA_USECS.
PR_STATIC_ASSERT(QUICK_BUFFERING_LOW_DATA_USECS <= AMPLE_AUDIO_USECS); PR_STATIC_ASSERT(QUICK_BUFFERING_LOW_DATA_USECS <= AMPLE_AUDIO_USECS);
// This value has been chosen empirically.
static const uint32_t AUDIOSTREAM_MIN_WRITE_BEFORE_START_USECS = 200000;
static TimeDuration UsecsToDuration(int64_t aUsecs) { static TimeDuration UsecsToDuration(int64_t aUsecs) {
return TimeDuration::FromMilliseconds(static_cast<double>(aUsecs) / USECS_PER_MS); return TimeDuration::FromMilliseconds(static_cast<double>(aUsecs) / USECS_PER_MS);
} }
@ -955,19 +952,6 @@ bool MediaDecoderStateMachine::IsPlaying()
return !mPlayStartTime.IsNull(); return !mPlayStartTime.IsNull();
} }
// If we have already written enough frames to the AudioStream, start the
// playback.
static void
StartAudioStreamPlaybackIfNeeded(AudioStream* aStream)
{
// We want to have enough data in the buffer to start the stream.
if (!aStream->IsStarted() &&
static_cast<double>(aStream->GetWritten()) / aStream->GetRate() >=
static_cast<double>(AUDIOSTREAM_MIN_WRITE_BEFORE_START_USECS) / USECS_PER_S) {
aStream->Start();
}
}
static void WriteSilence(AudioStream* aStream, uint32_t aFrames) static void WriteSilence(AudioStream* aStream, uint32_t aFrames)
{ {
uint32_t numSamples = aFrames * aStream->GetChannels(); uint32_t numSamples = aFrames * aStream->GetChannels();
@ -975,8 +959,6 @@ static void WriteSilence(AudioStream* aStream, uint32_t aFrames)
buf.SetLength(numSamples); buf.SetLength(numSamples);
memset(buf.Elements(), 0, numSamples * sizeof(AudioDataValue)); memset(buf.Elements(), 0, numSamples * sizeof(AudioDataValue));
aStream->Write(buf.Elements(), aFrames); aStream->Write(buf.Elements(), aFrames);
StartAudioStreamPlaybackIfNeeded(aStream);
} }
void MediaDecoderStateMachine::AudioLoop() void MediaDecoderStateMachine::AudioLoop()
@ -1126,11 +1108,6 @@ void MediaDecoderStateMachine::AudioLoop()
mState != DECODER_STATE_SHUTDOWN && mState != DECODER_STATE_SHUTDOWN &&
!mStopAudioThread) !mStopAudioThread)
{ {
// If the media was too short to trigger the start of the audio stream,
// start it now.
if (!mAudioStream->IsStarted()) {
mAudioStream->Start();
}
// Last frame pushed to audio hardware, wait for the audio to finish, // Last frame pushed to audio hardware, wait for the audio to finish,
// before the audio thread terminates. // before the audio thread terminates.
bool seeking = false; bool seeking = false;
@ -1235,8 +1212,6 @@ uint32_t MediaDecoderStateMachine::PlayFromAudioQueue(uint64_t aFrameOffset,
mAudioStream->Write(audio->mAudioData, mAudioStream->Write(audio->mAudioData,
audio->mFrames); audio->mFrames);
StartAudioStreamPlaybackIfNeeded(mAudioStream);
offset = audio->mOffset; offset = audio->mOffset;
frames = audio->mFrames; frames = audio->mFrames;