#ifndef STREAM_H #define STREAM_H #include #include #include #include #include #include "doubleBuffer.h" #include "chunk.h" #include "timeUtils.h" #include "queue.h" class Stream { public: Stream(); void addChunk(Chunk* chunk); void getPlayerChunk(short* outputBuffer, double outputBufferDacTime, unsigned long framesPerBuffer); void setBufferLen(size_t bufferLenMs); void setLatency(size_t latency); private: time_point_ms getNextPlayerChunk(short* outputBuffer, unsigned long framesPerBuffer, int correction = 0); void getSilentPlayerChunk(short* outputBuffer, unsigned long framesPerBuffer); void updateBuffers(int age); void resetBuffers(); long lastTick; float sleep; // int correction; Queue> chunks; DoubleBuffer* pCardBuffer; DoubleBuffer* pMiniBuffer; DoubleBuffer* pBuffer; DoubleBuffer* pShortBuffer; std::shared_ptr chunk; int median; int shortMedian; time_t lastUpdate; int bufferMs; int latencyMs; }; #endif