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

Side by Side Diff: media/filters/ffmpeg_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/ffmpeg_audio_decoder.h ('k') | media/filters/ffmpeg_video_decoder.h » ('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/ffmpeg_audio_decoder.h" 5 #include "media/filters/ffmpeg_audio_decoder.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "media/base/audio_buffer.h" 9 #include "media/base/audio_buffer.h"
10 #include "media/base/audio_bus.h" 10 #include "media/base/audio_bus.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 FFmpegAudioDecoder::FFmpegAudioDecoder( 128 FFmpegAudioDecoder::FFmpegAudioDecoder(
129 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 129 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
130 const LogCB& log_cb) 130 const LogCB& log_cb)
131 : task_runner_(task_runner), 131 : task_runner_(task_runner),
132 state_(kUninitialized), 132 state_(kUninitialized),
133 av_sample_format_(0), 133 av_sample_format_(0),
134 log_cb_(log_cb) { 134 log_cb_(log_cb) {
135 } 135 }
136 136
137 FFmpegAudioDecoder::~FFmpegAudioDecoder() { 137 FFmpegAudioDecoder::~FFmpegAudioDecoder() {
138 DCHECK_EQ(state_, kUninitialized); 138 DCHECK(task_runner_->BelongsToCurrentThread());
139 DCHECK(!codec_context_); 139
140 DCHECK(!av_frame_); 140 if (state_ != kUninitialized) {
141 ReleaseFFmpegResources();
142 ResetTimestampState();
143 }
141 } 144 }
142 145
143 void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config, 146 void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config,
144 const PipelineStatusCB& status_cb, 147 const PipelineStatusCB& status_cb,
145 const OutputCB& output_cb) { 148 const OutputCB& output_cb) {
146 DCHECK(task_runner_->BelongsToCurrentThread()); 149 DCHECK(task_runner_->BelongsToCurrentThread());
147 DCHECK(!config.is_encrypted()); 150 DCHECK(!config.is_encrypted());
148 151
149 FFmpegGlue::InitializeFFmpeg(); 152 FFmpegGlue::InitializeFFmpeg();
150 153
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 188
186 void FFmpegAudioDecoder::Reset(const base::Closure& closure) { 189 void FFmpegAudioDecoder::Reset(const base::Closure& closure) {
187 DCHECK(task_runner_->BelongsToCurrentThread()); 190 DCHECK(task_runner_->BelongsToCurrentThread());
188 191
189 avcodec_flush_buffers(codec_context_.get()); 192 avcodec_flush_buffers(codec_context_.get());
190 state_ = kNormal; 193 state_ = kNormal;
191 ResetTimestampState(); 194 ResetTimestampState();
192 task_runner_->PostTask(FROM_HERE, closure); 195 task_runner_->PostTask(FROM_HERE, closure);
193 } 196 }
194 197
195 void FFmpegAudioDecoder::Stop() {
196 DCHECK(task_runner_->BelongsToCurrentThread());
197
198 if (state_ == kUninitialized)
199 return;
200
201 ReleaseFFmpegResources();
202 ResetTimestampState();
203 state_ = kUninitialized;
204 }
205
206 void FFmpegAudioDecoder::DecodeBuffer( 198 void FFmpegAudioDecoder::DecodeBuffer(
207 const scoped_refptr<DecoderBuffer>& buffer, 199 const scoped_refptr<DecoderBuffer>& buffer,
208 const DecodeCB& decode_cb) { 200 const DecodeCB& decode_cb) {
209 DCHECK(task_runner_->BelongsToCurrentThread()); 201 DCHECK(task_runner_->BelongsToCurrentThread());
210 DCHECK_NE(state_, kUninitialized); 202 DCHECK_NE(state_, kUninitialized);
211 DCHECK_NE(state_, kDecodeFinished); 203 DCHECK_NE(state_, kDecodeFinished);
212 DCHECK_NE(state_, kError); 204 DCHECK_NE(state_, kError);
213 DCHECK(buffer); 205 DCHECK(buffer);
214 206
215 // Make sure we are notified if http://crbug.com/49709 returns. Issue also 207 // Make sure we are notified if http://crbug.com/49709 returns. Issue also
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 384
393 ResetTimestampState(); 385 ResetTimestampState();
394 return true; 386 return true;
395 } 387 }
396 388
397 void FFmpegAudioDecoder::ResetTimestampState() { 389 void FFmpegAudioDecoder::ResetTimestampState() {
398 discard_helper_->Reset(config_.codec_delay()); 390 discard_helper_->Reset(config_.codec_delay());
399 } 391 }
400 392
401 } // namespace media 393 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.h ('k') | media/filters/ffmpeg_video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698