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