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

Unified Diff: media/filters/ffmpeg_audio_decoder.cc

Issue 12224114: Guard against midstream audio configuration changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Created 7 years, 10 months 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
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.h ('k') | media/filters/pipeline_integration_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_audio_decoder.cc
diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc
index be142d515c253a2dce3b8b6cca14e76b7e8d38cc..618006394c334fd6d3a8e0bd62f69aaf4ac2ab6a 100644
--- a/media/filters/ffmpeg_audio_decoder.cc
+++ b/media/filters/ffmpeg_audio_decoder.cc
@@ -43,7 +43,9 @@ FFmpegAudioDecoder::FFmpegAudioDecoder(
codec_context_(NULL),
bits_per_channel_(0),
channel_layout_(CHANNEL_LAYOUT_NONE),
+ channels_(0),
samples_per_second_(0),
+ av_sample_format_(0),
bytes_per_frame_(0),
last_input_timestamp_(kNoTimestamp()),
output_bytes_to_drop_(0),
@@ -303,6 +305,11 @@ bool FFmpegAudioDecoder::ConfigureDecoder() {
output_timestamp_helper_.reset(new AudioTimestampHelper(
config.bytes_per_frame(), config.samples_per_second()));
bytes_per_frame_ = config.bytes_per_frame();
+
+ // Store initial values to guard against midstream configuration changes.
+ channels_ = codec_context_->channels;
+ av_sample_format_ = codec_context_->sample_fmt;
+
return true;
}
@@ -387,10 +394,16 @@ void FFmpegAudioDecoder::RunDecodeLoop(
int decoded_audio_size = 0;
if (frame_decoded) {
- int output_sample_rate = av_frame_->sample_rate;
- if (output_sample_rate != samples_per_second_) {
- DLOG(ERROR) << "Output sample rate (" << output_sample_rate
- << ") doesn't match expected rate " << samples_per_second_;
+ if (av_frame_->sample_rate != samples_per_second_ ||
+ av_frame_->channels != channels_ ||
+ av_frame_->format != av_sample_format_) {
+ DLOG(ERROR) << "Unsupported midstream configuration change!"
+ << " Sample Rate: " << av_frame_->sample_rate << " vs "
+ << samples_per_second_
+ << ", Channels: " << av_frame_->channels << " vs "
+ << channels_
+ << ", Sample Format: " << av_frame_->format << " vs "
+ << av_sample_format_;
// This is an unrecoverable error, so bail out.
QueuedAudioBuffer queue_entry = { kDecodeError, NULL };
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.h ('k') | media/filters/pipeline_integration_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698