Skip to main content

ResampleError

Enum ResampleError 

Source
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,
}
Available on crate feature 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_rate: u32

Rate the resampler was built for.

§expected_format: SampleFormat

Sample format the resampler was built for.

§found_rate: u32

Rate the offending frame carried.

§found_format: SampleFormat

Sample 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

§expected: usize

What the format and sample count require.

§found: usize

What the frame carries.

§

SampleCount

A sample count no frame can hold: one whose byte size overflows, or one past the c_int av_frame_get_buffer takes.

Fields

§requested: usize

The count that was asked for.

§

UnsupportedRate

One end of the conversion declares a sample rate swr cannot be driven with — zero, or past c_int.

Fields

§end: SpecEnd

Which end of the conversion.

§rate: u32

The rate that was declared.

§

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.

Fields

§end: SpecEnd

Which end of the conversion.

§

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

§end: SpecEnd

Which end of the conversion.

§order: i32

AVChannelOrder as the raw integer it is on the wire.

§channels: i32

The channel count the layout declares.

§

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

§end: SpecEnd

Which end of the conversion.

§channels: i32

The channel count the layout declares.

§limit: i32

Plane slots a frame has.

§

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.

Fields

§pts: i64

The timestamp the frame carried, in its own timebase.

§

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

§source_channels: i32

Channels the source layout declares.

§target_channels: i32

Channels the target layout declares.

§channel: i32

The first source channel that reaches no output channel.

§

RematrixUnsupported

FFmpeg will not build a mixing matrix between these two layouts at all.

Fields

§source_channels: i32

Channels the source layout declares.

§target_channels: i32

Channels the target layout declares.

§

TimestampOverflow

The output timeline would leave i64. Counted timestamps are exact or they are nothing, so this is named rather than saturated.

Fields

§pts: i64

Where the timeline stood.

§samples: i64

How many samples were produced.

§

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.

Fields

§plane: usize

Which plane slot.

§

QueueAlloc

The queue of converted frames could not be grown to hold one more.

Implementations§

Source§

impl ResampleError

Source

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

Source§

fn clone(&self) -> ResampleError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResampleError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ResampleError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for ResampleError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for ResampleError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more