Bug 943461. Part 1: A stream is fully finished when all its tracks have finished playing out. r=padenot

--HG--
extra : rebase_source : 0efa4353ea22ffd52d550331623098d275382148
This commit is contained in:
Robert O'Callahan 2013-12-04 14:08:12 +13:00
parent aebd99223c
commit 0606ce8b72
3 changed files with 30 additions and 1 deletions

View File

@ -416,7 +416,10 @@ MediaStreamGraphImpl::UpdateCurrentTime()
for (uint32_t i = 0; i < streamsReadyToFinish.Length(); ++i) {
MediaStream* stream = streamsReadyToFinish[i];
if (StreamTimeToGraphTime(stream, stream->GetBufferEnd()) <= mCurrentTime) {
// The stream is fully finished when all of its track data has been played
// out.
if (mCurrentTime >=
stream->StreamTimeToGraphTime(stream->GetStreamBuffer().GetAllTracksEnd())) {
stream->mNotifiedFinished = true;
stream->mLastPlayedVideoFrame.SetNull();
for (uint32_t j = 0; j < stream->mListeners.Length(); ++j) {

View File

@ -46,6 +46,25 @@ StreamBuffer::GetEnd() const
return t;
}
StreamTime
StreamBuffer::GetAllTracksEnd() const
{
StreamTime t = 0;
for (uint32_t i = 0; i < mTracks.Length(); ++i) {
Track* track = mTracks[i];
if (!track->IsEnded()) {
return STREAM_TIME_MAX;
}
t = std::max(t, track->GetEndTimeRoundDown());
}
if (t > mTracksKnownTime) {
// It can't be later then mTracksKnownTime, since a track might be added
// after that.
return STREAM_TIME_MAX;
}
return t;
}
StreamBuffer::Track*
StreamBuffer::FindTrack(TrackID aID)
{

View File

@ -224,6 +224,13 @@ public:
*/
StreamTime GetEnd() const;
/**
* Returns the earliest time >= 0 at which all tracks have ended
* and all their data has been played out and no new tracks can be added,
* or STREAM_TIME_MAX if there is no such time.
*/
StreamTime GetAllTracksEnd() const;
#ifdef DEBUG
void DumpTrackInfo() const;
#endif