Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix changing tuner-type
  • Loading branch information
bfennema authored and perexg committed Oct 14, 2014
1 parent 21a8762 commit a78a83c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
47 changes: 38 additions & 9 deletions src/input/mpegts/tvhdhomerun/tvhdhomerun.c
Expand Up @@ -89,11 +89,43 @@ tvhdhomerun_device_class_override_set( void *obj, const void * p )
free(hd->hd_override_type);
hd->hd_override_type = strdup(p);
tvhlog(LOG_INFO, "tvhdhomerun", "Setting override_type : %s", hd->hd_override_type);
return 1;
}
}
return 0;
}

static void
tvhdhomerun_device_class_override_notify( void * obj )
{
tvhdhomerun_device_t *hd = obj;
tvhdhomerun_frontend_t *hfe;
dvb_fe_type_t type = dvb_str2type(hd->hd_override_type);
struct hdhomerun_discover_device_t discover_info;
unsigned int tuner;
htsmsg_t *conf;

conf = hts_settings_load("input/tvhdhomerun/adapters/%s", hd->hd_info.uuid);
if (conf)
conf = htsmsg_get_map(conf, "frontends");

lock_assert(&global_lock);

while ((hfe = TAILQ_FIRST(&hd->hd_frontends)) != NULL)
{
if (hfe->hf_type == type)
break;

discover_info.device_id = hdhomerun_device_get_device_id(hfe->hf_hdhomerun_tuner);
discover_info.ip_addr = hdhomerun_device_get_device_ip(hfe->hf_hdhomerun_tuner);
tuner = hfe->hf_tunerNumber;

tvhdhomerun_frontend_delete(hfe);

tvhdhomerun_frontend_create(hd, &discover_info, conf, type, tuner);
}
}

const idclass_t tvhdhomerun_device_class =
{
.ic_class = "tvhdhomerun_client",
Expand All @@ -118,10 +150,10 @@ const idclass_t tvhdhomerun_device_class =
},
{
.type = PT_STR,
.id = "device_id",
.id = "uuid",
.name = "UUID",
.opts = PO_RDONLY,
.off = offsetof(tvhdhomerun_device_t, hd_info.device_id),
.off = offsetof(tvhdhomerun_device_t, hd_info.uuid),
},
{
.type = PT_STR,
Expand All @@ -143,6 +175,7 @@ const idclass_t tvhdhomerun_device_class =
.name = "Network Type",
.opts = PO_ADVANCED,
.set = tvhdhomerun_device_class_override_set,
.notify = tvhdhomerun_device_class_override_notify,
.list = tvhdhomerun_device_class_override_enum,
.off = offsetof(tvhdhomerun_device_t, hd_type),
},
Expand Down Expand Up @@ -229,8 +262,7 @@ static void tvhdhomerun_device_create(struct hdhomerun_discover_device_t *dInfo)
int j, save = 0;
struct hdhomerun_device_t *hdhomerun_tuner;
dvb_fe_type_t type = DVB_TYPE_C;


struct in_addr ip_addr;

tvhdhomerun_device_calc_uuid(&uuid, dInfo->device_id);

Expand Down Expand Up @@ -281,11 +313,8 @@ static void tvhdhomerun_device_create(struct hdhomerun_discover_device_t *dInfo)
char fName[128];
snprintf(fName, 128, "HDHomeRun(%08X)",dInfo->device_id);

char buffer[32];
char *ipInt = (char*)&dInfo->ip_addr;
sprintf(buffer, "%u.%u.%u.%u", ipInt[3],ipInt[2],ipInt[1],ipInt[0]);

hd->hd_info.ip_address = strdup(buffer);
ip_addr.s_addr = htonl(dInfo->ip_addr);
hd->hd_info.ip_address = strdup(inet_ntoa(ip_addr));
hd->hd_info.uuid = strdup(uuid.hex);
hd->hd_info.friendlyname = strdup(fName);

Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c
Expand Up @@ -546,7 +546,7 @@ tvhdhomerun_frontend_create(tvhdhomerun_device_t *hd, struct hdhomerun_discover_
else if (type == DVB_TYPE_C)
idc = &tvhdhomerun_frontend_dvbc_class;
else if (type == DVB_TYPE_ATSC) {
idc = &tvhdhomerun_frontend_atsc_class;
idc = &tvhdhomerun_frontend_atsc_class;
} else {
tvherror("stvhdhomerun", "unknown FE type %d", type);
return NULL;
Expand Down
1 change: 0 additions & 1 deletion src/input/mpegts/tvhdhomerun/tvhdhomerun_private.h
Expand Up @@ -61,7 +61,6 @@ static struct hdhomerun_debug_t* hdhomerun_debug_obj = 0;
struct tvhdhomerun_device_info
{
char *ip_address; /* IP address */
uint32_t device_id;
char *friendlyname;
char *deviceModel;

Expand Down

0 comments on commit a78a83c

Please sign in to comment.