pub enum ResampleError {
Show 16 variants
Again,
SourceChanged {
expected_rate: u32,
expected_format: SampleFormat,
found_rate: u32,
found_format: SampleFormat,
},
AfterEof,
PlaneCount {
expected: usize,
found: usize,
},
SampleCount {
requested: usize,
},
UnsupportedRate {
end: SpecEnd,
rate: u32,
},
UnsupportedFormat {
end: SpecEnd,
},
UnsupportedLayout {
end: SpecEnd,
order: i32,
channels: i32,
},
TooManyPlanes {
end: SpecEnd,
channels: i32,
limit: i32,
},
TimestampOutOfRange {
pts: i64,
},
ChannelDropped {
source_channels: i32,
target_channels: i32,
channel: i32,
},
RematrixUnsupported {
source_channels: i32,
target_channels: i32,
},
TimestampOverflow {
pts: i64,
samples: i64,
},
Resample(Error),
OutputBuffer {
plane: usize,
},
QueueAlloc,
}resample only.Expand description
Errors from FfmpegResampler.
Variants§
Again
No converted frame is ready yet — send more input, or
send_eof and drain the tail.
This is the “needs more” signal, carried in the error type exactly
as
AudioStreamDecoder::receive_frame
carries it.
SourceChanged
A frame arrived whose shape is not the source spec this resampler was built with — the mid-stream refusal.
The face never silently reconfigures: doing so would resample the two halves of a stream on different terms and hand back a single unbroken timeline built out of them. Build a new resampler for the new source spec.
Fields
expected_format: SampleFormatSample format the resampler was built for.
found_format: SampleFormatSample format the offending frame carried.
AfterEof
send_frame was called after
send_eof. Call
flush first to reuse the resampler for
another stream.
PlaneCount
A frame’s planes do not hold what its header claims — too few planes for the format, or a plane shorter than its sample count requires.
Fields
SampleCount
A sample count no frame can hold: one whose byte size overflows,
or one past the c_int av_frame_get_buffer takes.
UnsupportedRate
One end of the conversion declares a sample rate swr cannot be
driven with — zero, or past c_int.
UnsupportedFormat
One end of the conversion declares no sample format
(AV_SAMPLE_FMT_NONE) — the state a codec context is in before
its decoder opens.
UnsupportedLayout
One end of the conversion declares a channel layout this backend will not carry.
Native and unspecified layouts are the two it does. A custom
or ambisonic AVChannelLayout owns a heap-allocated channel
map, and FFmpeg documents that such a layout must be copied with
av_channel_layout_copy rather than assigned — while
ffmpeg_next::ChannelLayout is a Copy wrapper with no
destructor. Every AVFrame this type stages or allocates receives
the layout by assignment, and av_frame_free runs
av_channel_layout_uninit on it: the first staged frame to be
dropped would free a map the spec, the decoder and every later
frame still point at. Refusing at construction is what keeps that
use-after-free unreachable; a resampler over those layouts is a
separate design, not a silent approximation.
Fields
TooManyPlanes
A planar spec with more channels than a decoded frame has plane slots.
mediadecode’s AudioFrame carries a fixed eight planes
(AV_NUM_DATA_POINTERS); planar audio past that lives in
AVFrame.extended_data[], which this crate does not plumb
through. As a source no valid frame could ever arrive; as a
target swr would produce one this crate cannot hand back —
and it would fail only after the input had been consumed, leaving
a session that cannot be retried. Both are refused at
construction, where nothing has happened yet.
Fields
TimestampOutOfRange
A frame’s timestamp does not land on the output timeline: it does
not survive the rescale as an i64, or it is AV_NOPTS_VALUE,
which is a sentinel rather than a time.
Raised before anything is staged, so a refused frame leaves the resampler exactly as it was.
ChannelDropped
The conversion between these two layouts would silently drop a source channel: FFmpeg’s own mixing matrix routes it to no output.
swr mixes the channel positions its rematrix table knows and
processes the rest of the input as though it were absent — a log
line at most. Measured against FFmpeg 9, packed 22.2 → mono loses
fifteen of twenty-four channels and cube → stereo loses two of
eight, so this is not a matter of channel count. Installing an
explicit mix matrix is how such a conversion would be accepted
deliberately; until this crate has a seat for one, the pair is
refused.
Fields
RematrixUnsupported
FFmpeg will not build a mixing matrix between these two layouts at all.
Fields
TimestampOverflow
The output timeline would leave i64. Counted timestamps are
exact or they are nothing, so this is named rather than saturated.
Resample(Error)
The wrapped swresample call reported an error.
OutputBuffer
A reference to one of the output frame’s planes could not be taken.
Raised while preparing the conversion, never after it: that is the point of preparing.
QueueAlloc
The queue of converted frames could not be grown to hold one more.
Implementations§
Source§impl ResampleError
impl ResampleError
Sourcepub const fn is_again(&self) -> bool
pub const fn is_again(&self) -> bool
true for Self::Again — the “send more input” signal, which a
drain loop tests for rather than matching on.
Trait Implementations§
Source§impl Clone for ResampleError
impl Clone for ResampleError
Source§fn clone(&self) -> ResampleError
fn clone(&self) -> ResampleError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResampleError
impl Debug for ResampleError
Source§impl Display for ResampleError
impl Display for ResampleError
Source§impl Error for ResampleError
impl Error for ResampleError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()