-
Notifications
You must be signed in to change notification settings - Fork 349
Module api convert of aria, asrc, and copier #10284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7ae2990
0c7a4b0
937d9e6
4abdf3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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> | ||
|
|
@@ -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; | ||
|
|
||
|
|
@@ -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; | ||
|
|
@@ -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; | ||
|
|
@@ -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; | ||
|
|
@@ -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; | ||
|
|
@@ -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 | ||
|
|
@@ -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); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -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; | ||
| } | ||
|
|
||
|
|
@@ -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", | ||
|
|
@@ -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); | ||
|
|
@@ -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, | ||
|
|
@@ -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) { | ||
|
|
@@ -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); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am unsure of the callback semantics. Does .prepare() failure trigger module unload? Can there be a successful .prepare() after a failed one? I was not sure so I wrote the code as it would be possible. edit: |
||
| cd->buf = NULL; | ||
|
|
||
| err: | ||
|
|
@@ -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; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add a comment here saying, that this is needed because of the
.reset()path