OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 size_t file_samples_read = ReadInt16FromFileToFloatBuffer( | 75 size_t file_samples_read = ReadInt16FromFileToFloatBuffer( |
76 pcm_file.get(), | 76 pcm_file.get(), |
77 audio_buffer_length, | 77 audio_buffer_length, |
78 audio_buffer.get()); | 78 audio_buffer.get()); |
79 for (int time = 0; file_samples_read > 0; time += chunk_size_ms) { | 79 for (int time = 0; file_samples_read > 0; time += chunk_size_ms) { |
80 // Pad the rest of the buffer with zeros. | 80 // Pad the rest of the buffer with zeros. |
81 for (size_t i = file_samples_read; i < audio_buffer_length; ++i) { | 81 for (size_t i = file_samples_read; i < audio_buffer_length; ++i) { |
82 audio_buffer[i] = 0.0; | 82 audio_buffer[i] = 0.0; |
83 } | 83 } |
84 float value = | 84 float value = |
85 detector.Detect(audio_buffer.get(), audio_buffer_length, NULL, 0); | 85 detector.Detect(audio_buffer.get(), audio_buffer_length, nullptr, 0); |
86 if (value < 0.5f) { | 86 if (value < 0.5f) { |
87 value = time; | 87 value = time; |
88 } else { | 88 } else { |
89 value = FLT_MAX; | 89 value = FLT_MAX; |
90 ++lost_packets; | 90 ++lost_packets; |
91 } | 91 } |
92 send_times.push_back(value); | 92 send_times.push_back(value); |
93 | 93 |
94 // Read next buffer from the PCM test file. | 94 // Read next buffer from the PCM test file. |
95 file_samples_read = ReadInt16FromFileToFloatBuffer(pcm_file.get(), | 95 file_samples_read = ReadInt16FromFileToFloatBuffer(pcm_file.get(), |
96 audio_buffer_length, | 96 audio_buffer_length, |
97 audio_buffer.get()); | 97 audio_buffer.get()); |
98 } | 98 } |
99 | 99 |
100 size_t floats_written = WriteFloatBufferToFile(dat_file.get(), | 100 size_t floats_written = WriteFloatBufferToFile(dat_file.get(), |
101 send_times.size(), | 101 send_times.size(), |
102 &send_times[0]); | 102 &send_times[0]); |
103 | 103 |
104 if (floats_written == 0) { | 104 if (floats_written == 0) { |
105 printf("\nThe send times could not be written to DAT file\n\n"); | 105 printf("\nThe send times could not be written to DAT file\n\n"); |
106 return -1; | 106 return -1; |
107 } | 107 } |
108 | 108 |
109 pcm_file->CloseFile(); | 109 pcm_file->CloseFile(); |
110 dat_file->CloseFile(); | 110 dat_file->CloseFile(); |
111 | 111 |
112 return lost_packets; | 112 return lost_packets; |
113 } | 113 } |
OLD | NEW |