Index: content/common/gpu/media/vaapi_video_encode_accelerator.cc |
diff --git a/content/common/gpu/media/vaapi_video_encode_accelerator.cc b/content/common/gpu/media/vaapi_video_encode_accelerator.cc |
index cdd03a156fb5194eeef7ed0f4b786315b37dd5c2..3ea4f91d58882642f3c1f10e23458c0e54fadac7 100644 |
--- a/content/common/gpu/media/vaapi_video_encode_accelerator.cc |
+++ b/content/common/gpu/media/vaapi_video_encode_accelerator.cc |
@@ -6,6 +6,7 @@ |
#include "base/bind.h" |
#include "base/callback.h" |
+#include "base/message_loop/message_loop_proxy.h" |
#include "base/metrics/histogram.h" |
#include "base/numerics/safe_conversions.h" |
#include "content/common/gpu/media/h264_dpb.h" |
@@ -132,7 +133,7 @@ |
cpb_size_(0), |
encoding_parameters_changed_(false), |
encoder_thread_("VAVEAEncoderThread"), |
- child_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
+ child_message_loop_proxy_(base::MessageLoopProxy::current()), |
weak_this_ptr_factory_(this) { |
DVLOGF(4); |
weak_this_ = weak_this_ptr_factory_.GetWeakPtr(); |
@@ -146,7 +147,7 @@ |
VaapiVideoEncodeAccelerator::~VaapiVideoEncodeAccelerator() { |
DVLOGF(4); |
- DCHECK(child_task_runner_->BelongsToCurrentThread()); |
+ DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
DCHECK(!encoder_thread_.IsRunning()); |
} |
@@ -156,7 +157,7 @@ |
media::VideoCodecProfile output_profile, |
uint32 initial_bitrate, |
Client* client) { |
- DCHECK(child_task_runner_->BelongsToCurrentThread()); |
+ DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
DCHECK(!encoder_thread_.IsRunning()); |
DCHECK_EQ(state_, kUninitialized); |
@@ -206,18 +207,19 @@ |
LOG(ERROR) << "Failed to start encoder thread"; |
return false; |
} |
- encoder_thread_task_runner_ = encoder_thread_.task_runner(); |
+ encoder_thread_proxy_ = encoder_thread_.message_loop_proxy(); |
// Finish the remaining initialization on the encoder thread. |
- encoder_thread_task_runner_->PostTask( |
- FROM_HERE, base::Bind(&VaapiVideoEncodeAccelerator::InitializeTask, |
- base::Unretained(this))); |
+ encoder_thread_proxy_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&VaapiVideoEncodeAccelerator::InitializeTask, |
+ base::Unretained(this))); |
return true; |
} |
void VaapiVideoEncodeAccelerator::InitializeTask() { |
- DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); |
+ DCHECK(encoder_thread_proxy_->BelongsToCurrentThread()); |
DCHECK_EQ(state_, kUninitialized); |
DVLOGF(4); |
@@ -237,10 +239,13 @@ |
UpdatePPS(); |
GeneratePackedPPS(); |
- child_task_runner_->PostTask( |
+ child_message_loop_proxy_->PostTask( |
FROM_HERE, |
- base::Bind(&Client::RequireBitstreamBuffers, client_, kNumInputBuffers, |
- coded_size_, output_buffer_byte_size_)); |
+ base::Bind(&Client::RequireBitstreamBuffers, |
+ client_, |
+ kNumInputBuffers, |
+ coded_size_, |
+ output_buffer_byte_size_)); |
SetState(kEncoding); |
} |
@@ -248,7 +253,7 @@ |
void VaapiVideoEncodeAccelerator::RecycleVASurfaceID( |
VASurfaceID va_surface_id) { |
DVLOGF(4) << "va_surface_id: " << va_surface_id; |
- DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); |
+ DCHECK(encoder_thread_proxy_->BelongsToCurrentThread()); |
available_va_surface_ids_.push_back(va_surface_id); |
EncodeFrameTask(); |
@@ -520,7 +525,7 @@ |
} |
void VaapiVideoEncodeAccelerator::TryToReturnBitstreamBuffer() { |
- DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); |
+ DCHECK(encoder_thread_proxy_->BelongsToCurrentThread()); |
if (state_ != kEncoding) |
return; |
@@ -551,9 +556,12 @@ |
<< (encode_job->keyframe ? "(keyframe)" : "") |
<< " id: " << buffer->id << " size: " << data_size; |
- child_task_runner_->PostTask( |
- FROM_HERE, base::Bind(&Client::BitstreamBufferReady, client_, buffer->id, |
- data_size, encode_job->keyframe)); |
+ child_message_loop_proxy_->PostTask(FROM_HERE, |
+ base::Bind(&Client::BitstreamBufferReady, |
+ client_, |
+ buffer->id, |
+ data_size, |
+ encode_job->keyframe)); |
} |
void VaapiVideoEncodeAccelerator::Encode( |
@@ -561,11 +569,14 @@ |
bool force_keyframe) { |
DVLOGF(3) << "Frame timestamp: " << frame->timestamp().InMilliseconds() |
<< " force_keyframe: " << force_keyframe; |
- DCHECK(child_task_runner_->BelongsToCurrentThread()); |
- |
- encoder_thread_task_runner_->PostTask( |
- FROM_HERE, base::Bind(&VaapiVideoEncodeAccelerator::EncodeTask, |
- base::Unretained(this), frame, force_keyframe)); |
+ DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
+ |
+ encoder_thread_proxy_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&VaapiVideoEncodeAccelerator::EncodeTask, |
+ base::Unretained(this), |
+ frame, |
+ force_keyframe)); |
} |
bool VaapiVideoEncodeAccelerator::PrepareNextJob() { |
@@ -600,7 +611,7 @@ |
void VaapiVideoEncodeAccelerator::EncodeTask( |
const scoped_refptr<media::VideoFrame>& frame, |
bool force_keyframe) { |
- DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); |
+ DCHECK(encoder_thread_proxy_->BelongsToCurrentThread()); |
DCHECK_NE(state_, kUninitialized); |
encoder_input_queue_.push( |
@@ -609,7 +620,7 @@ |
} |
void VaapiVideoEncodeAccelerator::EncodeFrameTask() { |
- DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); |
+ DCHECK(encoder_thread_proxy_->BelongsToCurrentThread()); |
if (state_ != kEncoding || encoder_input_queue_.empty()) |
return; |
@@ -652,7 +663,7 @@ |
void VaapiVideoEncodeAccelerator::UseOutputBitstreamBuffer( |
const media::BitstreamBuffer& buffer) { |
DVLOGF(4) << "id: " << buffer.id(); |
- DCHECK(child_task_runner_->BelongsToCurrentThread()); |
+ DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
if (buffer.size() < output_buffer_byte_size_) { |
NOTIFY_ERROR(kInvalidArgumentError, "Provided bitstream buffer too small"); |
@@ -669,15 +680,16 @@ |
scoped_ptr<BitstreamBufferRef> buffer_ref( |
new BitstreamBufferRef(buffer.id(), shm.Pass(), buffer.size())); |
- encoder_thread_task_runner_->PostTask( |
+ encoder_thread_proxy_->PostTask( |
FROM_HERE, |
base::Bind(&VaapiVideoEncodeAccelerator::UseOutputBitstreamBufferTask, |
- base::Unretained(this), base::Passed(&buffer_ref))); |
+ base::Unretained(this), |
+ base::Passed(&buffer_ref))); |
} |
void VaapiVideoEncodeAccelerator::UseOutputBitstreamBufferTask( |
scoped_ptr<BitstreamBufferRef> buffer_ref) { |
- DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); |
+ DCHECK(encoder_thread_proxy_->BelongsToCurrentThread()); |
DCHECK_NE(state_, kUninitialized); |
available_bitstream_buffers_.push(make_linked_ptr(buffer_ref.release())); |
@@ -688,19 +700,21 @@ |
uint32 bitrate, |
uint32 framerate) { |
DVLOGF(2) << "bitrate: " << bitrate << " framerate: " << framerate; |
- DCHECK(child_task_runner_->BelongsToCurrentThread()); |
- |
- encoder_thread_task_runner_->PostTask( |
+ DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
+ |
+ encoder_thread_proxy_->PostTask( |
FROM_HERE, |
base::Bind( |
&VaapiVideoEncodeAccelerator::RequestEncodingParametersChangeTask, |
- base::Unretained(this), bitrate, framerate)); |
+ base::Unretained(this), |
+ bitrate, |
+ framerate)); |
} |
void VaapiVideoEncodeAccelerator::UpdateRates(uint32 bitrate, |
uint32 framerate) { |
if (encoder_thread_.IsRunning()) |
- DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); |
+ DCHECK(encoder_thread_proxy_->BelongsToCurrentThread()); |
DCHECK_NE(bitrate, 0u); |
DCHECK_NE(framerate, 0u); |
bitrate_ = bitrate; |
@@ -712,7 +726,7 @@ |
uint32 bitrate, |
uint32 framerate) { |
DVLOGF(2) << "bitrate: " << bitrate << " framerate: " << framerate; |
- DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); |
+ DCHECK(encoder_thread_proxy_->BelongsToCurrentThread()); |
DCHECK_NE(state_, kUninitialized); |
// This is a workaround to zero being temporarily, as part of the initial |
@@ -738,7 +752,7 @@ |
} |
void VaapiVideoEncodeAccelerator::Destroy() { |
- DCHECK(child_task_runner_->BelongsToCurrentThread()); |
+ DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
// Can't call client anymore after Destroy() returns. |
client_ptr_factory_.reset(); |
@@ -758,7 +772,7 @@ |
void VaapiVideoEncodeAccelerator::DestroyTask() { |
DVLOGF(2); |
- DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); |
+ DCHECK(encoder_thread_proxy_->BelongsToCurrentThread()); |
SetState(kError); |
} |
@@ -1022,10 +1036,12 @@ |
void VaapiVideoEncodeAccelerator::SetState(State state) { |
// Only touch state on encoder thread, unless it's not running. |
if (encoder_thread_.IsRunning() && |
- !encoder_thread_task_runner_->BelongsToCurrentThread()) { |
- encoder_thread_task_runner_->PostTask( |
- FROM_HERE, base::Bind(&VaapiVideoEncodeAccelerator::SetState, |
- base::Unretained(this), state)); |
+ !encoder_thread_proxy_->BelongsToCurrentThread()) { |
+ encoder_thread_proxy_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&VaapiVideoEncodeAccelerator::SetState, |
+ base::Unretained(this), |
+ state)); |
return; |
} |
@@ -1034,10 +1050,11 @@ |
} |
void VaapiVideoEncodeAccelerator::NotifyError(Error error) { |
- if (!child_task_runner_->BelongsToCurrentThread()) { |
- child_task_runner_->PostTask( |
- FROM_HERE, base::Bind(&VaapiVideoEncodeAccelerator::NotifyError, |
- weak_this_, error)); |
+ if (!child_message_loop_proxy_->BelongsToCurrentThread()) { |
+ child_message_loop_proxy_->PostTask( |
+ FROM_HERE, |
+ base::Bind( |
+ &VaapiVideoEncodeAccelerator::NotifyError, weak_this_, error)); |
return; |
} |