mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-31 00:32:52 +00:00
le-audio/bass: rename util functions
This commit is contained in:
parent
54461c8047
commit
6e96f7c765
@ -268,7 +268,7 @@ static void handle_gatt_server_notification(uint8_t packet_type, uint16_t channe
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
source->source_id = value[0];
|
source->source_id = value[0];
|
||||||
bass_util_get_source_from_buffer(&value[1], value_length - 1, &source->data, true);
|
bass_util_source_data_parse(&value[1], value_length - 1, &source->data, true);
|
||||||
|
|
||||||
// get big encryption + bad code
|
// get big encryption + bad code
|
||||||
source->big_encryption = (le_audio_big_encryption_t) value[13];
|
source->big_encryption = (le_audio_big_encryption_t) value[13];
|
||||||
@ -328,7 +328,8 @@ static uint16_t bass_client_prepare_add_source_buffer(bass_client_connection_t *
|
|||||||
buffer_offset);
|
buffer_offset);
|
||||||
source_offset++;
|
source_offset++;
|
||||||
|
|
||||||
stored_bytes += bass_util_copy_source_common_data_to_buffer(receive_state, &source_offset, buffer_offset, buffer, buffer_size);
|
stored_bytes += bass_util_source_data_header_virtual_memcpy(receive_state, &source_offset, buffer_offset, buffer,
|
||||||
|
buffer_size);
|
||||||
|
|
||||||
field_data[0] = (uint8_t)receive_state->pa_sync;
|
field_data[0] = (uint8_t)receive_state->pa_sync;
|
||||||
stored_bytes += le_audio_util_virtual_memcpy_helper(field_data, 1, source_offset, buffer, buffer_size,
|
stored_bytes += le_audio_util_virtual_memcpy_helper(field_data, 1, source_offset, buffer, buffer_size,
|
||||||
@ -340,9 +341,9 @@ static uint16_t bass_client_prepare_add_source_buffer(bass_client_connection_t *
|
|||||||
buffer_offset);
|
buffer_offset);
|
||||||
source_offset += 2;
|
source_offset += 2;
|
||||||
|
|
||||||
stored_bytes += bass_util_store_source_subgroups_into_buffer(receive_state, false, &source_offset, buffer_offset,
|
stored_bytes += bass_util_source_data_subgroups_virtual_memcpy(receive_state, false, &source_offset, buffer_offset,
|
||||||
buffer,
|
buffer,
|
||||||
buffer_size);
|
buffer_size);
|
||||||
|
|
||||||
return stored_bytes;
|
return stored_bytes;
|
||||||
}
|
}
|
||||||
@ -381,9 +382,9 @@ static uint16_t bass_client_prepare_modify_source_buffer(bass_client_connection_
|
|||||||
buffer_offset);
|
buffer_offset);
|
||||||
source_offset += 2;
|
source_offset += 2;
|
||||||
|
|
||||||
stored_bytes += bass_util_store_source_subgroups_into_buffer(receive_state, false, &source_offset, buffer_offset,
|
stored_bytes += bass_util_source_data_subgroups_virtual_memcpy(receive_state, false, &source_offset, buffer_offset,
|
||||||
buffer,
|
buffer,
|
||||||
buffer_size);
|
buffer_size);
|
||||||
return stored_bytes;
|
return stored_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +254,8 @@ static uint16_t bass_server_copy_source_to_buffer(bass_server_source_t * source,
|
|||||||
buffer_offset);
|
buffer_offset);
|
||||||
source_offset++;
|
source_offset++;
|
||||||
|
|
||||||
stored_bytes += bass_util_copy_source_common_data_to_buffer(&source->data, &source_offset, buffer_offset, buffer, buffer_size);
|
stored_bytes += bass_util_source_data_header_virtual_memcpy(&source->data, &source_offset, buffer_offset, buffer,
|
||||||
|
buffer_size);
|
||||||
|
|
||||||
field_data[0] = (uint8_t)source->data.pa_sync_state;
|
field_data[0] = (uint8_t)source->data.pa_sync_state;
|
||||||
stored_bytes += le_audio_util_virtual_memcpy_helper(field_data, 1, source_offset, buffer, buffer_size,
|
stored_bytes += le_audio_util_virtual_memcpy_helper(field_data, 1, source_offset, buffer, buffer_size,
|
||||||
@ -273,9 +274,9 @@ static uint16_t bass_server_copy_source_to_buffer(bass_server_source_t * source,
|
|||||||
source_offset += 16;
|
source_offset += 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
stored_bytes += bass_util_store_source_subgroups_into_buffer(&source->data, true, &source_offset, buffer_offset,
|
stored_bytes += bass_util_source_data_subgroups_virtual_memcpy(&source->data, true, &source_offset, buffer_offset,
|
||||||
buffer,
|
buffer,
|
||||||
buffer_size);
|
buffer_size);
|
||||||
return stored_bytes;
|
return stored_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,7 +313,7 @@ static void bass_server_add_source_from_buffer(uint8_t *buffer, uint16_t buffer_
|
|||||||
source->update_counter = bass_get_next_update_counter();
|
source->update_counter = bass_get_next_update_counter();
|
||||||
source->in_use = true;
|
source->in_use = true;
|
||||||
|
|
||||||
bass_util_get_source_from_buffer(buffer, buffer_size, &source->data, false);
|
bass_util_source_data_parse(buffer, buffer_size, &source->data, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool bass_pa_synchronized(bass_server_source_t * source){
|
static bool bass_pa_synchronized(bass_server_source_t * source){
|
||||||
@ -433,7 +434,7 @@ static int broadcast_audio_scan_service_write_callback(hci_con_handle_t con_hand
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BASS_OPCODE_ADD_SOURCE:
|
case BASS_OPCODE_ADD_SOURCE:
|
||||||
if (!bass_util_add_source_buffer_in_valid_range(remote_data, remote_data_size)){
|
if (!bass_util_source_buffer_in_valid_range(remote_data, remote_data_size)){
|
||||||
return ATT_ERROR_WRITE_REQUEST_REJECTED;
|
return ATT_ERROR_WRITE_REQUEST_REJECTED;
|
||||||
}
|
}
|
||||||
source = bass_find_empty_or_last_used_source();
|
source = bass_find_empty_or_last_used_source();
|
||||||
@ -453,7 +454,7 @@ static int broadcast_audio_scan_service_write_callback(hci_con_handle_t con_hand
|
|||||||
if (source == NULL){
|
if (source == NULL){
|
||||||
return BASS_ERROR_CODE_INVALID_SOURCE_ID;
|
return BASS_ERROR_CODE_INVALID_SOURCE_ID;
|
||||||
}
|
}
|
||||||
bass_util_get_pa_info_and_subgroups_from_buffer(remote_data + 1, remote_data_size - 1, &source->data,false);
|
bass_util_pa_info_and_subgroups_parse(remote_data + 1, remote_data_size - 1, &source->data, false);
|
||||||
bass_emit_source_modified(con_handle, source);
|
bass_emit_source_modified(con_handle, source);
|
||||||
// server needs to trigger notification
|
// server needs to trigger notification
|
||||||
break;
|
break;
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// offset gives position into fully serialized bass record
|
// offset gives position into fully serialized bass record
|
||||||
uint16_t bass_util_copy_source_common_data_to_buffer(const bass_source_data_t * data, uint16_t *source_offset, uint16_t buffer_offset, uint8_t * buffer, uint16_t buffer_size){
|
uint16_t bass_util_source_data_header_virtual_memcpy(const bass_source_data_t * data, uint16_t *source_offset, uint16_t buffer_offset, uint8_t * buffer, uint16_t buffer_size){
|
||||||
uint16_t stored_bytes = 0;
|
uint16_t stored_bytes = 0;
|
||||||
uint8_t field_data[16];
|
uint8_t field_data[16];
|
||||||
|
|
||||||
@ -85,8 +85,8 @@ uint16_t bass_util_copy_source_common_data_to_buffer(const bass_source_data_t *
|
|||||||
|
|
||||||
// offset gives position into fully serialized bass record
|
// offset gives position into fully serialized bass record
|
||||||
uint16_t
|
uint16_t
|
||||||
bass_util_store_source_subgroups_into_buffer(const bass_source_data_t *data, bool use_state_fields, uint16_t *source_offset,
|
bass_util_source_data_subgroups_virtual_memcpy(const bass_source_data_t *data, bool use_state_fields, uint16_t *source_offset,
|
||||||
uint16_t buffer_offset, uint8_t *buffer, uint16_t buffer_size) {
|
uint16_t buffer_offset, uint8_t *buffer, uint16_t buffer_size) {
|
||||||
uint16_t stored_bytes = 0;
|
uint16_t stored_bytes = 0;
|
||||||
uint8_t field_data[16];
|
uint8_t field_data[16];
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ bool bass_util_pa_sync_state_and_subgroups_in_valid_range(uint8_t *buffer, uint1
|
|||||||
return (pos == buffer_size);
|
return (pos == buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bass_util_add_source_buffer_in_valid_range(uint8_t *buffer, uint16_t buffer_size){
|
bool bass_util_source_buffer_in_valid_range(uint8_t *buffer, uint16_t buffer_size){
|
||||||
if (buffer_size < 15){
|
if (buffer_size < 15){
|
||||||
log_info("Add Source opcode, buffer too small");
|
log_info("Add Source opcode, buffer too small");
|
||||||
return false;
|
return false;
|
||||||
@ -199,8 +199,8 @@ bool bass_util_add_source_buffer_in_valid_range(uint8_t *buffer, uint16_t buffer
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
bass_util_get_pa_info_and_subgroups_from_buffer(uint8_t *buffer, uint16_t buffer_size, bass_source_data_t *source_data,
|
bass_util_pa_info_and_subgroups_parse(uint8_t *buffer, uint16_t buffer_size, bass_source_data_t *source_data,
|
||||||
bool is_broadcast_receive_state) {
|
bool is_broadcast_receive_state) {
|
||||||
UNUSED(buffer_size);
|
UNUSED(buffer_size);
|
||||||
uint8_t pos = 0;
|
uint8_t pos = 0;
|
||||||
// for Broadcast Receive state, we have BIG_Encryption + Bad_Code, while for Add/Modify we have PA_Interval
|
// for Broadcast Receive state, we have BIG_Encryption + Bad_Code, while for Add/Modify we have PA_Interval
|
||||||
@ -234,8 +234,8 @@ bass_util_get_pa_info_and_subgroups_from_buffer(uint8_t *buffer, uint16_t buffer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bass_util_get_source_from_buffer(uint8_t *buffer, uint16_t buffer_size, bass_source_data_t *source_data,
|
void bass_util_source_data_parse(uint8_t *buffer, uint16_t buffer_size, bass_source_data_t *source_data,
|
||||||
bool is_broadcast_receive_state) {
|
bool is_broadcast_receive_state) {
|
||||||
UNUSED(buffer_size);
|
UNUSED(buffer_size);
|
||||||
uint8_t pos = 0;
|
uint8_t pos = 0;
|
||||||
|
|
||||||
@ -249,5 +249,5 @@ void bass_util_get_source_from_buffer(uint8_t *buffer, uint16_t buffer_size, bas
|
|||||||
source_data->broadcast_id = little_endian_read_24(buffer, pos);
|
source_data->broadcast_id = little_endian_read_24(buffer, pos);
|
||||||
pos += 3;
|
pos += 3;
|
||||||
|
|
||||||
bass_util_get_pa_info_and_subgroups_from_buffer(buffer + pos, buffer_size - pos, source_data, is_broadcast_receive_state);
|
bass_util_pa_info_and_subgroups_parse(buffer + pos, buffer_size - pos, source_data, is_broadcast_receive_state);
|
||||||
}
|
}
|
@ -110,23 +110,21 @@ typedef struct {
|
|||||||
} bass_source_data_t;
|
} bass_source_data_t;
|
||||||
|
|
||||||
// offset gives position into fully serialized BASS record
|
// offset gives position into fully serialized BASS record
|
||||||
uint16_t bass_util_copy_source_common_data_to_buffer(const bass_source_data_t * data, uint16_t *source_offset, uint16_t buffer_offset, uint8_t * buffer, uint16_t buffer_size);
|
uint16_t bass_util_source_data_header_virtual_memcpy(const bass_source_data_t * data, uint16_t *source_offset, uint16_t buffer_offset, uint8_t * buffer, uint16_t buffer_size);
|
||||||
|
|
||||||
uint16_t
|
uint16_t bass_util_source_data_subgroups_virtual_memcpy(const bass_source_data_t *data, bool use_state_fields, uint16_t *source_offset,
|
||||||
bass_util_store_source_subgroups_into_buffer(const bass_source_data_t *data, bool use_state_fields, uint16_t *source_offset,
|
uint16_t buffer_offset, uint8_t *buffer, uint16_t buffer_size);
|
||||||
uint16_t buffer_offset, uint8_t *buffer, uint16_t buffer_size);
|
|
||||||
|
|
||||||
bool bass_util_pa_sync_state_and_subgroups_in_valid_range(uint8_t *buffer, uint16_t buffer_size);
|
bool bass_util_pa_sync_state_and_subgroups_in_valid_range(uint8_t *buffer, uint16_t buffer_size);
|
||||||
|
|
||||||
bool bass_util_add_source_buffer_in_valid_range(uint8_t *buffer, uint16_t buffer_size);
|
bool bass_util_source_buffer_in_valid_range(uint8_t *buffer, uint16_t buffer_size);
|
||||||
|
|
||||||
void bass_util_get_source_from_buffer(uint8_t *buffer, uint16_t buffer_size, bass_source_data_t *source_data,
|
void bass_util_source_data_parse(uint8_t *buffer, uint16_t buffer_size, bass_source_data_t *source_data,
|
||||||
|
bool is_broadcast_receive_state);
|
||||||
|
|
||||||
|
void bass_util_pa_info_and_subgroups_parse(uint8_t *buffer, uint16_t buffer_size, bass_source_data_t *source_data,
|
||||||
bool is_broadcast_receive_state);
|
bool is_broadcast_receive_state);
|
||||||
|
|
||||||
void
|
|
||||||
bass_util_get_pa_info_and_subgroups_from_buffer(uint8_t *buffer, uint16_t buffer_size, bass_source_data_t *source_data,
|
|
||||||
bool is_broadcast_receive_state);
|
|
||||||
|
|
||||||
/* API_END */
|
/* API_END */
|
||||||
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
|
Loading…
x
Reference in New Issue
Block a user