fix: support Bluetooth audio input devices (AirPods)#70
Merged
Conversation
On macOS, Bluetooth devices like AirPods connect in A2DP mode (output only). The microphone requires a switch to HFP/SCO, which cpal's low-level AudioUnit HAL doesn't always trigger. Changes: - Add CoreAudio activation hook (activate.rs) that re-sets the default input device via AudioObjectSetPropertyData to nudge macOS into establishing the Bluetooth SCO link for microphone input - Add dead-stream detection in ensure_warm() using a callback counter so disconnected devices are detected and the stream is re-opened - Log device name, sample rate, channels, and format when opening a device for easier debugging of audio issues - Log audio RMS in VAD when speech detection fails, and log when transcription produces empty text (previously silent)
62835e1 to
319613d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AirPods (and other Bluetooth devices) connected to macOS would deliver silence when used as the default audio input device. The microphone was never activated because cpal's low-level AudioUnit HAL doesn't trigger the Bluetooth A2DP → HFP profile switch that enables the mic.
Root Cause
macOS Bluetooth devices start in A2DP mode (high-quality output only). The microphone requires HFP/SCO mode, which higher-level Apple frameworks (
AVCaptureSession) trigger automatically, but cpal's AudioUnit HAL does not.Fix
activate.rs): Re-sets the default input device viaAudioObjectSetPropertyData, which nudges macOS into establishing the Bluetooth SCO link. Platform-gated (#[cfg(target_os = "macos")]), no-op elsewhere, no new dependencies.ensure_warm()now probes callback activity before each recording. If the device disconnected (e.g. Bluetooth dropped), the stream is re-opened on the current default device.Testing