mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1163467. Part 5 - move MediaDecoder::UpdateStreamBlockingForPlayState to MediaDecoderStateMachine. r=roc.
This commit is contained in:
parent
9b90b4d877
commit
c8a8f06a79
@ -289,20 +289,6 @@ void MediaDecoder::SetVolume(double aVolume)
|
||||
mVolume = aVolume;
|
||||
}
|
||||
|
||||
void MediaDecoder::UpdateStreamBlockingForPlayState()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
GetReentrantMonitor().AssertCurrentThreadIn();
|
||||
|
||||
auto s = GetDecodedStream();
|
||||
if (s) {
|
||||
bool blockForPlayState = mPlayState != PLAY_STATE_PLAYING || mLogicallySeeking;
|
||||
if (s->mHaveBlockedForPlayState != blockForPlayState) {
|
||||
s->mStream->ChangeExplicitBlockerCount(blockForPlayState ? 1 : -1);
|
||||
s->mHaveBlockedForPlayState = blockForPlayState;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MediaDecoder::RecreateDecodedStream(int64_t aStartTimeUSecs,
|
||||
MediaStreamGraph* aGraph)
|
||||
@ -310,9 +296,7 @@ void MediaDecoder::RecreateDecodedStream(int64_t aStartTimeUSecs,
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||
DECODER_LOG("RecreateDecodedStream aStartTimeUSecs=%lld!", aStartTimeUSecs);
|
||||
|
||||
mDecodedStream.RecreateData(aStartTimeUSecs, aGraph);
|
||||
UpdateStreamBlockingForPlayState();
|
||||
}
|
||||
|
||||
void MediaDecoder::AddOutputStream(ProcessedMediaStream* aStream,
|
||||
@ -599,7 +583,6 @@ nsresult MediaDecoder::Seek(double aTime, SeekTarget::Type aSeekType)
|
||||
mWasEndedWhenEnteredDormant = false;
|
||||
|
||||
mLogicallySeeking = true;
|
||||
UpdateStreamBlockingForPlayState();
|
||||
SeekTarget target = SeekTarget(timeUsecs, aSeekType);
|
||||
CallSeek(target);
|
||||
|
||||
@ -1019,7 +1002,6 @@ void MediaDecoder::OnSeekResolved(SeekResolveValue aVal)
|
||||
ChangeState(PLAY_STATE_ENDED);
|
||||
}
|
||||
mLogicallySeeking = false;
|
||||
UpdateStreamBlockingForPlayState();
|
||||
}
|
||||
|
||||
UpdateLogicalPosition(aVal.mEventVisibility);
|
||||
@ -1065,8 +1047,6 @@ void MediaDecoder::ChangeState(PlayState aState)
|
||||
gPlayStateStr[mPlayState], gPlayStateStr[aState]);
|
||||
mPlayState = aState;
|
||||
|
||||
UpdateStreamBlockingForPlayState();
|
||||
|
||||
if (mPlayState == PLAY_STATE_PLAYING) {
|
||||
ConstructMediaTracks();
|
||||
} else if (IsEnded()) {
|
||||
|
@ -395,8 +395,6 @@ public:
|
||||
// replaying after the input as ended. In the latter case, the new source is
|
||||
// not connected to streams created by captureStreamUntilEnded.
|
||||
|
||||
void UpdateStreamBlockingForPlayState();
|
||||
|
||||
/**
|
||||
* Recreates mDecodedStream. Call this to create mDecodedStream at first,
|
||||
* and when seeking, to ensure a new stream is set up with fresh buffers.
|
||||
|
@ -308,6 +308,8 @@ MediaDecoderStateMachine::InitializationTask()
|
||||
mWatchManager.Watch(mPreservesPitch, &MediaDecoderStateMachine::PreservesPitchChanged);
|
||||
mWatchManager.Watch(mPlayState, &MediaDecoderStateMachine::PlayStateChanged);
|
||||
mWatchManager.Watch(mLogicallySeeking, &MediaDecoderStateMachine::LogicallySeekingChanged);
|
||||
mWatchManager.Watch(mPlayState, &MediaDecoderStateMachine::UpdateStreamBlockingForPlayState);
|
||||
mWatchManager.Watch(mLogicallySeeking, &MediaDecoderStateMachine::UpdateStreamBlockingForPlayState);
|
||||
}
|
||||
|
||||
bool MediaDecoderStateMachine::HasFutureAudio()
|
||||
@ -479,6 +481,7 @@ void MediaDecoderStateMachine::SendStreamData()
|
||||
|
||||
// Make sure stream blocking is updated before sending stream data so we
|
||||
// don't 'leak' data when the stream is supposed to be blocked.
|
||||
UpdateStreamBlockingForPlayState();
|
||||
UpdateStreamBlockingForStateMachinePlaying();
|
||||
UpdateStreamBlocking(mediaStream, false);
|
||||
}
|
||||
@ -3520,6 +3523,23 @@ void MediaDecoderStateMachine::DispatchAudioCaptured()
|
||||
TaskQueue()->Dispatch(r.forget());
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::UpdateStreamBlockingForPlayState()
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
|
||||
auto stream = mDecoder->GetDecodedStream();
|
||||
if (!stream) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool blocking = mPlayState != MediaDecoder::PLAY_STATE_PLAYING ||
|
||||
mLogicallySeeking;
|
||||
if (blocking != stream->mHaveBlockedForPlayState) {
|
||||
stream->mHaveBlockedForPlayState = blocking;
|
||||
UpdateStreamBlocking(stream->mStream, blocking);
|
||||
}
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::UpdateStreamBlockingForStateMachinePlaying()
|
||||
{
|
||||
AssertCurrentThreadInMonitor();
|
||||
|
@ -158,6 +158,10 @@ private:
|
||||
// constructor immediately after the task queue is created.
|
||||
void InitializationTask();
|
||||
|
||||
// Update blocking state of mDecodedStream when mPlayState or
|
||||
// mLogicallySeeking change. Decoder monitor must be held.
|
||||
void UpdateStreamBlockingForPlayState();
|
||||
|
||||
// Call this IsPlaying() changes. Decoder monitor must be held.
|
||||
void UpdateStreamBlockingForStateMachinePlaying();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user