fix(capture): shell injection, stale FIFO, stderr listener, bridge exit handler
This commit is contained in:
parent
adfbeac217
commit
b46abc9b1a
1 changed files with 17 additions and 9 deletions
|
|
@ -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) ──────────
|
||||
|
|
|
|||
Loading…
Reference in a new issue