From 5283909d2b9c7068a643571b7d6145cbed33a661 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 27 Apr 2020 11:33:51 +0200 Subject: Fix FIG2 config parsing and segment count issue Thanks to Maik for his patch --- src/ConfigParser.cpp | 11 ++--------- src/fig/FIG2.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index 30140bf..5d73b55 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -95,16 +95,9 @@ static void parse_fig2_label(ptree& pt, DabLabel& label) { if (pt_tc) { FIG2TextControl tc; tc.bidi_flag = pt_tc->get("bidi", tc.bidi_flag); - auto base_direction = pt_tc->get("bidi", "LTR"); + auto base_direction = pt_tc->get("base_direction", "LTR"); - if (not(base_direction == "LTR" or base_direction == "RTL")) { - tc.base_direction_is_rtl = (base_direction == "RTL"); - } - else { - etiLog.level(error) << "Invalid value " << base_direction << - " for fig2 text control base direction"; - throw runtime_error("Invalid FIG2 text control definition"); - } + tc.base_direction_is_rtl = (base_direction == "RTL"); tc.contextual_flag = pt_tc->get("contextual", tc.contextual_flag); tc.combining_flag = pt_tc->get("combining", tc.combining_flag); diff --git a/src/fig/FIG2.cpp b/src/fig/FIG2.cpp index 7aecbe8..38c625b 100644 --- a/src/fig/FIG2.cpp +++ b/src/fig/FIG2.cpp @@ -34,7 +34,7 @@ namespace FIC { using namespace std; -static void write_fig2_segment_field( +static uint8_t* write_fig2_segment_field( uint8_t *buf, ssize_t& remaining, FIG2_Segments& segments, const DabLabel& label) { if (segments.current_segment_index() == 0) { @@ -70,6 +70,7 @@ static void write_fig2_segment_field( copy(character_field.begin(), character_field.end(), buf); buf += character_field.size(); remaining -= character_field.size(); + return buf; } void FIG2_Segments::clear() @@ -202,7 +203,7 @@ FillStatus FIG2_0::fill(uint8_t *buf, size_t max_size) buf += 2; remaining -= 2; - write_fig2_segment_field(buf, remaining, m_segments, ensemble->label); + buf = write_fig2_segment_field(buf, remaining, m_segments, ensemble->label); if (m_segments.complete()) { fs.complete_fig_transmitted = true; @@ -257,7 +258,6 @@ FillStatus FIG2_1_and_5::fill(uint8_t *buf, size_t max_size) } auto fig2 = (FIGtype2*)buf; - fig2->Length = required_bytes - 1; fig2->FIGtypeNumber = 2; @@ -283,7 +283,7 @@ FillStatus FIG2_1_and_5::fill(uint8_t *buf, size_t max_size) buf += id_length; remaining -= id_length; - write_fig2_segment_field(buf, remaining, segments, (*service)->label); + buf = write_fig2_segment_field(buf, remaining, segments, (*service)->label); if (segments.complete()) { segments.clear(); @@ -386,7 +386,7 @@ FillStatus FIG2_4::fill(uint8_t *buf, size_t max_size) remaining -= sizeof(FIGtype2_4_Data_Identifier); } - write_fig2_segment_field(buf, remaining, segments, (*component)->label); + buf = write_fig2_segment_field(buf, remaining, segments, (*component)->label); if (segments.complete()) { segments.clear(); -- cgit v1.2.3