зеркало из https://github.com/mozilla/gecko-dev.git
bug 1217625
add a means to schedule a callback after processing on the graph thread r=padenot
--HG-- extra : rebase_source : 65cdfcc2af43ea01cb1e6f4111098ac5d9f4239f
This commit is contained in:
Родитель
76a1ffa463
Коммит
008976864a
|
@ -1000,7 +1000,21 @@ MediaStreamGraphImpl::AllFinishedStreamsNotified()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaStreamGraphImpl::UpdateGraph(GraphTime aEndBlockingDecisions)
|
MediaStreamGraphImpl::RunMessageAfterProcessing(nsAutoPtr<ControlMessage> aMessage)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(CurrentDriver()->OnThread());
|
||||||
|
|
||||||
|
if (mFrontMessageQueue.IsEmpty()) {
|
||||||
|
mFrontMessageQueue.AppendElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only one block is used for messages from the graph thread.
|
||||||
|
MOZ_ASSERT(mFrontMessageQueue.Length() == 1);
|
||||||
|
mFrontMessageQueue[0].mMessages.AppendElement(Move(aMessage));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MediaStreamGraphImpl::RunMessagesInQueue()
|
||||||
{
|
{
|
||||||
// Calculate independent action times for each batch of messages (each
|
// Calculate independent action times for each batch of messages (each
|
||||||
// batch corresponding to an event loop task). This isolates the performance
|
// batch corresponding to an event loop task). This isolates the performance
|
||||||
|
@ -1013,7 +1027,11 @@ MediaStreamGraphImpl::UpdateGraph(GraphTime aEndBlockingDecisions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mFrontMessageQueue.Clear();
|
mFrontMessageQueue.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MediaStreamGraphImpl::UpdateGraph(GraphTime aEndBlockingDecisions)
|
||||||
|
{
|
||||||
MOZ_ASSERT(aEndBlockingDecisions >= mProcessedTime);
|
MOZ_ASSERT(aEndBlockingDecisions >= mProcessedTime);
|
||||||
// The next state computed time can be the same as the previous: it
|
// The next state computed time can be the same as the previous: it
|
||||||
// means the driver would be have been blocking indefinitly, but the graph has
|
// means the driver would be have been blocking indefinitly, but the graph has
|
||||||
|
@ -1204,6 +1222,9 @@ MediaStreamGraphImpl::OneIteration(GraphTime aStateEnd)
|
||||||
{
|
{
|
||||||
MaybeProduceMemoryReport();
|
MaybeProduceMemoryReport();
|
||||||
|
|
||||||
|
// Process graph message from the main thread for this iteration.
|
||||||
|
RunMessagesInQueue();
|
||||||
|
|
||||||
GraphTime stateEnd = std::min(aStateEnd, mEndTime);
|
GraphTime stateEnd = std::min(aStateEnd, mEndTime);
|
||||||
UpdateGraph(stateEnd);
|
UpdateGraph(stateEnd);
|
||||||
|
|
||||||
|
@ -1216,6 +1237,10 @@ MediaStreamGraphImpl::OneIteration(GraphTime aStateEnd)
|
||||||
|
|
||||||
UpdateCurrentTimeForStreams(oldProcessedTime);
|
UpdateCurrentTimeForStreams(oldProcessedTime);
|
||||||
|
|
||||||
|
// Process graph messages queued from RunMessageAfterProcessing() on this
|
||||||
|
// thread during the iteration.
|
||||||
|
RunMessagesInQueue();
|
||||||
|
|
||||||
return UpdateMainThreadState();
|
return UpdateMainThreadState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,11 @@ struct StreamUpdate
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This represents a message passed from the main thread to the graph thread.
|
* This represents a message run on the graph thread to modify stream or graph
|
||||||
* A ControlMessage always has a weak reference a particular affected stream.
|
* state. These are passed from main thread to graph thread through
|
||||||
|
* AppendMessage(), or scheduled on the graph thread with
|
||||||
|
* RunMessageAfterProcessing(). A ControlMessage
|
||||||
|
* always has a weak reference to a particular affected stream.
|
||||||
*/
|
*/
|
||||||
class ControlMessage
|
class ControlMessage
|
||||||
{
|
{
|
||||||
|
@ -58,6 +61,8 @@ public:
|
||||||
// All stream data for times < mProcessedTime has already been
|
// All stream data for times < mProcessedTime has already been
|
||||||
// computed.
|
// computed.
|
||||||
virtual void Run() = 0;
|
virtual void Run() = 0;
|
||||||
|
// RunDuringShutdown() is only relevant to messages generated on the main
|
||||||
|
// thread (for AppendMessage()).
|
||||||
// When we're shutting down the application, most messages are ignored but
|
// When we're shutting down the application, most messages are ignored but
|
||||||
// some cleanup messages should still be processed (on the main thread).
|
// some cleanup messages should still be processed (on the main thread).
|
||||||
// This must not add new control messages to the graph.
|
// This must not add new control messages to the graph.
|
||||||
|
@ -218,8 +223,12 @@ public:
|
||||||
*/
|
*/
|
||||||
void UpdateCurrentTimeForStreams(GraphTime aPrevCurrentTime);
|
void UpdateCurrentTimeForStreams(GraphTime aPrevCurrentTime);
|
||||||
/**
|
/**
|
||||||
* Process graph message for this iteration, update stream processing order,
|
* Process graph messages in mFrontMessageQueue.
|
||||||
* and recompute stream blocking until aEndBlockingDecisions.
|
*/
|
||||||
|
void RunMessagesInQueue();
|
||||||
|
/**
|
||||||
|
* Update stream processing order and recompute stream blocking until
|
||||||
|
* aEndBlockingDecisions.
|
||||||
*/
|
*/
|
||||||
void UpdateGraph(GraphTime aEndBlockingDecisions);
|
void UpdateGraph(GraphTime aEndBlockingDecisions);
|
||||||
|
|
||||||
|
@ -242,6 +251,14 @@ public:
|
||||||
GraphTime aDesiredUpToTime,
|
GraphTime aDesiredUpToTime,
|
||||||
bool* aEnsureNextIteration);
|
bool* aEnsureNextIteration);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For use during ProcessedMediaStream::ProcessInput() or
|
||||||
|
* MediaStreamListener callbacks, when graph state cannot be changed.
|
||||||
|
* Schedules |aMessage| to run after processing, at a time when graph state
|
||||||
|
* can be changed. Graph thread.
|
||||||
|
*/
|
||||||
|
void RunMessageAfterProcessing(nsAutoPtr<ControlMessage> aMessage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a suspend/resume/close operation has been completed, on the
|
* Called when a suspend/resume/close operation has been completed, on the
|
||||||
* graph thread.
|
* graph thread.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче