Bug 1385699. P4 - MediaDecoder::mExplicitDuration doesn't need to be a canonical anymore. r=cpearce

MozReview-Commit-ID: 4FUwQRS2K1m

--HG--
extra : rebase_source : 66b2f1a9fcdf54abd61f071847c1469ad3a3c5c4
extra : source : 0da2d6137100d1cb3ec33d5ce735252eeba3ac62
This commit is contained in:
JW Wang 2017-08-01 15:06:13 +08:00
Родитель 1ab15ede36
Коммит 17554a637a
3 изменённых файлов: 8 добавлений и 14 удалений

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

@ -380,7 +380,6 @@ MediaDecoder::MediaDecoder(MediaDecoderInit& aInit)
, INIT_CANONICAL(mVolume, aInit.mVolume)
, INIT_CANONICAL(mPreservesPitch, aInit.mPreservesPitch)
, INIT_CANONICAL(mLooping, aInit.mLooping)
, INIT_CANONICAL(mExplicitDuration, Maybe<double>())
, INIT_CANONICAL(mPlayState, PLAY_STATE_LOADING)
, INIT_CANONICAL(mLogicallySeeking, false)
, INIT_CANONICAL(mSameOriginMedia, false)
@ -1162,8 +1161,8 @@ MediaDecoder::DurationChanged()
// Use the explicit duration if we have one.
// Otherwise use the duration mirrored from MDSM.
if (mExplicitDuration.Ref().isSome()) {
mDuration = mExplicitDuration.Ref().ref();
if (mExplicitDuration.isSome()) {
mDuration = mExplicitDuration.ref();
} else if (mStateMachineDuration.Ref().isSome()) {
mDuration = mStateMachineDuration.Ref().ref().ToSeconds();
}
@ -1179,9 +1178,8 @@ MediaDecoder::DurationChanged()
// See https://www.w3.org/Bugs/Public/show_bug.cgi?id=28822 for a discussion
// of whether we should fire durationchange on explicit infinity.
if (mFiredMetadataLoaded
&& (!mozilla::IsInfinite<double>(mDuration)
|| mExplicitDuration.Ref().isSome())) {
if (mFiredMetadataLoaded &&
(!mozilla::IsInfinite<double>(mDuration) || mExplicitDuration.isSome())) {
GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("durationchange"));
}

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

@ -464,12 +464,12 @@ protected:
// State-watching manager.
WatchManager<MediaDecoder> mWatchManager;
double ExplicitDuration() { return mExplicitDuration.Ref().ref(); }
double ExplicitDuration() { return mExplicitDuration.ref(); }
void SetExplicitDuration(double aValue)
{
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
mExplicitDuration.Set(Some(aValue));
mExplicitDuration = Some(aValue);
// We Invoke DurationChanged explicitly, rather than using a watcher, so
// that it takes effect immediately, rather than at the end of the current task.
@ -714,7 +714,7 @@ protected:
// Media duration set explicitly by JS. At present, this is only ever present
// for MSE.
Canonical<Maybe<double>> mExplicitDuration;
Maybe<double> mExplicitDuration;
// Set to one of the valid play states.
// This can only be changed on the main thread while holding the decoder
@ -768,10 +768,6 @@ public:
{
return &mLooping;
}
AbstractCanonical<Maybe<double>>* CanonicalExplicitDuration()
{
return &mExplicitDuration;
}
AbstractCanonical<PlayState>* CanonicalPlayState() { return &mPlayState; }
AbstractCanonical<bool>* CanonicalLogicallySeeking()
{

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

@ -31,7 +31,7 @@ MediaSourceDecoder::MediaSourceDecoder(MediaDecoderInit& aInit)
, mMediaSource(nullptr)
, mEnded(false)
{
mExplicitDuration.Set(Some(UnspecifiedNaN<double>()));
mExplicitDuration.emplace(UnspecifiedNaN<double>());
}
MediaDecoderStateMachine*