From 83900516b408acb495c27f79dbaa4e7cb773f7a2 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Tue, 3 Mar 2020 17:00:04 +0000 Subject: [PATCH] Fix timers nsec addition. Don't update barclocks if paused --- defines.h | 9 ++++++++ dvbsubtitles.cc | 23 +------------------- inputman.cc | 6 +++--- main.cc | 57 +++++++++++++++++++++++++++++++------------------ timers.cc | 8 ++----- vvideorec.cc | 22 +++++++++++++------ 6 files changed, 66 insertions(+), 59 deletions(-) diff --git a/defines.h b/defines.h index d6eed72..82dbbaf 100644 --- a/defines.h +++ b/defines.h @@ -31,11 +31,20 @@ typedef unsigned long long ULLONG; #define BENCHMARK_FPS + +// Global useful functions + //ULLONG htonll(ULLONG a); //ULLONG ntohll(ULLONG a); void MILLISLEEP(ULONG a); long long getTimeMS(); +#include +#include +#include +std::string tp2str(const std::chrono::time_point& tp); + + int getClockRealTime(struct timespec *tp); //#define WINDOWS_LEGACY diff --git a/dvbsubtitles.cc b/dvbsubtitles.cc index db440e9..4663d13 100644 --- a/dvbsubtitles.cc +++ b/dvbsubtitles.cc @@ -30,31 +30,10 @@ #ifdef DVBSDEBUG - -// DBG #include -#include -#include -#include - -std::string tp2str(const std::chrono::time_point& tp) -{ - auto tms = std::chrono::time_point_cast(tp); - std::chrono::milliseconds e = tms.time_since_epoch(); - long long c = e.count(); - time_t tt = c / 1000; - int ttm = c % 1000; - auto stm = std::localtime(&tt); - std::stringstream ss; - ss << std::put_time(stm, "%T") << "." << std::setfill('0') << std::setw(3) << ttm; - return ss.str(); -} - #endif - - - +#include "defines.h" #include "demuxer.h" #include "osdreceiver.h" #include "video.h" diff --git a/inputman.cc b/inputman.cc index 230df7f..5aab2f7 100644 --- a/inputman.cc +++ b/inputman.cc @@ -59,9 +59,9 @@ bool InputMan::init() i1 = inputLinux->init(); if (!i1) { delete inputLinux; inputLinux = NULL; } - inputCEC = new InputCEC(); - i2 = inputCEC->init(); - if (!i2) { delete inputCEC; inputCEC = NULL; } +// inputCEC = new InputCEC(); +// i2 = inputCEC->init(); +// if (!i2) { delete inputCEC; inputCEC = NULL; } #endif inputUDP = new InputUDP(); diff --git a/main.cc b/main.cc index 65975a2..c6f0c73 100644 --- a/main.cc +++ b/main.cc @@ -21,46 +21,47 @@ #include #include #include + +#include +#include +#include +#include + #ifndef WIN32 -#include -#include + #include + #include #endif -#include #include "defines.h" #ifdef HANDLE_VT_SWITCHING -#include -#include -#include + #include + #include #endif + #include "log.h" #include "timers.h" #include "vdr.h" #include "boxstack.h" #include "command.h" +#include "inputman.h" +#include "wol.h" +#include "vsleeptimer.h" #ifdef VOMP_PLATTFORM_NMT - -#include "lednmt.h" -#include "osddirectfb.h" -#include "audionmt.h" -#include "videonmt.h" - + #include "lednmt.h" + #include "osddirectfb.h" + #include "audionmt.h" + #include "videonmt.h" #endif #ifdef VOMP_PLATFORM_RASPBERRY - -#include "ledraspberry.h" -#include "osdopenvg.h" -#include "audioomx.h" -#include "videoomx.h" - + #include "ledraspberry.h" + #include "osdopenvg.h" + #include "audioomx.h" + #include "videoomx.h" #endif -#include "inputman.h" -#include "wol.h" -#include "vsleeptimer.h" #ifndef WIN32 // FIXME do we need any if WIN32 stuff in here? windows has own winmain file @@ -447,6 +448,7 @@ void shutdown(int code) delete sleeptimer; logger->log("Core", Log::NOTICE, "Sleeptimer module shut down"); } + #ifdef HANDLE_VT_SWITCHING ioctl(fdtty, VT_UNLOCKSWITCH, 1); close(fdtty); @@ -524,3 +526,16 @@ int max(int a, int b) if (a > b) return a; else return b; } + +std::string tp2str(const std::chrono::time_point& tp) +{ + auto tms = std::chrono::time_point_cast(tp); + std::chrono::milliseconds e = tms.time_since_epoch(); + long long c = e.count(); + time_t tt = c / 1000; + int ttm = c % 1000; + auto stm = std::localtime(&tt); + std::stringstream ss; + ss << std::put_time(stm, "%T") << "." << std::setfill('0') << std::setw(3) << ttm; + return ss.str(); +} diff --git a/timers.cc b/timers.cc index 7caed9b..09ffa51 100644 --- a/timers.cc +++ b/timers.cc @@ -95,18 +95,14 @@ bool Timers::setTimerD(TimerReceiver* client, int clientReference, long int requ { std::chrono::system_clock::time_point fireTime = std::chrono::system_clock::now(); fireTime += std::chrono::seconds(requestedSecs); - //fireTime += std::chrono::nanoseconds(requestedNSecs); - fireTime += std::chrono::duration_cast(std::chrono::nanoseconds(requestedNSecs)); - + fireTime += std::chrono::nanoseconds(requestedNSecs); return setTimerC(client, clientReference, fireTime); } bool Timers::setTimerT(TimerReceiver* client, int clientReference, long int requestedTime, long int requestedTimeNSecs) { std::chrono::system_clock::time_point fireTime = std::chrono::system_clock::from_time_t(requestedTime); - //fireTime += std::chrono::nanoseconds(requestedTimeNSecs); - fireTime += std::chrono::duration_cast(std::chrono::nanoseconds(requestedTimeNSecs)); - + fireTime += std::chrono::nanoseconds(requestedTimeNSecs); return setTimerC(client, clientReference, fireTime); } diff --git a/vvideorec.cc b/vvideorec.cc index bd080d3..2e406b8 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -840,16 +840,24 @@ void VVideoRec::doBar(int action_in) boxstack->update(this, &barRegion); - if (action_in != -1) { - timers->cancelTimer(this, 1); + if (action_in != -1) + { + timers->cancelTimer(this, 1); + if ((playerState == PlayerVideoRec::S_FFWD) || (playerState == PlayerVideoRec::S_FBWD)) + barScanHold = true; + else + barScanHold = false; - if ((playerState == PlayerVideoRec::S_FFWD) || (playerState == PlayerVideoRec::S_FBWD)) barScanHold = true; - else barScanHold = false; + if (!barGenHold && !barScanHold && !barVasHold) + timers->setTimerD(this, 1, 4); - if (!barGenHold && !barScanHold && !barVasHold) timers->setTimerD(this, 1, 4); + Log::getInstance()->log("VVideoRec", Log::DEBUG, "player state: %i", playerState); - timers->setTimerD(this, 2, 0, 200000000); + if ((playerState == PlayerVideoRec::S_PAUSE_P) || (playerState == PlayerVideoRec::S_PAUSE_I)) + timers->cancelTimer(this, 2); + else + timers->setTimerD(this, 2, 0, 200'000'000); } } @@ -873,7 +881,7 @@ void VVideoRec::timercall(int clientReference) #else doBar(-1); #endif - timers->setTimerD(this, 2, 0, 200000000); + timers->setTimerD(this, 2, 0, 200'000'000); break; } } -- 2.39.5