Skip to content

Commit 4aff776

Browse files
authored
Merge pull request #229 from mrajwa/master
volume: Fix for default value of min/max parameters of volume component which were not setup properly.
2 parents 873185d + f3accb0 commit 4aff776

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/audio/volume.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#include <sof/work.h>
4949
#include <sof/clock.h>
5050
#include "volume.h"
51-
51+
#include <sof/math/numbers.h>
5252
/**
5353
* \brief Synchronize host mmap() volume with real value.
5454
* \param[in,out] cd Volume component private data.
@@ -192,15 +192,16 @@ static struct comp_dev *volume_new(struct sof_ipc_comp *comp)
192192
comp_set_drvdata(dev, cd);
193193
work_init(&cd->volwork, vol_work, dev, WORK_ASYNC);
194194

195+
/* set volume min/max levels */
196+
vol_set_min_max_levels(cd, ipc_vol->min_value, ipc_vol->max_value);
197+
195198
/* set the default volumes */
196199
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++) {
197-
cd->volume[i] = VOL_ZERO_DB;
198-
cd->tvolume[i] = VOL_ZERO_DB;
200+
cd->volume[i] = MAX(MIN(cd->max_volume,
201+
VOL_ZERO_DB), cd->min_volume);
202+
cd->tvolume[i] = cd->volume[i];
199203
}
200204

201-
/* set volume min/max levels */
202-
vol_set_min_max_levels(cd, ipc_vol->min_value, ipc_vol->max_value);
203-
204205
dev->state = COMP_STATE_READY;
205206
return dev;
206207
}

0 commit comments

Comments
 (0)