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

Side by Side Diff: media/filters/ffmpeg_video_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_video_decoder.h ('k') | media/filters/ffmpeg_video_decoder_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/ffmpeg_video_decoder.h" 5 #include "media/filters/ffmpeg_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 234 }
235 235
236 void FFmpegVideoDecoder::Reset(const base::Closure& closure) { 236 void FFmpegVideoDecoder::Reset(const base::Closure& closure) {
237 DCHECK(task_runner_->BelongsToCurrentThread()); 237 DCHECK(task_runner_->BelongsToCurrentThread());
238 238
239 avcodec_flush_buffers(codec_context_.get()); 239 avcodec_flush_buffers(codec_context_.get());
240 state_ = kNormal; 240 state_ = kNormal;
241 task_runner_->PostTask(FROM_HERE, closure); 241 task_runner_->PostTask(FROM_HERE, closure);
242 } 242 }
243 243
244 void FFmpegVideoDecoder::Stop() { 244 FFmpegVideoDecoder::~FFmpegVideoDecoder() {
245 DCHECK(task_runner_->BelongsToCurrentThread()); 245 DCHECK(task_runner_->BelongsToCurrentThread());
246 246
247 if (state_ == kUninitialized) 247 if (state_ != kUninitialized)
248 return; 248 ReleaseFFmpegResources();
249
250 ReleaseFFmpegResources();
251 state_ = kUninitialized;
252 }
253
254 FFmpegVideoDecoder::~FFmpegVideoDecoder() {
255 DCHECK_EQ(kUninitialized, state_);
256 DCHECK(!codec_context_);
257 DCHECK(!av_frame_);
258 } 249 }
259 250
260 bool FFmpegVideoDecoder::FFmpegDecode( 251 bool FFmpegVideoDecoder::FFmpegDecode(
261 const scoped_refptr<DecoderBuffer>& buffer, 252 const scoped_refptr<DecoderBuffer>& buffer,
262 bool* has_produced_frame) { 253 bool* has_produced_frame) {
263 DCHECK(!*has_produced_frame); 254 DCHECK(!*has_produced_frame);
264 255
265 // Create a packet for input data. 256 // Create a packet for input data.
266 // Due to FFmpeg API changes we no longer have const read-only pointers. 257 // Due to FFmpeg API changes we no longer have const read-only pointers.
267 AVPacket packet; 258 AVPacket packet;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { 341 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
351 ReleaseFFmpegResources(); 342 ReleaseFFmpegResources();
352 return false; 343 return false;
353 } 344 }
354 345
355 av_frame_.reset(av_frame_alloc()); 346 av_frame_.reset(av_frame_alloc());
356 return true; 347 return true;
357 } 348 }
358 349
359 } // namespace media 350 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_video_decoder.h ('k') | media/filters/ffmpeg_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698