ivansafrin/Polycode — pull request #115 by dannywarren (2012-06-19 04:12:44+00:00)
Title: Fixed soundmanager crash on winxp, upgraded to openal-soft 1.14

* there is an issue with openal when statically compiled on some win32 platforms, in which the openal dll is unloaded before the public destruction methods can be called (this looks to be a flaw in the original openal spec)

* when this happens, openal crashes on application exit, as it tries to free memory that has already been freed during the dll unload and its own internal cleanup routines

* this always happens on winxp, sometimes on vista, and never on windows 7 (from a cursory google search)

* one workaround is to just not use any of the public destruction methods, and hope openal cleans itself up using its internal "atexit" cleanup routines (though this seems unwise)

* this was fixed in openal-soft 1.14, by making sure the handle to the dll stays open until the application fully exits when openal is statically compiled. see: http://repo.or.cz/w/openal-soft.git/commitdiff/1a4a0abd1a1fd9a20345db54efef6587bec67197

* now when you call the openal destruction methods from soundmanager (alcCloseDevice, etc) they actually kick off destruction instead of just silently failing or causing a crash (depending on the system)

* added check to soundmanager destruction method to make sure a context exists before trying to destroy it (in case openal init failed and we never created one)

* added call to set "alcMakeContextCurrent" to null before destroying the current context, as per openal spec