| 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 "media/gpu/dxva_video_decode_accelerator_win.h" | 5 #include "media/gpu/dxva_video_decode_accelerator_win.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #if !defined(OS_WIN) | 9 #if !defined(OS_WIN) |
| 10 #error This file should only be built on Windows. | 10 #error This file should only be built on Windows. |
| (...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 pending_input_buffers_.clear(); | 1188 pending_input_buffers_.clear(); |
| 1189 | 1189 |
| 1190 RETURN_AND_NOTIFY_ON_FAILURE(StartDecoderThread(), | 1190 RETURN_AND_NOTIFY_ON_FAILURE(StartDecoderThread(), |
| 1191 "Failed to start decoder thread.", | 1191 "Failed to start decoder thread.", |
| 1192 PLATFORM_FAILURE, ); | 1192 PLATFORM_FAILURE, ); |
| 1193 SetState(kNormal); | 1193 SetState(kNormal); |
| 1194 } | 1194 } |
| 1195 | 1195 |
| 1196 void DXVAVideoDecodeAccelerator::Destroy() { | 1196 void DXVAVideoDecodeAccelerator::Destroy() { |
| 1197 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 1197 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 1198 Invalidate(); | 1198 Invalidate(false); |
| 1199 delete this; | 1199 delete this; |
| 1200 } | 1200 } |
| 1201 | 1201 |
| 1202 bool DXVAVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread( | 1202 bool DXVAVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread( |
| 1203 const base::WeakPtr<Client>& decode_client, | 1203 const base::WeakPtr<Client>& decode_client, |
| 1204 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) { | 1204 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) { |
| 1205 return false; | 1205 return false; |
| 1206 } | 1206 } |
| 1207 | 1207 |
| 1208 GLenum DXVAVideoDecodeAccelerator::GetSurfaceInternalFormat() const { | 1208 GLenum DXVAVideoDecodeAccelerator::GetSurfaceInternalFormat() const { |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2008 FROM_HERE, | 2008 FROM_HERE, |
| 2009 base::Bind(&DXVAVideoDecodeAccelerator::StopOnError, weak_ptr_, error)); | 2009 base::Bind(&DXVAVideoDecodeAccelerator::StopOnError, weak_ptr_, error)); |
| 2010 return; | 2010 return; |
| 2011 } | 2011 } |
| 2012 | 2012 |
| 2013 if (client_) | 2013 if (client_) |
| 2014 client_->NotifyError(error); | 2014 client_->NotifyError(error); |
| 2015 client_ = NULL; | 2015 client_ = NULL; |
| 2016 | 2016 |
| 2017 if (GetState() != kUninitialized) { | 2017 if (GetState() != kUninitialized) { |
| 2018 Invalidate(); | 2018 Invalidate(false); |
| 2019 } | 2019 } |
| 2020 } | 2020 } |
| 2021 | 2021 |
| 2022 void DXVAVideoDecodeAccelerator::Invalidate() { | 2022 void DXVAVideoDecodeAccelerator::Invalidate(bool for_config_change) { |
| 2023 if (GetState() == kUninitialized) | 2023 if (GetState() == kUninitialized) |
| 2024 return; | 2024 return; |
| 2025 | 2025 |
| 2026 // Best effort to make the GL context current. | 2026 // Best effort to make the GL context current. |
| 2027 make_context_current_cb_.Run(); | 2027 make_context_current_cb_.Run(); |
| 2028 | 2028 |
| 2029 StopDecoderThread(); | 2029 StopDecoderThread(); |
| 2030 weak_this_factory_.InvalidateWeakPtrs(); | 2030 weak_this_factory_.InvalidateWeakPtrs(); |
| 2031 weak_ptr_ = weak_this_factory_.GetWeakPtr(); | 2031 weak_ptr_ = weak_this_factory_.GetWeakPtr(); |
| 2032 pending_output_samples_.clear(); | 2032 pending_output_samples_.clear(); |
| 2033 decoder_.Reset(); | 2033 decoder_.Reset(); |
| 2034 config_change_detector_.reset(); | 2034 config_change_detector_.reset(); |
| 2035 | 2035 |
| 2036 // If we are processing a config change, then leave the d3d9/d3d11 objects | 2036 // If we are processing a config change, then leave the d3d9/d3d11 objects |
| 2037 // along with the output picture buffers intact as they can be reused. The | 2037 // along with the output picture buffers intact as they can be reused. The |
| 2038 // output picture buffers may need to be recreated in case the video | 2038 // output picture buffers may need to be recreated in case the video |
| 2039 // resolution changes. We already handle that in the | 2039 // resolution changes. We already handle that in the |
| 2040 // HandleResolutionChanged() function. | 2040 // HandleResolutionChanged() function. |
| 2041 if (GetState() != kConfigChange) { | 2041 if (!for_config_change) { |
| 2042 output_picture_buffers_.clear(); | 2042 output_picture_buffers_.clear(); |
| 2043 stale_output_picture_buffers_.clear(); | 2043 stale_output_picture_buffers_.clear(); |
| 2044 // We want to continue processing pending input after detecting a config | 2044 // We want to continue processing pending input after detecting a config |
| 2045 // change. | 2045 // change. |
| 2046 pending_input_buffers_.clear(); | 2046 pending_input_buffers_.clear(); |
| 2047 pictures_requested_ = false; | 2047 pictures_requested_ = false; |
| 2048 if (use_dx11_) { | 2048 if (use_dx11_) { |
| 2049 d3d11_processor_.Reset(); | 2049 d3d11_processor_.Reset(); |
| 2050 enumerator_.Reset(); | 2050 enumerator_.Reset(); |
| 2051 video_context_.Reset(); | 2051 video_context_.Reset(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2104 void DXVAVideoDecodeAccelerator::NotifyFlushDone() { | 2104 void DXVAVideoDecodeAccelerator::NotifyFlushDone() { |
| 2105 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 2105 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 2106 if (client_ && pending_flush_) { | 2106 if (client_ && pending_flush_) { |
| 2107 pending_flush_ = false; | 2107 pending_flush_ = false; |
| 2108 { | 2108 { |
| 2109 base::AutoLock lock(decoder_lock_); | 2109 base::AutoLock lock(decoder_lock_); |
| 2110 sent_drain_message_ = false; | 2110 sent_drain_message_ = false; |
| 2111 } | 2111 } |
| 2112 | 2112 |
| 2113 client_->NotifyFlushDone(); | 2113 client_->NotifyFlushDone(); |
| 2114 Invalidate(true); |
| 2115 Initialize(config_, client_); |
| 2114 } | 2116 } |
| 2115 } | 2117 } |
| 2116 | 2118 |
| 2117 void DXVAVideoDecodeAccelerator::NotifyResetDone() { | 2119 void DXVAVideoDecodeAccelerator::NotifyResetDone() { |
| 2118 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 2120 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 2119 if (client_) | 2121 if (client_) |
| 2120 client_->NotifyResetDone(); | 2122 client_->NotifyResetDone(); |
| 2121 } | 2123 } |
| 2122 | 2124 |
| 2123 void DXVAVideoDecodeAccelerator::RequestPictureBuffers(int width, int height) { | 2125 void DXVAVideoDecodeAccelerator::RequestPictureBuffers(int width, int height) { |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3028 E_FAIL); | 3030 E_FAIL); |
| 3029 } | 3031 } |
| 3030 *config_changed = config_change_detector_->config_changed(); | 3032 *config_changed = config_change_detector_->config_changed(); |
| 3031 return S_OK; | 3033 return S_OK; |
| 3032 } | 3034 } |
| 3033 | 3035 |
| 3034 void DXVAVideoDecodeAccelerator::ConfigChanged(const Config& config) { | 3036 void DXVAVideoDecodeAccelerator::ConfigChanged(const Config& config) { |
| 3035 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 3037 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 3036 | 3038 |
| 3037 SetState(kConfigChange); | 3039 SetState(kConfigChange); |
| 3038 Invalidate(); | 3040 Invalidate(true); |
| 3039 Initialize(config_, client_); | 3041 Initialize(config_, client_); |
| 3040 decoder_thread_task_runner_->PostTask( | 3042 decoder_thread_task_runner_->PostTask( |
| 3041 FROM_HERE, | 3043 FROM_HERE, |
| 3042 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 3044 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
| 3043 base::Unretained(this))); | 3045 base::Unretained(this))); |
| 3044 } | 3046 } |
| 3045 | 3047 |
| 3046 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { | 3048 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { |
| 3047 switch (GetPictureBufferMechanism()) { | 3049 switch (GetPictureBufferMechanism()) { |
| 3048 case PictureBufferMechanism::BIND: | 3050 case PictureBufferMechanism::BIND: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3080 return false; | 3082 return false; |
| 3081 } | 3083 } |
| 3082 NOTREACHED(); | 3084 NOTREACHED(); |
| 3083 return false; | 3085 return false; |
| 3084 } | 3086 } |
| 3085 ID3D11Device* DXVAVideoDecodeAccelerator::D3D11Device() const { | 3087 ID3D11Device* DXVAVideoDecodeAccelerator::D3D11Device() const { |
| 3086 return ShouldUseANGLEDevice() ? angle_device_.Get() : d3d11_device_.Get(); | 3088 return ShouldUseANGLEDevice() ? angle_device_.Get() : d3d11_device_.Get(); |
| 3087 } | 3089 } |
| 3088 | 3090 |
| 3089 } // namespace media | 3091 } // namespace media |
| OLD | NEW |