# HG changeset patch # User Mychaela Falconia # Date 1627613748 0 # Node ID 79cfefc1e2b4fd68775b3c571a08f007caf6a7cb # Parent fa22012c4a3999700955aab3f4a49dfe99603916 audio mode load: gracefully handle mode files of wrong AEC version Unfortunately our change of enabling L1_NEW_AEC (which is necessary in order to bring our Calypso ARM fw into match with the underlying DSP reality) brings along a change in the audio mode file binary format and file size - all those new tunable AEC parameters do need to be stored somewhere, after all. But we already have existing mode files in the old format, and setting AEC config to garbage when loading old audio modes (which is what would happen without the present change) is not an appealing proposition. The solution implemented in the present change is as follows: the audio mode loading code checks the file size, and if it differs from the active version of T_AUDIO_MODE, the T_AUDIO_AEC_CFG structure is cleared - set to the default (disabled AEC) for the compiled type of AEC. We got lucky in that this varying T_AUDIO_AEC_CFG structure sits at the end of T_AUDIO_MODE! diff -r fa22012c4a39 -r 79cfefc1e2b4 src/cs/services/audio/audio_mode_load.c --- a/src/cs/services/audio/audio_mode_load.c Thu Jul 29 18:57:36 2021 +0000 +++ b/src/cs/services/audio/audio_mode_load.c Fri Jul 30 02:55:48 2021 +0000 @@ -98,6 +98,9 @@ return(AUDIO_ERROR); \ } \ +/* FreeCalypso added definition for old vs new mode file handling */ +#define MODE_FILE_SIZE_NEWAEC 176 + /********************************************************************************/ /* */ /* Function Name: audio_mode_load_send_status */ @@ -308,6 +311,28 @@ return(AUDIO_OK); } + /* FreeCalypso added function */ + static void set_default_aec(T_AUDIO_AEC_CFG *aec) + { + aec->aec_enable = 0; + #if (L1_NEW_AEC) + aec->continuous_filtering = 0; + aec->granularity_attenuation = 1; + aec->smoothing_coefficient = 0x7FFF; + aec->max_echo_suppression_level = AUDIO_MAX_ECHO_12dB; + aec->vad_factor = 0x4000; + aec->absolute_threshold = 0x32; + aec->factor_asd_filtering = 0x1000; + aec->factor_asd_muting = 0x1000; + aec->aec_visibility = 0; + #else + aec->aec_mode = 0; + aec->echo_suppression_level = 0; + #endif + aec->noise_suppression_enable = 0; + aec->noise_suppression_level = 0; + } + /********************************************************************************/ /* */ /* Function Name: audio_mode_load_manager */ @@ -332,6 +357,7 @@ T_AUDIO_SPEAKER_LEVEL audio_volume; T_RVF_MB_STATUS mb_status; UINT8 message_to_confirm; + T_FFS_SIZE rdsize; #ifdef _WINDOWS INT8 *p_read, *p_write; UINT8 i; @@ -343,7 +369,7 @@ { /* allocate the buffer for the current Audio mode */ mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal, - sizeof (T_AUDIO_MODE), + MODE_FILE_SIZE_NEWAEC, (T_RVF_BUFFER **) (&(p_audio_gbl_var->audio_mode_var.audio_mode_load_var.p_audio_mode))); /* If insufficient resources, then report a memory error and abort. */ if (mb_status == RVF_RED) @@ -366,9 +392,10 @@ #else /* Load the audio mode structure from the FFS */ - if ( ffs_read (((T_AUDIO_MODE_LOAD_REQ *)p_message)->audio_ffs_fd, - (void *)(p_audio_gbl_var->audio_mode_var.audio_mode_load_var.p_audio_mode), - sizeof(T_AUDIO_MODE)) < EFFS_OK ) + rdsize = ffs_read (((T_AUDIO_MODE_LOAD_REQ *)p_message)->audio_ffs_fd, + (void *)(p_audio_gbl_var->audio_mode_var.audio_mode_load_var.p_audio_mode), + MODE_FILE_SIZE_NEWAEC); + if ( rdsize < EFFS_OK ) { AUDIO_SEND_TRACE("AUDIO MODE LOAD: impossible to load the current audio mode", RV_TRACE_LEVEL_ERROR); @@ -383,6 +410,11 @@ audio_mode_load_send_status (AUDIO_ERROR, ((T_AUDIO_MODE_LOAD_REQ *)p_message)->return_path); return; } + if ( rdsize != sizeof(T_AUDIO_MODE) ) + { + /* wrong version - clear the AEC part */ + set_default_aec(&p_audio_gbl_var->audio_mode_var.audio_mode_load_var.p_audio_mode->audio_microphone_speaker_loop_setting.aec); + } #endif /* Set the audio mode structure */