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

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

Issue 11420070: Remove locking from FFmpegDemuxerStream and associated TODOs from media code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 244
245 read_cb_ = read_cb; 245 read_cb_ = read_cb;
246 ReadFromDemuxerStream(); 246 ReadFromDemuxerStream();
247 } 247 }
248 248
249 void FFmpegVideoDecoder::ReadFromDemuxerStream() { 249 void FFmpegVideoDecoder::ReadFromDemuxerStream() {
250 DCHECK_NE(state_, kUninitialized); 250 DCHECK_NE(state_, kUninitialized);
251 DCHECK_NE(state_, kDecodeFinished); 251 DCHECK_NE(state_, kDecodeFinished);
252 DCHECK(!read_cb_.is_null()); 252 DCHECK(!read_cb_.is_null());
253 253
254 demuxer_stream_->Read(base::Bind(&FFmpegVideoDecoder::DecryptOrDecodeBuffer, 254 demuxer_stream_->Read(base::Bind(
255 this)); 255 &FFmpegVideoDecoder::DoDecryptOrDecodeBuffer, this));
256 }
257
258 void FFmpegVideoDecoder::DecryptOrDecodeBuffer(
259 DemuxerStream::Status status,
260 const scoped_refptr<DecoderBuffer>& buffer) {
261 DCHECK_EQ(status != DemuxerStream::kOk, !buffer) << status;
262 // TODO(scherkus): fix FFmpegDemuxerStream::Read() to not execute our read
263 // callback on the same execution stack so we can get rid of forced task post.
264 message_loop_->PostTask(FROM_HERE, base::Bind(
265 &FFmpegVideoDecoder::DoDecryptOrDecodeBuffer, this, status, buffer));
266 } 256 }
267 257
268 void FFmpegVideoDecoder::DoDecryptOrDecodeBuffer( 258 void FFmpegVideoDecoder::DoDecryptOrDecodeBuffer(
269 DemuxerStream::Status status, 259 DemuxerStream::Status status,
270 const scoped_refptr<DecoderBuffer>& buffer) { 260 const scoped_refptr<DecoderBuffer>& buffer) {
271 DCHECK(message_loop_->BelongsToCurrentThread()); 261 if (!message_loop_->BelongsToCurrentThread()) {
262 message_loop_->PostTask(FROM_HERE, base::Bind(
263 &FFmpegVideoDecoder::DoDecryptOrDecodeBuffer, this, status, buffer));
264 return;
265 }
266
272 DCHECK_NE(state_, kDecodeFinished); 267 DCHECK_NE(state_, kDecodeFinished);
268 DCHECK_EQ(status != DemuxerStream::kOk, !buffer) << status;
273 269
274 if (state_ == kUninitialized) 270 if (state_ == kUninitialized)
275 return; 271 return;
276 272
277 DCHECK(!read_cb_.is_null()); 273 DCHECK(!read_cb_.is_null());
278 274
279 if (!reset_cb_.is_null()) { 275 if (!reset_cb_.is_null()) {
280 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); 276 base::ResetAndReturn(&read_cb_).Run(kOk, NULL);
281 DoReset(); 277 DoReset();
282 return; 278 return;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) { 523 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) {
528 ReleaseFFmpegResources(); 524 ReleaseFFmpegResources();
529 return false; 525 return false;
530 } 526 }
531 527
532 av_frame_ = avcodec_alloc_frame(); 528 av_frame_ = avcodec_alloc_frame();
533 return true; 529 return true;
534 } 530 }
535 531
536 } // namespace media 532 } // 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