Fix macOS pixel format: use ARGB byte order in all raw ScanLine blending

On macOS Cocoa, TBitmap.pf32bit stores pixels in ARGB order
   (byte0=A, byte1=R, byte2=G, byte3=B) rather than BGRA used on
   Linux/Windows. All raw ScanLine pixel blending and channel mapping
   is now guarded with { DARWIN} to use the correct offsets.

   Also fix PortAudio library discovery on macOS: probe .dylib names
   (including Homebrew paths) before falling through to .so/.dll.
This commit is contained in:
Uladzimir Karpenka
2026-05-28 21:47:54 +03:00
parent 4f127a30ad
commit a02d35fcce
8 changed files with 132 additions and 24 deletions
+15 -2
View File
@@ -163,14 +163,22 @@ function PaOutCallback(inputBuffer, outputBuffer: Pointer;
implementation
const
{$IFDEF UNIX}
{$IFDEF DARWIN}
PA_LIBS: array[0..3] of AnsiString = (
'libportaudio.dylib',
'libportaudio.2.dylib',
'/usr/local/lib/libportaudio.dylib',
'/opt/homebrew/lib/libportaudio.dylib'
);
{$ELSE}
{$IFDEF UNIX}
PA_LIBS: array[0..3] of AnsiString = (
'libportaudio.so.2',
'libportaudio.so',
'libportaudio.so.2.0.0',
'libportaudio.so.0'
);
{$ELSE}
{$ELSE}
PA_LIBS: array[0..5] of AnsiString = (
'portaudio_x64.dll',
'portaudio_x86.dll',
@@ -179,6 +187,7 @@ const
'libportaudio.dll',
'libportaudio64.dll'
);
{$ENDIF}
{$ENDIF}
PA_NO_ERROR = 0;
PA_FLOAT32 = LongWord(1);
@@ -292,7 +301,11 @@ begin
{$IFDEF WINDOWS}
FLastError := 'PortAudio DLL not found. Put portaudio_x64.dll, portaudio.dll, or libportaudio-2.dll next to ewsdr.exe';
{$ELSE}
{$IFDEF DARWIN}
FLastError := 'libportaudio not found. Install via: brew install portaudio';
{$ELSE}
FLastError := 'libportaudio not found. sudo apt install libportaudio2';
{$ENDIF}
{$ENDIF}
Exit;
end;