{"record":{"id":"7be16cf4354e5399","repo":"Zackriya-Solutions/meetily","slug":"unsupported-sample-format","errorCode":null,"errorMessage":"Unsupported sample format: {:?}","messagePattern":"Unsupported sample format: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/audio/stream.rs","lineNumber":307,"sourceCode":"            }\n            cpal::SampleFormat::I8 => {\n                let capture_clone = capture.clone();\n                device.build_input_stream(\n                    &config_copy.into(),\n                    move |data: &[i8], _: &cpal::InputCallbackInfo| {\n                        let f32_data: Vec<f32> = data.iter()\n                            .map(|&sample| sample as f32 / i8::MAX as f32)\n                            .collect();\n                        capture.process_audio_data(&f32_data);\n                    },\n                    move |err| {\n                        capture_clone.handle_stream_error(err);\n                    },\n                    None,\n                )?\n            }\n            _ => {\n                return Err(anyhow::anyhow!(\"Unsupported sample format: {:?}\", config.sample_format()));\n            }\n        };\n\n        Ok(stream)\n    }\n\n    /// Get device info\n    pub fn device(&self) -> &AudioDevice {\n        &self.device\n    }\n\n    /// Stop the stream\n    pub fn stop(self) -> Result<()> {\n        info!(\"Stopping audio stream for device: {}\", self.device.name);\n\n        match self.backend {\n            StreamBackend::Cpal(stream) => {\n                // CRITICAL: Pause the stream first to stop callbacks immediately","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/0281737d87d26352fb0adc78c8c0975f691b23d1/frontend/src-tauri/src/audio/stream.rs#L289-L325","documentation":"The cpal match over config.sample_format() fell through to the catch-all arm: the negotiated device format is one stream.rs does not convert (the handled arms cover f32/i16/u16/i8; anything else like I32/U32/I64/U64 hits the error). No stream can be built for that device configuration.","triggerScenarios":"build_input_stream is called with a device whose negotiated config reports SampleFormat::I32 (professional interfaces, some ALSA/loopback configs), U32, or 64-bit formats - any format without a matching conversion arm.","commonSituations":"Pro audio interfaces (RME, Focusrite) exposing 32-bit integer PCM; Linux ALSA devices negotiated to unusual formats; Bluetooth HFP profiles exposing odd formats; new cpal versions adding SampleFormat variants the match does not cover.","solutions":["Negotiate a supported format: iterate device.supported_input_configs() and request F32 or I16 before building","Add a conversion arm for the reported format (e.g. I32 to f32 via sample as f32 / i32::MAX as f32)","Pick a different device that exposes a supported format"],"exampleFix":"// before\n_ => {\n    return Err(anyhow::anyhow!(\"Unsupported sample format: {:?}\", config.sample_format()));\n}\n\n// after - convert 32-bit integer PCM too, keep the guard for anything else\ncpal::SampleFormat::I32 => {\n    device.build_input_stream(\n        &config.clone().with_sample_format(cpal::SampleFormat::I32),\n        move |data: &[i32], _: &cpal::InputTimestamp| {\n            let f32_data: Vec<f32> = data.iter()\n                .map(|&sample| sample as f32 / i32::MAX as f32)\n                .collect();\n            capture_clone.process_audio_data(&f32_data);\n        },\n        move |err| capture_err.handle_stream_error(err),\n        None,\n    )?\n}\n_ => {\n    return Err(anyhow::anyhow!(\"Unsupported sample format: {:?}\", config.sample_format()));\n}","handlingStrategy":"validation","validationCode":"fn supported(f: cpal::SampleFormat) -> bool {\n    matches!(f, cpal::SampleFormat::F32 | cpal::SampleFormat::I16\n                | cpal::SampleFormat::U16 | cpal::SampleFormat::I8)\n}\n\n// Negotiate a convertible config before calling build_input_stream\nlet cfg = device.supported_input_configs()?\n    .find(|r| {\n        let c = r.with_sample_format(cpal::SampleFormat::F32);\n        supported(c.sample_format())\n    })\n    .ok_or_else(|| anyhow!(\"Device exposes no supported sample format\"))?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always negotiate a known format instead of trusting the default config","Extend the conversion match whenever adding device support (I32 etc.)","Include device name and sample_format in the error message for fast diagnosis"],"tags":["cpal","audio","sample-format","device-config"],"backgroundTag":"unsupported-sample-format","analyzedSha":"0281737d87d26352fb0adc78c8c0975f691b23d1","analyzedAt":"2026-08-16T20:57:52.567Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}