From 0226ed393837e753d4afe0349c28263d3c406f90 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 16 May 2018 11:48:42 +0200 Subject: Handle Ctrl-C when using EDI input --- src/DabMod.cpp | 13 ++++++++++--- src/EtiReader.cpp | 13 ++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/DabMod.cpp b/src/DabMod.cpp index bc32b9d..e388b15 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -330,14 +330,21 @@ int launch_modulator(int argc, char* argv[]) bool first_frame = true; while (running) { - while (not ediReader.isFrameReady()) { - bool success = ediUdpInput.rxPacket(); - if (not success) { + while (running and not ediReader.isFrameReady()) { + try { + ediUdpInput.rxPacket(); + } + catch (std::runtime_error& e) { + etiLog.level(warn) << "EDI input: " << e.what(); running = 0; break; } } + if (not running) { + break; + } + if (first_frame) { if (ediReader.getFp() != 0) { // Do not start the flowgraph before we get to FP 0 diff --git a/src/EtiReader.cpp b/src/EtiReader.cpp index c1b7445..4c5ad79 100644 --- a/src/EtiReader.cpp +++ b/src/EtiReader.cpp @@ -591,14 +591,13 @@ void EdiUdpInput::Open(const std::string& uri) bool EdiUdpInput::rxPacket() { - try { - auto udp_data = m_udp_rx.get_packet_buffer(); - m_decoder.push_packet(udp_data); - return true; - } - catch (std::runtime_error& e) { - etiLog.level(warn) << "EDI input: " << e.what(); + auto udp_data = m_udp_rx.get_packet_buffer(); + + if (udp_data.empty()) { return false; } + + m_decoder.push_packet(udp_data); + return true; } #endif // HAVE_EDI -- cgit v1.2.3