Bug 1163223 - Move bailout case in GetBuffered into the readers. r=jww

The problem here is that, because we run mReader->SetStartTime() as a promise
callback, MDSM::HasStartTime() may be true while the reader hasn't been
notified yet. This is obviously broken, but no more broken than the fact that
GetBuffered operates synchronously (and is basically the last piece of
machinery left doing so). Fixing that is next on my list, but let's just hack
around this for now to get this stack landed.
This commit is contained in:
Bobby Holley 2015-06-10 20:44:06 -07:00
parent 2942db2631
commit ed1ce0d8bb
6 changed files with 5 additions and 11 deletions

View File

@ -154,6 +154,7 @@ MediaDecoderReader::SetStartTime(int64_t aStartTime)
media::TimeIntervals
MediaDecoderReader::GetBuffered()
{
NS_ENSURE_TRUE(mStartTime >= 0, media::TimeIntervals());
AutoPinned<MediaResource> stream(mDecoder->GetResource());
int64_t durationUs = 0;
{

View File

@ -266,14 +266,7 @@ public:
}
media::TimeIntervals GetBuffered() {
// It's possible for JS to query .buffered before we've determined the start
// time from metadata, in which case the reader isn't ready to be asked this
// question.
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
if (mStartTime < 0) {
return media::TimeIntervals();
}
return mReader->GetBuffered();
}

View File

@ -1300,7 +1300,7 @@ MediaFormatReader::GetBuffered()
int64_t startTime;
{
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
MOZ_ASSERT(mStartTime != -1, "Need to finish metadata decode first");
NS_ENSURE_TRUE(mStartTime >= 0, media::TimeIntervals());
startTime = mStartTime;
}
if (NS_IsMainThread()) {

View File

@ -1081,7 +1081,7 @@ MP4Reader::GetBuffered()
return buffered;
}
UpdateIndex();
MOZ_ASSERT(mStartTime != -1, "Need to finish metadata decode first");
NS_ENSURE_TRUE(mStartTime >= 0, media::TimeIntervals());
AutoPinned<MediaResource> resource(mDecoder->GetResource());
nsTArray<MediaByteRange> ranges;

View File

@ -1852,7 +1852,7 @@ nsresult OggReader::SeekBisection(int64_t aTarget,
media::TimeIntervals OggReader::GetBuffered()
{
MOZ_ASSERT(mStartTime != -1, "Need to finish metadata decode first");
NS_ENSURE_TRUE(mStartTime >= 0, media::TimeIntervals());
{
mozilla::ReentrantMonitorAutoEnter mon(mMonitor);
if (mIsChained) {

View File

@ -1093,7 +1093,7 @@ nsresult WebMReader::SeekInternal(int64_t aTarget)
media::TimeIntervals WebMReader::GetBuffered()
{
MOZ_ASSERT(mStartTime != -1, "Need to finish metadata decode first");
NS_ENSURE_TRUE(mStartTime >= 0, media::TimeIntervals());
AutoPinned<MediaResource> resource(mDecoder->GetResource());
media::TimeIntervals buffered;