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

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

Issue 193303002: WeakPtr destruction order cleanup: media edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
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/ffmpeg_audio_decoder.h" 5 #include "media/filters/ffmpeg_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/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Called by FFmpeg's allocation routine to free a buffer. |opaque| is the 65 // Called by FFmpeg's allocation routine to free a buffer. |opaque| is the
66 // AudioBuffer allocated, so unref it. 66 // AudioBuffer allocated, so unref it.
67 static void ReleaseAudioBufferImpl(void* opaque, uint8* data) { 67 static void ReleaseAudioBufferImpl(void* opaque, uint8* data) {
68 scoped_refptr<AudioBuffer> buffer; 68 scoped_refptr<AudioBuffer> buffer;
69 buffer.swap(reinterpret_cast<AudioBuffer**>(&opaque)); 69 buffer.swap(reinterpret_cast<AudioBuffer**>(&opaque));
70 } 70 }
71 71
72 FFmpegAudioDecoder::FFmpegAudioDecoder( 72 FFmpegAudioDecoder::FFmpegAudioDecoder(
73 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) 73 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
74 : task_runner_(task_runner), 74 : task_runner_(task_runner),
75 weak_factory_(this),
76 demuxer_stream_(NULL), 75 demuxer_stream_(NULL),
77 bytes_per_channel_(0), 76 bytes_per_channel_(0),
78 channel_layout_(CHANNEL_LAYOUT_NONE), 77 channel_layout_(CHANNEL_LAYOUT_NONE),
79 channels_(0), 78 channels_(0),
80 samples_per_second_(0), 79 samples_per_second_(0),
81 av_sample_format_(0), 80 av_sample_format_(0),
82 last_input_timestamp_(kNoTimestamp()), 81 last_input_timestamp_(kNoTimestamp()),
83 output_frames_to_drop_(0) { 82 output_frames_to_drop_(0),
84 } 83 weak_factory_(this) {}
85 84
86 void FFmpegAudioDecoder::Initialize( 85 void FFmpegAudioDecoder::Initialize(
87 DemuxerStream* stream, 86 DemuxerStream* stream,
88 const PipelineStatusCB& status_cb, 87 const PipelineStatusCB& status_cb,
89 const StatisticsCB& statistics_cb) { 88 const StatisticsCB& statistics_cb) {
90 DCHECK(task_runner_->BelongsToCurrentThread()); 89 DCHECK(task_runner_->BelongsToCurrentThread());
91 PipelineStatusCB initialize_cb = BindToCurrentLoop(status_cb); 90 PipelineStatusCB initialize_cb = BindToCurrentLoop(status_cb);
92 91
93 FFmpegGlue::InitializeFFmpeg(); 92 FFmpegGlue::InitializeFFmpeg();
94 93
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 // Decoding finished successfully, update statistics. 590 // Decoding finished successfully, update statistics.
592 if (result > 0) { 591 if (result > 0) {
593 PipelineStatistics statistics; 592 PipelineStatistics statistics;
594 statistics.audio_bytes_decoded = result; 593 statistics.audio_bytes_decoded = result;
595 statistics_cb_.Run(statistics); 594 statistics_cb_.Run(statistics);
596 } 595 }
597 } while (packet.size > 0); 596 } while (packet.size > 0);
598 } 597 }
599 598
600 } // namespace media 599 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698