diff options
author | Stefan Pöschel <github@basicmaster.de> | 2015-04-10 15:59:36 +0200 |
---|---|---|
committer | Stefan Pöschel <github@basicmaster.de> | 2015-04-10 15:59:36 +0200 |
commit | b5dff73b4d98edff900737a33a050fa2781dcf54 (patch) | |
tree | 6bb8459d420589ae5a20e6e5934ecfe14eed573d /src/mot-encoder.cpp | |
parent | 46198fde64b2e911af913874b5b1fab811220956 (diff) | |
download | ODR-AudioEnc-b5dff73b4d98edff900737a33a050fa2781dcf54.tar.gz ODR-AudioEnc-b5dff73b4d98edff900737a33a050fa2781dcf54.tar.bz2 ODR-AudioEnc-b5dff73b4d98edff900737a33a050fa2781dcf54.zip |
(Re)Create DLS data groups only if needed
Diffstat (limited to 'src/mot-encoder.cpp')
-rw-r--r-- | src/mot-encoder.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mot-encoder.cpp b/src/mot-encoder.cpp index 2cd497f..0548614 100644 --- a/src/mot-encoder.cpp +++ b/src/mot-encoder.cpp @@ -229,8 +229,9 @@ void writeDLS(int output_fd, const char* dls_file, int padlen, uint8_t charset); int get_xpadlengthmask(int padlen); #define ALLOWED_PADLEN "23, 26, 34, 42, 58" -// The toggle flag for the DLS +// The toggle info for the DLS static uint8_t dls_toggle = 0; +char dlstext_prev[MAXDLS + 1]; // The DLS data groups std::deque<std::vector<uint8_t> > dlsdg; @@ -875,6 +876,7 @@ void writeDLS(int output_fd, const char* dls_file, int padlen, uint8_t charset) char dlstext[MAXDLS + 1]; int dlslen; int i; + bool dlstext_new; if (dlsfd != 0) { close(dlsfd); @@ -899,11 +901,16 @@ void writeDLS(int output_fd, const char* dls_file, int padlen, uint8_t charset) endp--; } + // (Re)Create data groups (and thereby toggle the toggle bit) only on (first call or) new text + dlstext_new = dlsdg.empty() || strcmp(dlstext, dlstext_prev); if (verbose) { - fprintf(stderr, "mot-encoder writing DLS text \"%s\"\n", dlstext); + fprintf(stderr, "mot-encoder writing %s DLS text \"%s\"\n", dlstext_new ? "new" : "old", dlstext); + } + if (dlstext_new) { + create_dls_datagroup(dlstext, padlen, charset); + strcpy(dlstext_prev, dlstext); } - create_dls_datagroup(dlstext, padlen, charset); for (i = 0; i < dlsdg.size(); i++) { size_t dummy = write(output_fd, &dlsdg[i].front(), dlsdg[i].size()); } |