Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copier: fix attenuation stream frames calculation #7761

Merged
merged 1 commit into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ static int do_conversion_copy(struct comp_dev *dev,
struct comp_copy_limits *processed_data)
{
int i;
int ret;

/* buffer params might be not yet configured by component on another pipeline */
if (!src->hw_params_configured || !sink->hw_params_configured)
Expand All @@ -455,12 +454,6 @@ static int do_conversion_copy(struct comp_dev *dev,
cd->converter[i](&src->stream, 0, &sink->stream, 0,
processed_data->frames * audio_stream_get_channels(&sink->stream));

if (cd->attenuation) {
btian1 marked this conversation as resolved.
Show resolved Hide resolved
ret = apply_attenuation(dev, cd, sink, processed_data->frames);
if (ret < 0)
return ret;
}

buffer_stream_writeback(sink, processed_data->sink_bytes);
comp_update_buffer_produce(sink, processed_data->sink_bytes);

Expand Down
21 changes: 11 additions & 10 deletions src/audio/copier/copier_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void copier_host_free(struct copier_data *cd)
void copier_host_dma_cb(struct comp_dev *dev, size_t bytes)
{
struct copier_data *cd = comp_get_drvdata(dev);
struct comp_buffer __sparse_cache *sink;
struct comp_buffer __sparse_cache *sink, *source;
int ret, frames;

comp_dbg(dev, "copier_host_dma_cb() %p", dev);
Expand All @@ -138,21 +138,22 @@ void copier_host_dma_cb(struct comp_dev *dev, size_t bytes)
if (cd->hd->copy_type == COMP_COPY_ONE_SHOT)
host_common_one_shot(cd->hd, bytes);

/* apply attenuation since copier copy missed this with host device remove */
if (cd->attenuation) {
if (dev->direction == SOF_IPC_STREAM_PLAYBACK)
sink = buffer_acquire(cd->hd->local_buffer);
else
sink = buffer_acquire(cd->hd->dma_buffer);

frames = bytes / get_sample_bytes(audio_stream_get_frm_fmt(&sink->stream));
frames = frames / audio_stream_get_channels(&sink->stream);
/* Apply attenuation since copier copy missed this with host device
* remove. Attenuation has to be applied in HOST Copier only with
* playback scenario.
*/
if (cd->attenuation && dev->direction == SOF_IPC_STREAM_PLAYBACK) {
source = buffer_acquire(cd->hd->dma_buffer);
dnikodem marked this conversation as resolved.
Show resolved Hide resolved
sink = buffer_acquire(cd->hd->local_buffer);
frames = bytes / audio_stream_frame_bytes(&source->stream);
btian1 marked this conversation as resolved.
Show resolved Hide resolved

ret = apply_attenuation(dev, cd, sink, frames);
if (ret < 0)
comp_dbg(dev, "copier_host_dma_cb() apply attenuation failed! %d", ret);

buffer_stream_writeback(sink, bytes);

buffer_release(source);
buffer_release(sink);
}
}
Expand Down