Loading system/gd/rust/linux/dbus_projection/dbus_macros/src/lib.rs +0 −2 Original line number Diff line number Diff line Loading @@ -590,8 +590,6 @@ pub fn generate_dbus_arg(_item: TokenStream) -> TokenStream { impl DirectDBus for bool {} impl DirectDBus for i32 {} impl DirectDBus for u32 {} impl DirectDBus for i64 {} impl DirectDBus for u64 {} impl DirectDBus for String {} impl<T: DirectDBus> DBusArg for T { type DBusType = T; Loading system/gd/rust/linux/service/src/iface_bluetooth_media.rs +2 −22 Original line number Diff line number Diff line use bt_topshim::profiles::a2dp::PresentationPosition; use btstack::bluetooth_media::{IBluetoothMedia, IBluetoothMediaCallback}; use btstack::RPCProxy; use dbus::arg::RefArg; use dbus::nonblock::SyncConnection; use dbus::strings::Path; use dbus_macros::{dbus_method, dbus_propmap, dbus_proxy_obj, generate_dbus_exporter}; use dbus_macros::{dbus_method, dbus_proxy_obj, generate_dbus_exporter}; use dbus_projection::DisconnectWatcher; use crate::dbus_arg::{DBusArg, DBusArgError, RefArgToRust}; use crate::dbus_arg::DBusArg; #[allow(dead_code)] struct BluetoothMediaCallbackDBus {} Loading @@ -34,14 +32,6 @@ impl IBluetoothMediaCallback for BluetoothMediaCallbackDBus { #[allow(dead_code)] struct IBluetoothMediaDBus {} #[dbus_propmap(PresentationPosition)] pub struct PresentationPositionDBus { remote_delay_report_ns: u64, total_bytes_read: u64, data_position_sec: i64, data_position_nsec: i32, } #[generate_dbus_exporter(export_bluetooth_media_dbus_obj, "org.chromium.bluetooth.BluetoothMedia")] impl IBluetoothMedia for IBluetoothMediaDBus { #[dbus_method("RegisterCallback")] Loading Loading @@ -86,14 +76,4 @@ impl IBluetoothMedia for IBluetoothMediaDBus { #[dbus_method("StopAudioRequest")] fn stop_audio_request(&mut self) {} #[dbus_method("GetPresentationPosition")] fn get_presentation_position(&mut self) -> PresentationPosition { PresentationPosition { remote_delay_report_ns: 0, total_bytes_read: 0, data_position_sec: 0, data_position_nsec: 0, } } } system/gd/rust/linux/stack/src/bluetooth_media.rs +0 −12 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ use bt_topshim::btif::{BluetoothInterface, RawAddress}; use bt_topshim::profiles::a2dp::{ A2dp, A2dpCallbacks, A2dpCallbacksDispatcher, A2dpCodecBitsPerSample, A2dpCodecChannelMode, A2dpCodecConfig, A2dpCodecIndex, A2dpCodecSampleRate, BtavConnectionState, PresentationPosition, }; use bt_topshim::profiles::avrcp::Avrcp; use bt_topshim::topstack; Loading Loading @@ -40,7 +39,6 @@ pub trait IBluetoothMedia { fn set_volume(&mut self, volume: i32); fn start_audio_request(&mut self); fn stop_audio_request(&mut self); fn get_presentation_position(&mut self) -> PresentationPosition; } pub trait IBluetoothMediaCallback { Loading Loading @@ -216,14 +214,4 @@ impl IBluetoothMedia for BluetoothMedia { fn stop_audio_request(&mut self) { self.a2dp.as_mut().unwrap().stop_audio_request(); } fn get_presentation_position(&mut self) -> PresentationPosition { let position = self.a2dp.as_mut().unwrap().get_presentation_position(); PresentationPosition { remote_delay_report_ns: position.remote_delay_report_ns, total_bytes_read: position.total_bytes_read, data_position_sec: position.data_position_sec, data_position_nsec: position.data_position_nsec, } } } system/gd/rust/topshim/btav/btav_shim.cc +12 −19 Original line number Diff line number Diff line Loading @@ -178,29 +178,29 @@ std::unique_ptr<A2dpIntf> GetA2dpProfile(const unsigned char* btif) { return a2dpif; } int A2dpIntf::init() const { int A2dpIntf::init() { std::vector<btav_a2dp_codec_config_t> a; std::vector<btav_a2dp_codec_config_t> b; return intf_->init(&internal::g_callbacks, 1, a, b); } int A2dpIntf::connect(RustRawAddress bt_addr) const { int A2dpIntf::connect(RustRawAddress bt_addr) { RawAddress addr = internal::from_rust_address(bt_addr); return intf_->connect(addr); } int A2dpIntf::disconnect(RustRawAddress bt_addr) const { int A2dpIntf::disconnect(RustRawAddress bt_addr) { RawAddress addr = internal::from_rust_address(bt_addr); return intf_->disconnect(addr); } int A2dpIntf::set_silence_device(RustRawAddress bt_addr, bool silent) const { int A2dpIntf::set_silence_device(RustRawAddress bt_addr, bool silent) { RawAddress addr = internal::from_rust_address(bt_addr); return intf_->set_silence_device(addr, silent); } int A2dpIntf::set_active_device(RustRawAddress bt_addr) const { int A2dpIntf::set_active_device(RustRawAddress bt_addr) { RawAddress addr = internal::from_rust_address(bt_addr); return intf_->set_active_device(addr); } int A2dpIntf::config_codec(RustRawAddress bt_addr, ::rust::Vec<A2dpCodecConfig> codec_preferences) const { int A2dpIntf::config_codec(RustRawAddress bt_addr, ::rust::Vec<A2dpCodecConfig> codec_preferences) { RawAddress addr = internal::from_rust_address(bt_addr); std::vector<btav_a2dp_codec_config_t> prefs; for (int i = 0; i < codec_preferences.size(); ++i) { Loading @@ -209,10 +209,10 @@ int A2dpIntf::config_codec(RustRawAddress bt_addr, ::rust::Vec<A2dpCodecConfig> return intf_->config_codec(addr, prefs); } void A2dpIntf::cleanup() const { void A2dpIntf::cleanup() { // TODO: Implement. } bool A2dpIntf::set_audio_config(A2dpCodecConfig rconfig) const { bool A2dpIntf::set_audio_config(A2dpCodecConfig rconfig) { bluetooth::audio::a2dp::AudioConfig config = { .sample_rate = static_cast<btav_a2dp_codec_sample_rate_t>(rconfig.sample_rate), .bits_per_sample = static_cast<btav_a2dp_codec_bits_per_sample_t>(rconfig.bits_per_sample), Loading @@ -220,21 +220,14 @@ bool A2dpIntf::set_audio_config(A2dpCodecConfig rconfig) const { }; return bluetooth::audio::a2dp::SetAudioConfig(config); } bool A2dpIntf::start_audio_request() const { bool A2dpIntf::start_audio_request() { return bluetooth::audio::a2dp::StartRequest(); } bool A2dpIntf::stop_audio_request() const { bool A2dpIntf::stop_audio_request() { return bluetooth::audio::a2dp::StopRequest(); } RustPresentationPosition A2dpIntf::get_presentation_position() const { bluetooth::audio::a2dp::PresentationPosition p = bluetooth::audio::a2dp::GetPresentationPosition(); RustPresentationPosition rposition = { .remote_delay_report_ns = p.remote_delay_report_ns, .total_bytes_read = p.total_bytes_read, .data_position_sec = p.data_position.tv_sec, .data_position_nsec = static_cast<int32_t>(p.data_position.tv_nsec), }; return rposition; bluetooth::audio::a2dp::PresentationPosition A2dpIntf::get_presentation_position() { return bluetooth::audio::a2dp::GetPresentationPosition(); } // AVRCP Loading system/gd/rust/topshim/btav/btav_shim.h +11 −12 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ namespace topshim { namespace rust { struct A2dpCodecConfig; struct RustPresentationPosition; struct RustRawAddress; class A2dpIntf { Loading @@ -38,19 +37,19 @@ class A2dpIntf { ~A2dpIntf(); // interface for Settings int init() const; int connect(RustRawAddress bt_addr) const; int disconnect(RustRawAddress bt_addr) const; int set_silence_device(RustRawAddress bt_addr, bool silent) const; int set_active_device(RustRawAddress bt_addr) const; int config_codec(RustRawAddress bt_addr, ::rust::Vec<A2dpCodecConfig> codec_preferences) const; void cleanup() const; int init(); int connect(RustRawAddress bt_addr); int disconnect(RustRawAddress bt_addr); int set_silence_device(RustRawAddress bt_addr, bool silent); int set_active_device(RustRawAddress bt_addr); int config_codec(RustRawAddress bt_addr, ::rust::Vec<A2dpCodecConfig> codec_preferences); void cleanup(); // interface for Audio server bool set_audio_config(A2dpCodecConfig rconfig) const; bool start_audio_request() const; bool stop_audio_request() const; RustPresentationPosition get_presentation_position() const; bool set_audio_config(A2dpCodecConfig rconfig); bool start_audio_request(); bool stop_audio_request(); bluetooth::audio::a2dp::PresentationPosition get_presentation_position(); private: const btav_source_interface_t* intf_; Loading Loading
system/gd/rust/linux/dbus_projection/dbus_macros/src/lib.rs +0 −2 Original line number Diff line number Diff line Loading @@ -590,8 +590,6 @@ pub fn generate_dbus_arg(_item: TokenStream) -> TokenStream { impl DirectDBus for bool {} impl DirectDBus for i32 {} impl DirectDBus for u32 {} impl DirectDBus for i64 {} impl DirectDBus for u64 {} impl DirectDBus for String {} impl<T: DirectDBus> DBusArg for T { type DBusType = T; Loading
system/gd/rust/linux/service/src/iface_bluetooth_media.rs +2 −22 Original line number Diff line number Diff line use bt_topshim::profiles::a2dp::PresentationPosition; use btstack::bluetooth_media::{IBluetoothMedia, IBluetoothMediaCallback}; use btstack::RPCProxy; use dbus::arg::RefArg; use dbus::nonblock::SyncConnection; use dbus::strings::Path; use dbus_macros::{dbus_method, dbus_propmap, dbus_proxy_obj, generate_dbus_exporter}; use dbus_macros::{dbus_method, dbus_proxy_obj, generate_dbus_exporter}; use dbus_projection::DisconnectWatcher; use crate::dbus_arg::{DBusArg, DBusArgError, RefArgToRust}; use crate::dbus_arg::DBusArg; #[allow(dead_code)] struct BluetoothMediaCallbackDBus {} Loading @@ -34,14 +32,6 @@ impl IBluetoothMediaCallback for BluetoothMediaCallbackDBus { #[allow(dead_code)] struct IBluetoothMediaDBus {} #[dbus_propmap(PresentationPosition)] pub struct PresentationPositionDBus { remote_delay_report_ns: u64, total_bytes_read: u64, data_position_sec: i64, data_position_nsec: i32, } #[generate_dbus_exporter(export_bluetooth_media_dbus_obj, "org.chromium.bluetooth.BluetoothMedia")] impl IBluetoothMedia for IBluetoothMediaDBus { #[dbus_method("RegisterCallback")] Loading Loading @@ -86,14 +76,4 @@ impl IBluetoothMedia for IBluetoothMediaDBus { #[dbus_method("StopAudioRequest")] fn stop_audio_request(&mut self) {} #[dbus_method("GetPresentationPosition")] fn get_presentation_position(&mut self) -> PresentationPosition { PresentationPosition { remote_delay_report_ns: 0, total_bytes_read: 0, data_position_sec: 0, data_position_nsec: 0, } } }
system/gd/rust/linux/stack/src/bluetooth_media.rs +0 −12 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ use bt_topshim::btif::{BluetoothInterface, RawAddress}; use bt_topshim::profiles::a2dp::{ A2dp, A2dpCallbacks, A2dpCallbacksDispatcher, A2dpCodecBitsPerSample, A2dpCodecChannelMode, A2dpCodecConfig, A2dpCodecIndex, A2dpCodecSampleRate, BtavConnectionState, PresentationPosition, }; use bt_topshim::profiles::avrcp::Avrcp; use bt_topshim::topstack; Loading Loading @@ -40,7 +39,6 @@ pub trait IBluetoothMedia { fn set_volume(&mut self, volume: i32); fn start_audio_request(&mut self); fn stop_audio_request(&mut self); fn get_presentation_position(&mut self) -> PresentationPosition; } pub trait IBluetoothMediaCallback { Loading Loading @@ -216,14 +214,4 @@ impl IBluetoothMedia for BluetoothMedia { fn stop_audio_request(&mut self) { self.a2dp.as_mut().unwrap().stop_audio_request(); } fn get_presentation_position(&mut self) -> PresentationPosition { let position = self.a2dp.as_mut().unwrap().get_presentation_position(); PresentationPosition { remote_delay_report_ns: position.remote_delay_report_ns, total_bytes_read: position.total_bytes_read, data_position_sec: position.data_position_sec, data_position_nsec: position.data_position_nsec, } } }
system/gd/rust/topshim/btav/btav_shim.cc +12 −19 Original line number Diff line number Diff line Loading @@ -178,29 +178,29 @@ std::unique_ptr<A2dpIntf> GetA2dpProfile(const unsigned char* btif) { return a2dpif; } int A2dpIntf::init() const { int A2dpIntf::init() { std::vector<btav_a2dp_codec_config_t> a; std::vector<btav_a2dp_codec_config_t> b; return intf_->init(&internal::g_callbacks, 1, a, b); } int A2dpIntf::connect(RustRawAddress bt_addr) const { int A2dpIntf::connect(RustRawAddress bt_addr) { RawAddress addr = internal::from_rust_address(bt_addr); return intf_->connect(addr); } int A2dpIntf::disconnect(RustRawAddress bt_addr) const { int A2dpIntf::disconnect(RustRawAddress bt_addr) { RawAddress addr = internal::from_rust_address(bt_addr); return intf_->disconnect(addr); } int A2dpIntf::set_silence_device(RustRawAddress bt_addr, bool silent) const { int A2dpIntf::set_silence_device(RustRawAddress bt_addr, bool silent) { RawAddress addr = internal::from_rust_address(bt_addr); return intf_->set_silence_device(addr, silent); } int A2dpIntf::set_active_device(RustRawAddress bt_addr) const { int A2dpIntf::set_active_device(RustRawAddress bt_addr) { RawAddress addr = internal::from_rust_address(bt_addr); return intf_->set_active_device(addr); } int A2dpIntf::config_codec(RustRawAddress bt_addr, ::rust::Vec<A2dpCodecConfig> codec_preferences) const { int A2dpIntf::config_codec(RustRawAddress bt_addr, ::rust::Vec<A2dpCodecConfig> codec_preferences) { RawAddress addr = internal::from_rust_address(bt_addr); std::vector<btav_a2dp_codec_config_t> prefs; for (int i = 0; i < codec_preferences.size(); ++i) { Loading @@ -209,10 +209,10 @@ int A2dpIntf::config_codec(RustRawAddress bt_addr, ::rust::Vec<A2dpCodecConfig> return intf_->config_codec(addr, prefs); } void A2dpIntf::cleanup() const { void A2dpIntf::cleanup() { // TODO: Implement. } bool A2dpIntf::set_audio_config(A2dpCodecConfig rconfig) const { bool A2dpIntf::set_audio_config(A2dpCodecConfig rconfig) { bluetooth::audio::a2dp::AudioConfig config = { .sample_rate = static_cast<btav_a2dp_codec_sample_rate_t>(rconfig.sample_rate), .bits_per_sample = static_cast<btav_a2dp_codec_bits_per_sample_t>(rconfig.bits_per_sample), Loading @@ -220,21 +220,14 @@ bool A2dpIntf::set_audio_config(A2dpCodecConfig rconfig) const { }; return bluetooth::audio::a2dp::SetAudioConfig(config); } bool A2dpIntf::start_audio_request() const { bool A2dpIntf::start_audio_request() { return bluetooth::audio::a2dp::StartRequest(); } bool A2dpIntf::stop_audio_request() const { bool A2dpIntf::stop_audio_request() { return bluetooth::audio::a2dp::StopRequest(); } RustPresentationPosition A2dpIntf::get_presentation_position() const { bluetooth::audio::a2dp::PresentationPosition p = bluetooth::audio::a2dp::GetPresentationPosition(); RustPresentationPosition rposition = { .remote_delay_report_ns = p.remote_delay_report_ns, .total_bytes_read = p.total_bytes_read, .data_position_sec = p.data_position.tv_sec, .data_position_nsec = static_cast<int32_t>(p.data_position.tv_nsec), }; return rposition; bluetooth::audio::a2dp::PresentationPosition A2dpIntf::get_presentation_position() { return bluetooth::audio::a2dp::GetPresentationPosition(); } // AVRCP Loading
system/gd/rust/topshim/btav/btav_shim.h +11 −12 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ namespace topshim { namespace rust { struct A2dpCodecConfig; struct RustPresentationPosition; struct RustRawAddress; class A2dpIntf { Loading @@ -38,19 +37,19 @@ class A2dpIntf { ~A2dpIntf(); // interface for Settings int init() const; int connect(RustRawAddress bt_addr) const; int disconnect(RustRawAddress bt_addr) const; int set_silence_device(RustRawAddress bt_addr, bool silent) const; int set_active_device(RustRawAddress bt_addr) const; int config_codec(RustRawAddress bt_addr, ::rust::Vec<A2dpCodecConfig> codec_preferences) const; void cleanup() const; int init(); int connect(RustRawAddress bt_addr); int disconnect(RustRawAddress bt_addr); int set_silence_device(RustRawAddress bt_addr, bool silent); int set_active_device(RustRawAddress bt_addr); int config_codec(RustRawAddress bt_addr, ::rust::Vec<A2dpCodecConfig> codec_preferences); void cleanup(); // interface for Audio server bool set_audio_config(A2dpCodecConfig rconfig) const; bool start_audio_request() const; bool stop_audio_request() const; RustPresentationPosition get_presentation_position() const; bool set_audio_config(A2dpCodecConfig rconfig); bool start_audio_request(); bool stop_audio_request(); bluetooth::audio::a2dp::PresentationPosition get_presentation_position(); private: const btav_source_interface_t* intf_; Loading