Class Library
java.lang.Object
com.mojang.blaze3d.audio.Library
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfaceprivate static classstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate longprivate static final intprivate @Nullable Stringprivate static final Library.ChannelPoolprivate final Listenerprivate static final org.slf4j.Loggerprivate static final intprivate Library.ChannelPoolprivate Library.ChannelPoolprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable ChannelacquireChannel(Library.Pool pool) Acquires a sound channel based on the given mode.voidcleanup()private IntBuffercreateAttributes(org.lwjgl.system.MemoryStack stack, boolean enableHrtf) private intstatic @Nullable StringbooleanvoidInitializes the OpenAL device and context.booleanprivate static longopenDeviceOrFallback(@Nullable String preferredDevice) Opens the specified audio device, or the default device if the specifier is null.voidreleaseChannel(Channel channel) Releases a channel.private static OptionalLongtryOpenDevice(@Nullable String name) Attempts to open the specified audio device.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
NO_DEVICE
private static final int NO_DEVICE- See Also:
-
DEFAULT_CHANNEL_COUNT
private static final int DEFAULT_CHANNEL_COUNT- See Also:
-
currentDevice
private long currentDevice -
context
private long context -
supportsDisconnections
private boolean supportsDisconnections -
defaultDeviceName
-
EMPTY
-
staticChannels
-
streamingChannels
-
listener
-
-
Constructor Details
-
Library
public Library()
-
-
Method Details
-
init
Initializes the OpenAL device and context.- Parameters:
preferredDevice- A string specifying the name of the audio device to use, or null to use the default device.useHrtf- Whether to enable HRTF (head-related transfer function) for spatial audio.- Throws:
IllegalStateException- if an error occurs during initialization.
-
createAttributes
-
getChannelCount
private int getChannelCount() -
getDefaultDeviceName
-
getCurrentDeviceName
-
hasDefaultDeviceChanged
public boolean hasDefaultDeviceChanged() -
openDeviceOrFallback
Opens the specified audio device, or the default device if the specifier is null.- Parameters:
preferredDevice- The name of the audio device to open, or null to open the default device.- Returns:
- The handle of the opened device.
- Throws:
IllegalStateException- if the device cannot be opened.
-
tryOpenDevice
Attempts to open the specified audio device.- Parameters:
name- A string specifying the name of the audio device to open, or null to use the default device.- Returns:
- an OptionalLong containing the handle of the opened device if successful, or empty if the device could not be opened
-
cleanup
public void cleanup() -
getListener
-
acquireChannel
Acquires a sound channel based on the given mode. -
releaseChannel
Releases a channel.- Parameters:
channel- The channel to release.
-
getDebugString
-
getAvailableSoundDevices
-
isCurrentDeviceDisconnected
public boolean isCurrentDeviceDisconnected()
-