diff options
-rw-r--r-- | media/filters/ffmpeg_demuxer.cc | 11 | ||||
-rw-r--r-- | media/filters/ffmpeg_demuxer.h | 7 | ||||
-rw-r--r-- | media/filters/ffmpeg_demuxer_unittest.cc | 2 |
3 files changed, 18 insertions, 2 deletions
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc index 8347019..01a6681 100644 --- a/media/filters/ffmpeg_demuxer.cc +++ b/media/filters/ffmpeg_demuxer.cc @@ -264,7 +264,8 @@ FFmpegDemuxer::FFmpegDemuxer(MessageLoop* message_loop) last_read_bytes_(0), read_position_(0), max_duration_(base::TimeDelta::FromMicroseconds(-1)), - deferred_status_(PIPELINE_OK) { + deferred_status_(PIPELINE_OK), + first_seek_hack_(true) { DCHECK(message_loop_); } @@ -531,6 +532,14 @@ void FFmpegDemuxer::InitializeTask(DataSource* data_source, void FFmpegDemuxer::SeekTask(base::TimeDelta time, const FilterStatusCB& cb) { DCHECK_EQ(MessageLoop::current(), message_loop_); + // TODO(scherkus): remove this by separating Seek() from Flush() from + // Preroll() states (i.e., the implicit Seek(0) should really be a Preroll()). + if (first_seek_hack_) { + first_seek_hack_ = false; + callback->Run(); + return; + } + // Tell streams to flush buffers due to seeking. StreamVector::iterator iter; for (iter = streams_.begin(); iter != streams_.end(); ++iter) { diff --git a/media/filters/ffmpeg_demuxer.h b/media/filters/ffmpeg_demuxer.h index d96622c..a651ee3 100644 --- a/media/filters/ffmpeg_demuxer.h +++ b/media/filters/ffmpeg_demuxer.h @@ -161,6 +161,9 @@ class FFmpegDemuxer : public Demuxer, // Provide access to FFmpegDemuxerStream. MessageLoop* message_loop(); + // For testing purposes. + void disable_first_seek_hack_for_testing() { first_seek_hack_ = false; } + private: // Only allow a factory to create this class. friend class MockFFmpegDemuxer; @@ -246,6 +249,10 @@ class FFmpegDemuxer : public Demuxer, base::TimeDelta max_duration_; PipelineStatus deferred_status_; + // Used to skip the implicit "first seek" to avoid resetting FFmpeg's internal + // state. + bool first_seek_hack_; + DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); }; diff --git a/media/filters/ffmpeg_demuxer_unittest.cc b/media/filters/ffmpeg_demuxer_unittest.cc index 74ce0ed..1234297 100644 --- a/media/filters/ffmpeg_demuxer_unittest.cc +++ b/media/filters/ffmpeg_demuxer_unittest.cc @@ -66,7 +66,7 @@ class FFmpegDemuxerTest : public testing::Test { FFmpegDemuxerTest() { // Create an FFmpegDemuxer. demuxer_ = new FFmpegDemuxer(&message_loop_); - DCHECK(demuxer_); + demuxer_->disable_first_seek_hack_for_testing(); // Inject a filter host and message loop and prepare a data source. demuxer_->set_host(&host_); |