Optimize web audio mic path: remove redundant copy and heap alloc

WebOnMic: drop intermediate Singles[] array, read PSingle directly.
PushAudio: replace per-frame SetLength/array of Byte with pre-allocated
FWsAudioBuf field — eliminates heap allocation from the DSP thread.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-21 18:31:48 +03:00
co-authored by Claude Sonnet 4.6
parent 960cadd4b0
commit cd9e504e8f
2 changed files with 12 additions and 10 deletions
+8 -5
View File
@@ -6135,16 +6135,19 @@ end;
procedure TMainForm.WebOnMic(Samples: PSingle; Count: Integer);
var
Singles: array[0..5759] of Single;
Buf: array[0..5759] of Double;
i, n: Integer;
Buf: array[0..5759] of Double;
SP: PSingle;
i, n: Integer;
begin
if not FWDSPReady then Exit;
n := Count;
if n > Length(Buf) then n := Length(Buf);
Move(Samples^, Singles[0], n * SizeOf(Single));
SP := Samples;
for i := 0 to n - 1 do
Buf[i] := Singles[i];
begin
Buf[i] := SP^;
Inc(SP);
end;
FDSPEngine.PushTXMicSamplesD(Buf, n);
end;