Index: media/filters/ffmpeg_audio_decoder.cc |
diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc |
index 58f3dcd064a2abbfe0c5056d0d7f99f7e780dfab..d77ae56b1d779120b7d9c09ee82c3f94ce48f151 100644 |
--- a/media/filters/ffmpeg_audio_decoder.cc |
+++ b/media/filters/ffmpeg_audio_decoder.cc |
@@ -5,6 +5,7 @@ |
#include "media/filters/ffmpeg_audio_decoder.h" |
#include "base/bind.h" |
+#include "base/callback_helpers.h" |
#include "media/base/audio_decoder_config.h" |
#include "media/base/data_buffer.h" |
#include "media/base/decoder_buffer.h" |
@@ -165,13 +166,17 @@ void FFmpegAudioDecoder::DoRead(const ReadCB& read_cb) { |
} |
void FFmpegAudioDecoder::DoDecodeBuffer( |
+ DemuxerStream::Status status, |
const scoped_refptr<DecoderBuffer>& input) { |
DCHECK_EQ(MessageLoop::current(), message_loop_); |
DCHECK(!read_cb_.is_null()); |
- if (!input) { |
- // DemuxeStream::Read() was aborted so we abort the decoder's pending read. |
- DeliverSamples(NULL); |
+ if (status != DemuxerStream::kOk) { |
Ami GONE FROM CHROMIUM
2012/06/26 00:33:21
DCHECK(!input) ?
acolwell GONE FROM CHROMIUM
2012/07/12 01:19:38
Done.
|
+ // TODO(acolwell): Add support for reinitializing the decoder when |
+ // |status| == kConfigChanged. For now we just trigger a decode error. |
+ AudioDecoder::Status decoder_status = |
+ (status == DemuxerStream::kAborted) ? kAborted : kDecodeError; |
+ base::ResetAndReturn(&read_cb_).Run(decoder_status, NULL); |
return; |
} |
@@ -245,7 +250,7 @@ void FFmpegAudioDecoder::DoDecodeBuffer( |
// Decoding finished successfully, update stats and execute callback. |
statistics_cb_.Run(statistics); |
if (output) { |
- DeliverSamples(output); |
+ base::ResetAndReturn(&read_cb_).Run(kOk, output); |
} else { |
ReadFromDemuxerStream(); |
} |
@@ -258,11 +263,14 @@ void FFmpegAudioDecoder::ReadFromDemuxerStream() { |
} |
void FFmpegAudioDecoder::DecodeBuffer( |
+ DemuxerStream::Status status, |
const scoped_refptr<DecoderBuffer>& buffer) { |
+ DCHECK_EQ(status != DemuxerStream::kOk, !buffer); |
+ |
// TODO(scherkus): fix FFmpegDemuxerStream::Read() to not execute our read |
// callback on the same execution stack so we can get rid of forced task post. |
message_loop_->PostTask(FROM_HERE, base::Bind( |
- &FFmpegAudioDecoder::DoDecodeBuffer, this, buffer)); |
+ &FFmpegAudioDecoder::DoDecodeBuffer, this, status, buffer)); |
} |
void FFmpegAudioDecoder::UpdateDurationAndTimestamp( |
@@ -295,11 +303,4 @@ base::TimeDelta FFmpegAudioDecoder::CalculateDuration(int size) { |
return base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)); |
} |
-void FFmpegAudioDecoder::DeliverSamples(const scoped_refptr<Buffer>& samples) { |
- // Reset the callback before running to protect against reentrancy. |
- ReadCB read_cb = read_cb_; |
- read_cb_.Reset(); |
- read_cb.Run(samples); |
-} |
- |
} // namespace media |