Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1334)

Unified Diff: media/filters/ffmpeg_demuxer.cc

Issue 8890071: Stop audio FFmpegDemuxerStreams if we get notified that audio rendering is disabled. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: one more time Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/filters/ffmpeg_demuxer.cc
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index c1a056cdbb8f2dc4cc86b43b183725e6ee859547..620b9ab75939d6e28949b7f45c5e02ed7d6b1c29 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -153,6 +153,10 @@ base::TimeDelta FFmpegDemuxerStream::duration() {
return duration_;
}
+int FFmpegDemuxerStream::stream_index() {
+ return stream_->index;
+}
+
DemuxerStream::Type FFmpegDemuxerStream::type() {
return type_;
}
@@ -490,6 +494,7 @@ void FFmpegDemuxer::InitializeTask(DataSource* data_source,
AVStream* stream = format_context_->streams[i];
scoped_refptr<FFmpegDemuxerStream> demuxer_stream(
new FFmpegDemuxerStream(this, stream));
+
if (!streams_[demuxer_stream->type()]) {
no_supported_streams = false;
streams_[demuxer_stream->type()] = demuxer_stream;
@@ -502,9 +507,6 @@ void FFmpegDemuxer::InitializeTask(DataSource* data_source,
start_time_ = first_dts;
}
}
- packet_streams_.push_back(demuxer_stream);
- } else {
- packet_streams_.push_back(NULL);
}
}
if (no_supported_streams) {
@@ -641,18 +643,10 @@ void FFmpegDemuxer::DemuxTask() {
// TODO(scherkus): should we post this back to the pipeline thread? I'm
// worried about downstream filters (i.e., decoders) executing on this
// thread.
- DCHECK_GE(packet->stream_index, 0);
- DCHECK_LT(packet->stream_index, static_cast<int>(packet_streams_.size()));
- FFmpegDemuxerStream* demuxer_stream = NULL;
- size_t i = packet->stream_index;
- // Defend against ffmpeg giving us a bad stream index.
- if (i < packet_streams_.size()) {
- demuxer_stream = packet_streams_[i];
- }
- if (demuxer_stream) {
- // Queue the packet with the appropriate stream. The stream takes
- // ownership of the AVPacket.
- if (packet.get()) {
+ for (StreamVector::iterator iter = streams_.begin();
acolwell GONE FROM CHROMIUM 2011/12/13 16:45:44 I don't feel good about this iteration happening o
scherkus (not reviewing) 2011/12/13 17:24:56 This loop unrolls to checking streams_[AUDIO]->str
+ iter != streams_.end();
+ ++iter) {
+ if ((*iter) && (*iter)->stream_index() == packet->stream_index) {
// If a packet is returned by FFmpeg's av_parser_parse2()
// the packet will reference an inner memory of FFmpeg.
// In this case, the packet's "destruct" member is NULL,
@@ -660,7 +654,11 @@ void FFmpegDemuxer::DemuxTask() {
// other codecs. It is safe to call this function even if the packet does
// not refer to inner memory from FFmpeg.
av_dup_packet(packet.get());
- demuxer_stream->EnqueuePacket(packet.release());
+
+ // Queue the packet with the appropriate stream. The stream takes
+ // ownership of the AVPacket.
+ (*iter)->EnqueuePacket(packet.release());
+ break;
}
}
@@ -688,17 +686,8 @@ void FFmpegDemuxer::StopTask(const base::Closure& callback) {
void FFmpegDemuxer::DisableAudioStreamTask() {
DCHECK_EQ(MessageLoop::current(), message_loop_);
- StreamVector::iterator iter;
- for (size_t i = 0; i < packet_streams_.size(); ++i) {
- if (!packet_streams_[i])
- continue;
-
- // If the codec type is audio, remove the reference. DemuxTask() will
- // look for such reference, and this will result in deleting the
- // audio packets after they are demuxed.
- if (packet_streams_[i]->type() == DemuxerStream::AUDIO) {
- packet_streams_[i] = NULL;
- }
+ if (streams_[DemuxerStream::AUDIO]) {
+ streams_[DemuxerStream::AUDIO]->Stop();
}
}

Powered by Google App Engine
This is Rietveld 408576698