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

Side by Side Diff: content/common/gpu/media/vaapi_video_decode_accelerator.cc

Issue 1432963003: [Ozone] Extends the lifetime of VaapiWrapper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NOT for upstream Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" 5 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 vaapi_wrapper_->CreateSurfaces(VA_RT_FORMAT_YUV420, requested_pic_size_, 722 vaapi_wrapper_->CreateSurfaces(VA_RT_FORMAT_YUV420, requested_pic_size_,
723 buffers.size(), &va_surface_ids), 723 buffers.size(), &va_surface_ids),
724 "Failed creating VA Surfaces", PLATFORM_FAILURE, ); 724 "Failed creating VA Surfaces", PLATFORM_FAILURE, );
725 DCHECK_EQ(va_surface_ids.size(), buffers.size()); 725 DCHECK_EQ(va_surface_ids.size(), buffers.size());
726 726
727 for (size_t i = 0; i < buffers.size(); ++i) { 727 for (size_t i = 0; i < buffers.size(); ++i) {
728 DVLOG(2) << "Assigning picture id: " << buffers[i].id() 728 DVLOG(2) << "Assigning picture id: " << buffers[i].id()
729 << " to texture id: " << buffers[i].texture_id() 729 << " to texture id: " << buffers[i].texture_id()
730 << " VASurfaceID: " << va_surface_ids[i]; 730 << " VASurfaceID: " << va_surface_ids[i];
731 731
732 linked_ptr<VaapiPicture> picture(VaapiPicture::CreatePicture( 732 scoped_refptr<VaapiPicture> picture(VaapiPicture::CreatePicture(
733 vaapi_wrapper_.get(), make_context_current_, buffers[i].id(), 733 vaapi_wrapper_, make_context_current_, buffers[i].id(),
734 buffers[i].texture_id(), requested_pic_size_)); 734 buffers[i].texture_id(), requested_pic_size_));
735 735
736 scoped_refptr<gl::GLImage> image = picture->GetImageToBind(); 736 scoped_refptr<gl::GLImage> image = picture->GetImageToBind();
737 if (image) { 737 if (image) {
738 bind_image_.Run(buffers[i].internal_texture_id(), 738 bind_image_.Run(buffers[i].internal_texture_id(),
739 VaapiPicture::GetGLTextureTarget(), image); 739 VaapiPicture::GetGLTextureTarget(), image);
740 } 740 }
741 741
742 RETURN_AND_NOTIFY_ON_FAILURE( 742 RETURN_AND_NOTIFY_ON_FAILURE(
743 picture.get(), "Failed assigning picture buffer to a texture.", 743 picture.get(), "Failed assigning picture buffer to a texture.",
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 923
924 base::AutoLock auto_lock(lock_); 924 base::AutoLock auto_lock(lock_);
925 if (state_ == kUninitialized || state_ == kDestroying) 925 if (state_ == kUninitialized || state_ == kDestroying)
926 return; 926 return;
927 927
928 DVLOG(1) << "Destroying VAVDA"; 928 DVLOG(1) << "Destroying VAVDA";
929 state_ = kDestroying; 929 state_ = kDestroying;
930 930
931 client_ptr_factory_.reset(); 931 client_ptr_factory_.reset();
932 weak_this_factory_.InvalidateWeakPtrs(); 932 weak_this_factory_.InvalidateWeakPtrs();
933 pictures_.clear();
kalyank 2015/11/14 10:42:06 I have played around with this a bit and issue is
Pawel Osciak 2015/11/16 04:24:35 If there are any references to VaapiDrmPicture bei
william.xie1 2015/11/16 08:07:26 Done.
william.xie1 2015/11/16 08:07:26 Done.
kalyank 2015/11/18 00:21:43 We want to ensure VaapiDrmPicture is alive while a
934 vaapi_wrapper_ = nullptr;
933 935
934 // Signal all potential waiters on the decoder_thread_, let them early-exit, 936 // Signal all potential waiters on the decoder_thread_, let them early-exit,
935 // as we've just moved to the kDestroying state, and wait for all tasks 937 // as we've just moved to the kDestroying state, and wait for all tasks
936 // to finish. 938 // to finish.
937 input_ready_.Signal(); 939 input_ready_.Signal();
938 surfaces_available_.Signal(); 940 surfaces_available_.Signal();
939 { 941 {
940 base::AutoUnlock auto_unlock(lock_); 942 base::AutoUnlock auto_unlock(lock_);
941 decoder_thread_.Stop(); 943 decoder_thread_.Stop();
942 } 944 }
943 945
944 state_ = kUninitialized; 946 state_ = kUninitialized;
945 } 947 }
946 948
947 void VaapiVideoDecodeAccelerator::Destroy() { 949 void VaapiVideoDecodeAccelerator::Destroy() {
948 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 950 DCHECK_EQ(message_loop_, base::MessageLoop::current());
949 Cleanup(); 951 Cleanup();
950 delete this; 952 delete this;
953 LOG(WARNING) << "!!!!!!!!!!!!!!!qxie2:" << __FUNCTION__;
951 } 954 }
952 955
953 bool VaapiVideoDecodeAccelerator::CanDecodeOnIOThread() { 956 bool VaapiVideoDecodeAccelerator::CanDecodeOnIOThread() {
954 return false; 957 return false;
955 } 958 }
956 959
957 bool VaapiVideoDecodeAccelerator::DecodeSurface( 960 bool VaapiVideoDecodeAccelerator::DecodeSurface(
958 const scoped_refptr<VaapiDecodeSurface>& dec_surface) { 961 const scoped_refptr<VaapiDecodeSurface>& dec_surface) {
959 if (!vaapi_wrapper_->ExecuteAndDestroyPendingBuffers( 962 if (!vaapi_wrapper_->ExecuteAndDestroyPendingBuffers(
960 dec_surface->va_surface()->id())) { 963 dec_surface->va_surface()->id())) {
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 return vaapi_pic->dec_surface(); 1735 return vaapi_pic->dec_surface();
1733 } 1736 }
1734 1737
1735 // static 1738 // static
1736 media::VideoDecodeAccelerator::SupportedProfiles 1739 media::VideoDecodeAccelerator::SupportedProfiles
1737 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { 1740 VaapiVideoDecodeAccelerator::GetSupportedProfiles() {
1738 return VaapiWrapper::GetSupportedDecodeProfiles(); 1741 return VaapiWrapper::GetSupportedDecodeProfiles();
1739 } 1742 }
1740 1743
1741 } // namespace content 1744 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698