mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-28 08:37:22 +00:00
avdtp: fix compile warning, rename function
This commit is contained in:
parent
91a08b113f
commit
319b19cc14
@ -154,7 +154,7 @@ static void produce_audio(int16_t * pcm_buffer, int num_samples){
|
||||
}
|
||||
}
|
||||
|
||||
static int fill_sbc_audio_buffer(a2dp_media_sending_context_t * context){
|
||||
static int a2dp_demo_fill_sbc_audio_buffer(a2dp_media_sending_context_t * context){
|
||||
// perform sbc encodin
|
||||
int total_num_bytes_read = 0;
|
||||
int num_audio_samples_per_sbc_buffer = btstack_sbc_encoder_num_audio_frames();
|
||||
@ -177,7 +177,7 @@ static int fill_sbc_audio_buffer(a2dp_media_sending_context_t * context){
|
||||
return total_num_bytes_read;
|
||||
}
|
||||
|
||||
static void avdtp_audio_timeout_handler(btstack_timer_source_t * timer){
|
||||
static void a2dp_demo_audio_timeout_handler(btstack_timer_source_t * timer){
|
||||
a2dp_media_sending_context_t * context = (a2dp_media_sending_context_t *) btstack_run_loop_get_timer_context(timer);
|
||||
btstack_run_loop_set_timer(&context->audio_timer, AUDIO_TIMEOUT_MS);
|
||||
btstack_run_loop_add_timer(&context->audio_timer);
|
||||
@ -200,7 +200,7 @@ static void avdtp_audio_timeout_handler(btstack_timer_source_t * timer){
|
||||
|
||||
if (context->sbc_ready_to_send) return;
|
||||
|
||||
fill_sbc_audio_buffer(context);
|
||||
a2dp_demo_fill_sbc_audio_buffer(context);
|
||||
|
||||
if ((context->sbc_storage_count + btstack_sbc_encoder_sbc_buffer_length()) > context->max_media_payload_size){
|
||||
// schedule sending
|
||||
@ -215,7 +215,7 @@ static void a2dp_demo_timer_start(a2dp_media_sending_context_t * context){
|
||||
context->sbc_ready_to_send = 0;
|
||||
context->streaming = 1;
|
||||
btstack_run_loop_remove_timer(&context->audio_timer);
|
||||
btstack_run_loop_set_timer_handler(&context->audio_timer, avdtp_audio_timeout_handler);
|
||||
btstack_run_loop_set_timer_handler(&context->audio_timer, a2dp_demo_audio_timeout_handler);
|
||||
btstack_run_loop_set_timer_context(&context->audio_timer, context);
|
||||
btstack_run_loop_set_timer(&context->audio_timer, AUDIO_TIMEOUT_MS);
|
||||
btstack_run_loop_add_timer(&context->audio_timer);
|
||||
|
@ -461,7 +461,6 @@ static void avdtp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t c
|
||||
|
||||
void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size, avdtp_context_t * context){
|
||||
bd_addr_t event_addr;
|
||||
hci_con_handle_t con_handle;
|
||||
uint16_t psm;
|
||||
uint16_t local_cid;
|
||||
avdtp_stream_endpoint_t * stream_endpoint = NULL;
|
||||
@ -553,10 +552,8 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
return;
|
||||
}
|
||||
|
||||
con_handle = l2cap_event_channel_opened_get_handle(packet);
|
||||
|
||||
// log_info("L2CAP_EVENT_CHANNEL_OPENED: Channel successfully opened: %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x, remote cid 0x%02x",
|
||||
// bd_addr_to_str(event_addr), con_handle, psm, local_cid, l2cap_event_channel_opened_get_remote_cid(packet));
|
||||
// bd_addr_to_str(event_addr), l2cap_event_channel_opened_get_handle(packet), psm, local_cid, l2cap_event_channel_opened_get_remote_cid(packet));
|
||||
|
||||
if (psm != BLUETOOTH_PROTOCOL_AVDTP) break;
|
||||
|
||||
|
@ -493,7 +493,6 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
uint8_t * out_buffer;
|
||||
uint16_t pos;
|
||||
|
||||
int status = 0;
|
||||
switch (acceptor_config_state){
|
||||
case AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE:
|
||||
break;
|
||||
@ -575,29 +574,25 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_SUSPEND);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_REJECT_UNKNOWN_CMD:
|
||||
status = 1;
|
||||
log_info("ACP: DONE REJECT");
|
||||
connection->reject_signal_identifier = AVDTP_SI_NONE;
|
||||
avdtp_acceptor_send_response_reject(cid, reject_signal_identifier, trid);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE:
|
||||
status = 1;
|
||||
log_info("ACP: DONE REJECT CATEGORY");
|
||||
connection->reject_service_category = 0;
|
||||
avdtp_acceptor_send_response_reject_service_category(cid, reject_signal_identifier, reject_service_category, error_code, trid);
|
||||
break;
|
||||
|
||||
case AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE:
|
||||
status = 1;
|
||||
log_info("ACP: DONE REJECT");
|
||||
connection->reject_signal_identifier = AVDTP_SI_NONE;
|
||||
connection->error_code = 0;
|
||||
avdtp_acceptor_send_response_reject_with_error_code(cid, reject_signal_identifier, error_code, trid);
|
||||
break;
|
||||
default:
|
||||
status = 0;
|
||||
log_info("ACP: NOT IMPLEMENTED");
|
||||
sent = 0;
|
||||
break;
|
||||
}
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->avdtp_cid, avdtp_local_seid(stream_endpoint), connection->signaling_packet.signal_identifier);
|
||||
// check fragmentation
|
||||
|
@ -65,7 +65,7 @@ static int avdtp_initiator_send_signaling_cmd_with_seid(uint16_t cid, avdtp_sign
|
||||
}
|
||||
|
||||
void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_t *packet, uint16_t size, int offset, avdtp_context_t * context){
|
||||
int status = 0;
|
||||
// int status = 0;
|
||||
avdtp_stream_endpoint_t * stream_endpoint = NULL;
|
||||
|
||||
uint8_t remote_sep_index;
|
||||
@ -88,16 +88,14 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
case AVDTP_RESPONSE_ACCEPT_MSG:
|
||||
switch (connection->signaling_packet.signal_identifier){
|
||||
case AVDTP_SI_DISCOVER:{
|
||||
log_info("AVDTP_SI_DISCOVER");
|
||||
if (connection->signaling_packet.transaction_label != connection->initiator_transaction_label){
|
||||
log_info(" unexpected transaction label, got %d, expected %d", connection->signaling_packet.transaction_label, connection->initiator_transaction_label);
|
||||
status = BAD_HEADER_FORMAT;
|
||||
// status = BAD_HEADER_FORMAT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (size == 3){
|
||||
log_info(" ERROR code %02x", packet[offset]);
|
||||
status = packet[offset];
|
||||
break;
|
||||
}
|
||||
|
||||
@ -107,7 +105,7 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
offset++;
|
||||
if (sep.seid < 0x01 || sep.seid > 0x3E){
|
||||
log_info(" invalid sep id");
|
||||
status = BAD_ACP_SEID;
|
||||
// status = BAD_ACP_SEID;
|
||||
break;
|
||||
}
|
||||
sep.in_use = (packet[i] >> 1) & 0x01;
|
||||
@ -124,7 +122,6 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
|
||||
case AVDTP_SI_GET_CAPABILITIES:
|
||||
case AVDTP_SI_GET_ALL_CAPABILITIES:
|
||||
log_info("AVDTP_SI_GET(_ALL)_CAPABILITIES int %d, acp %d", connection->local_seid, connection->remote_seid);
|
||||
sep.registered_service_categories = avdtp_unpack_service_capabilities(connection, &sep.capabilities, packet+offset, size-offset);
|
||||
if (get_bit16(sep.registered_service_categories, AVDTP_MEDIA_CODEC)){
|
||||
switch (sep.capabilities.media_codec.media_codec_type){
|
||||
@ -139,7 +136,6 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
break;
|
||||
|
||||
case AVDTP_SI_GET_CONFIGURATION:
|
||||
log_info("AVDTP_SI_GET_CONFIGURATION");
|
||||
sep.configured_service_categories = avdtp_unpack_service_capabilities(connection, &sep.configuration, packet+offset, size-offset);
|
||||
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
||||
switch (sep.configuration.media_codec.media_codec_type){
|
||||
@ -154,7 +150,6 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
break;
|
||||
|
||||
case AVDTP_SI_RECONFIGURE:
|
||||
log_info("AVDTP_SI_RECONFIGURE");
|
||||
sep.configured_service_categories = avdtp_unpack_service_capabilities(connection, &sep.configuration, connection->signaling_packet.command+4, connection->signaling_packet.size-4);
|
||||
// TODO check if configuration is supported
|
||||
|
||||
@ -168,7 +163,6 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
break;
|
||||
|
||||
case AVDTP_SI_SET_CONFIGURATION:{
|
||||
log_info("AVDTP_SI_SET_CONFIGURATION");
|
||||
sep.configured_service_categories = stream_endpoint->remote_capabilities_bitmap;
|
||||
sep.configuration = stream_endpoint->remote_capabilities;
|
||||
sep.in_use = 1;
|
||||
@ -189,7 +183,6 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
}
|
||||
|
||||
case AVDTP_SI_OPEN:
|
||||
log_info("AVDTP_SI_OPEN");
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM) {
|
||||
log_error("AVDTP_SI_OPEN in wrong stream endpoint state");
|
||||
return;
|
||||
@ -199,16 +192,13 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
l2cap_create_channel(context->packet_handler, connection->remote_addr, BLUETOOTH_PROTOCOL_AVDTP, 0xffff, NULL);
|
||||
return;
|
||||
case AVDTP_SI_START:
|
||||
log_info("AVDTP_SI_START");
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_OPENED) {
|
||||
log_error("AVDTP_SI_START in wrong stream endpoint state");
|
||||
return;
|
||||
}
|
||||
log_info("AVDTP_STREAM_ENDPOINT_STREAMING");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_STREAMING;
|
||||
break;
|
||||
case AVDTP_SI_SUSPEND:
|
||||
log_info("AVDTP_SI_SUSPEND");
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_STREAMING) {
|
||||
log_error("AVDTP_SI_SUSPEND in wrong stream endpoint state");
|
||||
return;
|
||||
@ -216,15 +206,12 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_OPENED;
|
||||
break;
|
||||
case AVDTP_SI_CLOSE:
|
||||
log_info("AVDTP_SI_CLOSE");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CLOSING;
|
||||
break;
|
||||
case AVDTP_SI_ABORT:
|
||||
log_info("AVDTP_SI_ABORT");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_ABORTING;
|
||||
break;
|
||||
default:
|
||||
status = 1;
|
||||
log_info(" AVDTP_RESPONSE_ACCEPT_MSG, signal %d not implemented", connection->signaling_packet.signal_identifier);
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user