From c1bfe1acd468c83c61f538a0bb20f830b1617db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85hgren?= Date: Fri, 21 Sep 2018 16:23:50 +0200 Subject: [PATCH] Avoids creating empty call_order file when no call order data is written MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL avoids that unpack_aecdump produces an empty callorder.char file regardless of it not writing any data to that file Bug: webrtc:5298 Change-Id: I15b01764a0dc16045346dd680e9bd4c1869c0d2c Reviewed-on: https://webrtc-review.googlesource.com/c/98340 Reviewed-by: Oleh Prypin Reviewed-by: Sam Zackrisson Commit-Queue: Per Ã…hgren Cr-Commit-Position: refs/heads/master@{#25214} --- rtc_tools/unpack_aecdump/unpack.cc | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/rtc_tools/unpack_aecdump/unpack.cc b/rtc_tools/unpack_aecdump/unpack.cc index 4c75608e74..af8bf3187a 100644 --- a/rtc_tools/unpack_aecdump/unpack.cc +++ b/rtc_tools/unpack_aecdump/unpack.cc @@ -87,6 +87,10 @@ void WriteCallOrderData(const bool render_call, WriteData(&call_type, sizeof(call_type), file, filename.c_str()); } +bool WritingCallOrderFile() { + return FLAG_full; +} + } // namespace int do_main(int argc, char* argv[]) { @@ -125,7 +129,9 @@ int do_main(int argc, char* argv[]) { rtc::StringBuilder callorder_raw_name; callorder_raw_name << FLAG_callorder_file << ".char"; - FILE* callorder_char_file = OpenFile(callorder_raw_name.str(), "wb"); + FILE* callorder_char_file = WritingCallOrderFile() + ? OpenFile(callorder_raw_name.str(), "wb") + : nullptr; FILE* settings_file = OpenFile(FLAG_settings_file, "wb"); while (ReadMessageFromFile(debug_file, &event_msg)) { @@ -163,8 +169,10 @@ int do_main(int argc, char* argv[]) { reverse_raw_file.get()); } if (FLAG_full) { - WriteCallOrderData(true /* render_call */, callorder_char_file, - FLAG_callorder_file); + if (WritingCallOrderFile()) { + WriteCallOrderData(true /* render_call */, callorder_char_file, + FLAG_callorder_file); + } } } else if (event_msg.type() == Event::STREAM) { frame_count++; @@ -222,8 +230,10 @@ int do_main(int argc, char* argv[]) { } if (FLAG_full) { - WriteCallOrderData(false /* render_call */, callorder_char_file, - FLAG_callorder_file); + if (WritingCallOrderFile()) { + WriteCallOrderData(false /* render_call */, callorder_char_file, + FLAG_callorder_file); + } if (msg.has_delay()) { static FILE* delay_file = OpenFile(FLAG_delay_file, "wb"); int32_t delay = msg.delay(); @@ -359,9 +369,11 @@ int do_main(int argc, char* argv[]) { output_wav_file.reset(new WavWriter( output_name.str(), output_sample_rate, num_output_channels)); - rtc::StringBuilder callorder_name; - callorder_name << FLAG_callorder_file << frame_count << ".char"; - callorder_char_file = OpenFile(callorder_name.str(), "wb"); + if (WritingCallOrderFile()) { + rtc::StringBuilder callorder_name; + callorder_name << FLAG_callorder_file << frame_count << ".char"; + callorder_char_file = OpenFile(callorder_name.str(), "wb"); + } } } }