[pulseaudio-commits] r2276 - /branches/glitch-free/src/tests/rtstutter.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sun Apr 20 12:44:34 PDT 2008


Author: lennart
Date: Sun Apr 20 21:44:33 2008
New Revision: 2276

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2276&root=pulseaudio&view=rev
Log:
add lower boundary for artifical latencies

Modified:
    branches/glitch-free/src/tests/rtstutter.c

Modified: branches/glitch-free/src/tests/rtstutter.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/tests/rtstutter.c?rev=2276&root=pulseaudio&r1=2275&r2=2276&view=diff
==============================================================================
--- branches/glitch-free/src/tests/rtstutter.c (original)
+++ branches/glitch-free/src/tests/rtstutter.c Sun Apr 20 21:44:33 2008
@@ -39,7 +39,7 @@
 #include <pulsecore/log.h>
 #include <pulsecore/macro.h>
 
-static int msec;
+static int msec_lower, msec_upper;
 
 static void* work(void *p) PA_GCC_NORETURN;
 
@@ -66,7 +66,9 @@
 
         pa_assert_se(clock_gettime(CLOCK_REALTIME, &end) == 0);
 
-        nsec = (uint64_t) ((((double) rand())*msec*PA_NSEC_PER_MSEC)/RAND_MAX);
+        nsec =
+            (uint64_t) ((((double) rand())*(msec_upper-msec_lower)*PA_NSEC_PER_MSEC)/RAND_MAX) +
+            (uint64_t) (msec_lower*PA_NSEC_PER_MSEC);
 
         pa_log_notice("CPU%i: Freezing for %ims", PA_PTR_TO_INT(p), (int) (nsec/PA_NSEC_PER_MSEC));
 
@@ -90,11 +92,21 @@
 
     srand(time(NULL));
 
-    msec = argc > 1 ? atoi(argv[1]) : 1000;
+    if (argc >= 3) {
+        msec_lower = atoi(argv[1]);
+        msec_upper = atoi(argv[2]);
+    } else if (argc >= 2) {
+        msec_lower = 0;
+        msec_upper = atoi(argv[1]);
+    } else {
+        msec_lower = 0;
+        msec_upper = 1000;
+    }
 
-    pa_assert(msec > 0);
+    pa_assert(msec_upper > 0);
+    pa_assert(msec_upper >= msec_lower);
 
-    pa_log_notice("Creating random latencies of up to %ims.", msec);
+    pa_log_notice("Creating random latencies in the range of %ims to  %ims.", msec_lower, msec_upper);
 
     for (n = 1; n < sysconf(_SC_NPROCESSORS_CONF); n++) {
         pthread_t t;




More information about the pulseaudio-commits mailing list