diff --git a/plugins/channelrx/demoddatv/datvdemodsink.cpp b/plugins/channelrx/demoddatv/datvdemodsink.cpp index cb461111a..48aa305d1 100644 --- a/plugins/channelrx/demoddatv/datvdemodsink.cpp +++ b/plugins/channelrx/demoddatv/datvdemodsink.cpp @@ -1169,8 +1169,7 @@ void DATVDemodSink::InitDATVS2Framework() *(leansdr::pipebuf< leansdr::fecframe > *) p_fecframes ); // Decode FEC-protected frames into plain BB frames. - leansdr::s2_fecdec_helper *r_fecdec = - new leansdr::s2_fecdec_helper( + r_fecdec = new leansdr::s2_fecdec_helper( m_objScheduler, *(leansdr::pipebuf< leansdr::fecframe > *) p_fecframes, *(leansdr::pipebuf *) p_bbframes, @@ -1178,9 +1177,10 @@ void DATVDemodSink::InitDATVS2Framework() p_vbitcount, p_verrcount) ; - const int nhelpers = 6; - r_fecdec->nhelpers = nhelpers; - r_fecdec->must_buffer = false; + leansdr::s2_fecdec_helper *fecdec = (leansdr::s2_fecdec_helper *) r_fecdec; + const int nhelpers = 2; + fecdec->nhelpers = nhelpers; + fecdec->must_buffer = false; #endif } else @@ -1194,7 +1194,8 @@ void DATVDemodSink::InitDATVS2Framework() *(leansdr::pipebuf< leansdr::fecframe > * ) p_fecframes ); r_fecdec = new leansdr::s2_fecdec( - m_objScheduler, *(leansdr::pipebuf< leansdr::fecframe > * ) p_fecframes, + m_objScheduler, + *(leansdr::pipebuf< leansdr::fecframe > * ) p_fecframes, *(leansdr::pipebuf *) p_bbframes, p_vbitcount, p_verrcount diff --git a/plugins/channelrx/demoddatv/ldpctool/ldpc_tool.cpp b/plugins/channelrx/demoddatv/ldpctool/ldpc_tool.cpp index d1ac52894..93adf33ed 100644 --- a/plugins/channelrx/demoddatv/ldpctool/ldpc_tool.cpp +++ b/plugins/channelrx/demoddatv/ldpctool/ldpc_tool.cpp @@ -168,10 +168,13 @@ int main(int argc, char **argv) for (int i = 0; i < CODE_LEN; ++i) code[(j + n) * CODE_LEN + i] = reinterpret_cast(simd + i)[n]; - if (count < 0) { + if (count < 0) + { iterations += blocks * trials; - // std::cerr << "decoder failed at converging to a code word in " << trials << " trials" << std::endl; - } else { + std::cerr << "ldpc_tool: decoder failed at converging to a code word in " << trials << " trials" << std::endl; + } + else + { iterations += blocks * (trials - count); } } diff --git a/plugins/channelrx/demoddatv/leansdr/dvbs2.h b/plugins/channelrx/demoddatv/leansdr/dvbs2.h index bdd35f743..8385981c8 100644 --- a/plugins/channelrx/demoddatv/leansdr/dvbs2.h +++ b/plugins/channelrx/demoddatv/leansdr/dvbs2.h @@ -2411,36 +2411,46 @@ struct s2_fecdec_helper : runnable s2_pls pls; helper_instance *h; }; + simplequeue jobs; + // Try to send a frame. Return false if helper was busy. bool send_frame(fecframe *pin) { pool *p = get_pool(&pin->pls); + for (int i = 0; i < p->nprocs; ++i) { helper_instance *h = &p->procs[i]; int iosize = (pin->pls.framebits() / 8) * sizeof(SOFTBYTE); // fprintf(stderr, "Writing %lu to fd %d\n", iosize, h->fd_tx); int nw = write(h->fd_tx, pin->bytes, iosize); + if (nw < 0 && errno == EWOULDBLOCK) - continue; + continue; // next worker if (nw < 0) fatal("write(LDPC helper"); if (nw != iosize) fatal("partial write(LDPC helper)"); + helper_job *job = jobs.put(); job->pls = pin->pls; job->h = h; ++h->b_in; + if (h->b_in >= h->batch_size) { h->b_in -= h->batch_size; h->b_out += h->batch_size; } - return true; + + return true; // done sent to worker } - return false; + + fprintf(stderr, "s2_fecdec_helper::send_frame: WARNING: all %d workers are busy\n", p->nprocs); + return false; // all workers are busy } + // Return a pool of running helpers for a given modcod. pool *get_pool(const s2_pls *pls) { @@ -2454,6 +2464,7 @@ struct s2_fecdec_helper : runnable } return p; } + // Spawn a helper process. void spawn_helper(helper_instance *h, const s2_pls *pls) { @@ -2554,6 +2565,7 @@ struct s2_fecdec_helper : runnable if (sch->debug) fprintf(stderr, "%c", corrupted ? '!' : ncorr ? '.' : '_'); } + pipereader> in; pipewriter out; const char *command;