From 69110b5cbe99a54937f108d239592e5afb55d008 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Sat, 25 Jul 2020 09:25:51 +0200 Subject: [PATCH] decode: start collecting internal state (samplerate) Introduce variables which hold the internal state during decoder operation so far. Start by adding a "samplerate used by protocol decoders". This is motivated by the pending Google Trace Event feature addition. --- decode.c | 2 ++ session.c | 2 ++ sigrok-cli.h | 1 + 3 files changed, 5 insertions(+) diff --git a/decode.c b/decode.c index 0bf1d25..d277039 100644 --- a/decode.c +++ b/decode.c @@ -29,6 +29,8 @@ static GHashTable *pd_meta_visible = NULL; static GHashTable *pd_binary_visible = NULL; static GHashTable *pd_channel_maps = NULL; +uint64_t pd_samplerate = 0; + extern struct srd_session *srd_sess; static int opts_to_gvar(struct srd_decoder *dec, GHashTable *hash, diff --git a/session.c b/session.c index f154235..e8ec5a2 100644 --- a/session.c +++ b/session.c @@ -324,6 +324,7 @@ void datafeed_in(const struct sr_dev_inst *sdi, g_critical("Failed to configure decode session."); break; } + pd_samplerate = samplerate; } if (srd_session_start(srd_sess) != SRD_OK) { g_critical("Failed to start decode session."); @@ -352,6 +353,7 @@ void datafeed_in(const struct sr_dev_inst *sdi, g_variant_new_uint64(samplerate)) != SRD_OK) { g_critical("Failed to pass samplerate to decoder."); } + pd_samplerate = samplerate; } #endif break; diff --git a/sigrok-cli.h b/sigrok-cli.h index 8d26699..10e74de 100644 --- a/sigrok-cli.h +++ b/sigrok-cli.h @@ -87,6 +87,7 @@ int setup_binary_stdout(void); /* decode.c */ #ifdef HAVE_SRD +extern uint64_t pd_samplerate; int register_pds(gchar **all_pds, char *opt_pd_annotations); int setup_pd_annotations(char *opt_pd_annotations); int setup_pd_meta(char *opt_pd_meta); -- 2.11.4.GIT