Support arbitrary input/output rates and downmixing in AudioProcessing.

Select "processing" rates based on the input and output sampling rates.
Resample the input streams to those rates, and if necessary to the
output rate.

- Remove deprecated stream format APIs.
- Remove deprecated device sample rate APIs.
- Add a ChannelBuffer class to help manage deinterleaved channels.
- Clean up the splitting filter state.
- Add a unit test which verifies the output against known-working
native format output.

BUG=2894
R=aluebs@webrtc.org, bjornv@webrtc.org, xians@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/9919004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5959 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_processing/test/test_utils.h b/webrtc/modules/audio_processing/test/test_utils.h
index c55b53e..e5204da 100644
--- a/webrtc/modules/audio_processing/test/test_utils.h
+++ b/webrtc/modules/audio_processing/test/test_utils.h
@@ -9,6 +9,7 @@
  */
 
 #include "webrtc/audio_processing/debug.pb.h"
+#include "webrtc/modules/audio_processing/common.h"
 #include "webrtc/modules/audio_processing/include/audio_processing.h"
 #include "webrtc/modules/interface/module_common_types.h"
 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
@@ -18,37 +19,6 @@
 static const AudioProcessing::Error kNoErr = AudioProcessing::kNoError;
 #define EXPECT_NOERR(expr) EXPECT_EQ(kNoErr, (expr))
 
-static const int kChunkSizeMs = 10;
-
-// Helper to encapsulate a contiguous data buffer with access to a pointer
-// array of the deinterleaved channels.
-template <typename T>
-class ChannelBuffer {
- public:
-  ChannelBuffer(int samples_per_channel, int num_channels)
-      : data_(new T[samples_per_channel * num_channels]),
-        channels_(new T*[num_channels]),
-        samples_per_channel_(samples_per_channel) {
-    memset(data_.get(), 0, sizeof(T) * samples_per_channel * num_channels);
-    for (int i = 0; i < num_channels; ++i)
-      channels_[i] = &data_[i * samples_per_channel];
-  }
-  ~ChannelBuffer() {}
-
-  void CopyFrom(const void* channel_ptr, int index) {
-    memcpy(channels_[index], channel_ptr, samples_per_channel_ * sizeof(T));
-  }
-
-  T* data() { return data_.get(); }
-  T* channel(int index) { return channels_[index]; }
-  T** channels() { return channels_.get(); }
-
- private:
-  scoped_ptr<T[]> data_;
-  scoped_ptr<T*[]> channels_;
-  int samples_per_channel_;
-};
-
 // Exits on failure; do not use in unit tests.
 static inline FILE* OpenFile(const std::string& filename, const char* mode) {
   FILE* file = fopen(filename.c_str(), mode);
@@ -59,10 +29,15 @@
   return file;
 }
 
+static inline int SamplesFromRate(int rate) {
+  return AudioProcessing::kChunkSizeMs * rate / 1000;
+}
+
 static inline void SetFrameSampleRate(AudioFrame* frame,
                                       int sample_rate_hz) {
   frame->sample_rate_hz_ = sample_rate_hz;
-  frame->samples_per_channel_ = kChunkSizeMs * sample_rate_hz / 1000;
+  frame->samples_per_channel_ = AudioProcessing::kChunkSizeMs *
+      sample_rate_hz / 1000;
 }
 
 template <typename T>