Bug 1040550 - Prevent MediaSource::SetDuration from being called outside the main thread. r=kinetik

This commit is contained in:
Jean-Yves Avenard 2014-07-28 11:50:32 +12:00
parent 7e5806cf78
commit e2367255f8

View File

@ -231,6 +231,12 @@ private:
return mDecoders[mActiveVideoDecoder]->GetReader();
}
void SetMediaSourceDuration(double aDuration) {
MOZ_ASSERT(NS_IsMainThread());
ErrorResult dummy;
mMediaSource->SetDuration(aDuration, dummy);
}
nsTArray<nsRefPtr<SubBufferDecoder>> mPendingDecoders;
nsTArray<nsRefPtr<SubBufferDecoder>> mDecoders;
@ -585,8 +591,9 @@ MediaSourceReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
if (maxDuration != -1) {
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mDecoder->SetMediaDuration(maxDuration);
ErrorResult dummy;
mMediaSource->SetDuration(maxDuration, dummy);
nsRefPtr<nsIRunnable> task (
NS_NewRunnableMethodWithArg<double>(this, &MediaSourceReader::SetMediaSourceDuration, maxDuration));
NS_DispatchToMainThread(task);
}
*aInfo = mInfo;