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/filters/decrypting_audio_decoder.h" | 5 #include "media/filters/decrypting_audio_decoder.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 166 } |
167 | 167 |
168 void DecryptingAudioDecoder::SetDecryptor(Decryptor* decryptor) { | 168 void DecryptingAudioDecoder::SetDecryptor(Decryptor* decryptor) { |
169 DVLOG(2) << "SetDecryptor()"; | 169 DVLOG(2) << "SetDecryptor()"; |
170 DCHECK(message_loop_->BelongsToCurrentThread()); | 170 DCHECK(message_loop_->BelongsToCurrentThread()); |
171 DCHECK_EQ(state_, kDecryptorRequested) << state_; | 171 DCHECK_EQ(state_, kDecryptorRequested) << state_; |
172 DCHECK(!init_cb_.is_null()); | 172 DCHECK(!init_cb_.is_null()); |
173 DCHECK(!set_decryptor_ready_cb_.is_null()); | 173 DCHECK(!set_decryptor_ready_cb_.is_null()); |
174 | 174 |
175 set_decryptor_ready_cb_.Reset(); | 175 set_decryptor_ready_cb_.Reset(); |
| 176 |
| 177 if (!decryptor) { |
| 178 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); |
| 179 // TODO(xhwang): Add kError state. See http://crbug.com/251503 |
| 180 state_ = kDecodeFinished; |
| 181 return; |
| 182 } |
| 183 |
176 decryptor_ = decryptor; | 184 decryptor_ = decryptor; |
177 | 185 |
178 const AudioDecoderConfig& input_config = | 186 const AudioDecoderConfig& input_config = |
179 demuxer_stream_->audio_decoder_config(); | 187 demuxer_stream_->audio_decoder_config(); |
180 AudioDecoderConfig config; | 188 AudioDecoderConfig config; |
181 config.Initialize(input_config.codec(), | 189 config.Initialize(input_config.codec(), |
182 kSampleFormatS16, | 190 kSampleFormatS16, |
183 input_config.channel_layout(), | 191 input_config.channel_layout(), |
184 input_config.samples_per_second(), | 192 input_config.samples_per_second(), |
185 input_config.extra_data(), | 193 input_config.extra_data(), |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 | 486 |
479 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( | 487 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( |
480 int number_of_samples) const { | 488 int number_of_samples) const { |
481 DCHECK(samples_per_second_); | 489 DCHECK(samples_per_second_); |
482 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * | 490 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * |
483 number_of_samples / | 491 number_of_samples / |
484 samples_per_second_); | 492 samples_per_second_); |
485 } | 493 } |
486 | 494 |
487 } // namespace media | 495 } // namespace media |
OLD | NEW |