Chromium Code Reviews| Index: media/filters/gpu_video_decoder.cc |
| diff --git a/media/filters/gpu_video_decoder.cc b/media/filters/gpu_video_decoder.cc |
| index c7a086974b7c4ac4df5a315a4b72f97f3afb76f1..724809d5747eeec781faac9ae643a4842598a51a 100644 |
| --- a/media/filters/gpu_video_decoder.cc |
| +++ b/media/filters/gpu_video_decoder.cc |
| @@ -36,6 +36,10 @@ |
| #include "media/formats/mp4/box_definitions.h" |
| #endif |
| +#if defined(OS_ANDROID) |
| +#include "base/android/build_info.h" |
| +#endif |
| + |
| namespace media { |
| namespace { |
| @@ -212,12 +216,16 @@ void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, |
| base::Bind(&ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB, |
| BindToCurrentLoop(init_cb), media_log_); |
| + bool requires_restart_for_external_output_surface = false; |
| #if !defined(OS_ANDROID) |
| if (config.is_encrypted()) { |
| DVLOG(1) << "Encrypted stream not supported."; |
| bound_init_cb.Run(false); |
| return; |
| } |
| +#else |
| + requires_restart_for_external_output_surface = |
| + base::android::BuildInfo::GetInstance()->sdk_int() < 23; |
| #endif |
| bool previously_initialized = config_.IsValidConfig(); |
| @@ -309,6 +317,7 @@ void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, |
| // If we have a surface request callback we should call it and complete |
| // initialization with the returned surface. |
| request_surface_cb_.Run( |
| + requires_restart_for_external_output_surface, |
| BindToCurrentLoop(base::Bind(&GpuVideoDecoder::CompleteInitialization, |
| weak_factory_.GetWeakPtr(), cdm_id))); |
| return; |
| @@ -321,7 +330,6 @@ void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, |
| void GpuVideoDecoder::CompleteInitialization(int cdm_id, int surface_id) { |
| DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| - DCHECK(!init_cb_.is_null()); |
| // It's possible for the vda to become null if NotifyError is called. |
| if (!vda_) { |
| @@ -329,11 +337,16 @@ void GpuVideoDecoder::CompleteInitialization(int cdm_id, int surface_id) { |
| return; |
| } |
| + vda_->SetSurface(surface_id); |
| + |
| + // If initialization has already completed, there's nothing left to do. |
| + if (init_cb_.is_null()) |
| + return; |
|
watk
2016/11/08 22:59:03
Any chance you could rework this a bit to make it
DaleCurtis
2016/11/08 23:50:10
Hmm, without redesigning how we provide the surfac
watk
2016/11/08 23:58:12
Fair enough. I guess I was thinking we could have
DaleCurtis
2016/11/09 00:19:03
Ah, this is good, but required some reworking of |
|
| + |
| VideoDecodeAccelerator::Config vda_config; |
| vda_config.profile = config_.profile(); |
| vda_config.cdm_id = cdm_id; |
| vda_config.is_encrypted = config_.is_encrypted(); |
| - vda_config.surface_id = surface_id; |
| vda_config.is_deferred_initialization_allowed = true; |
| vda_config.initial_expected_coded_size = config_.coded_size(); |
| @@ -785,7 +798,7 @@ GpuVideoDecoder::~GpuVideoDecoder() { |
| if (!init_cb_.is_null()) |
| base::ResetAndReturn(&init_cb_).Run(false); |
| if (!request_surface_cb_.is_null()) |
| - base::ResetAndReturn(&request_surface_cb_).Run(SurfaceCreatedCB()); |
| + base::ResetAndReturn(&request_surface_cb_).Run(false, SurfaceCreatedCB()); |
| for (size_t i = 0; i < available_shm_segments_.size(); ++i) { |
| delete available_shm_segments_[i]; |