From 7502376eecbd09aba1dbb7b7a8a6dbb43522c63c Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Wed, 18 Dec 2019 22:51:45 +0000 Subject: [PATCH] Bug 1586370 - Rename GraphDriver::OnGraphThread to InIteration. r=padenot Differential Revision: https://phabricator.services.mozilla.com/D56081 --HG-- extra : moz-landing-system : lando --- dom/media/GraphDriver.cpp | 22 ++++++++++------------ dom/media/GraphDriver.h | 4 ++-- dom/media/GraphRunner.cpp | 2 +- dom/media/GraphRunner.h | 2 +- dom/media/MediaTrackGraph.cpp | 4 ++-- dom/media/MediaTrackGraphImpl.h | 4 ++-- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/dom/media/GraphDriver.cpp b/dom/media/GraphDriver.cpp index b5e27273f7c6..e13ac857963d 100644 --- a/dom/media/GraphDriver.cpp +++ b/dom/media/GraphDriver.cpp @@ -40,7 +40,7 @@ GraphDriver::GraphDriver(MediaTrackGraphImpl* aGraphImpl, void GraphDriver::SetState(GraphTime aIterationStart, GraphTime aIterationEnd, GraphTime aStateComputedTime) { - MOZ_ASSERT(OnGraphThread() || !ThreadRunning()); + MOZ_ASSERT(InIteration() || !ThreadRunning()); mIterationStart = aIterationStart; mIterationEnd = aIterationEnd; @@ -48,18 +48,16 @@ void GraphDriver::SetState(GraphTime aIterationStart, GraphTime aIterationEnd, } #ifdef DEBUG -bool GraphDriver::OnGraphThread() { - return GraphImpl()->RunByGraphDriver(this); -} +bool GraphDriver::InIteration() { return GraphImpl()->InDriverIteration(this); } #endif GraphDriver* GraphDriver::PreviousDriver() { - MOZ_ASSERT(OnGraphThread() || !ThreadRunning()); + MOZ_ASSERT(InIteration() || !ThreadRunning()); return mPreviousDriver; } void GraphDriver::SetPreviousDriver(GraphDriver* aPreviousDriver) { - MOZ_ASSERT(OnGraphThread() || !ThreadRunning()); + MOZ_ASSERT(InIteration() || !ThreadRunning()); mPreviousDriver = aPreviousDriver; } @@ -565,7 +563,7 @@ bool AudioCallbackDriver::Init() { void AudioCallbackDriver::Start() { MOZ_ASSERT(!IsStarted()); MOZ_ASSERT(NS_IsMainThread() || OnCubebOperationThread() || - (PreviousDriver() && PreviousDriver()->OnGraphThread())); + (PreviousDriver() && PreviousDriver()->InIteration())); if (mPreviousDriver) { if (mPreviousDriver->AsAudioCallbackDriver()) { LOG(LogLevel::Debug, ("Releasing audio driver off main thread.")); @@ -813,7 +811,7 @@ static const char* StateToString(cubeb_state aState) { } void AudioCallbackDriver::StateCallback(cubeb_state aState) { - MOZ_ASSERT(!OnGraphThread()); + MOZ_ASSERT(!InIteration()); LOG(LogLevel::Debug, ("AudioCallbackDriver State: %s", StateToString(aState))); @@ -834,7 +832,7 @@ void AudioCallbackDriver::MixerCallback(AudioDataValue* aMixedBuffer, AudioSampleFormat aFormat, uint32_t aChannels, uint32_t aFrames, uint32_t aSampleRate) { - MOZ_ASSERT(OnGraphThread()); + MOZ_ASSERT(InIteration()); uint32_t toWrite = mBuffer.Available(); if (!mBuffer.Available()) { @@ -884,7 +882,7 @@ void AudioCallbackDriver::PanOutputIfNeeded(bool aMicrophoneActive) { } void AudioCallbackDriver::DeviceChangedCallback() { - MOZ_ASSERT(!OnGraphThread()); + MOZ_ASSERT(!InIteration()); // Tell the audio engine the device has changed, it might want to reset some // state. MonitorAutoLock mon(mGraphImpl->GetMonitor()); @@ -900,7 +898,7 @@ void AudioCallbackDriver::DeviceChangedCallback() { } uint32_t AudioCallbackDriver::IterationDuration() { - MOZ_ASSERT(OnGraphThread()); + MOZ_ASSERT(InIteration()); // The real fix would be to have an API in cubeb to give us the number. Short // of that, we approximate it here. bug 1019507 return mIterationDurationMS; @@ -912,7 +910,7 @@ void AudioCallbackDriver::EnqueueTrackAndPromiseForOperation( MediaTrack* aTrack, dom::AudioContextOperation aOperation, AbstractThread* aMainThread, MozPromiseHolder&& aHolder) { - MOZ_ASSERT(OnGraphThread() || !ThreadRunning()); + MOZ_ASSERT(InIteration() || !ThreadRunning()); auto promises = mPromisesForOperation.Lock(); promises->AppendElement(TrackAndPromiseForOperation( aTrack, aOperation, aMainThread, std::move(aHolder))); diff --git a/dom/media/GraphDriver.h b/dom/media/GraphDriver.h index 7f01ae3aadc1..8c7ea2de098a 100644 --- a/dom/media/GraphDriver.h +++ b/dom/media/GraphDriver.h @@ -262,8 +262,8 @@ class GraphDriver { MediaTrackGraphImpl* GraphImpl() const { return mGraphImpl; } #ifdef DEBUG - // True if the current thread is driving the MTG. - bool OnGraphThread(); + // True if the current thread is currently iterating the MTG. + bool InIteration(); #endif // True if the current thread is the GraphDriver's thread. virtual bool OnThread() = 0; diff --git a/dom/media/GraphRunner.cpp b/dom/media/GraphRunner.cpp index 40eefd366105..8527114283a0 100644 --- a/dom/media/GraphRunner.cpp +++ b/dom/media/GraphRunner.cpp @@ -129,7 +129,7 @@ bool GraphRunner::OnThread() { } #ifdef DEBUG -bool GraphRunner::RunByGraphDriver(GraphDriver* aDriver) { +bool GraphRunner::InDriverIteration(GraphDriver* aDriver) { if (!OnThread()) { return false; } diff --git a/dom/media/GraphRunner.h b/dom/media/GraphRunner.h index 0c0de84873a5..08d250327035 100644 --- a/dom/media/GraphRunner.h +++ b/dom/media/GraphRunner.h @@ -52,7 +52,7 @@ class GraphRunner final : public Runnable { * Returns true if called on mThread, and aDriver was the driver that called * OneIteration() last. */ - bool RunByGraphDriver(GraphDriver* aDriver); + bool InDriverIteration(GraphDriver* aDriver); #endif private: diff --git a/dom/media/MediaTrackGraph.cpp b/dom/media/MediaTrackGraph.cpp index f9981c42108f..6cf7f6db70ba 100644 --- a/dom/media/MediaTrackGraph.cpp +++ b/dom/media/MediaTrackGraph.cpp @@ -2945,9 +2945,9 @@ AbstractThread* MediaTrackGraph::AbstractMainThread() { } #ifdef DEBUG -bool MediaTrackGraphImpl::RunByGraphDriver(GraphDriver* aDriver) { +bool MediaTrackGraphImpl::InDriverIteration(GraphDriver* aDriver) { return aDriver->OnThread() || - (mGraphRunner && mGraphRunner->RunByGraphDriver(aDriver)); + (mGraphRunner && mGraphRunner->InDriverIteration(aDriver)); } #endif diff --git a/dom/media/MediaTrackGraphImpl.h b/dom/media/MediaTrackGraphImpl.h index e8e73b48a9b7..6c4a3513f38d 100644 --- a/dom/media/MediaTrackGraphImpl.h +++ b/dom/media/MediaTrackGraphImpl.h @@ -127,7 +127,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph, * True if we're on aDriver's thread, or if we're on mGraphRunner's thread * and mGraphRunner is currently run by aDriver. */ - bool RunByGraphDriver(GraphDriver* aDriver); + bool InDriverIteration(GraphDriver* aDriver); #endif /** @@ -576,7 +576,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph, * Monitor must be held. */ void SetCurrentDriver(GraphDriver* aDriver) { - MOZ_ASSERT_IF(mDriver->ThreadRunning(), RunByGraphDriver(mDriver)); + MOZ_ASSERT_IF(mDriver->ThreadRunning(), InDriverIteration(mDriver)); MOZ_ASSERT_IF(!mDriver->ThreadRunning(), NS_IsMainThread()); mDriver = aDriver; }