| 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
|
|
|