mirror of
https://github.com/smittix/intercept.git
synced 2026-04-27 16:20:02 -07:00
Fix monitor retune when frequency changes during startup
This commit is contained in:
@@ -2763,6 +2763,7 @@ const Waterfall = (function () {
|
|||||||
_resumeWaterfallAfterMonitor = !!wasRunningWaterfall;
|
_resumeWaterfallAfterMonitor = !!wasRunningWaterfall;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const liveCenterMhz = _currentCenter();
|
||||||
// Keep an explicit pending tune target so retunes cannot fall
|
// Keep an explicit pending tune target so retunes cannot fall
|
||||||
// back to a stale frequency during capture restart churn.
|
// back to a stale frequency during capture restart churn.
|
||||||
const requestedTuneMhz = Number.isFinite(_pendingMonitorTuneMhz)
|
const requestedTuneMhz = Number.isFinite(_pendingMonitorTuneMhz)
|
||||||
@@ -2770,11 +2771,11 @@ const Waterfall = (function () {
|
|||||||
: (
|
: (
|
||||||
Number.isFinite(_pendingCaptureVfoMhz)
|
Number.isFinite(_pendingCaptureVfoMhz)
|
||||||
? _pendingCaptureVfoMhz
|
? _pendingCaptureVfoMhz
|
||||||
: (Number.isFinite(_monitorFreqMhz) ? _monitorFreqMhz : _currentCenter())
|
: (Number.isFinite(_monitorFreqMhz) ? _monitorFreqMhz : liveCenterMhz)
|
||||||
);
|
);
|
||||||
const centerMhz = retuneOnly
|
const centerMhz = retuneOnly
|
||||||
? (Number.isFinite(requestedTuneMhz) ? requestedTuneMhz : _currentCenter())
|
? (Number.isFinite(liveCenterMhz) ? liveCenterMhz : requestedTuneMhz)
|
||||||
: _currentCenter();
|
: liveCenterMhz;
|
||||||
const mode = document.getElementById('wfMonitorMode')?.value || 'wfm';
|
const mode = document.getElementById('wfMonitorMode')?.value || 'wfm';
|
||||||
const squelch = parseInt(document.getElementById('wfMonitorSquelch')?.value, 10) || 0;
|
const squelch = parseInt(document.getElementById('wfMonitorSquelch')?.value, 10) || 0;
|
||||||
const sliderGain = parseInt(document.getElementById('wfMonitorGain')?.value, 10);
|
const sliderGain = parseInt(document.getElementById('wfMonitorGain')?.value, 10);
|
||||||
@@ -2795,6 +2796,8 @@ const Waterfall = (function () {
|
|||||||
_monitorFreqMhz = centerMhz;
|
_monitorFreqMhz = centerMhz;
|
||||||
} else if (Number.isFinite(centerMhz)) {
|
} else if (Number.isFinite(centerMhz)) {
|
||||||
_monitorFreqMhz = centerMhz;
|
_monitorFreqMhz = centerMhz;
|
||||||
|
_pendingMonitorTuneMhz = centerMhz;
|
||||||
|
_pendingCaptureVfoMhz = centerMhz;
|
||||||
}
|
}
|
||||||
_drawFreqAxis();
|
_drawFreqAxis();
|
||||||
_stopSmeter();
|
_stopSmeter();
|
||||||
@@ -2892,10 +2895,11 @@ const Waterfall = (function () {
|
|||||||
const attach = await _attachMonitorAudio(nonce, payload?.request_token);
|
const attach = await _attachMonitorAudio(nonce, payload?.request_token);
|
||||||
if (nonce !== _audioConnectNonce) return;
|
if (nonce !== _audioConnectNonce) return;
|
||||||
_monitorSource = payload?.source === 'waterfall' ? 'waterfall' : 'process';
|
_monitorSource = payload?.source === 'waterfall' ? 'waterfall' : 'process';
|
||||||
if (
|
const pendingTuneMismatch = (
|
||||||
Number.isFinite(_pendingMonitorTuneMhz)
|
Number.isFinite(_pendingMonitorTuneMhz)
|
||||||
&& Math.abs(_pendingMonitorTuneMhz - centerMhz) < 1e-6
|
&& Math.abs(_pendingMonitorTuneMhz - centerMhz) >= 1e-6
|
||||||
) {
|
);
|
||||||
|
if (!pendingTuneMismatch) {
|
||||||
_pendingMonitorTuneMhz = null;
|
_pendingMonitorTuneMhz = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2906,6 +2910,7 @@ const Waterfall = (function () {
|
|||||||
_setMonitorState(`Monitoring ${centerMhz.toFixed(4)} MHz ${mode.toUpperCase()} (audio locked)`);
|
_setMonitorState(`Monitoring ${centerMhz.toFixed(4)} MHz ${mode.toUpperCase()} (audio locked)`);
|
||||||
_setStatus('Monitor started but browser blocked playback. Click Unlock Audio.');
|
_setStatus('Monitor started but browser blocked playback. Click Unlock Audio.');
|
||||||
_setVisualStatus('MONITOR');
|
_setVisualStatus('MONITOR');
|
||||||
|
if (pendingTuneMismatch) _queueMonitorRetune(45);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2949,10 +2954,19 @@ const Waterfall = (function () {
|
|||||||
}
|
}
|
||||||
_setStatus(`Audio monitor active on ${displayMhz.toFixed(4)} MHz (${mode.toUpperCase()})`);
|
_setStatus(`Audio monitor active on ${displayMhz.toFixed(4)} MHz (${mode.toUpperCase()})`);
|
||||||
_setVisualStatus('MONITOR');
|
_setVisualStatus('MONITOR');
|
||||||
|
if (pendingTuneMismatch) {
|
||||||
|
_queueMonitorRetune(45);
|
||||||
|
}
|
||||||
// After a retune reconnect, sync the backend to the latest
|
// After a retune reconnect, sync the backend to the latest
|
||||||
// VFO in case the user clicked a new frequency while the
|
// VFO in case the user clicked a new frequency while the
|
||||||
// audio stream was reconnecting.
|
// audio stream was reconnecting.
|
||||||
if (retuneOnly && _monitorSource === 'waterfall' && _ws && _ws.readyState === WebSocket.OPEN) {
|
if (
|
||||||
|
!pendingTuneMismatch
|
||||||
|
&& retuneOnly
|
||||||
|
&& _monitorSource === 'waterfall'
|
||||||
|
&& _ws
|
||||||
|
&& _ws.readyState === WebSocket.OPEN
|
||||||
|
) {
|
||||||
_sendWsTuneCmd();
|
_sendWsTuneCmd();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user