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

Commit bed8983b authored by Michael Sun's avatar Michael Sun Committed by Gerrit Code Review
Browse files

Merge "floss: avrcp: handle set active device request from AVRCP interface"

parents 9f624fa6 4521995f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -270,6 +270,9 @@ impl BluetoothMedia {
                    Err(e) => warn!("{}", e),
                }
            }
            AvrcpCallbacks::AvrcpSetActiveDevice(addr) => {
                self.uinput.set_active_device(addr.to_string());
            }
        }
    }

+4 −1
Original line number Diff line number Diff line
@@ -62,7 +62,10 @@ class AvrcpMediaInterfaceImpl : public MediaInterface {
      [[maybe_unused]] bool now_playing,
      [[maybe_unused]] std::string media_id) override {}

  void SetActiveDevice([[maybe_unused]] const RawAddress& address) override {}
  void SetActiveDevice(const RawAddress& address) override {
    topshim::rust::RustRawAddress addr = rusty::CopyToRustAddress(address);
    rusty::avrcp_set_active_device(addr);
  }
};

class VolumeInterfaceImpl : public VolumeInterface {
+11 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ pub mod ffi {
        fn avrcp_device_disconnected(addr: RustRawAddress);
        fn avrcp_absolute_volume_update(volume: u8);
        fn avrcp_send_key_event(key: u8, state: u8);
        fn avrcp_set_active_device(addr: RustRawAddress);
    }
}

@@ -59,6 +60,9 @@ pub enum AvrcpCallbacks {
    /// Emitted when received a key event from a connected AVRCP device
    /// Params: Key, Value
    AvrcpSendKeyEvent(u8, u8),
    /// Emitted when received request from AVRCP interface to set a device to active
    /// Params: Device address
    AvrcpSetActiveDevice(RawAddress),
}

pub struct AvrcpCallbacksDispatcher {
@@ -93,6 +97,13 @@ cb_variant!(
    u8, u8, {}
);

cb_variant!(
    AvrcpCb,
    avrcp_set_active_device -> AvrcpCallbacks::AvrcpSetActiveDevice,
    ffi::RustRawAddress -> RawAddress, {
        let _0 = _0.into();
});

pub struct Avrcp {
    internal: cxx::UniquePtr<ffi::AvrcpIntf>,
    _is_init: bool,