wavparse: handle LIST INFO of 0 size

Handle LIST INFO chunks of 0 size instead of causing errors.

Fixes #584981
This commit is contained in:
Wim Taymans 2009-06-07 13:37:04 +02:00 committed by Wim Taymans
parent 7a0c94121f
commit fb25aced92

View file

@ -1429,36 +1429,42 @@ gst_wavparse_stream_headers (GstWavParse * wav)
const guint data_size = size - 4; const guint data_size = size - 4;
GstTagList *new; GstTagList *new;
GST_INFO_OBJECT (wav, "Have LIST chunk INFO"); GST_INFO_OBJECT (wav, "Have LIST chunk INFO size %u", data_size);
if (wav->streaming) { if (wav->streaming) {
gst_adapter_flush (wav->adapter, 12); gst_adapter_flush (wav->adapter, 12);
if (gst_adapter_available (wav->adapter) < data_size) { if (gst_adapter_available (wav->adapter) < data_size) {
return GST_FLOW_OK; return GST_FLOW_OK;
} }
gst_buffer_unref (buf); gst_buffer_unref (buf);
buf = gst_adapter_take_buffer (wav->adapter, data_size); if (data_size > 0)
buf = gst_adapter_take_buffer (wav->adapter, data_size);
} else { } else {
wav->offset += 12; wav->offset += 12;
gst_buffer_unref (buf); gst_buffer_unref (buf);
if ((res = if (data_size > 0) {
gst_pad_pull_range (wav->sinkpad, wav->offset, data_size, if ((res =
&buf)) != GST_FLOW_OK) gst_pad_pull_range (wav->sinkpad, wav->offset,
goto header_read_error; data_size, &buf)) != GST_FLOW_OK)
goto header_read_error;
}
} }
/* parse tags */ if (data_size > 0) {
gst_riff_parse_info (GST_ELEMENT (wav), buf, &new); /* parse tags */
if (new) { gst_riff_parse_info (GST_ELEMENT (wav), buf, &new);
GstTagList *old = wav->tags; if (new) {
wav->tags = gst_tag_list_merge (old, new, GST_TAG_MERGE_REPLACE); GstTagList *old = wav->tags;
if (old) wav->tags =
gst_tag_list_free (old); gst_tag_list_merge (old, new, GST_TAG_MERGE_REPLACE);
gst_tag_list_free (new); if (old)
} gst_tag_list_free (old);
if (wav->streaming) { gst_tag_list_free (new);
gst_adapter_flush (wav->adapter, data_size); }
} else { if (wav->streaming) {
gst_buffer_unref (buf); gst_adapter_flush (wav->adapter, data_size);
wav->offset += data_size; } else {
gst_buffer_unref (buf);
wav->offset += data_size;
}
} }
break; break;
} }
@ -1583,7 +1589,8 @@ unknown_format:
} }
header_read_error: header_read_error:
{ {
GST_ELEMENT_ERROR (wav, STREAM, DEMUX, (NULL), ("Couldn't read in header")); GST_ELEMENT_ERROR (wav, STREAM, DEMUX, (NULL),
("Couldn't read in header %d (%s)", res, gst_flow_get_name (res)));
g_free (codec_name); g_free (codec_name);
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }