Bug 1204430. Part 1 - dispatch AbstractMediaDecoder::SetMediaSeekable() to the main thread. r=kinetik.

This commit is contained in:
JW Wang 2015-09-21 13:48:39 +08:00
parent a12546643f
commit 7d3c2064f3
4 changed files with 10 additions and 5 deletions

View File

@ -93,6 +93,13 @@ public:
// Set the media as being seekable or not.
virtual void SetMediaSeekable(bool aMediaSeekable) = 0;
void DispatchSetMediaSeekable(bool aMediaSeekable)
{
nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethodWithArg<bool>(
this, &AbstractMediaDecoder::SetMediaSeekable, aMediaSeekable);
NS_DispatchToMainThread(r);
}
virtual VideoFrameContainer* GetVideoFrameContainer() = 0;
virtual mozilla::layers::ImageContainer* GetImageContainer() = 0;

View File

@ -1110,6 +1110,7 @@ void MediaDecoder::UpdateEstimatedMediaDuration(int64_t aDuration)
}
void MediaDecoder::SetMediaSeekable(bool aMediaSeekable) {
MOZ_ASSERT(NS_IsMainThread());
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
mMediaSeekable = aMediaSeekable;
}

View File

@ -1932,7 +1932,7 @@ MediaDecoderStateMachine::OnMetadataRead(MetadataHolder* aMetadata)
// Set mode to PLAYBACK after reading metadata.
mResource->SetReadMode(MediaCacheStream::MODE_PLAYBACK);
mDecoder->SetMediaSeekable(mReader->IsMediaSeekable());
mDecoder->DispatchSetMediaSeekable(mReader->IsMediaSeekable());
mInfo = aMetadata->mInfo;
mMetadataTags = aMetadata->mTags.forget();
nsRefPtr<MediaDecoderStateMachine> self = this;

View File

@ -720,10 +720,7 @@ void OggReader::SetChained(bool aIsChained) {
ReentrantMonitorAutoEnter mon(mMonitor);
mIsChained = aIsChained;
}
{
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mDecoder->SetMediaSeekable(false);
}
mDecoder->DispatchSetMediaSeekable(false);
}
bool OggReader::ReadOggChain()