aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPaul Adenot <[email protected]>2020-09-08 14:15:16 +0200
committerPaul Adenot <[email protected]>2020-09-09 14:30:03 +0200
commitc6789286af294385f9a558259192d273e1d1980f (patch)
treef4700b53d3d2658abe95387ef6a7b88c131270a4
parentc7fe95cca45df46fcce87b47326e96934b213865 (diff)
downloadcubeb-c6789286af294385f9a558259192d273e1d1980f.tar.gz
cubeb-c6789286af294385f9a558259192d273e1d1980f.zip
Assert that the temporary stack buffer used to prefill the resampler are big enough
-rw-r--r--src/cubeb_resampler_internal.h14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/cubeb_resampler_internal.h b/src/cubeb_resampler_internal.h
index a81811b..c63bff3 100644
--- a/src/cubeb_resampler_internal.h
+++ b/src/cubeb_resampler_internal.h
@@ -193,15 +193,13 @@ public:
target_rate, quality, &r);
assert(r == RESAMPLER_ERR_SUCCESS && "resampler allocation failure");
- uint32_t ratio_num, ratio_den;
- speex_resampler_get_ratio(speex_resampler, &ratio_num, &ratio_den);
uint32_t input_latency = speex_resampler_get_input_latency(speex_resampler);
- int64_t skip_frac_num = input_latency * ratio_den;
- T input_buffer[8192] = {};
- T output_buffer[8192] = {};
- uint32_t input_frame_count, output_frame_count;
- input_frame_count = input_latency;
- output_frame_count = 8192;
+ const size_t LATENCY_SAMPLES = 8192;
+ T input_buffer[LATENCY_SAMPLES] = {};
+ T output_buffer[LATENCY_SAMPLES] = {};
+ uint32_t input_frame_count = input_latency;
+ uint32_t output_frame_count = LATENCY_SAMPLES;
+ assert(input_latency * channels <= LATENCY_SAMPLES);
speex_resample(
input_buffer,
&input_frame_count,