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

Unified Diff: media/filters/ffmpeg_video_decoder.cc

Issue 9667018: Make FFmpegVideoDecoder defer a flush until the pending read completes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix rebase build buster Created 8 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 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 f5eb500fa74d449c54f4fc417d553e7deb44ac37..3d382648e9598c1a755b26eed53df515359a7e6c 100644
--- a/media/filters/ffmpeg_video_decoder.cc
+++ b/media/filters/ffmpeg_video_decoder.cc
@@ -163,9 +163,22 @@ void FFmpegVideoDecoder::Flush(const base::Closure& callback) {
return;
}
+ flush_cb_ = callback;
+
+ // Defer the flush if a read is pending.
+ if (!read_cb_.is_null())
+ return;
+
+ DoFlush();
+}
+
+void FFmpegVideoDecoder::DoFlush() {
+ DCHECK(read_cb_.is_null());
+
avcodec_flush_buffers(codec_context_);
state_ = kNormal;
- callback.Run();
+ flush_cb_.Run();
+ flush_cb_.Reset();
}
void FFmpegVideoDecoder::Read(const ReadCB& read_cb) {
@@ -226,6 +239,12 @@ void FFmpegVideoDecoder::DoDecodeBuffer(const scoped_refptr<Buffer>& buffer) {
return;
}
+ if (!flush_cb_.is_null()) {
+ DeliverFrame(NULL);
+ DoFlush();
+ return;
+ }
+
// During decode, because reads are issued asynchronously, it is possible to
// receive multiple end of stream buffers since each read is acked. When the
// first end of stream buffer is read, FFmpeg may still have frames queued
« 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