mirror of https://github.com/thesofproject/sof.git
muxdemux: Remove dependency on config->frame_format.
(de)mux_get_processing_function() call depended on config->frame_format being properly configured, which was obsolete from the very beginning. This patch removed that dependency in favor of reading frame_fmt from downstream buffer during the call, rendering that field completely obsolete. Signed-off-by: Artur Kloniecki <arturx.kloniecki@linux.intel.com>
This commit is contained in:
parent
578e21decd
commit
8d76846ba8
|
@ -71,7 +71,6 @@ static int mux_set_values(struct comp_dev *dev, struct comp_data *cd,
|
|||
}
|
||||
|
||||
cd->config.num_channels = cfg->num_channels;
|
||||
cd->config.frame_format = cfg->frame_format;
|
||||
|
||||
for (i = 0; i < cfg->num_streams; i++) {
|
||||
cd->config.streams[i].num_channels = cfg->streams[i].num_channels;
|
||||
|
@ -80,10 +79,12 @@ static int mux_set_values(struct comp_dev *dev, struct comp_data *cd,
|
|||
cd->config.streams[i].mask[j] = cfg->streams[i].mask[j];
|
||||
}
|
||||
|
||||
if (dev->comp.type == SOF_COMP_MUX)
|
||||
cd->mux = mux_get_processing_function(dev);
|
||||
else
|
||||
cd->demux = demux_get_processing_function(dev);
|
||||
if (dev->state > COMP_STATE_INIT) {
|
||||
if (dev->comp.type == SOF_COMP_MUX)
|
||||
cd->mux = mux_get_processing_function(dev);
|
||||
else
|
||||
cd->demux = demux_get_processing_function(dev);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -104,6 +105,8 @@ static struct comp_dev *mux_new(const struct comp_driver *drv,
|
|||
COMP_SIZE(struct sof_ipc_comp_process));
|
||||
if (!dev)
|
||||
return NULL;
|
||||
|
||||
dev->state = COMP_STATE_INIT;
|
||||
dev->drv = drv;
|
||||
|
||||
dev->size = COMP_SIZE(struct sof_ipc_comp_process);
|
||||
|
@ -198,7 +201,6 @@ static int mux_params(struct comp_dev *dev,
|
|||
source_list);
|
||||
|
||||
cd->config.num_channels = sinkb->stream.channels;
|
||||
cd->config.frame_format = sinkb->stream.frame_fmt;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -385,11 +385,17 @@ const struct comp_func_map mux_func_map[] = {
|
|||
|
||||
mux_func mux_get_processing_function(struct comp_dev *dev)
|
||||
{
|
||||
struct comp_data *cd = comp_get_drvdata(dev);
|
||||
struct comp_buffer *sinkb;
|
||||
uint8_t i;
|
||||
|
||||
if (list_is_empty(&dev->bsink_list))
|
||||
return NULL;
|
||||
|
||||
sinkb = list_first_item(&dev->bsink_list, struct comp_buffer,
|
||||
source_list);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mux_func_map); i++) {
|
||||
if (cd->config.frame_format == mux_func_map[i].frame_format)
|
||||
if (sinkb->stream.frame_fmt == mux_func_map[i].frame_format)
|
||||
return mux_func_map[i].mux_proc_func;
|
||||
}
|
||||
|
||||
|
@ -398,11 +404,17 @@ mux_func mux_get_processing_function(struct comp_dev *dev)
|
|||
|
||||
demux_func demux_get_processing_function(struct comp_dev *dev)
|
||||
{
|
||||
struct comp_data *cd = comp_get_drvdata(dev);
|
||||
struct comp_buffer *sinkb;
|
||||
uint8_t i;
|
||||
|
||||
if (list_is_empty(&dev->bsink_list))
|
||||
return NULL;
|
||||
|
||||
sinkb = list_first_item(&dev->bsink_list, struct comp_buffer,
|
||||
source_list);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mux_func_map); i++) {
|
||||
if (cd->config.frame_format == mux_func_map[i].frame_format)
|
||||
if (sinkb->stream.frame_fmt == mux_func_map[i].frame_format)
|
||||
return mux_func_map[i].demux_proc_func;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
// Author: Daniel Bogdzia <danielx.bogdzia@linux.intel.com>
|
||||
// Janusz Jankowski <janusz.jankowski@linux.intel.com>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#include <sof/audio/component_ext.h>
|
||||
#include <sof/audio/mux.h>
|
||||
|
||||
|
@ -18,6 +20,7 @@
|
|||
struct test_data {
|
||||
struct comp_dev *dev;
|
||||
struct comp_data *cd;
|
||||
struct comp_buffer *sink;
|
||||
};
|
||||
|
||||
static int setup_group(void **state)
|
||||
|
@ -51,6 +54,8 @@ static int setup_test_case(void **state)
|
|||
|
||||
td->cd = (struct comp_data *)td->dev->priv_data;
|
||||
|
||||
td->sink = create_test_sink(td->dev, 0, 0, 0);
|
||||
|
||||
*state = td;
|
||||
|
||||
return 0;
|
||||
|
@ -61,6 +66,7 @@ static int teardown_test_case(void **state)
|
|||
struct test_data *td = *state;
|
||||
|
||||
comp_free(td->dev);
|
||||
free(td->sink);
|
||||
free(td);
|
||||
|
||||
return 0;
|
||||
|
@ -73,7 +79,7 @@ static void test_mux_get_processing_function_invalid_float(void **state)
|
|||
mux_func func = NULL;
|
||||
|
||||
/* set frame format value to unsupported value */
|
||||
td->cd->config.frame_format = SOF_IPC_FRAME_FLOAT;
|
||||
td->sink->stream.frame_fmt = SOF_IPC_FRAME_FLOAT;
|
||||
|
||||
func = mux_get_processing_function(td->dev);
|
||||
|
||||
|
@ -87,7 +93,7 @@ static void test_mux_get_processing_function_valid_s16le(void **state)
|
|||
struct test_data *td = *state;
|
||||
mux_func func = NULL;
|
||||
|
||||
td->cd->config.frame_format = SOF_IPC_FRAME_S16_LE;
|
||||
td->sink->stream.frame_fmt = SOF_IPC_FRAME_S16_LE;
|
||||
|
||||
func = mux_get_processing_function(td->dev);
|
||||
|
||||
|
@ -101,7 +107,7 @@ static void test_mux_get_processing_function_valid_s24_4le(void **state)
|
|||
struct test_data *td = *state;
|
||||
mux_func func = NULL;
|
||||
|
||||
td->cd->config.frame_format = SOF_IPC_FRAME_S24_4LE;
|
||||
td->sink->stream.frame_fmt = SOF_IPC_FRAME_S24_4LE;
|
||||
|
||||
func = mux_get_processing_function(td->dev);
|
||||
|
||||
|
@ -115,7 +121,7 @@ static void test_mux_get_processing_function_valid_s32le(void **state)
|
|||
struct test_data *td = *state;
|
||||
mux_func func = NULL;
|
||||
|
||||
td->cd->config.frame_format = SOF_IPC_FRAME_S32_LE;
|
||||
td->sink->stream.frame_fmt = SOF_IPC_FRAME_S32_LE;
|
||||
|
||||
func = mux_get_processing_function(td->dev);
|
||||
|
||||
|
|
Loading…
Reference in New Issue