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

Commit b2334712 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

leaudio: Fix StartReceivingAudio or StartSendingAudio failed

When StartReceivingAudio and StartSendingAudio fails we should stop the
stream.

Bug: 301211890
Test: atest  bluetooth_le_audio_client_test
Tag: #feature
Change-Id: Ic715ba3e23f2decf7a2be2e15fc60b174edc4831
parent 5435a83f
Loading
Loading
Loading
Loading
+10 −6
Original line number Original line Diff line number Diff line
@@ -3413,7 +3413,7 @@ class LeAudioClientImpl : public LeAudioClient {
    audio_receiver_state_ = AudioState::STARTED;
    audio_receiver_state_ = AudioState::STARTED;
  }
  }


  bool StartSendingAudio(int group_id) {
  void StartSendingAudio(int group_id) {
    LOG(INFO) << __func__;
    LOG(INFO) << __func__;


    LeAudioDeviceGroup* group = aseGroups_.FindById(group_id);
    LeAudioDeviceGroup* group = aseGroups_.FindById(group_id);
@@ -3425,7 +3425,8 @@ class LeAudioClientImpl : public LeAudioClient {
    auto* stream_conf = GetStreamSinkConfiguration(group);
    auto* stream_conf = GetStreamSinkConfiguration(group);
    if (stream_conf == nullptr) {
    if (stream_conf == nullptr) {
      LOG(ERROR) << __func__ << " could not get sink configuration";
      LOG(ERROR) << __func__ << " could not get sink configuration";
      return false;
      groupStateMachine_->StopStream(group);
      return;
    }
    }


    LOG_DEBUG("Sink stream config (#%d):\n",
    LOG_DEBUG("Sink stream config (#%d):\n",
@@ -3457,7 +3458,8 @@ class LeAudioClientImpl : public LeAudioClient {
          audio_framework_source_config, current_source_codec_config);
          audio_framework_source_config, current_source_codec_config);
      if (codec_status != le_audio::CodecInterface::Status::STATUS_OK) {
      if (codec_status != le_audio::CodecInterface::Status::STATUS_OK) {
        LOG_ERROR("Left channel codec setup failed with err: %d", codec_status);
        LOG_ERROR("Left channel codec setup failed with err: %d", codec_status);
        return false;
        groupStateMachine_->StopStream(group);
        return;
      }
      }


      sw_enc_right =
      sw_enc_right =
@@ -3467,7 +3469,8 @@ class LeAudioClientImpl : public LeAudioClient {
      if (codec_status != le_audio::CodecInterface::Status::STATUS_OK) {
      if (codec_status != le_audio::CodecInterface::Status::STATUS_OK) {
        LOG_ERROR("Right channel codec setup failed with err: %d",
        LOG_ERROR("Right channel codec setup failed with err: %d",
                  codec_status);
                  codec_status);
        return false;
        groupStateMachine_->StopStream(group);
        return;
      }
      }
    }
    }


@@ -3487,8 +3490,6 @@ class LeAudioClientImpl : public LeAudioClient {
                    weak_factory_.GetWeakPtr(), std::placeholders::_1,
                    weak_factory_.GetWeakPtr(), std::placeholders::_1,
                    std::placeholders::_2));
                    std::placeholders::_2));
    }
    }

    return true;
  }
  }


  const struct le_audio::stream_configuration* GetStreamSourceConfiguration(
  const struct le_audio::stream_configuration* GetStreamSourceConfiguration(
@@ -3511,6 +3512,7 @@ class LeAudioClientImpl : public LeAudioClient {
    if (!stream_conf) {
    if (!stream_conf) {
      LOG(WARNING) << " Could not get source configuration for group "
      LOG(WARNING) << " Could not get source configuration for group "
                   << active_group_id_ << " probably microphone not configured";
                   << active_group_id_ << " probably microphone not configured";
      groupStateMachine_->StopStream(group);
      return;
      return;
    }
    }


@@ -3531,6 +3533,7 @@ class LeAudioClientImpl : public LeAudioClient {
                                                   audio_framework_sink_config);
                                                   audio_framework_sink_config);
      if (codec_status != le_audio::CodecInterface::Status::STATUS_OK) {
      if (codec_status != le_audio::CodecInterface::Status::STATUS_OK) {
        LOG_ERROR("Left channel codec setup failed with err: %d", codec_status);
        LOG_ERROR("Left channel codec setup failed with err: %d", codec_status);
        groupStateMachine_->StopStream(group);
        return;
        return;
      }
      }


@@ -3541,6 +3544,7 @@ class LeAudioClientImpl : public LeAudioClient {
      if (codec_status != le_audio::CodecInterface::Status::STATUS_OK) {
      if (codec_status != le_audio::CodecInterface::Status::STATUS_OK) {
        LOG_ERROR("Right channel codec setup failed with err: %d",
        LOG_ERROR("Right channel codec setup failed with err: %d",
                  codec_status);
                  codec_status);
        groupStateMachine_->StopStream(group);
        return;
        return;
      }
      }
    }
    }