Skip to content

Commit

Permalink
Bug 1833266 - part4 : let new created MDSM have the same status with …
Browse files Browse the repository at this point in the history
…the old one. r=jolin

Some attributes of media decoder can be mirrored to MDSM automatically
by state mirroring.

But seeking and playback rate change needs to be performed manually in
order to let the new created MDSM look like the old one.

Differential Revision: https://phabricator.services.mozilla.com/D178127
  • Loading branch information
alastor0325 committed May 18, 2023
1 parent 42570e8 commit fb525c5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
19 changes: 18 additions & 1 deletion dom/media/MediaDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,12 @@ void MediaDecoder::OnPlaybackErrorEvent(const MediaResult& aError) {
LOG("Failed to create a new state machine!");
}

// TODO : need to make the new MDSM have the same status as the previous one
// Some attributes might have been set on the destroyed state machine, and
// won't be reflected on the new MDSM by the state mirroring. We need to
// update them manually later, after MDSM finished reading the
// metadata because the MDSM might not be ready to perform the operations yet.
mPendingStatusUpdateForNewlyCreatedStateMachine = true;

discardStateMachine->BeginShutdown()->Then(
AbstractThread::MainThread(), __func__, [discardStateMachine] {});
#endif
Expand Down Expand Up @@ -779,6 +784,18 @@ void MediaDecoder::MetadataLoaded(
// the media element has the latest dimensions.
Invalidate();

#ifdef MOZ_WMF_MEDIA_ENGINE
if (mPendingStatusUpdateForNewlyCreatedStateMachine) {
mPendingStatusUpdateForNewlyCreatedStateMachine = false;
if (mLogicalPosition != 0) {
Seek(mLogicalPosition, SeekTarget::Accurate);
}
if (mPlaybackRate != 0 && mPlaybackRate != 1.0) {
mDecoderStateMachine->DispatchSetPlaybackRate(mPlaybackRate);
}
}
#endif

EnsureTelemetryReported();
}

Expand Down
6 changes: 6 additions & 0 deletions dom/media/MediaDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,12 @@ class MediaDecoder : public DecoderDoctorLifeLogger<MediaDecoder> {
bool mCanPlayThrough = false;

UniquePtr<TelemetryProbesReporter> mTelemetryProbesReporter;

# ifdef MOZ_WMF_MEDIA_ENGINE
// True when we need to update the newly created MDSM's status to make it
// consistent with the previous destroyed one.
bool mPendingStatusUpdateForNewlyCreatedStateMachine = false;
# endif
};

typedef MozPromise<mozilla::dom::MediaMemoryInfo, nsresult, true>
Expand Down

0 comments on commit fb525c5

Please sign in to comment.