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/webrtc@7600 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/common_audio/audio_converter.cc b/common_audio/audio_converter.cc
index 9e18033..f085ff1 100644
--- a/common_audio/audio_converter.cc
+++ b/common_audio/audio_converter.cc
@@ -43,10 +43,13 @@
} // 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 @@
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/common_audio/audio_converter.h b/common_audio/audio_converter.h
index df31755..6365f58 100644
--- a/common_audio/audio_converter.h
+++ b/common_audio/audio_converter.h
@@ -40,6 +40,10 @@
float* const* dest);
private:
+ const int src_channels_;
+ const int src_frames_;
+ const int dst_channels_;
+ const int dst_frames_;
scoped_ptr<ChannelBuffer<float>> downmix_buffer_;
ScopedVector<PushSincResampler> resamplers_;