1
0
mirror of https://github.com/DigitalDevices/dddvb.git synced 2023-10-10 13:37:43 +02:00

fix frontend allocation

This commit is contained in:
internal 2023-07-31 22:07:40 +02:00
parent 5e5ff60b21
commit 7250608d53
2 changed files with 10 additions and 7 deletions

View File

@ -30,7 +30,7 @@ LIBDDDVB_EXPORTED struct dddvb_fe *dddvb_fe_alloc_num(struct dddvb *dd, uint32_t
pthread_mutex_unlock(&dd->lock); pthread_mutex_unlock(&dd->lock);
if (dddvb_fe_start(fe) < 0) { if (dddvb_fe_start(fe) < 0) {
dbgprintf(DEBUG_SYS, "fe %d busy\n", fe->nr); dbgprintf(DEBUG_SYS, "fe %d busy\n", fe->nr);
return 0; return NULL;
} }
dbgprintf(DEBUG_SYS, "Allocated fe %d = %d/%d, fd=%d\n", dbgprintf(DEBUG_SYS, "Allocated fe %d = %d/%d, fd=%d\n",
fe->nr, fe->anum, fe->fnum, fe->fd); 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) LIBDDDVB_EXPORTED struct dddvb_fe *dddvb_fe_alloc(struct dddvb *dd, uint32_t type)
{ {
int i; int i;
struct dddvb_fe *fe = NULL; struct dddvb_fe *fe = NULL, *tfe;
pthread_mutex_lock(&dd->lock); pthread_mutex_lock(&dd->lock);
dbgprintf(DEBUG_SYS, "alloc_fe type %u\n", type); dbgprintf(DEBUG_SYS, "alloc_fe type %u\n", type);
for (i = 0; i < dd->dvbfe_num; i++) { for (i = 0; i < dd->dvbfe_num; i++) {
fe = &dd->dvbfe[i]; tfe = &dd->dvbfe[i];
if (fe->state == 0 && if (tfe->state == 0 &&
(fe->type & (1UL << type))) { (tfe->type & (1UL << type))) {
fe = dddvb_fe_alloc_num(dd, type, i); fe = dddvb_fe_alloc_num(dd, type, i);
if (fe) if (fe)
break; break;
} }
} }
pthread_mutex_unlock(&dd->lock); 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; return fe;
} }
LIBDDDVB_EXPORTED int dddvb_dvb_tune(struct dddvb_fe *fe, struct dddvb_params *p) LIBDDDVB_EXPORTED int dddvb_dvb_tune(struct dddvb_fe *fe, struct dddvb_params *p)