From d8df8755e2e73d27cf831f05573a10847335837e Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Tue, 2 Jun 2026 19:01:31 -0400 Subject: [PATCH] fix: main.c migrate-to-library + deltacast audit cleanup --- services/capture/deltacast-bridge/main.c | 37 ++++-------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/services/capture/deltacast-bridge/main.c b/services/capture/deltacast-bridge/main.c index 977a0ee..ce41763 100644 --- a/services/capture/deltacast-bridge/main.c +++ b/services/capture/deltacast-bridge/main.c @@ -37,6 +37,10 @@ #include "VideoMasterHD_Sdi.h" #include "VideoMasterHD_Sdi_Audio.h" +#ifndef F_SETPIPE_SZ +#define F_SETPIPE_SZ 1031 +#endif + /* ── Constants ────────────────────────────────────────────────────────── */ #define MAX_PORTS 8 @@ -74,7 +78,7 @@ static ULONG loopback_prop(unsigned port) { case 1: return VHD_CORE_BP_PASSIVE_LOOPBACK_1; case 2: return VHD_CORE_BP_PASSIVE_LOOPBACK_2; case 3: return VHD_CORE_BP_PASSIVE_LOOPBACK_3; - default: return VHD_CORE_BP_PASSIVE_LOOPBACK_0; + default: return -1; /* ports 4-7 have no passive loopback property; call site guards p < 4 */ } } @@ -246,10 +250,6 @@ static void *audio_thread(void *arg) { nanosleep(&ts, NULL); continue; } - fprintf(stderr, "[audio:%u] FIFO writer connected\n", ps->port); - #ifndef F_SETPIPE_SZ - #define F_SETPIPE_SZ 1031 - #endif fcntl(fd, F_SETPIPE_SZ, 1024 * 1024); /* Reset wall-clock baseline after potentially blocking on open(). @@ -257,12 +257,6 @@ static void *audio_thread(void *arg) { struct timespec next; clock_gettime(CLOCK_MONOTONIC, &next); - /* Audio-rate telemetry: count samples written per second so drift is - * visible in the log ([audio:N] rate=). At 48 kHz it must - * average 48000. */ - unsigned long dbg_samples = 0; - struct timespec dbg_t0; clock_gettime(CLOCK_MONOTONIC, &dbg_t0); - /* Inner loop: feed audio into the open FIFO until reader exits (EPIPE). */ while (!atomic_load(&g_stop) && !atomic_load(&g_port_stop[ps->port])) { size_t out_bytes = 0; @@ -292,14 +286,6 @@ static void *audio_thread(void *arg) { fprintf(stderr, "[audio:%u] EPIPE — waiting for next reader\n", ps->port); break; } - dbg_samples += out_bytes / FRAME_BYTES; - struct timespec dnow; clock_gettime(CLOCK_MONOTONIC, &dnow); - double el = (dnow.tv_sec - dbg_t0.tv_sec) + (dnow.tv_nsec - dbg_t0.tv_nsec)/1e9; - if (el >= 5.0) { - fprintf(stderr, "[audio:%u] rate=%.1f samples/s (target 48000)\n", - ps->port, dbg_samples / el); - dbg_samples = 0; dbg_t0 = dnow; - } } /* No wall-clock sleep — the board's slot cadence is the clock. */ continue; @@ -370,16 +356,10 @@ static void *video_thread(void *arg) { nanosleep(&ts, NULL); continue; } - fprintf(stderr, "[video:%u] FIFO writer connected\n", ps->port); - #ifndef F_SETPIPE_SZ - #define F_SETPIPE_SZ 1031 - #endif { int pipe_sz = 64 * 1024 * 1024; /* 64 MB — ~16 frames of 1080p UYVY */ if (fcntl(fd, F_SETPIPE_SZ, pipe_sz) < 0) { fprintf(stderr, "[video:%u] fcntl F_SETPIPE_SZ failed: %s\n", ps->port, strerror(errno)); - } else { - fprintf(stderr, "[video:%u] FIFO pipe size increased to %dMB\n", ps->port, pipe_sz / (1024*1024)); } } @@ -407,13 +387,6 @@ static void *video_thread(void *arg) { } } VHD_UnlockSlotHandle(slot); - static __thread unsigned long processed = 0; - if (++processed % 60 == 0) { - ULONG sc = 0, sd = 0; - VHD_GetStreamProperty(ps->video_stream, VHD_CORE_SP_SLOTS_COUNT, &sc); - VHD_GetStreamProperty(ps->video_stream, VHD_CORE_SP_SLOTS_DROPPED, &sd); - fprintf(stderr, "[video:%u] locked=%lu (sc=%lu, sd=%lu)\n", ps->port, processed, sc, sd); - } } else if (r != VHDERR_TIMEOUT) { fprintf(stderr, "[video:%u] VHD_LockSlotHandle error %lu — stopping port\n", ps->port, r);