linuxdvb: tidy some code and update to new mpegts_input API
This commit is contained in:
parent
15731c1a59
commit
ad39629335
5 changed files with 18 additions and 29 deletions
|
@ -29,6 +29,10 @@
|
|||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define FE_PATH "/dev/dvb/adapter%d/frontend%d"
|
||||
#define DVR_PATH "/dev/dvb/adapter%d/dvr%d"
|
||||
#define DMX_PATH "/dev/dvb/adapter%d/demux%d"
|
||||
|
||||
/* ***************************************************************************
|
||||
* DVB Adapter
|
||||
* **************************************************************************/
|
||||
|
@ -177,8 +181,6 @@ linuxdvb_adapter_find_by_number ( int adapter )
|
|||
la->la_number = a;
|
||||
snprintf(buf, sizeof(buf), "/dev/dvb/adapter%d", adapter);
|
||||
tvh_str_update(&la->la_rootpath, buf);
|
||||
if (!la->lh_displayname)
|
||||
la->lh_displayname = strdup(la->la_rootpath);
|
||||
|
||||
return la;
|
||||
}
|
||||
|
@ -196,7 +198,7 @@ linuxdvb_adapter_added ( int adapter )
|
|||
|
||||
/* Process each frontend */
|
||||
for (i = 0; i < 32; i++) {
|
||||
snprintf(fe_path, sizeof(fe_path), "/dev/dvb/adapter%d/frontend%d", adapter, i);
|
||||
snprintf(fe_path, sizeof(fe_path), FE_PATH, adapter, i);
|
||||
|
||||
/* No access */
|
||||
if (access(fe_path, R_OK | W_OK)) continue;
|
||||
|
@ -215,15 +217,15 @@ linuxdvb_adapter_added ( int adapter )
|
|||
}
|
||||
|
||||
/* DVR/DMX (bit of a guess) */
|
||||
snprintf(dmx_path, sizeof(dmx_path), "/dev/dvb/adapter%d/demux%d", adapter, i);
|
||||
snprintf(dmx_path, sizeof(dmx_path), DMX_PATH, adapter, i);
|
||||
if (access(dmx_path, R_OK | W_OK)) {
|
||||
snprintf(dmx_path, sizeof(dmx_path), "/dev/dvb/adapter%d/demux0", adapter);
|
||||
snprintf(dmx_path, sizeof(dmx_path), DMX_PATH, adapter, 0);
|
||||
if (access(dmx_path, R_OK | W_OK)) continue;
|
||||
}
|
||||
|
||||
snprintf(dvr_path, sizeof(dvr_path), "/dev/dvb/adapter%d/dvr%d", adapter, i);
|
||||
snprintf(dvr_path, sizeof(dvr_path), DVR_PATH, adapter, i);
|
||||
if (access(dvr_path, R_OK | W_OK)) {
|
||||
snprintf(dvr_path, sizeof(dvr_path), "/dev/dvb/adapter%d/dvr0", adapter);
|
||||
snprintf(dvr_path, sizeof(dvr_path), DVR_PATH, adapter, 0);
|
||||
if (access(dvr_path, R_OK | W_OK)) continue;
|
||||
}
|
||||
|
||||
|
@ -233,6 +235,11 @@ linuxdvb_adapter_added ( int adapter )
|
|||
tvhlog(LOG_ERR, "linuxdvb", "failed to find/create adapter%d", adapter);
|
||||
return NULL;
|
||||
}
|
||||
if (!la->mi_displayname) {
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "%s #%d", dfi.name, la->la_number);
|
||||
la->mi_displayname = strdup(buf);
|
||||
}
|
||||
}
|
||||
|
||||
/* Create frontend */
|
||||
|
|
|
@ -286,7 +286,7 @@ linuxdvb_device_find_by_adapter ( int a )
|
|||
|
||||
/* Copy device info */
|
||||
memcpy(&ld->ld_devid, &dev, sizeof(dev));
|
||||
ld->lh_displayname = strdup(dev.di_id);
|
||||
ld->mi_displayname = strdup(dev.di_id);
|
||||
return ld;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ static const char *
|
|||
linuxdvb_frontend_class_get_title ( idnode_t *in )
|
||||
{
|
||||
linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)in;
|
||||
if (lfe->lh_displayname)
|
||||
return lfe->lh_displayname;
|
||||
if (lfe->mi_displayname)
|
||||
return lfe->mi_displayname;
|
||||
if (lfe->lfe_fe_path)
|
||||
return lfe->lfe_fe_path;
|
||||
return "unknown";
|
||||
|
@ -891,7 +891,7 @@ linuxdvb_frontend_create0
|
|||
tvhlog(LOG_WARNING, "linuxdvb",
|
||||
"attempt to add network %s of wrong type %s to %s (%s)",
|
||||
dvb_type2str(ln->ln_type), ln->mn_network_name,
|
||||
lfe->lh_displayname, dvb_type2str(lfe->lfe_info.type));
|
||||
lfe->mi_displayname, dvb_type2str(lfe->lfe_info.type));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,12 +39,6 @@ linuxdvb_hardware_enumerate ( linuxdvb_hardware_list_t *list )
|
|||
return set;
|
||||
}
|
||||
|
||||
static const char *
|
||||
linuxdvb_hardware_class_get_title ( idnode_t *in )
|
||||
{
|
||||
return ((linuxdvb_hardware_t*)in)->lh_displayname;
|
||||
}
|
||||
|
||||
static idnode_set_t *
|
||||
linuxdvb_hardware_class_get_childs ( idnode_t *in )
|
||||
{
|
||||
|
@ -57,15 +51,8 @@ const idclass_t linuxdvb_hardware_class =
|
|||
.ic_super = &mpegts_input_class,
|
||||
.ic_class = "linuxdvb_hardware",
|
||||
.ic_caption = "LinuxDVB Hardware",
|
||||
.ic_get_title = linuxdvb_hardware_class_get_title,
|
||||
.ic_get_childs = linuxdvb_hardware_class_get_childs,
|
||||
.ic_properties = (const property_t[]){
|
||||
{
|
||||
.type = PT_STR,
|
||||
.id = "displayname",
|
||||
.name = "Name",
|
||||
.off = offsetof(linuxdvb_hardware_t, lh_displayname),
|
||||
},
|
||||
{}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -59,11 +59,6 @@ struct linuxdvb_hardware
|
|||
linuxdvb_hardware_t *lh_parent;
|
||||
LIST_ENTRY(linuxdvb_hardware) lh_parent_link;
|
||||
linuxdvb_hardware_list_t lh_children;
|
||||
|
||||
/*
|
||||
* Device info
|
||||
*/
|
||||
char *lh_displayname;
|
||||
};
|
||||
|
||||
extern const idclass_t linuxdvb_hardware_class;
|
||||
|
|
Loading…
Add table
Reference in a new issue