Skip to content
Permalink
Browse files

Fix #8387. Update libmythhdhhomerun to version 20100519beta1. Brings …

…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
Robert McNamara committed May 19, 2010
1 parent 7d17b8e commit baf36e4bab565413c8ca3a4738fc7cf51e0e8a4f
Showing with 1,989 additions and 949 deletions.
  1. +2 −5 mythtv/libs/libmythhdhomerun/hdhomerun.h
  2. +31 −17 mythtv/libs/libmythhdhomerun/hdhomerun_channels.c
  3. +2 −2 mythtv/libs/libmythhdhomerun/hdhomerun_channels.h
  4. +3 −3 mythtv/libs/libmythhdhomerun/hdhomerun_channelscan.c
  5. +1 −1 mythtv/libs/libmythhdhomerun/hdhomerun_channelscan.h
  6. +60 −23 mythtv/libs/libmythhdhomerun/hdhomerun_config.c
  7. +47 −69 mythtv/libs/libmythhdhomerun/hdhomerun_control.c
  8. +1 −1 mythtv/libs/libmythhdhomerun/hdhomerun_control.h
  9. +25 −35 mythtv/libs/libmythhdhomerun/hdhomerun_debug.c
  10. +1 −1 mythtv/libs/libmythhdhomerun/hdhomerun_debug.h
  11. +382 −88 mythtv/libs/libmythhdhomerun/hdhomerun_device.c
  12. +9 −22 mythtv/libs/libmythhdhomerun/hdhomerun_device.h
  13. +19 −17 mythtv/libs/libmythhdhomerun/hdhomerun_device_selector.c
  14. +8 −2 mythtv/libs/libmythhdhomerun/hdhomerun_device_selector.h
  15. +0 −252 mythtv/libs/libmythhdhomerun/hdhomerun_dhcp.c
  16. +0 −44 mythtv/libs/libmythhdhomerun/hdhomerun_dhcp.h
  17. +120 −135 mythtv/libs/libmythhdhomerun/hdhomerun_discover.c
  18. +20 −3 mythtv/libs/libmythhdhomerun/hdhomerun_discover.h
  19. +1 −1 mythtv/libs/libmythhdhomerun/hdhomerun_os.h
  20. +89 −0 mythtv/libs/libmythhdhomerun/hdhomerun_os_posix.c
  21. +11 −36 mythtv/libs/libmythhdhomerun/hdhomerun_os_posix.h
  22. +135 −0 mythtv/libs/libmythhdhomerun/hdhomerun_os_windows.c
  23. +19 −102 mythtv/libs/libmythhdhomerun/hdhomerun_os_windows.h
  24. +1 −1 mythtv/libs/libmythhdhomerun/hdhomerun_pkt.c
  25. +1 −1 mythtv/libs/libmythhdhomerun/hdhomerun_pkt.h
  26. +62 −0 mythtv/libs/libmythhdhomerun/hdhomerun_sock.h
  27. +414 −0 mythtv/libs/libmythhdhomerun/hdhomerun_sock_posix.c
  28. +347 −0 mythtv/libs/libmythhdhomerun/hdhomerun_sock_windows.c
  29. +1 −1 mythtv/libs/libmythhdhomerun/hdhomerun_types.h
  30. +107 −66 mythtv/libs/libmythhdhomerun/hdhomerun_video.c
  31. +12 −1 mythtv/libs/libmythhdhomerun/hdhomerun_video.h
  32. +10 −6 mythtv/libs/libmythhdhomerun/libmythhdhomerun.pro
  33. +7 −7 mythtv/libs/libmythtv/hdhrchannel.cpp
  34. +29 −5 mythtv/libs/libmythtv/hdhrstreamhandler.cpp
  35. +12 −2 mythtv/libs/libmythtv/hdhrstreamhandler.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
@@ -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"
@@ -43,5 +42,3 @@
#include "hdhomerun_channelscan.h"
#include "hdhomerun_device.h"
#include "hdhomerun_device_selector.h"

#endif /* __HDHOMERUN_INCLUDES__ */
@@ -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
@@ -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;
@@ -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)
@@ -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
@@ -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);
@@ -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
@@ -99,7 +99,7 @@ static int channelscan_find_lock(struct hdhomerun_channelscan_t *scan, uint32_t
return 1;
}

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

@@ -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. */
@@ -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
@@ -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
@@ -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, ...)
@@ -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);
@@ -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) {
@@ -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;
}

@@ -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) {
@@ -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;
}
@@ -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;
@@ -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);

0 comments on commit baf36e4

Please sign in to comment.
You can’t perform that action at this time.