Index: media/filters/ffmpeg_demuxer.cc |
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc |
index 56981e4710f59e92d4139c7421d9860bbf6e9546..b3cdc700b471fd99370d1f8360cd6c7eb7719dbd 100644 |
--- a/media/filters/ffmpeg_demuxer.cc |
+++ b/media/filters/ffmpeg_demuxer.cc |
@@ -52,6 +52,15 @@ class AVPacketBuffer : public Buffer { |
}; |
+// Helper class that is always at end of stream. Used to signal the demuxer |
+// that a stream has seen Stop(). |
+class EndOfStreamBuffer : public Buffer { |
acolwell GONE FROM CHROMIUM
2011/10/07 15:50:47
It feels like this should go in media/base somewhe
Ami GONE FROM CHROMIUM
2011/10/07 16:44:47
As soon as there's another customer, I'm happy for
acolwell GONE FROM CHROMIUM
2011/10/07 16:56:59
ChunkDemuxer could be that customer. It currently
Ami GONE FROM CHROMIUM
2011/10/07 17:11:10
Doing the latter (mimicking).
|
+ public: |
+ virtual const uint8* GetData() const { return NULL; } |
+ virtual size_t GetDataSize() const { return 0; } |
+}; |
+ |
+ |
// |
// FFmpegDemuxerStream |
// |
@@ -139,6 +148,10 @@ void FFmpegDemuxerStream::Stop() { |
DCHECK_EQ(MessageLoop::current(), demuxer_->message_loop()); |
base::AutoLock auto_lock(lock_); |
buffer_queue_.clear(); |
+ for (ReadQueue::iterator it = read_queue_.begin(); |
+ it != read_queue_.end(); ++it) { |
+ it->Run(new EndOfStreamBuffer()); |
+ } |
read_queue_.clear(); |
stopped_ = true; |
} |
@@ -289,13 +302,13 @@ FFmpegDemuxer::~FFmpegDemuxer() { |
void FFmpegDemuxer::PostDemuxTask() { |
message_loop_->PostTask(FROM_HERE, |
- base::Bind(&FFmpegDemuxer::DemuxTask, this)); |
+ base::Bind(&FFmpegDemuxer::DemuxTask, this)); |
} |
void FFmpegDemuxer::Stop(const base::Closure& callback) { |
// Post a task to notify the streams to stop as well. |
message_loop_->PostTask(FROM_HERE, |
- base::Bind(&FFmpegDemuxer::StopTask, this, callback)); |
+ base::Bind(&FFmpegDemuxer::StopTask, this, callback)); |
// Then wakes up the thread from reading. |
SignalReadCompleted(DataSource::kReadError); |
@@ -303,7 +316,7 @@ void FFmpegDemuxer::Stop(const base::Closure& callback) { |
void FFmpegDemuxer::Seek(base::TimeDelta time, const FilterStatusCB& cb) { |
message_loop_->PostTask(FROM_HERE, |
- base::Bind(&FFmpegDemuxer::SeekTask, this, time, cb)); |
+ base::Bind(&FFmpegDemuxer::SeekTask, this, time, cb)); |
} |
void FFmpegDemuxer::SetPlaybackRate(float playback_rate) { |
@@ -317,8 +330,8 @@ void FFmpegDemuxer::SetPreload(Preload preload) { |
} |
void FFmpegDemuxer::OnAudioRendererDisabled() { |
- message_loop_->PostTask(FROM_HERE, |
- base::Bind(&FFmpegDemuxer::DisableAudioStreamTask, this)); |
+ message_loop_->PostTask(FROM_HERE, base::Bind( |
+ &FFmpegDemuxer::DisableAudioStreamTask, this)); |
} |
void FFmpegDemuxer::set_host(FilterHost* filter_host) { |
@@ -473,7 +486,7 @@ void FFmpegDemuxer::InitializeTask(DataSource* data_source, |
AVStream* stream = format_context_->streams[i]; |
// WebM is currently strictly VP8 and Vorbis. |
if (kDemuxerIsWebm && (stream->codec->codec_id != CODEC_ID_VP8 && |
- stream->codec->codec_id != CODEC_ID_VORBIS)) { |
+ stream->codec->codec_id != CODEC_ID_VORBIS)) { |
packet_streams_.push_back(NULL); |
continue; |
} |
@@ -487,7 +500,7 @@ void FFmpegDemuxer::InitializeTask(DataSource* data_source, |
if (stream->first_dts != static_cast<int64_t>(AV_NOPTS_VALUE)) { |
const base::TimeDelta first_dts = ConvertFromTimeBase( |
- stream->time_base, stream->first_dts); |
+ stream->time_base, stream->first_dts); |
if (start_time_ == kNoTimestamp || first_dts < start_time_) |
start_time_ = first_dts; |
} |