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

Commit 9b79fd9d authored by Hsin-chen Chuang's avatar Hsin-chen Chuang
Browse files

floss: Wire btif_av_stream_suspend to topshim.

Bug: 274555164
Tag: #floss
Test: Tested together with the later patch

Change-Id: I1a97c80debe28d8df21f0cd923e7d35350723c30
parent 0f8bb33e
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -173,6 +173,21 @@ bool StopRequest() {
  return true;
  return true;
}
}


bool SuspendRequest() {
  if (a2dp_pending_cmd_ != A2DP_CTRL_CMD_NONE) {
    LOG_WARN("%s: busy in pending_cmd=%u", __func__, a2dp_pending_cmd_);
    return false;
  }
  if (!btif_av_stream_started_ready()) {
    LOG_WARN("%s: AV stream is not started", __func__);
    return false;
  }
  LOG_INFO("%s: handling", __func__);
  a2dp_pending_cmd_ = A2DP_CTRL_CMD_SUSPEND;
  btif_av_stream_suspend();
  return true;
}

// Invoked by audio server to check audio presentation position periodically.
// Invoked by audio server to check audio presentation position periodically.
PresentationPosition GetPresentationPosition() {
PresentationPosition GetPresentationPosition() {
  PresentationPosition presentation_position{
  PresentationPosition presentation_position{
+3 −0
Original line number Original line Diff line number Diff line
@@ -44,6 +44,9 @@ bool StartRequest();
// Invoked by audio server when audio streaming is done.
// Invoked by audio server when audio streaming is done.
bool StopRequest();
bool StopRequest();


// Invoked by audio server when audio streaming is suspended.
bool SuspendRequest();

struct PresentationPosition {
struct PresentationPosition {
  uint64_t remote_delay_report_ns;
  uint64_t remote_delay_report_ns;
  uint64_t total_bytes_read;
  uint64_t total_bytes_read;
+3 −0
Original line number Original line Diff line number Diff line
@@ -304,6 +304,9 @@ bool A2dpIntf::start_audio_request() const {
bool A2dpIntf::stop_audio_request() const {
bool A2dpIntf::stop_audio_request() const {
  return bluetooth::audio::a2dp::StopRequest();
  return bluetooth::audio::a2dp::StopRequest();
}
}
bool A2dpIntf::suspend_audio_request() const {
  return bluetooth::audio::a2dp::SuspendRequest();
}
RustPresentationPosition A2dpIntf::get_presentation_position() const {
RustPresentationPosition A2dpIntf::get_presentation_position() const {
  bluetooth::audio::a2dp::PresentationPosition p = bluetooth::audio::a2dp::GetPresentationPosition();
  bluetooth::audio::a2dp::PresentationPosition p = bluetooth::audio::a2dp::GetPresentationPosition();
  RustPresentationPosition rposition = {
  RustPresentationPosition rposition = {
+1 −0
Original line number Original line Diff line number Diff line
@@ -50,6 +50,7 @@ class A2dpIntf {
  bool set_audio_config(A2dpCodecConfig rconfig) const;
  bool set_audio_config(A2dpCodecConfig rconfig) const;
  bool start_audio_request() const;
  bool start_audio_request() const;
  bool stop_audio_request() const;
  bool stop_audio_request() const;
  bool suspend_audio_request() const;
  RustPresentationPosition get_presentation_position() const;
  RustPresentationPosition get_presentation_position() const;


 private:
 private:
+6 −0
Original line number Original line Diff line number Diff line
@@ -199,6 +199,7 @@ pub mod ffi {
        fn set_audio_config(self: &A2dpIntf, config: A2dpCodecConfig) -> bool;
        fn set_audio_config(self: &A2dpIntf, config: A2dpCodecConfig) -> bool;
        fn start_audio_request(self: &A2dpIntf) -> bool;
        fn start_audio_request(self: &A2dpIntf) -> bool;
        fn stop_audio_request(self: &A2dpIntf) -> bool;
        fn stop_audio_request(self: &A2dpIntf) -> bool;
        fn suspend_audio_request(self: &A2dpIntf) -> bool;
        fn cleanup(self: &A2dpIntf);
        fn cleanup(self: &A2dpIntf);
        fn get_presentation_position(self: &A2dpIntf) -> RustPresentationPosition;
        fn get_presentation_position(self: &A2dpIntf) -> RustPresentationPosition;
        // A2dp sink functions
        // A2dp sink functions
@@ -379,6 +380,11 @@ impl A2dp {
        self.internal.stop_audio_request();
        self.internal.stop_audio_request();
    }
    }


    #[profile_enabled_or]
    pub fn suspend_audio_request(&self) {
        self.internal.suspend_audio_request();
    }

    #[profile_enabled_or_default]
    #[profile_enabled_or_default]
    pub fn get_presentation_position(&self) -> PresentationPosition {
    pub fn get_presentation_position(&self) -> PresentationPosition {
        self.internal.get_presentation_position()
        self.internal.get_presentation_position()