Class AbstractAudioFrameBuffer
- java.lang.Object
-
- com.sedmelluq.discord.lavaplayer.track.playback.AbstractAudioFrameBuffer
-
- All Implemented Interfaces:
AudioFrameBuffer,AudioFrameConsumer,AudioFrameProvider
- Direct Known Subclasses:
AllocatingAudioFrameBuffer,NonAllocatingAudioFrameBuffer
public abstract class AbstractAudioFrameBuffer extends java.lang.Object implements AudioFrameBuffer
Common parts of a frame buffer which are not likely to depend on the specific implementation.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanclearOnInsertprotected AudioDataFormatformatprotected booleanlockedprotected booleanreceivedFramesprotected java.lang.Objectsynchronizerprotected booleanterminatedprotected booleanterminateOnEmpty
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractAudioFrameBuffer(AudioDataFormat format)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanhasClearOnInsert()booleanhasReceivedFrames()voidlockBuffer()Lock the buffer so no more incoming frames are accepted.voidsetClearOnInsert()Signal that the next frame provided to the buffer will clear the frames before it.voidsetTerminateOnEmpty()Signal that no more input is expected and if the content frames have been consumed, emit a terminator frame.protected abstract voidsignalWaiters()voidwaitForTermination()Wait until another thread has consumed a terminator frame from this buffer-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.sedmelluq.discord.lavaplayer.track.playback.AudioFrameBuffer
clear, getFullCapacity, getLastInputTimecode, getRemainingCapacity
-
Methods inherited from interface com.sedmelluq.discord.lavaplayer.track.playback.AudioFrameConsumer
consume, rebuild
-
Methods inherited from interface com.sedmelluq.discord.lavaplayer.track.playback.AudioFrameProvider
provide, provide, provide, provide
-
-
-
-
Field Detail
-
format
protected final AudioDataFormat format
-
synchronizer
protected final java.lang.Object synchronizer
-
locked
protected volatile boolean locked
-
receivedFrames
protected volatile boolean receivedFrames
-
terminated
protected boolean terminated
-
terminateOnEmpty
protected boolean terminateOnEmpty
-
clearOnInsert
protected boolean clearOnInsert
-
-
Constructor Detail
-
AbstractAudioFrameBuffer
protected AbstractAudioFrameBuffer(AudioDataFormat format)
-
-
Method Detail
-
waitForTermination
public void waitForTermination() throws java.lang.InterruptedExceptionDescription copied from interface:AudioFrameBufferWait until another thread has consumed a terminator frame from this buffer- Specified by:
waitForTerminationin interfaceAudioFrameBuffer- Throws:
java.lang.InterruptedException- When interrupted externally (or for seek/stop).
-
setTerminateOnEmpty
public void setTerminateOnEmpty()
Description copied from interface:AudioFrameBufferSignal that no more input is expected and if the content frames have been consumed, emit a terminator frame.- Specified by:
setTerminateOnEmptyin interfaceAudioFrameBuffer
-
setClearOnInsert
public void setClearOnInsert()
Description copied from interface:AudioFrameBufferSignal that the next frame provided to the buffer will clear the frames before it. This is useful when the next data is not contiguous with the current frame buffer, but the remaining frames in the buffer should be used until the next data arrives to prevent a situation where the buffer cannot provide any frames for a while.- Specified by:
setClearOnInsertin interfaceAudioFrameBuffer
-
hasClearOnInsert
public boolean hasClearOnInsert()
- Specified by:
hasClearOnInsertin interfaceAudioFrameBuffer- Returns:
- Whether the next frame is set to clear the buffer.
-
lockBuffer
public void lockBuffer()
Description copied from interface:AudioFrameBufferLock the buffer so no more incoming frames are accepted.- Specified by:
lockBufferin interfaceAudioFrameBuffer
-
hasReceivedFrames
public boolean hasReceivedFrames()
- Specified by:
hasReceivedFramesin interfaceAudioFrameBuffer- Returns:
- True if this buffer has received any input frames.
-
signalWaiters
protected abstract void signalWaiters()
-
-