mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-21 13:06:15 +02:00
46 lines
830 B
C++
46 lines
830 B
C++
#ifndef STREAM_H
|
|
#define STREAM_H
|
|
|
|
|
|
#include <deque>
|
|
#include <mutex>
|
|
#include <condition_variable>
|
|
#include <vector>
|
|
#include "doubleBuffer.h"
|
|
#include "chunk.h"
|
|
|
|
|
|
class Stream
|
|
{
|
|
public:
|
|
Stream();
|
|
void addChunk(Chunk* chunk);
|
|
Chunk* getNextChunk();
|
|
timeval getNextPlayerChunk(short* outputBuffer, int correction = 0);
|
|
void getSilentPlayerChunk(short* outputBuffer);
|
|
void getChunk(short* outputBuffer, double outputBufferDacTime, unsigned long framesPerBuffer);
|
|
void setBufferLen(size_t bufferLenMs);
|
|
|
|
private:
|
|
void sleepMs(int ms);
|
|
|
|
int sleep;
|
|
std::deque<Chunk*> chunks;
|
|
std::mutex mtx;
|
|
std::mutex mutex;
|
|
std::unique_lock<std::mutex>* pLock;
|
|
std::condition_variable cv;
|
|
DoubleBuffer<int>* pBuffer;
|
|
DoubleBuffer<int>* pShortBuffer;
|
|
|
|
int median;
|
|
int shortMedian;
|
|
time_t lastUpdate;
|
|
int bufferMs;
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|