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

Unified Diff: webrtc/modules/audio_processing/logging/aec_logging_file_handling.c

Issue 1272403003: Replaced the wav file dumping functionality in aec_core.c with the newly added corresponding macros (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added support for inclusion from C++ code 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/logging/aec_logging_file_handling.c
diff --git a/webrtc/modules/audio_processing/logging/aec_logging_file_handling.c b/webrtc/modules/audio_processing/logging/aec_logging_file_handling.c
new file mode 100644
index 0000000000000000000000000000000000000000..c562d128ffea9abebcafc70db2c422215432d041
--- /dev/null
+++ b/webrtc/modules/audio_processing/logging/aec_logging_file_handling.c
@@ -0,0 +1,62 @@
+/*
kwiberg-webrtc 2015/08/10 20:19:57 Why is this a C and not a C++ file? If it was C++,
peah-webrtc 2015/08/12 20:25:52 Do you mean I should rename it to aec_logging_file
kwiberg-webrtc 2015/08/13 07:59:34 Yes.
peah-webrtc 2015/08/13 13:37:40 Done.
+ * 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.
+ */
+
+
+#ifdef WEBRTC_AEC_DEBUG_DUMP
the sun 2015/08/11 08:48:26 The includes don't need to be within conditionals
peah-webrtc 2015/08/12 20:25:52 Done.
+#include <assert.h>
+#include <stdio.h>
+#include <stdint.h>
Andrew MacDonald 2015/08/10 15:25:55 nit: blank line after this. stdint.h before stdio
peah-webrtc 2015/08/12 20:25:52 Done.
+#include "webrtc/common_audio/wav_file.h"
+#include "webrtc/typedefs.h"
+#include "aec_logging_file_handling.h"
Andrew MacDonald 2015/08/10 15:25:55 Full path.
peah-webrtc 2015/08/12 20:25:53 Done.
+#endif
+
+// To enable AEC logging, run this command from trunk/ :
+// python webrtc/build/gyp_webrtc -Daec_debug_dump=1
+#ifdef WEBRTC_AEC_DEBUG_DUMP
kwiberg-webrtc 2015/08/10 20:19:57 Lines 19 and 23 cancel each other out. (In other w
peah-webrtc 2015/08/12 20:25:53 Thanks! I removed the first #ifdef pair, so it is
peah-webrtc 2015/08/12 20:25:53 Done.
+// Open a new Wav file for writing. If it was already open with a different
+// sample frequency, close it first.
Andrew MacDonald 2015/08/10 15:25:55 Move this documentation to the header. In particul
peah-webrtc 2015/08/12 20:25:52 Done.
+void WebRtcAec_ReopenWav(rtc_WavWriter** wav_file,
+ const char* const name,
the sun 2015/08/11 08:48:26 No need to make the pointer const, just the stuff
peah-webrtc 2015/08/12 20:25:52 Done.
+ const int seq1,
+ const int seq2,
Andrew MacDonald 2015/08/10 15:25:55 Better names than seq1, seq2. It's not clear what
peah-webrtc 2015/08/12 20:25:52 Fully agree on that! This was the original code th
peah-webrtc 2015/08/12 20:25:52 Done.
+ const int sample_rate) {
Andrew MacDonald 2015/08/10 15:25:55 Drop const from by-value parameters.
peah-webrtc 2015/08/12 20:25:52 Done.
+ 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, seq1, seq2);
+ assert(written >= 0); // no output error
+ assert((size_t)written < sizeof(filename)); // buffer was large enough
Andrew MacDonald 2015/08/10 15:25:55 Capitals and periods (and below).
peah-webrtc 2015/08/12 20:25:52 I'm not sure what you refer to. Could you please b
hlundin-webrtc 2015/08/13 06:19:02 He refers to the somewhat picky style rule saying
kwiberg-webrtc 2015/08/13 07:59:34 This is probably the part of our coding style that
peah-webrtc 2015/08/13 13:37:40 Done.
peah-webrtc 2015/08/13 13:37:40 Acknowledged.
peah-webrtc 2015/08/13 13:37:40 Done.
+ *wav_file = rtc_WavOpen(filename, sample_rate, 1);
+}
+
+
+// Open a new file for writing, named with a instance specific
+// suffix
Andrew MacDonald 2015/08/10 15:25:55 Move this to the header.
peah-webrtc 2015/08/12 20:25:53 Done.
+void WebRtcAec_RawFileOpen(FILE** file,
+ const char * const name,
+ const int16_t instanceCtr) {
Andrew MacDonald 2015/08/10 15:25:55 Drop const and instance_counter
peah-webrtc 2015/08/12 20:25:53 Done.
+int written ATTRIBUTE_UNUSED;
Andrew MacDonald 2015/08/10 15:25:55 Indent.
peah-webrtc 2015/08/12 20:25:53 Done.
+ char filename[64];
+
+ written = sprintf(filename, "%s_%d.dat", name, instanceCtr);
+ assert(written >= 0); // no output error
+ assert((size_t)written < sizeof(filename)); // buffer was large enough
the sun 2015/08/11 08:48:26 We should never knowingly introduce buffer overrun
peah-webrtc 2015/08/12 20:25:53 As far as I can see, the functions in stringutils.
the sun 2015/08/24 11:04:46 The implementation is C++ now, correct? Can you us
peah-webrtc 2015/08/25 05:05:28 Done.
+
+ *file = fopen(filename, "wb");
+}
+
+
+#endif // WEBRTC_AEC_DEBUG_DUMP

Powered by Google App Engine
This is Rietveld 408576698