chiark / gitweb /
Work around stupid excessively strict warning in GCC 4.4.
[disorder] / clients / rtpmon.c
index 66e2f0130e0ba5824730bb0b617bc6837d8a0803..e64b08e404a23da6dce8bc7886607a54e9c458c2 100644 (file)
@@ -35,6 +35,7 @@
 #include <locale.h>
 #include <errno.h>
 #include <stdlib.h>
+#include <sys/uio.h>
 
 #include "syscalls.h"
 #include "timeval.h"
@@ -61,7 +62,7 @@ static unsigned bpf = 4;
 static uint32_t serial;
 
 /** @brief Size of ring buffer */
-#define RINGSIZE 16384
+#define RINGSIZE 131072
 
 /** @brief Ring buffer */
 static struct entry ring[RINGSIZE];
@@ -104,14 +105,23 @@ static double rate(unsigned earlier, unsigned later) {
  * @param n How many frames of audio data we received
  */
 static void frames(const struct timeval *when, size_t n) {
+  const time_t prev = ring[(ringtail - 1) % RINGSIZE].when.tv_sec;
+
   ring[ringtail].when = *when;
   ring[ringtail].serial = serial;
   serial += n;
   ringtail = (ringtail + 1) % RINGSIZE;
-  // Report rates every couple of hundred packets
-  if(!(ringtail & 1023)) {
-    
-    if(printf("%8.2f  %8.2f  %8.2f\n",
+  // Report once a second
+  if(prev != when->tv_sec) {
+    if(printf("%8.2f  %8.2f  %8.2f  %8.2f  %8.2f  %8.2f  %8.2f\n",
+              rate((ringtail - RINGSIZE / 128) % RINGSIZE,
+                   (ringtail - 1) % RINGSIZE),
+              rate((ringtail - RINGSIZE / 64) % RINGSIZE,
+                   (ringtail - 1) % RINGSIZE),
+              rate((ringtail - RINGSIZE / 32) % RINGSIZE,
+                   (ringtail - 1) % RINGSIZE),
+              rate((ringtail - RINGSIZE / 16) % RINGSIZE,
+                   (ringtail - 1) % RINGSIZE),
               rate((ringtail - RINGSIZE / 8) % RINGSIZE,
                    (ringtail - 1) % RINGSIZE),
               rate((ringtail - RINGSIZE / 4) % RINGSIZE,