mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-28 13:58:48 +02:00
add clang-format file
reformat code
This commit is contained in:
parent
b733f646ea
commit
b20add3815
105 changed files with 7773 additions and 7723 deletions
|
@ -1,6 +1,6 @@
|
|||
/***
|
||||
This file is part of snapcast
|
||||
Copyright (C) 2014-2018 Johannes Pohl
|
||||
Copyright (C) 2014-2019 Johannes Pohl
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -19,11 +19,11 @@
|
|||
#ifndef TIME_PROVIDER_H
|
||||
#define TIME_PROVIDER_H
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include "common/timeDefs.h"
|
||||
#include "doubleBuffer.h"
|
||||
#include "message/message.h"
|
||||
#include "common/timeDefs.h"
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
|
||||
|
||||
/// Provides local and server time
|
||||
|
@ -35,57 +35,55 @@
|
|||
class TimeProvider
|
||||
{
|
||||
public:
|
||||
static TimeProvider& getInstance()
|
||||
{
|
||||
static TimeProvider instance;
|
||||
return instance;
|
||||
}
|
||||
static TimeProvider& getInstance()
|
||||
{
|
||||
static TimeProvider instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void setDiffToServer(double ms);
|
||||
void setDiff(const tv& c2s, const tv& s2c);
|
||||
void setDiffToServer(double ms);
|
||||
void setDiff(const tv& c2s, const tv& s2c);
|
||||
|
||||
template<typename T>
|
||||
inline T getDiffToServer() const
|
||||
{
|
||||
return std::chrono::duration_cast<T>(chronos::usec(diffToServer_));
|
||||
}
|
||||
template <typename T>
|
||||
inline T getDiffToServer() const
|
||||
{
|
||||
return std::chrono::duration_cast<T>(chronos::usec(diffToServer_));
|
||||
}
|
||||
|
||||
/* chronos::usec::rep getDiffToServer();
|
||||
chronos::usec::rep getPercentileDiffToServer(size_t percentile);
|
||||
long getDiffToServerMs();
|
||||
*/
|
||||
/* chronos::usec::rep getDiffToServer();
|
||||
chronos::usec::rep getPercentileDiffToServer(size_t percentile);
|
||||
long getDiffToServerMs();
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
static T sinceEpoche(const chronos::time_point_clk& point)
|
||||
{
|
||||
return std::chrono::duration_cast<T>(point.time_since_epoch());
|
||||
}
|
||||
template <typename T>
|
||||
static T sinceEpoche(const chronos::time_point_clk& point)
|
||||
{
|
||||
return std::chrono::duration_cast<T>(point.time_since_epoch());
|
||||
}
|
||||
|
||||
static chronos::time_point_clk toTimePoint(const tv& timeval)
|
||||
{
|
||||
return chronos::time_point_clk(chronos::usec(timeval.usec) + chronos::sec(timeval.sec));
|
||||
}
|
||||
static chronos::time_point_clk toTimePoint(const tv& timeval)
|
||||
{
|
||||
return chronos::time_point_clk(chronos::usec(timeval.usec) + chronos::sec(timeval.sec));
|
||||
}
|
||||
|
||||
inline static chronos::time_point_clk now()
|
||||
{
|
||||
return chronos::clk::now();
|
||||
}
|
||||
inline static chronos::time_point_clk now()
|
||||
{
|
||||
return chronos::clk::now();
|
||||
}
|
||||
|
||||
inline static chronos::time_point_clk serverNow()
|
||||
{
|
||||
return chronos::clk::now() + TimeProvider::getInstance().getDiffToServer<chronos::usec>();
|
||||
}
|
||||
inline static chronos::time_point_clk serverNow()
|
||||
{
|
||||
return chronos::clk::now() + TimeProvider::getInstance().getDiffToServer<chronos::usec>();
|
||||
}
|
||||
|
||||
private:
|
||||
TimeProvider();
|
||||
TimeProvider(TimeProvider const&); // Don't Implement
|
||||
void operator=(TimeProvider const&); // Don't implement
|
||||
TimeProvider();
|
||||
TimeProvider(TimeProvider const&); // Don't Implement
|
||||
void operator=(TimeProvider const&); // Don't implement
|
||||
|
||||
DoubleBuffer<chronos::usec::rep> diffBuffer_;
|
||||
std::atomic<chronos::usec::rep> diffToServer_;
|
||||
DoubleBuffer<chronos::usec::rep> diffBuffer_;
|
||||
std::atomic<chronos::usec::rep> diffToServer_;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue