]> sigrok.org Git - libsigrok.git/commitdiff
input: use common support to send samplerate meta packet
authorGerhard Sittig <redacted>
Thu, 11 Jun 2020 15:19:01 +0000 (17:19 +0200)
committerGerhard Sittig <redacted>
Fri, 24 Jul 2020 18:15:40 +0000 (20:15 +0200)
src/input/binary.c
src/input/chronovu_la8.c
src/input/csv.c
src/input/logicport.c
src/input/raw_analog.c
src/input/trace32_ad.c
src/input/wav.c

index 51a64d099039c6ac859e3e6868f39c71e8ff0cbb..631d6d38c10d85d8fa620d354da60305873e9392 100644 (file)
@@ -69,9 +69,7 @@ static int init(struct sr_input *in, GHashTable *options)
 static int process_buffer(struct sr_input *in)
 {
        struct sr_datafeed_packet packet;
-       struct sr_datafeed_meta meta;
        struct sr_datafeed_logic logic;
-       struct sr_config *src;
        struct context *inc;
        gsize chunk_size, i;
        int chunk;
@@ -81,13 +79,8 @@ static int process_buffer(struct sr_input *in)
                std_session_send_df_header(in->sdi);
 
                if (inc->samplerate) {
-                       packet.type = SR_DF_META;
-                       packet.payload = &meta;
-                       src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(inc->samplerate));
-                       meta.config = g_slist_append(NULL, src);
-                       sr_session_send(in->sdi, &packet);
-                       g_slist_free(meta.config);
-                       sr_config_free(src);
+                       (void)sr_session_send_meta(in->sdi, SR_CONF_SAMPLERATE,
+                               g_variant_new_uint64(inc->samplerate));
                }
 
                inc->started = TRUE;
index e7b7f082015ebe3c99d9dca209ac74c3fd9b7a40..91d05b90427fc349eec28299f76ae901cee49f39 100644 (file)
@@ -130,9 +130,7 @@ static int init(struct sr_input *in, GHashTable *options)
 static int process_buffer(struct sr_input *in)
 {
        struct sr_datafeed_packet packet;
-       struct sr_datafeed_meta meta;
        struct sr_datafeed_logic logic;
-       struct sr_config *src;
        struct context *inc;
        gsize chunk_size, i;
        gsize chunk;
@@ -145,13 +143,8 @@ static int process_buffer(struct sr_input *in)
                std_session_send_df_header(in->sdi);
 
                if (inc->samplerate) {
-                       packet.type = SR_DF_META;
-                       packet.payload = &meta;
-                       src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(inc->samplerate));
-                       meta.config = g_slist_append(NULL, src);
-                       sr_session_send(in->sdi, &packet);
-                       g_slist_free(meta.config);
-                       sr_config_free(src);
+                       (void)sr_session_send_meta(in->sdi, SR_CONF_SAMPLERATE,
+                               g_variant_new_uint64(inc->samplerate));
                }
 
                inc->samples_remain = CHRONOVU_LA8_DATASIZE;
index 3a42fc9b1e6cfd1d479bb7f9de72643f862e759f..ca451bc4b33e540f29ebc88866dd0b4361271bbe 100644 (file)
@@ -277,21 +277,13 @@ struct context {
 static int flush_samplerate(const struct sr_input *in)
 {
        struct context *inc;
-       struct sr_datafeed_packet packet;
-       struct sr_datafeed_meta meta;
-       struct sr_config *src;
 
        inc = in->priv;
        if (!inc->calc_samplerate && inc->samplerate)
                inc->calc_samplerate = inc->samplerate;
        if (inc->calc_samplerate && !inc->samplerate_sent) {
-               packet.type = SR_DF_META;
-               packet.payload = &meta;
-               src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(inc->calc_samplerate));
-               meta.config = g_slist_append(NULL, src);
-               sr_session_send(in->sdi, &packet);
-               g_slist_free(meta.config);
-               sr_config_free(src);
+               (void)sr_session_send_meta(in->sdi, SR_CONF_SAMPLERATE,
+                       g_variant_new_uint64(inc->calc_samplerate));
                inc->samplerate_sent = TRUE;
        }
 
index e594b2cece049379eaed8d869af2ebb4fd3316c0..354330ab453e9f800d5926cc2df081a59906e3c2 100644 (file)
@@ -842,8 +842,6 @@ static int send_buffer(struct sr_input *in)
 {
        struct context *inc;
        struct sr_datafeed_packet packet;
-       struct sr_datafeed_meta meta;
-       struct sr_config *src;
        struct sr_datafeed_logic logic;
        int rc;
 
@@ -859,14 +857,8 @@ static int send_buffer(struct sr_input *in)
        }
 
        if (inc->sample_rate && !inc->rate_sent) {
-               packet.type = SR_DF_META;
-               packet.payload = &meta;
-               src = sr_config_new(SR_CONF_SAMPLERATE,
+               rc = sr_session_send_meta(in->sdi, SR_CONF_SAMPLERATE,
                        g_variant_new_uint64(inc->sample_rate));
-               meta.config = g_slist_append(NULL, src);
-               rc = sr_session_send(in->sdi, &packet);
-               g_slist_free(meta.config);
-               sr_config_free(src);
                if (rc)
                        return rc;
                inc->rate_sent = TRUE;
index 87bcaf1c4f39995ce9c0e7be2e29a9d5bb2fd060..1974dc92143ea7fa07f8f0716fc6dec278094cb6 100644 (file)
@@ -155,9 +155,6 @@ static int init(struct sr_input *in, GHashTable *options)
 static int process_buffer(struct sr_input *in)
 {
        struct context *inc;
-       struct sr_datafeed_meta meta;
-       struct sr_datafeed_packet packet;
-       struct sr_config *src;
        unsigned int offset, chunk_size;
 
        inc = in->priv;
@@ -165,13 +162,8 @@ static int process_buffer(struct sr_input *in)
                std_session_send_df_header(in->sdi);
 
                if (inc->samplerate) {
-                       packet.type = SR_DF_META;
-                       packet.payload = &meta;
-                       src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(inc->samplerate));
-                       meta.config = g_slist_append(NULL, src);
-                       sr_session_send(in->sdi, &packet);
-                       g_slist_free(meta.config);
-                       sr_config_free(src);
+                       (void)sr_session_send_meta(in->sdi, SR_CONF_SAMPLERATE,
+                               g_variant_new_uint64(inc->samplerate));
                }
 
                inc->started = TRUE;
index 46a15ca665589ded468a58bfb6b1777a855ff96a..3a4e1cd479996d91396ddc3d91a9c176f6ac53fd 100644 (file)
@@ -407,21 +407,11 @@ static void create_channels(struct sr_input *in)
 
 static void send_metadata(struct sr_input *in)
 {
-       struct sr_datafeed_packet packet;
-       struct sr_datafeed_meta meta;
-       struct sr_config *src;
        struct context *inc;
 
        inc = in->priv;
-
-       packet.type = SR_DF_META;
-       packet.payload = &meta;
-       src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(inc->samplerate));
-       meta.config = g_slist_append(NULL, src);
-       sr_session_send(in->sdi, &packet);
-       g_slist_free(meta.config);
-       sr_config_free(src);
-
+       (void)sr_session_send_meta(in->sdi, SR_CONF_SAMPLERATE,
+               g_variant_new_uint64(inc->samplerate));
        inc->meta_sent = TRUE;
 }
 
index b6d55888bf54d3499f4d694ae061f80235ab94a6..a6369f4d4bd60778035e3d4597a22c45334bb774 100644 (file)
@@ -253,24 +253,14 @@ static void send_chunk(const struct sr_input *in, int offset, int num_samples)
 static int process_buffer(struct sr_input *in)
 {
        struct context *inc;
-       struct sr_datafeed_packet packet;
-       struct sr_datafeed_meta meta;
-       struct sr_config *src;
        int offset, chunk_samples, total_samples, processed, max_chunk_samples;
        int num_samples, i;
 
        inc = in->priv;
        if (!inc->started) {
                std_session_send_df_header(in->sdi);
-
-               packet.type = SR_DF_META;
-               packet.payload = &meta;
-               src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(inc->samplerate));
-               meta.config = g_slist_append(NULL, src);
-               sr_session_send(in->sdi, &packet);
-               g_slist_free(meta.config);
-               sr_config_free(src);
-
+               (void)sr_session_send_meta(in->sdi, SR_CONF_SAMPLERATE,
+                       g_variant_new_uint64(inc->samplerate));
                inc->started = TRUE;
        }