From da560221954bcf313036d3929142c39bf8fad932 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Tue, 29 Jun 2021 15:10:00 +0200 Subject: [PATCH] libgeneric-pc/dmx.cpp: add default timeout to NIT scan, copy from libarmbox dmx Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/c054fe12739c2515c5e5e7ecb9082d4a2f2ea2b8 Author: Jacek Jendrzej Date: 2021-06-29 (Tue, 29 Jun 2021) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libgeneric-pc/dmx.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libgeneric-pc/dmx.cpp b/libgeneric-pc/dmx.cpp index b3c8d68..3938c1c 100644 --- a/libgeneric-pc/dmx.cpp +++ b/libgeneric-pc/dmx.cpp @@ -201,10 +201,18 @@ int cDemux::Read(unsigned char *buff, int len, int timeout) ufds.events = POLLIN | POLLPRI | POLLERR; ufds.revents = 0; - if (timeout > 0) + /* hack: if the frontend loses and regains lock, the demuxer often will not + * return from read(), so as a "emergency exit" for e.g. NIT scan, set a (long) + * timeout here */ + int to = timeout; + if (dmx_type == DMX_PSI_CHANNEL && timeout <= 0){ + to = 60 * 1000; + } + + if (to > 0) { retry: - rc = ::poll(&ufds, 1, timeout); + rc = ::poll(&ufds, 1, to); if (!rc) return 0; // timeout else if (rc < 0)