C++ readability review for ajm.

As part of the review, refactored AudioConverter into internal derived
classes, each focused on one type of conversion. A factory method
returns the correct converter (or chain of converters, via
CompositionConverter).

BUG=b/18938079
R=rojer@google.com

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@8322 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/common_audio/resampler/push_sinc_resampler.cc b/common_audio/resampler/push_sinc_resampler.cc
index 49e2e12..7d37202 100644
--- a/common_audio/resampler/push_sinc_resampler.cc
+++ b/common_audio/resampler/push_sinc_resampler.cc
@@ -8,21 +8,21 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/common_audio/include/audio_util.h"
-
-#include <assert.h>
-#include <string.h>
-
 #include "webrtc/common_audio/resampler/push_sinc_resampler.h"
 
+#include <cstring>
+
+#include "webrtc/base/checks.h"
+#include "webrtc/common_audio/include/audio_util.h"
+
 namespace webrtc {
 
 PushSincResampler::PushSincResampler(int source_frames, int destination_frames)
     : resampler_(new SincResampler(source_frames * 1.0 / destination_frames,
                                    source_frames,
                                    this)),
-      source_ptr_(NULL),
-      source_ptr_int_(NULL),
+      source_ptr_(nullptr),
+      source_ptr_int_(nullptr),
       destination_frames_(destination_frames),
       first_pass_(true),
       source_available_(0) {}
@@ -38,10 +38,10 @@
     float_buffer_.reset(new float[destination_frames_]);
 
   source_ptr_int_ = source;
-  // Pass NULL as the float source to have Run() read from the int16 source.
-  Resample(NULL, source_length, float_buffer_.get(), destination_frames_);
+  // Pass nullptr as the float source to have Run() read from the int16 source.
+  Resample(nullptr, source_length, float_buffer_.get(), destination_frames_);
   FloatS16ToS16(float_buffer_.get(), destination_frames_, destination);
-  source_ptr_int_ = NULL;
+  source_ptr_int_ = nullptr;
   return destination_frames_;
 }
 
@@ -49,8 +49,8 @@
                                 int source_length,
                                 float* destination,
                                 int destination_capacity) {
-  assert(source_length == resampler_->request_frames());
-  assert(destination_capacity >= destination_frames_);
+  CHECK_EQ(source_length, resampler_->request_frames());
+  CHECK_GE(destination_capacity, destination_frames_);
   // Cache the source pointer. Calling Resample() will immediately trigger
   // the Run() callback whereupon we provide the cached value.
   source_ptr_ = source;
@@ -73,25 +73,25 @@
     resampler_->Resample(resampler_->ChunkSize(), destination);
 
   resampler_->Resample(destination_frames_, destination);
-  source_ptr_ = NULL;
+  source_ptr_ = nullptr;
   return destination_frames_;
 }
 
 void PushSincResampler::Run(int frames, float* destination) {
   // Ensure we are only asked for the available samples. This would fail if
   // Run() was triggered more than once per Resample() call.
-  assert(source_available_ == frames);
+  CHECK_EQ(source_available_, frames);
 
   if (first_pass_) {
     // Provide dummy input on the first pass, the output of which will be
     // discarded, as described in Resample().
-    memset(destination, 0, frames * sizeof(float));
+    std::memset(destination, 0, frames * sizeof(*destination));
     first_pass_ = false;
     return;
   }
 
   if (source_ptr_) {
-    memcpy(destination, source_ptr_, frames * sizeof(float));
+    std::memcpy(destination, source_ptr_, frames * sizeof(*destination));
   } else {
     for (int i = 0; i < frames; ++i)
       destination[i] = static_cast<float>(source_ptr_int_[i]);