OLD | NEW |
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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 &VaapiVideoDecodeAccelerator::DecodeTask, | 708 &VaapiVideoDecodeAccelerator::DecodeTask, |
709 base::Unretained(this))); | 709 base::Unretained(this))); |
710 } | 710 } |
711 | 711 |
712 DVLOG(1) << "Reset finished"; | 712 DVLOG(1) << "Reset finished"; |
713 } | 713 } |
714 | 714 |
715 void VaapiVideoDecodeAccelerator::Cleanup() { | 715 void VaapiVideoDecodeAccelerator::Cleanup() { |
716 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 716 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
717 | 717 |
| 718 base::AutoLock auto_lock(lock_); |
718 if (state_ == kUninitialized || state_ == kDestroying) | 719 if (state_ == kUninitialized || state_ == kDestroying) |
719 return; | 720 return; |
720 | 721 |
721 DVLOG(1) << "Destroying VAVDA"; | 722 DVLOG(1) << "Destroying VAVDA"; |
722 base::AutoLock auto_lock(lock_); | |
723 state_ = kDestroying; | 723 state_ = kDestroying; |
724 | 724 |
725 client_ptr_factory_.reset(); | 725 client_ptr_factory_.reset(); |
726 weak_this_factory_.InvalidateWeakPtrs(); | 726 weak_this_factory_.InvalidateWeakPtrs(); |
727 | 727 |
728 // Signal all potential waiters on the decoder_thread_, let them early-exit, | 728 // Signal all potential waiters on the decoder_thread_, let them early-exit, |
729 // as we've just moved to the kDestroying state, and wait for all tasks | 729 // as we've just moved to the kDestroying state, and wait for all tasks |
730 // to finish. | 730 // to finish. |
731 input_ready_.Signal(); | 731 input_ready_.Signal(); |
732 surfaces_available_.Signal(); | 732 surfaces_available_.Signal(); |
733 { | 733 { |
734 base::AutoUnlock auto_unlock(lock_); | 734 base::AutoUnlock auto_unlock(lock_); |
735 decoder_thread_.Stop(); | 735 decoder_thread_.Stop(); |
736 } | 736 } |
737 | 737 |
738 state_ = kUninitialized; | 738 state_ = kUninitialized; |
739 } | 739 } |
740 | 740 |
741 void VaapiVideoDecodeAccelerator::Destroy() { | 741 void VaapiVideoDecodeAccelerator::Destroy() { |
742 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 742 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
743 Cleanup(); | 743 Cleanup(); |
744 delete this; | 744 delete this; |
745 } | 745 } |
746 | 746 |
747 bool VaapiVideoDecodeAccelerator::CanDecodeOnIOThread() { | 747 bool VaapiVideoDecodeAccelerator::CanDecodeOnIOThread() { |
748 return false; | 748 return false; |
749 } | 749 } |
750 | 750 |
751 } // namespace content | 751 } // namespace content |
OLD | NEW |