0

vaapi cleanup: move TRACE_COUNTER1(input buffers) to a better place

This CL moves a TRACE_COUNTER1() counting input_buffers_.size()
from its current position to next to |input_buffers_| actions
(i.e. where it grows or shrinks).

It also renames s/GetInputBuffer_Locked/GetCurrInputBuffer_Locked/
to better reflect what the method does.

Cosmetic changes:
- removes .get() on checks for |curr_input_buffer_|
(bc unique_ptr<> has an operator boolean()).
- Removes unnecessary curly brackets.
- Removes superfluous comments.
- Escapes some variable names in comments.

TEST= simplechrome w/ crosvideos and v_d_a_unittests on soraka

Bug: 717265
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I5b3d51fd1509f8d0ce87487a44d6c7a77b4a253b
Reviewed-on: https://chromium-review.googlesource.com/934403
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Reviewed-by: Daniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539470}
This commit is contained in:
Miguel Casas
2018-02-27 17:11:34 +00:00
committed by Commit Bot
parent 261ffb73dd
commit c66b015961
2 changed files with 15 additions and 20 deletions

@ -284,10 +284,9 @@ void VaapiVideoDecodeAccelerator::QueueInputBuffer(
BindToCurrentLoop(
base::Bind(&Client::NotifyEndOfBitstreamBuffer, client_)));
input_buffers_.push(std::move(input_buffer));
TRACE_COUNTER1("media,gpu", "Input buffers", input_buffers_.size());
}
TRACE_COUNTER1("media,gpu", "Input buffers", input_buffers_.size());
input_ready_.Signal();
switch (state_) {
@ -316,7 +315,7 @@ void VaapiVideoDecodeAccelerator::QueueInputBuffer(
}
}
bool VaapiVideoDecodeAccelerator::GetInputBuffer_Locked() {
bool VaapiVideoDecodeAccelerator::GetCurrInputBuffer_Locked() {
DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread());
lock_.AssertAcquired();
@ -325,9 +324,8 @@ bool VaapiVideoDecodeAccelerator::GetInputBuffer_Locked() {
// Will only wait if it is expected that in current state new buffers will
// be queued from the client via Decode(). The state can change during wait.
while (input_buffers_.empty() && (state_ == kDecoding || state_ == kIdle)) {
while (input_buffers_.empty() && (state_ == kDecoding || state_ == kIdle))
input_ready_.Wait();
}
// We could have got woken up in a different state or never got to sleep
// due to current state.
@ -337,13 +335,14 @@ bool VaapiVideoDecodeAccelerator::GetInputBuffer_Locked() {
DCHECK(!input_buffers_.empty());
curr_input_buffer_ = std::move(input_buffers_.front());
input_buffers_.pop();
TRACE_COUNTER1("media,gpu", "Input buffers", input_buffers_.size());
if (curr_input_buffer_->IsFlushRequest()) {
VLOGF(4) << "New flush buffer";
return true;
}
VLOGF(4) << "New current input buffer, id: " << curr_input_buffer_->id()
VLOGF(4) << "New |curr_input_buffer_|, id: " << curr_input_buffer_->id()
<< " size: " << curr_input_buffer_->shm()->size() << "B";
decoder_->SetStream(
static_cast<uint8_t*>(curr_input_buffer_->shm()->memory()),
@ -357,8 +356,6 @@ void VaapiVideoDecodeAccelerator::ReturnCurrInputBuffer_Locked() {
lock_.AssertAcquired();
DCHECK(curr_input_buffer_.get());
curr_input_buffer_.reset();
TRACE_COUNTER1("media,gpu", "Input buffers", input_buffers_.size());
}
// TODO(posciak): refactor the whole class to remove sleeping in wait for
@ -381,13 +378,11 @@ void VaapiVideoDecodeAccelerator::DecodeTask() {
if (state_ != kDecoding)
return;
// Main decode task.
VLOGF(4) << "Decode task";
// Try to decode what stream data is (still) in the decoder until we run out
// of it.
while (GetInputBuffer_Locked()) {
while (GetCurrInputBuffer_Locked()) {
DCHECK(curr_input_buffer_.get());
if (curr_input_buffer_->IsFlushRequest()) {
@ -689,7 +684,7 @@ void VaapiVideoDecodeAccelerator::ReusePictureBuffer(
void VaapiVideoDecodeAccelerator::FlushTask() {
VLOGF(2);
DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread());
DCHECK(curr_input_buffer_.get() && curr_input_buffer_->IsFlushRequest());
DCHECK(curr_input_buffer_ && curr_input_buffer_->IsFlushRequest());
curr_input_buffer_.reset();
@ -759,7 +754,7 @@ void VaapiVideoDecodeAccelerator::ResetTask() {
base::AutoLock auto_lock(lock_);
// Return current input buffer, if present.
if (curr_input_buffer_.get())
if (curr_input_buffer_)
ReturnCurrInputBuffer_Locked();
// And let client know that we are done with reset.

@ -114,17 +114,17 @@ class MEDIA_GPU_EXPORT VaapiVideoDecodeAccelerator
// Queue a input buffer for decode.
void QueueInputBuffer(const BitstreamBuffer& bitstream_buffer);
// Get a new input buffer from the queue and set it up in decoder. This will
// sleep if no input buffers are available. Return true if a new buffer has
// been set up, false if an early exit has been requested (due to initiated
// reset/flush/destroy).
bool GetInputBuffer_Locked();
// Gets a new |current_input_buffer_| from |input_buffers_| and sets it up in
// |decoder_|. This method will sleep if no |input_buffers_| are available.
// Returns true if a new buffer has been set up, false if an early exit has
// been requested (due to initiated reset/flush/destroy).
bool GetCurrInputBuffer_Locked();
// Signal the client that the current buffer has been read and can be
// Signals the client that |curr_input_buffer_| has been read and can be
// returned. Will also release the mapping.
void ReturnCurrInputBuffer_Locked();
// Wait for more surfaces to become available. Return true once they do or
// Waits for more surfaces to become available. Returns true once they do or
// false if an early exit has been requested (due to an initiated
// reset/flush/destroy).
bool WaitForSurfaces_Locked();