Class FlacStream

All Implemented Interfaces:
Closeable, AutoCloseable, AudioStream, Device.Player, PcmWriter

public class FlacStream extends ExternalEncodedStream
Audio stream that sends FLAC encoded data to a channel. Also doubles as file encoder class when created via fileEncoder.
  • Field Details

    • BIT_LAYOUT

      public static final Device.BitLayout BIT_LAYOUT
      The bit layout for PCM data sent to a FLAC stream.
    • oggSupported

      public static final boolean oggSupported
      True if OGG FLAC is supported. This is set to false if libFLAC is subject to an issue that renders the number of samples in an encoding chunk unknown.
  • Constructor Details

    • FlacStream

      public FlacStream(PcmFormat format, boolean ogg, int comprLevel, int bufferFrames, double writeaheadSecs, double timeoutSecs, int holdingBytes, WritableByteChannel channel, Executor keepAlivePool, double keepAliveTimeoutSecs) throws IOException
      Creates a FLAC stream with the given specifications and destination channel.

      The holdingBytes parameter is used when streaming to recipient that does not begin to process the input until it has accumulated a certain amount of compressed data, causing the recipient to potentially stall when receiving highly compressible sound (such as silence). In particular, web browsers sometimes do this. When streaming to a web browser, a reasonable value to prevent stalling is 49152. When the destination is a file or something else that does not process audio in real time, it can be set to 0.

      If keepAliveExec is non-null, it is used by ExternalEncodedStream.close() to execute a wait loop that terminates when either the recipient has sent callback notification of having played (almost) all the data it has been sent, or no callback is made for keepAliveTimeoutSecs seconds. (See also ExternalEncodedStream.drain().)

      Throws:
      IOException
  • Method Details