From 03f8528315fa46c95991a34f3325d7b33ae5538c Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Sat, 02 May 2020 21:48:36 +0000
Subject: [PATCH] Update source to SDL2 2.0.12
---
source/src/audio/SDL_audiocvt.c | 26 ++++++++++++++++++--------
1 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/source/src/audio/SDL_audiocvt.c b/source/src/audio/SDL_audiocvt.c
index ee0ba32..7c0dd42 100644
--- a/source/src/audio/SDL_audiocvt.c
+++ b/source/src/audio/SDL_audiocvt.c
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
- Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -677,7 +677,7 @@
}
if (!filter) {
- return SDL_SetError("No conversion from float to destination format available");
+ return SDL_SetError("No conversion from float to format 0x%.4x available", dst_fmt);
}
if (SDL_AddAudioCVTFilter(cvt, filter) < 0) {
@@ -718,9 +718,15 @@
/* !!! FIXME: remove this if we can get the resampler to work in-place again. */
float *dst = (float *) (cvt->buf + srclen);
const int dstlen = (cvt->len * cvt->len_mult) - srclen;
- const int paddingsamples = (ResamplerPadding(inrate, outrate) * chans);
+ const int requestedpadding = ResamplerPadding(inrate, outrate);
+ int paddingsamples;
float *padding;
+ if (requestedpadding < SDL_MAX_SINT32 / chans) {
+ paddingsamples = requestedpadding * chans;
+ } else {
+ paddingsamples = 0;
+ }
SDL_assert(format == AUDIO_F32SYS);
/* we keep no streaming state here, so pad with silence on both ends. */
@@ -889,10 +895,14 @@
return SDL_SetError("Invalid source channels");
} else if (!SDL_SupportedChannelCount(dst_channels)) {
return SDL_SetError("Invalid destination channels");
- } else if (src_rate == 0) {
- return SDL_SetError("Source rate is zero");
- } else if (dst_rate == 0) {
- return SDL_SetError("Destination rate is zero");
+ } else if (src_rate <= 0) {
+ return SDL_SetError("Source rate is equal to or less than zero");
+ } else if (dst_rate <= 0) {
+ return SDL_SetError("Destination rate is equal to or less than zero");
+ } else if (src_rate >= SDL_MAX_SINT32 / RESAMPLER_SAMPLES_PER_ZERO_CROSSING) {
+ return SDL_SetError("Source rate is too high");
+ } else if (dst_rate >= SDL_MAX_SINT32 / RESAMPLER_SAMPLES_PER_ZERO_CROSSING) {
+ return SDL_SetError("Destination rate is too high");
}
#if DEBUG_CONVERT
@@ -905,7 +915,7 @@
cvt->dst_format = dst_fmt;
cvt->needed = 0;
cvt->filter_index = 0;
- SDL_zero(cvt->filters);
+ SDL_zeroa(cvt->filters);
cvt->len_mult = 1;
cvt->len_ratio = 1.0;
cvt->rate_incr = ((double) dst_rate) / ((double) src_rate);
--
Gitblit v1.9.3