Bug 848954 - Part 20 - Remove the now useless DriverHolder class. r=roc

This commit is contained in:
Paul Adenot 2014-08-26 17:02:28 +02:00
parent 633b616eea
commit a3533d7c93
4 changed files with 24 additions and 62 deletions

View File

@ -41,24 +41,6 @@ GraphDriver::GraphDriver(MediaStreamGraphImpl* aGraphImpl)
mNextDriver(nullptr)
{ }
DriverHolder::DriverHolder(MediaStreamGraphImpl* aGraphImpl)
: mGraphImpl(aGraphImpl)
{ }
GraphTime
DriverHolder::GetCurrentTime()
{
MOZ_ASSERT(mDriver, "Can't get current time without a clock.");
return mDriver->GetCurrentTime();
}
void
DriverHolder::Switch(GraphDriver* aDriver)
{
MOZ_ASSERT(!mDriver, "This is only for initial switch.");
mDriver = aDriver;
}
void GraphDriver::SetGraphTime(GraphDriver* aPreviousDriver,
GraphTime aLastSwitchNextIterationStart,
GraphTime aLastSwitchNextIterationEnd,

View File

@ -228,44 +228,6 @@ protected:
{ }
};
/**
* A driver holder allows a MediaStreamGraph to seamlessly switch between
* different Drivers, remembering the current time of the graph at time of
* switch.
*/
class DriverHolder
{
public:
DriverHolder(MediaStreamGraphImpl* aGraphImpl);
GraphTime GetCurrentTime();
// Immediately switch to another driver.
void Switch(GraphDriver* aDriver);
// Create the new driver, but switch to a new one when the new driver is
// ready. System drivers don't have much problems here, but audio drivers can
// take a little while to start to fire callbacks.
void SwitchAtNextIteration(GraphDriver* aDriver);
GraphDriver* GetDriver() {
MOZ_ASSERT(mDriver);
return mDriver.get();
}
void SetCurrentDriver(GraphDriver* aDriver) {
mDriver = aDriver;
}
protected:
// The current driver
nsRefPtr<GraphDriver> mDriver;
// The lifetime of this pointer is equal to the lifetime of the graph, so it
// will never be null.
MediaStreamGraphImpl* mGraphImpl;
// XXX
GraphTime mNextIterationStart;
GraphTime mNextStateComputedTime;
};
class MediaStreamGraphInitThreadRunnable;
/**

View File

@ -2640,8 +2640,7 @@ MediaStreamGraphImpl::MediaStreamGraphImpl(bool aRealtime,
TrackRate aSampleRate,
DOMMediaStream::TrackTypeHints aHint= DOMMediaStream::HINT_CONTENTS_UNKNOWN,
dom::AudioChannel aChannel)
: mDriverHolder(MOZ_THIS_IN_INITIALIZER_LIST())
, mProcessingGraphUpdateIndex(0)
: mProcessingGraphUpdateIndex(0)
, mPortCount(0)
, mMonitor("MediaStreamGraphImpl")
, mLifecycleState(LIFECYCLE_THREAD_NOT_STARTED)
@ -2673,13 +2672,13 @@ MediaStreamGraphImpl::MediaStreamGraphImpl(bool aRealtime,
if (mRealtime) {
if (aHint & DOMMediaStream::HINT_CONTENTS_AUDIO) {
AudioCallbackDriver* driver = new AudioCallbackDriver(this, aChannel);
mDriverHolder.Switch(driver);
mDriver = driver;
mMixer.AddCallback(driver);
} else {
mDriverHolder.Switch(new SystemClockDriver(this));
mDriver = new SystemClockDriver(this);
}
} else {
mDriverHolder.Switch(new OfflineClockDriver(this, MEDIA_GRAPH_TARGET_PERIOD_MS));
mDriver = new OfflineClockDriver(this, MEDIA_GRAPH_TARGET_PERIOD_MS);
}
mLastMainThreadUpdate = TimeStamp::Now();

View File

@ -398,6 +398,17 @@ public:
return RateConvertTicksRoundDown(aRate, GraphRate(), aTime);
}
/**
* Signal to the graph that the thread has paused indefinitly,
* or resumed.
*/
void PausedIndefinitly();
void ResumedFromPaused();
GraphDriver* CurrentDriver() {
return mDriver;
}
/**
* Effectively set the new driver, while we are switching.
* It is only safe to call this at the very end of an iteration, when there
@ -405,7 +416,7 @@ public:
* should return and pass the control to the new driver shortly after.
*/
void SetCurrentDriver(GraphDriver* aDriver) {
mDriverHolder.SetCurrentDriver(aDriver);
mDriver = aDriver;
}
Monitor& GetMonitor() {
@ -413,6 +424,14 @@ public:
}
// Data members
//
/**
* Graphs own owning references to their driver, until shutdown. When a driver
* switch occur, previous driver is either deleted, or it's ownership is
* passed to a event that will take care of the asynchronous cleanup, as
* audio stream can take some time to shut down.
*/
nsRefPtr<GraphDriver> mDriver;
// The following state is managed on the graph thread only, unless
// mLifecycleState > LIFECYCLE_RUNNING in which case the graph thread