Index: webrtc/modules/audio_processing/logging/aec_logging_file_handling.cc |
diff --git a/webrtc/modules/audio_processing/logging/aec_logging_file_handling.cc b/webrtc/modules/audio_processing/logging/aec_logging_file_handling.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f0d9ce84b725e0166db45f00ad298382aa48ca4c |
--- /dev/null |
+++ b/webrtc/modules/audio_processing/logging/aec_logging_file_handling.cc |
@@ -0,0 +1,63 @@ |
+/* |
+ * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#include "webrtc/modules/audio_processing/logging/aec_logging_file_handling.h" |
+ |
+#include <stdint.h> |
+#include <stdio.h> |
+ |
+#include "webrtc/base/basicdefs.h" |
+#include "webrtc/base/checks.h" |
+#include "webrtc/base/stringutils.h" |
+#include "webrtc/common_audio/wav_file.h" |
+#include "webrtc/typedefs.h" |
+ |
+#ifdef WEBRTC_AEC_DEBUG_DUMP |
+extern "C" void WebRtcAec_ReopenWav(const char* name, |
kwiberg-webrtc
2015/08/25 09:04:43
You only need the 'extern "C"' in the declaration,
Andrew MacDonald
2015/08/25 17:16:29
Ah, interesting. I think we have this pattern else
peah-webrtc
2015/08/26 07:24:24
Done.
peah-webrtc
2015/08/26 07:24:25
Acknowledged.
peah-webrtc
2015/08/26 07:24:25
Done.
|
+ int instance_index, |
+ int process_rate, |
+ int sample_rate, |
+ rtc_WavWriter** wav_file) { |
+ int written ATTRIBUTE_UNUSED; |
+ char filename[64]; |
kwiberg-webrtc
2015/08/25 09:04:43
Move declarations as far down as possible now that
peah-webrtc
2015/08/26 07:24:25
Done.
|
+ if (*wav_file) { |
+ if (rtc_WavSampleRate(*wav_file) == sample_rate) |
+ return; |
+ rtc_WavClose(*wav_file); |
+ } |
+ written = rtc::sprintfn(filename, ARRAY_SIZE(filename), "%s%d-%d.wav", name, |
Andrew MacDonald
2015/08/25 17:16:29
sprintfn calls for a number of bytes in the second
peah-webrtc
2015/08/26 07:24:24
Done.
|
+ instance_index, process_rate); |
kwiberg-webrtc
2015/08/25 09:04:43
You appear to need to run clang-format.
peah-webrtc
2015/08/26 07:24:24
Done.
|
+ |
+ // Ensure there was no buffer output error. |
+ DCHECK(written >= 0); |
kwiberg-webrtc
2015/08/25 09:04:43
DCHECK_GE
peah-webrtc
2015/08/26 07:24:24
Done.
|
+ // Ensure that the buffer size was sufficient. |
+ DCHECK(static_cast<size_t>(written) < sizeof(filename)); |
kwiberg-webrtc
2015/08/25 09:04:43
DCHECK_LT
peah-webrtc
2015/08/26 07:24:24
Done.
|
+ |
+ *wav_file = rtc_WavOpen(filename, sample_rate, 1); |
+} |
+ |
+extern "C" void WebRtcAec_RawFileOpen(const char* name, |
+ int instance_counter, |
the sun
2015/08/25 08:32:35
Is there a difference between instance_index (as u
peah-webrtc
2015/08/26 07:24:25
Done.
peah-webrtc
2015/08/26 07:24:25
Good point. No, there is not :-). I'll choose the
|
+ FILE** file) { |
+ int written ATTRIBUTE_UNUSED; |
kwiberg-webrtc
2015/08/25 09:04:43
You shouldn't need the ATTRIBUTE_UNUSED. (DCHECK i
peah-webrtc
2015/08/26 07:24:25
Done.
|
+ char filename[64]; |
+ |
+ written = rtc::sprintfn(filename, ARRAY_SIZE(filename), "%s_%d.dat", name, |
+ instance_counter); |
+ |
+ // Ensure there was no buffer output error. |
+ DCHECK(written >= 0); |
+ // Ensure that the buffer size was sufficient. |
+ DCHECK(static_cast<size_t>(written) < sizeof(filename)); |
+ |
+ *file = fopen(filename, "wb"); |
+} |
+ |
+#endif // WEBRTC_AEC_DEBUG_DUMP |