Skip to content

Commit e062748

Browse files
committed
Implement ALC.getStringList()
1 parent e947771 commit e062748

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed

project/src/media/openal/OpenALBindings.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3398,6 +3398,72 @@ namespace lime {
33983398
}
33993399

34003400

3401+
value lime_alc_get_string_list (value device, int param) {
3402+
3403+
ALCdevice* alcDevice = (ALCdevice*)val_data (device);
3404+
const char* result = alcGetString (alcDevice, param);
3405+
3406+
if (!result || *result == '\0') {
3407+
3408+
return alloc_null ();
3409+
3410+
}
3411+
3412+
value list = alloc_array (0);
3413+
3414+
while (*result != '\0') {
3415+
3416+
val_array_push (list, alloc_string (result));
3417+
result += strlen (result) + 1;
3418+
3419+
}
3420+
3421+
return list;
3422+
3423+
}
3424+
3425+
3426+
HL_PRIM varray* HL_NAME(hl_alc_get_string_list) (HL_CFFIPointer* device, int param) {
3427+
3428+
ALCdevice* alcDevice = device ? (ALCdevice*)device->ptr : 0;
3429+
const char* result = alcGetString(alcDevice, param);
3430+
3431+
if (!result || *result == '\0') {
3432+
3433+
return 0;
3434+
3435+
}
3436+
3437+
int count = 0;
3438+
const char* temp = result;
3439+
while (*temp != '\0') {
3440+
3441+
count++;
3442+
temp += strlen (temp) + 1;
3443+
3444+
}
3445+
3446+
varray* list = hl_alloc_array (&hlt_bytes, count);
3447+
vbyte** listData = hl_aptr (list, vbyte*);
3448+
3449+
while (*result != '\0') {
3450+
3451+
int length = strlen (result) + 1;
3452+
char* _result = (char*)malloc (length);
3453+
strcpy (_result, result);
3454+
3455+
*listData = (vbyte*)_result;
3456+
listData++;
3457+
3458+
result += length;
3459+
3460+
}
3461+
3462+
return list;
3463+
3464+
}
3465+
3466+
34013467
bool lime_alc_make_context_current (value context) {
34023468

34033469
ALCcontext* alcContext = (ALCcontext*)val_data (context);
@@ -3622,6 +3688,7 @@ namespace lime {
36223688
DEFINE_PRIME1 (lime_alc_get_error);
36233689
DEFINE_PRIME3 (lime_alc_get_integerv);
36243690
DEFINE_PRIME2 (lime_alc_get_string);
3691+
DEFINE_PRIME2 (lime_alc_get_string_list);
36253692
DEFINE_PRIME1 (lime_alc_make_context_current);
36263693
DEFINE_PRIME1 (lime_alc_open_device);
36273694
DEFINE_PRIME1v (lime_alc_pause_device);
@@ -3746,6 +3813,7 @@ namespace lime {
37463813
DEFINE_HL_PRIM (_I32, hl_alc_get_error, _TCFFIPOINTER);
37473814
DEFINE_HL_PRIM (_ARR, hl_alc_get_integerv, _TCFFIPOINTER _I32 _I32);
37483815
DEFINE_HL_PRIM (_BYTES, hl_alc_get_string, _TCFFIPOINTER _I32);
3816+
DEFINE_HL_PRIM (_ARR, hl_alc_get_string_list, _TCFFIPOINTER _I32);
37493817
DEFINE_HL_PRIM (_BOOL, hl_alc_make_context_current, _TCFFIPOINTER);
37503818
DEFINE_HL_PRIM (_TCFFIPOINTER, hl_alc_open_device, _STRING);
37513819
DEFINE_HL_PRIM (_VOID, hl_alc_pause_device, _TCFFIPOINTER);

src/lime/_internal/backend/native/NativeCFFI.hx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,8 @@ class NativeCFFI
16831683

16841684
@:cffi private static function lime_alc_get_string(device:CFFIPointer, param:Int):Dynamic;
16851685

1686+
@:cffi private static function lime_alc_get_string_list(device:CFFIPointer, param:Int):Array<Dynamic>;
1687+
16861688
@:cffi private static function lime_alc_make_context_current(context:CFFIPointer):Bool;
16871689

16881690
@:cffi private static function lime_alc_open_device(devicename:String):CFFIPointer;
@@ -1853,6 +1855,7 @@ class NativeCFFI
18531855
private static var lime_alc_get_integerv = new cpp.Callable<cpp.Object->Int->Int->cpp.Object>(cpp.Prime._loadPrime("lime", "lime_alc_get_integerv",
18541856
"oiio", false));
18551857
private static var lime_alc_get_string = new cpp.Callable<cpp.Object->Int->cpp.Object>(cpp.Prime._loadPrime("lime", "lime_alc_get_string", "oio", false));
1858+
private static var lime_alc_get_string_list = new cpp.Callable<cpp.Object->Int->cpp.Object>(cpp.Prime._loadPrime("lime", "lime_alc_get_string_list", "oio", false));
18561859
private static var lime_alc_make_context_current = new cpp.Callable<cpp.Object->Bool>(cpp.Prime._loadPrime("lime", "lime_alc_make_context_current", "ob",
18571860
false));
18581861
private static var lime_alc_open_device = new cpp.Callable<String->cpp.Object>(cpp.Prime._loadPrime("lime", "lime_alc_open_device", "so", false));
@@ -1976,6 +1979,7 @@ class NativeCFFI
19761979
private static var lime_alc_get_error = CFFI.load("lime", "lime_alc_get_error", 1);
19771980
private static var lime_alc_get_integerv = CFFI.load("lime", "lime_alc_get_integerv", 3);
19781981
private static var lime_alc_get_string = CFFI.load("lime", "lime_alc_get_string", 2);
1982+
private static var lime_alc_get_string_list = CFFI.load("lime", "lime_alc_get_string_list", 2);
19791983
private static var lime_alc_make_context_current = CFFI.load("lime", "lime_alc_make_context_current", 1);
19801984
private static var lime_alc_open_device = CFFI.load("lime", "lime_alc_open_device", 1);
19811985
private static var lime_alc_pause_device = CFFI.load("lime", "lime_alc_pause_device", 1);
@@ -2320,6 +2324,11 @@ class NativeCFFI
23202324
return null;
23212325
}
23222326

2327+
@:hlNative("lime", "hl_alc_get_string_list") private static function lime_alc_get_string_list(device:CFFIPointer, param:Int):hl.NativeArray<hl.Bytes>
2328+
{
2329+
return null;
2330+
}
2331+
23232332
@:hlNative("lime", "hl_alc_make_context_current") private static function lime_alc_make_context_current(context:ALContext):Bool
23242333
{
23252334
return false;

src/lime/media/OpenALAudioContext.hx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ class OpenALAudioContext
413413
}
414414
}
415415

416+
public function getStringList(device:ALDevice, param:Int):Array<String>
417+
{
418+
return ALC.getStringList(device, param);
419+
}
420+
416421
public function isBuffer(buffer:ALBuffer):Bool
417422
{
418423
return AL.isBuffer(buffer);

src/lime/media/openal/ALC.hx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,31 @@ class ALC
152152
#end
153153
}
154154

155+
public static function getStringList(device:ALDevice, param:Int):Array<String>
156+
{
157+
#if (lime_cffi && lime_openal && !macro)
158+
if (param == DEVICE_SPECIFIER ||
159+
param == ALL_DEVICES_SPECIFIER)
160+
{
161+
var result = NativeCFFI.lime_alc_get_string_list(device, param);
162+
#if hl
163+
if (result == null) return [];
164+
var _result = [];
165+
for (i in 0...result.length)
166+
_result[i] = CFFI.stringValue(result[i]);
167+
return _result;
168+
#else
169+
return result;
170+
#end
171+
172+
}
173+
174+
return [getString(device, param)];
175+
#else
176+
return null;
177+
#end
178+
}
179+
155180
public static function makeContextCurrent(context:ALContext):Bool
156181
{
157182
#if (lime_cffi && lime_openal && !macro)

0 commit comments

Comments
 (0)