toeverything/AFFiNE · error

Failed to create FastFixedIn resampler

Error message

Failed to create FastFixedIn resampler

What it means

Raised in `BufferedResampler::new` on Windows when the rubato FastFixedIn constructor rejects its arguments — typically a non-finite or non-positive sample-rate ratio (from_sr/to_sr), invalid channel count, or internal allocation failure. Without the resampler the Windows audio-capture pipeline cannot convert the device sample rate, so capture setup for that device fails.

Source

Thrown at packages/frontend/native/media_capture/src/windows/audio_capture.rs:40

struct BufferedResampler {
  resampler: FastFixedIn<f32>,
  channels: usize,
  fifo: Vec<Vec<f32>>,            // per-channel queue
  initial_output_discarded: bool, // Flag to discard first output block (warm-up)
}

impl BufferedResampler {
  fn new(from_sr: f64, to_sr: f64, channels: usize) -> Self {
    let ratio = to_sr / from_sr;
    let resampler = FastFixedIn::<f32>::new(
      ratio,
      1.0,                      // max_resample_ratio_relative (>= 1.0, fixed ratio)
      PolynomialDegree::Linear, // balance quality/perf
      RESAMPLER_INPUT_CHUNK,
      channels,
    )
    .expect("Failed to create FastFixedIn resampler");

    Self {
      resampler,
      channels,
      fifo: vec![Vec::<f32>::new(); channels],
      initial_output_discarded: false,
    }
  }

  fn append_output(&mut self, out_blocks: &[Vec<f32>], interleaved_out: &mut Vec<f32>, final_flush: bool) {
    if out_blocks.is_empty() || out_blocks.len() != self.channels {
      return;
    }

    if !self.initial_output_discarded && !final_flush {
      self.initial_output_discarded = true;
      return;
    }

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Check the requested sample rates are supported.
  2. Update the audio capture dependency and retry.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Panics in BufferedResampler::new on Windows when rubato FastFixedIn::new fails while building the capture resampler.

Common situations: The resampler could not be constructed for the capture and target sample rates. Verify the microphone and loopback devices report sane sample rates.


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/b96b900e31b358b9. Report an issue: GitHub.