| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/gpu/arc_gpu_video_decode_accelerator.h" | 5 #include "chrome/gpu/arc_gpu_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/numerics/safe_math.h" | 10 #include "base/numerics/safe_math.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 requested_num_of_output_buffers_(0), | 62 requested_num_of_output_buffers_(0), |
| 63 gpu_preferences_(gpu_preferences) {} | 63 gpu_preferences_(gpu_preferences) {} |
| 64 | 64 |
| 65 ArcGpuVideoDecodeAccelerator::~ArcGpuVideoDecodeAccelerator() { | 65 ArcGpuVideoDecodeAccelerator::~ArcGpuVideoDecodeAccelerator() { |
| 66 DCHECK(thread_checker_.CalledOnValidThread()); | 66 DCHECK(thread_checker_.CalledOnValidThread()); |
| 67 if (vda_) { | 67 if (vda_) { |
| 68 client_count_--; | 68 client_count_--; |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 ArcVideoAccelerator::Result ArcGpuVideoDecodeAccelerator::Initialize( | 72 ArcVideoDecodeAccelerator::Result ArcGpuVideoDecodeAccelerator::Initialize( |
| 73 const Config& config, | 73 const Config& config, |
| 74 ArcVideoAccelerator::Client* client) { | 74 ArcVideoDecodeAccelerator::Client* client) { |
| 75 auto result = InitializeTask(config, client); | 75 auto result = InitializeTask(config, client); |
| 76 // Report initialization status to UMA. | 76 // Report initialization status to UMA. |
| 77 UMA_HISTOGRAM_ENUMERATION( | 77 UMA_HISTOGRAM_ENUMERATION( |
| 78 "Media.ArcGpuVideoDecodeAccelerator.InitializeResult", result, | 78 "Media.ArcGpuVideoDecodeAccelerator.InitializeResult", result, |
| 79 RESULT_MAX); | 79 RESULT_MAX); |
| 80 return result; | 80 return result; |
| 81 } | 81 } |
| 82 | 82 |
| 83 ArcVideoAccelerator::Result ArcGpuVideoDecodeAccelerator::InitializeTask( | 83 ArcVideoDecodeAccelerator::Result ArcGpuVideoDecodeAccelerator::InitializeTask( |
| 84 const Config& config, | 84 const Config& config, |
| 85 ArcVideoAccelerator::Client* client) { | 85 ArcVideoDecodeAccelerator::Client* client) { |
| 86 DVLOG(5) << "Initialize(device=" << config.device_type | 86 DVLOG(5) << "Initialize(input_pixel_format=" << config.input_pixel_format |
| 87 << ", input_pixel_format=" << config.input_pixel_format | |
| 88 << ", num_input_buffers=" << config.num_input_buffers << ")"; | 87 << ", num_input_buffers=" << config.num_input_buffers << ")"; |
| 89 DCHECK(thread_checker_.CalledOnValidThread()); | 88 DCHECK(thread_checker_.CalledOnValidThread()); |
| 90 if (config.device_type != Config::DEVICE_DECODER) | |
| 91 return INVALID_ARGUMENT; | |
| 92 DCHECK(client); | 89 DCHECK(client); |
| 93 | 90 |
| 94 if (arc_client_) { | 91 if (arc_client_) { |
| 95 DLOG(ERROR) << "Re-Initialize() is not allowed"; | 92 DLOG(ERROR) << "Re-Initialize() is not allowed"; |
| 96 return ILLEGAL_STATE; | 93 return ILLEGAL_STATE; |
| 97 } | 94 } |
| 98 | 95 |
| 99 if (client_count_ >= kMaxConcurrentClients) { | 96 if (client_count_ >= kMaxConcurrentClients) { |
| 100 LOG(WARNING) << "Reject to Initialize() due to too many clients: " | 97 LOG(WARNING) << "Reject to Initialize() due to too many clients: " |
| 101 << client_count_; | 98 << client_count_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 130 | 127 |
| 131 auto vda_factory = media::GpuVideoDecodeAcceleratorFactory::CreateWithNoGL(); | 128 auto vda_factory = media::GpuVideoDecodeAcceleratorFactory::CreateWithNoGL(); |
| 132 vda_ = vda_factory->CreateVDA( | 129 vda_ = vda_factory->CreateVDA( |
| 133 this, vda_config, gpu::GpuDriverBugWorkarounds(), gpu_preferences_); | 130 this, vda_config, gpu::GpuDriverBugWorkarounds(), gpu_preferences_); |
| 134 if (!vda_) { | 131 if (!vda_) { |
| 135 DLOG(ERROR) << "Failed to create VDA."; | 132 DLOG(ERROR) << "Failed to create VDA."; |
| 136 return PLATFORM_FAILURE; | 133 return PLATFORM_FAILURE; |
| 137 } | 134 } |
| 138 | 135 |
| 139 client_count_++; | 136 client_count_++; |
| 140 DVLOG(5) << "Number of concurrent ArcVideoAccelerator clients: " | 137 DVLOG(5) << "Number of concurrent ArcVideoDecodeAccelerator clients: " |
| 141 << client_count_; | 138 << client_count_; |
| 142 | 139 |
| 143 return SUCCESS; | 140 return SUCCESS; |
| 144 } | 141 } |
| 145 | 142 |
| 146 void ArcGpuVideoDecodeAccelerator::SetNumberOfOutputBuffers(size_t number) { | 143 void ArcGpuVideoDecodeAccelerator::SetNumberOfOutputBuffers(size_t number) { |
| 147 DVLOG(5) << "SetNumberOfOutputBuffers(" << number << ")"; | 144 DVLOG(5) << "SetNumberOfOutputBuffers(" << number << ")"; |
| 148 DCHECK(thread_checker_.CalledOnValidThread()); | 145 DCHECK(thread_checker_.CalledOnValidThread()); |
| 149 if (!vda_) { | 146 if (!vda_) { |
| 150 DLOG(ERROR) << "VDA not initialized"; | 147 DLOG(ERROR) << "VDA not initialized"; |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 void ArcGpuVideoDecodeAccelerator::NotifyFlushDone() { | 455 void ArcGpuVideoDecodeAccelerator::NotifyFlushDone() { |
| 459 DCHECK(thread_checker_.CalledOnValidThread()); | 456 DCHECK(thread_checker_.CalledOnValidThread()); |
| 460 arc_client_->OnFlushDone(); | 457 arc_client_->OnFlushDone(); |
| 461 } | 458 } |
| 462 | 459 |
| 463 void ArcGpuVideoDecodeAccelerator::NotifyResetDone() { | 460 void ArcGpuVideoDecodeAccelerator::NotifyResetDone() { |
| 464 DCHECK(thread_checker_.CalledOnValidThread()); | 461 DCHECK(thread_checker_.CalledOnValidThread()); |
| 465 arc_client_->OnResetDone(); | 462 arc_client_->OnResetDone(); |
| 466 } | 463 } |
| 467 | 464 |
| 468 static ArcVideoAccelerator::Result ConvertErrorCode( | 465 static ArcVideoDecodeAccelerator::Result ConvertErrorCode( |
| 469 media::VideoDecodeAccelerator::Error error) { | 466 media::VideoDecodeAccelerator::Error error) { |
| 470 switch (error) { | 467 switch (error) { |
| 471 case media::VideoDecodeAccelerator::ILLEGAL_STATE: | 468 case media::VideoDecodeAccelerator::ILLEGAL_STATE: |
| 472 return ArcVideoAccelerator::ILLEGAL_STATE; | 469 return ArcVideoDecodeAccelerator::ILLEGAL_STATE; |
| 473 case media::VideoDecodeAccelerator::INVALID_ARGUMENT: | 470 case media::VideoDecodeAccelerator::INVALID_ARGUMENT: |
| 474 return ArcVideoAccelerator::INVALID_ARGUMENT; | 471 return ArcVideoDecodeAccelerator::INVALID_ARGUMENT; |
| 475 case media::VideoDecodeAccelerator::UNREADABLE_INPUT: | 472 case media::VideoDecodeAccelerator::UNREADABLE_INPUT: |
| 476 return ArcVideoAccelerator::UNREADABLE_INPUT; | 473 return ArcVideoDecodeAccelerator::UNREADABLE_INPUT; |
| 477 case media::VideoDecodeAccelerator::PLATFORM_FAILURE: | 474 case media::VideoDecodeAccelerator::PLATFORM_FAILURE: |
| 478 return ArcVideoAccelerator::PLATFORM_FAILURE; | 475 return ArcVideoDecodeAccelerator::PLATFORM_FAILURE; |
| 479 default: | 476 default: |
| 480 DLOG(ERROR) << "Unknown error: " << error; | 477 DLOG(ERROR) << "Unknown error: " << error; |
| 481 return ArcVideoAccelerator::PLATFORM_FAILURE; | 478 return ArcVideoDecodeAccelerator::PLATFORM_FAILURE; |
| 482 } | 479 } |
| 483 } | 480 } |
| 484 | 481 |
| 485 void ArcGpuVideoDecodeAccelerator::NotifyError( | 482 void ArcGpuVideoDecodeAccelerator::NotifyError( |
| 486 media::VideoDecodeAccelerator::Error error) { | 483 media::VideoDecodeAccelerator::Error error) { |
| 487 DCHECK(thread_checker_.CalledOnValidThread()); | 484 DCHECK(thread_checker_.CalledOnValidThread()); |
| 488 DLOG(ERROR) << "Error notified: " << error; | 485 DLOG(ERROR) << "Error notified: " << error; |
| 489 arc_client_->OnError(ConvertErrorCode(error)); | 486 arc_client_->OnError(ConvertErrorCode(error)); |
| 490 } | 487 } |
| 491 | 488 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 } | 528 } |
| 532 return true; | 529 return true; |
| 533 default: | 530 default: |
| 534 DLOG(ERROR) << "Invalid port: " << port; | 531 DLOG(ERROR) << "Invalid port: " << port; |
| 535 return false; | 532 return false; |
| 536 } | 533 } |
| 537 } | 534 } |
| 538 | 535 |
| 539 } // namespace arc | 536 } // namespace arc |
| 540 } // namespace chromeos | 537 } // namespace chromeos |
| OLD | NEW |