diff --git a/src/audio/module_adapter/module/volume/volume.c b/src/audio/module_adapter/module/volume/volume.c index 657fbba11..a66069189 100644 --- a/src/audio/module_adapter/module/volume/volume.c +++ b/src/audio/module_adapter/module/volume/volume.c @@ -275,6 +275,7 @@ static void volume_ramp(struct processing_module *mod) int i; bool ramp_finished = true; + cd->copy_gain = true; /* No need to ramp in idle state, jump volume to request. */ if (dev->state == COMP_STATE_READY) { for (i = 0; i < PLATFORM_MAX_CHANNELS; i++) @@ -361,6 +362,7 @@ static void reset_state(struct vol_data *cd) cd->vol_ramp_frames = 0; cd->vol_ramp_elapsed_frames = 0; cd->sample_rate = 0; + cd->copy_gain = true; } #if CONFIG_IPC_MAJOR_3 diff --git a/src/audio/module_adapter/module/volume/volume_hifi3.c b/src/audio/module_adapter/module/volume/volume_hifi3.c index 5786b4dd7..9bd1494a7 100644 --- a/src/audio/module_adapter/module/volume/volume_hifi3.c +++ b/src/audio/module_adapter/module/volume/volume_hifi3.c @@ -42,6 +42,7 @@ static void vol_store_gain(struct vol_data *cd, const int channels_count) cd->vol[i + channels_count * 2] = cd->volume[i]; cd->vol[i + channels_count * 3] = cd->volume[i]; } + cd->copy_gain = false; } static inline void peak_vol_calc(struct vol_data *cd, ae_f32x2 out_sample, size_t channel) @@ -84,7 +85,9 @@ static void vol_s24_to_s24_s32(struct processing_module *mod, struct input_strea * error loading of volume gain while the cd->vol would be set * as circular buffer */ - vol_store_gain(cd, channels_count); + if (cd->copy_gain) + vol_store_gain(cd, channels_count); + buf = (ae_f32x2 *)cd->vol; buf_end = (ae_f32x2 *)(cd->vol + channels_count * 2); vol = (ae_f32x2 *)buf; @@ -175,7 +178,9 @@ static void vol_s32_to_s24_s32(struct processing_module *mod, struct input_strea * error loading of volume gain while the cd->vol would be set * as circular buffer */ - vol_store_gain(cd, channels_count); + if (cd->copy_gain) + vol_store_gain(cd, channels_count); + buf = (ae_f32x2 *)cd->vol; buf_end = (ae_f32x2 *)(cd->vol + channels_count * 2); vol = (ae_f32x2 *)buf; @@ -270,7 +275,9 @@ static void vol_s16_to_s16(struct processing_module *mod, struct input_stream_bu * error loading of volume gain while the cd->vol would be set * as circular buffer */ - vol_store_gain(cd, channels_count); + if (cd->copy_gain) + vol_store_gain(cd, channels_count); + buf = (ae_f32x2 *)cd->vol; buf_end = (ae_f32x2 *)(cd->vol + channels_count * 4); vol = buf; diff --git a/src/include/sof/audio/volume.h b/src/include/sof/audio/volume.h index 04a16b925..d49b5c33f 100644 --- a/src/include/sof/audio/volume.h +++ b/src/include/sof/audio/volume.h @@ -157,6 +157,7 @@ struct vol_data { vol_scale_func scale_vol; /**< volume processing function */ vol_zc_func zc_get; /**< function getting nearest zero crossing frame */ vol_ramp_func ramp_func; /**< function for ramp shape */ + bool copy_gain; /**< control copy gain or not */ }; /** \brief Volume processing functions map. */