Skip to content

Commit

Permalink
Simplify WebMediaPlayerMSCompositor destruction.
Browse files Browse the repository at this point in the history
The code was only sometimes calling StopUsingProvider() and posted
the submitter destruction unnecessarily.

Destruction now works the same as in VideoFrameCompositor, where the
class itself is responsible for calling StopUsingProvider() during
its own destruction.

Fixed: 1407701
Change-Id: Ia649cb5532519468eea34e12745ed9c990580d82
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4195824
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Tony Herre <toprice@chromium.org>
Reviewed-by: Frank Liberato <liberato@chromium.org>
Reviewed-by: Tony Herre <toprice@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1098505}
  • Loading branch information
dalecurtis authored and Chromium LUCI CQ committed Jan 30, 2023
1 parent c80b7b3 commit cbd238e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,6 @@ WebMediaPlayerMS::~WebMediaPlayerMS() {
if (frame_deliverer_)
video_task_runner_->DeleteSoon(FROM_HERE, frame_deliverer_.release());

if (compositor_)
compositor_->StopUsingProvider();

if (video_frame_provider_)
video_frame_provider_->Stop();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,8 @@ WebMediaPlayerMSCompositor::WebMediaPlayerMSCompositor(
WebMediaPlayerMSCompositor::~WebMediaPlayerMSCompositor() {
// Ensured by destructor traits.
DCHECK(video_frame_compositor_task_runner_->BelongsToCurrentThread());

if (submitter_) {
video_frame_compositor_task_runner_->DeleteSoon(FROM_HERE,
std::move(submitter_));
} else {
DCHECK(!video_frame_provider_client_)
<< "Must call StopUsingProvider() before dtor!";
if (video_frame_provider_client_) {
video_frame_provider_client_->StopUsingProvider();
}
}

Expand All @@ -265,7 +260,7 @@ void WebMediaPlayerMSCompositorTraits::Destruct(

void WebMediaPlayerMSCompositor::InitializeSubmitter() {
DCHECK(video_frame_compositor_task_runner_->BelongsToCurrentThread());
submitter_->Initialize(this, /* is_media_stream = */ true);
submitter_->Initialize(this, /*is_media_stream=*/true);
}

void WebMediaPlayerMSCompositor::SetIsSurfaceVisible(
Expand Down Expand Up @@ -632,15 +627,6 @@ void WebMediaPlayerMSCompositor::ReplaceCurrentFrameWithACopy() {
WrapRefCounted(this))));
}

void WebMediaPlayerMSCompositor::StopUsingProvider() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
PostCrossThreadTask(
*video_frame_compositor_task_runner_, FROM_HERE,
CrossThreadBindOnce(
&WebMediaPlayerMSCompositor::StopUsingProviderInternal,
WrapRefCounted(this)));
}

bool WebMediaPlayerMSCompositor::MapTimestampsToRenderTimeTicks(
const std::vector<base::TimeDelta>& timestamps,
std::vector<base::TimeTicks>* wall_clock_times) {
Expand Down Expand Up @@ -874,13 +860,6 @@ void WebMediaPlayerMSCompositor::StopRenderingInternal() {
video_frame_provider_client_->StopRendering();
}

void WebMediaPlayerMSCompositor::StopUsingProviderInternal() {
DCHECK(video_frame_compositor_task_runner_->BelongsToCurrentThread());
if (video_frame_provider_client_)
video_frame_provider_client_->StopUsingProvider();
video_frame_provider_client_ = nullptr;
}

void WebMediaPlayerMSCompositor::ReplaceCurrentFrameWithACopyInternal() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
scoped_refptr<media::VideoFrame> current_frame_ref;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor
void StopRendering();
void ReplaceCurrentFrameWithACopy();

// Tell |video_frame_provider_client_| to stop using this instance in
// preparation for dtor.
void StopUsingProvider();

// Sets a hook to be notified when a new frame is presented, to fulfill a
// prending video.requestAnimationFrame() request.
// Can be called from any thread.
Expand Down Expand Up @@ -210,7 +206,6 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor

void StartRenderingInternal();
void StopRenderingInternal();
void StopUsingProviderInternal();
void ReplaceCurrentFrameWithACopyInternal();

void SetAlgorithmEnabledForTesting(bool algorithm_enabled);
Expand Down

0 comments on commit cbd238e

Please sign in to comment.