| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 opus_multistream_decoder_ctl(opus_decoder_, OPUS_RESET_STATE); | 291 opus_multistream_decoder_ctl(opus_decoder_, OPUS_RESET_STATE); |
| 292 ResetTimestampState(); | 292 ResetTimestampState(); |
| 293 CloseDecoder(); | 293 CloseDecoder(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 void OpusAudioDecoder::DecodeBuffer( | 296 void OpusAudioDecoder::DecodeBuffer( |
| 297 const scoped_refptr<DecoderBuffer>& input, | 297 const scoped_refptr<DecoderBuffer>& input, |
| 298 const DecodeCB& decode_cb) { | 298 const DecodeCB& decode_cb) { |
| 299 DCHECK(task_runner_->BelongsToCurrentThread()); | 299 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 300 DCHECK(!decode_cb.is_null()); | 300 DCHECK(!decode_cb.is_null()); |
| 301 DCHECK(input); | 301 DCHECK(input.get()); |
| 302 | 302 |
| 303 // Libopus does not buffer output. Decoding is complete when an end of stream | 303 // Libopus does not buffer output. Decoding is complete when an end of stream |
| 304 // input buffer is received. | 304 // input buffer is received. |
| 305 if (input->end_of_stream()) { | 305 if (input->end_of_stream()) { |
| 306 decode_cb.Run(kOk); | 306 decode_cb.Run(kOk); |
| 307 return; | 307 return; |
| 308 } | 308 } |
| 309 | 309 |
| 310 // Make sure we are notified if http://crbug.com/49709 returns. Issue also | 310 // Make sure we are notified if http://crbug.com/49709 returns. Issue also |
| 311 // occurs with some damaged files. | 311 // occurs with some damaged files. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 323 discard_helper_->Reset(config_.codec_delay()); | 323 discard_helper_->Reset(config_.codec_delay()); |
| 324 } | 324 } |
| 325 | 325 |
| 326 scoped_refptr<AudioBuffer> output_buffer; | 326 scoped_refptr<AudioBuffer> output_buffer; |
| 327 | 327 |
| 328 if (!Decode(input, &output_buffer)) { | 328 if (!Decode(input, &output_buffer)) { |
| 329 decode_cb.Run(kDecodeError); | 329 decode_cb.Run(kDecodeError); |
| 330 return; | 330 return; |
| 331 } | 331 } |
| 332 | 332 |
| 333 if (output_buffer) { | 333 if (output_buffer.get()) { |
| 334 output_cb_.Run(output_buffer); | 334 output_cb_.Run(output_buffer); |
| 335 } | 335 } |
| 336 | 336 |
| 337 decode_cb.Run(kOk); | 337 decode_cb.Run(kOk); |
| 338 } | 338 } |
| 339 | 339 |
| 340 bool OpusAudioDecoder::ConfigureDecoder() { | 340 bool OpusAudioDecoder::ConfigureDecoder() { |
| 341 if (config_.codec() != kCodecOpus) { | 341 if (config_.codec() != kCodecOpus) { |
| 342 DVLOG(1) << "Codec must be kCodecOpus."; | 342 DVLOG(1) << "Codec must be kCodecOpus."; |
| 343 return false; | 343 return false; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 output_buffer->get()->TrimEnd(trim_frames); | 474 output_buffer->get()->TrimEnd(trim_frames); |
| 475 | 475 |
| 476 // Handles discards and timestamping. Discard the buffer if more data needed. | 476 // Handles discards and timestamping. Discard the buffer if more data needed. |
| 477 if (!discard_helper_->ProcessBuffers(input, *output_buffer)) | 477 if (!discard_helper_->ProcessBuffers(input, *output_buffer)) |
| 478 *output_buffer = NULL; | 478 *output_buffer = NULL; |
| 479 | 479 |
| 480 return true; | 480 return true; |
| 481 } | 481 } |
| 482 | 482 |
| 483 } // namespace media | 483 } // namespace media |
| OLD | NEW |