From 5e9fe473ba528f336dd86ce9d3d7d3e40410db54 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 7 Mar 2014 11:36:17 +0100 Subject: add 120ms delay --- src/AlsaDabplus.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/AlsaDabplus.cpp b/src/AlsaDabplus.cpp index 758d96e..ea81bda 100644 --- a/src/AlsaDabplus.cpp +++ b/src/AlsaDabplus.cpp @@ -90,6 +90,7 @@ int prepare_aac_encoder( return 1; } + *encoder = handle; if(channels == 2 && subchannel_index <= 6) aot = AOT_DABPLUS_PS; @@ -362,6 +363,19 @@ int main(int argc, char *argv[]) { fprintf(stderr, "."); // -------------- wait 120ms (one DAB+ superframe) + tp.tv_nsec += 120000000; + if (tp.tv_nsec > 1000000000L) { + tp.tv_nsec -= 1000000000L; + tp.tv_sec += 1; + } + + struct timespec tp_now; + do { + usleep(10000); + clock_gettime(CLOCK_MONOTONIC, &tp); + } while (tp_now.tv_sec < tp.tv_sec || + ( tp_now.tv_sec == tp.tv_sec && + tp_now.tv_nsec < tp.tv_nsec) ); } -- cgit v1.2.3