diff --git a/ChangeLog b/ChangeLog index ef6ffeacb4..c2cd1964bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-06-16 Wim Taymans + + * sys/oss/gstosssrc.c: (gst_osssrc_get): + Timestamp fixes. + 2004-06-16 Wim Taymans * sys/v4l/gstv4lsrc.c: (gst_v4lsrc_sync_mode_get_type), diff --git a/sys/oss/gstosssrc.c b/sys/oss/gstosssrc.c index 31d9fc1ceb..704b480e40 100644 --- a/sys/oss/gstosssrc.c +++ b/sys/oss/gstosssrc.c @@ -374,13 +374,28 @@ gst_osssrc_get (GstPad * pad) GST_BUFFER_SIZE (buf) = readbytes; GST_BUFFER_OFFSET (buf) = src->curoffset; - /* FIXME: we are falsely assuming that we are the master clock here */ - GST_BUFFER_TIMESTAMP (buf) = - src->curoffset * GST_SECOND / GST_OSSELEMENT (src)->bps; GST_BUFFER_DURATION (buf) = (GST_SECOND * GST_BUFFER_SIZE (buf)) / (GST_OSSELEMENT (src)->bps * GST_OSSELEMENT (src)->rate); + /* if we have a clock */ + if (src->clock) { + if (src->clock == src->provided_clock) { + /* if it's our own clock, we can be very accurate */ + GST_BUFFER_TIMESTAMP (buf) = + src->curoffset * GST_SECOND / GST_OSSELEMENT (src)->bps; + } else { + /* somebody elses clock, timestamp with that clock, no discontinuity in + * the stream since the OFFSET is updated correctly. Elements can stretch + * to match timestamps */ + GST_BUFFER_TIMESTAMP (buf) = + gst_element_get_time (GST_ELEMENT (src)) - GST_BUFFER_DURATION (buf); + } + } else { + /* no clock, no timestamp */ + GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE; + } + src->curoffset += readbytes; GST_DEBUG ("pushed buffer from soundcard of %ld bytes, timestamp %"