Skip to content

Commit 7dd4c41

Browse files
singalsulrgirdwo
authored andcommitted
Audio: Continue volume ramp until all channels are complete
The volume component works correct when all channels receive the same gain value in volume set command. This patch fixes a bug that is triggered by applying different gain values for the channels. The logic with setting cd->ramp_finished to true caused the check in volume copy() to no more call volume_ramp() when one of the channel reached their target volume. When the ramp updating was stopped all other channels remain in intermediate gain value. In the fix the logic is set to opposite. Whenever a channel needs a ramp update it sets a temporary flag. The ramp finish is set only when no channels needed gain update. Fixes #3455 Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent 478eb68 commit 7dd4c41

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/audio/volume/volume.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ static void volume_ramp(struct comp_dev *dev)
216216
int32_t vol;
217217
int32_t ramp_time;
218218
int i;
219+
bool ramp_finished = true;
219220

220221
/* No need to ramp in idle state, jump volume to request. */
221222
if (dev->state == COMP_STATE_READY) {
@@ -257,9 +258,8 @@ static void volume_ramp(struct comp_dev *dev)
257258
if (vol >= cd->tvolume[i] || vol >= cd->vol_max) {
258259
cd->ramp_coef[i] = 0;
259260
cd->volume[i] = cd->tvolume[i];
260-
cd->ramp_finished = true;
261-
cd->vol_ramp_active = false;
262261
} else {
262+
ramp_finished = false;
263263
cd->volume[i] = vol;
264264
}
265265
} else {
@@ -274,16 +274,20 @@ static void volume_ramp(struct comp_dev *dev)
274274
vol <= cd->vol_min) {
275275
cd->ramp_coef[i] = 0;
276276
cd->volume[i] = cd->tvolume[i];
277-
cd->ramp_finished = true;
278-
cd->vol_ramp_active = false;
279277
} else {
278+
ramp_finished = false;
280279
cd->volume[i] = vol;
281280
}
282281
}
283282
}
284283

285284
}
286285

286+
if (ramp_finished) {
287+
cd->ramp_finished = true;
288+
cd->vol_ramp_active = false;
289+
}
290+
287291
/* sync host with new value */
288292
vol_sync_host(dev, cd->channels);
289293
}

0 commit comments

Comments
 (0)