mirror of
https://github.com/smittix/intercept.git
synced 2026-07-23 00:28:09 -07:00
Retry monitor audio starts after stale token responses
This commit is contained in:
@@ -1336,6 +1336,7 @@ def start_audio() -> Response:
|
|||||||
'message': 'Superseded audio start request',
|
'message': 'Superseded audio start request',
|
||||||
'source': audio_source,
|
'source': audio_source,
|
||||||
'superseded': True,
|
'superseded': True,
|
||||||
|
'current_token': audio_start_token,
|
||||||
}), 409
|
}), 409
|
||||||
audio_start_token = request_token
|
audio_start_token = request_token
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -2810,19 +2810,46 @@ const Waterfall = (function () {
|
|||||||
// Use live _monitorFreqMhz for retunes so that any user
|
// Use live _monitorFreqMhz for retunes so that any user
|
||||||
// clicks that changed the VFO during the async setup are
|
// clicks that changed the VFO during the async setup are
|
||||||
// picked up rather than overridden.
|
// picked up rather than overridden.
|
||||||
let { response, payload } = await _requestAudioStart({
|
const requestAudioStartResynced = async (deviceForRequest) => {
|
||||||
frequency: centerMhz,
|
let startResult = await _requestAudioStart({
|
||||||
modulation: mode,
|
frequency: centerMhz,
|
||||||
squelch,
|
modulation: mode,
|
||||||
gain,
|
squelch,
|
||||||
device: monitorDevice,
|
gain,
|
||||||
biasT,
|
device: deviceForRequest,
|
||||||
requestToken,
|
biasT,
|
||||||
});
|
requestToken,
|
||||||
|
});
|
||||||
|
const startPayload = startResult?.payload || {};
|
||||||
|
const isStale = startPayload.superseded === true || startPayload.status === 'stale';
|
||||||
|
if (isStale) {
|
||||||
|
const currentToken = Number(startPayload.current_token);
|
||||||
|
if (Number.isFinite(currentToken) && currentToken >= 0) {
|
||||||
|
startResult = await _requestAudioStart({
|
||||||
|
frequency: centerMhz,
|
||||||
|
modulation: mode,
|
||||||
|
squelch,
|
||||||
|
gain,
|
||||||
|
device: deviceForRequest,
|
||||||
|
biasT,
|
||||||
|
requestToken: currentToken + 1,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return startResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
let { response, payload } = await requestAudioStartResynced(monitorDevice);
|
||||||
if (nonce !== _audioConnectNonce) return;
|
if (nonce !== _audioConnectNonce) return;
|
||||||
|
|
||||||
const staleStart = payload?.superseded === true || payload?.status === 'stale';
|
const staleStart = payload?.superseded === true || payload?.status === 'stale';
|
||||||
if (staleStart) return;
|
if (staleStart) {
|
||||||
|
// If the backend still reports stale after token resync,
|
||||||
|
// schedule a fresh retune so monitor audio does not stay on
|
||||||
|
// an older station indefinitely.
|
||||||
|
if (_monitoring) _queueMonitorRetune(90);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const busy = payload?.error_type === 'DEVICE_BUSY' || (response.status === 409 && !staleStart);
|
const busy = payload?.error_type === 'DEVICE_BUSY' || (response.status === 409 && !staleStart);
|
||||||
if (
|
if (
|
||||||
busy
|
busy
|
||||||
@@ -2835,17 +2862,12 @@ const Waterfall = (function () {
|
|||||||
_resumeWaterfallAfterMonitor = true;
|
_resumeWaterfallAfterMonitor = true;
|
||||||
await _wait(220);
|
await _wait(220);
|
||||||
monitorDevice = selectedDevice;
|
monitorDevice = selectedDevice;
|
||||||
({ response, payload } = await _requestAudioStart({
|
({ response, payload } = await requestAudioStartResynced(monitorDevice));
|
||||||
frequency: centerMhz,
|
|
||||||
modulation: mode,
|
|
||||||
squelch,
|
|
||||||
gain,
|
|
||||||
device: monitorDevice,
|
|
||||||
biasT,
|
|
||||||
requestToken,
|
|
||||||
}));
|
|
||||||
if (nonce !== _audioConnectNonce) return;
|
if (nonce !== _audioConnectNonce) return;
|
||||||
if (payload?.superseded === true || payload?.status === 'stale') return;
|
if (payload?.superseded === true || payload?.status === 'stale') {
|
||||||
|
if (_monitoring) _queueMonitorRetune(90);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response.ok || payload.status !== 'started') {
|
if (!response.ok || payload.status !== 'started') {
|
||||||
|
|||||||
Reference in New Issue
Block a user