Class EncoderChannelStreamLine
java.lang.Object
net.avadeaux.klipspringer.encoder.PlayerState
net.avadeaux.klipspringer.encoder.ChannelStreamLine
net.avadeaux.klipspringer.encoder.EncoderChannelStreamLine
- All Implemented Interfaces:
AutoCloseable,DataLine,Line,SourceDataLine
- Direct Known Subclasses:
FlacChannelStreamLine,LameChannelStreamLine
Abstract line that organizes audio channels in separate buffers.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceFactory interface for subclasses to provide the constructor with a way of producing an encoder handle.Nested classes/interfaces inherited from interface javax.sound.sampled.DataLine
DataLine.Info -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEncoderChannelStreamLine(WritableByteChannel bc, AudioFormat format, long writeAheadMillis, long timeoutMillis, int bufferSamples, EncoderChannelStreamLine.EncoderFactory efact) bc should not be non-blocking. -
Method Summary
Modifier and TypeMethodDescriptionintprotected intNumber of bytes received by the line but not yet sent to the channel.voidclose()Closes the line and the destination channel, without writing anything.voidfinish()Emits buffered data and any data buffered in encoder.protected abstract voidfinish(long handle) voidflush()Discards buffered data that has not yet been written to the channel.protected abstract voidfree(long handle) intprotected longNumber of samples known to have been sent to the client endpoint for playing.protected abstract longoutputSamples(long handle) protected voidWrites data buffered on the line to the channel.protected abstract voidwriteBuffer(long handle, int samples) Methods inherited from class net.avadeaux.klipspringer.encoder.ChannelStreamLine
addLineListener, drain, getControl, getControls, getFormat, getFramePosition, getLevel, getLineInfo, getLongFramePosition, getMicrosecondPosition, isActive, isControlSupported, isRunning, open, open, open, removeLineListener, start, stopMethods inherited from class net.avadeaux.klipspringer.encoder.PlayerState
isOpen, onClose, playedMillis, playedMillis, waitForPlayedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.sound.sampled.SourceDataLine
write
-
Field Details
-
buf
-
-
Constructor Details
-
EncoderChannelStreamLine
public EncoderChannelStreamLine(WritableByteChannel bc, AudioFormat format, long writeAheadMillis, long timeoutMillis, int bufferSamples, EncoderChannelStreamLine.EncoderFactory efact) throws IOException, UnsupportedAudioFileException bc should not be non-blocking.
-
-
Method Details
-
bufferedSamples
protected int bufferedSamples()Description copied from class:ChannelStreamLineNumber of bytes received by the line but not yet sent to the channel.- Specified by:
bufferedSamplesin classChannelStreamLine
-
writeBuffer
Description copied from class:ChannelStreamLineWrites data buffered on the line to the channel.- Specified by:
writeBufferin classChannelStreamLine- Throws:
IOException
-
flush
public void flush()Discards buffered data that has not yet been written to the channel. -
finish
public void finish()Description copied from class:ChannelStreamLineEmits buffered data and any data buffered in encoder. Default implementation just callsdrain.- Overrides:
finishin classChannelStreamLine
-
close
public void close()Description copied from class:ChannelStreamLineCloses the line and the destination channel, without writing anything. In order for all data to be emitted,finishshould be called before close.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceLine- Overrides:
closein classChannelStreamLine
-
getBufferSize
public int getBufferSize() -
available
public int available() -
outputSamples
protected long outputSamples()Description copied from class:ChannelStreamLineNumber of samples known to have been sent to the client endpoint for playing. The default implementation returns the number of samples sent to the channel. Needs to be overridden if there is buffering/compression from this point that may cause a delay in the client playing. The number returned by this method may be slightly lower than the actual number output to the endpoint but must never be higher.- Overrides:
outputSamplesin classChannelStreamLine
-
writeBuffer
- Throws:
IOException
-
finish
- Throws:
IOException
-
free
protected abstract void free(long handle) -
outputSamples
protected abstract long outputSamples(long handle)
-