|
YAACC - UPNP Client and Server
|
The timeline of one stream (issue #330, design "Timeline and chunks"): the PCM of a producer is cut into chunks of about 20 ms and each chunk is stamped with the stream clock, in microseconds of the server clock. More...

Classes | |
| class | Chunk |
| One chunk: the stamp and the PCM (a whole number of frames). | |
Public Member Functions | |
| Chunker (int sampleRate, int frameBytes) | |
| int | chunkFrames () |
| int | chunkBytes () |
| int | resyncs () |
| How often the clock was restarted because a chunk was late. | |
| void | reset () |
| The producer went: what was pending is dropped and the clock starts again with the next data. | |
| List< Chunk > | feed (byte[] data, int offset, int length, long nowMicros) |
Takes data that arrived at nowMicros (server clock). | |
| long | waitMicros (long nowMicros) |
| How long the reader waits before it takes the next data: until the chunk it has cut is over in real time (snapserver paces its reads like this, so that a producer that is ahead is slowed by TCP and the queue stays small). | |
Static Public Member Functions | |
| static boolean | isSilent (byte[] pcm) |
| True if the PCM is only zeros (snapserver calls such a chunk silent even with a threshold of 0). | |
Static Public Attributes | |
| static final int | CHUNK_MILLIS = 20 |
The chunk duration of snapserver's default (chunk_ms). | |
The timeline of one stream (issue #330, design "Timeline and chunks"): the PCM of a producer is cut into chunks of about 20 ms and each chunk is stamped with the stream clock, in microseconds of the server clock.
The clock starts with the first data after a start or a reset(); every chunk adds its exact duration (counted in frames, so that a duration that is not a whole number of microseconds does not drift). A chunk that is completed more than one chunk after its time restarts the clock from now, as snapserver does after a late read (a gap that the clients hear and then play on). Not thread safe: one reader thread.
A client plays a chunk at stamp + bufferMs - latency, so the stamp is the time at which the audio was produced, not the time at which it is to be heard.
| List< Chunk > de.yaacc.snapcast.server.Chunker.feed | ( | byte[] | data, |
| int | offset, | ||
| int | length, | ||
| long | nowMicros ) |
Takes data that arrived at nowMicros (server clock).
Referenced by de.yaacc.snapcast.server.StreamPipeline.write().
