mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
audio: Don't stack-allocate resampler padding.
(I thought padding size ranged from 5 frames to ~30 frames (based around RESAMPLER_ZERO_CROSSINGS, which is 5), but it's actually between 512 and several thousands (based on RESAMPLER_SAMPLES_PER_ZERO_CROSSING)). It gets big fast when downsampling.
This commit is contained in:
parent
b647bd0692
commit
42fff7ce2b
@ -722,16 +722,15 @@ SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format
|
|||||||
SDL_assert(format == AUDIO_F32SYS);
|
SDL_assert(format == AUDIO_F32SYS);
|
||||||
|
|
||||||
/* we keep no streaming state here, so pad with silence on both ends. */
|
/* we keep no streaming state here, so pad with silence on both ends. */
|
||||||
padding = SDL_stack_alloc(float, paddingsamples);
|
padding = (float *) SDL_calloc(paddingsamples, sizeof (float));
|
||||||
if (!padding) {
|
if (!padding) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SDL_memset(padding, '\0', paddingsamples * sizeof (float));
|
|
||||||
|
|
||||||
cvt->len_cvt = SDL_ResampleAudio(chans, inrate, outrate, padding, padding, src, srclen, dst, dstlen);
|
cvt->len_cvt = SDL_ResampleAudio(chans, inrate, outrate, padding, padding, src, srclen, dst, dstlen);
|
||||||
|
|
||||||
SDL_stack_free(padding);
|
SDL_free(padding);
|
||||||
|
|
||||||
SDL_memcpy(cvt->buf, dst, cvt->len_cvt); /* !!! FIXME: remove this if we can get the resampler to work in-place again. */
|
SDL_memcpy(cvt->buf, dst, cvt->len_cvt); /* !!! FIXME: remove this if we can get the resampler to work in-place again. */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user