jack: ensure segtotal is at least 2

Not only adjust buffer-time and avoid segtotal=0, but instead ensure segtotal is
atleast 2. Do same change on jacksrc. We could also check the latency and buffer
time configured by the client and adjust buffer-time so that we get to the same
number of segments.
This commit is contained in:
Stefan Kost 2009-10-12 09:06:37 +03:00 committed by Tim-Philipp Müller
parent 45fb781f9b
commit f20c73684b
2 changed files with 13 additions and 7 deletions

View file

@ -440,10 +440,9 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
spec->segsize = buffer_size * sizeof (gfloat) * channels;
spec->latency_time = gst_util_uint64_scale (spec->segsize,
(GST_SECOND / GST_USECOND), spec->rate * spec->bytes_per_sample);
if (spec->latency_time < spec->buffer_time) {
/* segtotal based on buffer-time latency */
spec->segtotal = spec->buffer_time / spec->latency_time;
} else {
/* segtotal based on buffer-time latency */
spec->segtotal = spec->buffer_time / spec->latency_time;
if (spec->segtotal < 2) {
spec->segtotal = 2;
spec->buffer_time = spec->latency_time * spec->segtotal;
}
@ -452,7 +451,6 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
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);

View file

@ -444,9 +444,17 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
(GST_SECOND / GST_USECOND), spec->rate * spec->bytes_per_sample);
/* segtotal based on buffer-time latency */
spec->segtotal = spec->buffer_time / spec->latency_time;
if (spec->segtotal < 2) {
spec->segtotal = 2;
spec->buffer_time = spec->latency_time * spec->segtotal;
}
GST_DEBUG_OBJECT (src, "segsize %d, segtotal %d", spec->segsize,
spec->segtotal);
GST_DEBUG_OBJECT (src, "buffer time: %" G_GINT64_FORMAT " usec",
spec->buffer_time);
GST_DEBUG_OBJECT (src, "latency time: %" G_GINT64_FORMAT " usec",
spec->latency_time);
GST_DEBUG_OBJECT (src, "buffer_size %d, segsize %d, segtotal %d",
buffer_size, spec->segsize, spec->segtotal);
/* allocate the ringbuffer memory now */
buf->data = gst_buffer_new_and_alloc (spec->segtotal * spec->segsize);