From c838ad082d01afd7da3663c202a5994bae3f7b05 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 15 Mar 2019 15:43:30 +0200 Subject: [PATCH] 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 --- src/audio/volume.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/audio/volume.c b/src/audio/volume.c index 2651b727e..377ef3dc4 100644 --- a/src/audio/volume.c +++ b/src/audio/volume.c @@ -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);