Class Library

java.lang.Object
com.mojang.blaze3d.audio.Library

public class Library extends Object
  • Field Details

    • LOGGER

      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

      @Nullable private String defaultDeviceName
    • EMPTY

      private static final Library.ChannelPool EMPTY
    • staticChannels

      private Library.ChannelPool staticChannels
    • streamingChannels

      private Library.ChannelPool streamingChannels
    • listener

      private final Listener listener
  • Constructor Details

    • Library

      public Library()
  • Method Details

    • init

      public void init(@Nullable String pDeviceSpecifier, boolean pEnableHrtf)
      Initializes the OpenAL device and context.
      Parameters:
      pDeviceSpecifier - A string specifying the name of the audio device to use , or null to use the default device.
      pEnableHrtf - Whether to enable HRTF (head-related transfer function) for spatial audio.
      Throws:
      IllegalStateException - if an error occurs during initialization.
    • setHrtf

      private void setHrtf(boolean pEnableHrtf)
      Sets the HRTF (head-related transfer function) for spatial audio, if it is supported by the current device.
      Parameters:
      pEnableHrtf - Whether to enable HRTF.
    • getChannelCount

      private int getChannelCount()
    • getDefaultDeviceName

      @Nullable public static String getDefaultDeviceName()
    • getCurrentDeviceName

      public String getCurrentDeviceName()
    • hasDefaultDeviceChanged

      public boolean hasDefaultDeviceChanged()
    • openDeviceOrFallback

      private static long openDeviceOrFallback(@Nullable String pDeviceSpecifier)
      Opens the specified audio device, or the default device if the specifier is null.
      Parameters:
      pDeviceSpecifier - 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

      private static OptionalLong tryOpenDevice(@Nullable String pDeviceSpecifier)
      Attempts to open the specified audio device.
      Parameters:
      pDeviceSpecifier - 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

      public Listener getListener()
    • acquireChannel

      @Nullable public Channel acquireChannel(Library.Pool pPool)
      Acquires a sound channel based on the given mode.
    • releaseChannel

      public void releaseChannel(Channel pChannel)
      Releases a channel.
      Parameters:
      pChannel - The channel to release.
    • getDebugString

      public String getDebugString()
    • getAvailableSoundDevices

      public List<String> getAvailableSoundDevices()
    • isCurrentDeviceDisconnected

      public boolean isCurrentDeviceDisconnected()