mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-03 03:11:43 +02:00
renamed system_clock "hrc" to "clk"
This commit is contained in:
parent
42699bd4a5
commit
d8ebc5e372
7 changed files with 26 additions and 26 deletions
|
@ -94,11 +94,11 @@ bool Stream::waitForChunk(size_t ms) const
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cs::time_point_hrc Stream::getSilentPlayerChunk(void* outputBuffer, unsigned long framesPerBuffer)
|
cs::time_point_clk Stream::getSilentPlayerChunk(void* outputBuffer, unsigned long framesPerBuffer)
|
||||||
{
|
{
|
||||||
if (!chunk_)
|
if (!chunk_)
|
||||||
chunk_ = chunks_.pop();
|
chunk_ = chunks_.pop();
|
||||||
cs::time_point_hrc tp = chunk_->start();
|
cs::time_point_clk tp = chunk_->start();
|
||||||
memset(outputBuffer, 0, framesPerBuffer * format_.frameSize);
|
memset(outputBuffer, 0, framesPerBuffer * format_.frameSize);
|
||||||
return tp;
|
return tp;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ time_point_ms Stream::seekTo(const time_point_ms& to)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
time_point_hrc Stream::seek(long ms)
|
time_point_clk Stream::seek(long ms)
|
||||||
{
|
{
|
||||||
if (!chunk)
|
if (!chunk)
|
||||||
chunk_ = chunks_.pop();
|
chunk_ = chunks_.pop();
|
||||||
|
@ -142,12 +142,12 @@ time_point_hrc Stream::seek(long ms)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
cs::time_point_hrc Stream::getNextPlayerChunk(void* outputBuffer, const cs::usec& timeout, unsigned long framesPerBuffer)
|
cs::time_point_clk Stream::getNextPlayerChunk(void* outputBuffer, const cs::usec& timeout, unsigned long framesPerBuffer)
|
||||||
{
|
{
|
||||||
if (!chunk_ && !chunks_.try_pop(chunk_, timeout))
|
if (!chunk_ && !chunks_.try_pop(chunk_, timeout))
|
||||||
throw 0;
|
throw 0;
|
||||||
|
|
||||||
cs::time_point_hrc tp = chunk_->start();
|
cs::time_point_clk tp = chunk_->start();
|
||||||
char* buffer = (char*)outputBuffer;
|
char* buffer = (char*)outputBuffer;
|
||||||
unsigned long read = 0;
|
unsigned long read = 0;
|
||||||
while (read < framesPerBuffer)
|
while (read < framesPerBuffer)
|
||||||
|
@ -160,14 +160,14 @@ cs::time_point_hrc Stream::getNextPlayerChunk(void* outputBuffer, const cs::usec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cs::time_point_hrc Stream::getNextPlayerChunk(void* outputBuffer, const cs::usec& timeout, unsigned long framesPerBuffer, long framesCorrection)
|
cs::time_point_clk Stream::getNextPlayerChunk(void* outputBuffer, const cs::usec& timeout, unsigned long framesPerBuffer, long framesCorrection)
|
||||||
{
|
{
|
||||||
if (framesCorrection == 0)
|
if (framesCorrection == 0)
|
||||||
return getNextPlayerChunk(outputBuffer, timeout, framesPerBuffer);
|
return getNextPlayerChunk(outputBuffer, timeout, framesPerBuffer);
|
||||||
|
|
||||||
long toRead = framesPerBuffer + framesCorrection;
|
long toRead = framesPerBuffer + framesCorrection;
|
||||||
char* buffer = (char*)malloc(toRead * format_.frameSize);
|
char* buffer = (char*)malloc(toRead * format_.frameSize);
|
||||||
cs::time_point_hrc tp = getNextPlayerChunk(buffer, timeout, toRead);
|
cs::time_point_clk tp = getNextPlayerChunk(buffer, timeout, toRead);
|
||||||
|
|
||||||
float factor = (float)toRead / framesPerBuffer;//(float)(framesPerBuffer*channels_);
|
float factor = (float)toRead / framesPerBuffer;//(float)(framesPerBuffer*channels_);
|
||||||
// if (abs(framesCorrection) > 1)
|
// if (abs(framesCorrection) > 1)
|
||||||
|
|
|
@ -63,10 +63,10 @@ public:
|
||||||
bool waitForChunk(size_t ms) const;
|
bool waitForChunk(size_t ms) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
chronos::time_point_hrc getNextPlayerChunk(void* outputBuffer, const chronos::usec& timeout, unsigned long framesPerBuffer);
|
chronos::time_point_clk getNextPlayerChunk(void* outputBuffer, const chronos::usec& timeout, unsigned long framesPerBuffer);
|
||||||
chronos::time_point_hrc getNextPlayerChunk(void* outputBuffer, const chronos::usec& timeout, unsigned long framesPerBuffer, long framesCorrection);
|
chronos::time_point_clk getNextPlayerChunk(void* outputBuffer, const chronos::usec& timeout, unsigned long framesPerBuffer, long framesCorrection);
|
||||||
chronos::time_point_hrc getSilentPlayerChunk(void* outputBuffer, unsigned long framesPerBuffer);
|
chronos::time_point_clk getSilentPlayerChunk(void* outputBuffer, unsigned long framesPerBuffer);
|
||||||
chronos::time_point_hrc seek(long ms);
|
chronos::time_point_clk seek(long ms);
|
||||||
// time_point_ms seekTo(const time_point_ms& to);
|
// time_point_ms seekTo(const time_point_ms& to);
|
||||||
void updateBuffers(int age);
|
void updateBuffers(int age);
|
||||||
void resetBuffers();
|
void resetBuffers();
|
||||||
|
|
|
@ -56,24 +56,24 @@ public:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T sinceEpoche(const chronos::time_point_hrc& point)
|
static T sinceEpoche(const chronos::time_point_clk& point)
|
||||||
{
|
{
|
||||||
return std::chrono::duration_cast<T>(point.time_since_epoch());
|
return std::chrono::duration_cast<T>(point.time_since_epoch());
|
||||||
}
|
}
|
||||||
|
|
||||||
static chronos::time_point_hrc toTimePoint(const tv& timeval)
|
static chronos::time_point_clk toTimePoint(const tv& timeval)
|
||||||
{
|
{
|
||||||
return chronos::time_point_hrc(chronos::usec(timeval.usec) + chronos::sec(timeval.sec));
|
return chronos::time_point_clk(chronos::usec(timeval.usec) + chronos::sec(timeval.sec));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static chronos::time_point_hrc now()
|
inline static chronos::time_point_clk now()
|
||||||
{
|
{
|
||||||
return chronos::hrc::now();
|
return chronos::clk::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static chronos::time_point_hrc serverNow()
|
inline static chronos::time_point_clk serverNow()
|
||||||
{
|
{
|
||||||
return chronos::hrc::now() + TimeProvider::getInstance().getDiffToServer<chronos::usec>();
|
return chronos::clk::now() + TimeProvider::getInstance().getDiffToServer<chronos::usec>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
|
|
||||||
namespace chronos
|
namespace chronos
|
||||||
{
|
{
|
||||||
typedef std::chrono::system_clock hrc;
|
typedef std::chrono::system_clock clk;
|
||||||
typedef std::chrono::time_point<hrc> time_point_hrc;
|
typedef std::chrono::time_point<clk> time_point_clk;
|
||||||
typedef std::chrono::seconds sec;
|
typedef std::chrono::seconds sec;
|
||||||
typedef std::chrono::milliseconds msec;
|
typedef std::chrono::milliseconds msec;
|
||||||
typedef std::chrono::microseconds usec;
|
typedef std::chrono::microseconds usec;
|
||||||
|
|
|
@ -44,16 +44,16 @@ public:
|
||||||
int readFrames(void* outputBuffer, size_t frameCount);
|
int readFrames(void* outputBuffer, size_t frameCount);
|
||||||
int seek(int frames);
|
int seek(int frames);
|
||||||
|
|
||||||
virtual chronos::time_point_hrc start() const
|
virtual chronos::time_point_clk start() const
|
||||||
{
|
{
|
||||||
return chronos::time_point_hrc(
|
return chronos::time_point_clk(
|
||||||
chronos::sec(timestamp.sec) +
|
chronos::sec(timestamp.sec) +
|
||||||
chronos::usec(timestamp.usec) +
|
chronos::usec(timestamp.usec) +
|
||||||
chronos::usec((chronos::usec::rep)(1000000. * ((double)idx_ / (double)format.rate)))
|
chronos::usec((chronos::usec::rep)(1000000. * ((double)idx_ / (double)format.rate)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline chronos::time_point_hrc end() const
|
inline chronos::time_point_clk end() const
|
||||||
{
|
{
|
||||||
return start() + durationLeft<chronos::usec>();
|
return start() + durationLeft<chronos::usec>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,9 +67,9 @@ public:
|
||||||
return sizeof(tv) + sizeof(int32_t) + payloadSize;
|
return sizeof(tv) + sizeof(int32_t) + payloadSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual chronos::time_point_hrc start() const
|
virtual chronos::time_point_clk start() const
|
||||||
{
|
{
|
||||||
return chronos::time_point_hrc(chronos::sec(timestamp.sec) + chronos::usec(timestamp.usec));
|
return chronos::time_point_clk(chronos::sec(timestamp.sec) + chronos::usec(timestamp.usec));
|
||||||
}
|
}
|
||||||
|
|
||||||
tv timestamp;
|
tv timestamp;
|
||||||
|
|
|
@ -207,7 +207,7 @@ void StreamSession::writer()
|
||||||
const msg::WireChunk* wireChunk = dynamic_cast<const msg::WireChunk*>(message.get());
|
const msg::WireChunk* wireChunk = dynamic_cast<const msg::WireChunk*>(message.get());
|
||||||
if (wireChunk != NULL)
|
if (wireChunk != NULL)
|
||||||
{
|
{
|
||||||
chronos::time_point_hrc now = chronos::hrc::now();
|
chronos::time_point_clk now = chronos::clk::now();
|
||||||
size_t age = 0;
|
size_t age = 0;
|
||||||
if (now > wireChunk->start())
|
if (now > wireChunk->start())
|
||||||
age = std::chrono::duration_cast<chronos::msec>(now - wireChunk->start()).count();
|
age = std::chrono::duration_cast<chronos::msec>(now - wireChunk->start()).count();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue