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

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

leaudio: Remove not needed flag in the stream_conf

This structure is valid when configuration pointer is valid.
No need for special flag

Bug: 150670922
Test: atest --host  bluetooth_le_audio_client_test bluetooth_le_audio_test
Tag: #feature
sponsor: jpawlowski@
Change-Id: I207547c67cb2c64c04cde3cee878b83d1bed7196
parent d563197c
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -1705,8 +1705,9 @@ class LeAudioClientImpl : public LeAudioClient {
    LeAudioDeviceGroup* group = aseGroups_.FindById(active_group_id_);
    auto* stream_conf = &group->stream_conf;

    if (!stream_conf->valid) {
      LOG(INFO) << __func__
    if (audio_sender_state_ == AudioState::IDLE &&
        audio_receiver_state_ == AudioState::IDLE) {
      DLOG(INFO) << __func__
                 << " Device not streaming but active. Lets update audio "
                    "session to match needed channel number";
      UpdateCurrentHalSessions(active_group_id_, current_context_type_);
@@ -2014,7 +2015,6 @@ class LeAudioClientImpl : public LeAudioClient {
    stream_conf->sink_sample_frequency_hz = sample_freq_hz;
    stream_conf->sink_frame_duration_us = frame_duration_us;
    stream_conf->sink_octets_per_codec_frame = octets_per_frame;
    stream_conf->valid = true;

    LOG(INFO) << __func__ << " configuration: " << stream_conf->conf->name;

@@ -2033,7 +2033,9 @@ class LeAudioClientImpl : public LeAudioClient {
    }

    auto stream_conf = group->stream_conf;
    if (!stream_conf.valid || (stream_conf.sink_num_of_devices > 2)) {
    if ((stream_conf.sink_num_of_devices > 2) ||
        (stream_conf.sink_num_of_devices == 0) ||
        stream_conf.sink_streams.empty()) {
      LOG(ERROR) << __func__ << " Stream configufation is not valid.";
      return;
    }
@@ -2160,7 +2162,6 @@ class LeAudioClientImpl : public LeAudioClient {
        ase->codec_config.GetFrameDurationUs();
    stream_conf->source_octets_per_codec_frame =
        *ase->codec_config.octets_per_codec_frame;
    stream_conf->valid = true;

    LOG(INFO) << __func__ << " Added CIS: " << +ase->cis_conn_hdl
              << " to stream. Allocation: "
+0 −1
Original line number Diff line number Diff line
@@ -1187,7 +1187,6 @@ void LeAudioDeviceGroup::Dump(int fd) {
         << "      active stream configuration name: "
         << (active_conf ? active_conf->name : " not set") << "\n"
         << "    Last used stream configuration: \n"
         << "      valid: " << (stream_conf.valid ? " Yes " : " No") << "\n"
         << "      codec id : " << +(stream_conf.id.coding_format) << "\n"
         << "      name: "
         << (stream_conf.conf != nullptr ? stream_conf.conf->name : " null ")
+18 −28
Original line number Diff line number Diff line
@@ -365,21 +365,19 @@ class UnicastTestNoInit : public Test {

    // default action for WriteDescriptor function call
    ON_CALL(mock_gatt_queue_, WriteDescriptor(_, _, _, _, _, _))
        .WillByDefault(
            Invoke([](uint16_t conn_id, uint16_t handle,
                      std::vector<uint8_t> value, tGATT_WRITE_TYPE write_type,
        .WillByDefault(Invoke([](uint16_t conn_id, uint16_t handle,
                                 std::vector<uint8_t> value,
                                 tGATT_WRITE_TYPE write_type,
                                 GATT_WRITE_OP_CB cb, void* cb_data) -> void {
          if (cb)
                do_in_main_thread(FROM_HERE,
            do_in_main_thread(
                FROM_HERE,
                base::BindOnce(
                                      [](GATT_WRITE_OP_CB cb, uint16_t conn_id,
                                         uint16_t handle, uint16_t len,
                                         uint8_t* value, void* cb_data) {
                                        cb(conn_id, GATT_SUCCESS, handle, len,
                                           value, cb_data);
                    [](GATT_WRITE_OP_CB cb, uint16_t conn_id, uint16_t handle,
                       uint16_t len, uint8_t* value, void* cb_data) {
                      cb(conn_id, GATT_SUCCESS, handle, len, value, cb_data);
                    },
                                      cb, conn_id, handle, value.size(),
                                      value.data(), cb_data));
                    cb, conn_id, handle, value.size(), value.data(), cb_data));
        }));

    global_conn_id = 1;
@@ -565,7 +563,8 @@ class UnicastTestNoInit : public Test {
                              LeAudioDevice* leAudioDevice) {
          if (!group) return;
          auto* stream_conf = &group->stream_conf;
          if (stream_conf->valid) {
          if (!stream_conf->sink_streams.empty() ||
              !stream_conf->source_streams.empty()) {
            stream_conf->sink_streams.erase(
                std::remove_if(stream_conf->sink_streams.begin(),
                               stream_conf->sink_streams.end(),
@@ -585,11 +584,6 @@ class UnicastTestNoInit : public Test {
                                 return ases.source;
                               }),
                stream_conf->source_streams.end());

            if (stream_conf->sink_streams.empty()) {
              LOG(INFO) << __func__ << " stream stopped ";
              stream_conf->valid = false;
            }
          }

          if (group->IsEmpty()) {
@@ -615,7 +609,8 @@ class UnicastTestNoInit : public Test {
              }
              /* Invalidate stream configuration if needed */
              auto* stream_conf = &group->stream_conf;
              if (stream_conf->valid) {
              if (!stream_conf->sink_streams.empty() ||
                  !stream_conf->source_streams.empty()) {
                stream_conf->sink_streams.erase(
                    std::remove_if(
                        stream_conf->sink_streams.begin(),
@@ -645,11 +640,6 @@ class UnicastTestNoInit : public Test {
                          return ases.source;
                        }),
                    stream_conf->source_streams.end());

                if (stream_conf->sink_streams.empty()) {
                  LOG(INFO) << __func__ << " stream stopped ";
                  stream_conf->valid = false;
                }
              }
            });

+0 −1
Original line number Diff line number Diff line
@@ -950,7 +950,6 @@ const AudioSetConfigurations* get_confs_by_type(types::LeAudioContextType type);
}  // namespace set_configurations

struct stream_configuration {
  bool valid;

  types::LeAudioCodecId id;

+4 −14
Original line number Diff line number Diff line
@@ -497,7 +497,8 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
    }

    auto* stream_conf = &group->stream_conf;
    if (stream_conf->valid) {
    if (!stream_conf->sink_streams.empty() ||
        !stream_conf->source_streams.empty()) {
      stream_conf->sink_streams.erase(
          std::remove_if(stream_conf->sink_streams.begin(),
                         stream_conf->sink_streams.end(),
@@ -517,12 +518,6 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
                           return ases.source;
                         }),
          stream_conf->source_streams.end());

      if (stream_conf->sink_streams.empty() &&
          stream_conf->source_streams.empty()) {
        LOG(INFO) << __func__ << " stream stopped ";
        stream_conf->valid = false;
      }
    }

    /* mark ASEs as not used. */
@@ -674,7 +669,8 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {

    /* Invalidate stream configuration if needed */
    auto* stream_conf = &group->stream_conf;
    if (stream_conf->valid) {
    if (!stream_conf->sink_streams.empty() ||
        !stream_conf->source_streams.empty()) {
      if (ases_pair.sink) {
        stream_conf->sink_streams.erase(
            std::remove_if(stream_conf->sink_streams.begin(),
@@ -694,12 +690,6 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
                           }),
            stream_conf->source_streams.end());
      }

      if (stream_conf->sink_streams.empty() &&
          stream_conf->source_streams.empty()) {
        LOG(INFO) << __func__ << " stream stopped ";
        stream_conf->valid = false;
      }
    }

    auto target_state = group->GetTargetState();