Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(842)

Side by Side Diff: media/filters/opus_audio_decoder.cc

Issue 126793002: Add Stop() to AudioDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove blank lines Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 stop_cb.Run();
xhwang 2014/01/08 01:33:37 ditto about Stop() during pending demuxer read.
rileya (GONE FROM CHROMIUM) 2014/01/08 21:05:50 Added a TODO.
334 } 339 }
335 340
341 OpusAudioDecoder::~OpusAudioDecoder() {}
342
336 void OpusAudioDecoder::ReadFromDemuxerStream() { 343 void OpusAudioDecoder::ReadFromDemuxerStream() {
337 DCHECK(!read_cb_.is_null()); 344 DCHECK(!read_cb_.is_null());
338 demuxer_stream_->Read(base::Bind(&OpusAudioDecoder::BufferReady, weak_this_)); 345 demuxer_stream_->Read(base::Bind(&OpusAudioDecoder::BufferReady, weak_this_));
339 } 346 }
340 347
341 void OpusAudioDecoder::BufferReady( 348 void OpusAudioDecoder::BufferReady(
342 DemuxerStream::Status status, 349 DemuxerStream::Status status,
343 const scoped_refptr<DecoderBuffer>& input) { 350 const scoped_refptr<DecoderBuffer>& input) {
344 DCHECK(task_runner_->BelongsToCurrentThread()); 351 DCHECK(task_runner_->BelongsToCurrentThread());
345 DCHECK(!read_cb_.is_null()); 352 DCHECK(!read_cb_.is_null());
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 output_timestamp_helper_->AddFrames(frames_decoded); 626 output_timestamp_helper_->AddFrames(frames_decoded);
620 627
621 // Discard the buffer to indicate we need more data. 628 // Discard the buffer to indicate we need more data.
622 if (!frames_to_output) 629 if (!frames_to_output)
623 *output_buffer = NULL; 630 *output_buffer = NULL;
624 631
625 return true; 632 return true;
626 } 633 }
627 634
628 } // namespace media 635 } // namespace media
OLDNEW
« media/filters/ffmpeg_audio_decoder.cc ('K') | « media/filters/opus_audio_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698