mackron / dr_libs

Audio decoding libraries for C/C++, each in a single source file.
Other
1.24k stars 205 forks source link

dr_flac: Avoid illegal instruction on old systems. #240

Closed KrossX closed 2 years ago

KrossX commented 2 years ago

The code on drflac_has_sse41 seems to be copy pasted from drflac_has_sse2 and as such I think the detection has some problems.

#if defined(DRFLAC_X64)
            return DRFLAC_TRUE;    /* 64-bit targets always support SSE4.1. */

True for SSE2, not necessarily true for SSE4.1

 #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE4_1__)

_M_IX86_FP == 2 is true when using /arch:SSE2 with MSVC but also doesn't seem to define the SSEn macros, yet it does define AVX.

This code is untested, cuz I'm lazy as I've been using DRFLAC_NO_SSE41 as a workaround.

musicinmybrain commented 2 years ago

This looks right to me, and I’m applying it as a downstream patch in the Fedora Linux package.

mackron commented 2 years ago

You're totally right. Good catch! Merged into the dev branch. Will get this released soon.

kcgen commented 2 years ago

Will get this released soon.

Looking forward to the new release(s)! Thank you, @mackron.