mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
Fix resampler->process overriding memory because we don't know exactly how much memory it needss
This commit is contained in:
parent
57e0e30600
commit
2481d25f0f
@ -195,8 +195,15 @@ static bool one_shot_resample(const float* in, size_t samples_in,
|
|||||||
if (!retro_resampler_realloc(&data, &resampler, NULL, ratio))
|
if (!retro_resampler_realloc(&data, &resampler, NULL, ratio))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Allocate on a 16-byte boundary, and pad to a multiple of 16 bytes */
|
/*
|
||||||
*samples_out = samples_in * ratio;
|
* Allocate on a 16-byte boundary, and pad to a multiple of 16 bytes. We
|
||||||
|
* add four more samples in the formula below just as safeguard, because
|
||||||
|
* resampler->process sometimes reports more output samples than the
|
||||||
|
* formula below calculates. Ideally, audio resamplers should have a
|
||||||
|
* function to return the number of samples they will output given a
|
||||||
|
* count of input samples.
|
||||||
|
*/
|
||||||
|
*samples_out = samples_in * ratio + 4;
|
||||||
*out = (float*)memalign_alloc(16,
|
*out = (float*)memalign_alloc(16,
|
||||||
((*samples_out + 15) & ~15) * sizeof(float));
|
((*samples_out + 15) & ~15) * sizeof(float));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user