Skip to content
Snippets Groups Projects
Commit 918945fd authored by tanel's avatar tanel
Browse files

Guard against EOS when not yet decoding

parent 8a339089
No related branches found
No related tags found
No related merge requests found
...@@ -249,6 +249,7 @@ static void gst_kaldinnet2onlinedecoder_init( ...@@ -249,6 +249,7 @@ static void gst_kaldinnet2onlinedecoder_init(
// will be set later // will be set later
filter->feature_info = NULL; filter->feature_info = NULL;
filter->sample_rate = 0; filter->sample_rate = 0;
filter->decoding = false;
// init properties from various Kaldi Opts // init properties from various Kaldi Opts
GstElementClass * klass = GST_ELEMENT_GET_CLASS(filter); GstElementClass * klass = GST_ELEMENT_GET_CLASS(filter);
...@@ -603,6 +604,7 @@ static void gst_kaldinnet2onlinedecoder_loop( ...@@ -603,6 +604,7 @@ static void gst_kaldinnet2onlinedecoder_loop(
gst_pad_pause_task(filter->srcpad); gst_pad_pause_task(filter->srcpad);
delete filter->audio_source; delete filter->audio_source;
filter->audio_source = new GstBufferSource(); filter->audio_source = new GstBufferSource();
filter->decoding = false;
} }
/* GstElement vmethod implementations */ /* GstElement vmethod implementations */
...@@ -653,8 +655,8 @@ static gboolean gst_kaldinnet2onlinedecoder_sink_event(GstPad * pad, ...@@ -653,8 +655,8 @@ static gboolean gst_kaldinnet2onlinedecoder_sink_event(GstPad * pad,
switch (GST_EVENT_TYPE(event)) { switch (GST_EVENT_TYPE(event)) {
case GST_EVENT_SEGMENT: { case GST_EVENT_SEGMENT: {
GST_DEBUG_OBJECT(filter, "Starting decoding task"); GST_DEBUG_OBJECT(filter, "Starting decoding task");
filter->decoding = true;
gst_pad_start_task(filter->srcpad, gst_pad_start_task(filter->srcpad,
(GstTaskFunction) gst_kaldinnet2onlinedecoder_loop, (GstTaskFunction) gst_kaldinnet2onlinedecoder_loop,
filter, NULL); filter, NULL);
...@@ -670,7 +672,12 @@ static gboolean gst_kaldinnet2onlinedecoder_sink_event(GstPad * pad, ...@@ -670,7 +672,12 @@ static gboolean gst_kaldinnet2onlinedecoder_sink_event(GstPad * pad,
case GST_EVENT_EOS: { case GST_EVENT_EOS: {
/* end-of-stream, we should close down all stream leftovers here */ /* end-of-stream, we should close down all stream leftovers here */
GST_DEBUG_OBJECT(filter, "EOS received"); GST_DEBUG_OBJECT(filter, "EOS received");
filter->audio_source->SetEnded(true); if (filter->decoding) {
filter->audio_source->SetEnded(true);
} else {
GST_DEBUG_OBJECT(filter, "EOS received while not decoding, pushing EOS out");
gst_pad_push_event(filter->srcpad, gst_event_new_eos());
}
ret = TRUE; ret = TRUE;
break; break;
} }
......
...@@ -105,6 +105,7 @@ struct _Gstkaldinnet2onlinedecoder ...@@ -105,6 +105,7 @@ struct _Gstkaldinnet2onlinedecoder
fst::Fst<fst::StdArc> *decode_fst; fst::Fst<fst::StdArc> *decode_fst;
fst::SymbolTable *word_syms; fst::SymbolTable *word_syms;
int sample_rate; int sample_rate;
gboolean decoding;
}; };
struct _Gstkaldinnet2onlinedecoderClass struct _Gstkaldinnet2onlinedecoderClass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment