Add exit cleanup for OpenAL, in case proper shutdown does not occur
This commit is contained in:
@@ -89,6 +89,28 @@ namespace lime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void lime_al_cleanup () {
|
||||||
|
|
||||||
|
ALCcontext* alcContext = alcGetCurrentContext ();
|
||||||
|
|
||||||
|
if (alcContext) {
|
||||||
|
|
||||||
|
ALCdevice* alcDevice = alcGetContextsDevice (alcContext);
|
||||||
|
|
||||||
|
alcMakeContextCurrent (0);
|
||||||
|
alcDestroyContext (alcContext);
|
||||||
|
|
||||||
|
if (alcDevice) {
|
||||||
|
|
||||||
|
alcCloseDevice (alcDevice);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
value lime_al_delete_buffer (value buffer) {
|
value lime_al_delete_buffer (value buffer) {
|
||||||
|
|
||||||
ALuint data = val_int (buffer);
|
ALuint data = val_int (buffer);
|
||||||
@@ -939,6 +961,7 @@ namespace lime {
|
|||||||
int* list = val_array_int (attrlist);
|
int* list = val_array_int (attrlist);
|
||||||
|
|
||||||
ALCcontext *alcContext = alcCreateContext (alcDevice, list);
|
ALCcontext *alcContext = alcCreateContext (alcDevice, list);
|
||||||
|
|
||||||
return alloc_float ((intptr_t)alcContext);
|
return alloc_float ((intptr_t)alcContext);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1029,6 +1052,9 @@ namespace lime {
|
|||||||
value lime_alc_open_device (value devicename) {
|
value lime_alc_open_device (value devicename) {
|
||||||
|
|
||||||
ALCdevice* alcDevice = alcOpenDevice (devicename == val_null ? 0 : val_string (devicename));
|
ALCdevice* alcDevice = alcOpenDevice (devicename == val_null ? 0 : val_string (devicename));
|
||||||
|
|
||||||
|
atexit (lime_al_cleanup);
|
||||||
|
|
||||||
return alloc_float ((intptr_t)alcDevice);
|
return alloc_float ((intptr_t)alcDevice);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user