Bug 1069730 - Grab decoder monitor when clearing mEssentialTrackBuffers. r=cajbir

Also ensure MediaSource::InitializationEvent is only queued once.
This commit is contained in:
Matthew Gregan 2014-09-19 15:55:58 +12:00
Родитель 0b0b954051
Коммит 5b5712a79f
3 изменённых файлов: 11 добавлений и 7 удалений

Просмотреть файл

@ -338,7 +338,7 @@ MediaSource::Detach()
}
mDecoder->DetachMediaSource();
mDecoder = nullptr;
mFirstSourceBufferInitialization = false;
mFirstSourceBufferInitialized = false;
SetReadyState(MediaSourceReadyState::Closed);
mDuration = UnspecifiedNaN<double>();
if (mActiveSourceBuffers) {
@ -395,7 +395,7 @@ MediaSource::MediaSource(nsPIDOMWindow* aWindow)
, mDuration(UnspecifiedNaN<double>())
, mDecoder(nullptr)
, mReadyState(MediaSourceReadyState::Closed)
, mFirstSourceBufferInitialization(false)
, mFirstSourceBufferInitialized(false)
{
MOZ_ASSERT(NS_IsMainThread());
mSourceBuffers = new SourceBufferList(this);
@ -487,9 +487,10 @@ void
MediaSource::QueueInitializationEvent()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mFirstSourceBufferInitialization) {
mFirstSourceBufferInitialization = true;
if (mFirstSourceBufferInitialized) {
return;
}
mFirstSourceBufferInitialized = true;
MSE_DEBUG("MediaSource(%p)::QueueInitializationEvent()", this);
nsRefPtr<nsIRunnable> task =
NS_NewRunnableMethod(this, &MediaSource::InitializationEvent);

Просмотреть файл

@ -92,7 +92,7 @@ public:
// Queue InitializationEvent to run on the main thread. Called when a
// SourceBuffer has an initialization segment appended, but only
// dispatched the first time (using mFirstSourceBufferInitialization).
// dispatched the first time (using mFirstSourceBufferInitialized).
// Demarcates the point in time at which only currently registered
// TrackBuffers are treated as essential by the MediaSourceReader for
// initialization.
@ -130,7 +130,7 @@ private:
MediaSourceReadyState mReadyState;
bool mFirstSourceBufferInitialization;
bool mFirstSourceBufferInitialized;
};
NS_DEFINE_STATIC_IID_ACCESSOR(MediaSource, MOZILLA_DOM_MEDIASOURCE_IMPLEMENTATION_IID)

Просмотреть файл

@ -473,7 +473,10 @@ MediaSourceReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
this, mEssentialTrackBuffers.Length(), mTrackBuffers.Length(),
mAudioTrack.get(), mVideoTrack.get());
mEssentialTrackBuffers.Clear();
{
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mEssentialTrackBuffers.Clear();
}
if (!mAudioTrack && !mVideoTrack) {
MSE_DEBUG("MediaSourceReader(%p)::ReadMetadata missing track: mAudioTrack=%p mVideoTrack=%p",
this, mAudioTrack.get(), mVideoTrack.get());