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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 base::Bind(&DecryptingAudioDecoder::DecryptAndDecodeBuffer, weak_this_)); | 254 base::Bind(&DecryptingAudioDecoder::DecryptAndDecodeBuffer, weak_this_)); |
255 } | 255 } |
256 | 256 |
257 void DecryptingAudioDecoder::DecryptAndDecodeBuffer( | 257 void DecryptingAudioDecoder::DecryptAndDecodeBuffer( |
258 DemuxerStream::Status status, | 258 DemuxerStream::Status status, |
259 const scoped_refptr<DecoderBuffer>& buffer) { | 259 const scoped_refptr<DecoderBuffer>& buffer) { |
260 DVLOG(3) << "DecryptAndDecodeBuffer()"; | 260 DVLOG(3) << "DecryptAndDecodeBuffer()"; |
261 DCHECK(message_loop_->BelongsToCurrentThread()); | 261 DCHECK(message_loop_->BelongsToCurrentThread()); |
262 DCHECK_EQ(state_, kPendingDemuxerRead) << state_; | 262 DCHECK_EQ(state_, kPendingDemuxerRead) << state_; |
263 DCHECK(!read_cb_.is_null()); | 263 DCHECK(!read_cb_.is_null()); |
264 DCHECK_EQ(buffer != NULL, status == DemuxerStream::kOk) << status; | 264 DCHECK_EQ(buffer.get() != NULL, status == DemuxerStream::kOk) << status; |
265 | 265 |
266 if (status == DemuxerStream::kConfigChanged) { | 266 if (status == DemuxerStream::kConfigChanged) { |
267 DVLOG(2) << "DecryptAndDecodeBuffer() - kConfigChanged"; | 267 DVLOG(2) << "DecryptAndDecodeBuffer() - kConfigChanged"; |
268 | 268 |
269 const AudioDecoderConfig& input_config = | 269 const AudioDecoderConfig& input_config = |
270 demuxer_stream_->audio_decoder_config(); | 270 demuxer_stream_->audio_decoder_config(); |
271 AudioDecoderConfig config; | 271 AudioDecoderConfig config; |
272 config.Initialize(input_config.codec(), | 272 config.Initialize(input_config.codec(), |
273 kSampleFormatS16, | 273 kSampleFormatS16, |
274 input_config.channel_layout(), | 274 input_config.channel_layout(), |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 } | 329 } |
330 | 330 |
331 void DecryptingAudioDecoder::DeliverFrame( | 331 void DecryptingAudioDecoder::DeliverFrame( |
332 int buffer_size, | 332 int buffer_size, |
333 Decryptor::Status status, | 333 Decryptor::Status status, |
334 const Decryptor::AudioBuffers& frames) { | 334 const Decryptor::AudioBuffers& frames) { |
335 DVLOG(3) << "DeliverFrame() - status: " << status; | 335 DVLOG(3) << "DeliverFrame() - status: " << status; |
336 DCHECK(message_loop_->BelongsToCurrentThread()); | 336 DCHECK(message_loop_->BelongsToCurrentThread()); |
337 DCHECK_EQ(state_, kPendingDecode) << state_; | 337 DCHECK_EQ(state_, kPendingDecode) << state_; |
338 DCHECK(!read_cb_.is_null()); | 338 DCHECK(!read_cb_.is_null()); |
339 DCHECK(pending_buffer_to_decode_); | 339 DCHECK(pending_buffer_to_decode_.get()); |
340 DCHECK(queued_audio_frames_.empty()); | 340 DCHECK(queued_audio_frames_.empty()); |
341 | 341 |
342 bool need_to_try_again_if_nokey_is_returned = key_added_while_decode_pending_; | 342 bool need_to_try_again_if_nokey_is_returned = key_added_while_decode_pending_; |
343 key_added_while_decode_pending_ = false; | 343 key_added_while_decode_pending_ = false; |
344 | 344 |
345 scoped_refptr<DecoderBuffer> scoped_pending_buffer_to_decode = | 345 scoped_refptr<DecoderBuffer> scoped_pending_buffer_to_decode = |
346 pending_buffer_to_decode_; | 346 pending_buffer_to_decode_; |
347 pending_buffer_to_decode_ = NULL; | 347 pending_buffer_to_decode_ = NULL; |
348 | 348 |
349 if (!reset_cb_.is_null()) { | 349 if (!reset_cb_.is_null()) { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 | 478 |
479 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( | 479 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( |
480 int number_of_samples) const { | 480 int number_of_samples) const { |
481 DCHECK(samples_per_second_); | 481 DCHECK(samples_per_second_); |
482 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * | 482 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * |
483 number_of_samples / | 483 number_of_samples / |
484 samples_per_second_); | 484 samples_per_second_); |
485 } | 485 } |
486 | 486 |
487 } // namespace media | 487 } // namespace media |
OLD | NEW |