"""Data Transfer Objects for audio capture.

Define data structures used by audio capture components.
"""

from collections.abc import Callable
from dataclasses import dataclass

import numpy as np
from numpy.typing import NDArray


@dataclass(frozen=True)
class AudioDeviceInfo:
    """Information about an audio input device."""

    device_id: int
    name: str
    channels: int
    sample_rate: int
    is_default: bool


@dataclass
class TimestampedAudio:
    """Audio frames with capture timestamp."""

    frames: NDArray[np.float32]
    timestamp: float  # Monotonic time when captured
    duration: float  # Duration in seconds

    def __post_init__(self) -> None:
        """Validate audio data."""
        if self.duration < 0:
            raise ValueError("Duration must be non-negative")
        if self.timestamp < 0:
            raise ValueError("Timestamp must be non-negative")


# Type alias for audio frame callback
AudioFrameCallback = Callable[[NDArray[np.float32], float], None]
