mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 13:20:39 +00:00
hci: improve sco send without sco flow control for smaller packets
This commit is contained in:
parent
2332f233d7
commit
96627858b8
@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
|
||||
### Changed
|
||||
- HCI: hci_request_cis_can_send_now_events for CIG in Central role will emit can send now events for all streams in group
|
||||
- HCI: improve sco send without sco flow control for smaller packets
|
||||
- GAP: validate params in gap_set_scan_params
|
||||
- HID Host: emit HID_SUBEVENT_INCOMING_CONNECTION if memory allocation fails
|
||||
- BTstack HID: remove HID_PROTOCOL_MODE_REPORT_WITH_FALLBACK_TO_BOOT
|
||||
|
23
src/hci.c
23
src/hci.c
@ -4805,8 +4805,17 @@ static void sco_handler(uint8_t * packet, uint16_t size){
|
||||
} else {
|
||||
// log_debug("sco flow %u, handle 0x%04x, packets sent %u, bytes send %u", hci_stack->synchronous_flow_control_enabled, (int) con_handle, conn->num_packets_sent, conn->num_sco_bytes_sent);
|
||||
if (hci_stack->synchronous_flow_control_enabled == 0){
|
||||
// get multiplier 2 for CVSD (16-bit samples) and 1 for mSBC (8-bit datq)
|
||||
int multiplier;
|
||||
if (((hci_stack->sco_voice_setting_active & 0x03) != 0x03) &&
|
||||
((hci_stack->sco_voice_setting_active & 0x20) == 0x20)) {
|
||||
multiplier = 2;
|
||||
} else {
|
||||
multiplier = 1;
|
||||
}
|
||||
|
||||
// ignore received SCO packets for the first 10 ms, then allow for max two HCI_SCO_2EV3_SIZE packets
|
||||
uint8_t max_sco_packets = (uint8_t) btstack_min(2 * HCI_SCO_2EV3_SIZE / conn->sco_payload_length, hci_stack->sco_packets_total_num);
|
||||
uint8_t max_sco_packets = (uint8_t) btstack_min(2 * multiplier * HCI_SCO_2EV3_SIZE / conn->sco_payload_length, hci_stack->sco_packets_total_num);
|
||||
if (conn->sco_tx_active == 0){
|
||||
if (btstack_time_delta(btstack_run_loop_get_time_ms(), conn->sco_established_ms) > 10){
|
||||
conn->sco_tx_active = 1;
|
||||
@ -4815,8 +4824,16 @@ static void sco_handler(uint8_t * packet, uint16_t size){
|
||||
hci_notify_if_sco_can_send_now();
|
||||
}
|
||||
} else {
|
||||
if (conn->sco_tx_ready < max_sco_packets){
|
||||
conn->sco_tx_ready++;
|
||||
// calculate how many packets can be sent for one received one
|
||||
// - remove sco header and multiplier
|
||||
// - divide by acutal payload length
|
||||
// - avoid overrun
|
||||
int received_payload_len = (size - 3) / multiplier;
|
||||
int new_credits = received_payload_len / conn->sco_payload_length;
|
||||
if ((conn->sco_tx_ready + new_credits)< max_sco_packets){
|
||||
conn->sco_tx_ready += new_credits;
|
||||
} else {
|
||||
conn->sco_tx_ready = max_sco_packets;
|
||||
}
|
||||
hci_notify_if_sco_can_send_now();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user