summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-19 20:49:10 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-19 20:49:10 +0000
commitc468131fc71d1f3c3c393f8449a8cc55091843c7 (patch)
tree812afd32aa3d9d12b8877935abc79d1961796523
parent4d9c859fb328dbabd2c5fff5ac643f85cebee107 (diff)
downloadchromium_src-c468131fc71d1f3c3c393f8449a8cc55091843c7.zip
chromium_src-c468131fc71d1f3c3c393f8449a8cc55091843c7.tar.gz
chromium_src-c468131fc71d1f3c3c393f8449a8cc55091843c7.tar.bz2
Introduce a quick and dirty hack to skip the implicit first seek for FFmpegDemuxer.
The real fix is to split Seek() into explicit Seek() and Preroll() actions as Seek() can have unintended consequences (i.e., resetting internal FFmpeg state). BUG=40344,80187 TEST=media_unittests Review URL: http://codereview.chromium.org/6894044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85965 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--media/filters/ffmpeg_demuxer.cc11
-rw-r--r--media/filters/ffmpeg_demuxer.h7
-rw-r--r--media/filters/ffmpeg_demuxer_unittest.cc2
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_);