Fix for possible overflow in the resampler (can prevent some audio clicks)

Comment fixes
This commit is contained in:
Henrik Rydgård 2024-07-26 11:31:46 +02:00
parent 645272c82d
commit c3f291e9fe
3 changed files with 23 additions and 2 deletions

View File

@ -165,7 +165,13 @@ void StereoResampler::Clear() {
}
inline int16_t MixSingleSample(int16_t s1, int16_t s2, uint16_t frac) {
return s1 + (((s2 - s1) * frac) >> 16);
int32_t value = s1 + (((s2 - s1) * frac) >> 16);
if (value < -32767)
return -32767;
else if (value > 32767)
return 32767;
else
return (int16_t)value;
}
// Executed from sound stream thread, pulling sound out of the buffer.

View File

@ -194,7 +194,8 @@ public:
// Register-allocated JIT Temps don't get flushed so we don't reserve space for them.
// However, the IR interpreter needs some temps that can stick around between ops.
// Can be indexed through r[] using indices 192+.
// Can be indexed through r[] using indices 192+, thanks to predictable struct layout.
// Unfortunately, UBSAN isn't too happy about these.
u32 t[16]; //192
// If vfpuCtrl (prefixes) get mysterious values, check the VFPU regcache code.

View File

@ -25,3 +25,17 @@ Running with valgrind
Here's an example where we both use suppressions, and generate new ones (that you can then take from suppressions.log and simplify and copy to valgrind-wsl2.supp):
> valgrind --suppressions=SDL/valgrind-wsl2.supp --gen-suppressions=all --log-file=suppressions.log build/PPSSPPSDL
Running with ASAN
=================
./b.sh --sanitize
build/PPSSPPSDL.app/Contents/MacOS/PPSSPPSDL
Running with UBSAN
==================
./b.sh --sanitize --sanitizeub
UBSAN_OPTIONS=print_stacktrack=true build/PPSSPPSDL.app/Contents/MacOS/PPSSPPSDL