From fd0ccf8e996385559323b4b368529fb8a7a0c8a4 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Sun, 12 Apr 2026 17:08:48 +0400 Subject: [PATCH] fix(bluetooth): enable Oboe sample rate conversion for BT SCO (8/16kHz) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BT SCO devices only support 8kHz or 16kHz but our Oboe streams request 48kHz. Without resampling, AudioPolicyManager rejects the input stream ("getInputProfile could not find profile for... sampling rate 48000"). Fix: add setSampleRateConversionQuality(Best) to both capture and playout stream builders. Oboe resamples internally so our ring buffers stay at 48kHz regardless of the hardware sample rate. Also removes the broken setBluetoothScoOn/isBluetoothScoOn calls from stop_bluetooth_sco — just call stopBluetoothSco() unconditionally. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/wzp-native/cpp/oboe_bridge.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/wzp-native/cpp/oboe_bridge.cpp b/crates/wzp-native/cpp/oboe_bridge.cpp index e22e378..5d4394c 100644 --- a/crates/wzp-native/cpp/oboe_bridge.cpp +++ b/crates/wzp-native/cpp/oboe_bridge.cpp @@ -260,6 +260,11 @@ int wzp_oboe_start(const WzpOboeConfig* config, const WzpOboeRings* rings) { ->setSampleRate(config->sample_rate) ->setFramesPerDataCallback(config->frames_per_burst) ->setInputPreset(oboe::InputPreset::VoiceCommunication) + // Bluetooth SCO only supports 8/16kHz. Without resampling, opening + // a 48kHz capture stream against a BT device fails with + // "getInputProfile could not find profile". Oboe resamples internally + // so our ring buffers stay at 48kHz regardless of the hardware rate. + ->setSampleRateConversionQuality(oboe::SampleRateConversionQuality::Best) ->setDataCallback(&g_capture_cb); oboe::Result result = captureBuilder.openStream(g_capture_stream); @@ -320,6 +325,8 @@ int wzp_oboe_start(const WzpOboeConfig* config, const WzpOboeRings* rings) { ->setSampleRate(config->sample_rate) ->setFramesPerDataCallback(config->frames_per_burst) ->setUsage(oboe::Usage::VoiceCommunication) + // Match capture: Oboe resamples 48kHz ↔ device rate (8/16kHz for BT SCO) + ->setSampleRateConversionQuality(oboe::SampleRateConversionQuality::Best) ->setDataCallback(&g_playout_cb); result = playoutBuilder.openStream(g_playout_stream);