mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Bug 1189506. Simplify blocking code now that stream blocking decision are always independent of other streams. r=karlt
--HG-- extra : commitid : 7du3gdoRlpL extra : rebase_source : ea22fe1b46a9a27bbab3fc250f688aa9dae53250
This commit is contained in:
parent
33caf40bd0
commit
4de38847f5
@ -480,7 +480,6 @@ MediaStreamGraphImpl::UpdateStreamOrder()
|
||||
for (uint32_t i = 0; i < mStreams.Length(); ++i) {
|
||||
MediaStream* stream = mStreams[i];
|
||||
stream->mIsConsumed = false;
|
||||
stream->mInBlockingSet = false;
|
||||
#ifdef MOZ_WEBRTC
|
||||
if (stream->AsSourceStream() &&
|
||||
stream->AsSourceStream()->NeedsMixing()) {
|
||||
@ -716,19 +715,11 @@ MediaStreamGraphImpl::RecomputeBlocking(GraphTime aEndBlockingDecisions)
|
||||
STREAM_LOG(LogLevel::Verbose, ("Media graph %p computing blocking for time %f",
|
||||
this, MediaTimeToSeconds(mStateComputedTime)));
|
||||
for (MediaStream* stream : AllStreams()) {
|
||||
if (!stream->mInBlockingSet) {
|
||||
// Compute a partition of the streams containing 'stream' such that we
|
||||
// can
|
||||
// compute the blocking status of each subset independently.
|
||||
nsAutoTArray<MediaStream*, 10> streamSet;
|
||||
AddBlockingRelatedStreamsToSet(&streamSet, stream);
|
||||
|
||||
GraphTime end;
|
||||
for (GraphTime t = mStateComputedTime;
|
||||
t < aEndBlockingDecisions; t = end) {
|
||||
end = GRAPH_TIME_MAX;
|
||||
RecomputeBlockingAt(streamSet, t, aEndBlockingDecisions, &end);
|
||||
}
|
||||
GraphTime end;
|
||||
for (GraphTime t = mStateComputedTime;
|
||||
t < aEndBlockingDecisions; t = end) {
|
||||
end = GRAPH_TIME_MAX;
|
||||
RecomputeBlockingAt(stream, t, aEndBlockingDecisions, &end);
|
||||
}
|
||||
}
|
||||
STREAM_LOG(LogLevel::Verbose, ("Media graph %p computed blocking for interval %f to %f",
|
||||
@ -743,16 +734,6 @@ MediaStreamGraphImpl::RecomputeBlocking(GraphTime aEndBlockingDecisions)
|
||||
mStateComputedTime = aEndBlockingDecisions;
|
||||
}
|
||||
|
||||
void
|
||||
MediaStreamGraphImpl::AddBlockingRelatedStreamsToSet(nsTArray<MediaStream*>* aStreams,
|
||||
MediaStream* aStream)
|
||||
{
|
||||
if (aStream->mInBlockingSet)
|
||||
return;
|
||||
aStream->mInBlockingSet = true;
|
||||
aStreams->AppendElement(aStream);
|
||||
}
|
||||
|
||||
void
|
||||
MediaStreamGraphImpl::MarkStreamBlocking(MediaStream* aStream)
|
||||
{
|
||||
@ -762,65 +743,58 @@ MediaStreamGraphImpl::MarkStreamBlocking(MediaStream* aStream)
|
||||
}
|
||||
|
||||
void
|
||||
MediaStreamGraphImpl::RecomputeBlockingAt(const nsTArray<MediaStream*>& aStreams,
|
||||
MediaStreamGraphImpl::RecomputeBlockingAt(MediaStream* aStream,
|
||||
GraphTime aTime,
|
||||
GraphTime aEndBlockingDecisions,
|
||||
GraphTime* aEnd)
|
||||
{
|
||||
for (uint32_t i = 0; i < aStreams.Length(); ++i) {
|
||||
MediaStream* stream = aStreams[i];
|
||||
stream->mBlockInThisPhase = false;
|
||||
}
|
||||
aStream->mBlockInThisPhase = false;
|
||||
|
||||
for (uint32_t i = 0; i < aStreams.Length(); ++i) {
|
||||
MediaStream* stream = aStreams[i];
|
||||
|
||||
if (stream->mFinished) {
|
||||
GraphTime endTime = StreamTimeToGraphTime(stream,
|
||||
stream->GetStreamBuffer().GetAllTracksEnd());
|
||||
do {
|
||||
if (aStream->mFinished) {
|
||||
GraphTime endTime = StreamTimeToGraphTime(aStream,
|
||||
aStream->GetStreamBuffer().GetAllTracksEnd());
|
||||
if (endTime <= aTime) {
|
||||
STREAM_LOG(LogLevel::Verbose, ("MediaStream %p is blocked due to being finished", stream));
|
||||
STREAM_LOG(LogLevel::Verbose, ("MediaStream %p is blocked due to being finished", aStream));
|
||||
// We'll block indefinitely
|
||||
MarkStreamBlocking(stream);
|
||||
MarkStreamBlocking(aStream);
|
||||
*aEnd = std::min(*aEnd, aEndBlockingDecisions);
|
||||
continue;
|
||||
} else {
|
||||
STREAM_LOG(LogLevel::Verbose, ("MediaStream %p is finished, but not blocked yet (end at %f, with blocking at %f)",
|
||||
stream, MediaTimeToSeconds(stream->GetBufferEnd()),
|
||||
MediaTimeToSeconds(endTime)));
|
||||
aStream, MediaTimeToSeconds(aStream->GetBufferEnd()),
|
||||
MediaTimeToSeconds(endTime)));
|
||||
*aEnd = std::min(*aEnd, endTime);
|
||||
}
|
||||
}
|
||||
|
||||
GraphTime end;
|
||||
bool explicitBlock = stream->mExplicitBlockerCount.GetAt(aTime, &end) > 0;
|
||||
bool explicitBlock = aStream->mExplicitBlockerCount.GetAt(aTime, &end) > 0;
|
||||
*aEnd = std::min(*aEnd, end);
|
||||
if (explicitBlock) {
|
||||
STREAM_LOG(LogLevel::Verbose, ("MediaStream %p is blocked due to explicit blocker", stream));
|
||||
MarkStreamBlocking(stream);
|
||||
STREAM_LOG(LogLevel::Verbose, ("MediaStream %p is blocked due to explicit blocker", aStream));
|
||||
MarkStreamBlocking(aStream);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stream->IsSuspended()) {
|
||||
STREAM_LOG(LogLevel::Verbose, ("MediaStream %p is blocked due to being suspended", stream));
|
||||
MarkStreamBlocking(stream);
|
||||
if (aStream->IsSuspended()) {
|
||||
STREAM_LOG(LogLevel::Verbose, ("MediaStream %p is blocked due to being suspended", aStream));
|
||||
MarkStreamBlocking(aStream);
|
||||
continue;
|
||||
}
|
||||
|
||||
bool underrun = WillUnderrun(stream, aTime, aEndBlockingDecisions, aEnd);
|
||||
bool underrun = WillUnderrun(aStream, aTime, aEndBlockingDecisions, aEnd);
|
||||
if (underrun) {
|
||||
// We'll block indefinitely
|
||||
MarkStreamBlocking(stream);
|
||||
MarkStreamBlocking(aStream);
|
||||
*aEnd = std::min(*aEnd, aEndBlockingDecisions);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} while (false);
|
||||
|
||||
NS_ASSERTION(*aEnd > aTime, "Failed to advance!");
|
||||
|
||||
for (uint32_t i = 0; i < aStreams.Length(); ++i) {
|
||||
MediaStream* stream = aStreams[i];
|
||||
stream->mBlocked.SetAtAndAfter(aTime, stream->mBlockInThisPhase);
|
||||
}
|
||||
aStream->mBlocked.SetAtAndAfter(aTime, aStream->mBlockInThisPhase);
|
||||
}
|
||||
|
||||
void
|
||||
@ -3177,7 +3151,6 @@ MediaStreamGraphImpl::DecrementSuspendCount(MediaStream* aStream)
|
||||
if (ps) {
|
||||
ps->mCycleMarker = NOT_VISITED;
|
||||
ps->mIsConsumed = false;
|
||||
ps->mInBlockingSet = false;
|
||||
}
|
||||
SetStreamOrderDirty();
|
||||
}
|
||||
|
@ -717,10 +717,6 @@ protected:
|
||||
// True if the stream is being consumed (i.e. has track data being played,
|
||||
// or is feeding into some stream that is being consumed).
|
||||
bool mIsConsumed;
|
||||
// Temporary data for computing blocking status of streams
|
||||
// True if we've added this stream to the set of streams we're computing
|
||||
// blocking for.
|
||||
bool mInBlockingSet;
|
||||
// True if this stream should be blocked in this phase.
|
||||
bool mBlockInThisPhase;
|
||||
|
||||
|
@ -304,14 +304,6 @@ public:
|
||||
*/
|
||||
void RecomputeBlocking(GraphTime aEndBlockingDecisions);
|
||||
|
||||
// The following methods are used to help RecomputeBlocking.
|
||||
/**
|
||||
* If aStream isn't already in aStreams, add it and recursively call
|
||||
* AddBlockingRelatedStreamsToSet on all the streams whose blocking
|
||||
* status could depend on or affect the state of aStream.
|
||||
*/
|
||||
void AddBlockingRelatedStreamsToSet(nsTArray<MediaStream*>* aStreams,
|
||||
MediaStream* aStream);
|
||||
/**
|
||||
* Mark a stream blocked at time aTime. If this results in decisions that need
|
||||
* to be revisited at some point in the future, *aEnd will be reduced to the
|
||||
@ -324,7 +316,7 @@ public:
|
||||
* in the future, *aEnd will be reduced to the first time in the future to
|
||||
* recompute those decisions.
|
||||
*/
|
||||
void RecomputeBlockingAt(const nsTArray<MediaStream*>& aStreams,
|
||||
void RecomputeBlockingAt(MediaStream* aStream,
|
||||
GraphTime aTime, GraphTime aEndBlockingDecisions,
|
||||
GraphTime* aEnd);
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user