Skip to main content

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	/// Exclusive audio processing state is already owned by another live
34	/// capture or playback handle.
35	#[error("audio resource already in use: {0}")]
36	Busy(String),
37
38	/// A packet could not be decoded: truncated, corrupt, or using a codec
39	/// feature this build doesn't implement. The stream itself may be fine, so a
40	/// consumer can log this one and read the next packet.
41	#[error("audio decode: {0}")]
42	Decode(String),
43
44	/// The input buffer was not aligned to the codec's frame size.
45	#[error("input buffer length {got} bytes does not match expected {expected}")]
46	Misaligned {
47		/// The buffer length received, in bytes.
48		got: usize,
49		/// The buffer length required, in bytes.
50		expected: usize,
51	},
52
53	/// The sample-rate converter could not be constructed.
54	#[error("resample construction: {0}")]
55	ResamplerConstruction(String),
56
57	/// The sample-rate converter rejected an input buffer or ratio change.
58	#[error("resample: {0}")]
59	Resample(String),
60
61	/// hang catalog error.
62	#[error(transparent)]
63	Hang(#[from] hang::Error),
64
65	/// moq-mux container/transport error.
66	#[error(transparent)]
67	Mux(#[from] moq_mux::Error),
68
69	/// moq-net transport error.
70	#[error(transparent)]
71	Net(#[from] moq_net::Error),
72
73	/// Timestamp overflow.
74	#[error(transparent)]
75	TimeOverflow(#[from] moq_net::TimeOverflow),
76}