moq_audio/error.rs
1/// Errors returned by `moq-audio`.
2///
3/// `Clone` so a failure can be reported to more than one observer, matching
4/// `hang::Error`, `moq_mux::Error`, and `moq_net::Error`.
5#[derive(Clone, Debug, thiserror::Error)]
6#[non_exhaustive]
7pub enum Error {
8 /// The requested configuration is outside what the codec supports, e.g. a
9 /// sample rate, channel count, or frame duration Opus can't encode. The
10 /// caller asked for something impossible; picking different settings fixes it.
11 #[error("unsupported audio configuration: {0}")]
12 Unsupported(String),
13
14 /// No audio device matched the requested selector, or the machine has no
15 /// default input. Retrying won't help until the device list changes;
16 /// `capture::devices` reports what is available.
17 #[error("audio device: {0}")]
18 Device(String),
19
20 /// The capture backend failed or delivered nothing: a denied permission, a
21 /// device that stopped mid-stream, or a host API error. The configuration may
22 /// be fine; the device or its permissions are not.
23 #[error("audio capture: {0}")]
24 Capture(String),
25
26 /// The playback backend failed: the output device could not be opened, or the
27 /// stream stopped and could not be restarted. The device or host API is at
28 /// fault, not the configuration; `playback::devices` reports what is
29 /// available.
30 #[error("audio playback: {0}")]
31 Playback(String),
32
33 /// A packet could not be decoded: truncated, corrupt, or using a codec
34 /// feature this build doesn't implement. The stream itself may be fine, so a
35 /// consumer can log this one and read the next packet.
36 #[error("audio decode: {0}")]
37 Decode(String),
38
39 /// The input buffer was not aligned to the codec's frame size.
40 #[error("input buffer length {got} bytes does not match expected {expected}")]
41 Misaligned {
42 /// The buffer length received, in bytes.
43 got: usize,
44 /// The buffer length required, in bytes.
45 expected: usize,
46 },
47
48 /// Rubato resampler construction error.
49 #[error("resample construction: {0}")]
50 ResamplerConstruction(#[from] rubato::ResamplerConstructionError),
51
52 /// Rubato resampler runtime error.
53 #[error("resample: {0}")]
54 Resample(#[from] rubato::ResampleError),
55
56 /// hang catalog error.
57 #[error(transparent)]
58 Hang(#[from] hang::Error),
59
60 /// moq-mux container/transport error.
61 #[error(transparent)]
62 Mux(#[from] moq_mux::Error),
63
64 /// moq-net transport error.
65 #[error(transparent)]
66 Net(#[from] moq_net::Error),
67
68 /// Timestamp overflow.
69 #[error(transparent)]
70 TimeOverflow(#[from] moq_net::TimeOverflow),
71}