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..0a195448e2dc1c3a22d10ed9de648388f77d6df5 |
--- /dev/null |
+++ b/webrtc/modules/audio_processing/logging/aec_logging_file_handling.cc |
@@ -0,0 +1,60 @@ |
+/* |
+ * 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 <assert.h> |
+#include <stdint.h> |
+#include <stdio.h> |
+ |
+#include "webrtc/common_audio/wav_file.h" |
+#include "webrtc/typedefs.h" |
+#include "webrtc/modules/audio_processing/logging/aec_logging_file_handling.h" |
Andrew MacDonald
2015/08/17 16:37:05
nit: style guide likes the associated header to be
peah-webrtc
2015/08/25 05:05:28
Done.
|
+ |
+#ifdef WEBRTC_AEC_DEBUG_DUMP |
+extern "C" void WebRtcAec_ReopenWav(const char* name, |
+ int instance_index, |
+ int process_rate, |
+ int sample_rate, |
+ rtc_WavWriter** wav_file) { |
+ int written ATTRIBUTE_UNUSED; |
+ char filename[64]; |
+ if (*wav_file) { |
+ if (rtc_WavSampleRate(*wav_file) == sample_rate) |
+ return; |
+ rtc_WavClose(*wav_file); |
+ } |
+ written = snprintf(filename, sizeof(filename), "%s%d-%d.wav", name, |
+ instance_index, process_rate); |
+ |
+ // Ensrure there was no buffer output error. |
+ assert(written >= 0); |
Andrew MacDonald
2015/08/17 16:37:05
Since this is C++ now, you could use DCHECKs inste
the sun
2015/08/24 11:04:46
+1
peah-webrtc
2015/08/25 05:05:28
Done.
|
+ // Ensure that the buffer size was sufficient. |
+ assert((size_t)written < sizeof(filename)); |
+ |
+ *wav_file = rtc_WavOpen(filename, sample_rate, 1); |
+} |
+ |
+extern "C" void WebRtcAec_RawFileOpen(const char* name, |
+ int instance_counter, |
+ FILE** file) { |
+ int written ATTRIBUTE_UNUSED; |
+ char filename[64]; |
+ |
+ written = |
+ snprintf(filename, sizeof(filename), "%s_%d.dat", name, instance_counter); |
+ |
+ // Ensrure there was no buffer output error. |
+ assert(written >= 0); |
+ // Ensure that the buffer size was sufficient. |
+ assert((size_t)written < sizeof(filename)); |
+ |
+ *file = fopen(filename, "wb"); |
+} |
+ |
+#endif // WEBRTC_AEC_DEBUG_DUMP |