Bug 557432 - Lock the audio stream while getting it's played duration. r=doublec

This commit is contained in:
Chris Pearce 2010-04-08 20:16:02 +12:00
Родитель f6828d92da
Коммит d2bef555bd
1 изменённых файлов: 11 добавлений и 4 удалений

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

@ -933,8 +933,8 @@ nsresult nsOggPlayStateMachine::Run()
AdvanceFrame();
}
if (mAudioStream) {
// Close the audop stream so that next time audio is used a new stream
if (HasAudio()) {
// Close the audio stream so that next time audio is used a new stream
// is created. The StopPlayback call also resets the IsPlaying() state
// so audio is restarted correctly.
StopPlayback(AUDIO_SHUTDOWN);
@ -1125,9 +1125,16 @@ PRInt64
nsOggPlayStateMachine::GetAudioClock()
{
NS_ASSERTION(IsThread(mDecoder->mStateMachineThread), "Should be on state machine thread.");
if (!mAudioStream || !HasAudio())
if (!HasAudio())
return -1;
PRInt64 t = mAudioStream->GetPosition();
PRInt64 t;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
MonitorAutoEnter audioMon(mAudioMonitor);
if (!mAudioStream)
return -1;
t = mAudioStream->GetPosition();
}
return (t == -1) ? -1 : t + mAudioStartTime;
}