From 90e9f058450cfb8bc2f06b02c60ba8cb533c2738 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 10 Sep 2025 12:03:24 +0200 Subject: Remove some old _WIN32 ifdefs, restructure includes --- src/DabMultiplexer.cpp | 1 + src/DabMux.cpp | 80 +++--------------------------------------------- src/DabMux.h | 45 --------------------------- src/Eti.cpp | 17 +++------- src/Eti.h | 18 ++--------- src/Interleaver.cpp | 5 --- src/ManagementServer.cpp | 11 +------ src/ManagementServer.h | 2 -- src/MuxElements.cpp | 9 +++++- src/MuxElements.h | 8 ++--- src/PcDebug.h | 62 ++++++++++++------------------------- src/fig/FIG0_6.h | 2 -- src/fig/FIG1.h | 13 +------- src/fig/FIG2.h | 14 +-------- src/input/File.cpp | 18 +++-------- src/mpeg.h | 15 ++------- 16 files changed, 54 insertions(+), 266 deletions(-) delete mode 100644 src/DabMux.h (limited to 'src') diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index bea82c2..c665f2c 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -31,6 +31,7 @@ #include "ManagementServer.h" #include "crc.h" #include "utils.h" +#include "Eti.h" using namespace std; diff --git a/src/DabMux.cpp b/src/DabMux.cpp index 4b9352f..0066629 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -29,83 +29,27 @@ # include "config.h" #endif -#include #include #include #include #include +#include +#include #include -#include -#include -#include #include +#include #include -#include -#include -#include #include #include -// for basename -#include - -#include #include -#include #include -#include -#include -#include - -#ifdef _WIN32 -# include -# include -# include -# include -# include // For types... -typedef u_char uint8_t; -typedef WORD uint16_t; -typedef DWORD32 uint32_t; - -# ifndef __MINGW32__ -# include "xgetopt.h" -# endif -# define read _read -# define snprintf _snprintf -# define sleep(a) Sleep((a) * 1000) -#else -# include -# include -# include -# include -# include -# include -# include -# include - -#endif - -#include - -#ifdef _WIN32 -# pragma warning ( disable : 4103 ) -# include "Eti.h" -# pragma warning ( default : 4103 ) -#else -# include "Eti.h" -#endif -#include "input/Prbs.h" -#include "input/Zmq.h" +#include "DabMultiplexer.h" #include "dabOutput/dabOutput.h" -#include "crc.h" -#include "Socket.h" -#include "PcDebug.h" -#include "DabMux.h" #include "MuxElements.h" #include "utils.h" -#include "ConfigParser.h" #include "ManagementServer.h" #include "Log.h" #include "RemoteControl.h" @@ -120,14 +64,10 @@ volatile sig_atomic_t running = 1; */ void signalHandler(int signum) { -#ifdef _WIN32 - fprintf(stderr, "\npid: %i\n", _getpid()); -#else fprintf(stderr, "\npid: %i, ppid: %i\n", getpid(), getppid()); -#endif + #define SIG_MSG "Signal received: " switch (signum) { -#ifndef _WIN32 case SIGHUP: fprintf(stderr, SIG_MSG "SIGHUP\n"); break; @@ -138,7 +78,6 @@ void signalHandler(int signum) fprintf(stderr, SIG_MSG "SIGPIPE\n"); return; break; -#endif case SIGINT: fprintf(stderr, SIG_MSG "SIGINT\n"); break; @@ -150,9 +89,7 @@ void signalHandler(int signum) default: fprintf(stderr, SIG_MSG "number %i\n", signum); } -#ifndef _WIN32 killpg(0, SIGPIPE); -#endif running = 0; } @@ -185,12 +122,6 @@ int main(int argc, char *argv[]) } } -#ifdef _WIN32 - if (SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) == 0) { - etiLog.log(warn, "Can't increase priority: %s\n", - strerror(errno)); - } -#else // Use the lowest real-time priority for this thread, and switch to real-time scheduling const int policy = SCHED_RR; sched_param sp; @@ -199,7 +130,6 @@ int main(int argc, char *argv[]) if (thread_prio_ret != 0) { etiLog.level(error) << "Could not set real-time priority for thread:" << thread_prio_ret; } -#endif int returnCode = 0; ptree pt; diff --git a/src/DabMux.h b/src/DabMux.h deleted file mode 100644 index 80b4881..0000000 --- a/src/DabMux.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, - 2011 Her Majesty the Queen in Right of Canada (Communications - Research Center Canada) - - Copyright (C) 2014 - Matthias P. Braendli, matthias.braendli@mpb.li - - This file declares several structures used in the multiplexer, - and defines default values for some parameters. - */ -/* - This file is part of ODR-DabMux. - - ODR-DabMux is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - ODR-DabMux 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with ODR-DabMux. If not, see . -*/ -#pragma once - -#include -#include -#include -#include "DabMultiplexer.h" -#include "RemoteControl.h" -#include "dabOutput/dabOutput.h" -#include "input/inputs.h" -#include "Eti.h" -#include "MuxElements.h" - -#ifdef _WIN32 -# include -#else -# include -#endif - diff --git a/src/Eti.cpp b/src/Eti.cpp index e1b51fb..2f26f2d 100644 --- a/src/Eti.cpp +++ b/src/Eti.cpp @@ -22,19 +22,10 @@ along with ODR-DabMux. If not, see . */ -#ifdef _WIN32 -# pragma warning ( disable : 4103 ) -# include "Eti.h" -# pragma warning ( default : 4103 ) -#else -# include "Eti.h" -# include -#endif - +#include "Eti.h" //definitions des structures des champs du ETI(NI, G703) - unsigned short eti_FC::getFrameLength() { return (unsigned short)((FL_high << 8) | FL_low); @@ -80,7 +71,7 @@ void eti_MNSC_TIME_1::setFromTime(struct tm *time_tm) { second_unit = time_tm->tm_sec % 10; second_tens = time_tm->tm_sec / 10; - + minute_unit = time_tm->tm_min % 10; minute_tens = time_tm->tm_min / 10; } @@ -89,7 +80,7 @@ void eti_MNSC_TIME_2::setFromTime(struct tm *time_tm) { hour_unit = time_tm->tm_hour % 10; hour_tens = time_tm->tm_hour / 10; - + day_unit = time_tm->tm_mday % 10; day_tens = time_tm->tm_mday / 10; } @@ -98,7 +89,7 @@ void eti_MNSC_TIME_3::setFromTime(struct tm *time_tm) { month_unit = (time_tm->tm_mon + 1) % 10; month_tens = (time_tm->tm_mon + 1) / 10; - + // They didn't see the y2k bug coming, did they ? year_unit = (time_tm->tm_year - 100) % 10; year_tens = (time_tm->tm_year - 100) / 10; diff --git a/src/Eti.h b/src/Eti.h index 88055c3..0d7aea5 100644 --- a/src/Eti.h +++ b/src/Eti.h @@ -29,24 +29,12 @@ # include #endif -#ifdef _WIN32 -# include // For types... -typedef WORD uint16_t; -typedef DWORD32 uint32_t; - -# define PACKED -# pragma pack(push, 1) -#else -# include -# include - -# define PACKED __attribute__ ((packed)) -#endif - +#include +#include +#define PACKED __attribute__ ((packed)) //definitions des structures des champs du ETI(NI, G703) - struct eti_SYNC { uint32_t ERR:8; uint32_t FSYNC:24; diff --git a/src/Interleaver.cpp b/src/Interleaver.cpp index cf0d235..1786d08 100644 --- a/src/Interleaver.cpp +++ b/src/Interleaver.cpp @@ -23,11 +23,6 @@ #include -#ifdef _WIN32 -# define bzero(a, b) memset((a), 0, (b)) -#endif // _WIN32 - - Interleaver::Interleaver(unsigned short I, unsigned short M, bool reverse) : I(I), M(M), diff --git a/src/ManagementServer.cpp b/src/ManagementServer.cpp index dff093a..2c25a7a 100644 --- a/src/ManagementServer.cpp +++ b/src/ManagementServer.cpp @@ -95,11 +95,6 @@ INPUT_COUNTER_RESET_TIME = std::chrono::minutes(30); static constexpr int INPUT_UNSTABLE_THRESHOLD = 3; -/* For how long the input buffers must be empty before we move an input to the - * NoData state. */ -static constexpr auto -INPUT_NODATA_TIMEOUT = std::chrono::seconds(30); - /* Keep 30s of min/max buffer fill information so that we can catch meaningful * values even if we have a slow poller */ static constexpr auto @@ -643,11 +638,7 @@ input_state_t InputStat::determineState() // STATE CALCULATION - /* If the buffer has been empty for more than - * INPUT_NODATA_TIMEOUT, we go to the NoData state. - * - * Consider an empty deque to be NoData too. - */ + /* Consider an empty deque to be NoData. */ if (std::all_of( m_buffer_fill_stats.begin(), m_buffer_fill_stats.end(), [](const fill_stat_t& fs) { return fs.bufsize == 0; }) ) { diff --git a/src/ManagementServer.h b/src/ManagementServer.h index c7a4222..d328f88 100644 --- a/src/ManagementServer.h +++ b/src/ManagementServer.h @@ -50,7 +50,6 @@ # include "config.h" #endif -#include "Socket.h" #include "zmq.hpp" #include #include @@ -65,7 +64,6 @@ #include #include -#include /*** State handing ***/ /* An input can be in one of the following three states: diff --git a/src/MuxElements.cpp b/src/MuxElements.cpp index d17b283..1f02a6d 100644 --- a/src/MuxElements.cpp +++ b/src/MuxElements.cpp @@ -743,7 +743,14 @@ const json::map_t dabEnsemble::get_all_values() const return map; } -bool dabEnsemble::validate_linkage_sets() +bool dabEnsemble::validate_linkage_sets() const +{ + return validate_linkage_sets(services, linkagesets); +} + +bool dabEnsemble::validate_linkage_sets( + const vec_sp_service& services, + std::vector > linkagesets) { for (const auto& ls : linkagesets) { const std::string keyserviceuid = ls->keyservice; diff --git a/src/MuxElements.h b/src/MuxElements.h index d118df9..0266671 100644 --- a/src/MuxElements.h +++ b/src/MuxElements.h @@ -33,16 +33,13 @@ #include #include #include -#include #include -#include #include #include #include #include "dabOutput/dabOutput.h" #include "input/inputs.h" #include "RemoteControl.h" -#include "Eti.h" // Protection levels and bitrates for UEP. const unsigned char ProtectionLevelTable[64] = { @@ -315,7 +312,10 @@ class dabEnsemble : public RemoteControllable { virtual const json::map_t get_all_values() const; /* Check if the Linkage Sets are valid */ - bool validate_linkage_sets(void); + bool validate_linkage_sets() const; + static bool validate_linkage_sets( + const vec_sp_service& services, + std::vector > linkagesets); /* all fields are public, since this was a struct before */ uint16_t id = 0; diff --git a/src/PcDebug.h b/src/PcDebug.h index d0b2b2c..68fceb8 100644 --- a/src/PcDebug.h +++ b/src/PcDebug.h @@ -19,8 +19,7 @@ along with ODR-DabMux. If not, see . */ -#ifndef PC_DEBUG_ -#define PC_DEBUG_ +#pragma once #ifdef HAVE_CONFIG_H # include "config.h" @@ -31,49 +30,28 @@ #include -#define LOG stderr +#define LOG stderr -#if !defined(_WIN32) || defined(__MINGW32__) -# ifndef PDEBUG -# ifdef DEBUG -# define PDEBUG(fmt, args...) fprintf (LOG, fmt , ## args) -# else -# define PDEBUG(fmt, args...) -# endif -# endif +#ifndef PDEBUG # ifdef DEBUG -# define PDEBUG_VERBOSE(level, verbosity, fmt, args...) if (level <= verbosity) { fprintf(LOG, fmt, ## args); fflush(LOG); } -# define PDEBUG0_VERBOSE(level, verbosity, txt) if (level <= verbosity) { fprintf(LOG, txt); fflush(LOG); } -# define PDEBUG1_VERBOSE(level, verbosity, txt, arg0) if (level <= verbosity) { fprintf(LOG, txt, arg0); fflush(LOG); } -# define PDEBUG2_VERBOSE(level, verbosity, txt, arg0, arg1) if (level <= verbosity) { fprintf(LOG, txt, arg0, arg1); fflush(LOG); } -# define PDEBUG3_VERBOSE(level, verbosity, txt, arg0, arg1, arg2) if (level <= verbosity) { fprintf(LOG, txt, arg0, arg1, arg2); fflush(LOG); } -# define PDEBUG4_VERBOSE(level, verbosity, txt, arg0, arg1, arg2, arg3) if (level <= verbosity) { fprintf(LOG, txt, arg0, arg1, arg2, arg3); fflush(LOG); } -# else -# define PDEBUG_VERBOSE(level, verbosity, fmt, args...) -# define PDEBUG0_VERBOSE(level, verbosity, txt) -# define PDEBUG1_VERBOSE(level, verbosity, txt, arg0) -# define PDEBUG2_VERBOSE(level, verbosity, txt, arg0, arg1) -# define PDEBUG3_VERBOSE(level, verbosity, txt, arg0, arg1, arg2) -# define PDEBUG4_VERBOSE(level, verbosity, txt, arg0, arg1, arg2, arg3) -# endif // DEBUG -#else // _WIN32 -# ifdef _DEBUG -# define PDEBUG -# define PDEBUG_VERBOSE -# define PDEBUG0_VERBOSE(level, verbosity, txt) if (level <= verbosity) { fprintf(LOG, txt); fflush(LOG); } -# define PDEBUG1_VERBOSE(level, verbosity, txt, arg0) if (level <= verbosity) { fprintf(LOG, txt, arg0); fflush(LOG); } -# define PDEBUG2_VERBOSE(level, verbosity, txt, arg0, arg1) if (level <= verbosity) { fprintf(LOG, txt, arg0, arg1); fflush(LOG); } -# define PDEBUG3_VERBOSE(level, verbosity, txt, arg0, arg1, arg2) if (level <= verbosity) { fprintf(LOG, txt, arg0, arg1, arg2); fflush(LOG); } -# define PDEBUG4_VERBOSE(level, verbosity, txt, arg0, arg1, arg2, arg3) if (level <= verbosity) { fprintf(LOG, txt, arg0, arg1, arg2, arg3); fflush(LOG); } +# define PDEBUG(fmt, args...) fprintf (LOG, fmt , ## args) # else -# define PDEBUG -# define PDEBUG_VERBOSE -# define PDEBUG0_VERBOSE(level, verbosity, txt) -# define PDEBUG1_VERBOSE(level, verbosity, txt, arg0) -# define PDEBUG2_VERBOSE(level, verbosity, txt, arg0, arg1) -# define PDEBUG3_VERBOSE(level, verbosity, txt, arg0, arg1, arg2) -# define PDEBUG4_VERBOSE(level, verbosity, txt, arg0, arg1, arg2, arg3) +# define PDEBUG(fmt, args...) # endif #endif +#ifdef DEBUG +# define PDEBUG_VERBOSE(level, verbosity, fmt, args...) if (level <= verbosity) { fprintf(LOG, fmt, ## args); fflush(LOG); } +# define PDEBUG0_VERBOSE(level, verbosity, txt) if (level <= verbosity) { fprintf(LOG, txt); fflush(LOG); } +# define PDEBUG1_VERBOSE(level, verbosity, txt, arg0) if (level <= verbosity) { fprintf(LOG, txt, arg0); fflush(LOG); } +# define PDEBUG2_VERBOSE(level, verbosity, txt, arg0, arg1) if (level <= verbosity) { fprintf(LOG, txt, arg0, arg1); fflush(LOG); } +# define PDEBUG3_VERBOSE(level, verbosity, txt, arg0, arg1, arg2) if (level <= verbosity) { fprintf(LOG, txt, arg0, arg1, arg2); fflush(LOG); } +# define PDEBUG4_VERBOSE(level, verbosity, txt, arg0, arg1, arg2, arg3) if (level <= verbosity) { fprintf(LOG, txt, arg0, arg1, arg2, arg3); fflush(LOG); } +#else +# define PDEBUG_VERBOSE(level, verbosity, fmt, args...) +# define PDEBUG0_VERBOSE(level, verbosity, txt) +# define PDEBUG1_VERBOSE(level, verbosity, txt, arg0) +# define PDEBUG2_VERBOSE(level, verbosity, txt, arg0, arg1) +# define PDEBUG3_VERBOSE(level, verbosity, txt, arg0, arg1, arg2) +# define PDEBUG4_VERBOSE(level, verbosity, txt, arg0, arg1, arg2, arg3) +#endif // DEBUG -#endif // PC_DEBUG_ diff --git a/src/fig/FIG0_6.h b/src/fig/FIG0_6.h index 770c4d5..96464d2 100644 --- a/src/fig/FIG0_6.h +++ b/src/fig/FIG0_6.h @@ -26,8 +26,6 @@ #pragma once #include -#include -#include namespace FIC { diff --git a/src/fig/FIG1.h b/src/fig/FIG1.h index 0fedffe..fe36717 100644 --- a/src/fig/FIG1.h +++ b/src/fig/FIG1.h @@ -23,8 +23,7 @@ along with ODR-DabMux. If not, see . */ -#ifndef __FIG1_H_ -#define __FIG1_H_ +#pragma once #include @@ -103,10 +102,6 @@ class FIG1_5 : public IFIG vec_sp_service::iterator service; }; -#ifdef _WIN32 -# pragma pack(push) -#endif - struct FIGtype1_0 { uint8_t Length:5; uint8_t FIGtypeNumber:3; @@ -165,11 +160,5 @@ struct FIGtype1_4_data { } PACKED; -#ifdef _WIN32 -# pragma pack(pop) -#endif - } // namespace FIC -#endif // __FIG1_H_ - diff --git a/src/fig/FIG2.h b/src/fig/FIG2.h index ee3fed9..e69c5db 100644 --- a/src/fig/FIG2.h +++ b/src/fig/FIG2.h @@ -22,9 +22,7 @@ You should have received a copy of the GNU General Public License along with ODR-DabMux. If not, see . */ - -#ifndef __FIG2_H_ -#define __FIG2_H_ +#pragma once #include #include @@ -117,10 +115,6 @@ class FIG2_4 : public IFIG std::map, FIG2_Segments> segment_per_component; }; -#ifdef _WIN32 -# pragma pack(push) -#endif - struct FIGtype2 { uint8_t Length:5; uint8_t FIGtypeNumber:3; @@ -159,11 +153,5 @@ struct FIG2_Extended_Label_WithTextControl { uint8_t EncodingFlag:1; } PACKED; -#ifdef _WIN32 -# pragma pack(pop) -#endif - } // namespace FIC -#endif // __FIG2_H_ - diff --git a/src/input/File.cpp b/src/input/File.cpp index d9fe02a..c70feee 100644 --- a/src/input/File.cpp +++ b/src/input/File.cpp @@ -28,9 +28,6 @@ #include #include #include -#ifndef _WIN32 -# define O_BINARY 0 -#endif #include "input/File.h" #include "mpeg.h" #include "ReedSolomon.h" @@ -39,9 +36,6 @@ using namespace std; namespace Inputs { -#ifdef _WIN32 -# pragma pack(push, 1) -#endif struct packetHeader { unsigned char addressHigh:2; unsigned char last:1; @@ -52,11 +46,7 @@ struct packetHeader { unsigned char dataLength:7; unsigned char command; } -#ifdef _WIN32 -# pragma pack(pop) -#else __attribute((packed)) -#endif ; @@ -68,7 +58,7 @@ void FileBase::open(const std::string& name) load_entire_file(); } else { - int flags = O_RDONLY | O_BINARY; + int flags = O_RDONLY; if (m_nonblock) { flags |= O_NONBLOCK; } @@ -140,13 +130,13 @@ ssize_t FileBase::load_entire_file() { // Clear the buffer if the file open fails, this allows user to stop transmission // of the current data. - vector old_file_contents = move(m_file_contents); + vector old_file_contents = std::move(m_file_contents); m_file_contents.clear(); m_file_contents_offset = 0; // Read entire file in chunks of 4MiB constexpr size_t blocksize = 4 * 1024 * 1024; - constexpr int flags = O_RDONLY | O_BINARY; + constexpr int flags = O_RDONLY; m_fd = ::open(m_filename.c_str(), flags); if (m_fd == -1) { if (not m_file_open_alert_shown) { @@ -225,7 +215,7 @@ ssize_t FileBase::readFromFile(uint8_t *buffer, size_t size) vector remaining_buf; copy(m_nonblock_buffer.begin() + size, m_nonblock_buffer.end(), back_inserter(remaining_buf)); - m_nonblock_buffer = move(remaining_buf); + m_nonblock_buffer = std::move(remaining_buf); return size; } diff --git a/src/mpeg.h b/src/mpeg.h index 15b9b80..29b3655 100644 --- a/src/mpeg.h +++ b/src/mpeg.h @@ -18,23 +18,13 @@ You should have received a copy of the GNU General Public License along with ODR-DabMux. If not, see . */ - -#ifndef _MPEG -#define _MPEG +#pragma once #ifdef HAVE_CONFIG_H # include "config.h" #endif -#ifdef _WIN32 -# include -# include -# include - -# define ssize_t SSIZE_T -#else -# include -#endif +#include #ifdef __cplusplus extern "C" { @@ -86,4 +76,3 @@ int checkDabMpegFrame(void* data); } #endif -#endif // _MPEG -- cgit v1.2.3