summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY3
-rw-r--r--siinfo.c35
-rw-r--r--ttxtsubs.c8
3 files changed, 43 insertions, 3 deletions
diff --git a/HISTORY b/HISTORY
index a38ae75..954350d 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,6 +1,9 @@
VDR Plugin 'ttxtsubs' Revision History
--------------------------------------
+2003-04-28: Version 0.0.1b
+- Timeout on SI table reads
+
2003-03-07: Version 0.0.1
- Initial revision.
diff --git a/siinfo.c b/siinfo.c
index f878be7..8e91069 100644
--- a/siinfo.c
+++ b/siinfo.c
@@ -12,6 +12,7 @@
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include "linux/dvb/dmx.h"
#include "siinfo.h"
@@ -115,6 +116,29 @@ static int SetSectFilt(int fd, uint16_t pid, uint8_t tnr, uint8_t mask)
}
+static int
+read_timeout(int fd, void *buf, size_t count, int timeout_ms) {
+ int ret = -1;
+ struct pollfd pi;
+
+ pi.fd = fd;
+ pi.events = POLLIN | POLLERR | POLLHUP | POLLNVAL;
+
+ ret = poll(&pi, 1, timeout_ms);
+ if(ret < 0)
+ return errno;
+ if(ret == 0) { // timeout
+ fprintf(stderr, "ttxtsubs: read: timeout!\n");
+ return -1;
+ }
+
+ if(pi.revents == POLLIN) {
+ ret = read(fd, buf, count);
+ return ret;
+ } else
+ return -1;
+}
+
/*
* PID - pid to collect on
* table_id - table id to filter out (H.222.0 table 2-26)
@@ -132,6 +156,7 @@ static int CollectSections(int card_no, int pid, int table_id, char **sects, int
char *p = NULL;
int n;
char name[100];
+ time_t start_time;
snprintf(name, sizeof(name), "/dev/dvb/adapter%d/demux0", card_no);
@@ -147,14 +172,22 @@ static int CollectSections(int card_no, int pid, int table_id, char **sects, int
goto bail;
}
+ start_time = time(NULL);
+
do {
struct sect_header *h;
int i;
+ if((start_time + 5) < time(NULL)) {
+ ret = -1;
+ done = 1;
+ break;
+ }
+
if(p == NULL)
p = (char *) malloc(SECTSIZE);
- n = read(fd, p, SECTSIZE);
+ n = read_timeout(fd, p, SECTSIZE, 250);
if(n < 8)
continue;
diff --git a/ttxtsubs.c b/ttxtsubs.c
index da9c2f1..8b76848 100644
--- a/ttxtsubs.c
+++ b/ttxtsubs.c
@@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
- * $Id: ttxtsubs.c,v 1.11 2003/03/07 05:52:58 ragge Exp $
+ * $Id: ttxtsubs.c,v 1.11 2003/03/07 05:52:58 ragge Exp ragge $
*/
#include <vdr/plugin.h>
@@ -18,7 +18,7 @@
#include "siinfo.h"
#include "ttxtsubs.h"
-static const char *VERSION = "0.0.1";
+static const char *VERSION = "0.0.1b";
static const char *DESCRIPTION = "Teletext subtitles";
//static const char *MAINMENUENTRY = "Ttxtsubs";
@@ -264,6 +264,10 @@ void cPluginTtxtsubs::StartTtxtLive(const cDevice *Device, int pid, int page)
{
//dprint("cPluginTtxtsubs::StartTtxtLive\n");
+#if 0
+ return; // XXX TEST - No live subs
+#endif
+
if(!mRec) {
cTtxtSubsLiveReceiver *r;
//dprint("teletext subtitles started on pid %d\n", pid);