summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandrew@webrtc.org <andrew@webrtc.org>2014-11-03 21:32:14 +0000
committerandrew@webrtc.org <andrew@webrtc.org>2014-11-03 21:32:14 +0000
commitdeb9e492c3db34f9580f6799ac7fdd5bb72e3d1e (patch)
tree15de4a0d7149f7f516dd6ad32e681d0a7c79ca43
parentafcd610633482a99c5c11ddee9ca8b7c3fd66943 (diff)
downloadwebrtc-deb9e492c3db34f9580f6799ac7fdd5bb72e3d1e.tar.gz
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
-rw-r--r--common_audio/audio_converter.cc16
-rw-r--r--common_audio/audio_converter.h4
2 files changed, 15 insertions, 5 deletions
diff --git a/common_audio/audio_converter.cc b/common_audio/audio_converter.cc
index 9e18033f..f085ff13 100644
--- a/common_audio/audio_converter.cc
+++ b/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/common_audio/audio_converter.h b/common_audio/audio_converter.h
index df31755e..6365f587 100644
--- a/common_audio/audio_converter.h
+++ b/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<ChannelBuffer<float>> downmix_buffer_;
ScopedVector<PushSincResampler> resamplers_;