Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: content/renderer/media_recorder/video_track_recorder.cc

Issue 2750993002: Move destruction of VEAEncoder to encoding task runner (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media_recorder/video_track_recorder.cc
diff --git a/content/renderer/media_recorder/video_track_recorder.cc b/content/renderer/media_recorder/video_track_recorder.cc
index d77d300d8da957f3b0675927fff963acca09c093..92b20bc92cd36ea17ae421bd61e0d3f08a615e31 100644
--- a/content/renderer/media_recorder/video_track_recorder.cc
+++ b/content/renderer/media_recorder/video_track_recorder.cc
@@ -449,6 +449,8 @@ class VEAEncoder final : public VideoTrackRecorder::Encoder,
base::TimeTicks capture_timestamp) override;
void ConfigureEncoderOnEncodingTaskRunner(const gfx::Size& size) override;
+ void DestroyOnEncodingTaskRunner(base::WaitableEvent* async_waiter);
+
media::GpuVideoAcceleratorFactories* const gpu_factories_;
const media::VideoCodecProfile codec_;
@@ -585,9 +587,17 @@ VEAEncoder::VEAEncoder(
}
VEAEncoder::~VEAEncoder() {
+ DVLOG(3) << __func__;
mcasas 2017/03/15 01:14:17 nit: remove the DVLOG()s
emircan 2017/03/15 01:36:18 Done.
+
+ base::WaitableEvent release_waiter(
+ base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+ // base::Unretained is safe because the class will be alive until
+ // |release_waiter| is signaled.
mcasas 2017/03/15 01:14:17 I (still) think we need a comment here saying that
emircan 2017/03/15 01:36:18 Done.
encoding_task_runner_->PostTask(
- FROM_HERE, base::Bind(&media::VideoEncodeAccelerator::Destroy,
- base::Unretained(video_encoder_.release())));
+ FROM_HERE, base::Bind(&VEAEncoder::DestroyOnEncodingTaskRunner,
+ base::Unretained(this), &release_waiter));
+ release_waiter.Wait();
}
void VEAEncoder::RequireBitstreamBuffers(unsigned int /*input_count*/,
@@ -744,10 +754,7 @@ void VEAEncoder::EncodeOnEncodingTaskRunner(
frames_in_encode_.push(std::make_pair(
media::WebmMuxer::VideoParameters(frame), capture_timestamp));
- encoding_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&media::VideoEncodeAccelerator::Encode,
- base::Unretained(video_encoder_.get()), video_frame, false));
+ video_encoder_->Encode(video_frame, false);
}
void VEAEncoder::ConfigureEncoderOnEncodingTaskRunner(const gfx::Size& size) {
@@ -765,6 +772,14 @@ void VEAEncoder::ConfigureEncoderOnEncodingTaskRunner(const gfx::Size& size) {
}
}
+void VEAEncoder::DestroyOnEncodingTaskRunner(
+ base::WaitableEvent* async_waiter) {
+ DVLOG(3) << __func__;
+ DCHECK(encoding_task_runner_->BelongsToCurrentThread());
mcasas 2017/03/15 01:14:17 This one as well.
emircan 2017/03/15 01:36:18 Done.
+ video_encoder_.reset();
+ async_waiter->Signal();
+}
+
// static
void VpxEncoder::ShutdownEncoder(std::unique_ptr<base::Thread> encoding_thread,
ScopedVpxCodecCtxPtr encoder) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698