Skip to content

Commit

Permalink
Bug 1545133 - Avoid trying to double-suspend a MediaStream if externa…
Browse files Browse the repository at this point in the history
…l code makes the suspendCount negative. r=padenot

We don't currently know any ways in which external code can make the
suspendCount negative, but this will keep us safe should a future bug enable it.

Depends on D28805

Differential Revision: https://phabricator.services.mozilla.com/D28806

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Pehrsons committed Apr 25, 2019
1 parent b53e315 commit cef48c8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dom/media/MediaStreamGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,6 @@ void MediaStream::IncrementSuspendCount() {
void MediaStream::DecrementSuspendCount() {
NS_ASSERTION(mSuspendedCount > 0, "Suspend count underrun");
--mSuspendedCount;

if (mSuspendedCount == 0) {
for (uint32_t i = 0; i < mConsumers.Length(); ++i) {
mConsumers[i]->Resumed();
Expand Down Expand Up @@ -3574,13 +3573,14 @@ void MediaStreamGraph::NotifyWhenGraphStarted(AudioNodeStream* aStream) {

void MediaStreamGraphImpl::IncrementSuspendCount(MediaStream* aStream) {
MOZ_ASSERT(OnGraphThreadOrNotRunning());
if (!aStream->IsSuspended()) {
bool wasSuspended = aStream->IsSuspended();
aStream->IncrementSuspendCount();
if (!wasSuspended && aStream->IsSuspended()) {
MOZ_ASSERT(mStreams.Contains(aStream));
mStreams.RemoveElement(aStream);
mSuspendedStreams.AppendElement(aStream);
SetStreamOrderDirty();
}
aStream->IncrementSuspendCount();
}

void MediaStreamGraphImpl::DecrementSuspendCount(MediaStream* aStream) {
Expand Down

0 comments on commit cef48c8

Please sign in to comment.