hfp_ag.c (d4a8cc2955f76fbb78518ec70285afc81a1aee4e) hfp_ag.c (bc94e48c474f6ea279a2ac3d47d88e95579ca023)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 2214 unchanged lines hidden (view full) ---

2223 if (!cmd_sent){
2224 cmd_sent = hfp_ag_run_for_context_service_level_connection_queries(hfp_connection);
2225 }
2226
2227 if (!cmd_sent){
2228 cmd_sent = call_setup_state_machine(hfp_connection);
2229 }
2230
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 2214 unchanged lines hidden (view full) ---

2223 if (!cmd_sent){
2224 cmd_sent = hfp_ag_run_for_context_service_level_connection_queries(hfp_connection);
2225 }
2226
2227 if (!cmd_sent){
2228 cmd_sent = call_setup_state_machine(hfp_connection);
2229 }
2230
2231 // trigger codec exchange (must be before hfp_ag_run_for_audio_connection)
2232 if (hfp_connection->trigger_codec_exchange){
2233 switch (hfp_connection->codecs_state){
2234 case HFP_CODECS_IDLE:
2235 case HFP_CODECS_RECEIVED_LIST:
2236 case HFP_CODECS_AG_RESEND_COMMON_CODEC:
2237 case HFP_CODECS_ERROR:
2238 hfp_connection->trigger_codec_exchange = 0;
2239 hfp_connection->ag_send_common_codec = true;
2240 break;
2241 default:
2242 break;
2243 }
2244 }
2245
2246 if (!cmd_sent){
2247 cmd_sent = hfp_ag_run_for_audio_connection(hfp_connection);
2248 }
2249
2250 if (!cmd_sent){
2251 cmd_sent = hfp_ag_voice_recognition_state_machine(hfp_connection);
2252 }
2253

--- 391 unchanged lines hidden (view full) ---

2645 if (hfp_connection->negotiated_codec == hfp_connection->remote_codecs[i]){
2646 codec_was_in_use = true;
2647 } else if (hfp_connection->negotiated_codec < hfp_connection->remote_codecs[i]){
2648 better_codec_can_be_used = true;
2649 }
2650 }
2651
2652 if (!codec_was_in_use || better_codec_can_be_used){
2231 if (!cmd_sent){
2232 cmd_sent = hfp_ag_run_for_audio_connection(hfp_connection);
2233 }
2234
2235 if (!cmd_sent){
2236 cmd_sent = hfp_ag_voice_recognition_state_machine(hfp_connection);
2237 }
2238

--- 391 unchanged lines hidden (view full) ---

2630 if (hfp_connection->negotiated_codec == hfp_connection->remote_codecs[i]){
2631 codec_was_in_use = true;
2632 } else if (hfp_connection->negotiated_codec < hfp_connection->remote_codecs[i]){
2633 better_codec_can_be_used = true;
2634 }
2635 }
2636
2637 if (!codec_was_in_use || better_codec_can_be_used){
2653 hfp_connection->trigger_codec_exchange = 1;
2638 hfp_connection->ag_send_common_codec = true;
2654 hfp_connection->codecs_state = HFP_CODECS_IDLE;
2655 }
2656 return ERROR_CODE_SUCCESS;
2657}
2658
2659uint8_t hfp_ag_establish_audio_connection(hci_con_handle_t acl_handle){
2660 hfp_connection_t * hfp_connection = get_hfp_ag_connection_context_for_acl_handle(acl_handle);
2661 if (!hfp_connection){

--- 454 unchanged lines hidden ---
2639 hfp_connection->codecs_state = HFP_CODECS_IDLE;
2640 }
2641 return ERROR_CODE_SUCCESS;
2642}
2643
2644uint8_t hfp_ag_establish_audio_connection(hci_con_handle_t acl_handle){
2645 hfp_connection_t * hfp_connection = get_hfp_ag_connection_context_for_acl_handle(acl_handle);
2646 if (!hfp_connection){

--- 454 unchanged lines hidden ---