Skip to content

Commit baf36e4

Browse files
author
Robert McNamara
committed
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
1 parent 7d17b8e commit baf36e4

35 files changed

+1989
-949
lines changed

Diff for: mythtv/libs/libmythhdhomerun/hdhomerun.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
#ifndef __HDHOMERUN_INCLUDES__
2-
#define __HDHOMERUN_INCLUDES__
31
/*
42
* hdhomerun.h
53
*
6-
* Copyright © 2006-2008 Silicondust USA Inc. <www.silicondust.com>.
4+
* Copyright © 2006-2010 Silicondust USA Inc. <www.silicondust.com>.
75
*
86
* This library is free software; you can redistribute it and/or
97
* modify it under the terms of the GNU Lesser General Public
@@ -35,6 +33,7 @@
3533
#include "hdhomerun_os.h"
3634
#include "hdhomerun_types.h"
3735
#include "hdhomerun_pkt.h"
36+
#include "hdhomerun_sock.h"
3837
#include "hdhomerun_debug.h"
3938
#include "hdhomerun_discover.h"
4039
#include "hdhomerun_control.h"
@@ -43,5 +42,3 @@
4342
#include "hdhomerun_channelscan.h"
4443
#include "hdhomerun_device.h"
4544
#include "hdhomerun_device_selector.h"
46-
47-
#endif /* __HDHOMERUN_INCLUDES__ */

Diff for: mythtv/libs/libmythhdhomerun/hdhomerun_channels.c

+31-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* hdhomerun_channels.c
33
*
4-
* Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
4+
* Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
55
*
66
* This library is free software; you can redistribute it and/or
77
* modify it under the terms of the GNU Lesser General Public
@@ -55,7 +55,6 @@ struct hdhomerun_channelmap_range_t {
5555
};
5656

5757
struct hdhomerun_channelmap_record_t {
58-
const char *channelmap_prefix;
5958
const char *channelmap;
6059
const struct hdhomerun_channelmap_range_t *range_list;
6160
const char *channelmap_scan_group;
@@ -140,30 +139,45 @@ static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_us_i
140139
};
141140

142141
static const struct hdhomerun_channelmap_record_t hdhomerun_channelmap_table[] = {
143-
{"au", "au-bcast", hdhomerun_channelmap_range_au_bcast, "au-bcast", "AU"},
144-
{"au", "au-cable", hdhomerun_channelmap_range_au_cable, "au-cable", "AU"},
145-
{"eu", "eu-bcast", hdhomerun_channelmap_range_eu_bcast, "eu-bcast", "EU"},
146-
{"eu", "eu-cable", hdhomerun_channelmap_range_eu_cable, "eu-cable", "EU"},
147-
{"tw", "tw-bcast", hdhomerun_channelmap_range_us_bcast, "tw-bcast", "TW"},
148-
{"tw", "tw-cable", hdhomerun_channelmap_range_us_cable, "tw-cable", "TW"},
149-
{"us", "us-bcast", hdhomerun_channelmap_range_us_bcast, "us-bcast", "CA US"},
150-
{"us", "us-cable", hdhomerun_channelmap_range_us_cable, "us-cable us-hrc us-irc", "CA US"},
151-
{"us", "us-hrc", hdhomerun_channelmap_range_us_hrc , "us-cable us-hrc us-irc", "CA US"},
152-
{"us", "us-irc", hdhomerun_channelmap_range_us_irc, "us-cable us-hrc us-irc", "CA US"},
153-
{NULL, NULL, NULL, NULL, NULL}
142+
{"au-bcast", hdhomerun_channelmap_range_au_bcast, "au-bcast", "AU"},
143+
{"au-cable", hdhomerun_channelmap_range_au_cable, "au-cable", "AU"},
144+
{"eu-bcast", hdhomerun_channelmap_range_eu_bcast, "eu-bcast", "EU PA"},
145+
{"eu-cable", hdhomerun_channelmap_range_eu_cable, "eu-cable", "EU"},
146+
{"tw-bcast", hdhomerun_channelmap_range_us_bcast, "tw-bcast", "TW"},
147+
{"tw-cable", hdhomerun_channelmap_range_us_cable, "tw-cable", "TW"},
148+
149+
{"us-bcast", hdhomerun_channelmap_range_us_bcast, "us-bcast", "CA US"},
150+
{"us-cable", hdhomerun_channelmap_range_us_cable, "us-cable us-hrc us-irc", "CA PA US"},
151+
{"us-hrc", hdhomerun_channelmap_range_us_hrc , "us-cable us-hrc us-irc", "CA PA US"},
152+
{"us-irc", hdhomerun_channelmap_range_us_irc, "us-cable us-hrc us-irc", "CA PA US"},
153+
154+
{NULL, NULL, NULL, NULL}
154155
};
155156

156-
const char *hdhomerun_channelmap_convert_countrycode_to_channelmap_prefix(const char *countrycode)
157+
const char *hdhomerun_channelmap_get_channelmap_from_country_source(const char *countrycode, const char *source)
157158
{
159+
bool_t country_found = FALSE;
160+
158161
const struct hdhomerun_channelmap_record_t *record = hdhomerun_channelmap_table;
159162
while (record->channelmap) {
160-
if (strstr(record->countrycodes, countrycode)) {
161-
return record->channelmap_prefix;
163+
if (!strstr(record->countrycodes, countrycode)) {
164+
record++;
165+
continue;
166+
}
167+
168+
if (strstr(record->channelmap, source)) {
169+
return record->channelmap;
162170
}
171+
172+
country_found = TRUE;
163173
record++;
164174
}
165175

166-
return "eu";
176+
if (!country_found) {
177+
return hdhomerun_channelmap_get_channelmap_from_country_source("EU", source);
178+
}
179+
180+
return NULL;
167181
}
168182

169183
const char *hdhomerun_channelmap_get_channelmap_scan_group(const char *channelmap)

Diff for: mythtv/libs/libmythhdhomerun/hdhomerun_channels.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* hdhomerun_channels.h
33
*
4-
* Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
4+
* Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
55
*
66
* This library is free software; you can redistribute it and/or
77
* modify it under the terms of the GNU Lesser General Public
@@ -37,7 +37,7 @@ extern "C" {
3737
struct hdhomerun_channel_entry_t;
3838
struct hdhomerun_channel_list_t;
3939

40-
extern LIBTYPE const char *hdhomerun_channelmap_convert_countrycode_to_channelmap_prefix(const char *countrycode);
40+
extern LIBTYPE const char *hdhomerun_channelmap_get_channelmap_from_country_source(const char *countrycode, const char *source);
4141
extern LIBTYPE const char *hdhomerun_channelmap_get_channelmap_scan_group(const char *channelmap);
4242

4343
extern LIBTYPE uint8_t hdhomerun_channel_entry_channel_number(struct hdhomerun_channel_entry_t *entry);

Diff for: mythtv/libs/libmythhdhomerun/hdhomerun_channelscan.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* hdhomerun_channelscan.c
33
*
4-
* Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
4+
* Copyright © 2007-2010 Silicondust USA Inc. <www.silicondust.com>.
55
*
66
* This library is free software; you can redistribute it and/or
77
* 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
9999
return 1;
100100
}
101101

102-
msleep(250);
102+
msleep_approx(250);
103103
}
104104
}
105105

@@ -303,7 +303,7 @@ int channelscan_detect(struct hdhomerun_channelscan_t *scan, struct hdhomerun_ch
303303
break;
304304
}
305305

306-
msleep(250);
306+
msleep_approx(250);
307307
}
308308

309309
/* Lock => skip overlapping channels. */

Diff for: mythtv/libs/libmythhdhomerun/hdhomerun_channelscan.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* hdhomerun_channelscan.h
33
*
4-
* Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
4+
* Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
55
*
66
* This library is free software; you can redistribute it and/or
77
* modify it under the terms of the GNU Lesser General Public

Diff for: mythtv/libs/libmythhdhomerun/hdhomerun_config.c

+60-23
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* hdhomerun_config.c
33
*
4-
* Copyright © 2006-2008 Silicondust USA Inc. <www.silicondust.com>.
4+
* Copyright © 2006-2008 Silicondust USA Inc. <www.silicondust.com>.
55
*
66
* This library is free software; you can redistribute it and/or
77
* 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)
202202
return cmd_set_internal(item, value);
203203
}
204204

205-
static bool_t sigabort = FALSE;
205+
static volatile sig_atomic_t sigabort_flag = FALSE;
206+
static volatile sig_atomic_t siginfo_flag = FALSE;
207+
208+
static void sigabort_handler(int arg)
209+
{
210+
sigabort_flag = TRUE;
211+
}
206212

207-
static void signal_abort(int arg)
213+
static void siginfo_handler(int arg)
208214
{
209-
sigabort = TRUE;
215+
siginfo_flag = TRUE;
216+
}
217+
218+
static void register_signal_handlers(sig_t sigpipe_handler, sig_t sigint_handler, sig_t siginfo_handler)
219+
{
220+
#if defined(SIGPIPE)
221+
signal(SIGPIPE, sigpipe_handler);
222+
#endif
223+
#if defined(SIGINT)
224+
signal(SIGINT, sigint_handler);
225+
#endif
226+
#if defined(SIGINFO)
227+
signal(SIGINFO, siginfo_handler);
228+
#endif
210229
}
211230

212231
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)
274293
}
275294
}
276295

277-
signal(SIGINT, signal_abort);
278-
signal(SIGPIPE, signal_abort);
296+
register_signal_handlers(sigabort_handler, sigabort_handler, siginfo_handler);
279297

280298
int ret = 0;
281-
while (!sigabort) {
299+
while (!sigabort_flag) {
282300
struct hdhomerun_channelscan_result_t result;
283301
ret = hdhomerun_device_channelscan_advance(hd, &result);
284302
if (ret <= 0) {
285303
break;
286304
}
287305

288306
cmd_scan_printf(fp, "SCANNING: %lu (%s)\n",
289-
result.frequency, result.channel_str
307+
(unsigned long)result.frequency, result.channel_str
290308
);
291309

292310
ret = hdhomerun_device_channelscan_detect(hd, &result);
@@ -321,6 +339,20 @@ static int cmd_scan(const char *tuner_str, const char *filename)
321339
return ret;
322340
}
323341

342+
static void cmd_save_print_stats(void)
343+
{
344+
struct hdhomerun_video_stats_t stats;
345+
hdhomerun_device_get_video_stats(hd, &stats);
346+
347+
fprintf(stderr, "%u packets received, %u overflow errors, %u network errors, %u transport errors, %u sequence errors\n",
348+
(unsigned int)stats.packet_count,
349+
(unsigned int)stats.overflow_error_count,
350+
(unsigned int)stats.network_error_count,
351+
(unsigned int)stats.transport_error_count,
352+
(unsigned int)stats.sequence_error_count
353+
);
354+
}
355+
324356
static int cmd_save(const char *tuner_str, const char *filename)
325357
{
326358
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)
350382
return ret;
351383
}
352384

353-
signal(SIGINT, signal_abort);
354-
signal(SIGPIPE, signal_abort);
385+
register_signal_handlers(sigabort_handler, sigabort_handler, siginfo_handler);
355386

356387
struct hdhomerun_video_stats_t stats_old, stats_cur;
357388
hdhomerun_device_get_video_stats(hd, &stats_old);
358389

359390
uint64_t next_progress = getcurrenttime() + 1000;
360391

361-
while (!sigabort) {
392+
while (!sigabort_flag) {
362393
uint64_t loop_start_time = getcurrenttime();
363394

395+
if (siginfo_flag) {
396+
fprintf(stderr, "\n");
397+
cmd_save_print_stats();
398+
siginfo_flag = FALSE;
399+
}
400+
364401
size_t actual_size;
365402
uint8_t *ptr = hdhomerun_device_stream_recv(hd, VIDEO_DATA_BUFFER_SIZE_1S, &actual_size);
366403
if (!ptr) {
367-
msleep(64);
404+
msleep_approx(64);
368405
continue;
369406
}
370407

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

421+
/* Windows - indicate activity to suppress auto sleep mode. */
422+
#if defined(__WINDOWS__)
423+
SetThreadExecutionState(ES_SYSTEM_REQUIRED);
424+
#endif
425+
426+
/* Video stats. */
384427
hdhomerun_device_get_video_stats(hd, &stats_cur);
385428

386429
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)
404447
continue;
405448
}
406449

407-
msleep(delay);
450+
msleep_approx(delay);
408451
}
409452

410453
if (fp) {
411454
fclose(fp);
412455
}
413456

414457
hdhomerun_device_stream_stop(hd);
415-
hdhomerun_device_get_video_stats(hd, &stats_cur);
416458

417459
fprintf(stderr, "\n");
418460
fprintf(stderr, "-- Video statistics --\n");
419-
fprintf(stderr, "%u packets received, %u overflow errors, %u network errors, %u transport errors, %u sequence errors\n",
420-
(unsigned int)stats_cur.packet_count,
421-
(unsigned int)stats_cur.overflow_error_count,
422-
(unsigned int)stats_cur.network_error_count,
423-
(unsigned int)stats_cur.transport_error_count,
424-
(unsigned int)stats_cur.sequence_error_count);
461+
cmd_save_print_stats();
425462

426463
return 0;
427464
}
@@ -440,10 +477,10 @@ static int cmd_upgrade(const char *filename)
440477
fclose(fp);
441478
return -1;
442479
}
443-
sleep(2);
480+
msleep_minimum(2000);
444481

445482
printf("upgrading firmware...\n");
446-
sleep(8);
483+
msleep_minimum(8000);
447484

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

463-
sleep(1);
500+
msleep_minimum(1000);
464501
}
465502

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

0 commit comments

Comments
 (0)