mirror of https://github.com/thesofproject/sof.git
Audio: Volume: Add state clear to reset() operation
This patch adds clear of all component data in reset() component operation except state variables those are set by control commands. Note: If a new stream starts after reset() without free() and new(), the clear of all component data would result to wrong gain and wrong mute state. The driver commands are not re-sent in such case. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This commit is contained in:
parent
93ea223a89
commit
e82392e246
|
@ -292,6 +292,26 @@ static void volume_ramp(struct comp_dev *dev)
|
||||||
vol_sync_host(dev, cd->channels);
|
vol_sync_host(dev, cd->channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Reset state except controls.
|
||||||
|
*/
|
||||||
|
static void reset_state(struct vol_data *cd)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++) {
|
||||||
|
cd->rvolume[i] = 0;
|
||||||
|
cd->ramp_coef[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cd->channels = 0;
|
||||||
|
cd->ramp_finished = false;
|
||||||
|
cd->vol_ramp_active = false;
|
||||||
|
cd->vol_ramp_frames = 0;
|
||||||
|
cd->vol_ramp_elapsed_frames = 0;
|
||||||
|
cd->sample_rate = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Creates volume component.
|
* \brief Creates volume component.
|
||||||
*
|
*
|
||||||
|
@ -365,9 +385,7 @@ static struct comp_dev *volume_new(const struct comp_driver *drv,
|
||||||
cd->muted[i] = false;
|
cd->muted[i] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cd->vol_ramp_active = false;
|
reset_state(cd);
|
||||||
cd->channels = 0; /* To be set in prepare() */
|
|
||||||
|
|
||||||
comp_info(dev, "vol->initial_ramp = %d, vol->ramp = %d, vol->min_value = %d, vol->max_value = %d",
|
comp_info(dev, "vol->initial_ramp = %d, vol->ramp = %d, vol->min_value = %d, vol->max_value = %d",
|
||||||
vol->initial_ramp, vol->ramp,
|
vol->initial_ramp, vol->ramp,
|
||||||
vol->min_value, vol->max_value);
|
vol->min_value, vol->max_value);
|
||||||
|
@ -890,8 +908,10 @@ err:
|
||||||
*/
|
*/
|
||||||
static int volume_reset(struct comp_dev *dev)
|
static int volume_reset(struct comp_dev *dev)
|
||||||
{
|
{
|
||||||
comp_dbg(dev, "volume_reset()");
|
struct vol_data *cd = comp_get_drvdata(dev);
|
||||||
|
|
||||||
|
comp_dbg(dev, "volume_reset()");
|
||||||
|
reset_state(cd);
|
||||||
comp_set_state(dev, COMP_TRIGGER_RESET);
|
comp_set_state(dev, COMP_TRIGGER_RESET);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue