From 48e7a18d4002ac82249002a36a5d89c1cea16f32 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 1 Oct 2019 15:41:31 +0200 Subject: Fix EDI output frame sizes --- src/odr-sourcecompanion.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/odr-sourcecompanion.cpp b/src/odr-sourcecompanion.cpp index 6647853..02475eb 100644 --- a/src/odr-sourcecompanion.cpp +++ b/src/odr-sourcecompanion.cpp @@ -484,7 +484,19 @@ int main(int argc, char *argv[]) } else if (edi_output.enabled()) { edi_output.update_audio_levels(peak_left, peak_right); - success = edi_output.write_frame(outbuf.data(), numOutBytes); + // STI/EDI specifies that one AF packet must contain 24ms worth of data, + // therefore we must split the superframe into five parts + if (numOutBytes % 5 != 0) { + throw logic_error("Superframe size not multiple of 5"); + } + + const size_t blocksize = numOutBytes/5; + for (size_t i = 0; i < 5; i++) { + success = edi_output.write_frame(outbuf.data() + i * blocksize, blocksize); + if (not success) { + break; + } + } } if (not success) { -- cgit v1.2.3