From 01db5dbff0aa8d2a60c9b2de585831a205b19508 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 30 Apr 2012 11:00:19 +0200 Subject: [PATCH] interleave: handle EOS on all pads When all pads go to EOS immediately, we are not negotiated and our collected function is called (without any available data). Handle this case gracefully. Conflicts: gst/interleave/interleave.c --- gst/interleave/interleave.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gst/interleave/interleave.c b/gst/interleave/interleave.c index 703f69a..8174b1a 100644 --- a/gst/interleave/interleave.c +++ b/gst/interleave/interleave.c @@ -1177,7 +1177,7 @@ static GstFlowReturn gst_interleave_collected (GstCollectPads * pads, GstInterleave * self) { guint size; - GstBuffer *outbuf; + GstBuffer *outbuf = NULL; GstFlowReturn ret = GST_FLOW_OK; GSList *collected; guint nsamples; @@ -1186,13 +1186,15 @@ gst_interleave_collected (GstCollectPads * pads, GstInterleave * self) gint width = self->width / 8; GstMapInfo write_info; + size = gst_collect_pads_available (pads); + if (size == 0) + goto eos; + g_return_val_if_fail (self->func != NULL, GST_FLOW_NOT_NEGOTIATED); g_return_val_if_fail (self->width > 0, GST_FLOW_NOT_NEGOTIATED); g_return_val_if_fail (self->channels > 0, GST_FLOW_NOT_NEGOTIATED); g_return_val_if_fail (self->rate > 0, GST_FLOW_NOT_NEGOTIATED); - size = gst_collect_pads_available (pads); - g_return_val_if_fail (size % width == 0, GST_FLOW_ERROR); GST_DEBUG_OBJECT (self, "Starting to collect %u bytes from %d channels", size, @@ -1281,7 +1283,8 @@ gst_interleave_collected (GstCollectPads * pads, GstInterleave * self) eos: { GST_DEBUG_OBJECT (self, "no data available, must be EOS"); - gst_buffer_unref (outbuf); + if (outbuf) + gst_buffer_unref (outbuf); gst_pad_push_event (self->src, gst_event_new_eos ()); return GST_FLOW_EOS; } -- 2.7.4