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

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

Issue 395703002: Fold {Audio|Video}Decoder::Stop() into the dtor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/opus_audio_decoder.h ('k') | media/filters/video_decoder_selector_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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
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
OLDNEW
« no previous file with comments | « media/filters/opus_audio_decoder.h ('k') | media/filters/video_decoder_selector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698