Skip to content
Snippets Groups Projects
Commit dfbef4cd authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Floss: propagate wbs_supported to BluetoothMedia directly"

parents 671dffc7 ca5066b1
No related branches found
No related tags found
No related merge requests found
......@@ -243,15 +243,16 @@ impl BluetoothMedia {
}
BthfConnectionState::SlcConnected => {
info!("[{}]: hfp slc connected.", addr.to_string());
let mut hfp_caps = HfpCodecCapability::CVSD;
if self.hfp.as_mut().unwrap().get_wbs_supported() {
hfp_caps = hfp_caps | HfpCodecCapability::MSBC;
// The device may not support codec-negotiation,
// in which case we shall assume it supports CVSD at this point.
if !self.hfp_caps.contains_key(&addr) {
self.hfp_caps.insert(addr, HfpCodecCapability::CVSD);
}
self.hfp_caps.insert(addr, hfp_caps);
self.notify_media_capability_added(addr);
}
BthfConnectionState::Disconnected => {
info!("[{}]: hfp disconnected.", addr.to_string());
self.hfp_caps.remove(&addr);
match self.hfp_states.remove(&addr) {
Some(_) => self.notify_media_capability_removed(addr),
None => {
......@@ -300,6 +301,14 @@ impl BluetoothMedia {
callback.on_hfp_volume_changed(volume, addr.to_string());
});
}
HfpCallbacks::CapsUpdate(wbs_supported, addr) => {
let hfp_caps = match wbs_supported {
true => HfpCodecCapability::CVSD | HfpCodecCapability::MSBC,
false => HfpCodecCapability::CVSD,
};
self.hfp_caps.insert(addr, hfp_caps);
}
}
}
......
......@@ -30,7 +30,6 @@ namespace topshim {
namespace rust {
namespace internal {
static HfpIntf* g_hfpif;
static bool wbs_supported;
static void connection_state_cb(bluetooth::headset::bthf_connection_state_t state, RawAddress* addr) {
RustRawAddress raddr = rusty::CopyToRustAddress(*addr);
......@@ -104,7 +103,8 @@ class DBusHeadsetCallbacks : public headset::Callbacks {
void WbsCallback(headset::bthf_wbs_config_t wbs, RawAddress* bd_addr) override {
LOG_INFO("WbsCallback %d from %s", wbs, bd_addr->ToString().c_str());
internal::wbs_supported = (wbs == headset::BTHF_WBS_YES);
RustRawAddress raddr = rusty::CopyToRustAddress(*bd_addr);
rusty::hfp_caps_update_callback(wbs == headset::BTHF_WBS_YES, raddr);
}
void AtChldCallback([[maybe_unused]] headset::bthf_chld_type_t chld, [[maybe_unused]] RawAddress* bd_addr) override {}
......@@ -235,10 +235,6 @@ int HfpIntf::disconnect_audio(RustRawAddress bt_addr) {
return intf_->DisconnectAudio(&addr);
}
bool HfpIntf::get_wbs_supported() {
return internal::wbs_supported;
}
void HfpIntf::cleanup() {}
std::unique_ptr<HfpIntf> GetHfpProfile(const unsigned char* btif) {
......
......@@ -38,7 +38,6 @@ class HfpIntf {
int set_volume(int8_t volume, RustRawAddress bt_addr);
int disconnect(RustRawAddress bt_addr);
int disconnect_audio(RustRawAddress bt_addr);
bool get_wbs_supported();
void cleanup();
private:
......
......@@ -80,7 +80,6 @@ pub mod ffi {
fn set_volume(self: Pin<&mut HfpIntf>, volume: i8, bt_addr: RustRawAddress) -> i32;
fn disconnect(self: Pin<&mut HfpIntf>, bt_addr: RustRawAddress) -> i32;
fn disconnect_audio(self: Pin<&mut HfpIntf>, bt_addr: RustRawAddress) -> i32;
fn get_wbs_supported(self: Pin<&mut HfpIntf>) -> bool;
fn cleanup(self: Pin<&mut HfpIntf>);
}
......@@ -88,6 +87,7 @@ pub mod ffi {
fn hfp_connection_state_callback(state: u32, addr: RustRawAddress);
fn hfp_audio_state_callback(state: u32, addr: RustRawAddress);
fn hfp_volume_update_callback(volume: u8, addr: RustRawAddress);
fn hfp_caps_update_callback(wbs_supported: bool, addr: RustRawAddress);
}
}
......@@ -108,6 +108,7 @@ pub enum HfpCallbacks {
ConnectionState(BthfConnectionState, RawAddress),
AudioState(BthfAudioState, RawAddress),
VolumeUpdate(u8, RawAddress),
CapsUpdate(bool, RawAddress),
}
pub struct HfpCallbacksDispatcher {
......@@ -140,6 +141,14 @@ cb_variant!(
}
);
cb_variant!(
HfpCb,
hfp_caps_update_callback -> HfpCallbacks::CapsUpdate,
bool, ffi::RustRawAddress -> RawAddress, {
let _1 = _1.into();
}
);
pub struct Hfp {
internal: cxx::UniquePtr<ffi::HfpIntf>,
_is_init: bool,
......@@ -186,10 +195,6 @@ impl Hfp {
self.internal.pin_mut().disconnect_audio(addr.into())
}
pub fn get_wbs_supported(&mut self) -> bool {
self.internal.pin_mut().get_wbs_supported()
}
pub fn cleanup(&mut self) -> bool {
self.internal.pin_mut().cleanup();
true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment