Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(891)

Side by Side Diff: webrtc/modules/utility/source/file_player_unittests.cc

Issue 1230503003: Update a ton of audio code to use size_t more correctly and in general reduce (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 void PlayFileAndCheck(const std::string& input_file, 55 void PlayFileAndCheck(const std::string& input_file,
56 const std::string& ref_checksum, 56 const std::string& ref_checksum,
57 int output_length_ms) { 57 int output_length_ms) {
58 const float kScaling = 1; 58 const float kScaling = 1;
59 ASSERT_EQ(0, 59 ASSERT_EQ(0,
60 player_->StartPlayingFile( 60 player_->StartPlayingFile(
61 input_file.c_str(), false, 0, kScaling, 0, 0, NULL)); 61 input_file.c_str(), false, 0, kScaling, 0, 0, NULL));
62 rtc::Md5Digest checksum; 62 rtc::Md5Digest checksum;
63 for (int i = 0; i < output_length_ms / 10; ++i) { 63 for (int i = 0; i < output_length_ms / 10; ++i) {
64 int16_t out[10 * kSampleRateHz / 1000] = {0}; 64 int16_t out[10 * kSampleRateHz / 1000] = {0};
65 int num_samples; 65 size_t num_samples;
66 EXPECT_EQ(0, 66 EXPECT_EQ(0,
67 player_->Get10msAudioFromFile(out, num_samples, kSampleRateHz)); 67 player_->Get10msAudioFromFile(out, num_samples, kSampleRateHz));
68 checksum.Update(out, num_samples * sizeof(out[0])); 68 checksum.Update(out, num_samples * sizeof(out[0]));
69 if (FLAGS_file_player_output) { 69 if (FLAGS_file_player_output) {
70 ASSERT_EQ(static_cast<size_t>(num_samples), 70 ASSERT_EQ(num_samples,
71 fwrite(out, sizeof(out[0]), num_samples, output_file_)); 71 fwrite(out, sizeof(out[0]), num_samples, output_file_));
72 } 72 }
73 } 73 }
74 char checksum_result[rtc::Md5Digest::kSize]; 74 char checksum_result[rtc::Md5Digest::kSize];
75 EXPECT_EQ(rtc::Md5Digest::kSize, 75 EXPECT_EQ(rtc::Md5Digest::kSize,
76 checksum.Finish(checksum_result, rtc::Md5Digest::kSize)); 76 checksum.Finish(checksum_result, rtc::Md5Digest::kSize));
77 EXPECT_EQ(ref_checksum, 77 EXPECT_EQ(ref_checksum,
78 rtc::hex_encode(checksum_result, sizeof(checksum_result))); 78 rtc::hex_encode(checksum_result, sizeof(checksum_result)));
79 } 79 }
80 80
(...skipping 17 matching lines...) Expand all
98 test::ResourcePath("utility/encapsulated_pcm16b_8khz", "wav"); 98 test::ResourcePath("utility/encapsulated_pcm16b_8khz", "wav");
99 // The file is longer than this, but keeping the output shorter limits the 99 // The file is longer than this, but keeping the output shorter limits the
100 // runtime for the test. 100 // runtime for the test.
101 const int kOutputLengthMs = 10000; 101 const int kOutputLengthMs = 10000;
102 const std::string kRefChecksum = "e41d7e1dac8aeae9f21e8e03cd7ecd71"; 102 const std::string kRefChecksum = "e41d7e1dac8aeae9f21e8e03cd7ecd71";
103 103
104 PlayFileAndCheck(kFileName, kRefChecksum, kOutputLengthMs); 104 PlayFileAndCheck(kFileName, kRefChecksum, kOutputLengthMs);
105 } 105 }
106 106
107 } // namespace webrtc 107 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/utility/source/file_player_impl.cc ('k') | webrtc/modules/utility/source/file_recorder_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698