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

Unified Diff: webkit/media/crypto/ppapi/ffmpeg_cdm_audio_decoder.cc

Issue 12224114: Guard against midstream audio configuration changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
Index: webkit/media/crypto/ppapi/ffmpeg_cdm_audio_decoder.cc
diff --git a/webkit/media/crypto/ppapi/ffmpeg_cdm_audio_decoder.cc b/webkit/media/crypto/ppapi/ffmpeg_cdm_audio_decoder.cc
index e49fa2ba0b5a6c93b3d043aab93e8bb48958638d..248a33e3cc305b8d0aee7c8089bd811c5f367fc2 100644
--- a/webkit/media/crypto/ppapi/ffmpeg_cdm_audio_decoder.cc
+++ b/webkit/media/crypto/ppapi/ffmpeg_cdm_audio_decoder.cc
@@ -87,6 +87,8 @@ FFmpegCdmAudioDecoder::FFmpegCdmAudioDecoder(cdm::Allocator* allocator)
av_frame_(NULL),
bits_per_channel_(0),
samples_per_second_(0),
+ channels_(0),
+ av_sample_format_(0),
bytes_per_frame_(0),
last_input_timestamp_(media::kNoTimestamp()),
output_bytes_to_drop_(0) {
@@ -154,6 +156,10 @@ bool FFmpegCdmAudioDecoder::Initialize(const cdm::AudioDecoderConfig& config) {
serialized_audio_frames_.reserve(bytes_per_frame_ * samples_per_second_);
is_initialized_ = true;
+ // Store initial values to guard against mid-frame configuration changes.
scherkus (not reviewing) 2013/02/12 02:16:56 consistent terminology nit: s/mid-frame/mid-stream
DaleCurtis 2013/02/12 02:41:24 Done.
+ channels_ = codec_context_->channels;
+ av_sample_format_ = codec_context_->sample_fmt;
+
return true;
}
@@ -269,10 +275,16 @@ cdm::Status FFmpegCdmAudioDecoder::DecodeBuffer(
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 mid-frame configuration change!"
scherkus (not reviewing) 2013/02/12 02:16:56 consistent terminology nit: s/mid-frame/mid-stream
DaleCurtis 2013/02/12 02:41:24 Done.
+ << " 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_;
return cdm::kDecodeError;
}

Powered by Google App Engine
This is Rietveld 408576698