| 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/opus_audio_decoder.h" | 5 #include "media/filters/opus_audio_decoder.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/sys_byteorder.h" | 10 #include "base/sys_byteorder.h" |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 } | 515 } |
| 516 if (input->discard_padding().InMicroseconds() > 0) { | 516 if (input->discard_padding().InMicroseconds() > 0) { |
| 517 int discard_padding = TimeDeltaToAudioFrames( | 517 int discard_padding = TimeDeltaToAudioFrames( |
| 518 input->discard_padding(), config_.samples_per_second()); | 518 input->discard_padding(), config_.samples_per_second()); |
| 519 if (discard_padding < 0 || discard_padding > frames_to_output) { | 519 if (discard_padding < 0 || discard_padding > frames_to_output) { |
| 520 DVLOG(1) << "Invalid file. Incorrect discard padding value."; | 520 DVLOG(1) << "Invalid file. Incorrect discard padding value."; |
| 521 return false; | 521 return false; |
| 522 } | 522 } |
| 523 output_buffer->get()->TrimEnd(discard_padding); | 523 output_buffer->get()->TrimEnd(discard_padding); |
| 524 frames_to_output -= discard_padding; | 524 frames_to_output -= discard_padding; |
| 525 } else { |
| 526 DCHECK_EQ(input->discard_padding().InMicroseconds(), 0); |
| 525 } | 527 } |
| 526 } else { | 528 } else { |
| 527 frames_to_discard_ -= frames_to_output; | 529 frames_to_discard_ -= frames_to_output; |
| 528 frames_to_output = 0; | 530 frames_to_output = 0; |
| 529 } | 531 } |
| 530 | 532 |
| 533 // Discard the buffer to indicate we need more data. |
| 534 if (!frames_to_output) { |
| 535 *output_buffer = NULL; |
| 536 return true; |
| 537 } |
| 538 |
| 531 // Assign timestamp and duration to the buffer. | 539 // Assign timestamp and duration to the buffer. |
| 532 output_buffer->get()->set_timestamp(output_timestamp_helper_->GetTimestamp()); | 540 output_buffer->get()->set_timestamp(output_timestamp_helper_->GetTimestamp()); |
| 533 output_buffer->get()->set_duration( | 541 output_buffer->get()->set_duration( |
| 534 output_timestamp_helper_->GetFrameDuration(frames_to_output)); | 542 output_timestamp_helper_->GetFrameDuration(frames_to_output)); |
| 535 output_timestamp_helper_->AddFrames(frames_decoded); | 543 output_timestamp_helper_->AddFrames(frames_to_output); |
| 536 | |
| 537 // Discard the buffer to indicate we need more data. | |
| 538 if (!frames_to_output) | |
| 539 *output_buffer = NULL; | |
| 540 | |
| 541 return true; | 544 return true; |
| 542 } | 545 } |
| 543 | 546 |
| 544 } // namespace media | 547 } // namespace media |
| OLD | NEW |