Class AudioSink

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class AudioSink extends AudioBaseSink

This is the most simple base class for audio sinks that only requires subclasses to implement a set of simple functions:

  • open() :Open the device.

  • prepare() :Configure the device with the specified format.

  • write() :Write samples to the device.

  • reset() :Unblock writes and flush the device.

  • delay() :Get the number of samples written but not yet played by the device.

  • unprepare() :Undo operations done by prepare.

  • close() :Close the device.

All scheduling of samples and timestamps is done in this base class together with GstAudioBaseSink using a default implementation of a GstAudioRingBuffer that uses threads.

  • Constructor Details

    • AudioSink

      public AudioSink(MemorySegment address)
      Create a AudioSink instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • AudioSink

      public AudioSink()
      Create a new AudioSink.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the AudioSink class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected AudioSink asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class AudioBaseSink
      Returns:
      the instance as if it were its parent type
    • close

      protected boolean close()
      Close the device.
    • delay

      protected int delay()
      Return how many frames are still in the device. Participates in computing the time for audio clocks and drives the synchronisation.
    • open

      protected boolean open()
      Open the device. No configuration needs to be done at this point. This function is also used to check if the device is available.
    • pause

      protected void pause()
      Pause the device and unblock write as fast as possible. For retro compatibility, the audio sink will fallback to calling reset if this vmethod is not provided. Since: 1.18
    • prepare

      protected boolean prepare(AudioRingBufferSpec spec)
      Prepare the device to operate with the specified parameters.
    • reset

      protected void reset()
      Returns as quickly as possible from a write and flush any pending samples from the device. This vmethod is deprecated. Please provide pause and stop instead.
    • resume

      protected void resume()
      Resume the device. Since: 1.18
    • unprepare

      protected boolean unprepare()
      Undo operations done in prepare.
    • write

      protected int write(@Nullable byte @Nullable [] data)
      Write samples to the device.
      Parameters:
      data - the sample data
    • builder

      public static AudioSink.Builder<? extends AudioSink.Builder> builder()
      A AudioSink.Builder object constructs a AudioSink with the specified properties. Use the various set...() methods to set properties, and finish construction with AudioSink.Builder.build().
      Returns:
      the builder object