| 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 "media/gpu/avda_codec_allocator.h" |    5 #include "media/gpu/avda_codec_allocator.h" | 
|    6  |    6  | 
|    7 #include <stddef.h> |    7 #include <stddef.h> | 
|    8  |    8  | 
|    9 #include <memory> |    9 #include <memory> | 
|   10  |   10  | 
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  233       pending_codec_releases_.find(surface_id)->second; |  233       pending_codec_releases_.find(surface_id)->second; | 
|  234   released.TimedWait(base::TimeDelta::FromSeconds(2)); |  234   released.TimedWait(base::TimeDelta::FromSeconds(2)); | 
|  235   if (!released.IsSignaled()) |  235   if (!released.IsSignaled()) | 
|  236     DLOG(WARNING) << __func__ << ": timed out waiting for MediaCodec#release()"; |  236     DLOG(WARNING) << __func__ << ": timed out waiting for MediaCodec#release()"; | 
|  237 } |  237 } | 
|  238  |  238  | 
|  239 std::unique_ptr<VideoCodecBridge> AVDACodecAllocator::CreateMediaCodecSync( |  239 std::unique_ptr<VideoCodecBridge> AVDACodecAllocator::CreateMediaCodecSync( | 
|  240     scoped_refptr<CodecConfig> codec_config) { |  240     scoped_refptr<CodecConfig> codec_config) { | 
|  241   TRACE_EVENT0("media", "AVDA::CreateMediaCodecSync"); |  241   TRACE_EVENT0("media", "AVDA::CreateMediaCodecSync"); | 
|  242  |  242  | 
|  243   jobject media_crypto = codec_config->media_crypto_ |  243   jobject media_crypto = | 
|  244                              ? codec_config->media_crypto_->obj() |  244       codec_config->media_crypto ? codec_config->media_crypto->obj() : nullptr; | 
|  245                              : nullptr; |  | 
|  246  |  245  | 
|  247   // |needs_protected_surface_| implies encrypted stream. |  246   // |needs_protected_surface| implies encrypted stream. | 
|  248   DCHECK(!codec_config->needs_protected_surface_ || media_crypto); |  247   DCHECK(!codec_config->needs_protected_surface || media_crypto); | 
|  249  |  248  | 
|  250   const bool require_software_codec = codec_config->task_type_ == SW_CODEC; |  249   const bool require_software_codec = codec_config->task_type == SW_CODEC; | 
|  251  |  | 
|  252   std::unique_ptr<VideoCodecBridge> codec(VideoCodecBridge::CreateDecoder( |  250   std::unique_ptr<VideoCodecBridge> codec(VideoCodecBridge::CreateDecoder( | 
|  253       codec_config->codec_, codec_config->needs_protected_surface_, |  251       codec_config->codec, codec_config->needs_protected_surface, | 
|  254       codec_config->initial_expected_coded_size_, |  252       codec_config->initial_expected_coded_size, | 
|  255       codec_config->surface_.j_surface().obj(), media_crypto, |  253       codec_config->surface.j_surface().obj(), media_crypto, codec_config->csd0, | 
|  256       codec_config->csd0_, codec_config->csd1_, true, require_software_codec)); |  254       codec_config->csd1, true, require_software_codec)); | 
|  257  |  255  | 
|  258   return codec; |  256   return codec; | 
|  259 } |  257 } | 
|  260  |  258  | 
|  261 void AVDACodecAllocator::CreateMediaCodecAsync( |  259 void AVDACodecAllocator::CreateMediaCodecAsync( | 
|  262     base::WeakPtr<AVDACodecAllocatorClient> client, |  260     base::WeakPtr<AVDACodecAllocatorClient> client, | 
|  263     scoped_refptr<CodecConfig> codec_config) { |  261     scoped_refptr<CodecConfig> codec_config) { | 
|  264   base::PostTaskAndReplyWithResult( |  262   base::PostTaskAndReplyWithResult( | 
|  265       TaskRunnerFor(codec_config->task_type_).get(), FROM_HERE, |  263       TaskRunnerFor(codec_config->task_type).get(), FROM_HERE, | 
|  266       base::Bind(&AVDACodecAllocator::CreateMediaCodecSync, |  264       base::Bind(&AVDACodecAllocator::CreateMediaCodecSync, | 
|  267                  base::Unretained(this), codec_config), |  265                  base::Unretained(this), codec_config), | 
|  268       base::Bind(&AVDACodecAllocatorClient::OnCodecConfigured, client)); |  266       base::Bind(&AVDACodecAllocatorClient::OnCodecConfigured, client)); | 
|  269 } |  267 } | 
|  270  |  268  | 
|  271 void AVDACodecAllocator::ReleaseMediaCodec( |  269 void AVDACodecAllocator::ReleaseMediaCodec( | 
|  272     std::unique_ptr<VideoCodecBridge> media_codec, |  270     std::unique_ptr<VideoCodecBridge> media_codec, | 
|  273     TaskType task_type, |  271     TaskType task_type, | 
|  274     int surface_id) { |  272     int surface_id) { | 
|  275   DCHECK(thread_checker_.CalledOnValidThread()); |  273   DCHECK(thread_checker_.CalledOnValidThread()); | 
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  362 void AVDACodecAllocator::StopThreadTask(size_t index) { |  360 void AVDACodecAllocator::StopThreadTask(size_t index) { | 
|  363   threads_[index]->thread.Stop(); |  361   threads_[index]->thread.Stop(); | 
|  364   // Signal the stop event after both threads are stopped. |  362   // Signal the stop event after both threads are stopped. | 
|  365   if (stop_event_for_testing_ && !threads_[AUTO_CODEC]->thread.IsRunning() && |  363   if (stop_event_for_testing_ && !threads_[AUTO_CODEC]->thread.IsRunning() && | 
|  366       !threads_[SW_CODEC]->thread.IsRunning()) { |  364       !threads_[SW_CODEC]->thread.IsRunning()) { | 
|  367     stop_event_for_testing_->Signal(); |  365     stop_event_for_testing_->Signal(); | 
|  368   } |  366   } | 
|  369 } |  367 } | 
|  370  |  368  | 
|  371 }  // namespace media |  369 }  // namespace media | 
| OLD | NEW |