From 8ff89e414770a922e45eee829b672aceb10ea609 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 13 Feb 2019 10:30:59 +0100 Subject: Simplify and use isProgramme where possible --- src/fig/FIG0_13.cpp | 5 +++-- src/fig/FIG0_2.cpp | 2 +- src/fig/FIG1.cpp | 9 +++------ src/fig/FIG2.cpp | 6 ++---- 4 files changed, 9 insertions(+), 13 deletions(-) (limited to 'src/fig') diff --git a/src/fig/FIG0_13.cpp b/src/fig/FIG0_13.cpp index 433838e..314c6e1 100644 --- a/src/fig/FIG0_13.cpp +++ b/src/fig/FIG0_13.cpp @@ -89,8 +89,9 @@ FillStatus FIG0_13::fill(uint8_t *buf, size_t max_size) continue; } - if ( m_transmit_programme && - ((*subchannel)->type == subchannel_type_t::DABPlusAudio || (*subchannel)->type == subchannel_type_t::DABAudio) && + const auto type = (*subchannel)->type; + if ( m_transmit_programme and + (type == subchannel_type_t::DABPlusAudio or type == subchannel_type_t::DABAudio) and (*componentFIG0_13)->audio.uaType != 0xffff) { const int required_size = 3+4+11; diff --git a/src/fig/FIG0_2.cpp b/src/fig/FIG0_2.cpp index 0b6cd87..c9f8371 100644 --- a/src/fig/FIG0_2.cpp +++ b/src/fig/FIG0_2.cpp @@ -193,7 +193,7 @@ FillStatus FIG0_2::fill(uint8_t *buf, size_t max_size) break; } - if (type == subchannel_type_t::DABPlusAudio || type == subchannel_type_t::DABAudio) { + if (type == subchannel_type_t::DABPlusAudio or type == subchannel_type_t::DABAudio) { auto fig0_2serviceAudio = (FIGtype0_2_Service*)buf; fig0_2serviceAudio->SId = htons((*serviceFIG0_2)->id); diff --git a/src/fig/FIG1.cpp b/src/fig/FIG1.cpp index d0b6a17..6683f17 100644 --- a/src/fig/FIG1.cpp +++ b/src/fig/FIG1.cpp @@ -94,10 +94,9 @@ FillStatus FIG1_1::fill(uint8_t *buf, size_t max_size) break; } - const auto type = (*service)->getType(ensemble); + const bool is_programme = (*service)->isProgramme(ensemble); - if ( (type == subchannel_type_t::DABPlusAudio or type == subchannel_type_t::DABAudio) and - (*service)->label.has_fig1_label()) { + if (is_programme and (*service)->label.has_fig1_label()) { auto fig1_1 = (FIGtype1_1 *)buf; fig1_1->FIGtypeNumber = 1; @@ -155,10 +154,8 @@ FillStatus FIG1_4::fill(uint8_t *buf, size_t max_size) /* We check in the config parser if the primary component has * a label, which is forbidden since V2.1.1 */ - const auto type = (*service)->getType(ensemble); - if (not (*component)->label.long_label().empty() ) { - if (type == subchannel_type_t::DABAudio or type == subchannel_type_t::DABPlusAudio) { + if ((*service)->isProgramme(ensemble)) { if (remaining < 5 + 16 + 2) { break; diff --git a/src/fig/FIG2.cpp b/src/fig/FIG2.cpp index afa64eb..b88814c 100644 --- a/src/fig/FIG2.cpp +++ b/src/fig/FIG2.cpp @@ -202,8 +202,7 @@ FillStatus FIG2_1_and_5::fill(uint8_t *buf, size_t max_size) // Rotate through the subchannels until there is no more space while (service != ensemble->services.end()) { - const bool is_programme = (*service)->getType(ensemble) == subchannel_type_t::DABAudio or - ((*service)->getType(ensemble) == subchannel_type_t::DABPlusAudio); + const bool is_programme = (*service)->isProgramme(ensemble); if (not (m_programme xor is_programme) and (*service)->label.has_fig2_label()) { @@ -316,8 +315,7 @@ FillStatus FIG2_4::fill(uint8_t *buf, size_t max_size) } } - const bool is_programme = (*service)->getType(ensemble) == subchannel_type_t::DABAudio or - ((*service)->getType(ensemble) == subchannel_type_t::DABPlusAudio); + const bool is_programme = (*service)->isProgramme(ensemble); const size_t id_length = is_programme ? sizeof(FIGtype2_4_Programme_Identifier) : -- cgit v1.2.3