input/vcd: Send END packet on cleanup.

This commit is contained in:
Bert Vermeulen 2014-08-19 16:49:18 +02:00
parent 41d214f61a
commit c10ef17c23
1 changed files with 9 additions and 7 deletions

View File

@ -70,6 +70,7 @@
#define CHUNKSIZE 1024 #define CHUNKSIZE 1024
struct context { struct context {
gboolean started;
gboolean got_header; gboolean got_header;
uint64_t samplerate; uint64_t samplerate;
unsigned int maxchannels; unsigned int maxchannels;
@ -467,13 +468,6 @@ static int receive(const struct sr_input *in, GString *buf)
uint64_t samplerate; uint64_t samplerate;
char *p; char *p;
if (buf->len == 0) {
/* End of stream. */
packet.type = SR_DF_END;
sr_session_send(in->sdi, &packet);
return SR_OK;
}
g_string_append_len(in->buf, buf->str, buf->len); g_string_append_len(in->buf, buf->str, buf->len);
inc = in->priv; inc = in->priv;
@ -485,6 +479,7 @@ static int receive(const struct sr_input *in, GString *buf)
return SR_ERR; return SR_ERR;
std_session_send_df_header(in->sdi, LOG_PREFIX); 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;
@ -508,9 +503,16 @@ static int receive(const struct sr_input *in, GString *buf)
static int cleanup(struct sr_input *in) static int cleanup(struct sr_input *in)
{ {
struct sr_datafeed_packet packet;
struct context *inc; struct context *inc;
inc = in->priv; inc = in->priv;
if (inc->started) {
/* End of stream. */
packet.type = SR_DF_END;
sr_session_send(in->sdi, &packet);
}
g_slist_free_full(inc->channels, free_channel); g_slist_free_full(inc->channels, free_channel);
g_free(inc); g_free(inc);
in->priv = NULL; in->priv = NULL;