зеркало из https://github.com/mozilla/gecko-dev.git
Bug 589626 - Make video buffing logic consistent. r=kinetik a=blocking2.0
This commit is contained in:
Родитель
99ed5c183d
Коммит
c5fcd015fa
|
@ -164,7 +164,7 @@ PRBool nsBuiltinDecoderStateMachine::HasFutureAudio() const {
|
||||||
mDecoder->GetMonitor().AssertCurrentThreadIn();
|
mDecoder->GetMonitor().AssertCurrentThreadIn();
|
||||||
PRBool aboveLowAudioThreshold = PR_FALSE;
|
PRBool aboveLowAudioThreshold = PR_FALSE;
|
||||||
if (mAudioEndTime != -1) {
|
if (mAudioEndTime != -1) {
|
||||||
aboveLowAudioThreshold = mAudioEndTime - mCurrentFrameTime + mStartTime > LOW_AUDIO_MS;
|
aboveLowAudioThreshold = mAudioEndTime - GetMediaTime() > LOW_AUDIO_MS;
|
||||||
}
|
}
|
||||||
return HasAudio() &&
|
return HasAudio() &&
|
||||||
!mAudioCompleted &&
|
!mAudioCompleted &&
|
||||||
|
@ -259,7 +259,7 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
|
||||||
PRInt64 audioDecoded = 0;
|
PRInt64 audioDecoded = 0;
|
||||||
{
|
{
|
||||||
MonitorAutoEnter mon(mDecoder->GetMonitor());
|
MonitorAutoEnter mon(mDecoder->GetMonitor());
|
||||||
currentTime = mCurrentFrameTime + mStartTime;
|
currentTime = GetMediaTime();
|
||||||
audioDecoded = mReader->mAudioQueue.Duration();
|
audioDecoded = mReader->mAudioQueue.Duration();
|
||||||
if (mAudioEndTime != -1) {
|
if (mAudioEndTime != -1) {
|
||||||
audioDecoded += mAudioEndTime - currentTime;
|
audioDecoded += mAudioEndTime - currentTime;
|
||||||
|
@ -451,7 +451,7 @@ void nsBuiltinDecoderStateMachine::AudioLoop()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRInt64 audioAhead = mAudioEndTime - mCurrentFrameTime - mStartTime;
|
PRInt64 audioAhead = mAudioEndTime - GetMediaTime();
|
||||||
if (audioAhead > AMPLE_AUDIO_MS) {
|
if (audioAhead > AMPLE_AUDIO_MS) {
|
||||||
// We've pushed enough audio onto the hardware that we've queued up a
|
// We've pushed enough audio onto the hardware that we've queued up a
|
||||||
// significant amount ahead of the playback position. The decode
|
// significant amount ahead of the playback position. The decode
|
||||||
|
@ -653,7 +653,7 @@ void nsBuiltinDecoderStateMachine::UpdatePlaybackPosition(PRInt64 aTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify DOM of any queued up audioavailable events
|
// Notify DOM of any queued up audioavailable events
|
||||||
mEventManager.DispatchPendingEvents(mCurrentFrameTime + mStartTime);
|
mEventManager.DispatchPendingEvents(GetMediaTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsBuiltinDecoderStateMachine::ClearPositionChangeFlag()
|
void nsBuiltinDecoderStateMachine::ClearPositionChangeFlag()
|
||||||
|
@ -989,6 +989,7 @@ nsresult nsBuiltinDecoderStateMachine::Run()
|
||||||
StopPlayback(AUDIO_SHUTDOWN);
|
StopPlayback(AUDIO_SHUTDOWN);
|
||||||
StopDecodeThreads();
|
StopDecodeThreads();
|
||||||
ResetPlayback();
|
ResetPlayback();
|
||||||
|
PRInt64 currentTime = GetMediaTime();
|
||||||
nsresult res;
|
nsresult res;
|
||||||
{
|
{
|
||||||
MonitorAutoExit exitMon(mDecoder->GetMonitor());
|
MonitorAutoExit exitMon(mDecoder->GetMonitor());
|
||||||
|
@ -997,7 +998,7 @@ nsresult nsBuiltinDecoderStateMachine::Run()
|
||||||
res = mReader->Seek(seekTime,
|
res = mReader->Seek(seekTime,
|
||||||
mStartTime,
|
mStartTime,
|
||||||
mEndTime,
|
mEndTime,
|
||||||
mCurrentFrameTime + mStartTime);
|
currentTime);
|
||||||
}
|
}
|
||||||
if (NS_SUCCEEDED(res)){
|
if (NS_SUCCEEDED(res)){
|
||||||
PRInt64 audioTime = seekTime;
|
PRInt64 audioTime = seekTime;
|
||||||
|
@ -1035,7 +1036,7 @@ nsresult nsBuiltinDecoderStateMachine::Run()
|
||||||
// if we need to seek again.
|
// if we need to seek again.
|
||||||
|
|
||||||
nsCOMPtr<nsIRunnable> stopEvent;
|
nsCOMPtr<nsIRunnable> stopEvent;
|
||||||
if (mCurrentFrameTime == mEndTime) {
|
if (GetMediaTime() == mEndTime) {
|
||||||
LOG(PR_LOG_DEBUG, ("%p Changed state from SEEKING (to %lldms) to COMPLETED",
|
LOG(PR_LOG_DEBUG, ("%p Changed state from SEEKING (to %lldms) to COMPLETED",
|
||||||
mDecoder, seekTime));
|
mDecoder, seekTime));
|
||||||
stopEvent = NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::SeekingStoppedAtEnd);
|
stopEvent = NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::SeekingStoppedAtEnd);
|
||||||
|
|
|
@ -338,6 +338,16 @@ protected:
|
||||||
// be held.
|
// be held.
|
||||||
PRBool IsPlaying();
|
PRBool IsPlaying();
|
||||||
|
|
||||||
|
// Returns the "media time". This is the absolute time which the media
|
||||||
|
// playback has reached. i.e. this returns values in the range
|
||||||
|
// [mStartTime, mEndTime], and mStartTime will not be 0 if the media does
|
||||||
|
// not start at 0. Note this is different to the value returned
|
||||||
|
// by GetCurrentTime(), which is in the range [0,duration].
|
||||||
|
PRInt64 GetMediaTime() const {
|
||||||
|
mDecoder->GetMonitor().AssertCurrentThreadIn();
|
||||||
|
return mStartTime + mCurrentFrameTime;
|
||||||
|
}
|
||||||
|
|
||||||
// Monitor on mAudioStream. This monitor must be held in order to delete
|
// Monitor on mAudioStream. This monitor must be held in order to delete
|
||||||
// or use the audio stream. This stops us destroying the audio stream
|
// or use the audio stream. This stops us destroying the audio stream
|
||||||
// while it's being used on another thread (typically when it's being
|
// while it's being used on another thread (typically when it's being
|
||||||
|
|
Загрузка…
Ссылка в новой задаче