From: Vincent Palatin Date: Tue, 24 Oct 2017 12:00:29 +0000 (+0200) Subject: Force backup analog traces only if needed X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=f0de24ffe36fb3e983e347e607c522f32a963e25;p=sigrok-cli.git Force backup analog traces only if needed With the current conditions, when using the 'srzip' output module with device generating SR_DF_ANALOG packets, they are processed both by 'srzip' and the backup 'analog' module (as 'out' is always null for srzip which does its own file operation). For a moderately fast continuous analog capture (e.g. 2.4MSamples/s), the overhead of the 'analog' module is important (e.g. 80% of the whole processing of my workstation) while we are not using its output, so disable it when the user actually selected an output format/file but the module doesn't generate text output. Also remove the second part of the condition as 'opt_output_format' never seems to be null or at least not in the case where the user has omitted output parameters. Tested with a device generating analog packets both with '-o test.sr' and no output option. --- diff --git a/session.c b/session.c index 6b31ef5..5d92362 100644 --- a/session.c +++ b/session.c @@ -193,7 +193,9 @@ void datafeed_in(const struct sr_dev_inst *sdi, g_critical("Failed to initialize output module."); /* Set up backup analog output module. */ - oa = sr_output_new(sr_output_find("analog"), NULL, sdi, NULL); + if (outfile) + oa = sr_output_new(sr_output_find("analog"), NULL, + sdi, NULL); rcvd_samples_logic = rcvd_samples_analog = 0; @@ -311,9 +313,7 @@ void datafeed_in(const struct sr_dev_inst *sdi, if (o && !opt_pds) { if (sr_output_send(o, packet, &out) == SR_OK) { - if (!out || (out->len == 0 - && !opt_output_format - && packet->type == SR_DF_ANALOG)) { + if (oa && !out) { /* * The user didn't specify an output module, * but needs to see this analog data. @@ -340,7 +340,8 @@ void datafeed_in(const struct sr_dev_inst *sdi, sr_output_free(o); o = NULL; - sr_output_free(oa); + if (oa) + sr_output_free(oa); oa = NULL; if (outfile && outfile != stdout)