Skip to content

Commit 104c635

Browse files
lyakhlgirdwood
authored andcommitted
waves: always acquire buffers for access
Buffers must always be acquired before access. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent a25f18a commit 104c635

1 file changed

Lines changed: 47 additions & 28 deletions

File tree

  • src/audio/module_adapter/module

‎src/audio/module_adapter/module/waves.c‎

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -223,68 +223,79 @@ static int waves_effect_check(struct comp_dev *dev)
223223
source_list);
224224
struct comp_buffer *source = list_first_item(&dev->bsource_list, struct comp_buffer,
225225
sink_list);
226-
const struct audio_stream *src_fmt = &source->stream;
227-
const struct audio_stream *snk_fmt = &sink->stream;
226+
struct comp_buffer __sparse_cache *source_c = buffer_acquire(source);
227+
struct comp_buffer __sparse_cache *sink_c = buffer_acquire(sink);
228+
const struct audio_stream __sparse_cache *src_fmt = &source_c->stream;
229+
const struct audio_stream __sparse_cache *snk_fmt = &sink_c->stream;
230+
int ret = 0;
228231

229232
/* Init sink & source buffers */
230233
comp_dbg(dev, "waves_effect_check() start");
231234

232-
if (!source || !sink) {
233-
comp_err(dev, "waves_effect_check() source/sink buffer not found");
234-
return -EINVAL;
235-
}
236-
237235
/* todo use fallback to comp_verify_params when ready */
238236

239237
/* resampling not supported */
240238
if (src_fmt->rate != snk_fmt->rate) {
241239
comp_err(dev, "waves_effect_check() source %d sink %d rate mismatch",
242240
src_fmt->rate, snk_fmt->rate);
243-
return -EINVAL;
241+
ret = -EINVAL;
242+
goto out;
244243
}
245244

246245
/* upmix/downmix not supported */
247246
if (src_fmt->channels != snk_fmt->channels) {
248247
comp_err(dev, "waves_effect_check() source %d sink %d channels mismatch",
249248
src_fmt->channels, snk_fmt->channels);
250-
return -EINVAL;
249+
ret = -EINVAL;
250+
goto out;
251251
}
252252

253253
/* different frame format not supported */
254254
if (src_fmt->frame_fmt != snk_fmt->frame_fmt) {
255255
comp_err(dev, "waves_effect_check() source %d sink %d sample format mismatch",
256256
src_fmt->frame_fmt, snk_fmt->frame_fmt);
257-
return -EINVAL;
257+
ret = -EINVAL;
258+
goto out;
258259
}
259260

260261
/* different interleaving is not supported */
261-
if (source->buffer_fmt != sink->buffer_fmt) {
262+
if (source_c->buffer_fmt != sink_c->buffer_fmt) {
262263
comp_err(dev, "waves_effect_check() source %d sink %d buffer format mismatch");
263-
return -EINVAL;
264+
ret = -EINVAL;
265+
goto out;
264266
}
265267

266268
if (!format_is_supported(src_fmt->frame_fmt)) {
267269
comp_err(dev, "waves_effect_check() float samples not supported");
268-
return -EINVAL;
270+
ret = -EINVAL;
271+
goto out;
269272
}
270273

271-
if (!layout_is_supported(source->buffer_fmt)) {
274+
if (!layout_is_supported(source_c->buffer_fmt)) {
272275
comp_err(dev, "waves_effect_check() non interleaved format not supported");
273-
return -EINVAL;
276+
ret = -EINVAL;
277+
goto out;
274278
}
275279

276280
if (!rate_is_supported(src_fmt->rate)) {
277281
comp_err(dev, "waves_effect_check() rate %d not supported", src_fmt->rate);
278-
return -EINVAL;
282+
ret = -EINVAL;
283+
goto out;
279284
}
280285

281286
if (src_fmt->channels != 2) {
282287
comp_err(dev, "waves_effect_check() channels %d not supported", src_fmt->channels);
283-
return -EINVAL;
288+
ret = -EINVAL;
289+
goto out;
284290
}
285291

286292
comp_dbg(dev, "waves_effect_check() done");
287-
return 0;
293+
294+
out:
295+
buffer_release(sink_c);
296+
buffer_release(source_c);
297+
298+
return ret;
288299
}
289300

290301
/* initializes MaxxEffect based on stream parameters */
@@ -293,39 +304,42 @@ static int waves_effect_init(struct processing_module *mod)
293304
struct comp_dev *dev = mod->dev;
294305
struct comp_buffer *source = list_first_item(&dev->bsource_list, struct comp_buffer,
295306
sink_list);
307+
struct comp_buffer __sparse_cache *source_c = buffer_acquire(source);
296308
struct module_data *codec = &mod->priv;
297309
struct waves_codec_data *waves_codec = codec->private;
298-
299-
const struct audio_stream *src_fmt = &source->stream;
300-
310+
const struct audio_stream __sparse_cache *src_fmt = &source_c->stream;
301311
MaxxStatus_t status;
302312
MaxxBuffer_Format_t sample_format;
303313
MaxxBuffer_Layout_t buffer_format;
304314
int32_t sample_bytes;
305315
MaxxStreamFormat_t *i_formats[NUM_IO_STREAMS] = { &waves_codec->i_format };
306316
MaxxStreamFormat_t *o_formats[NUM_IO_STREAMS] = { &waves_codec->o_format };
317+
int ret = 0;
307318

308319
comp_dbg(dev, "waves_effect_init() start");
309320

310321
sample_format = format_convert_sof_to_me(src_fmt->frame_fmt);
311322
if (sample_format < 0) {
312323
comp_err(dev, "waves_effect_init() sof sample format %d not supported",
313324
src_fmt->frame_fmt);
314-
return -EINVAL;
325+
ret = -EINVAL;
326+
goto out;
315327
}
316328

317-
buffer_format = layout_convert_sof_to_me(source->buffer_fmt);
329+
buffer_format = layout_convert_sof_to_me(source_c->buffer_fmt);
318330
if (buffer_format < 0) {
319331
comp_err(dev, "waves_effect_init() sof buffer format %d not supported",
320-
source->buffer_fmt);
321-
return -EINVAL;
332+
source_c->buffer_fmt);
333+
ret = -EINVAL;
334+
goto out;
322335
}
323336

324337
sample_bytes = sample_format_convert_to_bytes(sample_format);
325338
if (sample_bytes < 0) {
326339
comp_err(dev, "waves_effect_init() sample_format %d not supported",
327340
sample_format);
328-
return -EINVAL;
341+
ret = -EINVAL;
342+
goto out;
329343
}
330344

331345
waves_codec->request_max_bytes = 0;
@@ -359,11 +373,16 @@ static int waves_effect_init(struct processing_module *mod)
359373

360374
if (status) {
361375
comp_err(dev, "waves_effect_init() MaxxEffect_Initialize returned %d", status);
362-
return -EINVAL;
376+
ret = -EINVAL;
377+
goto out;
363378
}
364379

365380
comp_dbg(dev, "waves_effect_init() done");
366-
return 0;
381+
382+
out:
383+
buffer_release(source_c);
384+
385+
return ret;
367386
}
368387

369388
/* allocate additional buffers for MaxxEffect */

0 commit comments

Comments
 (0)