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

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

Issue 16297002: Update media/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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/gpu_video_decoder.cc ('k') | media/filters/pipeline_integration_test_base.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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 void OpusAudioDecoder::ReadFromDemuxerStream() { 322 void OpusAudioDecoder::ReadFromDemuxerStream() {
323 DCHECK(!read_cb_.is_null()); 323 DCHECK(!read_cb_.is_null());
324 demuxer_stream_->Read(base::Bind(&OpusAudioDecoder::BufferReady, weak_this_)); 324 demuxer_stream_->Read(base::Bind(&OpusAudioDecoder::BufferReady, weak_this_));
325 } 325 }
326 326
327 void OpusAudioDecoder::BufferReady( 327 void OpusAudioDecoder::BufferReady(
328 DemuxerStream::Status status, 328 DemuxerStream::Status status,
329 const scoped_refptr<DecoderBuffer>& input) { 329 const scoped_refptr<DecoderBuffer>& input) {
330 DCHECK(message_loop_->BelongsToCurrentThread()); 330 DCHECK(message_loop_->BelongsToCurrentThread());
331 DCHECK(!read_cb_.is_null()); 331 DCHECK(!read_cb_.is_null());
332 DCHECK_EQ(status != DemuxerStream::kOk, !input) << status; 332 DCHECK_EQ(status != DemuxerStream::kOk, !input.get()) << status;
333 333
334 if (status == DemuxerStream::kAborted) { 334 if (status == DemuxerStream::kAborted) {
335 DCHECK(!input); 335 DCHECK(!input.get());
336 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL); 336 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL);
337 return; 337 return;
338 } 338 }
339 339
340 if (status == DemuxerStream::kConfigChanged) { 340 if (status == DemuxerStream::kConfigChanged) {
341 DCHECK(!input); 341 DCHECK(!input.get());
342 DVLOG(1) << "Config changed."; 342 DVLOG(1) << "Config changed.";
343 343
344 if (!ConfigureDecoder()) { 344 if (!ConfigureDecoder()) {
345 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL); 345 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL);
346 return; 346 return;
347 } 347 }
348 348
349 ResetTimestampState(); 349 ResetTimestampState();
350 ReadFromDemuxerStream(); 350 ReadFromDemuxerStream();
351 return; 351 return;
352 } 352 }
353 353
354 DCHECK_EQ(status, DemuxerStream::kOk); 354 DCHECK_EQ(status, DemuxerStream::kOk);
355 DCHECK(input); 355 DCHECK(input.get());
356 356
357 // Libopus does not buffer output. Decoding is complete when an end of stream 357 // Libopus does not buffer output. Decoding is complete when an end of stream
358 // input buffer is received. 358 // input buffer is received.
359 if (input->IsEndOfStream()) { 359 if (input->IsEndOfStream()) {
360 base::ResetAndReturn(&read_cb_).Run(kOk, DataBuffer::CreateEOSBuffer()); 360 base::ResetAndReturn(&read_cb_).Run(kOk, DataBuffer::CreateEOSBuffer());
361 return; 361 return;
362 } 362 }
363 363
364 // Make sure we are notified if http://crbug.com/49709 returns. Issue also 364 // Make sure we are notified if http://crbug.com/49709 returns. Issue also
365 // occurs with some damaged files. 365 // occurs with some damaged files.
(...skipping 17 matching lines...) Expand all
383 383
384 last_input_timestamp_ = input->GetTimestamp(); 384 last_input_timestamp_ = input->GetTimestamp();
385 385
386 scoped_refptr<DataBuffer> output_buffer; 386 scoped_refptr<DataBuffer> output_buffer;
387 387
388 if (!Decode(input, &output_buffer)) { 388 if (!Decode(input, &output_buffer)) {
389 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL); 389 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL);
390 return; 390 return;
391 } 391 }
392 392
393 if (output_buffer) { 393 if (output_buffer.get()) {
394 // Execute callback to return the decoded audio. 394 // Execute callback to return the decoded audio.
395 base::ResetAndReturn(&read_cb_).Run(kOk, output_buffer); 395 base::ResetAndReturn(&read_cb_).Run(kOk, output_buffer);
396 } else { 396 } else {
397 // We exhausted the input data, but it wasn't enough for a frame. Ask for 397 // We exhausted the input data, but it wasn't enough for a frame. Ask for
398 // more data in order to fulfill this read. 398 // more data in order to fulfill this read.
399 ReadFromDemuxerStream(); 399 ReadFromDemuxerStream();
400 } 400 }
401 } 401 }
402 402
403 bool OpusAudioDecoder::ConfigureDecoder() { 403 bool OpusAudioDecoder::ConfigureDecoder() {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 559
560 // Decoding finished successfully, update statistics. 560 // Decoding finished successfully, update statistics.
561 PipelineStatistics statistics; 561 PipelineStatistics statistics;
562 statistics.audio_bytes_decoded = decoded_audio_size; 562 statistics.audio_bytes_decoded = decoded_audio_size;
563 statistics_cb_.Run(statistics); 563 statistics_cb_.Run(statistics);
564 564
565 return true; 565 return true;
566 } 566 }
567 567
568 } // namespace media 568 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/gpu_video_decoder.cc ('k') | media/filters/pipeline_integration_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698