Skip to content

Commit

Permalink
rtnr: remove buffer_acquire from rtnr.c
Browse files Browse the repository at this point in the history
remove buffer ops from rtnr.c

this is a continuation of changes
from commit 4a03699

Signed-off-by: Tobiasz Dryjanski <[email protected]>
  • Loading branch information
tobonex committed Sep 19, 2023
1 parent 0ff349c commit ffac968
Showing 1 changed file with 17 additions and 30 deletions.
47 changes: 17 additions & 30 deletions src/audio/rtnr/rtnr.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ static int rtnr_params(struct comp_dev *dev, struct sof_ipc_stream_params *param
int ret;
struct comp_data *cd = comp_get_drvdata(dev);
struct comp_buffer *sinkb, *sourceb;
struct comp_buffer *sink_c, *source_c;
bool channels_valid;

comp_info(dev, "rtnr_params()");
Expand All @@ -341,21 +340,17 @@ static int rtnr_params(struct comp_dev *dev, struct sof_ipc_stream_params *param
sinkb = list_first_item(&dev->bsink_list, struct comp_buffer,
source_list);

source_c = buffer_acquire(sourceb);
sink_c = buffer_acquire(sinkb);

/* set source/sink_frames/rate */
cd->source_rate = audio_stream_get_rate(&source_c->stream);
cd->sink_rate = audio_stream_get_rate(&sink_c->stream);
cd->sources_stream[0].rate = audio_stream_get_rate(&source_c->stream);
cd->sink_stream.rate = audio_stream_get_rate(&sink_c->stream);
channels_valid = audio_stream_get_channels(&source_c->stream) ==
audio_stream_get_channels(&sink_c->stream);
cd->source_rate = audio_stream_get_rate(&sourceb->stream);
cd->sink_rate = audio_stream_get_rate(&sinkb->stream);
cd->sources_stream[0].rate = audio_stream_get_rate(&sourceb->stream);
cd->sink_stream.rate = audio_stream_get_rate(&sinkb->stream);
channels_valid = audio_stream_get_channels(&sourceb->stream) ==
audio_stream_get_channels(&sinkb->stream);

if (!cd->sink_rate) {
comp_err(dev, "rtnr_nr_params(), zero sink rate");
ret = -EINVAL;
goto out;
return -EINVAL;
}

/* Currently support 16kHz sample rate only. */
Expand All @@ -369,29 +364,23 @@ static int rtnr_params(struct comp_dev *dev, struct sof_ipc_stream_params *param
default:
comp_err(dev, "rtnr_nr_params(), invalid sample rate(%d kHz)",
cd->source_rate);
ret = -EINVAL;
goto out;
return -EINVAL;
}

if (!channels_valid) {
comp_err(dev, "rtnr_params(), source/sink stream must have same channels");
ret = -EINVAL;
goto out;
return -EINVAL;
}

/* set source/sink stream channels */
cd->sources_stream[0].channels = audio_stream_get_channels(&source_c->stream);
cd->sink_stream.channels = audio_stream_get_channels(&sink_c->stream);
cd->sources_stream[0].channels = audio_stream_get_channels(&sourceb->stream);
cd->sink_stream.channels = audio_stream_get_channels(&sinkb->stream);

/* set source/sink stream overrun/underrun permitted */
cd->sources_stream[0].overrun_permitted = audio_stream_get_overrun(&source_c->stream);
cd->sink_stream.overrun_permitted = audio_stream_get_overrun(&sink_c->stream);
cd->sources_stream[0].underrun_permitted = audio_stream_get_underrun(&source_c->stream);
cd->sink_stream.underrun_permitted = audio_stream_get_underrun(&sink_c->stream);

out:
buffer_release(sink_c);
buffer_release(source_c);
cd->sources_stream[0].overrun_permitted = audio_stream_get_overrun(&sourceb->stream);
cd->sink_stream.overrun_permitted = audio_stream_get_overrun(&sinkb->stream);
cd->sources_stream[0].underrun_permitted = audio_stream_get_underrun(&sourceb->stream);
cd->sink_stream.underrun_permitted = audio_stream_get_underrun(&sinkb->stream);

return ret;
}
Expand Down Expand Up @@ -874,10 +863,8 @@ static int rtnr_prepare(struct comp_dev *dev)

/* Get sink data format */
sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
sink_c = buffer_acquire(sinkb);
cd->sink_format = audio_stream_get_frm_fmt(&sink_c->stream);
cd->sink_stream.frame_fmt = audio_stream_get_frm_fmt(&sink_c->stream);
buffer_release(sink_c);
cd->sink_format = audio_stream_get_frm_fmt(&sinkb->stream);
cd->sink_stream.frame_fmt = audio_stream_get_frm_fmt(&sinkb->stream);

/* Check source and sink PCM format and get processing function */
comp_info(dev, "rtnr_prepare(), sink_format=%d", cd->sink_format);
Expand Down

0 comments on commit ffac968

Please sign in to comment.