From: Antonio Ospite Date: Mon, 2 Oct 2017 09:51:54 +0000 (+0200) Subject: Make feed_data more robust X-Git-Url: https://git.ao2.it/gst-aseq-appsrc.git/commitdiff_plain/2dcd337c4aad9ce7a8a0b06e9243b3adb05ecb95 Make feed_data more robust Make the function either push a buffer or send EOS in every exit path, this prevents the pipeline from waiting for data which is not going to come. --- diff --git a/gst-aseq-appsrc.c b/gst-aseq-appsrc.c index 7c42ab4..4988dc2 100644 --- a/gst-aseq-appsrc.c +++ b/gst-aseq-appsrc.c @@ -222,14 +222,18 @@ feed_data (GstElement * appsrc, guint size, App * app) ret = poll (app->pfds, app->npfds, DEFAULT_POLL_TIMEOUT_MS); if (ret < 0) { GST_ERROR ("ERROR in poll: %s", strerror (errno)); + gst_app_src_end_of_stream (GST_APP_SRC (appsrc)); } else if (ret == 0) { push_tick_buffer (app); } else { do { snd_seq_event_t *event; err = snd_seq_event_input (app->seq, &event); - if (err < 0) + if (err < 0 && err != -EAGAIN) { + GST_ERROR ("Error in snd_seq_event_input: %s", snd_strerror (err)); + gst_app_src_end_of_stream (GST_APP_SRC (appsrc)); break; + } if (event) { size_ev = snd_midi_event_decode (app->parser, app->buffer, DEFAULT_BUFSIZE, @@ -242,6 +246,7 @@ feed_data (GstElement * appsrc, guint size, App * app) } else { GST_ERROR ("Error decoding event from ALSA to output: %s", strerror (-size_ev)); + gst_app_src_end_of_stream (GST_APP_SRC (appsrc)); break; } } else {