Bug 1393386. P1 - make PinForSeek/UnpinForSeek pure virtual. r=gerald

Sub-classes should know how to pin/unpin the resource.

MozReview-Commit-ID: 50S8oSD5oEU

--HG--
extra : rebase_source : 5e1b7c657b759c0d1dfdd7b5c0a4b7dbc4077ffe
extra : intermediate-source : 3000b76a3b97c08955c2d584ac215114c8e8f59a
extra : source : a56b9846db916ff85a0cae09736c3284bd895506
This commit is contained in:
JW Wang 2017-08-24 18:08:37 +08:00
Родитель 5b56b9035b
Коммит 4af519df25
6 изменённых файлов: 39 добавлений и 36 удалений

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

@ -537,6 +537,29 @@ ChannelMediaDecoder::Resume()
}
}
void
ChannelMediaDecoder::PinForSeek()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mResource || mPinnedForSeek) {
return;
}
mPinnedForSeek = true;
mResource->Pin();
}
void
ChannelMediaDecoder::UnpinForSeek()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
if (!mResource || !mPinnedForSeek) {
return;
}
mPinnedForSeek = false;
mResource->Unpin();
}
void
ChannelMediaDecoder::MetadataLoaded(
UniquePtr<MediaInfo> aInfo,

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

@ -87,6 +87,8 @@ public:
private:
MediaResource* GetResource() const override final;
void PinForSeek() override;
void UnpinForSeek() override;
// Create a new state machine to run this decoder.
MediaDecoderStateMachine* CreateStateMachine();
@ -142,6 +144,10 @@ private:
// True if mPlaybackBytesPerSecond is a reliable estimate.
bool mPlaybackRateReliable = true;
// True when our media stream has been pinned. We pin the stream
// while seeking.
bool mPinnedForSeek = false;
};
} // namespace mozilla

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

@ -366,7 +366,6 @@ MediaDecoder::MediaDecoder(MediaDecoderInit& aInit)
, mAbstractMainThread(aInit.mOwner->AbstractMainThread())
, mFrameStats(new FrameStatistics())
, mVideoFrameContainer(aInit.mOwner->GetVideoFrameContainer())
, mPinnedForSeek(false)
, mMinimizePreroll(aInit.mMinimizePreroll)
, mFiredMetadataLoaded(false)
, mIsDocumentVisible(false)
@ -1369,31 +1368,6 @@ MediaDecoder::FireTimeUpdate()
GetOwner()->FireTimeUpdate(true);
}
void
MediaDecoder::PinForSeek()
{
MOZ_ASSERT(NS_IsMainThread());
MediaResource* resource = GetResource();
if (!resource || mPinnedForSeek) {
return;
}
mPinnedForSeek = true;
resource->Pin();
}
void
MediaDecoder::UnpinForSeek()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
MediaResource* resource = GetResource();
if (!resource || !mPinnedForSeek) {
return;
}
mPinnedForSeek = false;
resource->Unpin();
}
bool
MediaDecoder::CanPlayThrough()
{

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

@ -490,6 +490,12 @@ private:
// passed to a platform decoder.
virtual MediaResource* GetResource() const = 0;
// Ensures our media resource has been pinned.
virtual void PinForSeek() = 0;
// Ensures our media resource has been unpinned.
virtual void UnpinForSeek() = 0;
nsCString GetDebugInfo();
// Called when the owner's activity changed.
@ -539,12 +545,6 @@ protected:
MozPromiseRequestHolder<SeekPromise> mSeekRequest;
// Ensures our media stream has been pinned.
void PinForSeek();
// Ensures our media stream has been unpinned.
void UnpinForSeek();
const char* PlayStateStr();
void OnMetadataUpdate(TimedMetadata&& aMetadata);
@ -562,10 +562,6 @@ protected:
RefPtr<VideoFrameContainer> mVideoFrameContainer;
// True when our media stream has been pinned. We pin the stream
// while seeking.
bool mPinnedForSeek;
// True if the decoder has been directed to minimize its preroll before
// playback starts. After the first time playback starts, we don't attempt
// to minimize preroll, as we assume the user is likely to keep playing,

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

@ -45,6 +45,8 @@ public:
private:
MediaResource* GetResource() const override final;
void PinForSeek() override {}
void UnpinForSeek() override {}
MediaDecoderStateMachine* CreateStateMachine();

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

@ -67,6 +67,8 @@ public:
private:
MediaResource* GetResource() const override final;
void PinForSeek() override {}
void UnpinForSeek() override {}
MediaDecoderStateMachine* CreateStateMachine();
void DoSetMediaSourceDuration(double aDuration);
media::TimeInterval ClampIntervalToEnd(const media::TimeInterval& aInterval);