Commit 8efa4937 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

winecoreaudio.drv: Ensure divide-by-zero SSE exceptions are masked before…

winecoreaudio.drv: Ensure divide-by-zero SSE exceptions are masked before calling AudioConverterNew. AudioConverterNew can trigger a divide-by-zero exception. Normally this is masked by the default SSE mask flags. However, iRacing disables this mask, leading to a crash when it tries to initialize a recording device. Signed-off-by: 's avatarAndrew Eikum <aeikum@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent d05edd03
......@@ -36,6 +36,7 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <fenv.h>
#include <unistd.h>
#include <libkern/OSAtomic.h>
......@@ -1233,6 +1234,8 @@ static HRESULT ca_setup_audiounit(EDataFlow dataflow, AudioComponentInstance uni
AudioStreamBasicDescription desc;
UInt32 size;
Float64 rate;
fenv_t fenv;
BOOL fenv_stored = TRUE;
hr = ca_get_audiodesc(&desc, fmt);
if(FAILED(hr))
......@@ -1262,7 +1265,17 @@ static HRESULT ca_setup_audiounit(EDataFlow dataflow, AudioComponentInstance uni
return osstatus_to_hresult(sc);
}
/* AudioConverterNew requires divide-by-zero SSE exceptions to be masked */
if(feholdexcept(&fenv)){
WARN("Failed to store fenv state\n");
fenv_stored = FALSE;
}
sc = AudioConverterNew(dev_desc, &desc, converter);
if(fenv_stored && fesetenv(&fenv))
WARN("Failed to restore fenv state\n");
if(sc != noErr){
WARN("Couldn't create audio converter: %x\n", (int)sc);
return osstatus_to_hresult(sc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment