pulsesrc: guard fragment size with a lower limit based on latency-time
authorRené Stadler <mail@renestadler.de>
Fri, 2 Oct 2009 20:51:29 +0000 (23:51 +0300)
committerRené Stadler <mail@renestadler.de>
Tue, 6 Oct 2009 17:54:20 +0000 (20:54 +0300)
In case that the pulse daemon runs the source device at a relatively low fixed
fragment size compared to the requested latency-time, configure the ring buffer
segsize to the largest integer multiple of the fragment size that is still
smaller than or equal to the requested latency-time.

Fixes bug #597463.

ext/pulse/pulsesrc.c

index 1da7936620934dd454638adf940fbb7f81fc5443..d53acf8e88daa306d2ce7249087957f72708516f 100644 (file)
@@ -1014,8 +1014,11 @@ gst_pulsesrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
   GST_INFO_OBJECT (pulsesrc, "fragsize:  %d (wanted %d)",
       actual->fragsize, wanted.fragsize);
 
-  /* adjust latency again */
-  spec->segsize = actual->fragsize;
+  if (actual->fragsize >= wanted.fragsize) {
+    spec->segsize = actual->fragsize;
+  } else {
+    spec->segsize = actual->fragsize * (wanted.fragsize / actual->fragsize);
+  }
   spec->segtotal = actual->maxlength / spec->segsize;
 
   pa_threaded_mainloop_unlock (pulsesrc->mainloop);