| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 } | 274 } |
| 275 | 275 |
| 276 void OpusAudioDecoder::Reset(const base::Closure& closure) { | 276 void OpusAudioDecoder::Reset(const base::Closure& closure) { |
| 277 DCHECK(task_runner_->BelongsToCurrentThread()); | 277 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 278 | 278 |
| 279 opus_multistream_decoder_ctl(opus_decoder_, OPUS_RESET_STATE); | 279 opus_multistream_decoder_ctl(opus_decoder_, OPUS_RESET_STATE); |
| 280 ResetTimestampState(); | 280 ResetTimestampState(); |
| 281 task_runner_->PostTask(FROM_HERE, closure); | 281 task_runner_->PostTask(FROM_HERE, closure); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void OpusAudioDecoder::Stop() { | 284 OpusAudioDecoder::~OpusAudioDecoder() { |
| 285 DCHECK(task_runner_->BelongsToCurrentThread()); | 285 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 286 | 286 |
| 287 if (!opus_decoder_) | 287 if (!opus_decoder_) |
| 288 return; | 288 return; |
| 289 | 289 |
| 290 opus_multistream_decoder_ctl(opus_decoder_, OPUS_RESET_STATE); | 290 opus_multistream_decoder_ctl(opus_decoder_, OPUS_RESET_STATE); |
| 291 ResetTimestampState(); | 291 ResetTimestampState(); |
| 292 CloseDecoder(); | 292 CloseDecoder(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 OpusAudioDecoder::~OpusAudioDecoder() { | |
| 296 DCHECK(!opus_decoder_); | |
| 297 } | |
| 298 | |
| 299 void OpusAudioDecoder::DecodeBuffer( | 295 void OpusAudioDecoder::DecodeBuffer( |
| 300 const scoped_refptr<DecoderBuffer>& input, | 296 const scoped_refptr<DecoderBuffer>& input, |
| 301 const DecodeCB& decode_cb) { | 297 const DecodeCB& decode_cb) { |
| 302 DCHECK(task_runner_->BelongsToCurrentThread()); | 298 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 303 DCHECK(!decode_cb.is_null()); | 299 DCHECK(!decode_cb.is_null()); |
| 304 DCHECK(input); | 300 DCHECK(input); |
| 305 | 301 |
| 306 // Libopus does not buffer output. Decoding is complete when an end of stream | 302 // Libopus does not buffer output. Decoding is complete when an end of stream |
| 307 // input buffer is received. | 303 // input buffer is received. |
| 308 if (input->end_of_stream()) { | 304 if (input->end_of_stream()) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 output_buffer->get()->TrimEnd(trim_frames); | 473 output_buffer->get()->TrimEnd(trim_frames); |
| 478 | 474 |
| 479 // Handles discards and timestamping. Discard the buffer if more data needed. | 475 // Handles discards and timestamping. Discard the buffer if more data needed. |
| 480 if (!discard_helper_->ProcessBuffers(input, *output_buffer)) | 476 if (!discard_helper_->ProcessBuffers(input, *output_buffer)) |
| 481 *output_buffer = NULL; | 477 *output_buffer = NULL; |
| 482 | 478 |
| 483 return true; | 479 return true; |
| 484 } | 480 } |
| 485 | 481 |
| 486 } // namespace media | 482 } // namespace media |
| OLD | NEW |