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. // Set the media as being seekable or not.
virtual void SetMediaSeekable(bool aMediaSeekable) = 0; 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 VideoFrameContainer* GetVideoFrameContainer() = 0;
virtual mozilla::layers::ImageContainer* GetImageContainer() = 0; virtual mozilla::layers::ImageContainer* GetImageContainer() = 0;

View File

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

View File

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

View File

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