jack: don't crash in ringbuffer with SIGFPE on small buffer-times

Jack overrides user-specified latency-time with the one it gets from jack
itself. It also needs to adjust buffer-time somewhat to avoid segtotal being 0
This commit is contained in:
Stefan Kost 2009-10-12 00:51:27 +03:00
parent c1c0a4b143
commit 0b08651664

View file

@ -440,11 +440,21 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
spec->segsize = buffer_size * sizeof (gfloat) * channels; spec->segsize = buffer_size * sizeof (gfloat) * channels;
spec->latency_time = gst_util_uint64_scale (spec->segsize, spec->latency_time = gst_util_uint64_scale (spec->segsize,
(GST_SECOND / GST_USECOND), spec->rate * spec->bytes_per_sample); (GST_SECOND / GST_USECOND), spec->rate * spec->bytes_per_sample);
/* segtotal based on buffer-time latency */ if (spec->latency_time < spec->buffer_time) {
spec->segtotal = spec->buffer_time / spec->latency_time; /* segtotal based on buffer-time latency */
spec->segtotal = spec->buffer_time / spec->latency_time;
} else {
spec->segtotal = 2;
spec->buffer_time = spec->latency_time * spec->segtotal;
}
GST_DEBUG_OBJECT (sink, "segsize %d, segtotal %d", spec->segsize, GST_DEBUG_OBJECT (sink, "buffer time: %" G_GINT64_FORMAT " usec",
spec->segtotal); spec->buffer_time);
GST_DEBUG_OBJECT (sink, "latency time: %" G_GINT64_FORMAT " usec",
spec->latency_time);
GST_DEBUG_OBJECT (sink, "buffer_size %d, segsize %d, segtotal %d",
buffer_size, spec->segsize, spec->segtotal);
/* allocate the ringbuffer memory now */ /* allocate the ringbuffer memory now */
buf->data = gst_buffer_new_and_alloc (spec->segtotal * spec->segsize); buf->data = gst_buffer_new_and_alloc (spec->segtotal * spec->segsize);