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

Commit 5b38fa67 authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

LeAudio: Improve function naming

This change improves some of the function naming
so that it was more obvious what each of them do
at the point where they are called, without looking
into the implementation. This improves code readability.
It also for consisency replaces a static DebugDump
function call that was called on an instance, while
all other calls around are called directly from the
class namespace.

Bug: 256967923
Test: atest --host bluetooth_le_audio_test bluetooth_le_audio_client_test --no-bazel-mode
Change-Id: Id51c18211ee3936b8890dc21c0ed139969b51810
parent c0399e75
Loading
Loading
Loading
Loading
+34 −27
Original line number Diff line number Diff line
@@ -2513,8 +2513,9 @@ class LeAudioClientImpl : public LeAudioClient {
    cached_channel_is_left_ = false;
  }

  void SendAudioData(uint8_t* data, uint16_t size, uint16_t cis_conn_hdl,
                     uint32_t timestamp) {
  /* Handles audio data packets coming from the controller */
  void HandleIncomingCisData(uint8_t* data, uint16_t size,
                             uint16_t cis_conn_hdl, uint32_t timestamp) {
    /* Get only one channel for MONO microphone */
    /* Gather data for channel */
    if ((active_group_id_ == bluetooth::groups::kGroupUnknown) ||
@@ -3063,7 +3064,7 @@ class LeAudioClientImpl : public LeAudioClient {
  }

  void OnLocalAudioSourceSuspend() {
    LOG_DEBUG(" IN: audio_receiver_state_: %s,  audio_sender_state_: %s",
    LOG_INFO("IN: audio_receiver_state_: %s,  audio_sender_state_: %s",
             ToString(audio_receiver_state_).c_str(),
             ToString(audio_sender_state_).c_str());

@@ -3094,14 +3095,15 @@ class LeAudioClientImpl : public LeAudioClient {
      le_audio::MetricsCollector::Get()->OnStreamEnded(active_group_id_);
    }

    DLOG(INFO) << __func__
               << " OUT: audio_receiver_state_: " << audio_receiver_state_
               << " audio_sender_state_: " << audio_sender_state_;
    LOG_INFO("OUT: audio_receiver_state_: %s,  audio_sender_state_: %s",
             ToString(audio_receiver_state_).c_str(),
             ToString(audio_sender_state_).c_str());
  }

  void OnLocalAudioSourceResume() {
    LOG(INFO) << __func__;

    LOG_INFO("IN: audio_receiver_state_: %s,  audio_sender_state_: %s",
             ToString(audio_receiver_state_).c_str(),
             ToString(audio_sender_state_).c_str());
    /* Note: This callback is from audio hal driver.
     * Bluetooth peer is a Sink for Audio Framework.
     * e.g. Peer is a speaker
@@ -3207,7 +3209,7 @@ class LeAudioClientImpl : public LeAudioClient {
  }

  void OnLocalAudioSinkSuspend() {
    LOG_DEBUG(" IN: audio_receiver_state_: %s,  audio_sender_state_: %s",
    LOG_INFO("IN: audio_receiver_state_: %s,  audio_sender_state_: %s",
             ToString(audio_receiver_state_).c_str(),
             ToString(audio_sender_state_).c_str());

@@ -3236,9 +3238,9 @@ class LeAudioClientImpl : public LeAudioClient {
        (audio_sender_state_ == AudioState::READY_TO_RELEASE))
      OnAudioSuspend();

    DLOG(INFO) << __func__
               << " OUT: audio_receiver_state_: " << audio_receiver_state_
               << " audio_sender_state_: " << audio_sender_state_;
    LOG_INFO("OUT: audio_receiver_state_: %s,  audio_sender_state_: %s",
             ToString(audio_receiver_state_).c_str(),
             ToString(audio_sender_state_).c_str());
  }

  bool IsAudioSourceAvailableForCurrentConfiguration() {
@@ -3251,7 +3253,9 @@ class LeAudioClientImpl : public LeAudioClient {
  }

  void OnLocalAudioSinkResume() {
    LOG(INFO) << __func__;
    LOG_INFO("IN: audio_receiver_state_: %s,  audio_sender_state_: %s",
             ToString(audio_receiver_state_).c_str(),
             ToString(audio_sender_state_).c_str());

    /* Note: This callback is from audio hal driver.
     * Bluetooth peer is a Source for Audio Framework.
@@ -3401,8 +3405,9 @@ class LeAudioClientImpl : public LeAudioClient {
    auto reconfig_result = UpdateConfigAndCheckIfReconfigurationIsNeeded(
        group->group_id_, new_context_type);

    LOG_INFO("group_id %d, context type %s, reconfig_needed %s",
             group->group_id_, ToHexString(new_context_type).c_str(),
    LOG_INFO("group_id %d, context type %s (%s), %s", group->group_id_,
             ToString(new_context_type).c_str(),
             ToHexString(new_context_type).c_str(),
             ToString(reconfig_result).c_str());
    if (reconfig_result ==
        AudioReconfigurationResult::RECONFIGURATION_NOT_NEEDED) {
@@ -3642,7 +3647,7 @@ class LeAudioClientImpl : public LeAudioClient {
          break;
        }

        SendAudioData(event->p_msg->data + event->p_msg->offset,
        HandleIncomingCisData(event->p_msg->data + event->p_msg->offset,
                              event->p_msg->len - event->p_msg->offset,
                              event->cis_conn_hdl, event->ts);
      } break;
@@ -3849,7 +3854,7 @@ class LeAudioClientImpl : public LeAudioClient {
    stream_setup_start_timestamp_ = 0;
  }

  void StatusReportCb(int group_id, GroupStreamStatus status) {
  void OnStateMachineStatusReportCb(int group_id, GroupStreamStatus status) {
    LOG_INFO("status: %d , audio_sender_state %s, audio_receiver_state %s",
             static_cast<int>(status),
             bluetooth::common::ToString(audio_sender_state_).c_str(),
@@ -4132,7 +4137,7 @@ LeAudioStateMachineHciCallbacksImpl stateMachineHciCallbacksImpl;
class CallbacksImpl : public LeAudioGroupStateMachine::Callbacks {
 public:
  void StatusReportCb(int group_id, GroupStreamStatus status) override {
    if (instance) instance->StatusReportCb(group_id, status);
    if (instance) instance->OnStateMachineStatusReportCb(group_id, status);
  }

  void OnStateTransitionTimeout(int group_id) override {
@@ -4158,7 +4163,8 @@ class SourceCallbacksImpl : public LeAudioSourceAudioHalClient::Callbacks {

  void OnAudioMetadataUpdate(
      std::vector<struct playback_track_metadata> source_metadata) override {
    if (instance) instance->OnLocalAudioSourceMetadataUpdate(source_metadata);
    if (instance)
      instance->OnLocalAudioSourceMetadataUpdate(std::move(source_metadata));
  }
};

@@ -4174,7 +4180,8 @@ class SinkCallbacksImpl : public LeAudioSinkAudioHalClient::Callbacks {

  void OnAudioMetadataUpdate(
      std::vector<struct record_track_metadata> sink_metadata) override {
    if (instance) instance->OnLocalAudioSinkMetadataUpdate(sink_metadata);
    if (instance)
      instance->OnLocalAudioSinkMetadataUpdate(std::move(sink_metadata));
  }
};

@@ -4323,7 +4330,7 @@ void LeAudioClient::DebugDump(int fd) {

  LeAudioSinkAudioHalClient::DebugDump(fd);
  LeAudioSourceAudioHalClient::DebugDump(fd);
  le_audio::AudioSetConfigurationProvider::Get()->DebugDump(fd);
  le_audio::AudioSetConfigurationProvider::DebugDump(fd);
  IsoManager::GetInstance()->Dump(fd);
  dprintf(fd, "\n");
}
+1 −1
Original line number Diff line number Diff line
@@ -856,7 +856,7 @@ bool LeAudioDeviceGroup::IsInTransition(void) {
  return target_state_ != current_state_;
}

bool LeAudioDeviceGroup::IsReleasing(void) {
bool LeAudioDeviceGroup::IsReleasingOrIdle(void) {
  return target_state_ == AseState::BTA_LE_AUDIO_ASE_STATE_IDLE;
}

+1 −1
Original line number Diff line number Diff line
@@ -362,7 +362,7 @@ class LeAudioDeviceGroup {
  }

  bool IsInTransition(void);
  bool IsReleasing(void);
  bool IsReleasingOrIdle(void);
  void Dump(int fd, int active_group_id);

 private:
+1 −1
Original line number Diff line number Diff line
@@ -278,7 +278,7 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
  }

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