diff options
author | Torne (Richard Coles) <torne@google.com> | 2014-02-21 12:16:55 +0000 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2014-02-21 12:16:55 +0000 |
commit | 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7 (patch) | |
tree | 5d4ae202b870bd86673f596f0d424bc4b3e55ebe /content/common/gpu/media/vaapi_video_decode_accelerator.cc | |
parent | e862bac9c33104a29d98631d62668ae7b6676510 (diff) | |
download | chromium_org-5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7.tar.gz |
Merge from Chromium at DEPS revision 251904
This commit was generated by merge_to_master.py.
Change-Id: I1f9543259d7d2a57d81aa41a1b84f85837439d21
Diffstat (limited to 'content/common/gpu/media/vaapi_video_decode_accelerator.cc')
-rw-r--r-- | content/common/gpu/media/vaapi_video_decode_accelerator.cc | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/content/common/gpu/media/vaapi_video_decode_accelerator.cc b/content/common/gpu/media/vaapi_video_decode_accelerator.cc index cd18574a8d..73471d64ea 100644 --- a/content/common/gpu/media/vaapi_video_decode_accelerator.cc +++ b/content/common/gpu/media/vaapi_video_decode_accelerator.cc @@ -12,7 +12,7 @@ #include "content/child/child_thread.h" #include "content/common/gpu/gpu_channel.h" #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" -#include "media/base/bind_to_loop.h" +#include "media/base/bind_to_current_loop.h" #include "media/video/picture.h" #include "ui/gl/gl_bindings.h" #include "ui/gl/scoped_binders.h" @@ -44,7 +44,7 @@ VaapiVideoDecodeAccelerator::InputBuffer::~InputBuffer() { void VaapiVideoDecodeAccelerator::NotifyError(Error error) { if (message_loop_ != base::MessageLoop::current()) { - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); + DCHECK(decoder_thread_proxy_->BelongsToCurrentThread()); message_loop_->PostTask(FROM_HERE, base::Bind( &VaapiVideoDecodeAccelerator::NotifyError, weak_this_, error)); return; @@ -84,10 +84,6 @@ class VaapiVideoDecodeAccelerator::TFPPicture { return picture_buffer_id_; } - uint32 texture_id() { - return texture_id_; - } - gfx::Size size() { return size_; } @@ -240,17 +236,18 @@ VaapiVideoDecodeAccelerator::TFPPicture* } VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator( - Display* x_display, GLXContext glx_context, + Display* x_display, Client* client, const base::Callback<bool(void)>& make_context_current) : x_display_(x_display), - glx_context_(glx_context), make_context_current_(make_context_current), state_(kUninitialized), input_ready_(&lock_), surfaces_available_(&lock_), message_loop_(base::MessageLoop::current()), weak_this_(base::AsWeakPtr(this)), + va_surface_release_cb_(media::BindToCurrentLoop(base::Bind( + &VaapiVideoDecodeAccelerator::RecycleVASurfaceID, weak_this_))), client_ptr_factory_(client), client_(client_ptr_factory_.GetWeakPtr()), decoder_thread_("VaapiDecoderThread"), @@ -266,7 +263,7 @@ VaapiVideoDecodeAccelerator::~VaapiVideoDecodeAccelerator() { DCHECK_EQ(message_loop_, base::MessageLoop::current()); } -class ScopedPtrXFree { +class XFreeDeleter { public: void operator()(void* x) const { ::XFree(x); @@ -283,7 +280,7 @@ bool VaapiVideoDecodeAccelerator::InitializeFBConfig() { }; int num_fbconfigs; - scoped_ptr_malloc<GLXFBConfig, ScopedPtrXFree> glx_fb_configs( + scoped_ptr<GLXFBConfig, XFreeDeleter> glx_fb_configs( glXChooseFBConfig(x_display_, DefaultScreen(x_display_), fbconfig_attr, &num_fbconfigs)); if (!glx_fb_configs) @@ -323,11 +320,12 @@ bool VaapiVideoDecodeAccelerator::Initialize( decoder_.reset( new VaapiH264Decoder( vaapi_wrapper_.get(), - media::BindToLoop(message_loop_->message_loop_proxy(), base::Bind( + media::BindToCurrentLoop(base::Bind( &VaapiVideoDecodeAccelerator::SurfaceReady, weak_this_)), base::Bind(&ReportToUMA))); CHECK(decoder_thread_.Start()); + decoder_thread_proxy_ = decoder_thread_.message_loop_proxy(); state_ = kIdle; @@ -383,7 +381,8 @@ void VaapiVideoDecodeAccelerator::OutputPicture( TRACE_COUNTER1("Video Decoder", "Textures at client", num_frames_at_client_); DVLOG(4) << "Notifying output picture id " << output_id << " for input "<< input_id << " is ready"; - client_->PictureReady(media::Picture(output_id, input_id)); + if (client_) + client_->PictureReady(media::Picture(output_id, input_id)); } void VaapiVideoDecodeAccelerator::TryOutputSurface() { @@ -440,7 +439,7 @@ void VaapiVideoDecodeAccelerator::MapAndQueueNewInputBuffer( } bool VaapiVideoDecodeAccelerator::GetInputBuffer_Locked() { - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); + DCHECK(decoder_thread_proxy_->BelongsToCurrentThread()); lock_.AssertAcquired(); if (curr_input_buffer_.get()) @@ -486,7 +485,7 @@ bool VaapiVideoDecodeAccelerator::GetInputBuffer_Locked() { void VaapiVideoDecodeAccelerator::ReturnCurrInputBuffer_Locked() { lock_.AssertAcquired(); - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); + DCHECK(decoder_thread_proxy_->BelongsToCurrentThread()); DCHECK(curr_input_buffer_.get()); int32 id = curr_input_buffer_->id; @@ -502,7 +501,7 @@ void VaapiVideoDecodeAccelerator::ReturnCurrInputBuffer_Locked() { bool VaapiVideoDecodeAccelerator::FeedDecoderWithOutputSurfaces_Locked() { lock_.AssertAcquired(); - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); + DCHECK(decoder_thread_proxy_->BelongsToCurrentThread()); while (available_va_surfaces_.empty() && (state_ == kDecoding || state_ == kFlushing || state_ == kIdle)) { @@ -512,13 +511,9 @@ bool VaapiVideoDecodeAccelerator::FeedDecoderWithOutputSurfaces_Locked() { if (state_ != kDecoding && state_ != kFlushing && state_ != kIdle) return false; - VASurface::ReleaseCB va_surface_release_cb = - media::BindToLoop(message_loop_->message_loop_proxy(), base::Bind( - &VaapiVideoDecodeAccelerator::RecycleVASurfaceID, weak_this_)); - while (!available_va_surfaces_.empty()) { scoped_refptr<VASurface> va_surface( - new VASurface(available_va_surfaces_.front(), va_surface_release_cb)); + new VASurface(available_va_surfaces_.front(), va_surface_release_cb_)); available_va_surfaces_.pop_front(); decoder_->ReuseSurface(va_surface); } @@ -527,7 +522,7 @@ bool VaapiVideoDecodeAccelerator::FeedDecoderWithOutputSurfaces_Locked() { } void VaapiVideoDecodeAccelerator::DecodeTask() { - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); + DCHECK(decoder_thread_proxy_->BelongsToCurrentThread()); TRACE_EVENT0("Video Decoder", "VAVDA::DecodeTask"); base::AutoLock auto_lock(lock_); @@ -631,7 +626,8 @@ void VaapiVideoDecodeAccelerator::TryFinishSurfaceSetChange() { for (TFPPictures::iterator iter = tfp_pictures_.begin(); iter != tfp_pictures_.end(); ++iter) { DVLOG(2) << "Dismissing picture id: " << iter->first; - client_->DismissPictureBuffer(iter->first); + if (client_) + client_->DismissPictureBuffer(iter->first); } tfp_pictures_.clear(); @@ -658,7 +654,7 @@ void VaapiVideoDecodeAccelerator::Decode( switch (state_) { case kIdle: state_ = kDecoding; - decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( + decoder_thread_proxy_->PostTask(FROM_HERE, base::Bind( &VaapiVideoDecodeAccelerator::DecodeTask, base::Unretained(this))); break; @@ -736,7 +732,7 @@ void VaapiVideoDecodeAccelerator::AssignPictureBuffers( } state_ = kDecoding; - decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( + decoder_thread_proxy_->PostTask(FROM_HERE, base::Bind( &VaapiVideoDecodeAccelerator::DecodeTask, base::Unretained(this))); } @@ -753,7 +749,7 @@ void VaapiVideoDecodeAccelerator::ReusePictureBuffer(int32 picture_buffer_id) { } void VaapiVideoDecodeAccelerator::FlushTask() { - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); + DCHECK(decoder_thread_proxy_->BelongsToCurrentThread()); DVLOG(1) << "Flush task"; // First flush all the pictures that haven't been outputted, notifying the @@ -776,7 +772,7 @@ void VaapiVideoDecodeAccelerator::Flush() { base::AutoLock auto_lock(lock_); state_ = kFlushing; // Queue a flush task after all existing decoding tasks to clean up. - decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( + decoder_thread_proxy_->PostTask(FROM_HERE, base::Bind( &VaapiVideoDecodeAccelerator::FlushTask, base::Unretained(this))); input_ready_.Signal(); @@ -810,7 +806,7 @@ void VaapiVideoDecodeAccelerator::FinishFlush() { } void VaapiVideoDecodeAccelerator::ResetTask() { - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); + DCHECK(decoder_thread_proxy_->BelongsToCurrentThread()); DVLOG(1) << "ResetTask"; // All the decoding tasks from before the reset request from client are done @@ -846,7 +842,7 @@ void VaapiVideoDecodeAccelerator::Reset() { input_buffers_.pop(); } - decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( + decoder_thread_proxy_->PostTask(FROM_HERE, base::Bind( &VaapiVideoDecodeAccelerator::ResetTask, base::Unretained(this))); input_ready_.Signal(); @@ -890,7 +886,7 @@ void VaapiVideoDecodeAccelerator::FinishReset() { // that we are back in kDecoding state. if (!input_buffers_.empty()) { state_ = kDecoding; - decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( + decoder_thread_proxy_->PostTask(FROM_HERE, base::Bind( &VaapiVideoDecodeAccelerator::DecodeTask, base::Unretained(this))); } @@ -914,7 +910,7 @@ void VaapiVideoDecodeAccelerator::Cleanup() { base::AutoUnlock auto_unlock(lock_); // Post a dummy task to the decoder_thread_ to ensure it is drained. base::WaitableEvent waiter(false, false); - decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( + decoder_thread_proxy_->PostTask(FROM_HERE, base::Bind( &base::WaitableEvent::Signal, base::Unretained(&waiter))); input_ready_.Signal(); surfaces_available_.Signal(); |