# HG changeset patch # User Mychaela Falconia # Date 1627617352 0 # Node ID 800bf29abf3183d0dd925a6363c5949b6658a991 # Parent f12872b7eb21ab66806a8640b79283d51f314ff6 audio mode load change from Tourmaline Our FreeCalypso universe now has two kinds of audio mode config files: the old 164 byte kind and the new 176 byte kind. We are not enabling L1_NEW_AEC in Magnetite, only in Tourmaline, thus 164 byte audio mode files are still native to Magnetite. But we still desire graceful handling of the situation when a running Magnetite fw may load a 176 byte audio mode file (presumably with new AEC config), thus we incorporate the same audio mode loading change which we implemented in Tourmaline: if the loaded audio mode file is of the wrong kind, the AEC config is cleared to default disabled state. diff -r f12872b7eb21 -r 800bf29abf31 src/cs/services/audio/audio_mode_load.c --- a/src/cs/services/audio/audio_mode_load.c Wed Jun 09 18:04:26 2021 +0000 +++ b/src/cs/services/audio/audio_mode_load.c Fri Jul 30 03:55:52 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 */