From a200cabad4ce794a12cf7eb1c49a92eb6854d2a4 Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Tue, 2 Jun 2026 14:21:44 -0400 Subject: [PATCH] fix(deltacast-bridge): pin buffer packing + sdi interface + f_setpipe_sz --- services/capture/deltacast-bridge/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/services/capture/deltacast-bridge/main.c b/services/capture/deltacast-bridge/main.c index 7adfaa9..5675eb7 100644 --- a/services/capture/deltacast-bridge/main.c +++ b/services/capture/deltacast-bridge/main.c @@ -228,6 +228,10 @@ static void *audio_thread(void *arg) { 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(). */ struct timespec next; @@ -311,6 +315,14 @@ static void *video_thread(void *arg) { continue; } fprintf(stderr, "[video:%u] FIFO writer connected\n", ps->port); + #ifndef F_SETPIPE_SZ + #define F_SETPIPE_SZ 1031 + #endif + if (fcntl(fd, F_SETPIPE_SZ, 8 * 1024 * 1024) < 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 8MB\n", ps->port); + } HANDLE slot = NULL; int fatal = 0; @@ -336,6 +348,13 @@ 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); @@ -575,6 +594,11 @@ int main(int argc, char *argv[]) { VHD_SetStreamProperty(vs, VHD_SDI_SP_CLOCK_SYSTEM, p->clock_div); VHD_SetStreamProperty(vs, VHD_CORE_SP_TRANSFER_SCHEME, VHD_TRANSFER_SLAVED); VHD_SetStreamProperty(vs, VHD_CORE_SP_BUFFERQUEUE_DEPTH, 8); + ULONG iface = 0; + if (VHD_GetStreamProperty(vs, VHD_SDI_SP_INTERFACE, &iface) == VHDERR_NOERROR) { + VHD_SetStreamProperty(vs, VHD_SDI_SP_INTERFACE, iface); + fprintf(stderr, "[board] port %u explicitly set SDI Interface to %lu\n", ports[pi], iface); + } /* Pin to tightly-packed 8-bit UYVY. Relying on SDK default caused * the board to deliver frames whose size != width*height*2, * producing rolled/sheared ("bouncing and bending") video. */