Skip to main content

moq_audio/
error.rs

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