mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1109437 - Switch m{Audio,Video}RequestPending to a tri-state. r=cpearce
This commit is contained in:
parent
4166dff3db
commit
cdd1259acb
@ -203,8 +203,8 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
|
||||
mAmpleVideoFrames(2),
|
||||
mLowAudioThresholdUsecs(LOW_AUDIO_USECS),
|
||||
mAmpleAudioThresholdUsecs(AMPLE_AUDIO_USECS),
|
||||
mAudioRequestPending(false),
|
||||
mVideoRequestPending(false),
|
||||
mAudioRequestStatus(RequestStatus::Idle),
|
||||
mVideoRequestStatus(RequestStatus::Idle),
|
||||
mAudioCaptured(false),
|
||||
mPositionChangeQueued(false),
|
||||
mAudioCompleted(false),
|
||||
@ -628,7 +628,7 @@ MediaDecoderStateMachine::DecodeVideo()
|
||||
if (mState != DECODER_STATE_DECODING &&
|
||||
mState != DECODER_STATE_BUFFERING &&
|
||||
mState != DECODER_STATE_SEEKING) {
|
||||
mVideoRequestPending = false;
|
||||
mVideoRequestStatus = RequestStatus::Idle;
|
||||
DispatchDecodeTasksIfNeeded();
|
||||
return;
|
||||
}
|
||||
@ -688,7 +688,7 @@ MediaDecoderStateMachine::DecodeAudio()
|
||||
if (mState != DECODER_STATE_DECODING &&
|
||||
mState != DECODER_STATE_BUFFERING &&
|
||||
mState != DECODER_STATE_SEEKING) {
|
||||
mAudioRequestPending = false;
|
||||
mAudioRequestStatus = RequestStatus::Idle;
|
||||
DispatchDecodeTasksIfNeeded();
|
||||
mon.NotifyAll();
|
||||
return;
|
||||
@ -743,7 +743,7 @@ MediaDecoderStateMachine::OnAudioDecoded(AudioData* aAudioSample)
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
nsRefPtr<AudioData> audio(aAudioSample);
|
||||
MOZ_ASSERT(audio);
|
||||
mAudioRequestPending = false;
|
||||
mAudioRequestStatus = RequestStatus::Idle;
|
||||
mDecodedAudioEndTime = audio->GetEndTime();
|
||||
|
||||
SAMPLE_LOG("OnAudioDecoded [%lld,%lld] disc=%d",
|
||||
@ -855,11 +855,7 @@ MediaDecoderStateMachine::OnNotDecoded(MediaData::Type aType,
|
||||
MOZ_ASSERT_IF(!isAudio, aType == MediaData::VIDEO_DATA);
|
||||
|
||||
// This callback means that the pending request is dead.
|
||||
if (isAudio) {
|
||||
mAudioRequestPending = false;
|
||||
} else {
|
||||
mVideoRequestPending = false;
|
||||
}
|
||||
RequestStatusRef(aType) = RequestStatus::Idle;
|
||||
|
||||
// If this is a decode error, delegate to the generic error path.
|
||||
if (aReason == MediaDecoderReader::DECODE_ERROR) {
|
||||
@ -960,7 +956,7 @@ MediaDecoderStateMachine::OnVideoDecoded(VideoData* aVideoSample)
|
||||
MOZ_ASSERT(OnDecodeThread());
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
nsRefPtr<VideoData> video(aVideoSample);
|
||||
mVideoRequestPending = false;
|
||||
mVideoRequestStatus = RequestStatus::Idle;
|
||||
mDecodedVideoEndTime = video ? video->GetEndTime() : mDecodedVideoEndTime;
|
||||
|
||||
SAMPLE_LOG("OnVideoDecoded [%lld,%lld] disc=%d",
|
||||
@ -1777,9 +1773,9 @@ MediaDecoderStateMachine::DispatchDecodeTasksIfNeeded()
|
||||
!needToDecodeVideo &&
|
||||
!IsPlaying();
|
||||
|
||||
SAMPLE_LOG("DispatchDecodeTasksIfNeeded needAudio=%d dispAudio=%d needVideo=%d dispVid=%d needIdle=%d",
|
||||
needToDecodeAudio, mAudioRequestPending,
|
||||
needToDecodeVideo, mVideoRequestPending,
|
||||
SAMPLE_LOG("DispatchDecodeTasksIfNeeded needAudio=%d audioStatus=%d needVideo=%d videoStatus=%d needIdle=%d",
|
||||
needToDecodeAudio, mAudioRequestStatus,
|
||||
needToDecodeVideo, mVideoRequestStatus,
|
||||
needIdle);
|
||||
|
||||
if (needToDecodeAudio) {
|
||||
@ -1849,8 +1845,8 @@ MediaDecoderStateMachine::EnsureAudioDecodeTaskQueued()
|
||||
NS_ASSERTION(OnStateMachineThread() || OnDecodeThread(),
|
||||
"Should be on state machine or decode thread.");
|
||||
|
||||
SAMPLE_LOG("EnsureAudioDecodeTaskQueued isDecoding=%d dispatched=%d",
|
||||
IsAudioDecoding(), mAudioRequestPending);
|
||||
SAMPLE_LOG("EnsureAudioDecodeTaskQueued isDecoding=%d status=%d",
|
||||
IsAudioDecoding(), mAudioRequestStatus);
|
||||
|
||||
if (mState >= DECODER_STATE_COMPLETED) {
|
||||
return NS_OK;
|
||||
@ -1858,12 +1854,12 @@ MediaDecoderStateMachine::EnsureAudioDecodeTaskQueued()
|
||||
|
||||
MOZ_ASSERT(mState > DECODER_STATE_DECODING_FIRSTFRAME);
|
||||
|
||||
if (IsAudioDecoding() && !mAudioRequestPending && !mWaitingForDecoderSeek) {
|
||||
if (IsAudioDecoding() && mAudioRequestStatus == RequestStatus::Idle && !mWaitingForDecoderSeek) {
|
||||
RefPtr<nsIRunnable> task(
|
||||
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::DecodeAudio));
|
||||
nsresult rv = DecodeTaskQueue()->Dispatch(task);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mAudioRequestPending = true;
|
||||
mAudioRequestStatus = RequestStatus::Pending;
|
||||
} else {
|
||||
DECODER_WARN("Failed to dispatch task to decode audio");
|
||||
}
|
||||
@ -1891,8 +1887,8 @@ MediaDecoderStateMachine::EnsureVideoDecodeTaskQueued()
|
||||
{
|
||||
AssertCurrentThreadInMonitor();
|
||||
|
||||
SAMPLE_LOG("EnsureVideoDecodeTaskQueued isDecoding=%d dispatched=%d",
|
||||
IsVideoDecoding(), mVideoRequestPending);
|
||||
SAMPLE_LOG("EnsureVideoDecodeTaskQueued isDecoding=%d status=%d",
|
||||
IsVideoDecoding(), mVideoRequestStatus);
|
||||
|
||||
NS_ASSERTION(OnStateMachineThread() || OnDecodeThread(),
|
||||
"Should be on state machine or decode thread.");
|
||||
@ -1903,12 +1899,12 @@ MediaDecoderStateMachine::EnsureVideoDecodeTaskQueued()
|
||||
|
||||
MOZ_ASSERT(mState > DECODER_STATE_DECODING_FIRSTFRAME);
|
||||
|
||||
if (IsVideoDecoding() && !mVideoRequestPending && !mWaitingForDecoderSeek) {
|
||||
if (IsVideoDecoding() && mVideoRequestStatus == RequestStatus::Idle && !mWaitingForDecoderSeek) {
|
||||
RefPtr<nsIRunnable> task(
|
||||
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::DecodeVideo));
|
||||
nsresult rv = DecodeTaskQueue()->Dispatch(task);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mVideoRequestPending = true;
|
||||
mVideoRequestStatus = RequestStatus::Pending;
|
||||
} else {
|
||||
DECODER_WARN("Failed to dispatch task to decode video");
|
||||
}
|
||||
@ -2792,8 +2788,8 @@ MediaDecoderStateMachine::FlushDecoding()
|
||||
// These flags will be reset when the decoded data returned in OnAudioDecoded()
|
||||
// and OnVideoDecoded(). Because the decode tasks are flushed, these flags need
|
||||
// to be reset here.
|
||||
mAudioRequestPending = false;
|
||||
mVideoRequestPending = false;
|
||||
mAudioRequestStatus = RequestStatus::Idle;
|
||||
mVideoRequestStatus = RequestStatus::Idle;
|
||||
|
||||
// We must reset playback so that all references to frames queued
|
||||
// in the state machine are dropped, else subsequent calls to Shutdown()
|
||||
|
@ -919,11 +919,22 @@ protected:
|
||||
bool mIsAudioPrerolling;
|
||||
bool mIsVideoPrerolling;
|
||||
|
||||
MOZ_BEGIN_NESTED_ENUM_CLASS(RequestStatus)
|
||||
Idle,
|
||||
Pending,
|
||||
Waiting
|
||||
MOZ_END_NESTED_ENUM_CLASS(RequestStatus)
|
||||
|
||||
// True when we have dispatched a task to the decode task queue to request
|
||||
// decoded audio/video, and/or we are waiting for the requested sample to be
|
||||
// returned by callback from the Reader.
|
||||
bool mAudioRequestPending;
|
||||
bool mVideoRequestPending;
|
||||
RequestStatus mAudioRequestStatus;
|
||||
RequestStatus mVideoRequestStatus;
|
||||
|
||||
RequestStatus& RequestStatusRef(MediaData::Type aType)
|
||||
{
|
||||
return aType == MediaData::AUDIO_DATA ? mAudioRequestStatus : mVideoRequestStatus;
|
||||
}
|
||||
|
||||
// True if we shouldn't play our audio (but still write it to any capturing
|
||||
// streams). When this is true, mStopAudioThread is always true and
|
||||
|
Loading…
Reference in New Issue
Block a user