55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
///-------------------------------------------------------------------------------------------------
|
|
///
|
|
/// \file Utils.cpp
|
|
/// \brief Implementation of utils for LSL within OpenViBE
|
|
/// \author Thomas Prampart (INRIA).
|
|
/// \version 0.0.1.
|
|
/// \date Thu Apr 1 2021.
|
|
///
|
|
/// \copyright (C) 2021 INRIA
|
|
///
|
|
/// This program is free software: you can redistribute it and/or modify
|
|
/// it under the terms of the GNU Affero General Public License as published
|
|
/// by the Free Software Foundation, either version 3 of the License, or
|
|
/// (at your option) any later version.
|
|
///
|
|
/// This program is distributed in the hope that it will be useful,
|
|
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
/// GNU Affero General Public License for more details.
|
|
///
|
|
/// You should have received a copy of the GNU Affero General Public License
|
|
/// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
///-------------------------------------------------------------------------------------------------
|
|
|
|
#include <lsl_cpp.h>
|
|
|
|
#include <system/ovCTime.h>
|
|
#include <openvibe/CTime.hpp>
|
|
|
|
#include "Utils.hpp"
|
|
|
|
namespace OpenViBE {
|
|
namespace LabStreamLayer {
|
|
|
|
double getLSLRelativeTime(const CTime& time)
|
|
{
|
|
const CTime ovTimeNow(System::Time::zgetTime());
|
|
const double lslRelativeTime = lsl::local_clock();
|
|
|
|
double diffToCurrent;
|
|
if (time > ovTimeNow)
|
|
{
|
|
diffToCurrent = (time - ovTimeNow).toSeconds();
|
|
}
|
|
else
|
|
{
|
|
diffToCurrent = -(ovTimeNow - time).toSeconds();
|
|
}
|
|
|
|
return (lslRelativeTime + diffToCurrent);
|
|
}
|
|
|
|
} // namespace LabStreamLayer
|
|
} // namespace OpenViBE
|