- if (inc->started) {
- /* End of stream. */
- packet.type = SR_DF_END;
- sr_session_send(in->sdi, &packet);
+ if (!in->sdi_ready) {
+ if ((ret = parse_wav_header(in->buf, inc)) == SR_ERR_NA)
+ /* Not enough data yet. */
+ return SR_OK;
+ 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;