mirror of
https://github.com/smittix/intercept.git
synced 2026-07-05 16:18:12 -07:00
Fix waterfall crash on zoom by reusing WebSocket and adding USB release retry
Zooming caused "I/Q capture process exited immediately" because the client closed the WebSocket and opened a new one, racing with the old rtl_sdr process releasing the USB device. Now zoom/retune sends a start command on the existing WebSocket, and the server adds a USB release delay plus retry loop when restarting capture within the same connection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3250,6 +3250,26 @@ async function syncWaterfallToFrequency(freq, options = {}) {
|
||||
if (isDirectListening || waterfallMode === 'audio') return { started: false };
|
||||
|
||||
if (isWaterfallRunning && waterfallMode === 'rf' && restartIfRunning) {
|
||||
// Reuse existing WebSocket to avoid USB device release race
|
||||
if (waterfallUseWebSocket && waterfallWebSocket && waterfallWebSocket.readyState === WebSocket.OPEN) {
|
||||
const sf = parseFloat(document.getElementById('waterfallStartFreq')?.value || 88);
|
||||
const ef = parseFloat(document.getElementById('waterfallEndFreq')?.value || 108);
|
||||
const fft = parseInt(document.getElementById('waterfallFftSize')?.value || document.getElementById('waterfallBinSize')?.value || 1024);
|
||||
const g = parseInt(document.getElementById('waterfallGain')?.value || 40);
|
||||
const dev = typeof getSelectedDevice === 'function' ? getSelectedDevice() : 0;
|
||||
waterfallWebSocket.send(JSON.stringify({
|
||||
cmd: 'start',
|
||||
center_freq: (sf + ef) / 2,
|
||||
span_mhz: Math.max(0.1, ef - sf),
|
||||
gain: g,
|
||||
device: dev,
|
||||
sdr_type: (typeof getSelectedSdrType === 'function') ? getSelectedSdrType() : 'rtlsdr',
|
||||
fft_size: fft,
|
||||
fps: 25,
|
||||
avg_count: 4,
|
||||
}));
|
||||
return { started: true };
|
||||
}
|
||||
await stopWaterfall();
|
||||
return await startWaterfall({ silent: silent });
|
||||
}
|
||||
@@ -3275,8 +3295,28 @@ async function zoomWaterfall(direction) {
|
||||
setWaterfallRange(center, newSpan);
|
||||
|
||||
if (isWaterfallRunning && waterfallMode === 'rf' && !isDirectListening) {
|
||||
await stopWaterfall();
|
||||
await startWaterfall({ silent: true });
|
||||
// Reuse existing WebSocket to avoid USB device release race
|
||||
if (waterfallUseWebSocket && waterfallWebSocket && waterfallWebSocket.readyState === WebSocket.OPEN) {
|
||||
const sf = parseFloat(document.getElementById('waterfallStartFreq')?.value || 88);
|
||||
const ef = parseFloat(document.getElementById('waterfallEndFreq')?.value || 108);
|
||||
const fft = parseInt(document.getElementById('waterfallFftSize')?.value || document.getElementById('waterfallBinSize')?.value || 1024);
|
||||
const g = parseInt(document.getElementById('waterfallGain')?.value || 40);
|
||||
const dev = typeof getSelectedDevice === 'function' ? getSelectedDevice() : 0;
|
||||
waterfallWebSocket.send(JSON.stringify({
|
||||
cmd: 'start',
|
||||
center_freq: (sf + ef) / 2,
|
||||
span_mhz: Math.max(0.1, ef - sf),
|
||||
gain: g,
|
||||
device: dev,
|
||||
sdr_type: (typeof getSelectedSdrType === 'function') ? getSelectedSdrType() : 'rtlsdr',
|
||||
fft_size: fft,
|
||||
fps: 25,
|
||||
avg_count: 4,
|
||||
}));
|
||||
} else {
|
||||
await stopWaterfall();
|
||||
await startWaterfall({ silent: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user