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

Unified Diff: media/filters/ffmpeg_video_decoder.cc

Issue 1456993004: media::FFmpegVideoDecoder: remove ctor param |task_runner| and use a ThreadChecker instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_video_decoder.cc
diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc
index 5c419f5ff218f77d3aef074c7f015885571632c1..04350fc094d7a0d3bd926edc4ff76ee79cc47185 100644
--- a/media/filters/ffmpeg_video_decoder.cc
+++ b/media/filters/ffmpeg_video_decoder.cc
@@ -72,10 +72,10 @@ bool FFmpegVideoDecoder::IsCodecSupported(VideoCodec codec) {
return avcodec_find_decoder(VideoCodecToCodecID(codec)) != nullptr;
}
-FFmpegVideoDecoder::FFmpegVideoDecoder(
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
- : task_runner_(task_runner), state_(kUninitialized),
- decode_nalus_(false) {}
+FFmpegVideoDecoder::FFmpegVideoDecoder()
+ : state_(kUninitialized), decode_nalus_(false) {
+ thread_checker_.DetachFromThread();
+}
int FFmpegVideoDecoder::GetVideoBuffer(struct AVCodecContext* codec_context,
AVFrame* frame,
@@ -168,7 +168,7 @@ void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config,
const SetCdmReadyCB& /* set_cdm_ready_cb */,
const InitCB& init_cb,
const OutputCB& output_cb) {
- DCHECK(task_runner_->BelongsToCurrentThread());
+ DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(config.IsValidConfig());
DCHECK(!output_cb.is_null());
@@ -198,7 +198,7 @@ void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config,
void FFmpegVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
const DecodeCB& decode_cb) {
- DCHECK(task_runner_->BelongsToCurrentThread());
+ DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(buffer.get());
DCHECK(!decode_cb.is_null());
CHECK_NE(state_, kUninitialized);
@@ -258,15 +258,16 @@ void FFmpegVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
}
void FFmpegVideoDecoder::Reset(const base::Closure& closure) {
- DCHECK(task_runner_->BelongsToCurrentThread());
+ DCHECK(thread_checker_.CalledOnValidThread());
avcodec_flush_buffers(codec_context_.get());
state_ = kNormal;
- task_runner_->PostTask(FROM_HERE, closure);
+ // PostTask() to avoid calling |closure| inmediately.
+ base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure);
}
FFmpegVideoDecoder::~FFmpegVideoDecoder() {
- DCHECK(task_runner_->BelongsToCurrentThread());
+ DCHECK(thread_checker_.CalledOnValidThread());
if (state_ != kUninitialized)
ReleaseFFmpegResources();
« 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