Skip to content

Commit 09111f0

Browse files
authored
Fix n_samples_new > n_samples_step case
1 parent f54a439 commit 09111f0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/stream/stream.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,11 @@ int main(int argc, char ** argv) {
302302
}
303303
} else {
304304
// piped: need at least step_ms but try to get length_ms at first
305-
const auto n_bytes_min = (n_samples_step - n_samples_new) * sizeof(float);
305+
const auto n_bytes_min = std::max<long>(0, (n_samples_step - n_samples_new) * sizeof(float));
306306
auto n_bytes_wanted = n_samples_len * sizeof(float);
307307
pcmf32.resize(n_samples_len);
308308

309-
auto n_bytes_read = 0;
309+
long n_bytes_read = 0;
310310
while (n_bytes_wanted > 0) {
311311
char *p_buf = (char *)pcmf32.data();
312312
const auto n_read = read(fileno(stdin), p_buf + n_bytes_read, n_bytes_wanted);

0 commit comments

Comments
 (0)