mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-27 00:17:32 +00:00
Phase 5 (D1): move RX audio routing into the controller
OnAudioReady moves from MainForm into TRadioController (radio-speaker push + local AudioOut). The web steal becomes a route hook: controller fires OnAudioConsume; TWebAdapter.AudioConsume mixes to mono and pushes to the web client, returning True to skip local AudioOut. Behavior-preserving; removes the last audio-path coupling to MainForm. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
682025e99b
commit
7c8fd298ae
+4
-22
@@ -336,7 +336,6 @@ type
|
||||
procedure DoStopAndDisconnect;
|
||||
|
||||
// DSP/Audio callbacks (вызываются из рабочих потоков)
|
||||
procedure OnAudioReady(const Left, Right: array of Single; Count: Integer);
|
||||
procedure OnSpectrumReady(const Pixels: array of Single; Count: Integer);
|
||||
procedure OnWaterfallReady(const Pixels: array of Single; Count: Integer);
|
||||
|
||||
@@ -982,10 +981,12 @@ begin
|
||||
|
||||
// DSP Engine.Open (загрузка libwdsp, ~1-2 сек) вызывается при нажатии START.
|
||||
FController.FWDSPReady := False;
|
||||
FController.FDSPEngine.OnAudio := OnAudioReady;
|
||||
FController.FDSPEngine.OnAudio := FController.OnAudioReady;
|
||||
FController.FDSPEngine.OnSpectrum := OnSpectrumReady;
|
||||
FController.FDSPEngine.OnWaterfall := OnWaterfallReady;
|
||||
FController.FDSPEngine.OnTXIQ := FController.OnTXIQ;
|
||||
// Web-клиент перехватывает RX-аудио (моно-микс) у контроллера, если подключён.
|
||||
FController.OnAudioConsume := FWebAdapter.AudioConsume;
|
||||
// Sound-card mic путь: WDSP TX-thread дёргает этот колбэк перед каждым
|
||||
// тиком, если выбран источник SoundCard. Для Radio колбэк не вызывается.
|
||||
FController.FDSPEngine.OnPullMicSamples := FController.PullSoundCardMic;
|
||||
@@ -3206,7 +3207,7 @@ begin
|
||||
end;
|
||||
FController.FWDSPReady := False;
|
||||
FController.FDSPEngine := TWDSPEngine.Create(ASampleRate, 48000, 512);
|
||||
FController.FDSPEngine.OnAudio := OnAudioReady;
|
||||
FController.FDSPEngine.OnAudio := FController.OnAudioReady;
|
||||
FController.FDSPEngine.OnSpectrum := OnSpectrumReady;
|
||||
FController.FDSPEngine.OnWaterfall := OnWaterfallReady;
|
||||
FController.FDSPEngine.OnTXIQ := FController.OnTXIQ;
|
||||
@@ -5179,25 +5180,6 @@ end;
|
||||
// DSP/Audio callbacks — вызываются из рабочих потоков
|
||||
// ===========================================================================
|
||||
|
||||
procedure TMainForm.OnAudioReady(const Left, Right: array of Single;
|
||||
Count: Integer);
|
||||
var
|
||||
MonoBuf: array[0..1023] of Single;
|
||||
i: Integer;
|
||||
begin
|
||||
// Дублируем RX-аудио во встроенный динамик трансивера (DDC Audio, port 1028).
|
||||
if FController.FSendAudioToRadio then
|
||||
FController.FNetwork.SendSpeakerAudio(Left, Right, Count);
|
||||
if Assigned(FWebServer) and FWebServer.WebClientActive then
|
||||
begin
|
||||
for i := 0 to Count - 1 do
|
||||
MonoBuf[i] := (Left[i] + Right[i]) * 0.5;
|
||||
FWebServer.PushAudio(@MonoBuf[0], Count);
|
||||
Exit;
|
||||
end;
|
||||
FController.FAudioOut.Write(Left, Right, Count);
|
||||
end;
|
||||
|
||||
procedure TMainForm.OnSpectrumReady(const Pixels: array of Single;
|
||||
Count: Integer);
|
||||
var
|
||||
|
||||
Reference in New Issue
Block a user