| Index: media/filters/audio_file_reader.cc
|
| diff --git a/media/filters/audio_file_reader.cc b/media/filters/audio_file_reader.cc
|
| index 58c4501b43f62b74d4a8021e64ab72708e4565a7..32627b04b10ad558bab4b4facc386da0a3c4552d 100644
|
| --- a/media/filters/audio_file_reader.cc
|
| +++ b/media/filters/audio_file_reader.cc
|
| @@ -15,21 +15,16 @@ namespace media {
|
| AudioFileReader::AudioFileReader(FFmpegURLProtocol* protocol)
|
| : codec_context_(NULL),
|
| stream_index_(0),
|
| - protocol_(protocol) {
|
| + protocol_(protocol),
|
| + channels_(0),
|
| + sample_rate_(0),
|
| + av_sample_format_(0) {
|
| }
|
|
|
| AudioFileReader::~AudioFileReader() {
|
| Close();
|
| }
|
|
|
| -int AudioFileReader::channels() const {
|
| - return codec_context_->channels;
|
| -}
|
| -
|
| -int AudioFileReader::sample_rate() const {
|
| - return codec_context_->sample_rate;
|
| -}
|
| -
|
| base::TimeDelta AudioFileReader::duration() const {
|
| const AVRational av_time_base = {1, AV_TIME_BASE};
|
|
|
| @@ -110,6 +105,11 @@ bool AudioFileReader::Open() {
|
| return false;
|
| }
|
|
|
| + // Store initial values to guard against midstream configuration changes.
|
| + channels_ = codec_context_->channels;
|
| + sample_rate_ = codec_context_->sample_rate;
|
| + av_sample_format_ = codec_context_->sample_fmt;
|
| +
|
| return true;
|
| }
|
|
|
| @@ -179,6 +179,22 @@ int AudioFileReader::Read(AudioBus* audio_bus) {
|
| break;
|
| }
|
|
|
| + if (av_frame->sample_rate != sample_rate_ ||
|
| + av_frame->channels != channels_ ||
|
| + av_frame->format != av_sample_format_) {
|
| + DLOG(ERROR) << "Unsupported midstream configuration change!"
|
| + << " Sample Rate: " << av_frame->sample_rate << " vs "
|
| + << sample_rate_
|
| + << ", Channels: " << av_frame->channels << " vs "
|
| + << channels_
|
| + << ", Sample Format: " << av_frame->format << " vs "
|
| + << av_sample_format_;
|
| +
|
| + // This is an unrecoverable error, so bail out.
|
| + continue_decoding = false;
|
| + break;
|
| + }
|
| +
|
| // Truncate, if necessary, if the destination isn't big enough.
|
| if (current_frame + frames_read > audio_bus->frames())
|
| frames_read = audio_bus->frames() - current_frame;
|
|
|