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	/// The input buffer was not aligned to the codec's frame size.
31	#[error("input buffer length {got} bytes does not match expected {expected}")]
32	Misaligned {
33		/// The buffer length received, in bytes.
34		got: usize,
35		/// The buffer length required, in bytes.
36		expected: usize,
37	},
38
39	/// Rubato resampler construction error.
40	#[error("resample construction: {0}")]
41	ResamplerConstruction(#[from] rubato::ResamplerConstructionError),
42
43	/// Rubato resampler runtime error.
44	#[error("resample: {0}")]
45	Resample(#[from] rubato::ResampleError),
46
47	/// hang catalog error.
48	#[error(transparent)]
49	Hang(#[from] hang::Error),
50
51	/// moq-mux container/transport error.
52	#[error(transparent)]
53	Mux(#[from] moq_mux::Error),
54
55	/// moq-net transport error.
56	#[error(transparent)]
57	Net(#[from] moq_net::Error),
58
59	/// Timestamp overflow.
60	#[error(transparent)]
61	TimeOverflow(#[from] moq_net::TimeOverflow),
62}