Bug 1353607. P4 - change the type of mFragmentEndTime to TimeUnit.
MozReview-Commit-ID: FhUZMpXokSt
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2606,17 +2606,16 @@ MediaDecoderStateMachine::MediaDecoderSt
mAudioChannel(aDecoder->GetAudioChannel()),
mTaskQueue(new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK),
/* aSupportsTailDispatch = */ true)),
mWatchManager(this, mTaskQueue),
mDispatchedStateMachine(false),
mDelayedScheduler(mTaskQueue),
mCurrentFrameID(0),
INIT_WATCHABLE(mObservedDuration, TimeUnit()),
- mFragmentEndTime(-1),
mReader(new MediaDecoderReaderWrapper(mTaskQueue, aReader)),
mDecodedAudioEndTime(0),
mDecodedVideoEndTime(0),
mPlaybackRate(1.0),
mLowAudioThreshold(detail::LOW_AUDIO_THRESHOLD),
mAmpleAudioThreshold(detail::AMPLE_AUDIO_THRESHOLD),
mAudioCaptured(false),
mMinimizePreroll(aDecoder->GetMinimizePreroll()),
@@ -2930,18 +2929,18 @@ MediaDecoderStateMachine::UpdatePlayback
}
void
MediaDecoderStateMachine::UpdatePlaybackPosition(const TimeUnit& aTime)
{
MOZ_ASSERT(OnTaskQueue());
UpdatePlaybackPositionInternal(aTime);
- bool fragmentEnded = mFragmentEndTime >= 0
- && GetMediaTime().ToMicroseconds() >= mFragmentEndTime;
+ bool fragmentEnded = mFragmentEndTime.IsValid()
+ && GetMediaTime() >= mFragmentEndTime;
mMetadataManager.DispatchMetadataIfNeeded(aTime);
if (fragmentEnded) {
StopPlayback();
}
}
/* static */ const char*
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -189,17 +189,20 @@ public:
RefPtr<ShutdownPromise> BeginShutdown();
// Set the media fragment end time. aEndTime is in microseconds.
void DispatchSetFragmentEndTime(int64_t aEndTime)
{
RefPtr<MediaDecoderStateMachine> self = this;
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([self, aEndTime] () {
- self->mFragmentEndTime = aEndTime;
+ // A negative number means we don't have a fragment end time at all.
+ self->mFragmentEndTime = aEndTime >= 0
+ ? media::TimeUnit::FromMicroseconds(aEndTime)
+ : media::TimeUnit::Invalid();
});
OwnerThread()->Dispatch(r.forget());
}
// Drop reference to mResource. Only called during shutdown dance.
void BreakCycles() {
MOZ_ASSERT(NS_IsMainThread());
mResource = nullptr;
@@ -535,18 +538,18 @@ private:
// The decoder monitor must be held.
bool IsLogicallyPlaying()
{
MOZ_ASSERT(OnTaskQueue());
return mPlayState == MediaDecoder::PLAY_STATE_PLAYING
|| mNextPlayState == MediaDecoder::PLAY_STATE_PLAYING;
}
- // Media Fragment end time in microseconds. Access controlled by decoder monitor.
- int64_t mFragmentEndTime;
+ // Media Fragment end time.
+ media::TimeUnit mFragmentEndTime = media::TimeUnit::Invalid();
// The media sink resource. Used on the state machine thread.
RefPtr<media::MediaSink> mMediaSink;
const RefPtr<MediaDecoderReaderWrapper> mReader;
// The end time of the last audio frame that's been pushed onto the media sink
// in microseconds. This will approximately be the end time