All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.lwjgl.openal.ALUtil Maven / Gradle / Ivy

Go to download

A cross-platform 3D audio API appropriate for use with gaming applications and many other types of audio applications.

The newest version!
/*
 * Copyright LWJGL. All rights reserved.
 * License terms: https://www.lwjgl.org/license
 */
package org.lwjgl.openal;

import javax.annotation.*;
import java.nio.*;
import java.util.*;

import static org.lwjgl.openal.ALC10.*;
import static org.lwjgl.system.MemoryUtil.*;

/** OpenAL utilities. */
public final class ALUtil {

    private ALUtil() {
    }

    /**
     * Obtains string values from ALC. This is a custom implementation for those tokens that return a list of strings instead of a single string.
     *
     * @param deviceHandle the device to query
     * @param token        the information to query. One of:
{@link ALC11#ALC_ALL_DEVICES_SPECIFIER}, {@link ALC11#ALC_CAPTURE_DEVICE_SPECIFIER} */ @Nullable public static List getStringList(long deviceHandle, int token) { long __result = nalcGetString(deviceHandle, token); if (__result == NULL) { return null; } ByteBuffer buffer = memByteBuffer(__result, Integer.MAX_VALUE); List strings = new ArrayList<>(); int offset = 0; while (true) { if (buffer.get() == 0) { int limit = buffer.position() - 1; if (limit == offset) { // Previous char was also a \0 == end of list. break; } strings.add(memUTF8(buffer, limit - offset, offset)); offset = buffer.position(); } } return strings; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy