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

Commit 4ff2eae5 authored by Jakub Pawłowski's avatar Jakub Pawłowski Committed by Gerrit Code Review
Browse files

Merge changes I8d27d805,I440e6249,I6740dc62,Ifdc10b82

* changes:
  leaudio: Improve update active device
  leaudio: Minor coding style fix
  leaudio: Cleanup state machine on service cleanup
  leaudio: Improve logs
parents 0b9e24b4 2e459fb7
Loading
Loading
Loading
Loading
+20 −18
Original line number Diff line number Diff line
@@ -658,6 +658,14 @@ public class LeAudioService extends ProfileService {
        boolean newSupportedByDeviceInput = (newSupportedAudioDirections
                & AUDIO_DIRECTION_INPUT_BIT) != 0;

        /*
         * Do not update input if neither previous nor current device support input
         */
        if (!oldSupportedByDeviceInput && !newSupportedByDeviceInput) {
            Log.d(TAG, "updateActiveInDevice: Device does not support input.");
            return false;
        }

        if (device != null && mActiveAudioInDevice != null) {
            int previousGroupId = getGroupId(mActiveAudioInDevice);
            if (previousGroupId == groupId) {
@@ -673,14 +681,6 @@ public class LeAudioService extends ProfileService {

        BluetoothDevice previousInDevice = mActiveAudioInDevice;

        /*
         * Do not update input if neither previous nor current device support input
         */
        if (!oldSupportedByDeviceInput && !newSupportedByDeviceInput) {
            Log.d(TAG, "updateActiveInDevice: Device does not support input.");
            return false;
        }

        /*
         * Update input if:
         * - Device changed
@@ -717,6 +717,14 @@ public class LeAudioService extends ProfileService {
        boolean newSupportedByDeviceOutput = (newSupportedAudioDirections
                & AUDIO_DIRECTION_OUTPUT_BIT) != 0;

        /*
         * Do not update output if neither previous nor current device support output
         */
        if (!oldSupportedByDeviceOutput && !newSupportedByDeviceOutput) {
            Log.d(TAG, "updateActiveOutDevice: Device does not support output.");
            return false;
        }

        if (device != null && mActiveAudioOutDevice != null) {
            int previousGroupId = getGroupId(mActiveAudioOutDevice);
            if (previousGroupId == groupId) {
@@ -732,14 +740,6 @@ public class LeAudioService extends ProfileService {

        BluetoothDevice previousOutDevice = mActiveAudioOutDevice;

        /*
         * Do not update output if neither previous nor current device support output
         */
        if (!oldSupportedByDeviceOutput && !newSupportedByDeviceOutput) {
            Log.d(TAG, "updateActiveOutDevice: Device does not support output.");
            return false;
        }

        /*
         * Update output if:
         * - Device changed
@@ -770,14 +770,16 @@ public class LeAudioService extends ProfileService {
     * Report the active devices change to the active device manager and the media framework.
     * @param groupId id of group which devices should be updated
     * @param newActiveContexts new active contexts for group of devices
     * @param oldActiveContexts old active contexts for group of devices
     * @param isActive if there is new active group
     */
    private void updateActiveDevices(Integer groupId, Integer oldActiveContexts,
            Integer newActiveContexts, boolean isActive) {

        BluetoothDevice device = null;

        if (isActive)
        if (isActive) {
            device = getFirstDeviceFromGroup(groupId);
        }

        boolean outReplaced =
            updateActiveOutDevice(device, groupId, oldActiveContexts, newActiveContexts);
+1 −0
Original line number Diff line number Diff line
@@ -2334,6 +2334,7 @@ class LeAudioClientImpl : public LeAudioClient {

  void Cleanup(base::Callback<void()> cleanupCb) {
    if (alarm_is_scheduled(suspend_timeout_)) alarm_cancel(suspend_timeout_);
    groupStateMachine_->Cleanup();
    leAudioDevices_.Cleanup();
    aseGroups_.Cleanup();
    StopAudio();
+5 −2
Original line number Diff line number Diff line
@@ -211,7 +211,8 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {

  void StopStream(LeAudioDeviceGroup* group) override {
    if (group->IsReleasing()) {
      LOG(INFO) << __func__ << ", group already in releasing process";
      LOG(INFO) << __func__ << ", group: " << group->group_id_
                << " already in releasing process";
      return;
    }

@@ -596,7 +597,9 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
    }

    if (group->GetTargetState() != AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) {
      LOG(ERROR) << __func__ << ", Unintended CIS establishement event came";
      LOG(ERROR) << __func__
                 << ", Unintended CIS establishement event came for group id:"
                 << group->group_id_;
      StopStream(group);
      return;
    }