Files
foo_input_joc/tools/build_tests.ps1
T
TheM14 43b16687cc
build / windows (push) Canceled after 0s
build / release (push) Canceled after 0s
Add a side/rear channel swap for speaker output
Some receivers and players expect the side pair (Ls/Rs) where the renderer puts
the rear pair (Lrs/Rrs) and the other way round, and the layouts here follow the
reference table, so the delivered PCM cannot match both. The new preference does
the reorder on the way out: Ls with Lrs, Rs with Rrs, everything else untouched.

Which channels to move is decided by name in the layout table, not by channel
count. 7.1, 7.1.2, 7.1.4, 9.1.4 and 9.1.6 carry both pairs; 5.1.2 and 5.1.4 fill
the last two slots with top channels and are left alone, and a layout that has no
rear pair makes the swap a no-op. The decoder only enables it when the layout the
core rendered is the one being delivered, so a binaural stream is never touched.

The reorder happens once per read, before the float32 and the forced int24
delivery branch, so both formats carry it and the peak and clip accounting see the
same samples as before. Decoding, object positions, the layout table and the
rendering itself are unchanged.

channel_swap_test checks the layout selection, the reorder, its inverse and the
int24 packing order. The render harness gained --swap-side-rear and the text fit
check now measures the new label in both languages.

Verified on a 7.1 render: only channels 5-8 change, 5<->7 and 6<->8 byte-exactly,
with float32 and int24 alike; a 5.1.2 render is identical with the switch on.
2026-11-01 23:53:54 +08:00

62 lines
3.6 KiB
PowerShell

# Builds the headless test tools.
#
# pwsh -File tools/build_tests.ps1 # x64 (matches the core's own build)
# pwsh -File tools/build_tests.ps1 -Platform Win32 # x86 (the architecture foobar2000 1.6 uses)
#
# They link the kernel archive that the component itself links
# (kernel\joc_kernel.vcxproj -> build\kernel-<Platform>\joc_kernel.lib), so what
# they exercise is the same code the component plays with.
[CmdletBinding()]
param(
[ValidateSet('Win32', 'x64')][string]$Platform = 'x64'
)
$ErrorActionPreference = 'Stop'
$projectRoot = Split-Path -Parent $PSScriptRoot
$vsRoot = 'C:\Program Files\Microsoft Visual Studio\2022\Community'
$vcvars = if ($Platform -eq 'x64') {
Join-Path $vsRoot 'VC\Auxiliary\Build\vcvars64.bat'
} else {
Join-Path $vsRoot 'VC\Auxiliary\Build\vcvars32.bat'
}
$coreLib = Join-Path $projectRoot "build\kernel-$Platform\joc_kernel.lib"
foreach ($tool in @($vcvars, $coreLib)) {
if (-not (Test-Path -LiteralPath $tool)) {
throw "missing: $tool (build kernel\joc_kernel.vcxproj for $Platform first)"
}
}
$outDir = Join-Path $projectRoot "build\tests-$Platform"
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
$bat = Join-Path $outDir 'build.bat'
# JOC_STATIC / EJOC_STATIC: the kernel headers must not decorate their entry
# points as imported, because the tools link the archive directly.
$common = "/nologo /std:c++20 /EHsc /O2 /MT /W4 /utf-8 /D_CRT_SECURE_NO_WARNINGS /DJOC_STATIC /DEJOC_STATIC /I src /I kernel\include /I kernel\src"
$lines = @(
'@echo off',
"call `"$vcvars`" >nul",
"cd /d `"$projectRoot`"",
# log.cpp comes along because the engine writes its diagnostics through it.
"cl $common /Fe:`"$outDir\container_scan_test.exe`" /Fo:`"$outDir\\`" tests\container_scan_test.cpp src\container_scan.cpp src\log.cpp",
"cl $common /Fe:`"$outDir\log_rotation_test.exe`" /Fo:`"$outDir\\`" tests\log_rotation_test.cpp src\log.cpp",
"cl $common /Fe:`"$outDir\long_path_test.exe`" /Fo:`"$outDir\\`" tests\long_path_test.cpp src\container_scan.cpp src\joc_decode.cpp src\eac3_scan.cpp src\log.cpp `"$coreLib`" shell32.lib",
"cl $common /Fe:`"$outDir\scan_selftest.exe`" /Fo:`"$outDir\\`" tests\scan_selftest.cpp src\eac3_scan.cpp",
"cl $common /Fe:`"$outDir\prefs_layout_check.exe`" /Fo:`"$outDir\\`" tests\prefs_layout_check.cpp user32.lib gdi32.lib",
"cl $common /Fe:`"$outDir\scan_crosscheck.exe`" /Fo:`"$outDir\\`" tests\scan_crosscheck.cpp src\eac3_scan.cpp `"$coreLib`" shell32.lib",
"cl $common /Fe:`"$outDir\render_harness.exe`" /Fo:`"$outDir\\`" tests\render_harness.cpp src\joc_decode.cpp src\eac3_scan.cpp src\container_scan.cpp src\log.cpp `"$coreLib`" shell32.lib",
"cl $common /Fe:`"$outDir\layout_table_test.exe`" /Fo:`"$outDir\\`" tests\layout_table_test.cpp src\joc_decode.cpp src\eac3_scan.cpp src\container_scan.cpp src\log.cpp `"$coreLib`" shell32.lib",
"cl $common /Fe:`"$outDir\channel_swap_test.exe`" /Fo:`"$outDir\\`" tests\channel_swap_test.cpp src\joc_decode.cpp src\eac3_scan.cpp src\container_scan.cpp src\log.cpp `"$coreLib`" shell32.lib",
"cl $common /Fe:`"$outDir\ui_text_fit_test.exe`" /Fo:`"$outDir\\`" tests\ui_text_fit_test.cpp src\lang.cpp src\joc_decode.cpp src\eac3_scan.cpp src\container_scan.cpp src\log.cpp `"$coreLib`" shell32.lib user32.lib gdi32.lib",
'if errorlevel 1 exit /b 1',
'exit /b 0'
)
Set-Content -LiteralPath $bat -Value $lines -Encoding ASCII
& cmd /c $bat
if ($LASTEXITCODE -ne 0) { throw "test build failed with exit code $LASTEXITCODE" }
Get-ChildItem $outDir -Filter '*.exe' | ForEach-Object {
Write-Host ("built {0} ({1} bytes)" -f $_.Name, $_.Length) -ForegroundColor Green
}