hfp_ag: extract hfp_ag_run_ring_and_clip and call after audio gets established

This commit is contained in:
Matthias Ringwald 2021-12-08 20:43:01 +01:00
parent cab96eec12
commit c1eef992e2

View File

@ -2077,25 +2077,6 @@ static int hfp_ag_send_commands(hfp_connection_t *hfp_connection){
return 1;
}
// delay RING/CLIP until audio connection has been established for incoming calls
// hfp_ag_hf_trigger_ring_and_clip is called in call_setup_state_machine
if (hfp_connection->call_state != HFP_CALL_W4_AUDIO_CONNECTION_FOR_IN_BAND_RING){
if (hfp_connection->ag_ring){
hfp_connection->ag_ring = 0;
hfp_connection->command = HFP_CMD_NONE;
hfp_emit_simple_event(hfp_connection, HFP_SUBEVENT_RING);
hfp_ag_send_ring(hfp_connection->rfcomm_cid);
return 1;
}
if (hfp_connection->ag_send_clip){
hfp_connection->ag_send_clip = 0;
hfp_connection->command = HFP_CMD_NONE;
hfp_ag_send_clip(hfp_connection->rfcomm_cid);
return 1;
}
}
if (hfp_connection->send_phone_number_for_voice_tag){
hfp_connection->send_phone_number_for_voice_tag = 0;
hfp_connection->command = HFP_CMD_NONE;
@ -2140,6 +2121,29 @@ static int hfp_ag_send_commands(hfp_connection_t *hfp_connection){
return 0;
}
// sends pending command, returns if command was sent
static int hfp_ag_run_ring_and_clip(hfp_connection_t *hfp_connection){
// delay RING/CLIP until audio connection has been established for incoming calls
// hfp_ag_hf_trigger_ring_and_clip is called in call_setup_state_machine
if (hfp_connection->call_state != HFP_CALL_W4_AUDIO_CONNECTION_FOR_IN_BAND_RING){
if (hfp_connection->ag_ring){
hfp_connection->ag_ring = 0;
hfp_connection->command = HFP_CMD_NONE;
hfp_emit_simple_event(hfp_connection, HFP_SUBEVENT_RING);
hfp_ag_send_ring(hfp_connection->rfcomm_cid);
return 1;
}
if (hfp_connection->ag_send_clip){
hfp_connection->ag_send_clip = 0;
hfp_connection->command = HFP_CMD_NONE;
hfp_ag_send_clip(hfp_connection->rfcomm_cid);
return 1;
}
}
return 0;
}
static void hfp_ag_run_for_context(hfp_connection_t *hfp_connection){
btstack_assert(hfp_connection != NULL);
@ -2249,6 +2253,10 @@ static void hfp_ag_run_for_context(hfp_connection_t *hfp_connection){
cmd_sent = hfp_ag_run_for_audio_connection(hfp_connection);
}
if (!cmd_sent){
cmd_sent = hfp_ag_run_ring_and_clip(hfp_connection);
}
if (!cmd_sent){
cmd_sent = hfp_ag_voice_recognition_state_machine(hfp_connection);
}