-
Notifications
You must be signed in to change notification settings - Fork 371
audio: use size_t for circular-buffer bytes counts #11208
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
base: main
Are you sure you want to change the base?
Changes from all commits
0972efe
4680f9e
279949f
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 |
|---|---|---|
|
|
@@ -57,16 +57,15 @@ LOG_MODULE_REGISTER(volume, CONFIG_SOF_LOG_LEVEL); | |
| * \param[in] frames Number of frames. | ||
| * \param[in,out] prev_sum Previous sum of channel samples. | ||
| */ | ||
| static uint32_t vol_zc_get_s16(struct cir_buf_source *source, const int channels, | ||
| uint32_t frames, int64_t *prev_sum) | ||
| static size_t vol_zc_get_s16(struct cir_buf_source *source, const unsigned int channels, | ||
| size_t frames, int64_t *prev_sum) | ||
| { | ||
| uint32_t curr_frames = frames; | ||
| size_t curr_frames = frames; | ||
| int32_t sum; | ||
| const int16_t *x = source->ptr; | ||
| int bytes; | ||
| int nmax; | ||
| int i, j, n; | ||
| int remaining_samples = frames * channels; | ||
| size_t bytes, nmax, i, n; | ||
| unsigned int j; | ||
| size_t remaining_samples = frames * channels; | ||
|
|
||
| /* Go to last channel */ | ||
| x = source_cir_buf_wrap(x + remaining_samples - 1, source->buf_start, source->buf_end); | ||
|
|
@@ -106,16 +105,15 @@ static uint32_t vol_zc_get_s16(struct cir_buf_source *source, const int channels | |
| * \param[in] frames Number of frames. | ||
| * \param[in,out] prev_sum Previous sum of channel samples. | ||
| */ | ||
| static uint32_t vol_zc_get_s24(struct cir_buf_source *source, const int channels, | ||
| uint32_t frames, int64_t *prev_sum) | ||
| static size_t vol_zc_get_s24(struct cir_buf_source *source, const unsigned int channels, | ||
| size_t frames, int64_t *prev_sum) | ||
| { | ||
| int64_t sum; | ||
| uint32_t curr_frames = frames; | ||
| size_t curr_frames = frames; | ||
| const int32_t *x = source->ptr; | ||
| int bytes; | ||
| int nmax; | ||
| int i, j, n; | ||
| int remaining_samples = frames * channels; | ||
| size_t bytes, nmax, i, n; | ||
| unsigned int j; | ||
| size_t remaining_samples = frames * channels; | ||
|
|
||
| /* Go to last channel */ | ||
| x = source_cir_buf_wrap(x + remaining_samples - 1, source->buf_start, source->buf_end); | ||
|
|
@@ -155,16 +153,15 @@ static uint32_t vol_zc_get_s24(struct cir_buf_source *source, const int channels | |
| * \param[in] frames Number of frames. | ||
| * \param[in,out] prev_sum Previous sum of channel samples. | ||
| */ | ||
| static uint32_t vol_zc_get_s32(struct cir_buf_source *source, const int channels, | ||
| uint32_t frames, int64_t *prev_sum) | ||
| static size_t vol_zc_get_s32(struct cir_buf_source *source, const unsigned int channels, | ||
| size_t frames, int64_t *prev_sum) | ||
| { | ||
| int64_t sum; | ||
| uint32_t curr_frames = frames; | ||
| size_t curr_frames = frames; | ||
| const int32_t *x = source->ptr; | ||
| int bytes; | ||
| int nmax; | ||
| int i, j, n; | ||
| int remaining_samples = frames * channels; | ||
| size_t bytes, nmax, i, n; | ||
| unsigned int j; | ||
| size_t remaining_samples = frames * channels; | ||
|
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. in general I like this change, it is very close to what types I'd also use for channel counters and byte numbers (perhaps not for frame / sample counts though). But we have many modules that follow a roughly the same pattern -
Collaborator
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. For frame and sample counts, I also prefer I agree it would be beneficial to establish a set of preferred types and gradually converge towards them. However, I don't think this is important enough to justify a project-wide conversion right now. Also, I'm not a fan of introducing dedicated typedefs such as |
||
|
|
||
| /* Go to last channel */ | ||
| x = source_cir_buf_wrap(x + remaining_samples - 1, source->buf_start, source->buf_end); | ||
|
|
@@ -564,12 +561,11 @@ static int volume_process(struct processing_module *mod, | |
| struct sof_sink *sink = sinks[0]; | ||
| struct cir_buf_source source_buf; | ||
| struct cir_buf_sink sink_buf; | ||
| const int nch = cd->channels; | ||
| const unsigned int nch = cd->channels; | ||
| size_t source_frame_bytes = source_get_frame_bytes(source); | ||
| size_t sink_frame_bytes = sink_get_frame_bytes(sink); | ||
| size_t source_bytes, sink_bytes, bytes; | ||
| uint32_t avail_frames; | ||
| uint32_t frames; | ||
| size_t avail_frames, frames; | ||
| int64_t prev_sum = 0; | ||
| int ret; | ||
|
|
||
|
|
||
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.
hm, would all modules now be expected to change
remaining_samplesin all their processing methods tosize_t? it would be a rather big changeThere 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.
Ultimately, I'd like all byte, sample, and frame counts to use
size_tfor consistency and some unsigned type for channels count. That said, I'm not planning a project-wide conversion right now.I'm only introducing these changes in modules that are already being touched, such as during sink/source API conversions, or when they naturally come up as part of other work (for example, when updating helper definitions). Over time, this should allow us to move towards a consistent use of
size_twithout requiring a large-scale refactoring effort.