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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 } | 335 } |
336 | 336 |
337 pending_buffer_to_decode_ = buffer; | 337 pending_buffer_to_decode_ = buffer; |
338 state_ = kPendingDecode; | 338 state_ = kPendingDecode; |
339 DecodePendingBuffer(); | 339 DecodePendingBuffer(); |
340 } | 340 } |
341 | 341 |
342 void DecryptingAudioDecoder::DecodePendingBuffer() { | 342 void DecryptingAudioDecoder::DecodePendingBuffer() { |
343 DCHECK(message_loop_->BelongsToCurrentThread()); | 343 DCHECK(message_loop_->BelongsToCurrentThread()); |
344 DCHECK_EQ(state_, kPendingDecode) << state_; | 344 DCHECK_EQ(state_, kPendingDecode) << state_; |
| 345 |
| 346 int buffer_size = 0; |
| 347 if (!pending_buffer_to_decode_->IsEndOfStream()) { |
| 348 buffer_size = pending_buffer_to_decode_->GetDataSize(); |
| 349 } |
| 350 |
345 decryptor_->DecryptAndDecodeAudio( | 351 decryptor_->DecryptAndDecodeAudio( |
346 pending_buffer_to_decode_, | 352 pending_buffer_to_decode_, |
347 base::Bind(&DecryptingAudioDecoder::DeliverFrame, this, | 353 base::Bind(&DecryptingAudioDecoder::DeliverFrame, this, buffer_size)); |
348 pending_buffer_to_decode_->GetDataSize())); | |
349 } | 354 } |
350 | 355 |
351 void DecryptingAudioDecoder::DeliverFrame( | 356 void DecryptingAudioDecoder::DeliverFrame( |
352 int buffer_size, | 357 int buffer_size, |
353 Decryptor::Status status, | 358 Decryptor::Status status, |
354 const Decryptor::AudioBuffers& frames) { | 359 const Decryptor::AudioBuffers& frames) { |
355 // We need to force task post here because the AudioDecodeCB can be executed | 360 // We need to force task post here because the AudioDecodeCB can be executed |
356 // synchronously in Reset(). Instead of using more complicated logic in | 361 // synchronously in Reset(). Instead of using more complicated logic in |
357 // those function to fix it, why not force task post here to make everything | 362 // those function to fix it, why not force task post here to make everything |
358 // simple and clear? | 363 // simple and clear? |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 | 516 |
512 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( | 517 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( |
513 int number_of_samples) const { | 518 int number_of_samples) const { |
514 DCHECK(samples_per_second_); | 519 DCHECK(samples_per_second_); |
515 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * | 520 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * |
516 number_of_samples / | 521 number_of_samples / |
517 samples_per_second_); | 522 samples_per_second_); |
518 } | 523 } |
519 | 524 |
520 } // namespace media | 525 } // namespace media |
OLD | NEW |