- 新增 collect_windows_audio_topology.ps1 (C1b) - 新增 collect_chromeos_audio_topology.sh (C1c) - README 标注 C1/C1a/C1b 完成,补充 C1c 说明与验证步骤 - audio_topology/README 补充 Windows/ChromeOS 用法与脚本验证说明 - 附一份 Windows 拓扑收集示例输出 Co-authored-by: Cursor <cursoragent@cursor.com>
200 lines
7.7 KiB
PowerShell
200 lines
7.7 KiB
PowerShell
#
|
|
# Chromebox 10 代 - Windows 音频硬件拓扑收集脚本
|
|
# 用于在 Windows 下收集与 Linux 脚本对应的硬件拓扑信息
|
|
#
|
|
# 用法: .\collect_windows_audio_topology.ps1 [-OutputPath "路径"]
|
|
# 默认输出到: audio_topology\collected\audio_topology_windows_<计算机名>_<日期时间>.txt
|
|
#
|
|
# 建议: 以管理员身份运行 PowerShell 可获取更完整的驱动与设备信息
|
|
|
|
param(
|
|
[string] $OutputPath = ""
|
|
)
|
|
|
|
$ErrorActionPreference = "Continue"
|
|
|
|
$ScriptDir = Split-Path -LiteralPath $MyInvocation.MyCommand.Path
|
|
$OutputDir = Join-Path $ScriptDir "collected"
|
|
if (-not (Test-Path $OutputDir)) { New-Item -ItemType Directory -Path $OutputDir | Out-Null }
|
|
|
|
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
|
|
$defaultName = "audio_topology_windows_$env:COMPUTERNAME`_$timestamp.txt"
|
|
$Output = if ($OutputPath) { $OutputPath } else { Join-Path $OutputDir $defaultName }
|
|
|
|
function Log {
|
|
param([string] $Message)
|
|
$t = Get-Date -Format "HH:mm:ss"
|
|
Write-Host "[$t] $Message"
|
|
}
|
|
|
|
function Section {
|
|
param([string] $Title)
|
|
"" | Out-File -FilePath $Output -Append -Encoding utf8
|
|
"========================================" | Out-File -FilePath $Output -Append -Encoding utf8
|
|
"### $Title" | Out-File -FilePath $Output -Append -Encoding utf8
|
|
"========================================" | Out-File -FilePath $Output -Append -Encoding utf8
|
|
"" | Out-File -FilePath $Output -Append -Encoding utf8
|
|
}
|
|
|
|
function Out-Block {
|
|
param(
|
|
[string] $Description,
|
|
[scriptblock] $ScriptBlock
|
|
)
|
|
"# $Description" | Out-File -FilePath $Output -Append -Encoding utf8
|
|
"``````" | Out-File -FilePath $Output -Append -Encoding utf8
|
|
try {
|
|
& $ScriptBlock | Out-File -FilePath $Output -Append -Encoding utf8
|
|
} catch {
|
|
"(Error: $_)" | Out-File -FilePath $Output -Append -Encoding utf8
|
|
}
|
|
"``````" | Out-File -FilePath $Output -Append -Encoding utf8
|
|
"" | Out-File -FilePath $Output -Append -Encoding utf8
|
|
}
|
|
|
|
Log "Collecting Windows audio topology..."
|
|
Log "Output: $Output"
|
|
|
|
# 清空并写头部
|
|
@"
|
|
# Chromebox 10 代 - Windows 音频硬件拓扑
|
|
# 收集时间: $(Get-Date -Format "yyyy-MM-ddTHH:mm:sszzz")
|
|
# 计算机: $env:COMPUTERNAME
|
|
# 用户: $env:USERNAME
|
|
|
|
"@ | Set-Content -Path $Output -Encoding utf8
|
|
|
|
# --- 系统信息 ---
|
|
Section "System Info"
|
|
Out-Block "OS and computer" {
|
|
if (Get-Command Get-ComputerInfo -ErrorAction SilentlyContinue) {
|
|
Get-ComputerInfo | Select-Object CsName, WindowsProductName, WindowsVersion, OsArchitecture, CsProcessors, CsNumberOfProcessors
|
|
} else {
|
|
[System.Environment]::OSVersion
|
|
"Computer: $env:COMPUTERNAME"
|
|
}
|
|
}
|
|
Out-Block "systeminfo" {
|
|
systeminfo 2>$null
|
|
}
|
|
|
|
# --- PCI/PNP 音频相关设备 (对应 Linux lspci) ---
|
|
Section "PCI/PnP Audio Devices"
|
|
Out-Block "PnP Media (sound/codec)" {
|
|
Get-PnpDevice -Class Media -ErrorAction SilentlyContinue | Format-Table -AutoSize Status, Class, FriendlyName, InstanceId
|
|
}
|
|
Out-Block "PnP AudioEndpoint" {
|
|
Get-PnpDevice -Class AudioEndpoint -ErrorAction SilentlyContinue | Format-Table -AutoSize Status, Class, FriendlyName, InstanceId
|
|
}
|
|
Out-Block "WMI Win32_SoundDevice" {
|
|
Get-WmiObject Win32_SoundDevice -ErrorAction SilentlyContinue | Format-List Name, Status, StatusInfo, DeviceID, Manufacturer, PNPDeviceID
|
|
}
|
|
Out-Block "WMI PnPEntity audio/sound/media" {
|
|
Get-WmiObject Win32_PnPEntity -ErrorAction SilentlyContinue | Where-Object {
|
|
$_.Name -match 'audio|sound|media|intel.*hda|realtek|codec'
|
|
} | Format-Table -AutoSize Status, Name, DeviceID
|
|
}
|
|
|
|
# --- 音频设备详细信息 (对应 ALSA cards/pcm) ---
|
|
Section "Audio Devices Detail"
|
|
Out-Block "Media devices and InstanceId" {
|
|
Get-PnpDevice -Class Media -ErrorAction SilentlyContinue | ForEach-Object {
|
|
"Status: $($_.Status) | Name: $($_.FriendlyName)"
|
|
" InstanceId: $($_.InstanceId)"
|
|
}
|
|
}
|
|
Out-Block "AudioEndpoint devices" {
|
|
Get-PnpDevice -Class AudioEndpoint -ErrorAction SilentlyContinue | ForEach-Object {
|
|
"Status: $($_.Status) | Name: $($_.FriendlyName)"
|
|
" InstanceId: $($_.InstanceId)"
|
|
}
|
|
}
|
|
Out-Block "HDMI/Display PnP (like Linux ELD)" {
|
|
Get-WmiObject Win32_PnPEntity -ErrorAction SilentlyContinue | Where-Object {
|
|
$_.Name -match 'HDMI|display|nvidia|amd|intel.*graphics'
|
|
} | Select-Object Name, Status, PNPDeviceID | Format-Table -AutoSize
|
|
}
|
|
|
|
# --- 驱动信息 (对应 Linux 驱动/模块) ---
|
|
Section "Audio Drivers"
|
|
Out-Block "Media devices and drivers" {
|
|
$media = Get-PnpDevice -Class Media -ErrorAction SilentlyContinue
|
|
$drivers = Get-WmiObject Win32_PnPSignedDriver -ErrorAction SilentlyContinue | Where-Object { $_.DeviceID }
|
|
foreach ($dev in $media) {
|
|
"Device: $($dev.FriendlyName) | Status: $($dev.Status)"
|
|
" InstanceId: $($dev.InstanceId)"
|
|
$match = $drivers | Where-Object { $_.DeviceID -eq $dev.InstanceId }
|
|
if ($match) {
|
|
" Driver: $($match.DriverName) | Version: $($match.DriverVersion) | Inf: $($match.InfName)"
|
|
}
|
|
""
|
|
}
|
|
}
|
|
Out-Block "pnputil enum drivers audio/sound" {
|
|
pnputil /enum-drivers 2>$null | Select-String -Pattern "audio|sound|media|intel|realtek|hda|\.inf" -Context 0,2
|
|
}
|
|
|
|
# --- 注册表音频类 (对应 /proc/asound 拓扑) ---
|
|
Section "Registry Audio Class"
|
|
$soundClassGuid = "{4d36e96c-e325-11ce-bfc1-08002be10318}"
|
|
Out-Block "HKLM Class Sound subkeys" {
|
|
$path = "HKLM:\SYSTEM\CurrentControlSet\Control\Class\$soundClassGuid"
|
|
if (Test-Path $path) {
|
|
Get-ChildItem $path -ErrorAction SilentlyContinue | ForEach-Object {
|
|
$sub = $_.PSChildName
|
|
if ($sub -match '^\d+$') {
|
|
$name = (Get-ItemProperty -Path $_.PSPath -Name DriverDesc -ErrorAction SilentlyContinue).DriverDesc
|
|
"Subkey: $sub -> $name"
|
|
}
|
|
}
|
|
} else {
|
|
"(Sound class registry path not found)"
|
|
}
|
|
}
|
|
|
|
# --- Windows 音频服务 (对应 PulseAudio/PipeWire) ---
|
|
Section "Windows Audio Services"
|
|
Out-Block "Audio-related services" {
|
|
Get-Service -ErrorAction SilentlyContinue | Where-Object {
|
|
$_.Name -match 'audio|Audiosrv|Winmgmt'
|
|
} | Format-Table Name, Status, DisplayName -AutoSize
|
|
}
|
|
Out-Block "Audiosrv service detail" {
|
|
Get-Service -Name Audiosrv -ErrorAction SilentlyContinue | Format-List *
|
|
}
|
|
|
|
# --- 主板/机器识别 (对应 Linux DMI) ---
|
|
Section "Board/System (DMI-like)"
|
|
Out-Block "WMI BaseBoard and ComputerSystem" {
|
|
Get-WmiObject Win32_BaseBoard -ErrorAction SilentlyContinue | Format-List Product, Manufacturer, SerialNumber
|
|
Get-WmiObject Win32_ComputerSystem -ErrorAction SilentlyContinue | Select-Object Manufacturer, Model, SystemFamily | Format-List
|
|
}
|
|
|
|
# --- 设备管理器导出 (与 WMI 声卡列表一致,便于对照) ---
|
|
Section "Device Manager Sound"
|
|
Out-Block "Win32_SoundDevice (list)" {
|
|
Get-WmiObject Win32_SoundDevice -ErrorAction SilentlyContinue | Format-List Name, Status, StatusInfo, DeviceID, Manufacturer, PNPDeviceID
|
|
}
|
|
|
|
# --- 系统事件日志中的音频/设备相关 (对应 dmesg) ---
|
|
Section "System Event Log (audio/device)"
|
|
Out-Block "Last 24h System log audio/device events" {
|
|
$hours = 24
|
|
$filter = @{
|
|
LogName = 'System'
|
|
StartTime = (Get-Date).AddHours(-$hours)
|
|
}
|
|
Get-WinEvent -FilterHashtable $filter -MaxEvents 500 -ErrorAction SilentlyContinue |
|
|
Where-Object { $_.Message -match 'audio|sound|driver|device|Intel|Realtek|HDA|Media' } |
|
|
Select-Object -First 30 TimeCreated, Id, Message |
|
|
ForEach-Object { "$($_.TimeCreated) [$($_.Id)] $($_.Message)" }
|
|
}
|
|
|
|
# --- DirectSound / 默认设备 (对应默认 sink) ---
|
|
Section "Default Audio (MMDevice)"
|
|
Out-Block "Note" {
|
|
"Default device: Settings -> System -> Sound or MMDevice API. This script lists PnP endpoints only."
|
|
}
|
|
|
|
Log "Done. Output: $Output"
|