diff --git a/lime/audio/openal/ALC.hx b/lime/audio/openal/ALC.hx index 16fe00b00..4db8bf195 100644 --- a/lime/audio/openal/ALC.hx +++ b/lime/audio/openal/ALC.hx @@ -46,9 +46,9 @@ class ALC { public static function createContext (device:ALDevice, attrlist:Array = null):ALContext { #if ((cpp || neko || nodejs) && lime_openal && !macro) - var handle:Float = lime_alc_create_context (device, attrlist); + var handle = lime_alc_create_context (device, attrlist); - if (handle != 0) { + if (handle != null) { return new ALContext (handle); @@ -72,9 +72,9 @@ class ALC { public static function getContextsDevice (context:ALContext):ALDevice { #if ((cpp || neko || nodejs) && lime_openal && !macro) - var handle:Float = lime_alc_get_contexts_device (context); + var handle = lime_alc_get_contexts_device (context); - if (handle != 0) { + if (handle != null) { return new ALDevice (handle); @@ -89,9 +89,9 @@ class ALC { public static function getCurrentContext ():ALContext { #if ((cpp || neko || nodejs) && lime_openal && !macro) - var handle:Float = lime_alc_get_current_context (); + var handle = lime_alc_get_current_context (); - if (handle != 0) { + if (handle != null) { return new ALContext (handle); @@ -166,9 +166,9 @@ class ALC { public static function openDevice (deviceName:String = null):ALDevice { #if ((cpp || neko || nodejs) && lime_openal && !macro) - var handle:Float = lime_alc_open_device (deviceName); + var handle = lime_alc_open_device (deviceName); - if (handle != 0) { + if (handle != null) { return new ALDevice (handle); diff --git a/project/src/audio/openal/OpenALBindings.cpp b/project/src/audio/openal/OpenALBindings.cpp index c7cf5a0e0..0a7e34ceb 100644 --- a/project/src/audio/openal/OpenALBindings.cpp +++ b/project/src/audio/openal/OpenALBindings.cpp @@ -891,7 +891,15 @@ namespace lime { ALCcontext* alcContext = alcCreateContext (alcDevice, list); - return cffi::alloc_pointer (alcContext); + if (alcContext) { + + return cffi::alloc_pointer (alcContext); + + } else { + + return alloc_null (); + + } } @@ -908,7 +916,16 @@ namespace lime { ALCcontext* alcContext = (ALCcontext*)val_data (context); ALCdevice* alcDevice = alcGetContextsDevice (alcContext); - return cffi::alloc_pointer (alcDevice); + + if (alcDevice) { + + return cffi::alloc_pointer (alcDevice); + + } else { + + return alloc_null (); + + } } @@ -916,7 +933,16 @@ namespace lime { value lime_alc_get_current_context () { ALCcontext* alcContext = alcGetCurrentContext (); - return cffi::alloc_pointer (alcContext); + + if (alcContext) { + + return cffi::alloc_pointer (alcContext); + + } else { + + return alloc_null (); + + } } @@ -971,7 +997,16 @@ namespace lime { ALCdevice* alcDevice = alcOpenDevice (devicename.__s); atexit (lime_al_cleanup); - return cffi::alloc_pointer (alcDevice); + + if (alcDevice) { + + return cffi::alloc_pointer (alcDevice); + + } else { + + return alloc_null (); + + } }