wavparse: Error out correctly if no data tag is found until EOS in pull mode

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8956>
This commit is contained in:
Sebastian Dröge 2025-05-12 13:19:37 +03:00 committed by GStreamer Marge Bot
parent ba8fd35e72
commit faa912a31d

View File

@ -1313,8 +1313,9 @@ gst_wavparse_stream_headers (GstWavParse * wav)
gst_pad_peer_query_duration (wav->sinkpad, GST_FORMAT_BYTES, &upstream_size); gst_pad_peer_query_duration (wav->sinkpad, GST_FORMAT_BYTES, &upstream_size);
GST_DEBUG_OBJECT (wav, "upstream size %" G_GUINT64_FORMAT, upstream_size); GST_DEBUG_OBJECT (wav, "upstream size %" G_GUINT64_FORMAT, upstream_size);
/* loop headers until we get data */ /* loop headers until we got the data tag in push mode, or until we
while (!gotdata) { * reached the end of file in pull mode*/
while (!gotdata || !wav->streaming) {
if (wav->streaming) { if (wav->streaming) {
if (!gst_wavparse_peek_chunk_info (wav, &tag, &size)) if (!gst_wavparse_peek_chunk_info (wav, &tag, &size))
goto exit; goto exit;
@ -1324,7 +1325,6 @@ gst_wavparse_stream_headers (GstWavParse * wav)
buf = NULL; buf = NULL;
res = gst_wavparse_pull_range_exact (wav, wav->offset, 8, &buf); res = gst_wavparse_pull_range_exact (wav, wav->offset, 8, &buf);
if (res == GST_FLOW_EOS) { if (res == GST_FLOW_EOS) {
gotdata = TRUE;
break; break;
} else if (res != GST_FLOW_OK) { } else if (res != GST_FLOW_OK) {
goto header_pull_error; goto header_pull_error;
@ -1368,7 +1368,6 @@ gst_wavparse_stream_headers (GstWavParse * wav)
} }
if (wav->streaming) { if (wav->streaming) {
gst_adapter_flush (wav->adapter, 8); gst_adapter_flush (wav->adapter, 8);
gotdata = TRUE;
} else { } else {
gst_buffer_unref (buf); gst_buffer_unref (buf);
} }
@ -1397,6 +1396,7 @@ gst_wavparse_stream_headers (GstWavParse * wav)
/* We will continue parsing tags 'till end */ /* We will continue parsing tags 'till end */
wav->offset += size64; wav->offset += size64;
} }
gotdata = TRUE;
GST_DEBUG_OBJECT (wav, "datasize = %" G_GUINT64_FORMAT, size64); GST_DEBUG_OBJECT (wav, "datasize = %" G_GUINT64_FORMAT, size64);
break; break;
} }
@ -1728,10 +1728,14 @@ gst_wavparse_stream_headers (GstWavParse * wav)
if (upstream_size && (wav->offset >= upstream_size)) { if (upstream_size && (wav->offset >= upstream_size)) {
/* Now we are gone through the whole file */ /* 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"); GST_DEBUG_OBJECT (wav, "Finished parsing headers");
if (wav->bps <= 0 && wav->fact) { if (wav->bps <= 0 && wav->fact) {
@ -1800,6 +1804,11 @@ fail:
res = GST_FLOW_ERROR; res = GST_FLOW_ERROR;
goto exit; goto exit;
} }
no_data:
{
GST_ELEMENT_ERROR (wav, STREAM, FAILED, (NULL), ("Stream without data"));
goto fail;
}
parse_header_error: parse_header_error:
{ {
GST_ELEMENT_ERROR (wav, STREAM, DEMUX, (NULL), GST_ELEMENT_ERROR (wav, STREAM, DEMUX, (NULL),