mirror of https://github.com/thesofproject/sof.git
copier: fix attenuation stream frames calculation
When calculating number of frames to be attenuated in HOST copier source stream frame bytes should be used instead of sink frame bytes. E.g. in case of 24/24 bit to 24/32 bit PCM conversion using sink container size will reduce frames number by 1/4 which will lead to multiple glitches. Also attenuation has to be applied in HOST copier in playback scenario only, thus remove from do_conversion_copy() Signed-off-by: Ievgen Ganakov <ievgen.ganakov@intel.com>
This commit is contained in:
parent
d3f8bdc304
commit
8fb011df6c
|
@ -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)
|
||||
|
@ -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) {
|
||||
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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
@ -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);
|
||||
sink = buffer_acquire(cd->hd->local_buffer);
|
||||
frames = bytes / audio_stream_frame_bytes(&source->stream);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue