[gst-cvs] gst-plugins-base: oggdemux: don't loop when at EOS
Wim Taymans
wtay at kemper.freedesktop.org
Tue May 19 03:47:23 PDT 2009
Module: gst-plugins-base
Branch: master
Commit: ed36eafabae42f73143bf3f6beaf58d793b28132
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=ed36eafabae42f73143bf3f6beaf58d793b28132
Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date: Tue May 19 12:45:59 2009 +0200
oggdemux: don't loop when at EOS
When we try to read the last page, don't try to read past the upper boundary, as
this might cause endless loops.
See #582942
---
ext/ogg/gstoggdemux.c | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c
index 9e695d6..176b69d 100644
--- a/ext/ogg/gstoggdemux.c
+++ b/ext/ogg/gstoggdemux.c
@@ -1550,13 +1550,18 @@ gst_ogg_demux_seek (GstOggDemux * ogg, gint64 offset)
* the ogg sync layer.
*/
static GstFlowReturn
-gst_ogg_demux_get_data (GstOggDemux * ogg)
+gst_ogg_demux_get_data (GstOggDemux * ogg, gint64 end_offset)
{
GstFlowReturn ret;
GstBuffer *buffer;
- GST_LOG_OBJECT (ogg, "get data %" G_GINT64_FORMAT " %" G_GINT64_FORMAT,
- ogg->read_offset, ogg->length);
+ GST_LOG_OBJECT (ogg,
+ "get data %" G_GINT64_FORMAT " %" G_GINT64_FORMAT " %" G_GINT64_FORMAT,
+ ogg->read_offset, ogg->length, end_offset);
+
+ if (end_offset > 0 && ogg->read_offset >= end_offset)
+ goto boundary_reached;
+
if (ogg->read_offset == ogg->length)
goto eos;
@@ -1571,6 +1576,11 @@ gst_ogg_demux_get_data (GstOggDemux * ogg)
return ret;
/* ERROR */
+boundary_reached:
+ {
+ GST_LOG_OBJECT (ogg, "reached boundary");
+ return GST_FLOW_LIMIT;
+ }
eos:
{
GST_LOG_OBJECT (ogg, "reached EOS");
@@ -1603,7 +1613,7 @@ static GstFlowReturn
gst_ogg_demux_get_next_page (GstOggDemux * ogg, ogg_page * og, gint64 boundary,
gint64 * offset)
{
- gint64 end_offset = 0;
+ gint64 end_offset = -1;
GstFlowReturn ret;
GST_LOG_OBJECT (ogg,
@@ -1616,7 +1626,7 @@ gst_ogg_demux_get_next_page (GstOggDemux * ogg, ogg_page * og, gint64 boundary,
while (TRUE) {
glong more;
- if (boundary > 0 && ogg->offset >= end_offset)
+ if (end_offset > 0 && ogg->offset >= end_offset)
goto boundary_reached;
more = ogg_sync_pageseek (&ogg->sync, og);
@@ -1634,7 +1644,7 @@ gst_ogg_demux_get_next_page (GstOggDemux * ogg, ogg_page * og, gint64 boundary,
goto boundary_reached;
GST_LOG_OBJECT (ogg, "need more data");
- ret = gst_ogg_demux_get_data (ogg);
+ ret = gst_ogg_demux_get_data (ogg, end_offset);
if (ret != GST_FLOW_OK)
break;
} else {
More information about the Gstreamer-commits
mailing list