#!/Users/jje/JJ-PROJECTS/landr-master-live/.venv/bin/python
"""Print + log all I/O devices (debug)."""
from __future__ import annotations

import os
import sys
from pathlib import Path

_ROOT = Path(__file__).resolve().parent
os.chdir(_ROOT)
sys.path.insert(0, str(_ROOT))

import sounddevice as sd

from debug_ndjson import dbg


def main() -> None:
    lines = []
    for i, d in enumerate(sd.query_devices()):
        ins = d.get("max_input_channels", 0)
        outs = d.get("max_output_channels", 0)
        if ins or outs:
            lines.append(f"{i:3}  in={ins} out={outs}  {d['name']}")
    text = "\n".join(lines)
    print(text)
    dbg("route_report.py", "device list", {"lines": lines[:40], "count": len(lines)}, "H2", "pre")


if __name__ == "__main__":
    main()
