mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 14:08:56 +00:00
sys/oss/: Fix offset on osssrc.
Original commit message from CVS: * sys/oss/gstosselement.c: (gst_osselement_reset), (gst_osselement_parse_caps): * sys/oss/gstosselement.h: * sys/oss/gstosssrc.c: (gst_osssrc_get): Fix offset on osssrc.
This commit is contained in:
parent
87aff668ef
commit
f68667a5e5
4 changed files with 21 additions and 5 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2004-07-07 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* sys/oss/gstosselement.c: (gst_osselement_reset),
|
||||||
|
(gst_osselement_parse_caps):
|
||||||
|
* sys/oss/gstosselement.h:
|
||||||
|
* sys/oss/gstosssrc.c: (gst_osssrc_get):
|
||||||
|
Fix offset on osssrc.
|
||||||
|
|
||||||
2004-07-07 Wim Taymans <wim@fluendo.com>
|
2004-07-07 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* ext/theora/theora.c: (plugin_init):
|
* ext/theora/theora.c: (plugin_init):
|
||||||
|
|
|
@ -456,6 +456,7 @@ gst_osselement_reset (GstOssElement * oss)
|
||||||
oss->rate = 44100;
|
oss->rate = 44100;
|
||||||
oss->fragment = 0;
|
oss->fragment = 0;
|
||||||
oss->bps = 0;
|
oss->bps = 0;
|
||||||
|
oss->sample_width = 0;
|
||||||
|
|
||||||
/* AFMT_*_BE not available on all OSS includes (e.g. FBSD) */
|
/* AFMT_*_BE not available on all OSS includes (e.g. FBSD) */
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
@ -545,6 +546,7 @@ gst_osselement_parse_caps (GstOssElement * oss, const GstCaps * caps)
|
||||||
gst_structure_get_int (structure, "channels", &oss->channels);
|
gst_structure_get_int (structure, "channels", &oss->channels);
|
||||||
gst_structure_get_int (structure, "rate", &oss->rate);
|
gst_structure_get_int (structure, "rate", &oss->rate);
|
||||||
|
|
||||||
|
oss->sample_width = bps * oss->channels;
|
||||||
oss->bps = bps * oss->channels * oss->rate;
|
oss->bps = bps * oss->channels * oss->rate;
|
||||||
oss->format = format;
|
oss->format = format;
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,9 @@ struct _GstOssElement
|
||||||
/* stats bytes per *second* */
|
/* stats bytes per *second* */
|
||||||
guint bps;
|
guint bps;
|
||||||
|
|
||||||
|
/* sample width in bytes */
|
||||||
|
guint sample_width;
|
||||||
|
|
||||||
/* parameters */
|
/* parameters */
|
||||||
gint law;
|
gint law;
|
||||||
gint endianness;
|
gint endianness;
|
||||||
|
|
|
@ -335,6 +335,7 @@ gst_osssrc_get (GstPad * pad)
|
||||||
GstOssSrc *src;
|
GstOssSrc *src;
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
glong readbytes;
|
glong readbytes;
|
||||||
|
glong readsamples;
|
||||||
|
|
||||||
src = GST_OSSSRC (gst_pad_get_parent (pad));
|
src = GST_OSSSRC (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
|
@ -376,19 +377,21 @@ gst_osssrc_get (GstPad * pad)
|
||||||
return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
|
return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readsamples = readbytes * GST_OSSELEMENT (src)->rate /
|
||||||
|
GST_OSSELEMENT (src)->bps;
|
||||||
|
|
||||||
GST_BUFFER_SIZE (buf) = readbytes;
|
GST_BUFFER_SIZE (buf) = readbytes;
|
||||||
GST_BUFFER_OFFSET (buf) = src->curoffset;
|
GST_BUFFER_OFFSET (buf) = src->curoffset;
|
||||||
|
GST_BUFFER_OFFSET_END (buf) = src->curoffset + readsamples;
|
||||||
GST_BUFFER_DURATION (buf) =
|
GST_BUFFER_DURATION (buf) =
|
||||||
(GST_SECOND * GST_BUFFER_SIZE (buf)) / (GST_OSSELEMENT (src)->bps *
|
readsamples * GST_SECOND / GST_OSSELEMENT (src)->rate;
|
||||||
GST_OSSELEMENT (src)->rate);
|
|
||||||
|
|
||||||
/* if we have a clock */
|
/* if we have a clock */
|
||||||
if (src->clock) {
|
if (src->clock) {
|
||||||
if (src->clock == src->provided_clock) {
|
if (src->clock == src->provided_clock) {
|
||||||
/* if it's our own clock, we can be very accurate */
|
/* if it's our own clock, we can be very accurate */
|
||||||
GST_BUFFER_TIMESTAMP (buf) =
|
GST_BUFFER_TIMESTAMP (buf) =
|
||||||
src->curoffset * GST_SECOND / GST_OSSELEMENT (src)->bps;
|
src->curoffset * GST_SECOND / GST_OSSELEMENT (src)->rate;
|
||||||
} else {
|
} else {
|
||||||
/* somebody elses clock, timestamp with that clock, no discontinuity in
|
/* somebody elses clock, timestamp with that clock, no discontinuity in
|
||||||
* the stream since the OFFSET is updated correctly. Elements can stretch
|
* the stream since the OFFSET is updated correctly. Elements can stretch
|
||||||
|
@ -401,7 +404,7 @@ gst_osssrc_get (GstPad * pad)
|
||||||
GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
|
GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
src->curoffset += readbytes;
|
src->curoffset += readsamples;
|
||||||
|
|
||||||
GST_DEBUG ("pushed buffer from soundcard of %ld bytes, timestamp %"
|
GST_DEBUG ("pushed buffer from soundcard of %ld bytes, timestamp %"
|
||||||
G_GINT64_FORMAT, readbytes, GST_BUFFER_TIMESTAMP (buf));
|
G_GINT64_FORMAT, readbytes, GST_BUFFER_TIMESTAMP (buf));
|
||||||
|
|
Loading…
Reference in a new issue