X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Finput%2Fbinary.c;h=631d6d38c10d85d8fa620d354da60305873e9392;hb=08f023fe97e402d68106299d04726f9094f00c45;hp=223efd88089bd1fa78f2eeaec0f429cab01829ec;hpb=408b6ab42beb76a4854d5885b81ffcd8914dbf34;p=libsigrok.git diff --git a/src/input/binary.c b/src/input/binary.c index 223efd88..631d6d38 100644 --- a/src/input/binary.c +++ b/src/input/binary.c @@ -29,7 +29,7 @@ #define LOG_PREFIX "input/binary" -#define MAX_CHUNK_SIZE 4096 +#define CHUNK_SIZE (4 * 1024 * 1024) #define DEFAULT_NUM_CHANNELS 8 #define DEFAULT_SAMPLERATE 0 @@ -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; @@ -102,7 +95,9 @@ static int process_buffer(struct sr_input *in) for (i = 0; i < chunk_size; i += chunk) { logic.data = in->buf->str + i; - chunk = MIN(MAX_CHUNK_SIZE, chunk_size - i); + chunk = MIN(CHUNK_SIZE, chunk_size - i); + chunk /= logic.unitsize; + chunk *= logic.unitsize; logic.length = chunk; sr_session_send(in->sdi, &packet); } @@ -174,7 +169,7 @@ static const struct sr_option *get_options(void) SR_PRIV struct sr_input_module input_binary = { .id = "binary", .name = "Binary", - .desc = "Raw binary", + .desc = "Raw binary logic data", .exts = NULL, .options = get_options, .init = init,