summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/DabMultiplexer.cpp18
-rw-r--r--src/MuxElements.h47
-rw-r--r--src/fig/FIG0_10.cpp16
-rw-r--r--src/fig/FIG0_9.cpp5
-rw-r--r--src/utils.cpp5
5 files changed, 38 insertions, 53 deletions
diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp
index 95a0cce..15c57a5 100644
--- a/src/DabMultiplexer.cpp
+++ b/src/DabMultiplexer.cpp
@@ -92,6 +92,8 @@ DabMultiplexer::DabMultiplexer(
m_clock_tai(split_pipe_separated_string(pt.get("general.tai_clock_bulletins", ""))),
fig_carousel(ensemble)
{
+ gettimeofday(&mnsc_time, nullptr);
+
RC_ADD_PARAMETER(frames, "Show number of frames generated [read-only]");
RC_ADD_PARAMETER(tist_edioffset, "EDI Time offset in seconds");
@@ -169,7 +171,7 @@ void DabMultiplexer::prepare(bool require_tai_clock)
throw MuxInitException();
}
- auto last_subchannel = *(ensemble->subchannels.end() - 1);
+ const auto last_subchannel = *(ensemble->subchannels.end() - 1);
if (last_subchannel->startAddress + last_subchannel->getSizeCu() > 864) {
etiLog.log(error, "Total size in CU exceeds 864");
@@ -199,7 +201,7 @@ void DabMultiplexer::prepare(bool require_tai_clock)
try {
m_clock_tai.get_offset();
}
- catch (std::runtime_error& e) {
+ catch (const std::runtime_error& e) {
etiLog.level(error) <<
"Could not initialise TAI clock properly. "
"Do you have a working internet connection?";
@@ -392,9 +394,6 @@ void DabMultiplexer::mux_frame(std::vector<std::shared_ptr<DabOutput> >& outputs
unsigned char etiFrame[6144];
unsigned short index = 0;
- vec_sp_service::iterator service;
- vec_sp_component::iterator component;
-
// FIC Length, DAB Mode I, II, IV -> FICL = 24, DAB Mode III -> FICL = 32
unsigned FICL =
(ensemble->transmission_mode == TransmissionMode_e::TM_III ? 32 : 24);
@@ -538,7 +537,8 @@ void DabMultiplexer::mux_frame(std::vector<std::shared_ptr<DabOutput> >& outputs
eoh->MNSC = 0;
- struct tm *time_tm = gmtime(&mnsc_time.tv_sec);
+ struct tm time_tm;
+ gmtime_r(&mnsc_time.tv_sec, &time_tm);
switch (fc->FP & 0x3)
{
case 0:
@@ -559,7 +559,7 @@ void DabMultiplexer::mux_frame(std::vector<std::shared_ptr<DabOutput> >& outputs
case 1:
{
eti_MNSC_TIME_1 *mnsc = (eti_MNSC_TIME_1 *) &eoh->MNSC;
- mnsc->setFromTime(time_tm);
+ mnsc->setFromTime(&time_tm);
mnsc->accuracy = 1;
mnsc->sync_to_frame = 1;
}
@@ -567,13 +567,13 @@ void DabMultiplexer::mux_frame(std::vector<std::shared_ptr<DabOutput> >& outputs
case 2:
{
eti_MNSC_TIME_2 *mnsc = (eti_MNSC_TIME_2 *) &eoh->MNSC;
- mnsc->setFromTime(time_tm);
+ mnsc->setFromTime(&time_tm);
}
break;
case 3:
{
eti_MNSC_TIME_3 *mnsc = (eti_MNSC_TIME_3 *) &eoh->MNSC;
- mnsc->setFromTime(time_tm);
+ mnsc->setFromTime(&time_tm);
}
break;
}
diff --git a/src/MuxElements.h b/src/MuxElements.h
index 09bf072..d116a4e 100644
--- a/src/MuxElements.h
+++ b/src/MuxElements.h
@@ -294,15 +294,7 @@ class DabSubchannel
{
public:
DabSubchannel(std::string& uid) :
- uid(uid),
- input(),
- id(0),
- type(subchannel_type_t::Audio),
- startAddress(0),
- bitrate(0),
- protection()
- {
- }
+ uid(uid) { }
// Calculate subchannel size in number of CU
unsigned short getSizeCu(void) const;
@@ -320,20 +312,17 @@ public:
std::string inputUri;
std::shared_ptr<Inputs::InputBase> input;
- unsigned char id;
- subchannel_type_t type;
- uint16_t startAddress;
- uint16_t bitrate;
- dabProtection protection;
+ unsigned char id = 0;
+ subchannel_type_t type = subchannel_type_t::Audio;
+ uint16_t startAddress = 0;
+ uint16_t bitrate = 0;
+ struct dabProtection protection;
};
struct dabAudioComponent {
- dabAudioComponent() :
- uaType(0xFFFF) {}
-
- uint16_t uaType; // User Application Type
+ uint16_t uaType = 0xFFFF; // User Application Type
};
@@ -346,16 +335,10 @@ struct dabFidcComponent {
struct dabPacketComponent {
- dabPacketComponent() :
- id(0),
- address(0),
- appType(0xFFFF),
- datagroup(false) { }
-
- uint16_t id;
- uint16_t address;
- uint16_t appType;
- bool datagroup;
+ uint16_t id = 0;
+ uint16_t address = 0;
+ uint16_t appType = 0xFFFF;
+ bool datagroup = false;
};
class DabComponent : public RemoteControllable
@@ -371,10 +354,10 @@ class DabComponent : public RemoteControllable
std::string uid;
DabLabel label;
- uint32_t serviceId;
- uint8_t subchId;
- uint8_t type;
- uint8_t SCIdS;
+ uint32_t serviceId = 0;
+ uint8_t subchId = 0;
+ uint8_t type = 0;
+ uint8_t SCIdS = 0;
dabAudioComponent audio;
dabDataComponent data;
diff --git a/src/fig/FIG0_10.cpp b/src/fig/FIG0_10.cpp
index 3ce2847..56ce9fb 100644
--- a/src/fig/FIG0_10.cpp
+++ b/src/fig/FIG0_10.cpp
@@ -101,22 +101,22 @@ FillStatus FIG0_10::fill(uint8_t *buf, size_t max_size)
buf += 2;
remaining -= 2;
- tm* timeData;
+ struct tm timeData;
time_t dab_time_seconds = 0;
uint32_t dab_time_millis = 0;
get_dab_time(&dab_time_seconds, &dab_time_millis);
- timeData = gmtime(&dab_time_seconds);
+ gmtime_r(&dab_time_seconds, &timeData);
fig0_10->RFU = 0;
- fig0_10->setMJD(gregorian2mjd(timeData->tm_year + 1900,
- timeData->tm_mon + 1,
- timeData->tm_mday));
+ fig0_10->setMJD(gregorian2mjd(timeData.tm_year + 1900,
+ timeData.tm_mon + 1,
+ timeData.tm_mday));
fig0_10->LSI = 0;
fig0_10->ConfInd = 1;
fig0_10->UTC = 1;
- fig0_10->setHours(timeData->tm_hour);
- fig0_10->Minutes = timeData->tm_min;
- fig0_10->Seconds = timeData->tm_sec;
+ fig0_10->setHours(timeData.tm_hour);
+ fig0_10->Minutes = timeData.tm_min;
+ fig0_10->Seconds = timeData.tm_sec;
fig0_10->setMilliseconds(dab_time_millis);
buf += 6;
remaining -= 6;
diff --git a/src/fig/FIG0_9.cpp b/src/fig/FIG0_9.cpp
index cf73625..dcee17c 100644
--- a/src/fig/FIG0_9.cpp
+++ b/src/fig/FIG0_9.cpp
@@ -139,8 +139,9 @@ FillStatus FIG0_9::fill(uint8_t *buf, size_t max_size)
if (ensemble->lto_auto) {
time_t now = time(NULL);
- struct tm* ltime = localtime(&now);
- time_t now2 = timegm(ltime);
+ struct tm ltime;
+ localtime_r(&now, &ltime);
+ time_t now2 = timegm(&ltime);
ensemble->lto = (now2 - now) / 1800;
}
diff --git a/src/utils.cpp b/src/utils.cpp
index be3cfd3..7a922fe 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -536,8 +536,9 @@ void printEnsemble(const shared_ptr<dabEnsemble>& ensemble)
if (ensemble->lto_auto) {
time_t now = time(nullptr);
- struct tm* ltime = localtime(&now);
- time_t now2 = timegm(ltime);
+ struct tm ltime;
+ localtime_r(&now, &ltime);
+ time_t now2 = timegm(&ltime);
etiLog.log(info, " lto: %2.1f hours", 0.5 * (now2 - now) / 1800);
}
else {