Loading system/audio_hal_interface/a2dp_encoding_host.h +2 −2 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ struct AudioConfig { BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO; }; // Invoked by audio server to notify Bluetooth about audio config bool Init(AudioConfig); // Invoked by audio server to set audio config (PCM for now) bool SetAudioConfig(AudioConfig); // Invoked by audio server when it has audio data to stream. bool StartRequest(); Loading system/gd/rust/linux/service/src/iface_bluetooth_media.rs +14 −4 Original line number Diff line number Diff line Loading @@ -46,9 +46,19 @@ impl IBluetoothMedia for IBluetoothMediaDBus { #[dbus_method("Disconnect")] fn disconnect(&mut self, device: String) {} #[dbus_method("StartSession")] fn start_session(&mut self) {} #[dbus_method("SetAudioConfig")] fn set_audio_config( &mut self, sample_rate: i32, bits_per_sample: i32, channel_mode: i32, ) -> bool { true } #[dbus_method("StartAudioRequest")] fn start_audio_request(&mut self) {} #[dbus_method("StopSession")] fn stop_session(&mut self) {} #[dbus_method("StopAudioRequest")] fn stop_audio_request(&mut self) {} } system/gd/rust/linux/stack/src/bluetooth_media.rs +32 −7 Original line number Diff line number Diff line Loading @@ -2,10 +2,12 @@ use bt_topshim::btif::BluetoothInterface; use bt_topshim::profiles::a2dp::{ A2dp, A2dpCallbacks, A2dpCallbacksDispatcher, BtavConnectionState, A2dp, A2dpCallbacks, A2dpCallbacksDispatcher, A2dpCodecBitsPerSample, A2dpCodecChannelMode, A2dpCodecSampleRate, BtavConnectionState, }; use bt_topshim::topstack; use std::convert::TryFrom; use std::sync::Arc; use std::sync::Mutex; Loading @@ -22,8 +24,14 @@ pub trait IBluetoothMedia { fn connect(&mut self, device: String); fn set_active_device(&mut self, device: String); fn disconnect(&mut self, device: String); fn start_session(&mut self); fn stop_session(&mut self); fn set_audio_config( &mut self, sample_rate: i32, bits_per_sample: i32, channel_mode: i32, ) -> bool; fn start_audio_request(&mut self); fn stop_audio_request(&mut self); } pub trait IBluetoothMediaCallback { Loading Loading @@ -120,10 +128,27 @@ impl IBluetoothMedia for BluetoothMedia { self.a2dp.as_mut().unwrap().disconnect(device); } fn start_session(&mut self) { self.a2dp.as_mut().unwrap().start_session(); fn set_audio_config( &mut self, sample_rate: i32, bits_per_sample: i32, channel_mode: i32, ) -> bool { if !A2dpCodecSampleRate::validate_bits(sample_rate) || !A2dpCodecBitsPerSample::validate_bits(bits_per_sample) || !A2dpCodecChannelMode::validate_bits(channel_mode) { return false; } fn stop_session(&mut self) { self.a2dp.as_mut().unwrap().stop_session(); self.a2dp.as_mut().unwrap().set_audio_config(sample_rate, bits_per_sample, channel_mode); true } fn start_audio_request(&mut self) { self.a2dp.as_mut().unwrap().start_audio_request(); } fn stop_audio_request(&mut self) { self.a2dp.as_mut().unwrap().stop_audio_request(); } } system/gd/rust/topshim/btav/btav_shim.cc +8 −0 Original line number Diff line number Diff line Loading @@ -203,6 +203,14 @@ int A2dpIntf::config_codec(RustRawAddress bt_addr, ::rust::Vec<A2dpCodecConfig> void A2dpIntf::cleanup() { // TODO: Implement. } 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), .channel_mode = static_cast<btav_a2dp_codec_channel_mode_t>(rconfig.channel_mode), }; return bluetooth::audio::a2dp::SetAudioConfig(config); } bool A2dpIntf::start_audio_request() { return bluetooth::audio::a2dp::StartRequest(); } Loading system/gd/rust/topshim/btav/btav_shim.h +1 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ class A2dpIntf { void cleanup(); // interface for Audio server bool set_audio_config(A2dpCodecConfig rconfig); bool start_audio_request(); bool stop_audio_request(); bluetooth::audio::a2dp::PresentationPosition get_presentation_position(); Loading Loading
system/audio_hal_interface/a2dp_encoding_host.h +2 −2 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ struct AudioConfig { BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO; }; // Invoked by audio server to notify Bluetooth about audio config bool Init(AudioConfig); // Invoked by audio server to set audio config (PCM for now) bool SetAudioConfig(AudioConfig); // Invoked by audio server when it has audio data to stream. bool StartRequest(); Loading
system/gd/rust/linux/service/src/iface_bluetooth_media.rs +14 −4 Original line number Diff line number Diff line Loading @@ -46,9 +46,19 @@ impl IBluetoothMedia for IBluetoothMediaDBus { #[dbus_method("Disconnect")] fn disconnect(&mut self, device: String) {} #[dbus_method("StartSession")] fn start_session(&mut self) {} #[dbus_method("SetAudioConfig")] fn set_audio_config( &mut self, sample_rate: i32, bits_per_sample: i32, channel_mode: i32, ) -> bool { true } #[dbus_method("StartAudioRequest")] fn start_audio_request(&mut self) {} #[dbus_method("StopSession")] fn stop_session(&mut self) {} #[dbus_method("StopAudioRequest")] fn stop_audio_request(&mut self) {} }
system/gd/rust/linux/stack/src/bluetooth_media.rs +32 −7 Original line number Diff line number Diff line Loading @@ -2,10 +2,12 @@ use bt_topshim::btif::BluetoothInterface; use bt_topshim::profiles::a2dp::{ A2dp, A2dpCallbacks, A2dpCallbacksDispatcher, BtavConnectionState, A2dp, A2dpCallbacks, A2dpCallbacksDispatcher, A2dpCodecBitsPerSample, A2dpCodecChannelMode, A2dpCodecSampleRate, BtavConnectionState, }; use bt_topshim::topstack; use std::convert::TryFrom; use std::sync::Arc; use std::sync::Mutex; Loading @@ -22,8 +24,14 @@ pub trait IBluetoothMedia { fn connect(&mut self, device: String); fn set_active_device(&mut self, device: String); fn disconnect(&mut self, device: String); fn start_session(&mut self); fn stop_session(&mut self); fn set_audio_config( &mut self, sample_rate: i32, bits_per_sample: i32, channel_mode: i32, ) -> bool; fn start_audio_request(&mut self); fn stop_audio_request(&mut self); } pub trait IBluetoothMediaCallback { Loading Loading @@ -120,10 +128,27 @@ impl IBluetoothMedia for BluetoothMedia { self.a2dp.as_mut().unwrap().disconnect(device); } fn start_session(&mut self) { self.a2dp.as_mut().unwrap().start_session(); fn set_audio_config( &mut self, sample_rate: i32, bits_per_sample: i32, channel_mode: i32, ) -> bool { if !A2dpCodecSampleRate::validate_bits(sample_rate) || !A2dpCodecBitsPerSample::validate_bits(bits_per_sample) || !A2dpCodecChannelMode::validate_bits(channel_mode) { return false; } fn stop_session(&mut self) { self.a2dp.as_mut().unwrap().stop_session(); self.a2dp.as_mut().unwrap().set_audio_config(sample_rate, bits_per_sample, channel_mode); true } fn start_audio_request(&mut self) { self.a2dp.as_mut().unwrap().start_audio_request(); } fn stop_audio_request(&mut self) { self.a2dp.as_mut().unwrap().stop_audio_request(); } }
system/gd/rust/topshim/btav/btav_shim.cc +8 −0 Original line number Diff line number Diff line Loading @@ -203,6 +203,14 @@ int A2dpIntf::config_codec(RustRawAddress bt_addr, ::rust::Vec<A2dpCodecConfig> void A2dpIntf::cleanup() { // TODO: Implement. } 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), .channel_mode = static_cast<btav_a2dp_codec_channel_mode_t>(rconfig.channel_mode), }; return bluetooth::audio::a2dp::SetAudioConfig(config); } bool A2dpIntf::start_audio_request() { return bluetooth::audio::a2dp::StartRequest(); } Loading
system/gd/rust/topshim/btav/btav_shim.h +1 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ class A2dpIntf { void cleanup(); // interface for Audio server bool set_audio_config(A2dpCodecConfig rconfig); bool start_audio_request(); bool stop_audio_request(); bluetooth::audio::a2dp::PresentationPosition get_presentation_position(); Loading