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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 320 |
321 void OpusAudioDecoder::Reset(const base::Closure& closure) { | 321 void OpusAudioDecoder::Reset(const base::Closure& closure) { |
322 DCHECK(task_runner_->BelongsToCurrentThread()); | 322 DCHECK(task_runner_->BelongsToCurrentThread()); |
323 base::Closure reset_cb = BindToCurrentLoop(closure); | 323 base::Closure reset_cb = BindToCurrentLoop(closure); |
324 | 324 |
325 opus_multistream_decoder_ctl(opus_decoder_, OPUS_RESET_STATE); | 325 opus_multistream_decoder_ctl(opus_decoder_, OPUS_RESET_STATE); |
326 ResetTimestampState(); | 326 ResetTimestampState(); |
327 reset_cb.Run(); | 327 reset_cb.Run(); |
328 } | 328 } |
329 | 329 |
330 OpusAudioDecoder::~OpusAudioDecoder() { | 330 void OpusAudioDecoder::Stop(const base::Closure& closure) { |
331 // TODO(scherkus): should we require Stop() to be called? this might end up | 331 DCHECK(task_runner_->BelongsToCurrentThread()); |
332 // getting called on a random thread due to refcounting. | 332 base::Closure stop_cb = BindToCurrentLoop(closure); |
| 333 |
| 334 opus_multistream_decoder_ctl(opus_decoder_, OPUS_RESET_STATE); |
| 335 ResetTimestampState(); |
333 CloseDecoder(); | 336 CloseDecoder(); |
| 337 |
| 338 // TODO(rileya): Properly handle the case in which we have a pending |
| 339 // |read_cb_| when Stop() or Reset()-ing. |
| 340 stop_cb.Run(); |
334 } | 341 } |
335 | 342 |
| 343 OpusAudioDecoder::~OpusAudioDecoder() {} |
| 344 |
336 void OpusAudioDecoder::ReadFromDemuxerStream() { | 345 void OpusAudioDecoder::ReadFromDemuxerStream() { |
337 DCHECK(!read_cb_.is_null()); | 346 DCHECK(!read_cb_.is_null()); |
338 demuxer_stream_->Read(base::Bind(&OpusAudioDecoder::BufferReady, weak_this_)); | 347 demuxer_stream_->Read(base::Bind(&OpusAudioDecoder::BufferReady, weak_this_)); |
339 } | 348 } |
340 | 349 |
341 void OpusAudioDecoder::BufferReady( | 350 void OpusAudioDecoder::BufferReady( |
342 DemuxerStream::Status status, | 351 DemuxerStream::Status status, |
343 const scoped_refptr<DecoderBuffer>& input) { | 352 const scoped_refptr<DecoderBuffer>& input) { |
344 DCHECK(task_runner_->BelongsToCurrentThread()); | 353 DCHECK(task_runner_->BelongsToCurrentThread()); |
345 DCHECK(!read_cb_.is_null()); | 354 DCHECK(!read_cb_.is_null()); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 output_timestamp_helper_->AddFrames(frames_decoded); | 628 output_timestamp_helper_->AddFrames(frames_decoded); |
620 | 629 |
621 // Discard the buffer to indicate we need more data. | 630 // Discard the buffer to indicate we need more data. |
622 if (!frames_to_output) | 631 if (!frames_to_output) |
623 *output_buffer = NULL; | 632 *output_buffer = NULL; |
624 | 633 |
625 return true; | 634 return true; |
626 } | 635 } |
627 | 636 |
628 } // namespace media | 637 } // namespace media |
OLD | NEW |