a2dp sink: reset state on connetion failure

This commit is contained in:
Milanka Ringwald 2017-08-25 17:47:32 +02:00
parent ff8fd80fee
commit 326e5ced38
2 changed files with 11 additions and 3 deletions

View File

@ -686,6 +686,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
UNUSED(size);
uint16_t cid;
bd_addr_t address;
uint8_t status;
if (packet_type != HCI_EVENT_PACKET) return;
if (hci_event_packet_get_type(packet) != HCI_EVENT_A2DP_META) return;
@ -717,10 +718,16 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
}
case A2DP_SUBEVENT_STREAM_ESTABLISHED:
a2dp_subevent_stream_established_get_bd_addr(packet, address);
status = a2dp_subevent_stream_established_get_status(packet);
cid = a2dp_subevent_stream_established_get_a2dp_cid(packet);
if (cid != a2dp_cid) break;
local_seid = a2dp_subevent_stream_established_get_local_seid(packet);
if (status){
app_state = AVDTP_APPLICATION_IDLE;
printf(" -- a2dp sink demo: streaming connection failed, status 0x%02x\n", status);
break;
}
printf(" -- a2dp sink demo: streaming connection is established, address %s, a2dp cid 0x%02X, local_seid %d\n", bd_addr_to_str(address), a2dp_cid, local_seid);
local_seid = a2dp_subevent_stream_established_get_local_seid(packet);
app_state = AVDTP_APPLICATION_STREAMING;
break;
@ -813,7 +820,7 @@ static void stdin_process(char cmd){
uint8_t status = ERROR_CODE_SUCCESS;
switch (cmd){
case 'b':
printf(" - Create AVDTP connection to addr %s.\n", bd_addr_to_str(device_addr));
printf(" - Create AVDTP connection to addr %s, and local seid %d.\n", bd_addr_to_str(device_addr), local_seid);
status = a2dp_sink_establish_stream(device_addr, local_seid, &a2dp_cid);
break;
case 'B':

View File

@ -180,7 +180,7 @@ avdtp_stream_endpoint_t * a2dp_sink_create_stream_endpoint(avdtp_media_type_t me
uint8_t a2dp_sink_establish_stream(bd_addr_t bd_addr, uint8_t local_seid, uint16_t * avdtp_cid){
sc.local_stream_endpoint = avdtp_stream_endpoint_for_seid(local_seid, &a2dp_sink_context);
if (!sc.local_stream_endpoint){
log_error(" no local_stream_endpoint for seid %d", local_seid);
log_info("No local_stream_endpoint for seid %d", local_seid);
return AVDTP_SEID_DOES_NOT_EXIST;
}
return avdtp_sink_connect(bd_addr, avdtp_cid);
@ -253,6 +253,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
cid = avdtp_subevent_signaling_connection_established_get_avdtp_cid(packet);
status = avdtp_subevent_signaling_connection_established_get_status(packet);
if (status != 0){
app_state = A2DP_IDLE;
log_info("AVDTP_SUBEVENT_SIGNALING_CONNECTION failed status %d ---", status);
a2dp_streaming_emit_connection_established(a2dp_sink_context.a2dp_callback, cid, address, 0, 0, status);
break;