diff options
author | Tobias Grimm <tobias@e-tobi.loc> | 2008-12-13 10:38:16 +0100 |
---|---|---|
committer | Tobias Grimm <tobias@e-tobi.loc> | 2008-12-13 10:38:16 +0100 |
commit | d4d170b1fefd4b54137a3d37e0a090cae6558d51 (patch) | |
tree | 35a04ff06947988aa0f9c0e8b2bcedcef12b31e7 | |
parent | 76ac85e366bfc27b3b688a4f13031c0735ea2436 (diff) | |
download | vdr-plugin-ttxtsubs-0.0.1b.tar.gz vdr-plugin-ttxtsubs-0.0.1b.tar.bz2 |
- Timeout on SI table readsv0.0.1b
-rw-r--r-- | HISTORY | 3 | ||||
-rw-r--r-- | siinfo.c | 35 | ||||
-rw-r--r-- | ttxtsubs.c | 8 |
3 files changed, 43 insertions, 3 deletions
@@ -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. @@ -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; @@ -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); |