From 58049360522e2132e5247ddf7cdd4b818d016a45 Mon Sep 17 00:00:00 2001 From: "andrew@webrtc.org" Date: Mon, 3 Nov 2014 21:32:14 +0000 Subject: [PATCH] Add format members to AudioConverter for DCHECKing. And use a std::min. Post-commit fixes after: https://review.webrtc.org/30779004/ TBR=kwiberg Review URL: https://webrtc-codereview.appspot.com/25059004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7600 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/common_audio/audio_converter.cc | 16 +++++++++++----- webrtc/common_audio/audio_converter.h | 4 ++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/webrtc/common_audio/audio_converter.cc b/webrtc/common_audio/audio_converter.cc index 9e18033fc4..f085ff13d1 100644 --- a/webrtc/common_audio/audio_converter.cc +++ b/webrtc/common_audio/audio_converter.cc @@ -43,10 +43,13 @@ void UpmixFromMono(const float* src, } // namespace AudioConverter::AudioConverter(int src_channels, int src_frames, - int dst_channels, int dst_frames) { + int dst_channels, int dst_frames) + : src_channels_(src_channels), + src_frames_(src_frames), + dst_channels_(dst_channels), + dst_frames_(dst_frames) { CHECK(dst_channels == src_channels || dst_channels == 1 || src_channels == 1); - const int resample_channels = src_channels < dst_channels ? src_channels : - dst_channels; + const int resample_channels = std::min(src_channels, dst_channels); // Prepare buffers as needed for intermediate stages. if (dst_channels < src_channels) @@ -66,8 +69,11 @@ void AudioConverter::Convert(const float* const* src, int dst_channels, int dst_frames, float* const* dst) { - DCHECK(dst_channels == src_channels || dst_channels == 1 || - src_channels == 1); + DCHECK_EQ(src_channels_, src_channels); + DCHECK_EQ(src_frames_, src_frames); + DCHECK_EQ(dst_channels_, dst_channels); + DCHECK_EQ(dst_frames_, dst_frames);; + if (src_channels == dst_channels && src_frames == dst_frames) { // Shortcut copy. if (src != dst) { diff --git a/webrtc/common_audio/audio_converter.h b/webrtc/common_audio/audio_converter.h index df31755eef..6365f58799 100644 --- a/webrtc/common_audio/audio_converter.h +++ b/webrtc/common_audio/audio_converter.h @@ -40,6 +40,10 @@ class AudioConverter { float* const* dest); private: + const int src_channels_; + const int src_frames_; + const int dst_channels_; + const int dst_frames_; scoped_ptr> downmix_buffer_; ScopedVector resamplers_;