summaryrefslogtreecommitdiff
path: root/media/libcubeb/unresampled-frames.patch
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2019-11-03 14:14:26 -0500
committerMatt A. Tobin <email@mattatobin.com>2019-11-03 14:14:26 -0500
commit1960d6e08a949ceed50e6a18240d40a7ecee879c (patch)
tree580b06d4df15ff5f8a9c3f20468bf2160ac666e5 /media/libcubeb/unresampled-frames.patch
parent732fe36241032a1793e09209ccc06cb720225b9e (diff)
downloaduxp-1960d6e08a949ceed50e6a18240d40a7ecee879c.tar.gz
Revert "Issue #1267 - Part 1: Update libcubeb to a1200c34."
This reverts commit d162ecbaffe845c9707da5d2f6cab11f343ef00e.
Diffstat (limited to 'media/libcubeb/unresampled-frames.patch')
-rw-r--r--media/libcubeb/unresampled-frames.patch36
1 files changed, 36 insertions, 0 deletions
diff --git a/media/libcubeb/unresampled-frames.patch b/media/libcubeb/unresampled-frames.patch
new file mode 100644
index 0000000000..714f3d4bae
--- /dev/null
+++ b/media/libcubeb/unresampled-frames.patch
@@ -0,0 +1,36 @@
+From 46d12e9ae6fa9c233bc32812b13185ee7df8d3fd Mon Sep 17 00:00:00 2001
+From: Paul Adenot <paul@paul.cx>
+Date: Thu, 10 Nov 2016 06:20:16 +0100
+Subject: [PATCH] Prevent underflowing the number of input frames needed in
+ input when resampling. (#188)
+
+---
+ src/cubeb_resampler_internal.h | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/src/cubeb_resampler_internal.h b/src/cubeb_resampler_internal.h
+index e165cc2..3c37a04 100644
+--- a/src/cubeb_resampler_internal.h
++++ b/src/cubeb_resampler_internal.h
+@@ -263,9 +263,15 @@ public:
+ * number of output frames will be exactly equal. */
+ uint32_t input_needed_for_output(uint32_t output_frame_count)
+ {
+- return (uint32_t)ceilf((output_frame_count - samples_to_frames(resampling_out_buffer.length()))
+- * resampling_ratio);
+-
++ int32_t unresampled_frames_left = samples_to_frames(resampling_in_buffer.length());
++ int32_t resampled_frames_left = samples_to_frames(resampling_out_buffer.length());
++ float input_frames_needed =
++ (output_frame_count - unresampled_frames_left) * resampling_ratio
++ - resampled_frames_left;
++ if (input_frames_needed < 0) {
++ return 0;
++ }
++ return (uint32_t)ceilf(input_frames_needed);
+ }
+
+ /** Returns a pointer to the input buffer, that contains empty space for at
+--
+2.7.4
+