{"record":{"id":"add2861642e02327","repo":"Zackriya-Solutions/meetily","slug":"cannot-start-microphone","errorCode":null,"errorMessage":"Cannot start microphone: {}","messagePattern":"Cannot start microphone: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/audio/devices/discovery.rs","lineNumber":145,"sourceCode":"            .map_err(|e| anyhow::anyhow!(\"Failed to get microphone config: {}\", e))?;\n\n        let callback_fired = Arc::new(AtomicBool::new(false));\n        let callback_fired_clone = callback_fired.clone();\n\n        let stream = device\n            .build_input_stream(\n                &config.into(),\n                move |_data: &[f32], _: &cpal::InputCallbackInfo| {\n                    callback_fired_clone.store(true, Ordering::SeqCst);\n                },\n                |err| warn!(\"[verify_microphone_access] test stream error: {}\", err),\n                None,\n            )\n            .map_err(|e| anyhow::anyhow!(\"Cannot access microphone: {}\", e))?;\n\n        stream\n            .play()\n            .map_err(|e| anyhow::anyhow!(\"Cannot start microphone: {}\", e))?;\n\n        // Wait up to 5s for the first callback.\n        for _ in 0..50 {\n            if callback_fired.load(Ordering::SeqCst) {\n                drop(stream);\n                info!(\"[verify_microphone_access] microphone access verified\");\n                return Ok(());\n            }\n            std::thread::sleep(std::time::Duration::from_millis(100));\n        }\n\n        drop(stream);\n        Err(anyhow::anyhow!(\n            \"Microphone permission not granted. Please allow microphone access in \\\n             System Settings > Privacy & Security > Microphone, then try again.\"\n        ))\n    })\n    .await","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/a2cb62e827da7ef59f65064c97233efb2313878e/frontend/src-tauri/src/audio/devices/discovery.rs#L127-L163","documentation":"If the input stream was built successfully, verify_microphone_access calls stream.play() to start it. A failure there is wrapped as 'Cannot start microphone: {}'. The stream exists but the audio backend refused to start delivering callbacks.","triggerScenarios":"stream.play() returning Err after a successful build_input_stream - backend could not start the device (device became unavailable between build and play, driver error, invalid state).","commonSituations":"Device unplugged in the milliseconds between stream creation and play; driver crash/reset during stream start; macOS device invalidated by OS (sleep/wake, sample-rate change by another app).","solutions":["Retry the verification - transient start failures often clear on the second attempt.","Reconnect/reselect the microphone and re-run device enumeration first.","Catch this in the caller and prompt the user to pick another input device.","Update audio drivers if it reproduces with a specific device."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in 0..2 {\n    match verify_microphone_access().await {\n        Ok(()) => break,\n        Err(e) if e.to_string().contains(\"Cannot start microphone\") && attempt == 0 => continue,\n        Err(e) => { show_error(e); break; }\n    }\n}","preventionTips":["Retry once automatically - start failures are frequently transient.","Re-enumerate devices between attempts in case the device vanished.","Handle sleep/wake and sample-rate-change events by restarting streams.","Keep audio drivers updated; log the cpal backend error for diagnostics."],"tags":["audio","cpal","microphone","stream"],"backgroundTag":"device-start-failed","analyzedSha":"a2cb62e827da7ef59f65064c97233efb2313878e","analyzedAt":"2026-09-12T11:12:14.152Z","contentChangedAt":"2026-09-12T11:12:14.152Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}