Skip to content

Commit

Permalink
Fix #8387. Update libmythhdhhomerun to version 20100519beta1. Brings …
Browse files Browse the repository at this point in the history
…us current on the HDHomeRun library. Please report any issues with this resync with a new ticket in trac. Specifically, we are looking for throrough testing of both physical tuners and multirec active at once. Thanks to Jafa at SiliconDust for providing the patch.

git-svn-id: http://svn.mythtv.org/svn/trunk@24741 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
Robert McNamara committed May 19, 2010
1 parent 7d17b8e commit baf36e4
Show file tree
Hide file tree
Showing 35 changed files with 1,989 additions and 949 deletions.
7 changes: 2 additions & 5 deletions mythtv/libs/libmythhdhomerun/hdhomerun.h
@@ -1,9 +1,7 @@
#ifndef __HDHOMERUN_INCLUDES__
#define __HDHOMERUN_INCLUDES__
/*
* hdhomerun.h
*
* Copyright © 2006-2008 Silicondust USA Inc. <www.silicondust.com>.
* Copyright © 2006-2010 Silicondust USA Inc. <www.silicondust.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -35,6 +33,7 @@
#include "hdhomerun_os.h"
#include "hdhomerun_types.h"
#include "hdhomerun_pkt.h"
#include "hdhomerun_sock.h"
#include "hdhomerun_debug.h"
#include "hdhomerun_discover.h"
#include "hdhomerun_control.h"
Expand All @@ -43,5 +42,3 @@
#include "hdhomerun_channelscan.h"
#include "hdhomerun_device.h"
#include "hdhomerun_device_selector.h"

#endif /* __HDHOMERUN_INCLUDES__ */
48 changes: 31 additions & 17 deletions mythtv/libs/libmythhdhomerun/hdhomerun_channels.c
@@ -1,7 +1,7 @@
/*
* hdhomerun_channels.c
*
* Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
* Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -55,7 +55,6 @@ struct hdhomerun_channelmap_range_t {
};

struct hdhomerun_channelmap_record_t {
const char *channelmap_prefix;
const char *channelmap;
const struct hdhomerun_channelmap_range_t *range_list;
const char *channelmap_scan_group;
Expand Down Expand Up @@ -140,30 +139,45 @@ static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_us_i
};

static const struct hdhomerun_channelmap_record_t hdhomerun_channelmap_table[] = {
{"au", "au-bcast", hdhomerun_channelmap_range_au_bcast, "au-bcast", "AU"},
{"au", "au-cable", hdhomerun_channelmap_range_au_cable, "au-cable", "AU"},
{"eu", "eu-bcast", hdhomerun_channelmap_range_eu_bcast, "eu-bcast", "EU"},
{"eu", "eu-cable", hdhomerun_channelmap_range_eu_cable, "eu-cable", "EU"},
{"tw", "tw-bcast", hdhomerun_channelmap_range_us_bcast, "tw-bcast", "TW"},
{"tw", "tw-cable", hdhomerun_channelmap_range_us_cable, "tw-cable", "TW"},
{"us", "us-bcast", hdhomerun_channelmap_range_us_bcast, "us-bcast", "CA US"},
{"us", "us-cable", hdhomerun_channelmap_range_us_cable, "us-cable us-hrc us-irc", "CA US"},
{"us", "us-hrc", hdhomerun_channelmap_range_us_hrc , "us-cable us-hrc us-irc", "CA US"},
{"us", "us-irc", hdhomerun_channelmap_range_us_irc, "us-cable us-hrc us-irc", "CA US"},
{NULL, NULL, NULL, NULL, NULL}
{"au-bcast", hdhomerun_channelmap_range_au_bcast, "au-bcast", "AU"},
{"au-cable", hdhomerun_channelmap_range_au_cable, "au-cable", "AU"},
{"eu-bcast", hdhomerun_channelmap_range_eu_bcast, "eu-bcast", "EU PA"},
{"eu-cable", hdhomerun_channelmap_range_eu_cable, "eu-cable", "EU"},
{"tw-bcast", hdhomerun_channelmap_range_us_bcast, "tw-bcast", "TW"},
{"tw-cable", hdhomerun_channelmap_range_us_cable, "tw-cable", "TW"},

{"us-bcast", hdhomerun_channelmap_range_us_bcast, "us-bcast", "CA US"},
{"us-cable", hdhomerun_channelmap_range_us_cable, "us-cable us-hrc us-irc", "CA PA US"},
{"us-hrc", hdhomerun_channelmap_range_us_hrc , "us-cable us-hrc us-irc", "CA PA US"},
{"us-irc", hdhomerun_channelmap_range_us_irc, "us-cable us-hrc us-irc", "CA PA US"},

{NULL, NULL, NULL, NULL}
};

const char *hdhomerun_channelmap_convert_countrycode_to_channelmap_prefix(const char *countrycode)
const char *hdhomerun_channelmap_get_channelmap_from_country_source(const char *countrycode, const char *source)
{
bool_t country_found = FALSE;

const struct hdhomerun_channelmap_record_t *record = hdhomerun_channelmap_table;
while (record->channelmap) {
if (strstr(record->countrycodes, countrycode)) {
return record->channelmap_prefix;
if (!strstr(record->countrycodes, countrycode)) {
record++;
continue;
}

if (strstr(record->channelmap, source)) {
return record->channelmap;
}

country_found = TRUE;
record++;
}

return "eu";
if (!country_found) {
return hdhomerun_channelmap_get_channelmap_from_country_source("EU", source);
}

return NULL;
}

const char *hdhomerun_channelmap_get_channelmap_scan_group(const char *channelmap)
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythhdhomerun/hdhomerun_channels.h
@@ -1,7 +1,7 @@
/*
* hdhomerun_channels.h
*
* Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
* Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -37,7 +37,7 @@ extern "C" {
struct hdhomerun_channel_entry_t;
struct hdhomerun_channel_list_t;

extern LIBTYPE const char *hdhomerun_channelmap_convert_countrycode_to_channelmap_prefix(const char *countrycode);
extern LIBTYPE const char *hdhomerun_channelmap_get_channelmap_from_country_source(const char *countrycode, const char *source);
extern LIBTYPE const char *hdhomerun_channelmap_get_channelmap_scan_group(const char *channelmap);

extern LIBTYPE uint8_t hdhomerun_channel_entry_channel_number(struct hdhomerun_channel_entry_t *entry);
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythhdhomerun/hdhomerun_channelscan.c
@@ -1,7 +1,7 @@
/*
* hdhomerun_channelscan.c
*
* Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
* Copyright © 2007-2010 Silicondust USA Inc. <www.silicondust.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -99,7 +99,7 @@ static int channelscan_find_lock(struct hdhomerun_channelscan_t *scan, uint32_t
return 1;
}

msleep(250);
msleep_approx(250);
}
}

Expand Down Expand Up @@ -303,7 +303,7 @@ int channelscan_detect(struct hdhomerun_channelscan_t *scan, struct hdhomerun_ch
break;
}

msleep(250);
msleep_approx(250);
}

/* Lock => skip overlapping channels. */
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythhdhomerun/hdhomerun_channelscan.h
@@ -1,7 +1,7 @@
/*
* hdhomerun_channelscan.h
*
* Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
* Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down
83 changes: 60 additions & 23 deletions mythtv/libs/libmythhdhomerun/hdhomerun_config.c
@@ -1,7 +1,7 @@
/*
* hdhomerun_config.c
*
* Copyright © 2006-2008 Silicondust USA Inc. <www.silicondust.com>.
* Copyright © 2006-2008 Silicondust USA Inc. <www.silicondust.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -202,11 +202,30 @@ static int cmd_set(const char *item, const char *value)
return cmd_set_internal(item, value);
}

static bool_t sigabort = FALSE;
static volatile sig_atomic_t sigabort_flag = FALSE;
static volatile sig_atomic_t siginfo_flag = FALSE;

static void sigabort_handler(int arg)
{
sigabort_flag = TRUE;
}

static void signal_abort(int arg)
static void siginfo_handler(int arg)
{
sigabort = TRUE;
siginfo_flag = TRUE;
}

static void register_signal_handlers(sig_t sigpipe_handler, sig_t sigint_handler, sig_t siginfo_handler)
{
#if defined(SIGPIPE)
signal(SIGPIPE, sigpipe_handler);
#endif
#if defined(SIGINT)
signal(SIGINT, sigint_handler);
#endif
#if defined(SIGINFO)
signal(SIGINFO, siginfo_handler);
#endif
}

static void cmd_scan_printf(FILE *fp, const char *fmt, ...)
Expand Down Expand Up @@ -274,19 +293,18 @@ static int cmd_scan(const char *tuner_str, const char *filename)
}
}

signal(SIGINT, signal_abort);
signal(SIGPIPE, signal_abort);
register_signal_handlers(sigabort_handler, sigabort_handler, siginfo_handler);

int ret = 0;
while (!sigabort) {
while (!sigabort_flag) {
struct hdhomerun_channelscan_result_t result;
ret = hdhomerun_device_channelscan_advance(hd, &result);
if (ret <= 0) {
break;
}

cmd_scan_printf(fp, "SCANNING: %lu (%s)\n",
result.frequency, result.channel_str
(unsigned long)result.frequency, result.channel_str
);

ret = hdhomerun_device_channelscan_detect(hd, &result);
Expand Down Expand Up @@ -321,6 +339,20 @@ static int cmd_scan(const char *tuner_str, const char *filename)
return ret;
}

static void cmd_save_print_stats(void)
{
struct hdhomerun_video_stats_t stats;
hdhomerun_device_get_video_stats(hd, &stats);

fprintf(stderr, "%u packets received, %u overflow errors, %u network errors, %u transport errors, %u sequence errors\n",
(unsigned int)stats.packet_count,
(unsigned int)stats.overflow_error_count,
(unsigned int)stats.network_error_count,
(unsigned int)stats.transport_error_count,
(unsigned int)stats.sequence_error_count
);
}

static int cmd_save(const char *tuner_str, const char *filename)
{
if (hdhomerun_device_set_tuner_from_str(hd, tuner_str) <= 0) {
Expand Down Expand Up @@ -350,21 +382,26 @@ static int cmd_save(const char *tuner_str, const char *filename)
return ret;
}

signal(SIGINT, signal_abort);
signal(SIGPIPE, signal_abort);
register_signal_handlers(sigabort_handler, sigabort_handler, siginfo_handler);

struct hdhomerun_video_stats_t stats_old, stats_cur;
hdhomerun_device_get_video_stats(hd, &stats_old);

uint64_t next_progress = getcurrenttime() + 1000;

while (!sigabort) {
while (!sigabort_flag) {
uint64_t loop_start_time = getcurrenttime();

if (siginfo_flag) {
fprintf(stderr, "\n");
cmd_save_print_stats();
siginfo_flag = FALSE;
}

size_t actual_size;
uint8_t *ptr = hdhomerun_device_stream_recv(hd, VIDEO_DATA_BUFFER_SIZE_1S, &actual_size);
if (!ptr) {
msleep(64);
msleep_approx(64);
continue;
}

Expand All @@ -381,6 +418,12 @@ static int cmd_save(const char *tuner_str, const char *filename)
next_progress = loop_start_time + 1000;
}

/* Windows - indicate activity to suppress auto sleep mode. */
#if defined(__WINDOWS__)
SetThreadExecutionState(ES_SYSTEM_REQUIRED);
#endif

/* Video stats. */
hdhomerun_device_get_video_stats(hd, &stats_cur);

if (stats_cur.overflow_error_count > stats_old.overflow_error_count) {
Expand All @@ -404,24 +447,18 @@ static int cmd_save(const char *tuner_str, const char *filename)
continue;
}

msleep(delay);
msleep_approx(delay);
}

if (fp) {
fclose(fp);
}

hdhomerun_device_stream_stop(hd);
hdhomerun_device_get_video_stats(hd, &stats_cur);

fprintf(stderr, "\n");
fprintf(stderr, "-- Video statistics --\n");
fprintf(stderr, "%u packets received, %u overflow errors, %u network errors, %u transport errors, %u sequence errors\n",
(unsigned int)stats_cur.packet_count,
(unsigned int)stats_cur.overflow_error_count,
(unsigned int)stats_cur.network_error_count,
(unsigned int)stats_cur.transport_error_count,
(unsigned int)stats_cur.sequence_error_count);
cmd_save_print_stats();

return 0;
}
Expand All @@ -440,10 +477,10 @@ static int cmd_upgrade(const char *filename)
fclose(fp);
return -1;
}
sleep(2);
msleep_minimum(2000);

printf("upgrading firmware...\n");
sleep(8);
msleep_minimum(8000);

printf("rebooting...\n");
int count = 0;
Expand All @@ -460,7 +497,7 @@ static int cmd_upgrade(const char *filename)
return -1;
}

sleep(1);
msleep_minimum(1000);
}

printf("upgrade complete - now running firmware %s\n", version_str);
Expand Down

0 comments on commit baf36e4

Please sign in to comment.