From 803cf898ed825d47fba35c75c684fdd7500347e1 Mon Sep 17 00:00:00 2001 From: Erik Walthinsen Date: Fri, 21 Sep 2001 20:02:01 +0000 Subject: [PATCH] added EOS event handling to filesrc Original commit message from CVS: added EOS event handling to filesrc --- gst/elements/gstfilesrc.c | 9 +++++---- plugins/elements/gstfilesrc.c | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gst/elements/gstfilesrc.c b/gst/elements/gstfilesrc.c index 86b198b1b5..124d65f272 100644 --- a/gst/elements/gstfilesrc.c +++ b/gst/elements/gstfilesrc.c @@ -435,7 +435,6 @@ gst_filesrc_get (GstPad *pad) GstFileSrc *src; GstBuffer *buf = NULL, *map; off_t readend,readsize,mapstart,mapend; - gboolean eof = FALSE; GstFileSrcRegion region; int i; @@ -443,6 +442,11 @@ gst_filesrc_get (GstPad *pad) src = GST_FILESRC (gst_pad_get_parent (pad)); g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN), NULL); + // check for EOF + if (src->curoffset == src->filelen) { + return gst_event_empty_new(GST_EVENT_EOS); + } + // calculate end pointers so we don't have to do so repeatedly later readsize = src->block_size; readend = src->curoffset + src->block_size; // note this is the byte *after* the read @@ -453,7 +457,6 @@ gst_filesrc_get (GstPad *pad) if (readend > src->filelen) { readsize = src->filelen - src->curoffset; readend = src->curoffset; - eof = TRUE; } // if the start is past the mapstart @@ -528,8 +531,6 @@ gst_filesrc_get (GstPad *pad) *(GST_BUFFER_DATA(buf)+i) = *(GST_BUFFER_DATA(buf)+i); } - // if we hit EOF, - /* we're done, return the buffer */ src->curoffset += GST_BUFFER_SIZE(buf); return buf; diff --git a/plugins/elements/gstfilesrc.c b/plugins/elements/gstfilesrc.c index 86b198b1b5..124d65f272 100644 --- a/plugins/elements/gstfilesrc.c +++ b/plugins/elements/gstfilesrc.c @@ -435,7 +435,6 @@ gst_filesrc_get (GstPad *pad) GstFileSrc *src; GstBuffer *buf = NULL, *map; off_t readend,readsize,mapstart,mapend; - gboolean eof = FALSE; GstFileSrcRegion region; int i; @@ -443,6 +442,11 @@ gst_filesrc_get (GstPad *pad) src = GST_FILESRC (gst_pad_get_parent (pad)); g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN), NULL); + // check for EOF + if (src->curoffset == src->filelen) { + return gst_event_empty_new(GST_EVENT_EOS); + } + // calculate end pointers so we don't have to do so repeatedly later readsize = src->block_size; readend = src->curoffset + src->block_size; // note this is the byte *after* the read @@ -453,7 +457,6 @@ gst_filesrc_get (GstPad *pad) if (readend > src->filelen) { readsize = src->filelen - src->curoffset; readend = src->curoffset; - eof = TRUE; } // if the start is past the mapstart @@ -528,8 +531,6 @@ gst_filesrc_get (GstPad *pad) *(GST_BUFFER_DATA(buf)+i) = *(GST_BUFFER_DATA(buf)+i); } - // if we hit EOF, - /* we're done, return the buffer */ src->curoffset += GST_BUFFER_SIZE(buf); return buf;