Files
cinema-spatial/work/看声卡route.py
T

46 lines
1.6 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
"""打印指定声卡的 profile/route 原始参数(排查"数字/模拟输出"响度差).
用法: python3 看声卡route.py [设备名关键字]
"""
from __future__ import annotations
import json
import subprocess
import sys
from typing import Any
def main() -> None:
key = (sys.argv[1] if len(sys.argv) > 1 else "edifier").lower()
d = json.loads(subprocess.run(["pw-dump"], capture_output=True, text=True).stdout)
for o in d:
if o.get("type") != "PipeWire:Interface:Device":
continue
p = o.get("info", {}).get("props", {})
blob = json.dumps(p, ensure_ascii=False).lower()
if key not in blob:
continue
print(f"### 设备 id={o['id']} {p.get('device.description','')}")
print(f" node.name = {p.get('node.name','')}")
print(f" api.alsa.card = {p.get('api.alsa.card.name','')}")
prms = o.get("info", {}).get("params", {})
for section in ("Profile", "EnumProfile", "Route", "EnumRoute"):
items = prms.get(section) or []
if not items:
continue
print(f"\n[{section}] ({len(items)} 项)")
for it in items:
keep: dict[str, Any] = {}
for k, v in it.items():
if k in ("props", "profiles", "devices", "volume", "channelVolumes",
"index", "device", "save", "available", "availability",
"priority", "name", "description"):
keep[k] = v
print(" " + json.dumps(keep, ensure_ascii=False)[:400])
if __name__ == "__main__":
main()