1 /* 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_LOGGING_ 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_LOGGING_ 13 14 #include <stdio.h> 15 16 #include "webrtc/modules/audio_processing/logging/aec_logging_file_handling.h" 17 18 // To enable AEC logging, invoke GYP with -Daec_debug_dump=1. 19 #ifdef WEBRTC_AEC_DEBUG_DUMP 20 // Dumps a wav data to file. 21 #define RTC_AEC_DEBUG_WAV_WRITE(file, data, num_samples) \ 22 do { \ 23 rtc_WavWriteSamples(file, data, num_samples); \ 24 } while (0) 25 26 // (Re)opens a wav file for writing using the specified sample rate. 27 #define RTC_AEC_DEBUG_WAV_REOPEN(name, instance_index, process_rate, \ 28 sample_rate, wav_file) \ 29 do { \ 30 WebRtcAec_ReopenWav(name, instance_index, process_rate, sample_rate, \ 31 wav_file); \ 32 } while (0) 33 34 // Closes a wav file. 35 #define RTC_AEC_DEBUG_WAV_CLOSE(wav_file) \ 36 do { \ 37 rtc_WavClose(wav_file); \ 38 } while (0) 39 40 // Dumps a raw data to file. 41 #define RTC_AEC_DEBUG_RAW_WRITE(file, data, data_size) \ 42 do { \ 43 (void) fwrite(data, data_size, 1, file); \ 44 } while (0) 45 46 // Dumps a raw scalar int32 to file. 47 #define RTC_AEC_DEBUG_RAW_WRITE_SCALAR_INT32(file, data) \ 48 do { \ 49 int32_t value_to_store = data; \ 50 (void) fwrite(&value_to_store, sizeof(value_to_store), 1, file); \ 51 } while (0) 52 53 // Dumps a raw scalar double to file. 54 #define RTC_AEC_DEBUG_RAW_WRITE_SCALAR_DOUBLE(file, data) \ 55 do { \ 56 double value_to_store = data; \ 57 (void) fwrite(&value_to_store, sizeof(value_to_store), 1, file); \ 58 } while (0) 59 60 // Opens a raw data file for writing using the specified sample rate. 61 #define RTC_AEC_DEBUG_RAW_OPEN(name, instance_counter, file) \ 62 do { \ 63 WebRtcAec_RawFileOpen(name, instance_counter, file); \ 64 } while (0) 65 66 // Closes a raw data file. 67 #define RTC_AEC_DEBUG_RAW_CLOSE(file) \ 68 do { \ 69 fclose(file); \ 70 } while (0) 71 72 #else // RTC_AEC_DEBUG_DUMP 73 #define RTC_AEC_DEBUG_WAV_WRITE(file, data, num_samples) \ 74 do { \ 75 } while (0) 76 77 #define RTC_AEC_DEBUG_WAV_REOPEN(wav_file, name, instance_index, process_rate, \ 78 sample_rate) \ 79 do { \ 80 } while (0) 81 82 #define RTC_AEC_DEBUG_WAV_CLOSE(wav_file) \ 83 do { \ 84 } while (0) 85 86 #define RTC_AEC_DEBUG_RAW_WRITE(file, data, data_size) \ 87 do { \ 88 } while (0) 89 90 #define RTC_AEC_DEBUG_RAW_WRITE_SCALAR_INT32(file, data) \ 91 do { \ 92 } while (0) 93 94 #define RTC_AEC_DEBUG_RAW_WRITE_SCALAR_DOUBLE(file, data) \ 95 do { \ 96 } while (0) 97 98 #define RTC_AEC_DEBUG_RAW_OPEN(file, name, instance_counter) \ 99 do { \ 100 } while (0) 101 102 #define RTC_AEC_DEBUG_RAW_CLOSE(file) \ 103 do { \ 104 } while (0) 105 106 #endif // WEBRTC_AEC_DEBUG_DUMP 107 108 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_LOGGING_ 109