"""Audio device API endpoints."""

import logging

from fastapi import APIRouter, Depends

from ..auth import verify_token
from ..services import get_audio_devices

logger = logging.getLogger(__name__)

router = APIRouter(prefix="/api/audio", tags=["audio"])


@router.get("/devices")
async def list_audio_devices(_: str = Depends(verify_token)) -> list[dict[str, str]]:
    """List available audio output devices.

    Returns a list of audio devices with their IDs and friendly names.
    Use the device name in the `audio_device` config option to control
    a specific device instead of the default one.

    Returns:
        List of audio devices with id and name
    """
    devices = get_audio_devices()
    logger.debug("Found %d audio devices", len(devices))
    return devices
