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 9d635818a925ad9c7ab1a522616bee32779e8ecc..a92fd34bf18c4045c35a3b0d13cc5a5f188d64fd 100644 |
| --- a/media/filters/decrypting_audio_decoder.cc |
| +++ b/media/filters/decrypting_audio_decoder.cc |
| @@ -25,6 +25,8 @@ namespace media { |
| #define BIND_TO_LOOP(function) \ |
| media::BindToLoop(message_loop_, base::Bind(function, this)) |
| +const int DecryptingAudioDecoder::kSupportedBitsPerChannel = 16; |
| + |
| static inline bool IsOutOfSync(const base::TimeDelta& timestamp_1, |
| const base::TimeDelta& timestamp_2) { |
| // Out of sync of 100ms would be pretty noticeable and we should keep any |
| @@ -170,8 +172,17 @@ void DecryptingAudioDecoder::SetDecryptor(Decryptor* decryptor) { |
| set_decryptor_ready_cb_.Reset(); |
| decryptor_ = decryptor; |
| + const AudioDecoderConfig& input_config = |
| + demuxer_stream_->audio_decoder_config(); |
| scoped_ptr<AudioDecoderConfig> scoped_config(new AudioDecoderConfig()); |
| - scoped_config->CopyFrom(demuxer_stream_->audio_decoder_config()); |
| + scoped_config->Initialize(input_config.codec(), |
| + kSampleFormatS16, |
| + input_config.channel_layout(), |
| + input_config.samples_per_second(), |
| + input_config.extra_data(), |
| + input_config.extra_data_size(), |
| + input_config.is_encrypted(), |
| + false); |
| state_ = kPendingDecoderInit; |
| decryptor_->InitializeAudioDecoder( |
| @@ -194,13 +205,7 @@ void DecryptingAudioDecoder::FinishInitialization(bool success) { |
| } |
| // Success! |
| - const AudioDecoderConfig& config = demuxer_stream_->audio_decoder_config(); |
| - bits_per_channel_ = config.bits_per_channel(); |
| - channel_layout_ = config.channel_layout(); |
| - samples_per_second_ = config.samples_per_second(); |
| - const int kBitsPerByte = 8; |
| - bytes_per_sample_ = ChannelLayoutToChannelCount(channel_layout_) * |
| - bits_per_channel_ / kBitsPerByte; |
| + SetDecoderConfig(); |
| decryptor_->RegisterNewKeyCB( |
| Decryptor::kAudio, BIND_TO_LOOP(&DecryptingAudioDecoder::OnKeyAdded)); |
| @@ -224,6 +229,8 @@ void DecryptingAudioDecoder::FinishConfigChange(bool success) { |
| } |
| // Config change succeeded. |
| + SetDecoderConfig(); |
|
DaleCurtis
2013/01/10 01:24:35
Is this a bug fix?
xhwang
2013/01/10 18:17:23
Hmm, yes, filed bug and split this change to https
|
| + |
| if (!reset_cb_.is_null()) { |
| base::ResetAndReturn(&read_cb_).Run(kAborted, NULL); |
| DoReset(); |
| @@ -285,8 +292,17 @@ void DecryptingAudioDecoder::DoDecryptAndDecodeBuffer( |
| if (status == DemuxerStream::kConfigChanged) { |
| DVLOG(2) << "DoDecryptAndDecodeBuffer() - kConfigChanged"; |
| - scoped_ptr<AudioDecoderConfig> scoped_config(new AudioDecoderConfig()); |
| - scoped_config->CopyFrom(demuxer_stream_->audio_decoder_config()); |
| + const AudioDecoderConfig& input_config = |
| + demuxer_stream_->audio_decoder_config(); |
| + scoped_ptr<AudioDecoderConfig> scoped_config(new AudioDecoderConfig()); |
| + scoped_config->Initialize(input_config.codec(), |
| + kSampleFormatS16, |
| + input_config.channel_layout(), |
| + input_config.samples_per_second(), |
| + input_config.extra_data(), |
| + input_config.extra_data_size(), |
| + input_config.is_encrypted(), |
| + false); |
| state_ = kPendingConfigChange; |
| decryptor_->DeinitializeDecoder(Decryptor::kAudio); |
| @@ -447,6 +463,18 @@ void DecryptingAudioDecoder::DoReset() { |
| base::ResetAndReturn(&reset_cb_).Run(); |
| } |
| +void DecryptingAudioDecoder::SetDecoderConfig() { |
| + const AudioDecoderConfig& config = demuxer_stream_->audio_decoder_config(); |
| + bits_per_channel_ = kSupportedBitsPerChannel; |
| + channel_layout_ = config.channel_layout(); |
| + samples_per_second_ = config.samples_per_second(); |
| + const int kBitsPerByte = 8; |
| + bytes_per_sample_ = ChannelLayoutToChannelCount(channel_layout_) * |
| + bits_per_channel_ / kBitsPerByte; |
| + output_timestamp_base_ = kNoTimestamp(); |
| + total_samples_decoded_ = 0; |
| +} |
| + |
| void DecryptingAudioDecoder::EnqueueFrames( |
| const Decryptor::AudioBuffers& frames) { |
| queued_audio_frames_ = frames; |