Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mpegts: consolidate dvb network class lookup
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
  • Loading branch information
swegener authored and perexg committed Nov 9, 2015
1 parent ea0983b commit 0e8a933
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
3 changes: 3 additions & 0 deletions src/input/mpegts/mpegts_dvb.h
Expand Up @@ -56,6 +56,9 @@ void dvb_network_done ( void );
static inline dvb_network_t *dvb_network_find_by_uuid(const char *uuid)
{ return idnode_find(uuid, &dvb_network_class, NULL); }

const idclass_t *dvb_network_class_by_fe_type(dvb_fe_type_t type);
dvb_fe_type_t dvb_fe_type_by_network_class(const idclass_t *idc);

dvb_network_t *dvb_network_create0
( const char *uuid, const idclass_t *idc, htsmsg_t *conf );

Expand Down
37 changes: 29 additions & 8 deletions src/input/mpegts/mpegts_network_dvb.c
Expand Up @@ -604,14 +604,7 @@ dvb_network_create0
const char *s;

ln = calloc(1, sizeof(dvb_network_t));
if (idc == &dvb_network_dvbt_class)
ln->ln_type = DVB_TYPE_T;
else if (idc == &dvb_network_dvbc_class)
ln->ln_type = DVB_TYPE_C;
else if (idc == &dvb_network_dvbs_class)
ln->ln_type = DVB_TYPE_S;
else
ln->ln_type = DVB_TYPE_ATSC;
ln->ln_type = dvb_fe_type_by_network_class(idc);

/* Create */
if (!(ln = (dvb_network_t*)mpegts_network_create0((void*)ln,
Expand Down Expand Up @@ -717,6 +710,34 @@ void dvb_network_done ( void )
* Search
* ***************************************************************************/

const idclass_t *dvb_network_class_by_fe_type(dvb_fe_type_t type)
{
if (type == DVB_TYPE_T)
return &dvb_network_dvbt_class;
else if (type == DVB_TYPE_C)
return &dvb_network_dvbc_class;
else if (type == DVB_TYPE_S)
return &dvb_network_dvbs_class;
else if (type == DVB_TYPE_ATSC)
return &dvb_network_atsc_class;

return NULL;
}

dvb_fe_type_t dvb_fe_type_by_network_class(const idclass_t *idc)
{
if (idc == &dvb_network_dvbt_class)
return DVB_TYPE_T;
else if (idc == &dvb_network_dvbc_class)
return DVB_TYPE_C;
else if (idc == &dvb_network_dvbs_class)
return DVB_TYPE_S;
else if (idc == &dvb_network_atsc_class)
return DVB_TYPE_ATSC;

return DVB_TYPE_NONE;
}

int dvb_network_get_orbital_pos(mpegts_network_t *mn)
{
dvb_network_t *ln = (dvb_network_t *)mn;
Expand Down
8 changes: 1 addition & 7 deletions src/input/mpegts/satip/satip_frontend.c
Expand Up @@ -1717,13 +1717,7 @@ satip_frontend_create
if (type == DVB_TYPE_S)
idc = master ? &satip_frontend_dvbs_slave_class :
&satip_frontend_dvbs_class;
else if (type == DVB_TYPE_T)
idc = &satip_frontend_dvbt_class;
else if (type == DVB_TYPE_C)
idc = &satip_frontend_dvbc_class;
else if (type == DVB_TYPE_ATSC)
idc = &satip_frontend_atsc_class;
else {
else if (!(idc = dvb_network_class_by_fe_type(type))) {

This comment has been minimized.

Copy link
@perexg

perexg Nov 11, 2015

Contributor

Uff. You cannot use this fcn - it does return different class. Reverted in b5184b2 . Four issues filled.

tvherror("satip", "unknown FE type %d", type);
return NULL;
}
Expand Down
8 changes: 1 addition & 7 deletions src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c
Expand Up @@ -632,13 +632,7 @@ tvhdhomerun_frontend_create(tvhdhomerun_device_t *hd, struct hdhomerun_discover_
uuid = htsmsg_get_str(conf, "uuid");

/* Class */
if (type == DVB_TYPE_T)
idc = &tvhdhomerun_frontend_dvbt_class;
else if (type == DVB_TYPE_C)
idc = &tvhdhomerun_frontend_dvbc_class;
else if (type == DVB_TYPE_ATSC) {
idc = &tvhdhomerun_frontend_atsc_class;
} else {
if (!(idc = dvb_network_class_by_fe_type(type))) {

This comment has been minimized.

Copy link
@perexg

perexg Nov 11, 2015

Contributor

Also different class...

tvherror("stvhdhomerun", "unknown FE type %d", type);
return NULL;
}
Expand Down

0 comments on commit 0e8a933

Please sign in to comment.