Skip to content

Commit c622f16

Browse files
author
Jyri Sarha
committed
Audio: SRC: All memory allocations through module
Change all memory allocations to go through module API mod_alloc(), mod_zalloc(), and mod_free(). Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 6b9980d commit c622f16

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

src/audio/src/src.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static int src_prepare(struct processing_module *mod,
6060
if (ret < 0)
6161
return ret;
6262

63-
ret = src_allocate_copy_stages(mod->dev, a,
63+
ret = src_allocate_copy_stages(mod, a,
6464
src_table1[a->idx_out][a->idx_in],
6565
src_table2[a->idx_out][a->idx_in]);
6666
if (ret < 0)

src/audio/src/src_common.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,9 @@ int src_params_general(struct processing_module *mod,
531531
}
532532

533533
/* free any existing delay lines. TODO reuse if same size */
534-
rfree(cd->delay_lines);
534+
mod_free(mod, cd->delay_lines);
535535

536-
cd->delay_lines = rballoc(SOF_MEM_FLAG_USER, delay_lines_size);
536+
cd->delay_lines = mod_alloc(mod, delay_lines_size, 0);
537537
if (!cd->delay_lines) {
538538
comp_err(dev, "src_params(): failed to alloc cd->delay_lines, delay_lines_size = %zu",
539539
delay_lines_size);
@@ -594,10 +594,11 @@ int src_param_set(struct comp_dev *dev, struct comp_data *cd)
594594
return 0;
595595
}
596596

597-
int src_allocate_copy_stages(struct comp_dev *dev, struct src_param *prm,
597+
int src_allocate_copy_stages(struct processing_module *mod, struct src_param *prm,
598598
const struct src_stage *stage_src1,
599599
const struct src_stage *stage_src2)
600600
{
601+
struct comp_dev *dev = mod->dev;
601602
#if CONFIG_FAST_GET
602603
struct src_stage *stage_dst;
603604
size_t coef_size[2];
@@ -607,8 +608,7 @@ int src_allocate_copy_stages(struct comp_dev *dev, struct src_param *prm,
607608
size_t tap_size = sizeof(int32_t);
608609
#endif
609610

610-
stage_dst = rmalloc(SOF_MEM_FLAG_USER,
611-
2 * sizeof(*stage_dst));
611+
stage_dst = mod_alloc(mod, 2 * sizeof(*stage_dst), 0);
612612
if (!stage_dst) {
613613
comp_err(dev, "failed to allocate stages");
614614
return -ENOMEM;
@@ -625,7 +625,7 @@ int src_allocate_copy_stages(struct comp_dev *dev, struct src_param *prm,
625625
comp_err(dev,
626626
"illegal zero coefficient vector size for unsupported conversion request %d to %d",
627627
prm->in_fs[prm->idx_in], prm->out_fs[prm->idx_out]);
628-
rfree(stage_dst);
628+
mod_free(mod, stage_dst);
629629
return -EINVAL;
630630
}
631631

@@ -635,7 +635,7 @@ int src_allocate_copy_stages(struct comp_dev *dev, struct src_param *prm,
635635
if (!stage_dst[0].coefs || !stage_dst[1].coefs) {
636636
comp_err(dev, "failed to allocate coefficients");
637637
fast_put(stage_dst[0].coefs);
638-
rfree(stage_dst);
638+
mod_free(mod, stage_dst);
639639
return -ENOMEM;
640640
}
641641

@@ -714,14 +714,14 @@ __cold int src_free(struct processing_module *mod)
714714
comp_info(mod->dev, "src_free()");
715715

716716
/* Free dynamically reserved buffers for SRC algorithm */
717-
rfree(cd->delay_lines);
717+
mod_free(mod, cd->delay_lines);
718718
#if CONFIG_FAST_GET
719719
if (cd->param.stage1) {
720720
fast_put(cd->param.stage1->coefs);
721721
fast_put(cd->param.stage2->coefs);
722722
}
723-
rfree((void *)cd->param.stage1);
723+
mod_free(mod, (void *)cd->param.stage1);
724724
#endif
725-
rfree(cd);
725+
mod_free(mod, cd);
726726
return 0;
727727
}

src/audio/src/src_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static inline int src_fallback(struct comp_data *cd,
215215
return 0;
216216
}
217217

218-
int src_allocate_copy_stages(struct comp_dev *dev, struct src_param *prm,
218+
int src_allocate_copy_stages(struct processing_module *mod, struct src_param *prm,
219219
const struct src_stage *stage_src1,
220220
const struct src_stage *stage_src2);
221221
int src_rate_check(const void *spec);

src/audio/src/src_ipc3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ int src_init(struct processing_module *mod)
178178
return -EINVAL;
179179
}
180180

181-
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
181+
cd = mod_zalloc(mod, sizeof(*cd), 0);
182182
if (!cd)
183183
return -ENOMEM;
184184

src/audio/src/src_ipc4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ __cold int src_init(struct processing_module *mod)
209209
return -EINVAL;
210210
}
211211

212-
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
212+
cd = mod_zalloc(mod, sizeof(*cd), 0);
213213
if (!cd)
214214
return -ENOMEM;
215215

@@ -240,7 +240,7 @@ __cold int src_init(struct processing_module *mod)
240240
default:
241241
comp_err(dev, "src_init(): Illegal sample depth %d",
242242
cd->ipc_config.base.audio_fmt.depth);
243-
rfree(cd);
243+
mod_free(mod, cd);
244244
return -EINVAL;
245245
}
246246

src/audio/src/src_lite.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static int src_lite_prepare(struct processing_module *mod,
4343
if (ret < 0)
4444
return ret;
4545

46-
ret = src_allocate_copy_stages(mod->dev, a,
46+
ret = src_allocate_copy_stages(mod, a,
4747
src_table1[a->idx_out][a->idx_in],
4848
src_table2[a->idx_out][a->idx_in]);
4949
if (ret < 0)

0 commit comments

Comments
 (0)