input/wav: initialize channel list before going into ready state

The sr_input_dev_inst_get API documentation guarantees an input is fully
initialized as soon as the device instance is returned. An sdi
implementation should not set sdi_ready any earlier.

This fixes parts of bug #387.
This commit is contained in:
Stefan Brüns 2015-11-28 16:52:08 +01:00 committed by Uwe Hermann
parent 7cccc9155c
commit 74c9a8d2bd
1 changed files with 6 additions and 6 deletions

View File

@ -242,15 +242,9 @@ static int process_buffer(struct sr_input *in)
struct sr_config *src;
int offset, chunk_samples, total_samples, processed, max_chunk_samples;
int num_samples, i;
char channelname[8];
inc = in->priv;
if (!inc->started) {
for (i = 0; i < inc->num_channels; i++) {
snprintf(channelname, 8, "CH%d", i + 1);
sr_channel_new(in->sdi, i, SR_CHANNEL_ANALOG, TRUE, channelname);
}
std_session_send_df_header(in->sdi, LOG_PREFIX);
packet.type = SR_DF_META;
@ -310,6 +304,7 @@ static int receive(struct sr_input *in, GString *buf)
{
struct context *inc;
int ret;
char channelname[8];
g_string_append_len(in->buf, buf->str, buf->len);
@ -329,6 +324,11 @@ static int receive(struct sr_input *in, GString *buf)
else if (ret != SR_OK)
return ret;
for (int i = 0; i < inc->num_channels; i++) {
snprintf(channelname, 8, "CH%d", i + 1);
sr_channel_new(in->sdi, i, SR_CHANNEL_ANALOG, TRUE, channelname);
}
/* sdi is ready, notify frontend. */
in->sdi_ready = TRUE;
return SR_OK;