diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2022-03-28 07:25:55 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2022-03-28 07:25:55 +0000 |
commit | 0d33ffe00bbfb83aac999ef9ba84d908bddaa0d3 (patch) | |
tree | 0bb40338aedd534c2607ad0968f4a0df60c30e20 | |
parent | 95955ba79f604449ff1de861c18659a78c10f838 (diff) | |
parent | e08a02acb5530bcf5c12aef3ed719e06a511e816 (diff) |
Merge changes Ia785af19,Id9eb0614
* changes:
leaudio: Clear CIS ID allocation when group goes to IDLE
leaudio: Start using gd log style
-rw-r--r-- | system/bta/le_audio/client.cc | 18 | ||||
-rw-r--r-- | system/bta/le_audio/devices.cc | 2 | ||||
-rw-r--r-- | system/bta/le_audio/le_audio_types.cc | 29 | ||||
-rw-r--r-- | system/bta/le_audio/le_audio_types.h | 12 | ||||
-rw-r--r-- | system/bta/le_audio/state_machine.cc | 77 |
5 files changed, 82 insertions, 56 deletions
diff --git a/system/bta/le_audio/client.cc b/system/bta/le_audio/client.cc index d3274ac39c..e731338e7e 100644 --- a/system/bta/le_audio/client.cc +++ b/system/bta/le_audio/client.cc @@ -36,7 +36,9 @@ #include "devices.h" #include "embdrv/lc3/include/lc3.h" #include "gatt/bta_gattc_int.h" +#include "gd/common/strings.h" #include "le_audio_types.h" +#include "osi/include/log.h" #include "osi/include/osi.h" #include "osi/include/properties.h" #include "stack/btm/btm_dev.h" @@ -46,6 +48,7 @@ using base::Closure; using bluetooth::Uuid; +using bluetooth::common::ToString; using bluetooth::groups::DeviceGroups; using bluetooth::groups::DeviceGroupsCallbacks; using bluetooth::hci::IsoManager; @@ -598,15 +601,15 @@ class LeAudioClientImpl : public LeAudioClient { } if (group->IsInTransition()) { - LOG(INFO) << __func__ - << ", group is in transition from: " << group->GetState() - << ", to: " << group->GetTargetState(); + LOG_INFO(", group is in transition from: %s to: %s", + ToString(group->GetState()).c_str(), + ToString(group->GetTargetState()).c_str()); return; } if (group->GetState() != AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) { - LOG(ERROR) << __func__ - << ", invalid current state of group: " << group->GetState(); + LOG_ERROR(", invalid current state of group: %s", + ToString(group->GetState()).c_str()); return; } @@ -627,8 +630,9 @@ class LeAudioClientImpl : public LeAudioClient { } if (group->GetState() == AseState::BTA_LE_AUDIO_ASE_STATE_IDLE) { - LOG(ERROR) << __func__ - << ", group already stopped: " << group->GetState(); + LOG_ERROR(", group already stopped: %s", + ToString(group->GetState()).c_str()); + return; } diff --git a/system/bta/le_audio/devices.cc b/system/bta/le_audio/devices.cc index 58ca4c46c4..0015a0d403 100644 --- a/system/bta/le_audio/devices.cc +++ b/system/bta/le_audio/devices.cc @@ -28,7 +28,9 @@ #include "btm_iso_api_types.h" #include "client_audio.h" #include "device/include/controller.h" +#include "gd/common/strings.h" #include "le_audio_set_configuration_provider.h" +#include "osi/include/log.h" using bluetooth::hci::kIsoCigFramingFramed; using bluetooth::hci::kIsoCigFramingUnframed; diff --git a/system/bta/le_audio/le_audio_types.cc b/system/bta/le_audio/le_audio_types.cc index 3c082fb338..235e43f17a 100644 --- a/system/bta/le_audio/le_audio_types.cc +++ b/system/bta/le_audio/le_audio_types.cc @@ -443,20 +443,8 @@ uint8_t GetMaxCodecFramesPerSduFromPac(const acs_ac_record* pac) { return 1; } -} // namespace le_audio - -std::ostream& operator<<(std::ostream& os, - const le_audio::types::LeAudioLc3Config& config) { - os << " LeAudioLc3Config(SamplFreq=" << loghex(*config.sampling_frequency) - << ", FrameDur=" << loghex(*config.frame_duration) - << ", OctetsPerFrame=" << int(*config.octets_per_codec_frame) - << ", CodecFramesBlocksPerSDU=" << int(*config.codec_frames_blocks_per_sdu) - << ", AudioChanLoc=" << loghex(*config.audio_channel_allocation) << ")"; - return os; -} - -std::ostream& operator<<(std::ostream& os, - const le_audio::types::AseState& state) { +namespace types { +std::ostream& operator<<(std::ostream& os, const types::AseState& state) { static const char* char_value_[7] = { "IDLE", "CODEC_CONFIGURED", "QOS_CONFIGURED", "ENABLING", "STREAMING", "DISABLING", "RELEASING", @@ -467,3 +455,16 @@ std::ostream& operator<<(std::ostream& os, << ")"; return os; } + +std::ostream& operator<<(std::ostream& os, + const types::LeAudioLc3Config& config) { + os << " LeAudioLc3Config(SamplFreq=" << loghex(*config.sampling_frequency) + << ", FrameDur=" << loghex(*config.frame_duration) + << ", OctetsPerFrame=" << int(*config.octets_per_codec_frame) + << ", CodecFramesBlocksPerSDU=" << int(*config.codec_frames_blocks_per_sdu) + << ", AudioChanLoc=" << loghex(*config.audio_channel_allocation) << ")"; + return os; +} +} // namespace types + +} // namespace le_audio diff --git a/system/bta/le_audio/le_audio_types.h b/system/bta/le_audio/le_audio_types.h index ab1410a1bb..f733b15208 100644 --- a/system/bta/le_audio/le_audio_types.h +++ b/system/bta/le_audio/le_audio_types.h @@ -575,6 +575,9 @@ using PublishedAudioCapabilities = using AudioLocations = std::bitset<32>; using AudioContexts = std::bitset<16>; +std::ostream& operator<<(std::ostream& os, const AseState& state); + +std::ostream& operator<<(std::ostream& os, const LeAudioLc3Config& config); } // namespace types namespace set_configurations { @@ -696,11 +699,4 @@ void AppendMetadataLtvEntryForCcidList(std::vector<uint8_t>& metadata, void AppendMetadataLtvEntryForStreamingContext( std::vector<uint8_t>& metadata, types::LeAudioContextType context_type); uint8_t GetMaxCodecFramesPerSduFromPac(const types::acs_ac_record* pac_record); - -} // namespace le_audio - -std::ostream& operator<<(std::ostream& os, - const le_audio::types::LeAudioLc3Config& config); - -std::ostream& operator<<(std::ostream& os, - const le_audio::types::AseState& state); +} // namespace le_audio
\ No newline at end of file diff --git a/system/bta/le_audio/state_machine.cc b/system/bta/le_audio/state_machine.cc index 97d8a47d76..8241833af9 100644 --- a/system/bta/le_audio/state_machine.cc +++ b/system/bta/le_audio/state_machine.cc @@ -29,9 +29,11 @@ #include "client_parser.h" #include "codec_manager.h" #include "devices.h" +#include "gd/common/strings.h" #include "hcimsgs.h" #include "le_audio_types.h" #include "osi/include/alarm.h" +#include "osi/include/log.h" #include "osi/include/osi.h" #include "osi/include/properties.h" @@ -86,6 +88,7 @@ */ // clang-format on +using bluetooth::common::ToString; using bluetooth::hci::IsoManager; using bluetooth::le_audio::GroupStreamStatus; using le_audio::CodecManager; @@ -133,8 +136,8 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { * group and just got reconnected. */ if (group->GetState() != AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) { - LOG(ERROR) << __func__ - << " group not in the streaming state: " << group->GetState(); + LOG_ERROR(" group not in the streaming state: %s", + ToString(group->GetState()).c_str()); return false; } @@ -144,7 +147,7 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { bool StartStream(LeAudioDeviceGroup* group, le_audio::types::LeAudioContextType context_type) override { - LOG(INFO) << __func__ << " current state: " << group->GetState(); + LOG_INFO(" current state: %s", ToString(group->GetState()).c_str()); switch (group->GetState()) { case AseState::BTA_LE_AUDIO_ASE_STATE_CODEC_CONFIGURED: @@ -190,7 +193,8 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { } default: - LOG(ERROR) << "Unable to transit from " << group->GetState(); + LOG_ERROR("Unable to transit from %s", + ToString(group->GetState()).c_str()); return false; } @@ -239,9 +243,10 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { ParseAseStatusHeader(arh, len, value); - LOG(INFO) << __func__ << " " << leAudioDevice->address_ - << ", ASE id: " << +ase->id << " state changed " << ase->state - << " -> " << AseState(arh.state); + LOG_INFO(" %s , ASE id: %d, state changed %s -> %s ", + leAudioDevice->address_.ToString().c_str(), +ase->id, + ToString(ase->state).c_str(), + ToString(AseState(arh.state)).c_str()); switch (static_cast<AseState>(arh.state)) { case AseState::BTA_LE_AUDIO_ASE_STATE_IDLE: @@ -347,9 +352,9 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { if (group->GetTargetState() == AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) { StartConfigQoSForTheGroup(group); } else { - LOG(ERROR) << __func__ - << ", invalid state transition, from: " << group->GetState() - << ", to: " << group->GetTargetState(); + LOG_ERROR(", invalid state transition, from: %s , to: %s", + ToString(group->GetState()).c_str(), + ToString(group->GetTargetState()).c_str()); StopStream(group); return; } @@ -381,7 +386,6 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { for (auto& ase : leAudioDevice->ases_) { ase.data_path_state = AudioStreamDataPathState::IDLE; - ase.cis_id = le_audio::kInvalidCisId; } } while ((leAudioDevice = group->GetNextDevice(leAudioDevice))); } @@ -485,6 +489,22 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { << ", duplicatePackets: " << loghex(duplicatePackets); } + void ReleaseCisIds(LeAudioDeviceGroup* group) { + if (group == nullptr) { + LOG_DEBUG(" Group is null."); + return; + } + LOG_DEBUG(" Releasing CIS is for group %d", group->group_id_); + + LeAudioDevice* leAudioDevice = group->GetFirstDevice(); + while (leAudioDevice != nullptr) { + for (auto& ase : leAudioDevice->ases_) { + ase.cis_id = le_audio::kInvalidCisId; + } + leAudioDevice = group->GetNextDevice(leAudioDevice); + } + } + void ProcessHciNotifAclDisconnected(LeAudioDeviceGroup* group, LeAudioDevice* leAudioDevice) { FreeLinkQualityReports(leAudioDevice); @@ -554,6 +574,7 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { group->SetState(AseState::BTA_LE_AUDIO_ASE_STATE_IDLE); group->SetTargetState(AseState::BTA_LE_AUDIO_ASE_STATE_IDLE); if (alarm_is_scheduled(watchdog_)) alarm_cancel(watchdog_); + ReleaseCisIds(group); state_machine_callbacks_->StatusReportCb(group->group_id_, GroupStreamStatus::IDLE); @@ -852,6 +873,8 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { << " shouldn't be called without an active ASE"; do { auto& cis = ase->cis_id; + ASSERT_LOG(ase->cis_id != le_audio::kInvalidCisId, + " ase id %d has invalid cis id %d", ase->id, ase->cis_id); auto iter = find_if(cis_cfgs.begin(), cis_cfgs.end(), [&cis](auto const& cfg) { return cis == cfg.cis_id; }); @@ -1056,7 +1079,7 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { if (alarm_is_scheduled(watchdog_)) alarm_cancel(watchdog_); group->SetState(AseState::BTA_LE_AUDIO_ASE_STATE_IDLE); - + ReleaseCisIds(group); state_machine_callbacks_->StatusReportCb(group->group_id_, GroupStreamStatus::IDLE); } @@ -1411,9 +1434,9 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { state_machine_callbacks_->StatusReportCb( group->group_id_, GroupStreamStatus::SUSPENDED); } else { - LOG(ERROR) << __func__ << ", invalid state transition, from: " - << group->GetState() - << ", to: " << group->GetTargetState(); + LOG_ERROR(", invalid state transition, from: %s, to: %s", + ToString(group->GetState()).c_str(), + ToString(group->GetTargetState()).c_str()); StopStream(group); return; } @@ -1689,9 +1712,9 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { return; } else { - LOG(ERROR) << __func__ << ", invalid state transition, from: " - << group->GetState() - << ", to: " << group->GetTargetState(); + LOG_ERROR(", invalid state transition, from: %s, to: %s", + ToString(group->GetState()).c_str(), + ToString(group->GetTargetState()).c_str()); StopStream(group); return; } @@ -1739,9 +1762,9 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { if (ase->direction == le_audio::types::kLeAudioDirectionSink) { /* Sink ASE state machine does not have Disabling state */ - LOG(ERROR) << __func__ - << ", invalid state transition, from: " << group->GetState() - << ", to: " << group->GetTargetState(); + LOG_ERROR(", invalid state transition, from: %s , to: %s ", + ToString(group->GetState()).c_str(), + ToString(group->GetTargetState()).c_str()); StopStream(group); return; } @@ -1865,9 +1888,9 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { if (group->GetTargetState() == AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) { CisCreate(group); } else { - LOG(ERROR) << __func__ - << ", invalid state transition, from: " << group->GetState() - << ", to: " << group->GetTargetState(); + LOG_ERROR(", invalid state transition, from: %s , to: %s ", + ToString(group->GetState()).c_str(), + ToString(group->GetTargetState()).c_str()); StopStream(group); } } @@ -1896,9 +1919,9 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine { AseState::BTA_LE_AUDIO_ASE_STATE_QOS_CONFIGURED) { ReleaseDataPath(group); } else { - LOG(ERROR) << __func__ - << ", invalid state transition, from: " << group->GetState() - << ", to: " << group->GetTargetState(); + LOG_ERROR(", invalid state transition, from: %s , to: %s ", + ToString(group->GetState()).c_str(), + ToString(group->GetTargetState()).c_str()); StopStream(group); } } |