FreeCalypso > hg > fc-tourmaline
changeset 275:79cfefc1e2b4
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!
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 30 Jul 2021 02:55:48 +0000 |
parents | fa22012c4a39 |
children | 4221c724c664 |
files | src/cs/services/audio/audio_mode_load.c |
diffstat | 1 files changed, 36 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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 */