Skip to content

Commit 7f5aebc

Browse files
committed
igo_nr: compute circular buffer ends in samples not bytes
The processing buffers' end pointers were computed by adding a byte count to sample-typed pointers, placing the end past the real buffer and letting the wrap check pass too late. Convert the byte sizes to element counts when computing the ends. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 133784c commit 7f5aebc

1 file changed

Lines changed: 21 additions & 12 deletions

File tree

src/audio/igo_nr/igo_nr.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static int igo_nr_capture_s16(struct comp_data *cd,
7272
int16_t *x, *y1, *y2;
7373
int16_t *x_start, *y_start, *x_end, *y_end;
7474
int16_t sample;
75-
size_t x_size, y_size;
75+
int x_size, y_size;
7676
size_t request_size = frames * source_get_frame_bytes(source);
7777
int sink_samples_without_wrap;
7878
int samples_without_wrap;
@@ -93,12 +93,15 @@ static int igo_nr_capture_s16(struct comp_data *cd,
9393

9494
#endif
9595

96-
ret = source_get_data(source, request_size, (void const **)&x,
97-
(void const **)&x_start, &x_size);
96+
/* use the sample-count source/sink accessors so the returned sizes are
97+
* already in samples and need no byte-to-element conversion
98+
*/
99+
ret = source_get_data_s16(source, request_size, (int16_t const **)&x,
100+
(int16_t const **)&x_start, &x_size);
98101
if (ret)
99102
return ret;
100103

101-
ret = sink_get_buffer(sink, request_size, (void **)&y1, (void **)&y_start, &y_size);
104+
ret = sink_get_buffer_s16(sink, request_size, &y1, &y_start, &y_size);
102105
if (ret) {
103106
source_release_data(source, 0);
104107
return ret;
@@ -174,7 +177,7 @@ static int igo_nr_capture_s24(struct comp_data *cd,
174177
{
175178
int32_t *x, *y1, *y2;
176179
int32_t *x_start, *y_start, *x_end, *y_end;
177-
size_t x_size, y_size;
180+
int x_size, y_size;
178181
size_t request_size = frames * source_get_frame_bytes(source);
179182
int sink_samples_without_wrap;
180183
int samples_without_wrap;
@@ -195,12 +198,15 @@ static int igo_nr_capture_s24(struct comp_data *cd,
195198

196199
#endif
197200

198-
ret = source_get_data(source, request_size, (void const **)&x,
199-
(void const **)&x_start, &x_size);
201+
/* use the sample-count source/sink accessors so the returned sizes are
202+
* already in samples and need no byte-to-element conversion
203+
*/
204+
ret = source_get_data_s32(source, request_size, (int32_t const **)&x,
205+
(int32_t const **)&x_start, &x_size);
200206
if (ret)
201207
return ret;
202208

203-
ret = sink_get_buffer(sink, request_size, (void **)&y1, (void **)&y_start, &y_size);
209+
ret = sink_get_buffer_s32(sink, request_size, &y1, &y_start, &y_size);
204210
if (ret) {
205211
source_release_data(source, 0);
206212
return ret;
@@ -275,7 +281,7 @@ static int igo_nr_capture_s32(struct comp_data *cd,
275281
{
276282
int32_t *x, *y1, *y2;
277283
int32_t *x_start, *y_start, *x_end, *y_end;
278-
size_t x_size, y_size;
284+
int x_size, y_size;
279285
size_t request_size = frames * source_get_frame_bytes(source);
280286
int sink_samples_without_wrap;
281287
int samples_without_wrap;
@@ -296,12 +302,15 @@ static int igo_nr_capture_s32(struct comp_data *cd,
296302

297303
#endif
298304

299-
ret = source_get_data(source, request_size, (void const **)&x,
300-
(void const **)&x_start, &x_size);
305+
/* use the sample-count source/sink accessors so the returned sizes are
306+
* already in samples and need no byte-to-element conversion
307+
*/
308+
ret = source_get_data_s32(source, request_size, (int32_t const **)&x,
309+
(int32_t const **)&x_start, &x_size);
301310
if (ret)
302311
return ret;
303312

304-
ret = sink_get_buffer(sink, request_size, (void **)&y1, (void **)&y_start, &y_size);
313+
ret = sink_get_buffer_s32(sink, request_size, &y1, &y_start, &y_size);
305314
if (ret) {
306315
source_release_data(source, 0);
307316
return ret;

0 commit comments

Comments
 (0)