ext/mad/gstmad.c: don't overflow data buffer. Flush not needed sync data when syncing failed.

Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_chain):
don't overflow data buffer. Flush not needed sync data when syncing
failed.
This commit is contained in:
Benjamin Otte 2004-11-05 03:33:26 +00:00
parent 5509374caf
commit 3824908ab3
2 changed files with 23 additions and 4 deletions

View file

@ -1,3 +1,9 @@
2004-11-05 Benjamin Otte <otte@gnome.org>
* ext/mad/gstmad.c: (gst_mad_chain):
don't overflow data buffer. Flush not needed sync data when syncing
failed.
2004-11-04 Wim Taymans <wim@fluendo.com>
* gst/alpha/gstalpha.c: (gst_alpha_method_get_type),

View file

@ -1246,7 +1246,15 @@ gst_mad_chain (GstPad * pad, GstData * _data)
gint tocopy;
guchar *mad_input_buffer; /* convenience pointer to tempbuffer */
tocopy = MIN (MAD_BUFFER_MDLEN, size);
tocopy =
MIN (MAD_BUFFER_MDLEN, MIN (size,
MAD_BUFFER_MDLEN * 3 - mad->tempsize));
if (tocopy == 0) {
GST_ELEMENT_ERROR (mad, STREAM, DECODE, (NULL),
("mad claims to need more data than %u bytes, we don't have that much",
MAD_BUFFER_MDLEN * 3));
return;
}
/* append the chunk to process to our internal temporary buffer */
GST_LOG ("tempbuffer size %d, copying %d bytes from incoming buffer",
@ -1287,9 +1295,14 @@ gst_mad_chain (GstPad * pad, GstData * _data)
/* not enough data, need to wait for next buffer? */
if (mad->stream.error == MAD_ERROR_BUFLEN) {
GST_LOG ("not enough data in tempbuffer (%d), breaking to get more",
mad->tempsize);
break;
if (mad->stream.next_frame == mad_input_buffer) {
GST_LOG ("not enough data in tempbuffer (%d), breaking to get more",
mad->tempsize);
break;
} else {
GST_LOG ("sync error, flushing unneeded data");
goto next;
}
}
/* we are in an error state */
mad->in_error = TRUE;