input/binary: Fix broken I/O loop.
This commit is contained in:
parent
013ec84b83
commit
88189019ac
|
@ -80,33 +80,33 @@ static int receive(const struct sr_input *in, GString *buf)
|
||||||
|
|
||||||
num_channels = g_slist_length(in->sdi->channels);
|
num_channels = g_slist_length(in->sdi->channels);
|
||||||
|
|
||||||
std_session_send_df_header(in->sdi, LOG_PREFIX);
|
if (!inc->started) {
|
||||||
inc->started = TRUE;
|
std_session_send_df_header(in->sdi, LOG_PREFIX);
|
||||||
|
inc->started = TRUE;
|
||||||
|
|
||||||
packet.type = SR_DF_META;
|
packet.type = SR_DF_META;
|
||||||
packet.payload = &meta;
|
packet.payload = &meta;
|
||||||
src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(inc->samplerate));
|
src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(inc->samplerate));
|
||||||
meta.config = g_slist_append(NULL, src);
|
meta.config = g_slist_append(NULL, src);
|
||||||
sr_session_send(in->sdi, &packet);
|
sr_session_send(in->sdi, &packet);
|
||||||
sr_config_free(src);
|
sr_config_free(src);
|
||||||
|
}
|
||||||
|
|
||||||
packet.type = SR_DF_LOGIC;
|
packet.type = SR_DF_LOGIC;
|
||||||
packet.payload = &logic;
|
packet.payload = &logic;
|
||||||
logic.unitsize = (num_channels + 7) / 8;
|
logic.unitsize = (num_channels + 7) / 8;
|
||||||
logic.data = in->buf->str;
|
|
||||||
|
|
||||||
/* 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;
|
||||||
|
|
||||||
chunk = 0;
|
chunk = 0;
|
||||||
for (i = 0; i < chunk_size; i += chunk) {
|
for (i = 0; i < chunk_size; i += chunk) {
|
||||||
chunk = MAX(MAX_CHUNK_SIZE, chunk_size - i);
|
logic.data = in->buf->str + i;
|
||||||
|
chunk = MIN(MAX_CHUNK_SIZE, chunk_size - i);
|
||||||
logic.length = chunk;
|
logic.length = chunk;
|
||||||
sr_session_send(in->sdi, &packet);
|
sr_session_send(in->sdi, &packet);
|
||||||
}
|
}
|
||||||
|
g_string_erase(in->buf, 0, chunk_size);
|
||||||
if (in->buf->len > chunk_size)
|
|
||||||
g_string_erase(in->buf, 0, in->buf->len - chunk_size);
|
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue