Skip to content

Commit 6409230

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 f425004 commit 6409230

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

src/audio/igo_nr/igo_nr.c

Lines changed: 18 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,14 @@ 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, &x, &x_start, &x_size);
98100
if (ret)
99101
return ret;
100102

101-
ret = sink_get_buffer(sink, request_size, (void **)&y1, (void **)&y_start, &y_size);
103+
ret = sink_get_buffer_s16(sink, request_size, &y1, &y_start, &y_size);
102104
if (ret) {
103105
source_release_data(source, 0);
104106
return ret;
@@ -174,7 +176,7 @@ static int igo_nr_capture_s24(struct comp_data *cd,
174176
{
175177
int32_t *x, *y1, *y2;
176178
int32_t *x_start, *y_start, *x_end, *y_end;
177-
size_t x_size, y_size;
179+
int x_size, y_size;
178180
size_t request_size = frames * source_get_frame_bytes(source);
179181
int sink_samples_without_wrap;
180182
int samples_without_wrap;
@@ -195,12 +197,14 @@ static int igo_nr_capture_s24(struct comp_data *cd,
195197

196198
#endif
197199

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

203-
ret = sink_get_buffer(sink, request_size, (void **)&y1, (void **)&y_start, &y_size);
207+
ret = sink_get_buffer_s32(sink, request_size, &y1, &y_start, &y_size);
204208
if (ret) {
205209
source_release_data(source, 0);
206210
return ret;
@@ -275,7 +279,7 @@ static int igo_nr_capture_s32(struct comp_data *cd,
275279
{
276280
int32_t *x, *y1, *y2;
277281
int32_t *x_start, *y_start, *x_end, *y_end;
278-
size_t x_size, y_size;
282+
int x_size, y_size;
279283
size_t request_size = frames * source_get_frame_bytes(source);
280284
int sink_samples_without_wrap;
281285
int samples_without_wrap;
@@ -296,12 +300,14 @@ static int igo_nr_capture_s32(struct comp_data *cd,
296300

297301
#endif
298302

299-
ret = source_get_data(source, request_size, (void const **)&x,
300-
(void const **)&x_start, &x_size);
303+
/* use the sample-count source/sink accessors so the returned sizes are
304+
* already in samples and need no byte-to-element conversion
305+
*/
306+
ret = source_get_data_s32(source, request_size, &x, &x_start, &x_size);
301307
if (ret)
302308
return ret;
303309

304-
ret = sink_get_buffer(sink, request_size, (void **)&y1, (void **)&y_start, &y_size);
310+
ret = sink_get_buffer_s32(sink, request_size, &y1, &y_start, &y_size);
305311
if (ret) {
306312
source_release_data(source, 0);
307313
return ret;

0 commit comments

Comments
 (0)