summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-19 23:33:27 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-19 23:33:27 +0000
commit0c150b5688948d0f7f1be33a16f57d58c910100d (patch)
tree8352bfc4e2f9945f498b2b1c40cd714c8db0ffff
parenta619d8895892b0793f906482f07429ef91e79e4d (diff)
downloadchromium_src-0c150b5688948d0f7f1be33a16f57d58c910100d.zip
chromium_src-0c150b5688948d0f7f1be33a16f57d58c910100d.tar.gz
chromium_src-0c150b5688948d0f7f1be33a16f57d58c910100d.tar.bz2
Introduce a quick and dirty hack to skip the implicit first seek for FFmpegDemuxer (again).
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@86008 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..6ff0302 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;
+ cb.Run(PIPELINE_OK);
+ 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_);