Add managed Windows remote audio stack

This commit is contained in:
2026-09-20 17:26:36 +01:00
commit baa48c10b6
9 changed files with 650 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
$ErrorActionPreference = 'Stop'
. (Join-Path $PSScriptRoot '..\deps.ps1')
$originalManifest = $script:depsManifest
$originalDownloadDir = $script:depsDownloadDir
$originalInstallDir = $script:depsInstallDir
$testRoot = Join-Path $script:depsProjectRoot ('.runtime\bootstrap-test-' + [guid]::NewGuid().ToString('n'))
try {
$script:depsDownloadDir = Join-Path $testRoot 'downloads'
$script:depsInstallDir = Join-Path $testRoot 'deps'
$source = Join-Path $testRoot 'source'
New-Item -ItemType Directory -Force -Path $source, $script:depsDownloadDir | Out-Null
Set-Content -LiteralPath (Join-Path $source 'jacktrip.exe') -Value 'test fixture'
$zip = Join-Path $script:depsDownloadDir 'fixture.zip'
Compress-Archive -LiteralPath (Join-Path $source 'jacktrip.exe') -DestinationPath $zip
$script:depsManifest = [pscustomobject]@{
jacktrip = [pscustomobject]@{
version = 'test'
file = 'fixture.zip'
url = 'https://invalid.example/fixture.zip'
sha256 = (Get-FileHash -LiteralPath $zip -Algorithm SHA256).Hash.ToLowerInvariant()
}
}
$resolved = Install-ManagedJackTrip
if (-not (Test-Path -LiteralPath $resolved -PathType Leaf)) { throw 'JackTrip extraction failed' }
if (-not $resolved.StartsWith($script:depsInstallDir, [StringComparison]::OrdinalIgnoreCase)) { throw 'JackTrip path escaped dependency directory' }
Write-Host 'Bootstrap cache verification and extraction OK'
} finally {
$script:depsManifest = $originalManifest
$script:depsDownloadDir = $originalDownloadDir
$script:depsInstallDir = $originalInstallDir
$runtimeRoot = [System.IO.Path]::GetFullPath((Join-Path $script:depsProjectRoot '.runtime')).TrimEnd('\') + '\'
$testPath = [System.IO.Path]::GetFullPath($testRoot)
if (-not $testPath.StartsWith($runtimeRoot, [StringComparison]::OrdinalIgnoreCase)) { throw 'Refusing to remove test files outside .runtime' }
if (Test-Path -LiteralPath $testPath) { Remove-Item -LiteralPath $testPath -Recurse -Force }
}
+22
View File
@@ -0,0 +1,22 @@
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
. (Join-Path $root 'audio.ps1') status
Initialize-JobApi
New-Item -ItemType Directory -Force -Path (Join-Path $root '.runtime\logs') | Out-Null
$job = [AudioJob]::CreateKillOnCloseJob()
try {
$powershell = Join-Path $env:SystemRoot 'System32\WindowsPowerShell\v1.0\powershell.exe'
$child = Start-ManagedProcess 'power-policy-test' $powershell @('-NoProfile', '-Command', 'Start-Sleep -Seconds 30') $job 'Normal' $false $true
$state = New-Object AudioJob+PowerThrottlingState
$state.Version = 1
if (-not [AudioJob]::GetProcessInformation($child.Handle, 4, [ref]$state, 12)) {
throw "GetProcessInformation failed: $([Runtime.InteropServices.Marshal]::GetLastWin32Error())"
}
if ($state.ControlMask -ne 5 -or $state.StateMask -ne 0) {
throw "Unexpected power policy: ControlMask=$($state.ControlMask), StateMask=$($state.StateMask)"
}
Write-Host 'Per-process power policy applied and verified.'
} finally {
[void][AudioJob]::CloseHandle($job)
}