{"record":{"id":"b96b900e31b358b9","repo":"toeverything/AFFiNE","slug":"failed-to-create-fastfixedin-resampler","errorCode":null,"errorMessage":"Failed to create FastFixedIn resampler","messagePattern":"Failed to create FastFixedIn resampler","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/frontend/native/media_capture/src/windows/audio_capture.rs","lineNumber":40,"sourceCode":"\nstruct BufferedResampler {\n  resampler: FastFixedIn<f32>,\n  channels: usize,\n  fifo: Vec<Vec<f32>>,            // per-channel queue\n  initial_output_discarded: bool, // Flag to discard first output block (warm-up)\n}\n\nimpl BufferedResampler {\n  fn new(from_sr: f64, to_sr: f64, channels: usize) -> Self {\n    let ratio = to_sr / from_sr;\n    let resampler = FastFixedIn::<f32>::new(\n      ratio,\n      1.0,                      // max_resample_ratio_relative (>= 1.0, fixed ratio)\n      PolynomialDegree::Linear, // balance quality/perf\n      RESAMPLER_INPUT_CHUNK,\n      channels,\n    )\n    .expect(\"Failed to create FastFixedIn resampler\");\n\n    Self {\n      resampler,\n      channels,\n      fifo: vec![Vec::<f32>::new(); channels],\n      initial_output_discarded: false,\n    }\n  }\n\n  fn append_output(&mut self, out_blocks: &[Vec<f32>], interleaved_out: &mut Vec<f32>, final_flush: bool) {\n    if out_blocks.is_empty() || out_blocks.len() != self.channels {\n      return;\n    }\n\n    if !self.initial_output_discarded && !final_flush {\n      self.initial_output_discarded = true;\n      return;\n    }","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/native/media_capture/src/windows/audio_capture.rs#L22-L58","documentation":"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.","triggerScenarios":"Panics in BufferedResampler::new on Windows when rubato FastFixedIn::new fails while building the capture resampler.","commonSituations":"The resampler could not be constructed for the capture and target sample rates. Verify the microphone and loopback devices report sane sample rates.","solutions":["Check the requested sample rates are supported.","Update the audio capture dependency and retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}