renamed system_clock "hrc" to "clk"

This commit is contained in:
badaix 2016-10-03 13:58:46 +02:00
parent 42699bd4a5
commit d8ebc5e372
7 changed files with 26 additions and 26 deletions

View file

@ -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_)
chunk_ = chunks_.pop();
cs::time_point_hrc tp = chunk_->start();
cs::time_point_clk tp = chunk_->start();
memset(outputBuffer, 0, framesPerBuffer * format_.frameSize);
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)
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))
throw 0;
cs::time_point_hrc tp = chunk_->start();
cs::time_point_clk tp = chunk_->start();
char* buffer = (char*)outputBuffer;
unsigned long read = 0;
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)
return getNextPlayerChunk(outputBuffer, timeout, framesPerBuffer);
long toRead = framesPerBuffer + framesCorrection;
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_);
// if (abs(framesCorrection) > 1)

View file

@ -63,10 +63,10 @@ public:
bool waitForChunk(size_t ms) const;
private:
chronos::time_point_hrc 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_hrc getSilentPlayerChunk(void* outputBuffer, unsigned long framesPerBuffer);
chronos::time_point_hrc seek(long ms);
chronos::time_point_clk getNextPlayerChunk(void* outputBuffer, const chronos::usec& timeout, unsigned long framesPerBuffer);
chronos::time_point_clk getNextPlayerChunk(void* outputBuffer, const chronos::usec& timeout, unsigned long framesPerBuffer, long framesCorrection);
chronos::time_point_clk getSilentPlayerChunk(void* outputBuffer, unsigned long framesPerBuffer);
chronos::time_point_clk seek(long ms);
// time_point_ms seekTo(const time_point_ms& to);
void updateBuffers(int age);
void resetBuffers();

View file

@ -56,24 +56,24 @@ public:
*/
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());
}
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:

View file

@ -24,8 +24,8 @@
namespace chronos
{
typedef std::chrono::system_clock hrc;
typedef std::chrono::time_point<hrc> time_point_hrc;
typedef std::chrono::system_clock clk;
typedef std::chrono::time_point<clk> time_point_clk;
typedef std::chrono::seconds sec;
typedef std::chrono::milliseconds msec;
typedef std::chrono::microseconds usec;

View file

@ -44,16 +44,16 @@ public:
int readFrames(void* outputBuffer, size_t frameCount);
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::usec(timestamp.usec) +
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>();
}

View file

@ -67,9 +67,9 @@ public:
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;

View file

@ -207,7 +207,7 @@ void StreamSession::writer()
const msg::WireChunk* wireChunk = dynamic_cast<const msg::WireChunk*>(message.get());
if (wireChunk != NULL)
{
chronos::time_point_hrc now = chronos::hrc::now();
chronos::time_point_clk now = chronos::clk::now();
size_t age = 0;
if (now > wireChunk->start())
age = std::chrono::duration_cast<chronos::msec>(now - wireChunk->start()).count();