commit 02b03fabec05c9e959d5b89c8a5b06c5e4c1d330 from: Sven M. Hallberg date: Thu Nov 09 19:09:18 2023 UTC remove debug output commit - 237ea00efb38e4f4408ead5b7805aa612769e323 commit + 02b03fabec05c9e959d5b89c8a5b06c5e4c1d330 blob - 80c2cfff465ec3f424bae3c6fcb6fdbfd270d10d blob + f5becb2c828ecec2e3c1779ead6c88ab362c3f27 --- cw.c +++ cw.c @@ -188,27 +188,6 @@ sample_out(int f, int x, int n, int total, int nramp) sio_write(hdl, buf, n * framesz); } - -#ifdef DEBUGTIME -#include - -static struct timespec t0; - -static void -timestamp(const char *str) -{ - struct timespec t, dt; - double ms; - - clock_gettime(CLOCK_MONOTONIC, &t); - timespecsub(&t, &t0, &dt); - ms = dt.tv_sec * 1000 + dt.tv_nsec / 1000000.0; - fprintf(stderr, "[%7.3f ms] %s", ms, str); -} -#else -#define timestamp(S) -#endif - /* play a beep of the desired frequency and length */ void beep(int f, int len) @@ -223,10 +202,6 @@ beep(int f, int len) nrise = par.rate * rise / 1000; nfall = par.rate * fall / 1000; -#ifdef DEBUGTIME - timestamp("beep"); - fprintf(stderr, "(%d ms): begin writing, %d frames\n", len, total); -#endif n = total; x = 0; while (n >= bufsz) { @@ -237,7 +212,6 @@ beep(int f, int len) if (n > 0) sample_out(f, x, n, total, nfall); writ += total; - timestamp("beep(): done writing\n"); inbeep = 1; } @@ -255,10 +229,6 @@ silence(int len) total = par.rate * len / 1000; -#ifdef DEBUGTIME - timestamp("silence"); - fprintf(stderr, "(%d ms): begin writing, %d frames\n", len, total); -#endif n = total; while (n >= bufsz) { sio_write(hdl, buf, bufsz * framesz); @@ -267,7 +237,6 @@ silence(int len) if (n > 0) sio_write(hdl, buf, n * framesz); writ += total; - timestamp("silence(): done writing\n"); inbeep = 0; } @@ -278,11 +247,6 @@ cb_onmove(void *arg, int delta) if (delta == 0) /* start of playback */ clock_gettime(CLOCK_MONOTONIC, &tplay); pos += delta; -#ifdef DEBUGTIME - timestamp("onmove: "); - fprintf(stderr, "delta = %d frames (%d ms), pos = %d/%d\n", delta, - delta * 1000 / par.rate, pos, writ); -#endif } void @@ -317,14 +281,6 @@ cwinit(void) if (par.msb) errx(1, "got MSB-aligned samples instead of LSB"); sample_max = (1 << (par.bits - 1)) - 1; - -#ifdef DEBUGTIME - fprintf(stderr, "par.rate = %6u Hz\n", par.rate); - fprintf(stderr, "par.bufsz = %6u (%3u ms)\n", par.bufsz, - par.bufsz * 1000 / par.rate); - fprintf(stderr, "par.appbufsz = %6u (%3u ms)\n", par.appbufsz, - par.appbufsz * 1000 / par.rate); -#endif /* allocate our buffer */ framesz = par.bps * par.pchan; @@ -360,45 +316,17 @@ cwinit(void) void cwstart() { -#ifdef DEBUGTIME - struct timespec t1, delta; - double ms; - - clock_gettime(CLOCK_MONOTONIC, &t0); /* resets the clock */ - timestamp("cwstart()\n"); -#endif writ = pos = 0; clock_gettime(CLOCK_MONOTONIC, &tplay); /* onmove(0) will update this */ if (!sio_start(hdl)) errx(1, "sio_start failed"); -#ifdef DEBUGTIME - clock_gettime(CLOCK_MONOTONIC, &t1); - timespecsub(&t1, &t0, &delta); - ms = delta.tv_sec * 1000 + delta.tv_nsec / 1000000.0; - timestamp("sio_start() "); - fprintf(stderr, "took %f ms\n", ms); -#endif } int cwstop(void) { -#ifdef DEBUGTIME - struct timespec t0, t1, delta; - double ms; - - timestamp("cwstop()\n"); - clock_gettime(CLOCK_MONOTONIC, &t0); -#endif if (!sio_stop(hdl)) errx(1, "sio_stop failed"); -#ifdef DEBUGTIME - clock_gettime(CLOCK_MONOTONIC, &t1); - timespecsub(&t1, &t0, &delta); - ms = delta.tv_sec * 1000 + delta.tv_nsec / 1000000.0; - timestamp("sio_stop() "); - fprintf(stderr, "took %f ms\n", ms); -#endif /* * Calculate and report our "return latency", i.e. the time it took @@ -414,11 +342,5 @@ cwstop(void) nowms = dt.tv_sec * 1000 + dt.tv_nsec / 1000000; playms = writ * 1000 / par.rate; -#ifdef DEBUGTIME - timestamp("playback started "); - fprintf(stderr, "%d ms ago, playback time %d ms\n", nowms, playms); - timestamp("cwstop: "); - fprintf(stderr, "return latency %d ms\n", nowms - playms); -#endif return nowms - playms; }