Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf446d50 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "floss: Update volume callback's signature"

parents 3d108316 25da6fa4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -62,12 +62,12 @@ impl IBluetoothMediaCallback for BluetoothMediaCallbackDBus {
    }

    #[dbus_method("OnAbsoluteVolumeChanged")]
    fn on_absolute_volume_changed(&self, volume: i32) {
    fn on_absolute_volume_changed(&self, volume: u8) {
        dbus_generated!()
    }

    #[dbus_method("OnHfpVolumeChanged")]
    fn on_hfp_volume_changed(&self, volume: u32, addr: String) {
    fn on_hfp_volume_changed(&self, volume: u8, addr: String) {
        dbus_generated!()
    }
}
+8 −5
Original line number Diff line number Diff line
@@ -77,13 +77,16 @@ pub trait IBluetoothMediaCallback {
    ///
    fn on_absolute_volume_supported_changed(&self, supported: bool);

    ///
    fn on_absolute_volume_changed(&self, volume: i32);
    /// Triggered when a Bluetooth device triggers an AVRCP/A2DP volume change
    /// event. We need to notify audio client to reflect the change on the audio
    /// stack. The volume should be in the range of 0 to 127.
    fn on_absolute_volume_changed(&self, volume: u8);

    /// Triggered when a Bluetooth device triggers a HFP AT command (AT+VGS) to
    /// notify AG about its speaker volume change. We need to notify audio
    /// client to reflect the change on the audio stack.
    fn on_hfp_volume_changed(&self, volume: u32, addr: String);
    /// client to reflect the change on the audio stack. The volume should be
    /// in the range of 0 to 15.
    fn on_hfp_volume_changed(&self, volume: u8, addr: String);
}

/// Serializable device used in.
@@ -199,7 +202,7 @@ impl BluetoothMedia {
            }
            AvrcpCallbacks::AvrcpAbsoluteVolumeUpdate(volume) => {
                self.for_all_callbacks(|callback| {
                    callback.on_absolute_volume_changed(i32::from(volume));
                    callback.on_absolute_volume_changed(volume);
                });
            }
        }
+2 −0
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ class VolumeInterfaceImpl : public VolumeInterface {

  // Set TG's (Android, ChromeOS) volume.
  void SetVolume(int8_t volume) override {
    if (volume < 0) return;

    rusty::avrcp_absolute_volume_update(volume);
  }

+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ static void audio_state_cb(bluetooth::headset::bthf_audio_state_t state, RawAddr
  rusty::hfp_audio_state_callback(state, raddr);
}

static void volume_update_cb(uint32_t volume, RawAddress* addr) {
static void volume_update_cb(uint8_t volume, RawAddress* addr) {
  RustRawAddress raddr = rusty::CopyToRustAddress(*addr);
  rusty::hfp_volume_update_callback(volume, raddr);
}
+3 −3
Original line number Diff line number Diff line
@@ -20,14 +20,14 @@ pub mod ffi {
    }
    extern "Rust" {
        fn avrcp_absolute_volume_enabled(enabled: bool);
        fn avrcp_absolute_volume_update(volume: i8);
        fn avrcp_absolute_volume_update(volume: u8);
    }
}

#[derive(Debug)]
pub enum AvrcpCallbacks {
    AvrcpAbsoluteVolumeEnabled(bool),
    AvrcpAbsoluteVolumeUpdate(i8),
    AvrcpAbsoluteVolumeUpdate(u8),
}

pub struct AvrcpCallbacksDispatcher {
@@ -45,7 +45,7 @@ cb_variant!(
cb_variant!(
    AvrcpCb,
    avrcp_absolute_volume_update -> AvrcpCallbacks::AvrcpAbsoluteVolumeUpdate,
    i8, {}
    u8, {}
);

pub struct Avrcp {
Loading