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 /// An audio consumer's decoder or output setup was refused before subscribing to its track.
9 #[error("audio decoder setup refused: {0}")]
10 UnsupportedConfig(String),
11
12 /// The requested configuration is outside what the codec or device supports,
13 /// e.g. a sample rate, channel count, or frame duration Opus can't encode, or a
14 /// capture format the microphone can't deliver. The
15 /// caller asked for something impossible; picking different settings fixes it.
16 /// This also covers a playout delay beyond the subscribed track's retention;
17 /// consumer decoder setup is tagged as [`Self::UnsupportedConfig`] instead.
18 #[error("unsupported audio configuration: {0}")]
19 Unsupported(String),
20
21 /// No audio device matched the requested selector, or the machine has no
22 /// default input. Retrying won't help until the device list changes;
23 /// `capture::devices` reports what is available.
24 #[error("audio device: {0}")]
25 Device(String),
26
27 /// The capture backend failed or delivered nothing: a denied permission, a
28 /// device that stopped mid-stream, or a host API error. The configuration may
29 /// be fine; the device or its permissions are not.
30 #[error("audio capture: {0}")]
31 Capture(String),
32
33 /// The playback backend failed: the output device could not be opened, or the
34 /// stream stopped and could not be restarted. The device or host API is at
35 /// fault, not the configuration; `playback::devices` reports what is
36 /// available.
37 #[error("audio playback: {0}")]
38 Playback(String),
39
40 /// Exclusive audio processing state is already owned by another live
41 /// capture or playback handle.
42 #[error("audio resource already in use: {0}")]
43 Busy(String),
44
45 /// The codec library failed for a reason the configuration does not explain,
46 /// such as an allocation or internal error. Other settings are no more likely
47 /// to work; the codec itself is at fault.
48 #[error("audio codec: {0}")]
49 Codec(String),
50
51 /// A packet could not be decoded: truncated, corrupt, or using a codec
52 /// feature this build doesn't implement. The stream itself may be fine, so a
53 /// consumer can log this one and read the next packet.
54 #[error("audio decode: {0}")]
55 Decode(String),
56
57 /// The input buffer was not aligned to its sample or frame size.
58 #[error("input buffer length {got} does not match expected {expected}")]
59 Misaligned {
60 /// The buffer length received, in the units the error's origin documents.
61 got: usize,
62 /// The buffer length the call accepts, in the units the error's origin documents.
63 expected: usize,
64 },
65
66 /// The sample-rate converter could not be constructed.
67 #[error("resample construction: {0}")]
68 ResamplerConstruction(String),
69
70 /// The sample-rate converter rejected an input buffer or ratio change.
71 #[error("resample: {0}")]
72 Resample(String),
73
74 /// hang catalog error.
75 #[error(transparent)]
76 Hang(#[from] hang::Error),
77
78 /// moq-mux container/transport error.
79 #[error(transparent)]
80 Mux(#[from] moq_mux::Error),
81
82 /// moq-net transport error.
83 #[error(transparent)]
84 Net(#[from] moq_net::Error),
85
86 /// Timestamp overflow.
87 #[error(transparent)]
88 TimeOverflow(#[from] moq_net::TimeOverflow),
89}