diff options
author | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2004-03-07 02:51:33 +0000 |
---|---|---|
committer | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2004-03-07 02:51:33 +0000 |
commit | 63e0fe099ee70bc6993f44cefb7537e7a559aef4 (patch) | |
tree | c89115d7f340bf5b22904a7475213555ed7329e3 /sys | |
parent | bc6e4f585ce770947a61f5c191622586e9839d65 (diff) |
sys/oss/gstosssink.c: And another caller that couldn't handle delay < 0 (unsigned integer overflow). Video now contin...
Original commit message from CVS:
* sys/oss/gstosssink.c: (gst_osssink_chain):
And another caller that couldn't handle delay < 0 (unsigned
integer overflow). Video now continues playing on an audio
buffer underrun, and the clock continues working. Audio still
stalls.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/oss/gstosssink.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/oss/gstosssink.c b/sys/oss/gstosssink.c index 6e91bdba..839321f3 100644 --- a/sys/oss/gstosssink.c +++ b/sys/oss/gstosssink.c @@ -337,6 +337,7 @@ gst_osssink_chain (GstPad *pad, GstData *_data) GstClockTime buftime, elementtime, soundtime; guchar *data; guint to_write; + gint delay; /* this has to be an audio buffer */ osssink = GST_OSSSINK (gst_pad_get_parent (pad)); @@ -367,7 +368,10 @@ gst_osssink_chain (GstPad *pad, GstData *_data) to_write = GST_BUFFER_SIZE (buf); /* sync audio with buffers timestamp */ elementtime = gst_element_get_time (GST_ELEMENT (osssink)); - soundtime = elementtime + gst_osssink_get_delay (osssink) * GST_SECOND / GST_OSSELEMENT (osssink)->bps; + delay = gst_osssink_get_delay (osssink); + if (delay < 0) + delay = 0; + soundtime = elementtime + delay * GST_SECOND / GST_OSSELEMENT (osssink)->bps; if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) { buftime = GST_BUFFER_TIMESTAMP (buf); } else { @@ -381,9 +385,9 @@ gst_osssink_chain (GstPad *pad, GstData *_data) elementtime, soundtime, buftime); if (soundtime > buftime) { /* full frames */ - guint throw_away = (soundtime - buftime) * GST_OSSELEMENT (osssink)->bps / GST_SECOND - / GST_OSSELEMENT (osssink)->width / GST_OSSELEMENT (osssink)->channels - * GST_OSSELEMENT (osssink)->width * GST_OSSELEMENT (osssink)->channels; + guint throw_away = (soundtime - buftime) * GST_OSSELEMENT (osssink)->bps / GST_SECOND; + throw_away &= ~(GST_OSSELEMENT (osssink)->width * GST_OSSELEMENT (osssink)->channels); + osssink->handled += throw_away; if (throw_away >= GST_BUFFER_SIZE (buf)) { gst_data_unref (_data); return; |