Bug 1404997 - P17. Split ExtractPendingInput into two methods. r?padenot
There were two steps happening inside ExtractPendingInput:
1- Retrieve the data from the StreamTracks
2- Process any pending pending states change
We split it so that the retrieval from the StreamTrack can be promisified in an upcoming change
MozReview-Commit-ID: 53O4fXWMDGL
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -1146,17 +1146,18 @@ MediaStreamGraphImpl::UpdateGraph(GraphT
UpdateStreamOrder();
bool ensureNextIteration = false;
// Grab pending stream input and compute blocking time
for (MediaStream* stream : mStreams) {
if (SourceMediaStream* is = stream->AsSourceStream()) {
- is->ExtractPendingInput(aEndBlockingDecisions, &ensureNextIteration);
+ is->PullNewData(aEndBlockingDecisions, &ensureNextIteration);
+ is->ExtractPendingInput();
}
if (stream->mFinished) {
// The stream's not suspended, and since it's finished, underruns won't
// stop it playing out. So there's no blocking other than what we impose
// here.
GraphTime endTime = stream->GetStreamTracks().GetAllTracksEnd() +
stream->mTracksStartTime;
@@ -2689,18 +2690,18 @@ SourceMediaStream::SetPullEnabled(bool a
MutexAutoLock lock(mMutex);
mPullEnabled = aEnabled;
if (mPullEnabled && GraphImpl()) {
GraphImpl()->EnsureNextIteration();
}
}
void
-SourceMediaStream::ExtractPendingInput(StreamTime aDesiredUpToTime,
- bool* aEnsureNextIteration)
+SourceMediaStream::PullNewData(StreamTime aDesiredUpToTime,
+ bool* aEnsureNextIteration)
{
MutexAutoLock lock(mMutex);
if (mPullEnabled && !mFinished && !mListeners.IsEmpty()) {
// Compute how much stream time we'll need assuming we don't block
// the stream at all.
StreamTime t = GraphTimeToStreamTime(aDesiredUpToTime);
StreamTime current = mTracks.GetEnd();
LOG(LogLevel::Verbose,
@@ -2725,16 +2726,22 @@ SourceMediaStream::ExtractPendingInput(S
MediaStreamListener* l = mListeners[j];
{
MutexAutoUnlock unlock(mMutex);
l->NotifyPull(GraphImpl(), t);
}
}
}
}
+}
+
+void
+SourceMediaStream::ExtractPendingInput()
+{
+ MutexAutoLock lock(mMutex);
bool finished = mFinishPending;
bool shouldNotifyTrackCreated = false;
for (int32_t i = mUpdateTracks.Length() - 1; i >= 0; --i) {
SourceMediaStream::TrackData* data = &mUpdateTracks[i];
ApplyTrackDisabling(data->mID, data->mData);
// Dealing with NotifyQueuedTrackChanges and NotifyQueuedAudioData part.
--- a/dom/media/MediaStreamGraph.h
+++ b/dom/media/MediaStreamGraph.h
@@ -694,20 +694,25 @@ public:
* gets called on MediaStreamListeners for this stream during the
* MediaStreamGraph control loop. Pulling is initially disabled.
* Due to unavoidable race conditions, after a call to SetPullEnabled(false)
* it is still possible for a NotifyPull to occur.
*/
void SetPullEnabled(bool aEnabled);
/**
+ * Call all MediaStreamListeners to request new data via the NotifyPull API
+ * (if enabled).
+ */
+ void PullNewData(StreamTime aDesiredUpToTime, bool* aEnsureNextIteration);
+
+ /**
* Extract any state updates pending in the stream, and apply them.
*/
- void ExtractPendingInput(StreamTime aDesiredUpToTime,
- bool* aEnsureNextIteration);
+ void ExtractPendingInput();
/**
* These add/remove DirectListeners, which allow bypassing the graph and any
* synchronization delays for e.g. PeerConnection, which wants the data ASAP
* and lets the far-end handle sync and playout timing.
*/
void NotifyListenersEventImpl(MediaStreamGraphEvent aEvent);
void NotifyListenersEvent(MediaStreamGraphEvent aEvent);