diff --git a/services/capture/src/capture-manager.js b/services/capture/src/capture-manager.js index 0149656..bab7902 100644 --- a/services/capture/src/capture-manager.js +++ b/services/capture/src/capture-manager.js @@ -201,8 +201,13 @@ class CaptureManager { const audioFifo = `/tmp/dc-audio-${this._sessionIdForBridge}`; // Create the audio FIFO before spawning the bridge. - const { execSync: _exec } = await import('child_process'); - try { _exec(`mkfifo ${audioFifo}`); } catch (_) { /* may already exist */ } + const { execFileSync: _execFile } = await import('child_process'); + const { unlinkSync: _unlink, existsSync: _exists } = await import('node:fs'); + // Remove any stale FIFO or file from a prior crashed session + if (_exists(audioFifo)) { try { _unlink(audioFifo); } catch (_) {} } + try { _execFile('mkfifo', [audioFifo]); } catch (e) { + throw new Error(`Failed to create audio FIFO ${audioFifo}: ${e.message}`); + } const bridge = spawn('deltacast-capture', [ '--device', String(idx), @@ -211,14 +216,9 @@ class CaptureManager { '--signal-timeout', '30', ], { stdio: ['ignore', 'pipe', 'pipe'] }); - // Log bridge stderr after the first line (non-JSON diagnostic output) - let firstLineDone = false; - bridge.stderr.on('data', (d) => { - if (firstLineDone) console.error(`[deltacast-bridge] ${d}`); - else if (d.toString().includes('\n')) firstLineDone = true; - }); - const fmt = await readFirstStderrLine(bridge, 35_000); + // Log any subsequent bridge stderr (diagnostics, warnings) + bridge.stderr.on('data', (d) => console.error(`[deltacast-bridge] ${d.toString().trimEnd()}`)); // fmt: { width, height, fps_num, fps_den, interlaced, pix_fmt, // audio_channels, audio_rate, device, port } @@ -421,6 +421,14 @@ class CaptureManager { const processes = { hires: hiresProcess }; if (bridgeProcess) processes.bridge = bridgeProcess; + if (bridgeProcess) { + bridgeProcess.on('exit', (code) => { + if (code !== 0 && code !== null) { + console.error(`[deltacast-bridge] exited with code ${code}`); + this.state.lastError = `deltacast bridge exited: code ${code}`; + } + }); + } const uploads = { hires: hiresUpload }; // ── HLS tee for network sources (live preview in the UI) ──────────