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