Chromium Code Reviews| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 DCHECK(task_runner_->BelongsToCurrentThread()); | 283 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 284 | 284 |
| 285 if (!opus_decoder_) | 285 if (!opus_decoder_) |
| 286 return; | 286 return; |
| 287 | 287 |
| 288 opus_multistream_decoder_ctl(opus_decoder_, OPUS_RESET_STATE); | 288 opus_multistream_decoder_ctl(opus_decoder_, OPUS_RESET_STATE); |
| 289 ResetTimestampState(); | 289 ResetTimestampState(); |
| 290 CloseDecoder(); | 290 CloseDecoder(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 OpusAudioDecoder::~OpusAudioDecoder() {} | 293 OpusAudioDecoder::~OpusAudioDecoder() {} |
|
wolenetz
2014/06/16 23:36:08
Enforce that ::Stop() is called before this if Ini
DaleCurtis
2014/06/19 01:05:52
Added DCHECK() as best-effort since decoder doesn'
| |
| 294 | 294 |
| 295 void OpusAudioDecoder::DecodeBuffer( | 295 void OpusAudioDecoder::DecodeBuffer( |
| 296 const scoped_refptr<DecoderBuffer>& input, | 296 const scoped_refptr<DecoderBuffer>& input, |
| 297 const DecodeCB& decode_cb) { | 297 const DecodeCB& decode_cb) { |
| 298 DCHECK(task_runner_->BelongsToCurrentThread()); | 298 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 299 DCHECK(!decode_cb.is_null()); | 299 DCHECK(!decode_cb.is_null()); |
| 300 | 300 |
| 301 DCHECK(input.get()); | 301 if (!input) { |
| 302 decode_cb.Run(kAborted, NULL); | |
| 303 return; | |
| 304 } | |
| 302 | 305 |
| 303 // Libopus does not buffer output. Decoding is complete when an end of stream | 306 // Libopus does not buffer output. Decoding is complete when an end of stream |
| 304 // input buffer is received. | 307 // input buffer is received. |
| 305 if (input->end_of_stream()) { | 308 if (input->end_of_stream()) { |
| 306 decode_cb.Run(kOk, AudioBuffer::CreateEOSBuffer()); | 309 decode_cb.Run(kOk, AudioBuffer::CreateEOSBuffer()); |
| 307 return; | 310 return; |
| 308 } | 311 } |
| 309 | 312 |
| 310 // Make sure we are notified if http://crbug.com/49709 returns. Issue also | 313 // Make sure we are notified if http://crbug.com/49709 returns. Issue also |
| 311 // occurs with some damaged files. | 314 // occurs with some damaged files. |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 output_buffer->get()->TrimEnd(trim_frames); | 479 output_buffer->get()->TrimEnd(trim_frames); |
| 477 | 480 |
| 478 // Handles discards and timestamping. Discard the buffer if more data needed. | 481 // Handles discards and timestamping. Discard the buffer if more data needed. |
| 479 if (!discard_helper_->ProcessBuffers(input, *output_buffer)) | 482 if (!discard_helper_->ProcessBuffers(input, *output_buffer)) |
| 480 *output_buffer = NULL; | 483 *output_buffer = NULL; |
| 481 | 484 |
| 482 return true; | 485 return true; |
| 483 } | 486 } |
| 484 | 487 |
| 485 } // namespace media | 488 } // namespace media |
| OLD | NEW |