From 7250608d53bde316b2649f7b47aad3b3c3ff8bd2 Mon Sep 17 00:00:00 2001 From: internal <> Date: Mon, 31 Jul 2023 22:07:40 +0200 Subject: [PATCH] fix frontend allocation --- lib/ddzap.c | 2 +- lib/src/dddvb.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/ddzap.c b/lib/ddzap.c index 0ab1358..559cb60 100644 --- a/lib/ddzap.c +++ b/lib/ddzap.c @@ -484,7 +484,7 @@ int main(int argc, char **argv) else fe = dddvb_fe_alloc(dd, delsys); if (!fe) { - fprintf(fout,"dddvb_fe_alloc failed\n"); + fprintf(fout,"dddvb_fe_alloc failed\n"); exit(-1); } dddvb_param_init(&p); diff --git a/lib/src/dddvb.c b/lib/src/dddvb.c index b011a04..a593101 100644 --- a/lib/src/dddvb.c +++ b/lib/src/dddvb.c @@ -30,7 +30,7 @@ LIBDDDVB_EXPORTED struct dddvb_fe *dddvb_fe_alloc_num(struct dddvb *dd, uint32_t pthread_mutex_unlock(&dd->lock); if (dddvb_fe_start(fe) < 0) { dbgprintf(DEBUG_SYS, "fe %d busy\n", fe->nr); - return 0; + return NULL; } dbgprintf(DEBUG_SYS, "Allocated fe %d = %d/%d, fd=%d\n", fe->nr, fe->anum, fe->fnum, fe->fd); @@ -40,22 +40,25 @@ LIBDDDVB_EXPORTED struct dddvb_fe *dddvb_fe_alloc_num(struct dddvb *dd, uint32_t LIBDDDVB_EXPORTED struct dddvb_fe *dddvb_fe_alloc(struct dddvb *dd, uint32_t type) { int i; - struct dddvb_fe *fe = NULL; + struct dddvb_fe *fe = NULL, *tfe; pthread_mutex_lock(&dd->lock); dbgprintf(DEBUG_SYS, "alloc_fe type %u\n", type); for (i = 0; i < dd->dvbfe_num; i++) { - fe = &dd->dvbfe[i]; - if (fe->state == 0 && - (fe->type & (1UL << type))) { + tfe = &dd->dvbfe[i]; + if (tfe->state == 0 && + (tfe->type & (1UL << type))) { fe = dddvb_fe_alloc_num(dd, type, i); if (fe) break; } } pthread_mutex_unlock(&dd->lock); + if (!fe) + dbgprintf(DEBUG_SYS, "alloc_fe type %u\n failed!", type); + else + dbgprintf(DEBUG_SYS, "alloc_fe type %u success!\n", type); return fe; - } LIBDDDVB_EXPORTED int dddvb_dvb_tune(struct dddvb_fe *fe, struct dddvb_params *p)