From faa912a31da00302400570bdac39e39926c49e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 12 May 2025 13:19:37 +0300 Subject: [PATCH] wavparse: Error out correctly if no data tag is found until EOS in pull mode Part-of: --- .../gst/wavparse/gstwavparse.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/wavparse/gstwavparse.c b/subprojects/gst-plugins-good/gst/wavparse/gstwavparse.c index 917e60fa70..50142d593e 100644 --- a/subprojects/gst-plugins-good/gst/wavparse/gstwavparse.c +++ b/subprojects/gst-plugins-good/gst/wavparse/gstwavparse.c @@ -1313,8 +1313,9 @@ gst_wavparse_stream_headers (GstWavParse * wav) gst_pad_peer_query_duration (wav->sinkpad, GST_FORMAT_BYTES, &upstream_size); GST_DEBUG_OBJECT (wav, "upstream size %" G_GUINT64_FORMAT, upstream_size); - /* loop headers until we get data */ - while (!gotdata) { + /* loop headers until we got the data tag in push mode, or until we + * reached the end of file in pull mode*/ + while (!gotdata || !wav->streaming) { if (wav->streaming) { if (!gst_wavparse_peek_chunk_info (wav, &tag, &size)) goto exit; @@ -1324,7 +1325,6 @@ gst_wavparse_stream_headers (GstWavParse * wav) buf = NULL; res = gst_wavparse_pull_range_exact (wav, wav->offset, 8, &buf); if (res == GST_FLOW_EOS) { - gotdata = TRUE; break; } else if (res != GST_FLOW_OK) { goto header_pull_error; @@ -1368,7 +1368,6 @@ gst_wavparse_stream_headers (GstWavParse * wav) } if (wav->streaming) { gst_adapter_flush (wav->adapter, 8); - gotdata = TRUE; } else { gst_buffer_unref (buf); } @@ -1397,6 +1396,7 @@ gst_wavparse_stream_headers (GstWavParse * wav) /* We will continue parsing tags 'till end */ wav->offset += size64; } + gotdata = TRUE; GST_DEBUG_OBJECT (wav, "datasize = %" G_GUINT64_FORMAT, size64); break; } @@ -1728,10 +1728,14 @@ gst_wavparse_stream_headers (GstWavParse * wav) if (upstream_size && (wav->offset >= upstream_size)) { /* Now we are gone through the whole file */ - gotdata = TRUE; + if (!wav->streaming) + break; } } + if (!gotdata) + goto no_data; + GST_DEBUG_OBJECT (wav, "Finished parsing headers"); if (wav->bps <= 0 && wav->fact) { @@ -1800,6 +1804,11 @@ fail: res = GST_FLOW_ERROR; goto exit; } +no_data: + { + GST_ELEMENT_ERROR (wav, STREAM, FAILED, (NULL), ("Stream without data")); + goto fail; + } parse_header_error: { GST_ELEMENT_ERROR (wav, STREAM, DEMUX, (NULL),