Bug 1224973 - Part 3: Plumb element visibility into MDSM. r=jya,jwwang

change MediaDecoder::mIsVisible to be a Canonical<bool> and plumb through to
the MediaDecoderStateMachine.  This will be used to trigger suspending the
decoding of video frames.

MozReview-Commit-ID: F3Dpf0ogE7c
This commit is contained in:
Dan Glastonbury 2016-04-12 17:00:29 +10:00 коммит произвёл Dan Glastonbury
Родитель 9f98a19f8c
Коммит 78730160f5
7 изменённых файлов: 32 добавлений и 6 удалений

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

@ -62,7 +62,7 @@ public:
// Return an event that will be notified when data arrives in MediaResource.
// MediaDecoderReader will register with this event to receive notifications
// in order to udpate buffer ranges.
// in order to update buffer ranges.
// Return null if this decoder doesn't support the event.
virtual MediaEventSource<void>* DataArrivedEvent()
{

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

@ -335,7 +335,7 @@ MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity)
"ownerActive=%d mIsVisible=%d mIsHeuristicDormant=%d "
"mPlayState=%s encrypted=%s",
aDormantTimeout, aActivity, mIsDormant, mOwner->IsActive(),
mIsVisible, mIsHeuristicDormant, PlayStateStr(),
mIsVisible.Ref(), mIsHeuristicDormant, PlayStateStr(),
(!mInfo ? "Unknown" : (mInfo->IsEncrypted() ? "1" : "0")));
bool prevDormant = mIsDormant;
@ -574,7 +574,8 @@ MediaDecoder::MediaDecoder(MediaDecoderOwner* aOwner)
"MediaDecoder::mMediaSeekable (Canonical)")
, mMediaSeekableOnlyInBufferedRanges(AbstractThread::MainThread(), false,
"MediaDecoder::mMediaSeekableOnlyInBufferedRanges (Canonical)")
, mIsVisible(!mOwner->IsHidden())
, mIsVisible(AbstractThread::MainThread(), !mOwner->IsHidden(),
"MediaDecoder::mIsVisible (Canonical)")
, mTelemetryReported(false)
{
MOZ_COUNT_CTOR(MediaDecoder);

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

@ -744,7 +744,7 @@ protected:
// start playing back again.
Mirror<int64_t> mPlaybackPosition;
// Used to distiguish whether the audio is producing sound.
// Used to distinguish whether the audio is producing sound.
Mirror<bool> mIsAudioDataAudible;
// Volume of playback. 0.0 = muted. 1.0 = full volume.
@ -806,7 +806,8 @@ protected:
// True if the media is only seekable within its buffered ranges.
Canonical<bool> mMediaSeekableOnlyInBufferedRanges;
bool mIsVisible;
// True if the decoder is visible.
Canonical<bool> mIsVisible;
public:
AbstractCanonical<media::NullableTimeUnit>* CanonicalDurationOrNull() override;
@ -855,6 +856,9 @@ public:
AbstractCanonical<bool>* CanonicalMediaSeekableOnlyInBufferedRanges() {
return &mMediaSeekableOnlyInBufferedRanges;
}
AbstractCanonical<bool>* CanonicalIsVisible() {
return &mIsVisible;
}
private:
// Notify owner when the audible state changed

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

@ -183,6 +183,10 @@ MediaDecoderReader::UpdateBuffered()
mBuffered = GetBuffered();
}
void
MediaDecoderReader::VisibilityChanged()
{}
media::TimeIntervals
MediaDecoderReader::GetBuffered()
{

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

@ -395,6 +395,8 @@ private:
// Recomputes mBuffered.
virtual void UpdateBuffered();
virtual void VisibilityChanged();
virtual void NotifyDataArrivedInternal() {}
// Overrides of this function should decodes an unspecified amount of

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

@ -271,6 +271,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
"MediaDecoderStateMachine::mMediaSeekable (Mirror)"),
mMediaSeekableOnlyInBufferedRanges(mTaskQueue, false,
"MediaDecoderStateMachine::mMediaSeekableOnlyInBufferedRanges (Mirror)"),
mIsVisible(mTaskQueue, true, "MediaDecoderStateMachine::mIsVisible (Mirror)"),
mDuration(mTaskQueue, NullableTimeUnit(),
"MediaDecoderStateMachine::mDuration (Canonical"),
mIsShutdown(mTaskQueue, false,
@ -333,6 +334,7 @@ MediaDecoderStateMachine::InitializationTask(MediaDecoder* aDecoder)
mDecoderPosition.Connect(aDecoder->CanonicalDecoderPosition());
mMediaSeekable.Connect(aDecoder->CanonicalMediaSeekable());
mMediaSeekableOnlyInBufferedRanges.Connect(aDecoder->CanonicalMediaSeekableOnlyInBufferedRanges());
mIsVisible.Connect(aDecoder->CanonicalIsVisible());
// Initialize watchers.
mWatchManager.Watch(mBuffered, &MediaDecoderStateMachine::BufferedRangeUpdated);
@ -346,6 +348,7 @@ MediaDecoderStateMachine::InitializationTask(MediaDecoder* aDecoder)
mWatchManager.Watch(mExplicitDuration, &MediaDecoderStateMachine::RecomputeDuration);
mWatchManager.Watch(mObservedDuration, &MediaDecoderStateMachine::RecomputeDuration);
mWatchManager.Watch(mPlayState, &MediaDecoderStateMachine::PlayStateChanged);
mWatchManager.Watch(mIsVisible, &MediaDecoderStateMachine::VisibilityChanged);
// Configure MediaDecoderReaderWrapper.
SetMediaDecoderReaderWrapperCallback();
@ -1312,6 +1315,11 @@ void MediaDecoderStateMachine::PlayStateChanged()
ScheduleStateMachine();
}
void MediaDecoderStateMachine::VisibilityChanged()
{
DECODER_LOG("VisibilityChanged: is visible = %c", mIsVisible ? 'T' : 'F');
}
void MediaDecoderStateMachine::BufferedRangeUpdated()
{
MOZ_ASSERT(OnTaskQueue());
@ -2085,6 +2093,7 @@ MediaDecoderStateMachine::FinishShutdown()
mDecoderPosition.DisconnectIfConnected();
mMediaSeekable.DisconnectIfConnected();
mMediaSeekableOnlyInBufferedRanges.DisconnectIfConnected();
mIsVisible.DisconnectIfConnected();
mDuration.DisconnectAll();
mIsShutdown.DisconnectAll();

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

@ -471,6 +471,9 @@ protected:
// Notification method invoked when mPlayState changes.
void PlayStateChanged();
// Notification method invoked when mIsVisible changes.
void VisibilityChanged();
// Sets internal state which causes playback of media to pause.
// The decoder monitor must be held.
void StopPlayback();
@ -997,6 +1000,9 @@ private:
// True if the media is seekable only in buffered ranges.
Mirror<bool> mMediaSeekableOnlyInBufferedRanges;
// IsVisible, mirrored from the media decoder.
Mirror<bool> mIsVisible;
// Duration of the media. This is guaranteed to be non-null after we finish
// decoding the first frame.
Canonical<media::NullableTimeUnit> mDuration;
@ -1016,7 +1022,7 @@ private:
// Current playback position in the stream in bytes.
Canonical<int64_t> mPlaybackOffset;
// Used to distiguish whether the audio is producing sound.
// Used to distinguish whether the audio is producing sound.
Canonical<bool> mIsAudioDataAudible;
public: