Volume: Improve PCM format handling in params and prepare

This patch removes from params function the setting of component's
own stored frame_fmt since the variable cd->sink_format was not set.

In prepare function the frame_fmt is stored based on stream
direction. In playback it's set from source and in capture from sink.
This way the format matches the host component side of stream.

These changes help other components in the pipeline to operate with
correct PCM format.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This commit is contained in:
Seppo Ingalsuo 2019-03-15 15:43:30 +02:00 committed by Liam Girdwood
parent cd4633c53e
commit c838ad082d
1 changed files with 5 additions and 7 deletions

View File

@ -236,13 +236,8 @@ static void volume_free(struct comp_dev *dev)
*/
static int volume_params(struct comp_dev *dev)
{
struct comp_data *cd = comp_get_drvdata(dev);
trace_volume("volume_params()");
/* rewrite params format for all downstream */
dev->params.frame_fmt = cd->sink_format;
return 0;
}
@ -551,8 +546,11 @@ static int volume_prepare(struct comp_dev *dev)
comp_set_period_bytes(sinkb->sink, dev->frames, &cd->sink_format,
&sink_period_bytes);
/* rewrite params format for all downstream */
dev->params.frame_fmt = cd->sink_format;
/* Rewrite params format for this component to match the host side. */
if (dev->params.direction == SOF_IPC_STREAM_PLAYBACK)
dev->params.frame_fmt = cd->source_format;
else
dev->params.frame_fmt = cd->sink_format;
/* set downstream buffer size */
ret = buffer_set_size(sinkb, sink_period_bytes * config->periods_sink);