mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
linux: fix issues if certain codepaths are hit while signal handlers are temporarily off.
This commit is contained in:
@@ -100,11 +100,6 @@ Audio::Audio()
|
||||
, poolThread(nullptr)
|
||||
, distanceModel(DISTANCE_INVERSE_CLAMPED)
|
||||
{
|
||||
#if defined(LOVE_LINUX)
|
||||
// Temporarly block signals, as the thread inherits this mask
|
||||
love::thread::disableSignals();
|
||||
#endif
|
||||
|
||||
// Before opening new device, check if recording
|
||||
// is requested.
|
||||
if (getRequestRecordingPermission())
|
||||
@@ -114,29 +109,32 @@ Audio::Audio()
|
||||
requestRecordingPermission();
|
||||
}
|
||||
|
||||
// Passing null for default device.
|
||||
device = alcOpenDevice(nullptr);
|
||||
{
|
||||
#if defined(LOVE_LINUX)
|
||||
// Temporarly block signals, as the thread inherits this mask
|
||||
love::thread::ScopedDisableSignals disableSignals;
|
||||
#endif
|
||||
|
||||
if (device == nullptr)
|
||||
throw love::Exception("Could not open device.");
|
||||
// Passing null for default device.
|
||||
device = alcOpenDevice(nullptr);
|
||||
|
||||
if (device == nullptr)
|
||||
throw love::Exception("Could not open device.");
|
||||
|
||||
#ifdef ALC_EXT_EFX
|
||||
ALint attribs[4] = { ALC_MAX_AUXILIARY_SENDS, MAX_SOURCE_EFFECTS, 0, 0 };
|
||||
ALint attribs[4] = { ALC_MAX_AUXILIARY_SENDS, MAX_SOURCE_EFFECTS, 0, 0 };
|
||||
#else
|
||||
ALint *attribs = nullptr;
|
||||
ALint *attribs = nullptr;
|
||||
#endif
|
||||
|
||||
context = alcCreateContext(device, attribs);
|
||||
context = alcCreateContext(device, attribs);
|
||||
|
||||
if (context == nullptr)
|
||||
throw love::Exception("Could not create context.");
|
||||
if (context == nullptr)
|
||||
throw love::Exception("Could not create context.");
|
||||
|
||||
if (!alcMakeContextCurrent(context) || alcGetError(device) != ALC_NO_ERROR)
|
||||
throw love::Exception("Could not make context current.");
|
||||
|
||||
#if defined(LOVE_LINUX)
|
||||
love::thread::reenableSignals();
|
||||
#endif
|
||||
if (!alcMakeContextCurrent(context) || alcGetError(device) != ALC_NO_ERROR)
|
||||
throw love::Exception("Could not make context current.");
|
||||
}
|
||||
|
||||
#ifdef ALC_EXT_EFX
|
||||
initializeEFX();
|
||||
|
||||
@@ -44,7 +44,7 @@ bool Thread::start()
|
||||
{
|
||||
#if defined(LOVE_LINUX)
|
||||
// Temporarly block signals, as the thread inherits this mask
|
||||
love::thread::disableSignals();
|
||||
love::thread::ScopedDisableSignals disableSignals;
|
||||
#endif
|
||||
|
||||
Lock l(mutex);
|
||||
@@ -55,9 +55,6 @@ bool Thread::start()
|
||||
thread = SDL_CreateThread(thread_runner, t->getThreadName(), this);
|
||||
running = (thread != nullptr);
|
||||
|
||||
#if defined(LOVE_LINUX)
|
||||
love::thread::reenableSignals();
|
||||
#endif
|
||||
return running;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,6 +132,12 @@ Thread *newThread(Threadable *t);
|
||||
#if defined(LOVE_LINUX)
|
||||
void disableSignals();
|
||||
void reenableSignals();
|
||||
|
||||
struct ScopedDisableSignals
|
||||
{
|
||||
ScopedDisableSignals() { disableSignals(); }
|
||||
~ScopedDisableSignals() { reenableSignals(); }
|
||||
};
|
||||
#endif
|
||||
|
||||
} // thread
|
||||
|
||||
Reference in New Issue
Block a user