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

Commit 1d354e24 authored by Jeremy Wu's avatar Jeremy Wu Committed by Automerger Merge Worker
Browse files

Floss: pass request status for audio connection am: e3a86d3a am: 7496e934 am: 3dc771d0

parents 0eeb60f7 3dc771d0
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -146,13 +146,13 @@ bool StartRequest() {
    /*
     * Post start event and wait for audio path to open.
     * If we are the source, the ACK will be sent after the start
     * procedure is completed, othewise send it now.
     * procedure is completed.
     */
    a2dp_pending_cmd_ = A2DP_CTRL_CMD_START;
    btif_av_stream_start();
    if (btif_av_get_peer_sep() != AVDT_TSEP_SRC) {
      LOG(INFO) << __func__ << ": accepted";
      return false;  // TODO: should be pending
      LOG_INFO("%s: accepted", __func__);
      return true;  // NOTE: The request is placed, but could still fail.
    }
    a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE;
    return true;
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ struct AudioConfig {
bool SetAudioConfig(AudioConfig);

// Invoked by audio server when it has audio data to stream.
// Returns whether the start request has been made successfully.
bool StartRequest();

// Invoked by audio server when audio streaming is done.
+5 −5
Original line number Diff line number Diff line
@@ -201,12 +201,12 @@ impl IBluetoothMedia for IBluetoothMediaDBus {
    }

    #[dbus_method("StartAudioRequest")]
    fn start_audio_request(&mut self) {
    fn start_audio_request(&mut self) -> bool {
        dbus_generated!()
    }

    #[dbus_method("GetA2dpAudioStarted")]
    fn get_a2dp_audio_started(&mut self, address: String) -> u8 {
    fn get_a2dp_audio_started(&mut self, address: String) -> bool {
        dbus_generated!()
    }

@@ -216,12 +216,12 @@ impl IBluetoothMedia for IBluetoothMediaDBus {
    }

    #[dbus_method("StartScoCall")]
    fn start_sco_call(&mut self, address: String, sco_offload: bool, force_cvsd: bool) {
    fn start_sco_call(&mut self, address: String, sco_offload: bool, force_cvsd: bool) -> bool {
        dbus_generated!()
    }

    #[dbus_method("GetHfpAudioStarted")]
    fn get_hfp_audio_started(&mut self, address: String) -> u8 {
    #[dbus_method("GetHfpAudioFinalCodecs")]
    fn get_hfp_audio_final_codecs(&mut self, address: String) -> u8 {
        dbus_generated!()
    }

+24 −18
Original line number Diff line number Diff line
@@ -81,20 +81,20 @@ pub trait IBluetoothMedia {
    // Set the HFP speaker volume. Valid volume specified by the HFP spec should
    // be in the range of 0-15.
    fn set_hfp_volume(&mut self, volume: u8, address: String);
    fn start_audio_request(&mut self);
    fn start_audio_request(&mut self) -> bool;
    fn stop_audio_request(&mut self);

    /// Returns non-zero value iff A2DP audio has started.
    fn get_a2dp_audio_started(&mut self, address: String) -> u8;
    /// Returns true iff A2DP audio has started.
    fn get_a2dp_audio_started(&mut self, address: String) -> bool;

    /// Returns the negotiated codec (CVSD=1, mSBC=2) to use if HFP audio has started.
    /// Returns 0 if HFP audio hasn't started.
    fn get_hfp_audio_started(&mut self, address: String) -> u8;
    fn get_hfp_audio_final_codecs(&mut self, address: String) -> u8;

    fn get_presentation_position(&mut self) -> PresentationPosition;

    // Start the SCO setup to connect audio
    fn start_sco_call(&mut self, address: String, sco_offload: bool, force_cvsd: bool);
    /// Start the SCO setup to connect audio
    fn start_sco_call(&mut self, address: String, sco_offload: bool, force_cvsd: bool) -> bool;
    fn stop_sco_call(&mut self, address: String);

    /// Set the current playback status: e.g., playing, paused, stopped, etc. The method is a copy
@@ -1236,14 +1236,17 @@ impl IBluetoothMedia for BluetoothMedia {
        };
    }

    fn start_audio_request(&mut self) {
    fn start_audio_request(&mut self) -> bool {
        // TODO(b/254808917): revert to debug log once fixed
        info!("Start audio request");

        match self.a2dp.as_mut() {
            Some(a2dp) => a2dp.start_audio_request(),
            None => warn!("Uninitialized A2DP to start audio request"),
        };
            None => {
                warn!("Uninitialized A2DP to start audio request");
                false
            }
        }
    }

    fn stop_audio_request(&mut self) {
@@ -1261,11 +1264,11 @@ impl IBluetoothMedia for BluetoothMedia {
        };
    }

    fn start_sco_call(&mut self, address: String, sco_offload: bool, force_cvsd: bool) {
    fn start_sco_call(&mut self, address: String, sco_offload: bool, force_cvsd: bool) -> bool {
        let addr = match RawAddress::from_string(address.clone()) {
            None => {
                warn!("Can't start sco call with: {}", address);
                return;
                return false;
            }
            Some(addr) => addr,
        };
@@ -1274,7 +1277,7 @@ impl IBluetoothMedia for BluetoothMedia {
        let hfp = match self.hfp.as_mut() {
            None => {
                warn!("Uninitialized HFP to start the sco call");
                return;
                return false;
            }
            Some(hfp) => hfp,
        };
@@ -1282,11 +1285,13 @@ impl IBluetoothMedia for BluetoothMedia {
        match hfp.connect_audio(addr, sco_offload, force_cvsd) {
            0 => {
                info!("SCO connect_audio status success.");
                true
            }
            x => {
                warn!("SCO connect_audio status failed: {}", x);
                false
            }
        }
        };
    }

    fn stop_sco_call(&mut self, address: String) {
@@ -1299,6 +1304,7 @@ impl IBluetoothMedia for BluetoothMedia {
        };

        info!("Stop sco call for {}", address);

        match self.hfp.as_mut() {
            Some(hfp) => {
                hfp.disconnect_audio(addr);
@@ -1307,22 +1313,22 @@ impl IBluetoothMedia for BluetoothMedia {
        };
    }

    fn get_a2dp_audio_started(&mut self, address: String) -> u8 {
    fn get_a2dp_audio_started(&mut self, address: String) -> bool {
        let addr = match RawAddress::from_string(address.clone()) {
            None => {
                warn!("Invalid device address {}", address);
                return 0;
                return false;
            }
            Some(addr) => addr,
        };

        match self.a2dp_audio_state.get(&addr) {
            Some(BtavAudioState::Started) => 1,
            _ => 0,
            Some(BtavAudioState::Started) => true,
            _ => false,
        }
    }

    fn get_hfp_audio_started(&mut self, address: String) -> u8 {
    fn get_hfp_audio_final_codecs(&mut self, address: String) -> u8 {
        let addr = match RawAddress::from_string(address.clone()) {
            None => {
                warn!("Invalid device address {}", address);
+3 −3
Original line number Diff line number Diff line
@@ -354,9 +354,9 @@ impl A2dp {
        self.internal.set_audio_config(config);
    }

    #[profile_enabled_or]
    pub fn start_audio_request(&self) {
        self.internal.start_audio_request();
    #[profile_enabled_or(false)]
    pub fn start_audio_request(&self) -> bool {
        self.internal.start_audio_request()
    }

    #[profile_enabled_or]