Avoids creating empty call_order file when no call order data is written

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 <oprypin@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25214}
This commit is contained in:
Per Åhgren
2018-09-21 16:23:50 +02:00
committed by Commit Bot
parent 6026f05ef1
commit c1bfe1acd4

View File

@ -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");
}
}
}
}