From b89f95f179e620a09f4d0875a723982abbc335f7 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sun, 28 Jul 2002 18:16:59 +0000 Subject: [PATCH] Do better sync Original commit message from CVS: Do better sync --- ext/vorbis/vorbisfile.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/ext/vorbis/vorbisfile.c b/ext/vorbis/vorbisfile.c index 5ed8486..aca1863 100644 --- a/ext/vorbis/vorbisfile.c +++ b/ext/vorbis/vorbisfile.c @@ -355,6 +355,8 @@ gst_vorbisfile_loop (GstElement *element) VorbisFile *vorbisfile = GST_VORBISFILE (element); GstBuffer *outbuf; long ret; + GstClockTime time; + gint64 samples; if (vorbisfile->restart) { vorbisfile->current_section = 0; @@ -403,13 +405,20 @@ gst_vorbisfile_loop (GstElement *element) vorbisfile->seek_pending = FALSE; } + outbuf = gst_buffer_new (); + GST_BUFFER_DATA (outbuf) = g_malloc (4096); + GST_BUFFER_SIZE (outbuf) = 4096; + + /* get current time for discont and buffer timestamp */ + time = (GstClockTime) (ov_time_tell (&vorbisfile->vf) * GST_SECOND); + + ret = ov_read (&vorbisfile->vf, GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf), + 0, 2, 1, &vorbisfile->current_section); + if (vorbisfile->need_discont) { GstEvent *discont; - GstClockTime time; - gint64 samples; /* get stream stats */ - time = (gint64) (ov_time_tell (&vorbisfile->vf) * GST_SECOND); samples = (gint64) (ov_pcm_tell (&vorbisfile->vf)); discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time, @@ -419,13 +428,6 @@ gst_vorbisfile_loop (GstElement *element) gst_pad_push (vorbisfile->srcpad, GST_BUFFER (discont)); } - outbuf = gst_buffer_new (); - GST_BUFFER_DATA (outbuf) = g_malloc (4096); - GST_BUFFER_SIZE (outbuf) = 4096; - - ret = ov_read (&vorbisfile->vf, GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf), - 0, 2, 1, &vorbisfile->current_section); - if (ret == 0) { GST_DEBUG (0, "eos"); //ov_clear (&vorbisfile->vf); @@ -461,21 +463,13 @@ gst_vorbisfile_loop (GstElement *element) vorbisfile->may_eos = TRUE; - { - GstFormat format; - gint64 value; - - format = GST_FORMAT_TIME; - gst_vorbisfile_src_query (vorbisfile->srcpad, GST_PAD_QUERY_POSITION, &format, &value); - - GST_BUFFER_TIMESTAMP (outbuf) = value; - } + GST_BUFFER_TIMESTAMP (outbuf) = time; if (!vorbisfile->vf.seekable) { vorbisfile->total_bytes += GST_BUFFER_SIZE (outbuf); } - if (GST_PAD_IS_CONNECTED (vorbisfile->srcpad)) { + if (GST_PAD_IS_USABLE (vorbisfile->srcpad)) { gst_pad_push (vorbisfile->srcpad, outbuf); } else { -- 2.7.4