mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
Reset the value to AUDIO_DURATION_USECS or re-calculate if the remainingTime is negtive. Schedule the state machine at the first video sample pushed into the queue
This commit is contained in:
@@ -1051,6 +1051,17 @@ MediaDecoderStateMachine::OnVideoDecoded(VideoData* aVideoSample)
|
||||
StopPrerollingVideo();
|
||||
}
|
||||
|
||||
// Schedule the state machine to send stream data as soon as possible or
|
||||
// the VideoQueue() is empty before the Push().
|
||||
// VideoQueue() is empty implies the state machine thread doesn't have
|
||||
// precise time information about video frames. Once the first video
|
||||
// frame pushed in the queue, schedule the state machine as soon as
|
||||
// possible to render the video frame or delay the state machine thread
|
||||
// accurately.
|
||||
if (mAudioCaptured || VideoQueue().GetSize() == 1) {
|
||||
ScheduleStateMachine();
|
||||
}
|
||||
|
||||
// For non async readers, if the requested video sample was slow to
|
||||
// arrive, increase the amount of audio we buffer to ensure that we
|
||||
// don't run out of audio. This is unnecessary for async readers,
|
||||
@@ -1070,11 +1081,6 @@ MediaDecoderStateMachine::OnVideoDecoded(VideoData* aVideoSample)
|
||||
DECODER_LOG("Slow video decode, set mLowAudioThresholdUsecs=%lld mAmpleAudioThresholdUsecs=%lld",
|
||||
mLowAudioThresholdUsecs, mAmpleAudioThresholdUsecs);
|
||||
}
|
||||
|
||||
// Schedule the state machine to send stream data as soon as possible.
|
||||
if (mAudioCaptured) {
|
||||
ScheduleStateMachine();
|
||||
}
|
||||
return;
|
||||
}
|
||||
case DECODER_STATE_SEEKING: {
|
||||
@@ -2977,9 +2983,7 @@ void MediaDecoderStateMachine::AdvanceFrame()
|
||||
// Current frame has already been presented, wait until it's time to
|
||||
// present the next frame.
|
||||
if (frame && !currentFrame) {
|
||||
int64_t now = IsPlaying() ? clock_time : mStartTime + mPlayDuration;
|
||||
|
||||
remainingTime = frame->mTime - now;
|
||||
remainingTime = frame->mTime - clock_time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3059,6 +3063,22 @@ void MediaDecoderStateMachine::AdvanceFrame()
|
||||
currentFrame = nullptr;
|
||||
}
|
||||
|
||||
// The remainingTime is negative (include zero):
|
||||
// 1. When the clock_time is larger than the latest video frame's endtime.
|
||||
// All the video frames should be rendered or dropped, nothing left in
|
||||
// VideoQueue. And since the VideoQueue is empty, we don't need to wake up
|
||||
// statemachine thread immediately, so set the remainingTime to default value.
|
||||
// 2. Current frame's endtime is smaller than clock_time but there still exist
|
||||
// newer frames in queue. Re-calculate the remainingTime.
|
||||
if (remainingTime <= 0) {
|
||||
VideoData* nextFrame = VideoQueue().PeekFront();
|
||||
if (nextFrame) {
|
||||
remainingTime = nextFrame->mTime - clock_time;
|
||||
} else {
|
||||
remainingTime = AUDIO_DURATION_USECS;
|
||||
}
|
||||
}
|
||||
|
||||
int64_t delay = remainingTime / mPlaybackRate;
|
||||
if (delay > 0) {
|
||||
ScheduleStateMachineIn(delay);
|
||||
|
||||
Reference in New Issue
Block a user