| Index: webrtc/modules/audio_processing/test/test_utils.cc
|
| diff --git a/webrtc/modules/audio_processing/test/test_utils.cc b/webrtc/modules/audio_processing/test/test_utils.cc
|
| index 1b9ac3ce4cb8b40c3bf852c9579386618c058005..47bcc71f1069c14035ed2dd55030d7972093519c 100644
|
| --- a/webrtc/modules/audio_processing/test/test_utils.cc
|
| +++ b/webrtc/modules/audio_processing/test/test_utils.cc
|
| @@ -31,6 +31,17 @@ void RawFile::WriteSamples(const float* samples, size_t num_samples) {
|
| fwrite(samples, sizeof(*samples), num_samples, file_handle_);
|
| }
|
|
|
| +ChannelBufferWavWriter::ChannelBufferWavWriter(rtc::scoped_ptr<WavWriter> file)
|
| + : file_(file.Pass()) {}
|
| +
|
| +void ChannelBufferWavWriter::Write(const ChannelBuffer<float>& buffer) {
|
| + interleaved_.resize(buffer.size());
|
| + Interleave(buffer.channels(), buffer.num_frames(), buffer.num_channels(),
|
| + &interleaved_[0]);
|
| + FloatToFloatS16(&interleaved_[0], interleaved_.size(), &interleaved_[0]);
|
| + file_->WriteSamples(&interleaved_[0], interleaved_.size());
|
| +}
|
| +
|
| void WriteIntData(const int16_t* data,
|
| size_t length,
|
| WavWriter* wav_file,
|
| @@ -97,23 +108,27 @@ AudioProcessing::ChannelLayout LayoutFromChannels(int num_channels) {
|
| }
|
| }
|
|
|
| -std::vector<Point> ParseArrayGeometry(const std::string& mic_positions,
|
| - size_t num_mics) {
|
| +std::vector<Point> ParseArrayGeometry(const std::string& mic_positions) {
|
| const std::vector<float> values = ParseList<float>(mic_positions);
|
| - RTC_CHECK_EQ(values.size(), 3 * num_mics)
|
| - << "Could not parse mic_positions or incorrect number of points.";
|
| + const size_t num_mics =
|
| + rtc::CheckedDivExact(values.size(), static_cast<size_t>(3));
|
| + RTC_CHECK_GT(num_mics, 0u);
|
|
|
| std::vector<Point> result;
|
| result.reserve(num_mics);
|
| for (size_t i = 0; i < values.size(); i += 3) {
|
| - double x = values[i + 0];
|
| - double y = values[i + 1];
|
| - double z = values[i + 2];
|
| - result.push_back(Point(x, y, z));
|
| + result.push_back(Point(values[i + 0], values[i + 1], values[i + 2]));
|
| }
|
|
|
| return result;
|
| }
|
|
|
| +std::vector<Point> ParseArrayGeometry(const std::string& mic_positions,
|
| + size_t num_mics) {
|
| + std::vector<Point> result = ParseArrayGeometry(mic_positions);
|
| + RTC_CHECK_EQ(result.size(), num_mics)
|
| + << "Could not parse mic_positions or incorrect number of points.";
|
| + return result;
|
| +}
|
|
|
| } // namespace webrtc
|
|
|