aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cubeb_resampler_internal.h
diff options
context:
space:
mode:
authorPaul Adenot <[email protected]>2020-08-04 15:32:17 +0200
committerPaul Adenot <[email protected]>2020-09-09 14:30:03 +0200
commit7b1782b3ea354ea3911b1e45f17380b70ab650f9 (patch)
tree693c290861a6c8369c9310618df5fa45cba6084c /src/cubeb_resampler_internal.h
parenta7b68885cb7e5206c62fc86909cd25f3d391c74d (diff)
downloadcubeb-7b1782b3ea354ea3911b1e45f17380b70ab650f9.tar.gz
cubeb-7b1782b3ea354ea3911b1e45f17380b70ab650f9.zip
Handle underrun without asserting when resampling an input stream in duplex mode
Diffstat (limited to 'src/cubeb_resampler_internal.h')
-rw-r--r--src/cubeb_resampler_internal.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cubeb_resampler_internal.h b/src/cubeb_resampler_internal.h
index e676428..4ccd9e3 100644
--- a/src/cubeb_resampler_internal.h
+++ b/src/cubeb_resampler_internal.h
@@ -270,7 +270,14 @@ public:
speex_resample(resampling_in_buffer.data(), &in_len,
resampling_out_buffer.data(), &out_len);
- assert(out_len == output_frame_count);
+ if (out_len < output_frame_count) {
+ LOGV("underrun during resampling: got %u frames, expected %u", out_len, output_frame_count);
+ // silence the rightmost part
+ T* data = resampling_out_buffer.data();
+ for (uint32_t i = frames_to_samples(out_len); i < frames_to_samples(output_frame_count); i++) {
+ data[i] = 0;
+ }
+ }
/* This shifts back any unresampled samples to the beginning of the input
buffer. */