summaryrefslogtreecommitdiffstats
path: root/gst/modplug
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2004-03-14 13:11:14 +0000
committerBenjamin Otte <otte@gnome.org>2004-03-14 13:11:14 +0000
commitbcddae04d655326f0207f618abb809a3f45d2938 (patch)
tree23f33a3e72860737f36a988d230dd60d9616d7b3 /gst/modplug
parent94f1403b7b476849d62621d22ba0530fe7ab7216 (diff)
downloadgst-plugins-bad-bcddae04d655326f0207f618abb809a3f45d2938.tar.gz
gst-plugins-bad-bcddae04d655326f0207f618abb809a3f45d2938.tar.bz2
gst-plugins-bad-bcddae04d655326f0207f618abb809a3f45d2938.zip
gst/modplug/gstmodplug.*: set correct timestamps on outgoing buffers
Original commit message from CVS: * gst/modplug/gstmodplug.cc: * gst/modplug/gstmodplug.h: set correct timestamps on outgoing buffers
Diffstat (limited to 'gst/modplug')
-rw-r--r--gst/modplug/gstmodplug.cc41
-rw-r--r--gst/modplug/gstmodplug.h1
2 files changed, 25 insertions, 17 deletions
diff --git a/gst/modplug/gstmodplug.cc b/gst/modplug/gstmodplug.cc
index 06701c6d..e6e67e33 100644
--- a/gst/modplug/gstmodplug.cc
+++ b/gst/modplug/gstmodplug.cc
@@ -530,7 +530,7 @@ gst_modplug_loop (GstElement *element)
/* GstBuffer *buf;*/
modplug->seek_at = -1;
- modplug->need_discont = FALSE;
+ modplug->need_discont = TRUE;
modplug->eos = FALSE;
/*
buf = gst_pad_pull (modplug->sinkpad);
@@ -621,29 +621,36 @@ gst_modplug_loop (GstElement *element)
modplug->seek_at = -1;
}
+ if (modplug->need_discont && GST_PAD_IS_USABLE (modplug->srcpad))
+ {
+ GstEvent *discont;
+ gint64 value;
+ GstFormat format = GST_FORMAT_TIME;
+
+ if (gst_modplug_src_query (modplug->srcpad, GST_QUERY_POSITION, &format, &value)) {
+ discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, value, GST_FORMAT_UNDEFINED);
+ modplug->timestamp = value;
+ } else {
+ modplug->timestamp = GST_CLOCK_TIME_NONE;
+ discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_UNDEFINED);
+ }
+ gst_pad_push (modplug->srcpad, GST_DATA (discont));
+ modplug->need_discont= FALSE;
+ }
+
if (modplug->mSoundFile->Read (modplug->audiobuffer, modplug->length) != 0)
{
GstBuffer *buffer_out;
- GstFormat format;
- gint64 value;
- format = GST_FORMAT_TIME;
- gst_modplug_src_query (modplug->srcpad, GST_QUERY_POSITION, &format, &value);
-
- if (modplug->need_discont && GST_PAD_IS_USABLE (modplug->srcpad))
- {
- GstEvent *discont;
-
- discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, value, NULL);
- gst_pad_push (modplug->srcpad, GST_DATA (discont));
-
- modplug->need_discont= FALSE;
- }
-
buffer_out = gst_buffer_new ();
GST_BUFFER_DATA (buffer_out) = (guchar *) g_memdup (modplug->audiobuffer, modplug->length);
GST_BUFFER_SIZE (buffer_out) = modplug->length;
- GST_BUFFER_TIMESTAMP (buffer_out) = value;
+ GST_BUFFER_TIMESTAMP (buffer_out) = modplug->timestamp;
+
+ if (GST_CLOCK_TIME_IS_VALID (modplug->timestamp)) {
+ GST_BUFFER_DURATION (buffer_out) = modplug->length * GST_SECOND / modplug->frequency / modplug->channel / (modplug->_16bit ? 2 : 1) ;
+ modplug->timestamp += GST_BUFFER_DURATION (buffer_out);
+ }
if (GST_PAD_IS_USABLE (modplug->srcpad))
gst_pad_push (modplug->srcpad, GST_DATA (buffer_out));
diff --git a/gst/modplug/gstmodplug.h b/gst/modplug/gstmodplug.h
index 95a71443..c4a98b86 100644
--- a/gst/modplug/gstmodplug.h
+++ b/gst/modplug/gstmodplug.h
@@ -70,6 +70,7 @@ struct _GstModPlug {
gboolean eos;
gint64 seek_at;
guint64 song_size;
+ guint64 timestamp;
CSoundFile *mSoundFile;
gboolean opened; /* set to TRUE when mSoundFile is created */