mirror of https://github.com/thesofproject/sof.git
module_adapter: Add a new helper to update input/output stream buffers
Add a new helper to update the consumed bytes in the input stream buffer and the produces bytes in the output stream buffer. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
This commit is contained in:
parent
2583398d45
commit
ea72e3e97e
|
@ -80,8 +80,8 @@ static void eq_iir_s16_default(struct processing_module *mod, struct input_strea
|
|||
const int samples = frames * nch;
|
||||
int processed = 0;
|
||||
|
||||
bsource->consumed += samples << 1;
|
||||
bsink->size += samples << 1;
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S16_LE,
|
||||
SOF_IPC_FRAME_S16_LE, samples);
|
||||
|
||||
x = source->r_ptr;
|
||||
y = sink->w_ptr;
|
||||
|
@ -131,8 +131,8 @@ static void eq_iir_s24_default(struct processing_module *mod, struct input_strea
|
|||
const int samples = frames * nch;
|
||||
int processed = 0;
|
||||
|
||||
bsource->consumed += S32_SAMPLES_TO_BYTES(samples);
|
||||
bsink->size += S32_SAMPLES_TO_BYTES(samples);
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S32_LE,
|
||||
SOF_IPC_FRAME_S32_LE, samples);
|
||||
|
||||
x = source->r_ptr;
|
||||
y = sink->w_ptr;
|
||||
|
@ -182,8 +182,8 @@ static void eq_iir_s32_default(struct processing_module *mod, struct input_strea
|
|||
const int samples = frames * nch;
|
||||
int processed = 0;
|
||||
|
||||
bsource->consumed += S32_SAMPLES_TO_BYTES(samples);
|
||||
bsink->size += S32_SAMPLES_TO_BYTES(samples);
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S32_LE,
|
||||
SOF_IPC_FRAME_S32_LE, samples);
|
||||
|
||||
x = source->r_ptr;
|
||||
y = sink->w_ptr;
|
||||
|
@ -233,8 +233,8 @@ static void eq_iir_s32_16_default(struct processing_module *mod,
|
|||
const int samples = frames * nch;
|
||||
int processed = 0;
|
||||
|
||||
bsource->consumed += S32_SAMPLES_TO_BYTES(samples);
|
||||
bsink->size += S16_SAMPLES_TO_BYTES(samples);
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S32_LE,
|
||||
SOF_IPC_FRAME_S16_LE, samples);
|
||||
|
||||
x = source->r_ptr;
|
||||
y = sink->w_ptr;
|
||||
|
@ -284,8 +284,8 @@ static void eq_iir_s32_24_default(struct processing_module *mod,
|
|||
const int samples = frames * nch;
|
||||
int processed = 0;
|
||||
|
||||
bsource->consumed += S32_SAMPLES_TO_BYTES(samples);
|
||||
bsink->size += S32_SAMPLES_TO_BYTES(samples);
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S32_LE,
|
||||
SOF_IPC_FRAME_S32_LE, samples);
|
||||
|
||||
x = source->r_ptr;
|
||||
y = sink->w_ptr;
|
||||
|
@ -318,13 +318,12 @@ static void eq_iir_pass(struct processing_module *mod, struct input_stream_buffe
|
|||
struct audio_stream __sparse_cache *source = bsource->data;
|
||||
struct audio_stream __sparse_cache *sink = bsink->data;
|
||||
|
||||
if (source->frame_fmt == SOF_IPC_FRAME_S16_LE) {
|
||||
bsource->consumed += S16_SAMPLES_TO_BYTES(frames * source->channels);
|
||||
bsink->size += S16_SAMPLES_TO_BYTES(frames * source->channels);
|
||||
} else {
|
||||
bsource->consumed += S32_SAMPLES_TO_BYTES(frames * source->channels);
|
||||
bsink->size += S32_SAMPLES_TO_BYTES(frames * source->channels);
|
||||
}
|
||||
if (source->frame_fmt == SOF_IPC_FRAME_S16_LE)
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S16_LE,
|
||||
SOF_IPC_FRAME_S16_LE, frames * source->channels);
|
||||
else
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S32_LE,
|
||||
SOF_IPC_FRAME_S32_LE, frames * source->channels);
|
||||
|
||||
audio_stream_copy(source, 0, sink, 0, frames * source->channels);
|
||||
}
|
||||
|
@ -342,8 +341,8 @@ static void eq_iir_s32_s16_pass(struct processing_module *mod, struct input_stre
|
|||
int i;
|
||||
int remaining_samples = frames * source->channels;
|
||||
|
||||
bsource->consumed += S32_SAMPLES_TO_BYTES(remaining_samples);
|
||||
bsink->size += S16_SAMPLES_TO_BYTES(remaining_samples);
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S32_LE,
|
||||
SOF_IPC_FRAME_S16_LE, remaining_samples);
|
||||
|
||||
while (remaining_samples) {
|
||||
nmax = BYTES_TO_S32_SAMPLES(audio_stream_bytes_without_wrap(source, x));
|
||||
|
@ -375,8 +374,8 @@ static void eq_iir_s32_s24_pass(struct processing_module *mod, struct input_stre
|
|||
int i;
|
||||
int remaining_samples = frames * source->channels;
|
||||
|
||||
bsource->consumed += S32_SAMPLES_TO_BYTES(remaining_samples);
|
||||
bsink->size += S32_SAMPLES_TO_BYTES(remaining_samples);
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S32_LE,
|
||||
SOF_IPC_FRAME_S32_LE, remaining_samples);
|
||||
|
||||
while (remaining_samples) {
|
||||
nmax = BYTES_TO_S32_SAMPLES(audio_stream_bytes_without_wrap(source, x));
|
||||
|
|
|
@ -71,8 +71,8 @@ static void vol_s24_to_s24(struct processing_module *mod, struct input_stream_bu
|
|||
x = source->r_ptr;
|
||||
y = sink->w_ptr;
|
||||
|
||||
bsource->consumed += S32_SAMPLES_TO_BYTES(remaining_samples);
|
||||
bsink->size += S32_SAMPLES_TO_BYTES(remaining_samples);
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S32_LE,
|
||||
SOF_IPC_FRAME_S32_LE, remaining_samples);
|
||||
while (remaining_samples) {
|
||||
nmax = BYTES_TO_S32_SAMPLES(audio_stream_bytes_without_wrap(source, x));
|
||||
n = MIN(remaining_samples, nmax);
|
||||
|
@ -133,8 +133,8 @@ static void vol_s32_to_s32(struct processing_module *mod, struct input_stream_bu
|
|||
|
||||
x = source->r_ptr;
|
||||
y = sink->w_ptr;
|
||||
bsource->consumed += S32_SAMPLES_TO_BYTES(remaining_samples);
|
||||
bsink->size += S32_SAMPLES_TO_BYTES(remaining_samples);
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S32_LE,
|
||||
SOF_IPC_FRAME_S32_LE, remaining_samples);
|
||||
while (remaining_samples) {
|
||||
nmax = BYTES_TO_S32_SAMPLES(audio_stream_bytes_without_wrap(source, x));
|
||||
n = MIN(remaining_samples, nmax);
|
||||
|
@ -201,8 +201,8 @@ static void vol_s16_to_s16(struct processing_module *mod, struct input_stream_bu
|
|||
x = source->r_ptr;
|
||||
y = sink->w_ptr;
|
||||
|
||||
bsource->consumed += S16_SAMPLES_TO_BYTES(remaining_samples);
|
||||
bsink->size += S16_SAMPLES_TO_BYTES(remaining_samples);
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S16_LE,
|
||||
SOF_IPC_FRAME_S16_LE, remaining_samples);
|
||||
while (remaining_samples) {
|
||||
nmax = BYTES_TO_S16_SAMPLES(audio_stream_bytes_without_wrap(source, x));
|
||||
n = MIN(remaining_samples, nmax);
|
||||
|
|
|
@ -92,8 +92,8 @@ static void vol_s24_to_s24_s32(struct processing_module *mod, struct input_strea
|
|||
AE_SETCBEGIN0(buf);
|
||||
AE_SETCEND0(buf_end);
|
||||
|
||||
bsource->consumed += S32_SAMPLES_TO_BYTES(samples);
|
||||
bsink->size += S32_SAMPLES_TO_BYTES(samples);
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S32_LE,
|
||||
SOF_IPC_FRAME_S32_LE, samples);
|
||||
|
||||
while (samples) {
|
||||
m = BYTES_TO_S32_SAMPLES(audio_stream_bytes_without_wrap(source, in));
|
||||
|
@ -183,8 +183,8 @@ static void vol_s32_to_s24_s32(struct processing_module *mod, struct input_strea
|
|||
AE_SETCBEGIN0(buf);
|
||||
AE_SETCEND0(buf_end);
|
||||
|
||||
bsource->consumed += S32_SAMPLES_TO_BYTES(samples);
|
||||
bsink->size += S32_SAMPLES_TO_BYTES(samples);
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S32_LE,
|
||||
SOF_IPC_FRAME_S32_LE, samples);
|
||||
|
||||
while (samples) {
|
||||
m = BYTES_TO_S32_SAMPLES(audio_stream_bytes_without_wrap(source, in));
|
||||
|
@ -324,8 +324,8 @@ static void vol_s16_to_s16(struct processing_module *mod, struct input_stream_bu
|
|||
}
|
||||
AE_SA64POS_FP(outu, out);
|
||||
samples -= n;
|
||||
bsource->consumed += S16_SAMPLES_TO_BYTES(n);
|
||||
bsink->size += S16_SAMPLES_TO_BYTES(n);
|
||||
module_update_processing_position(bsource, bsink, SOF_IPC_FRAME_S16_LE,
|
||||
SOF_IPC_FRAME_S16_LE, n);
|
||||
in = audio_stream_wrap(source, in);
|
||||
out = audio_stream_wrap(sink, out);
|
||||
}
|
||||
|
|
|
@ -334,4 +334,29 @@ int module_set_large_config(struct comp_dev *dev, uint32_t param_id, bool first_
|
|||
int module_get_large_config(struct comp_dev *dev, uint32_t param_id, bool first_block,
|
||||
bool last_block, uint32_t *data_offset, char *data);
|
||||
|
||||
static inline void
|
||||
module_update_processing_position(struct input_stream_buffer *input,
|
||||
struct output_stream_buffer *output,
|
||||
enum sof_ipc_frame input_frame_fmt,
|
||||
enum sof_ipc_frame output_frame_fmt, int samples)
|
||||
{
|
||||
switch (input_frame_fmt) {
|
||||
case SOF_IPC_FRAME_S16_LE:
|
||||
input->consumed += S16_SAMPLES_TO_BYTES(samples);
|
||||
break;
|
||||
default:
|
||||
input->consumed += S32_SAMPLES_TO_BYTES(samples);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (output_frame_fmt) {
|
||||
case SOF_IPC_FRAME_S16_LE:
|
||||
output->size += S16_SAMPLES_TO_BYTES(samples);
|
||||
break;
|
||||
default:
|
||||
output->size += S32_SAMPLES_TO_BYTES(samples);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __SOF_AUDIO_MODULE_GENERIC__ */
|
||||
|
|
Loading…
Reference in New Issue