Chromium Code Reviews| Index: media/filters/decrypting_audio_decoder.cc |
| diff --git a/media/filters/decrypting_audio_decoder.cc b/media/filters/decrypting_audio_decoder.cc |
| index 60586a819dc09ab20d9bfac4936b4ff00c21a715..10d4776f6bfde2bf59ff118b38229bf85c6d3c60 100644 |
| --- a/media/filters/decrypting_audio_decoder.cc |
| +++ b/media/filters/decrypting_audio_decoder.cc |
| @@ -50,7 +50,7 @@ std::string DecryptingAudioDecoder::GetDisplayName() const { |
| } |
| void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config, |
| - const SetCdmReadyCB& set_cdm_ready_cb, |
| + CdmContext* cdm_context, |
| const InitCB& init_cb, |
| const OutputCB& output_cb) { |
| DVLOG(2) << "Initialize()"; |
| @@ -62,6 +62,8 @@ void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config, |
| init_cb_ = BindToCurrentLoop(init_cb); |
| output_cb_ = BindToCurrentLoop(output_cb); |
| + // TODO(xhwang): We should be able to DCHECK config.IsValidConfig() and |
| + // config.is_encrypted(). |
| if (!config.IsValidConfig()) { |
| DLOG(ERROR) << "Invalid audio stream config."; |
| base::ResetAndReturn(&init_cb_).Run(false); |
| @@ -77,16 +79,19 @@ void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config, |
| config_ = config; |
| if (state_ == kUninitialized) { |
| - DCHECK(!set_cdm_ready_cb.is_null()); |
| - state_ = kDecryptorRequested; |
| - set_cdm_ready_cb_ = set_cdm_ready_cb; |
| - set_cdm_ready_cb_.Run(BindToCurrentLoop( |
| - base::Bind(&DecryptingAudioDecoder::SetCdm, weak_this_))); |
| - return; |
| + DCHECK(cdm_context); |
| + if (!cdm_context->GetDecryptor()) { |
| + MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor"; |
| + base::ResetAndReturn(&init_cb_).Run(false); |
|
jrummell
2016/02/03 23:32:28
In SetCdm() state_ was set to kError. Was it inten
xhwang
2016/02/09 22:23:58
Yeah, this is a bit messy. I don't think it matter
|
| + return; |
| + } |
| + |
| + decryptor_ = cdm_context->GetDecryptor(); |
| + } else { |
| + // Reinitialization (i.e. upon a config change) |
| + decryptor_->DeinitializeDecoder(Decryptor::kAudio); |
| } |
| - // Reinitialization (i.e. upon a config change) |
| - decryptor_->DeinitializeDecoder(Decryptor::kAudio); |
| InitializeDecoder(); |
| } |
| @@ -163,8 +168,6 @@ DecryptingAudioDecoder::~DecryptingAudioDecoder() { |
| decryptor_->DeinitializeDecoder(Decryptor::kAudio); |
| decryptor_ = NULL; |
| } |
| - if (!set_cdm_ready_cb_.is_null()) |
| - base::ResetAndReturn(&set_cdm_ready_cb_).Run(CdmReadyCB()); |
| pending_buffer_to_decode_ = NULL; |
| if (!init_cb_.is_null()) |
| base::ResetAndReturn(&init_cb_).Run(false); |
| @@ -174,30 +177,6 @@ DecryptingAudioDecoder::~DecryptingAudioDecoder() { |
| base::ResetAndReturn(&reset_cb_).Run(); |
| } |
| -void DecryptingAudioDecoder::SetCdm(CdmContext* cdm_context, |
| - const CdmAttachedCB& cdm_attached_cb) { |
| - DVLOG(2) << __FUNCTION__; |
| - DCHECK(task_runner_->BelongsToCurrentThread()); |
| - DCHECK_EQ(state_, kDecryptorRequested) << state_; |
| - DCHECK(!init_cb_.is_null()); |
| - DCHECK(!set_cdm_ready_cb_.is_null()); |
| - |
| - set_cdm_ready_cb_.Reset(); |
| - |
| - if (!cdm_context || !cdm_context->GetDecryptor()) { |
| - MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor set"; |
| - base::ResetAndReturn(&init_cb_).Run(false); |
| - state_ = kError; |
| - cdm_attached_cb.Run(false); |
| - return; |
| - } |
| - |
| - decryptor_ = cdm_context->GetDecryptor(); |
| - |
| - InitializeDecoder(); |
| - cdm_attached_cb.Run(true); |
| -} |
| - |
| void DecryptingAudioDecoder::InitializeDecoder() { |
| state_ = kPendingDecoderInit; |
| decryptor_->InitializeAudioDecoder( |