input/binary: Only calculate unitsize once.
This commit is contained in:
parent
867293a101
commit
408b6ab42b
|
@ -36,6 +36,7 @@
|
||||||
struct context {
|
struct context {
|
||||||
gboolean started;
|
gboolean started;
|
||||||
uint64_t samplerate;
|
uint64_t samplerate;
|
||||||
|
uint16_t unitsize;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int init(struct sr_input *in, GHashTable *options)
|
static int init(struct sr_input *in, GHashTable *options)
|
||||||
|
@ -60,6 +61,8 @@ static int init(struct sr_input *in, GHashTable *options)
|
||||||
sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
|
sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inc->unitsize = (g_slist_length(in->sdi->channels) + 7) / 8;
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +95,7 @@ static int process_buffer(struct sr_input *in)
|
||||||
|
|
||||||
packet.type = SR_DF_LOGIC;
|
packet.type = SR_DF_LOGIC;
|
||||||
packet.payload = &logic;
|
packet.payload = &logic;
|
||||||
logic.unitsize = (g_slist_length(in->sdi->channels) + 7) / 8;
|
logic.unitsize = inc->unitsize;
|
||||||
|
|
||||||
/* Cut off at multiple of unitsize. */
|
/* Cut off at multiple of unitsize. */
|
||||||
chunk_size = in->buf->len / logic.unitsize * logic.unitsize;
|
chunk_size = in->buf->len / logic.unitsize * logic.unitsize;
|
||||||
|
|
Loading…
Reference in New Issue