OpenAL fix

This commit is contained in:
Joshua Granick
2015-09-23 08:17:44 -07:00
parent 88023ffcea
commit fea74fabce
2 changed files with 47 additions and 12 deletions

View File

@@ -46,9 +46,9 @@ class ALC {
public static function createContext (device:ALDevice, attrlist:Array<Int> = null):ALContext { public static function createContext (device:ALDevice, attrlist:Array<Int> = null):ALContext {
#if ((cpp || neko || nodejs) && lime_openal && !macro) #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); return new ALContext (handle);
@@ -72,9 +72,9 @@ class ALC {
public static function getContextsDevice (context:ALContext):ALDevice { public static function getContextsDevice (context:ALContext):ALDevice {
#if ((cpp || neko || nodejs) && lime_openal && !macro) #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); return new ALDevice (handle);
@@ -89,9 +89,9 @@ class ALC {
public static function getCurrentContext ():ALContext { public static function getCurrentContext ():ALContext {
#if ((cpp || neko || nodejs) && lime_openal && !macro) #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); return new ALContext (handle);
@@ -166,9 +166,9 @@ class ALC {
public static function openDevice (deviceName:String = null):ALDevice { public static function openDevice (deviceName:String = null):ALDevice {
#if ((cpp || neko || nodejs) && lime_openal && !macro) #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); return new ALDevice (handle);

View File

@@ -891,7 +891,15 @@ namespace lime {
ALCcontext* alcContext = alcCreateContext (alcDevice, list); 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); ALCcontext* alcContext = (ALCcontext*)val_data (context);
ALCdevice* alcDevice = alcGetContextsDevice (alcContext); 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 () { value lime_alc_get_current_context () {
ALCcontext* alcContext = alcGetCurrentContext (); 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); ALCdevice* alcDevice = alcOpenDevice (devicename.__s);
atexit (lime_al_cleanup); atexit (lime_al_cleanup);
return cffi::alloc_pointer (alcDevice);
if (alcDevice) {
return cffi::alloc_pointer (alcDevice);
} else {
return alloc_null ();
}
} }