Skip to content

Commit

Permalink
OpenALBindings: Avoid deadlock when Sys.exit() is called
Browse files Browse the repository at this point in the history
This change eliminates the cleanup attempt of the current OpenAL context and associated system resources. A change in OpenAL 1.20.0 made it unlikely that we will be able to clean up things in this way moving forward. We should steer users toward using `lime.system.System.exit()` or petition a change in the haxe stdlib to allow us to hook into Sys.exit(). 

I am not 100% satisfied with this, so perhaps we will find another solution. In the end, I think the benefit of updating OpenAL supersedes any inconvenience here.

Closes #1803
  • Loading branch information
dimensionscape authored Oct 25, 2024
1 parent e24ab07 commit 6a40998
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions project/src/media/openal/OpenALBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ namespace lime {

}


/*This has been removed after updating to openal 1.20.0+ since the cleanup functions involved
* lead to deadlocking. See https://github.com/openfl/lime/issues/1803 for more info.
* Developers should use lime.system.System.exit() instead of Sys.exit() to clean up any system
* resources
*/
/*
void lime_al_atexit () {
ALCcontext* alcContext = alcGetCurrentContext ();
Expand All @@ -163,7 +168,7 @@ namespace lime {
}
}

*/

void lime_al_auxf (value aux, int param, float value) {

Expand Down Expand Up @@ -3412,7 +3417,8 @@ namespace lime {
value lime_alc_open_device (HxString devicename) {

ALCdevice* alcDevice = alcOpenDevice (devicename.__s);
atexit (lime_al_atexit);
//TODO: Can we work out our own cleanup for openal?
//atexit (lime_al_atexit);

value ptr = CFFIPointer (alcDevice, gc_alc_object);
alcObjects[alcDevice] = ptr;
Expand All @@ -3424,7 +3430,8 @@ namespace lime {
HL_PRIM HL_CFFIPointer* HL_NAME(hl_alc_open_device) (hl_vstring* devicename) {

ALCdevice* alcDevice = alcOpenDevice (devicename ? (char*)hl_to_utf8 ((const uchar*)devicename->bytes) : 0);
atexit (lime_al_atexit);
//TODO: Can we work out our own cleanup for openal?
//atexit (lime_al_atexit);

HL_CFFIPointer* ptr = HLCFFIPointer (alcDevice, (hl_finalizer)hl_gc_alc_object);
alcObjects[alcDevice] = ptr;
Expand Down

0 comments on commit 6a40998

Please sign in to comment.