mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1189506. Convert ChangeExplicitBlockerCount to MediaStream::Suspend/Resume. r=padenot
This commit is contained in:
parent
6d97b30da4
commit
1f573122bc
@ -91,11 +91,6 @@ CameraPreviewMediaStream::RemoveVideoOutput(VideoFrameContainer* aContainer)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CameraPreviewMediaStream::ChangeExplicitBlockerCount(int32_t aDelta)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CameraPreviewMediaStream::AddListener(MediaStreamListener* aListener)
|
||||
{
|
||||
|
@ -48,7 +48,8 @@ public:
|
||||
virtual void RemoveAudioOutput(void* aKey) override;
|
||||
virtual void AddVideoOutput(VideoFrameContainer* aContainer) override;
|
||||
virtual void RemoveVideoOutput(VideoFrameContainer* aContainer) override;
|
||||
virtual void ChangeExplicitBlockerCount(int32_t aDelta) override;
|
||||
virtual void Suspend() override {}
|
||||
virtual void Resume() override {}
|
||||
virtual void AddListener(MediaStreamListener* aListener) override;
|
||||
virtual void RemoveListener(MediaStreamListener* aListener) override;
|
||||
virtual void Destroy() override;
|
||||
|
@ -407,7 +407,7 @@ public:
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
NS_ENSURE_TRUE(mTrackUnionStream, NS_ERROR_FAILURE);
|
||||
mTrackUnionStream->ChangeExplicitBlockerCount(1);
|
||||
mTrackUnionStream->Suspend();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -418,7 +418,7 @@ public:
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
NS_ENSURE_TRUE(mTrackUnionStream, NS_ERROR_FAILURE);
|
||||
mTrackUnionStream->ChangeExplicitBlockerCount(-1);
|
||||
mTrackUnionStream->Resume();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2144,18 +2144,16 @@ MediaStream::RemoveVideoOutput(VideoFrameContainer* aContainer)
|
||||
}
|
||||
|
||||
void
|
||||
MediaStream::ChangeExplicitBlockerCount(int32_t aDelta)
|
||||
MediaStream::Suspend()
|
||||
{
|
||||
class Message : public ControlMessage {
|
||||
public:
|
||||
Message(MediaStream* aStream, int32_t aDelta) :
|
||||
ControlMessage(aStream), mDelta(aDelta) {}
|
||||
explicit Message(MediaStream* aStream) :
|
||||
ControlMessage(aStream) {}
|
||||
virtual void Run()
|
||||
{
|
||||
mStream->ChangeExplicitBlockerCountImpl(
|
||||
mStream->GraphImpl()->mStateComputedTime, mDelta);
|
||||
mStream->GraphImpl()->IncrementSuspendCount(mStream);
|
||||
}
|
||||
int32_t mDelta;
|
||||
};
|
||||
|
||||
// This can happen if this method has been called asynchronously, and the
|
||||
@ -2163,7 +2161,28 @@ MediaStream::ChangeExplicitBlockerCount(int32_t aDelta)
|
||||
if (mMainThreadDestroyed) {
|
||||
return;
|
||||
}
|
||||
GraphImpl()->AppendMessage(new Message(this, aDelta));
|
||||
GraphImpl()->AppendMessage(new Message(this));
|
||||
}
|
||||
|
||||
void
|
||||
MediaStream::Resume()
|
||||
{
|
||||
class Message : public ControlMessage {
|
||||
public:
|
||||
explicit Message(MediaStream* aStream) :
|
||||
ControlMessage(aStream) {}
|
||||
virtual void Run()
|
||||
{
|
||||
mStream->GraphImpl()->DecrementSuspendCount(mStream);
|
||||
}
|
||||
};
|
||||
|
||||
// This can happen if this method has been called asynchronously, and the
|
||||
// stream has been destroyed since then.
|
||||
if (mMainThreadDestroyed) {
|
||||
return;
|
||||
}
|
||||
GraphImpl()->AppendMessage(new Message(this));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -362,9 +362,13 @@ public:
|
||||
// Only the first enabled video track is played.
|
||||
virtual void AddVideoOutput(VideoFrameContainer* aContainer);
|
||||
virtual void RemoveVideoOutput(VideoFrameContainer* aContainer);
|
||||
// Explicitly block. Useful for example if a media element is pausing
|
||||
// and we need to stop its stream emitting its buffered data.
|
||||
virtual void ChangeExplicitBlockerCount(int32_t aDelta);
|
||||
// Explicitly suspend. Useful for example if a media element is pausing
|
||||
// and we need to stop its stream emitting its buffered data. As soon as the
|
||||
// Suspend message reaches the graph, the stream stops processing. It
|
||||
// ignores its inputs and produces silence/no video until Resumed. Its
|
||||
// current time does not advance.
|
||||
virtual void Suspend();
|
||||
virtual void Resume();
|
||||
void BlockStreamIfNeeded();
|
||||
void UnblockStreamIfNeeded();
|
||||
// Events will be dispatched by calling methods of aListener.
|
||||
|
@ -86,14 +86,21 @@ private:
|
||||
};
|
||||
|
||||
static void
|
||||
UpdateStreamBlocking(MediaStream* aStream, bool aBlocking)
|
||||
UpdateStreamSuspended(MediaStream* aStream, bool aBlocking)
|
||||
{
|
||||
int32_t delta = aBlocking ? 1 : -1;
|
||||
if (NS_IsMainThread()) {
|
||||
aStream->ChangeExplicitBlockerCount(delta);
|
||||
if (aBlocking) {
|
||||
aStream->Suspend();
|
||||
} else {
|
||||
aStream->Resume();
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethodWithArg<int32_t>(
|
||||
aStream, &MediaStream::ChangeExplicitBlockerCount, delta);
|
||||
nsCOMPtr<nsIRunnable> r;
|
||||
if (aBlocking) {
|
||||
r = NS_NewRunnableMethod(aStream, &MediaStream::Suspend);
|
||||
} else {
|
||||
r = NS_NewRunnableMethod(aStream, &MediaStream::Resume);
|
||||
}
|
||||
AbstractThread::MainThread()->Dispatch(r.forget());
|
||||
}
|
||||
}
|
||||
@ -189,7 +196,7 @@ DecodedStreamData::SetPlaying(bool aPlaying)
|
||||
{
|
||||
if (mPlaying != aPlaying) {
|
||||
mPlaying = aPlaying;
|
||||
UpdateStreamBlocking(mStream, !mPlaying);
|
||||
UpdateStreamSuspended(mStream, !mPlaying);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -680,7 +680,7 @@ AudioDestinationNode::SetIsOnlyNodeForContext(bool aIsOnlyNode)
|
||||
}
|
||||
|
||||
if (aIsOnlyNode) {
|
||||
mStream->ChangeExplicitBlockerCount(1);
|
||||
mStream->Suspend();
|
||||
mStartedBlockingDueToBeingOnlyNode = TimeStamp::Now();
|
||||
// Don't do an update of mExtraCurrentTimeSinceLastStartedBlocking until the next stable state.
|
||||
mExtraCurrentTimeUpdatedSinceLastStableState = true;
|
||||
@ -690,7 +690,7 @@ AudioDestinationNode::SetIsOnlyNodeForContext(bool aIsOnlyNode)
|
||||
ExtraCurrentTime();
|
||||
mExtraCurrentTime += mExtraCurrentTimeSinceLastStartedBlocking;
|
||||
mExtraCurrentTimeSinceLastStartedBlocking = 0;
|
||||
mStream->ChangeExplicitBlockerCount(-1);
|
||||
mStream->Resume();
|
||||
mStartedBlockingDueToBeingOnlyNode = TimeStamp();
|
||||
}
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ nsSpeechTask::Pause()
|
||||
}
|
||||
|
||||
if (mStream) {
|
||||
mStream->ChangeExplicitBlockerCount(1);
|
||||
mStream->Suspend();
|
||||
}
|
||||
|
||||
if (!mInited) {
|
||||
@ -586,7 +586,7 @@ nsSpeechTask::Resume()
|
||||
}
|
||||
|
||||
if (mStream) {
|
||||
mStream->ChangeExplicitBlockerCount(-1);
|
||||
mStream->Resume();
|
||||
}
|
||||
|
||||
if (mPrePaused) {
|
||||
@ -612,7 +612,7 @@ nsSpeechTask::Cancel()
|
||||
}
|
||||
|
||||
if (mStream) {
|
||||
mStream->ChangeExplicitBlockerCount(1);
|
||||
mStream->Suspend();
|
||||
}
|
||||
|
||||
if (!mInited) {
|
||||
@ -628,7 +628,7 @@ void
|
||||
nsSpeechTask::ForceEnd()
|
||||
{
|
||||
if (mStream) {
|
||||
mStream->ChangeExplicitBlockerCount(1);
|
||||
mStream->Suspend();
|
||||
}
|
||||
|
||||
if (!mInited) {
|
||||
|
Loading…
Reference in New Issue
Block a user