Skip to content
Draft
11 changes: 5 additions & 6 deletions src/audio/aria/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <sof/audio/pipeline.h>
#include <rtos/panic.h>
#include <sof/ipc/msg.h>
#include <rtos/alloc.h>
#include <rtos/cache.h>
#include <rtos/init.h>
#include <sof/lib/notifier.h>
Expand Down Expand Up @@ -126,7 +125,7 @@ static int aria_init(struct processing_module *mod)
list_init(&dev->bsource_list);
list_init(&dev->bsink_list);

cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
cd = mod_zalloc(mod, sizeof(*cd));
if (!cd) {
return -ENOMEM;
}
Expand All @@ -145,10 +144,10 @@ static int aria_init(struct processing_module *mod)
}
mod_data->private = cd;

buf = rballoc(SOF_MEM_FLAG_USER, req_mem);
buf = mod_balloc(mod, req_mem);

if (!buf) {
rfree(cd);
mod_free(mod, cd);
comp_err(dev, "allocation failed for size %d", req_mem);
return -ENOMEM;
}
Expand All @@ -160,8 +159,8 @@ static int aria_free(struct processing_module *mod)
{
struct aria_data *cd = module_get_private_data(mod);

rfree(cd->data_addr);
rfree(cd);
mod_free(mod, cd->data_addr);
mod_free(mod, cd);
return 0;
}

Expand Down
51 changes: 24 additions & 27 deletions src/audio/asrc/asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <sof/audio/ipc-config.h>
#include <rtos/panic.h>
#include <sof/ipc/msg.h>
#include <rtos/alloc.h>
#include <rtos/init.h>
#include <sof/lib/uuid.h>
#include <sof/math/numbers.h>
Expand Down Expand Up @@ -217,7 +216,7 @@ static int asrc_init(struct processing_module *mod)
return -EINVAL;
}

cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
cd = mod_zalloc(mod, sizeof(*cd));
if (!cd)
return -ENOMEM;

Expand All @@ -242,7 +241,7 @@ static int asrc_init(struct processing_module *mod)
return 0;
}

static int asrc_initialize_buffers(struct asrc_farrow *src_obj)
static int asrc_initialize_buffers(struct processing_module *mod, struct asrc_farrow *src_obj)
{
int32_t *buf_32;
int16_t *buf_16;
Expand All @@ -261,7 +260,7 @@ static int asrc_initialize_buffers(struct asrc_farrow *src_obj)
buffer_size = src_obj->buffer_length * sizeof(int32_t);

for (ch = 0; ch < src_obj->num_channels; ch++) {
buf_32 = rzalloc(SOF_MEM_FLAG_USER, buffer_size);
buf_32 = mod_zalloc(mod, buffer_size);

if (!buf_32)
return -ENOMEM;
Expand All @@ -272,7 +271,7 @@ static int asrc_initialize_buffers(struct asrc_farrow *src_obj)
buffer_size = src_obj->buffer_length * sizeof(int16_t);

for (ch = 0; ch < src_obj->num_channels; ch++) {
buf_16 = rzalloc(SOF_MEM_FLAG_USER, buffer_size);
buf_16 = mod_zalloc(mod, buffer_size);

if (!buf_16)
return -ENOMEM;
Expand All @@ -284,7 +283,7 @@ static int asrc_initialize_buffers(struct asrc_farrow *src_obj)
return 0;
}

static void asrc_release_buffers(struct asrc_farrow *src_obj)
static void asrc_release_buffers(struct processing_module *mod, struct asrc_farrow *src_obj)
{
int32_t *buf_32;
int16_t *buf_16;
Expand All @@ -299,7 +298,7 @@ static void asrc_release_buffers(struct asrc_farrow *src_obj)

if (buf_32) {
src_obj->ring_buffers32[ch] = NULL;
rfree(buf_32);
mod_free(mod, buf_32);
}
}
else
Expand All @@ -308,7 +307,7 @@ static void asrc_release_buffers(struct asrc_farrow *src_obj)

if (buf_16) {
src_obj->ring_buffers16[ch] = NULL;
rfree(buf_16);
mod_free(mod, buf_16);
}
}
}
Expand All @@ -320,11 +319,11 @@ static int asrc_free(struct processing_module *mod)

comp_dbg(dev, "asrc_free()");

rfree(cd->buf);
asrc_release_buffers(cd->asrc_obj);
asrc_free_polyphase_filter(cd->asrc_obj);
rfree(cd->asrc_obj);
rfree(cd);
mod_free(mod, cd->buf);
asrc_release_buffers(mod, cd->asrc_obj);
asrc_free_polyphase_filter(mod, cd->asrc_obj);
mod_free(mod, cd->asrc_obj);
mod_free(mod, cd);
return 0;
}

Expand Down Expand Up @@ -614,8 +613,7 @@ static int asrc_prepare(struct processing_module *mod,
cd->buf_size = (cd->source_frames_max + cd->sink_frames_max) *
frame_bytes;

cd->buf = rzalloc(SOF_MEM_FLAG_USER,
cd->buf_size);
cd->buf = mod_zalloc(mod, cd->buf_size);
if (!cd->buf) {
cd->buf_size = 0;
comp_err(dev, "asrc_prepare(), allocation fail for size %d",
Expand All @@ -632,16 +630,15 @@ static int asrc_prepare(struct processing_module *mod,

/* Get required size and allocate memory for ASRC */
sample_bits = sample_bytes * 8;
ret = asrc_get_required_size(dev, &cd->asrc_size,
ret = asrc_get_required_size(mod, &cd->asrc_size,
audio_stream_get_channels(&sourceb->stream),
sample_bits);
if (ret) {
comp_err(dev, "asrc_prepare(), get_required_size_bytes failed");
goto err_free_buf;
}

cd->asrc_obj = rzalloc(SOF_MEM_FLAG_USER,
cd->asrc_size);
cd->asrc_obj = mod_zalloc(mod, cd->asrc_size);
if (!cd->asrc_obj) {
comp_err(dev, "asrc_prepare(), allocation fail for size %d",
cd->asrc_size);
Expand All @@ -659,7 +656,7 @@ static int asrc_prepare(struct processing_module *mod,
fs_sec = cd->source_rate;
}

ret = asrc_initialise(dev, cd->asrc_obj, audio_stream_get_channels(&sourceb->stream),
ret = asrc_initialise(mod, cd->asrc_obj, audio_stream_get_channels(&sourceb->stream),
fs_prim, fs_sec,
ASRC_IOF_INTERLEAVED, ASRC_IOF_INTERLEAVED,
ASRC_BM_LINEAR, cd->frames, sample_bits,
Expand All @@ -670,7 +667,7 @@ static int asrc_prepare(struct processing_module *mod,
}

/* Allocate ring buffers */
ret = asrc_initialize_buffers(cd->asrc_obj);
ret = asrc_initialize_buffers(mod, cd->asrc_obj);

/* check for errors */
if (ret) {
Expand Down Expand Up @@ -698,12 +695,12 @@ static int asrc_prepare(struct processing_module *mod,
return 0;

err_free_asrc:
asrc_release_buffers(cd->asrc_obj);
rfree(cd->asrc_obj);
asrc_release_buffers(mod, cd->asrc_obj);
mod_free(mod, cd->asrc_obj);
cd->asrc_obj = NULL;

err_free_buf:
rfree(cd->buf);
mod_free(mod, cd->buf);
cd->buf = NULL;

err:
Expand Down Expand Up @@ -865,10 +862,10 @@ static int asrc_reset(struct processing_module *mod)
asrc_dai_stop_timestamp(cd);

/* Free the allocations those were done in prepare() */
asrc_release_buffers(cd->asrc_obj);
asrc_free_polyphase_filter(cd->asrc_obj);
rfree(cd->asrc_obj);
rfree(cd->buf);
asrc_release_buffers(mod, cd->asrc_obj);
asrc_free_polyphase_filter(mod, cd->asrc_obj);
mod_free(mod, cd->asrc_obj);
mod_free(mod, cd->buf);
cd->asrc_obj = NULL;
cd->buf = NULL;

Expand Down
Loading
Loading