Loading system/bta/hearing_aid/hearing_aid.cc +21 −2 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <base/logging.h> #include <base/strings/string_number_conversions.h> // HexEncode #include <chrono> #include <cstdint> #include <mutex> #include <vector> Loading @@ -33,6 +34,7 @@ #include "bta/include/bta_gatt_queue.h" #include "bta/include/bta_hearing_aid_api.h" #include "btm_iso_api.h" #include "common/init_flags.h" #include "device/include/controller.h" #include "embdrv/g722/g722_enc_dec.h" #include "osi/include/compat.h" Loading Loading @@ -259,6 +261,11 @@ class HearingAidImpl : public HearingAid { "persist.bluetooth.hearing_aid_max_ce_len"; // Record whether the connection parameter needs to update to a better one bool needs_parameter_update = false; std::chrono::time_point<std::chrono::steady_clock> last_drop_time_point = std::chrono::steady_clock::now(); // at most 1 packet DROP per DROP_FREQUENCY_THRESHOLD seconds const int DROP_FREQUENCY_THRESHOLD = bluetooth::common::init_flags::get_asha_packet_drop_frequency_threshold(); public: ~HearingAidImpl() override = default; Loading Loading @@ -395,6 +402,16 @@ class HearingAidImpl : public HearingAid { return connection_interval; } bool IsBelowDropFrequency( std::chrono::time_point<std::chrono::steady_clock> tp) { auto duration = tp - last_drop_time_point; bool droppable = std::chrono::duration_cast<std::chrono::seconds>(duration).count() >= DROP_FREQUENCY_THRESHOLD; LOG_INFO("IsBelowDropFrequency %s", droppable ? "true" : "false"); return droppable; } void Connect(const RawAddress& address) { LOG_DEBUG("%s", ADDRESS_TO_LOGGABLE_CSTR(address)); hearingDevices.Add(HearingDevice(address, true)); Loading Loading @@ -1383,6 +1400,7 @@ class HearingAidImpl : public HearingAid { // reallocations // TODO: this should basically fit the encoded data, tune the size later std::vector<uint8_t> encoded_data_left; auto time_point = std::chrono::steady_clock::now(); if (left) { // TODO: instead of a magic number, we need to figure out the correct // buffer size Loading @@ -1397,7 +1415,7 @@ class HearingAidImpl : public HearingAid { if (packets_in_chans) { // Compare the two sides LE CoC credit value to confirm need to drop or // skip audio packet. if (NeedToDropPacket(left, right)) { if (NeedToDropPacket(left, right) && IsBelowDropFrequency(time_point)) { LOG_INFO("%s triggers dropping, %u packets in channel", ADDRESS_TO_LOGGABLE_CSTR(left->address), packets_in_chans); Loading Loading @@ -1431,7 +1449,7 @@ class HearingAidImpl : public HearingAid { if (packets_in_chans) { // Compare the two sides LE CoC credit value to confirm need to drop or // skip audio packet. if (NeedToDropPacket(right, left)) { if (NeedToDropPacket(right, left) && IsBelowDropFrequency(time_point)) { LOG_INFO("%s triggers dropping, %u packets in channel", ADDRESS_TO_LOGGABLE_CSTR(right->address), packets_in_chans); Loading @@ -1457,6 +1475,7 @@ class HearingAidImpl : public HearingAid { CalcCompressedAudioPacketSize(codec_in_use, default_data_interval_ms); if (need_drop) { last_drop_time_point = time_point; if (left) { left->audio_stats.packet_drop_count++; } Loading system/gd/rust/common/src/init_flags.rs +1 −0 Original line number Diff line number Diff line Loading @@ -358,6 +358,7 @@ pub const LOG_TAG_VERBOSE: i32 = 6; init_flags!( name: InitFlags flags: { asha_packet_drop_frequency_threshold: i32 = 60, always_send_services_if_gatt_disc_done = true, always_use_private_gatt_for_debugging, asynchronously_start_l2cap_coc = true, Loading system/gd/rust/shim/src/init_flags.rs +1 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ mod ffi { fn get_default_log_level() -> i32; fn get_hci_adapter() -> i32; fn get_log_level_for_tag(tag: &str) -> i32; fn get_asha_packet_drop_frequency_threshold() -> i32; fn hfp_dynamic_version_is_enabled() -> bool; fn irk_rotation_is_enabled() -> bool; fn leaudio_targeted_announcement_reconnection_mode_is_enabled() -> bool; Loading Loading
system/bta/hearing_aid/hearing_aid.cc +21 −2 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <base/logging.h> #include <base/strings/string_number_conversions.h> // HexEncode #include <chrono> #include <cstdint> #include <mutex> #include <vector> Loading @@ -33,6 +34,7 @@ #include "bta/include/bta_gatt_queue.h" #include "bta/include/bta_hearing_aid_api.h" #include "btm_iso_api.h" #include "common/init_flags.h" #include "device/include/controller.h" #include "embdrv/g722/g722_enc_dec.h" #include "osi/include/compat.h" Loading Loading @@ -259,6 +261,11 @@ class HearingAidImpl : public HearingAid { "persist.bluetooth.hearing_aid_max_ce_len"; // Record whether the connection parameter needs to update to a better one bool needs_parameter_update = false; std::chrono::time_point<std::chrono::steady_clock> last_drop_time_point = std::chrono::steady_clock::now(); // at most 1 packet DROP per DROP_FREQUENCY_THRESHOLD seconds const int DROP_FREQUENCY_THRESHOLD = bluetooth::common::init_flags::get_asha_packet_drop_frequency_threshold(); public: ~HearingAidImpl() override = default; Loading Loading @@ -395,6 +402,16 @@ class HearingAidImpl : public HearingAid { return connection_interval; } bool IsBelowDropFrequency( std::chrono::time_point<std::chrono::steady_clock> tp) { auto duration = tp - last_drop_time_point; bool droppable = std::chrono::duration_cast<std::chrono::seconds>(duration).count() >= DROP_FREQUENCY_THRESHOLD; LOG_INFO("IsBelowDropFrequency %s", droppable ? "true" : "false"); return droppable; } void Connect(const RawAddress& address) { LOG_DEBUG("%s", ADDRESS_TO_LOGGABLE_CSTR(address)); hearingDevices.Add(HearingDevice(address, true)); Loading Loading @@ -1383,6 +1400,7 @@ class HearingAidImpl : public HearingAid { // reallocations // TODO: this should basically fit the encoded data, tune the size later std::vector<uint8_t> encoded_data_left; auto time_point = std::chrono::steady_clock::now(); if (left) { // TODO: instead of a magic number, we need to figure out the correct // buffer size Loading @@ -1397,7 +1415,7 @@ class HearingAidImpl : public HearingAid { if (packets_in_chans) { // Compare the two sides LE CoC credit value to confirm need to drop or // skip audio packet. if (NeedToDropPacket(left, right)) { if (NeedToDropPacket(left, right) && IsBelowDropFrequency(time_point)) { LOG_INFO("%s triggers dropping, %u packets in channel", ADDRESS_TO_LOGGABLE_CSTR(left->address), packets_in_chans); Loading Loading @@ -1431,7 +1449,7 @@ class HearingAidImpl : public HearingAid { if (packets_in_chans) { // Compare the two sides LE CoC credit value to confirm need to drop or // skip audio packet. if (NeedToDropPacket(right, left)) { if (NeedToDropPacket(right, left) && IsBelowDropFrequency(time_point)) { LOG_INFO("%s triggers dropping, %u packets in channel", ADDRESS_TO_LOGGABLE_CSTR(right->address), packets_in_chans); Loading @@ -1457,6 +1475,7 @@ class HearingAidImpl : public HearingAid { CalcCompressedAudioPacketSize(codec_in_use, default_data_interval_ms); if (need_drop) { last_drop_time_point = time_point; if (left) { left->audio_stats.packet_drop_count++; } Loading
system/gd/rust/common/src/init_flags.rs +1 −0 Original line number Diff line number Diff line Loading @@ -358,6 +358,7 @@ pub const LOG_TAG_VERBOSE: i32 = 6; init_flags!( name: InitFlags flags: { asha_packet_drop_frequency_threshold: i32 = 60, always_send_services_if_gatt_disc_done = true, always_use_private_gatt_for_debugging, asynchronously_start_l2cap_coc = true, Loading
system/gd/rust/shim/src/init_flags.rs +1 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ mod ffi { fn get_default_log_level() -> i32; fn get_hci_adapter() -> i32; fn get_log_level_for_tag(tag: &str) -> i32; fn get_asha_packet_drop_frequency_threshold() -> i32; fn hfp_dynamic_version_is_enabled() -> bool; fn irk_rotation_is_enabled() -> bool; fn leaudio_targeted_announcement_reconnection_mode_is_enabled() -> bool; Loading