From 0957760c42cc04d9c295b649b039015186b25609 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 5 Mar 2016 23:29:57 +0100 Subject: Replace clock_gettime with std::chrono for EDI --- src/DabMultiplexer.cpp | 9 +++------ src/DabMultiplexer.h | 5 +++-- src/dabOutput/dabOutput.h | 2 +- src/dabOutput/dabOutputSimul.cpp | 3 ++- src/dabOutput/edi/TagItems.cpp | 8 +++++++- src/dabOutput/edi/TagItems.h | 10 +++------- 6 files changed, 19 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index e60feaa..8002fe1 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2015 + Copyright (C) 2016 Matthias P. Braendli, matthias.braendli@mpb.li */ /* @@ -30,7 +30,6 @@ #include "fig/FIG.h" using namespace std; -using namespace boost; static const unsigned char Padding_FIB[] = { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -216,9 +215,7 @@ void DabMultiplexer::prepare() gettimeofday(&mnsc_time, NULL); #if HAVE_OUTPUT_EDI - if (clock_gettime(CLOCK_REALTIME, &edi_time)) { - throw std::runtime_error("Setting eti_time with clock_gettime failed"); - } + edi_time = chrono::system_clock::now(); // Try to load offset once @@ -1788,7 +1785,7 @@ void DabMultiplexer::mux_frame(std::vector >& outputs MNSC_increment_time = true; // Immediately update edi time - edi_time.tv_sec++; + edi_time += chrono::seconds(1); } diff --git a/src/DabMultiplexer.h b/src/DabMultiplexer.h index 054addc..3e16141 100644 --- a/src/DabMultiplexer.h +++ b/src/DabMultiplexer.h @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2015 + Copyright (C) 2016 Matthias P. Braendli, matthias.braendli@mpb.li */ /* @@ -48,6 +48,7 @@ #include "ClockTAI.h" #include #include +#include #include #include #include @@ -101,7 +102,7 @@ class DabMultiplexer : public RemoteControllable { unsigned timestamp; bool MNSC_increment_time; struct timeval mnsc_time; - struct timespec edi_time; + std::chrono::system_clock::time_point edi_time; edi_configuration_t edi_conf; diff --git a/src/dabOutput/dabOutput.h b/src/dabOutput/dabOutput.h index 6756027..5f02f76 100644 --- a/src/dabOutput/dabOutput.h +++ b/src/dabOutput/dabOutput.h @@ -2,7 +2,7 @@ Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2013, 2014 Matthias P. Braendli + Copyright (C) 2016 Matthias P. Braendli http://mpb.li http://opendigitalradio.org diff --git a/src/dabOutput/dabOutputSimul.cpp b/src/dabOutput/dabOutputSimul.cpp index 04ce536..347b29c 100644 --- a/src/dabOutput/dabOutputSimul.cpp +++ b/src/dabOutput/dabOutputSimul.cpp @@ -2,7 +2,7 @@ Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2013 Matthias P. Braendli + Copyright (C) 2016 Matthias P. Braendli http://mpb.li SIMUL throttling output. It guarantees correct frame generation rate @@ -90,3 +90,4 @@ int DabOutputSimul::Write(void* buffer, int size) return size; } + diff --git a/src/dabOutput/edi/TagItems.cpp b/src/dabOutput/edi/TagItems.cpp index f3e8404..54e996b 100644 --- a/src/dabOutput/edi/TagItems.cpp +++ b/src/dabOutput/edi/TagItems.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013,2014 Matthias P. Braendli + Copyright (C) 2016 Matthias P. Braendli http://mpb.li EDI output. @@ -131,6 +131,12 @@ std::vector TagDETI::Assemble() return packet; } +void TagDETI::set_seconds(std::chrono::system_clock::time_point t) +{ + std::time_t posix_timestamp_1_jan_2000 = 946684800; + seconds = std::chrono::system_clock::to_time_t(t) - posix_timestamp_1_jan_2000; +} + std::vector TagESTn::Assemble() { diff --git a/src/dabOutput/edi/TagItems.h b/src/dabOutput/edi/TagItems.h index 50d5e99..6a8470b 100644 --- a/src/dabOutput/edi/TagItems.h +++ b/src/dabOutput/edi/TagItems.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013,2014 Matthias P. Braendli + Copyright (C) 2016 Matthias P. Braendli http://mpb.li EDI output. @@ -30,6 +30,7 @@ #include "config.h" #include "Eti.h" #include +#include #include #include @@ -98,12 +99,7 @@ class TagDETI : public TagItem */ uint32_t seconds; - void set_seconds(struct timespec tv) - { - time_t posix_timestamp_1_jan_2000 = 946684800; - seconds = tv.tv_sec - posix_timestamp_1_jan_2000; - } - + void set_seconds(std::chrono::system_clock::time_point t); /* TSTA: Shall be the 24 least significant bits of the Time Stamp * (TIST) field from the STI-D(LI) Frame. The full definition for the -- cgit v1.2.3