summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
authortrav90 <travawine@openmailbox.org>2017-10-25 04:04:11 -0500
committertrav90 <travawine@openmailbox.org>2017-10-25 04:04:11 -0500
commita828d018f10b0c351d2ade1069b71df2e5ceeba4 (patch)
tree8e18d9b56d669f226142d87d908f291393153807 /dom
parent2f761baa85ef9efca8c0ff55ccb8604e7950a9e0 (diff)
downloadpalemoon-gre-a828d018f10b0c351d2ade1069b71df2e5ceeba4.tar.gz
Move MediaDecoder::UpdateStreamBlockingForPlayState to the MDSM
Diffstat (limited to 'dom')
-rw-r--r--dom/media/MediaDecoder.cpp20
-rw-r--r--dom/media/MediaDecoder.h2
-rw-r--r--dom/media/MediaDecoderStateMachine.cpp20
-rw-r--r--dom/media/MediaDecoderStateMachine.h4
4 files changed, 24 insertions, 22 deletions
diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp
index 561c057a3..bab636b7a 100644
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -300,21 +300,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)
{
MOZ_ASSERT(NS_IsMainThread());
@@ -322,7 +307,6 @@ void MediaDecoder::RecreateDecodedStream(int64_t aStartTimeUSecs)
DECODER_LOG("RecreateDecodedStream aStartTimeUSecs=%lld!", aStartTimeUSecs);
mDecodedStream.RecreateData(aStartTimeUSecs, MediaStreamGraph::GetInstance());
- UpdateStreamBlockingForPlayState();
}
void MediaDecoder::AddOutputStream(ProcessedMediaStream* aStream,
@@ -612,7 +596,6 @@ nsresult MediaDecoder::Seek(double aTime, SeekTarget::Type aSeekType)
mWasEndedWhenEnteredDormant = false;
mLogicallySeeking = true;
- UpdateStreamBlockingForPlayState();
SeekTarget target = SeekTarget(timeUsecs, aSeekType);
CallSeek(target);
@@ -1033,7 +1016,6 @@ void MediaDecoder::OnSeekResolved(SeekResolveValue aVal)
ChangeState(PLAY_STATE_ENDED);
}
mLogicallySeeking = false;
- UpdateStreamBlockingForPlayState();
}
UpdateLogicalPosition(aVal.mEventVisibility);
@@ -1079,8 +1061,6 @@ void MediaDecoder::ChangeState(PlayState aState)
gPlayStateStr[mPlayState], gPlayStateStr[aState]);
mPlayState = aState;
- UpdateStreamBlockingForPlayState();
-
if (mPlayState == PLAY_STATE_PLAYING) {
ConstructMediaTracks();
} else if (IsEnded()) {
diff --git a/dom/media/MediaDecoder.h b/dom/media/MediaDecoder.h
index abaa9d7b5..e4685552c 100644
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -391,8 +391,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.
diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp
index 227453acf..faaee9b57 100644
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -325,6 +325,8 @@ MediaDecoderStateMachine::InitializationTask()
mWatchManager.Watch(mObservedDuration, &MediaDecoderStateMachine::RecomputeDuration);
mWatchManager.Watch(mPlayState, &MediaDecoderStateMachine::PlayStateChanged);
mWatchManager.Watch(mLogicallySeeking, &MediaDecoderStateMachine::LogicallySeekingChanged);
+ mWatchManager.Watch(mPlayState, &MediaDecoderStateMachine::UpdateStreamBlockingForPlayState);
+ mWatchManager.Watch(mLogicallySeeking, &MediaDecoderStateMachine::UpdateStreamBlockingForPlayState);
}
bool MediaDecoderStateMachine::HasFutureAudio() {
@@ -483,6 +485,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);
}
@@ -3523,6 +3526,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();
diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h
index 9a14dee2f..0bd04446e 100644
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -163,6 +163,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();