From 8f9cc68f76c4fd0960f919a77fb16a6455922deb Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 29 Jul 2001 18:00:00 +0200 Subject: =?UTF-8?q?Version=200.85=20-=20Added=20Norwegian=20language=20tex?= =?UTF-8?q?ts=20(thanks=20to=20J=F8rgen=20Tvedt).=20-=20Increased=20the=20?= =?UTF-8?q?usleep=20value=20in=20cDvbOsd::Cmd()=20to=205000=20in=20order?= =?UTF-8?q?=20to=20work=20on=20=20=20systems=20with=20the=20KURT/utime-pat?= =?UTF-8?q?ch=20(thanks=20to=20Guido=20Fiala).=20-=20Changed=20the=20check?= =?UTF-8?q?=20whether=20the=20driver=20is=20loaded=20in=20runvdr=20to=20ch?= =?UTF-8?q?eck=20for=20the=20=20=20'dvb'=20module=20(the=20last=20one=20lo?= =?UTF-8?q?aded).=20-=20Fixed=20repeat=20function=20with=20LIRC=20(thanks?= =?UTF-8?q?=20to=20Stefan=20Huelswitt).=20-=20Increased=20the=20upper=20li?= =?UTF-8?q?mit=20for=20the=20symbol=20rate=20to=2030000=20(thanks=20to=20U?= =?UTF-8?q?lrich=20=20=20R=F6der).=20-=20Made=20the=20position=20of=20the?= =?UTF-8?q?=20channel=20display=20configurable=20(thanks=20to=20Stefan=20?= =?UTF-8?q?=20=20Huelswitt).=20-=20Made=20the=20width=20and=20height=20of?= =?UTF-8?q?=20the=20OSD=20configurable=20(thanks=20to=20Stefan=20Huelswitt?= =?UTF-8?q?).=20-=20DiSEqC=20support=20can=20now=20be=20generally=20enable?= =?UTF-8?q?d/disabled=20in=20the=20Setup=20menu.=20This=20=20=20may=20be?= =?UTF-8?q?=20necessary=20if=20your=20multiswitch=20gets=20irritated=20by?= =?UTF-8?q?=20the=20default=20DiSEqC=20=20=20codes=20'0'=20(thanks=20to=20?= =?UTF-8?q?Markus=20Lang).=20-=20Fixed=20replaying=20in=20case=20there=20i?= =?UTF-8?q?s=20no=20index=20file.=20-=20Fixed=20jumping=20to=20an=20editin?= =?UTF-8?q?g=20mark=20when=20replay=20has=20been=20paused.=20-=20Avoiding?= =?UTF-8?q?=20unnecessary=20code=20execution=20in=20the=20replay=20progres?= =?UTF-8?q?s=20display=20(thanks=20=20=20to=20Guido=20Fiala).=20-=20When?= =?UTF-8?q?=20entering=20time=20values=20the=20digits=20that=20still=20hav?= =?UTF-8?q?e=20to=20be=20entered=20are=20now=20=20=20shown=20as=20'-'=20(a?= =?UTF-8?q?s=20in=20"1-:--").=20-=20When=20setting=20an=20editing=20mark?= =?UTF-8?q?=20while=20the=20progress=20display=20is=20not=20active,=20the?= =?UTF-8?q?=20=20=20display=20will=20now=20be=20turned=20on=20for=20a=20sh?= =?UTF-8?q?ort=20while=20to=20indicate=20the=20successful=20=20=20setting?= =?UTF-8?q?=20of=20the=20mark.=20-=20Updated=20'channels.conf'=20for=20Pre?= =?UTF-8?q?miere=20World=20(thanks=20to=20Helmut=20Sch=E4chner).=20=20=20C?= =?UTF-8?q?heck=20your=20timers=20if=20you=20use=20this=20channels.conf=20?= =?UTF-8?q?file,=20since=20the=20sequence=20of=20=20=20several=20PW=20chan?= =?UTF-8?q?nels=20has=20been=20changed.=20-=20Changed=20the=20color=20of?= =?UTF-8?q?=20"Info"=20messages=20to=20"black=20on=20green"=20and=20that?= =?UTF-8?q?=20of=20the=20=20=20confirmation=20messages=20(like=20"Delete..?= =?UTF-8?q?.")=20to=20"black=20on=20yellow".=20-=20Fixed=20display=20with?= =?UTF-8?q?=20DEBUG=5FOSD=20(it=20still=20crashes=20sometimes,=20esp.=20wh?= =?UTF-8?q?en=20replaying,=20=20=20but=20I=20can't=20seem=20to=20find=20wh?= =?UTF-8?q?at=20causes=20this...=20any=20ideas=20anybody=3F).=20-=20Avoidi?= =?UTF-8?q?ng=20audio/video=20distortions=20in=20'Transfer=20Mode'=20by=20?= =?UTF-8?q?no=20longer=20actually=20=20=20tuning=20the=20primary=20interfa?= =?UTF-8?q?ce=20(which=20can't=20receive=20this=20channel,=20anyway).=20?= =?UTF-8?q?=20=20Apparently=20the=20driver=20gets=20irritated=20when=20the?= =?UTF-8?q?=20channel=20is=20switched=20and=20a=20=20=20replay=20session?= =?UTF-8?q?=20is=20started=20immediately=20after=20that.=20-=20Increased?= =?UTF-8?q?=20timeout=20until=20reporting=20"video=20data=20stream=20broke?= =?UTF-8?q?n"=20when=20recording.=20-=20Explicitly=20switching=20back=20to?= =?UTF-8?q?=20the=20previously=20active=20channel=20after=20ending=20a=20?= =?UTF-8?q?=20=20replay=20session=20(to=20have=20it=20shown=20correctly=20?= =?UTF-8?q?in=20case=20it=20was=20in=20'Transfer=20Mode').?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eit.c | 257 ++++++++++++++++++++++++++++++++---------------------------------- 1 file changed, 126 insertions(+), 131 deletions(-) (limited to 'eit.c') diff --git a/eit.c b/eit.c index 6cbe504..3de6102 100644 --- a/eit.c +++ b/eit.c @@ -13,17 +13,16 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: eit.c 1.15 2001/04/01 15:36:09 kls Exp $ + * $Id: eit.c 1.16 2001/05/26 10:58:01 kls Exp $ ***************************************************************************/ #include "eit.h" #include -#include -#include #include #include #include #include +#include #include #include #include @@ -1108,31 +1107,43 @@ cMutex cSIProcessor::schedulesMutex; /** */ cSIProcessor::cSIProcessor(const char *FileName) { + fileName = strdup(FileName); masterSIProcessor = numSIProcessors == 0; // the first one becomes the 'master' useTStime = false; filters = NULL; - if ((fsvbi = open(FileName, O_RDONLY)) >= 0) - { - if (!numSIProcessors++) // the first one creates it - schedules = new cSchedules; - filters = (SIP_FILTER *)calloc(MAX_FILTERS, sizeof(SIP_FILTER)); - } - else - LOG_ERROR_STR(FileName); + if (!numSIProcessors++) // the first one creates it + schedules = new cSchedules; + filters = (SIP_FILTER *)calloc(MAX_FILTERS, sizeof(SIP_FILTER)); + SetStatus(true); + Start(); } cSIProcessor::~cSIProcessor() { - if (fsvbi >= 0) + active = false; + Cancel(3); + ShutDownFilters(); + delete filters; + if (!--numSIProcessors) // the last one deletes it + delete schedules; + delete fileName; +} + +void cSIProcessor::SetStatus(bool On) +{ + LOCK_THREAD; + schedulesMutex.Lock(); + ShutDownFilters(); + if (On) { - active = false; - Cancel(3); - ShutDownFilters(); - delete filters; - if (!--numSIProcessors) // the last one deletes it - delete schedules; - close(fsvbi); + AddFilter(0x14, 0x70); // TDT + AddFilter(0x14, 0x73); // TOT + AddFilter(0x12, 0x4e); // event info, actual TS, present/following + AddFilter(0x12, 0x4f); // event info, other TS, present/following + AddFilter(0x12, 0x50); // event info, actual TS, schedule + AddFilter(0x12, 0x60); // event info, other TS, schedule } + schedulesMutex.Unlock(); } /** use the vbi device to parse all relevant SI @@ -1140,19 +1151,10 @@ information and let the classes corresponding to the tables write their information to the disk */ void cSIProcessor::Action() { - if (fsvbi < 0) { - esyslog(LOG_ERR, "cSIProcessor::Action() called without open file - returning"); - return; - } - dsyslog(LOG_INFO, "EIT processing thread started (pid=%d)%s", getpid(), masterSIProcessor ? " - master" : ""); - unsigned char buf[4096+1]; // max. allowed size for any EIT section (+1 for safety ;-) - unsigned int seclen; - unsigned int pid; time_t lastCleanup = time(NULL); time_t lastDump = time(NULL); - struct pollfd pfd; active = true; @@ -1187,100 +1189,123 @@ void cSIProcessor::Action() } } - /* wait data become ready from the bitfilter */ - pfd.fd = fsvbi; - pfd.events = POLLIN; - if(poll(&pfd, 1, 1000) != 0) /* timeout is 5 secs */ + // set up pfd structures for all active filter + pollfd pfd[MAX_FILTERS]; + int NumUsedFilters = 0; + for (int a = 0; a < MAX_FILTERS ; a++) { - // fprintf(stderr, "\n"); - /* read section */ - read(fsvbi, buf, 8); - seclen = (buf[6] << 8) | buf[7]; - pid = (buf[4] << 8) | buf[5]; - read(fsvbi, buf, seclen); - - //dsyslog(LOG_INFO, "Received pid 0x%02x with table ID 0x%02x and length of %04d\n", pid, buf[0], seclen); + if (filters[a].inuse) + { + pfd[NumUsedFilters].fd = filters[a].handle; + pfd[NumUsedFilters].events = POLLIN; + NumUsedFilters++; + } + } - switch (pid) + // wait until data becomes ready from the bitfilter + if (poll(pfd, NumUsedFilters, 1000) != 0) + { + for (int a = 0; a < NumUsedFilters ; a++) { - case 0x14: - if (buf[0] == 0x70) + if (pfd[a].revents & POLLIN) + { + /* read section */ + unsigned char buf[4096+1]; // max. allowed size for any EIT section (+1 for safety ;-) + if (read(filters[a].handle, buf, 3) == 3) { - if (useTStime) + int seclen = ((buf[1] & 0x0F) << 8) | (buf[2] & 0xFF); + int pid = filters[a].pid; + int n = read(filters[a].handle, buf + 3, seclen); + if (n == seclen) { - cTDT ctdt((tdt_t *)buf); - ctdt.SetSystemTime(); + seclen += 3; + //dsyslog(LOG_INFO, "Received pid 0x%02x with table ID 0x%02x and length of %04d\n", pid, buf[0], seclen); + switch (pid) + { + case 0x14: + if (buf[0] == 0x70) + { + if (useTStime) + { + cTDT ctdt((tdt_t *)buf); + ctdt.SetSystemTime(); + } + } + /*XXX this comes pretty often: + else + dsyslog(LOG_INFO, "Time packet was not 0x70 but 0x%02x\n", (int)buf[0]); + XXX*/ + break; + + case 0x12: + if (buf[0] != 0x72) + { + LOCK_THREAD; + + schedulesMutex.Lock(); + cEIT ceit(buf, seclen, schedules); + ceit.ProcessEIT(); + schedulesMutex.Unlock(); + } + else + dsyslog(LOG_INFO, "Received stuffing section in EIT\n"); + break; + + default: + break; + } } + else + dsyslog(LOG_INFO, "read incomplete section - seclen = %d, n = %d", seclen, n); } - /*XXX this comes pretty often: - else - dsyslog(LOG_INFO, "Time packet was not 0x70 but 0x%02x\n", (int)buf[0]); - XXX*/ - break; - - case 0x12: - if (buf[0] != 0x72) - { - LOCK_THREAD; - - schedulesMutex.Lock(); - cEIT ceit(buf, seclen, schedules); - ceit.ProcessEIT(); - schedulesMutex.Unlock(); - } - else - dsyslog(LOG_INFO, "Received stuffing section in EIT\n"); - break; - - default: - break; + } } } - else - { - LOCK_THREAD; - - //XXX this comes pretty often - //isyslog(LOG_INFO, "Received timeout from poll, refreshing filters\n"); - RefreshFilters(); - } -// WakeUp(); } + + dsyslog(LOG_INFO, "EIT processing thread ended (pid=%d)%s", getpid(), masterSIProcessor ? " - master" : ""); } /** Add a filter with packet identifier pid and table identifer tid */ bool cSIProcessor::AddFilter(u_char pid, u_char tid) { - if (fsvbi < 0) - return false; - - int section = ((int)tid << 8) | 0x00ff; - - struct bitfilter filt = { - pid, - { section, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - SECTION_CONTINUOS, 0, - FILTER_MEM, - {}, - }; - - if (ioctl(fsvbi, VIDIOCSBITFILTER, &filt) < 0) - return false; + dmxSctFilterParams sctFilterParams; + sctFilterParams.pid = pid; + memset(&sctFilterParams.filter.filter, 0, DMX_FILTER_SIZE); + memset(&sctFilterParams.filter.mask, 0, DMX_FILTER_SIZE); + sctFilterParams.timeout = 0; + sctFilterParams.flags = DMX_IMMEDIATE_START; + sctFilterParams.filter.filter[0] = tid; + sctFilterParams.filter.mask[0] = 0xFF; for (int a = 0; a < MAX_FILTERS; a++) { - if (filters[a].inuse == false) + if (!filters[a].inuse) { filters[a].pid = pid; filters[a].tid = tid; - filters[a].handle = filt.handle; - filters[a].inuse = true; - // dsyslog(LOG_INFO, " Registered filter handle %04x, pid = %02d, tid = %02d", filters[a].handle, filters[a].pid, filters[a].tid); + if ((filters[a].handle = open(fileName, O_RDWR | O_NONBLOCK)) >= 0) + { + if (ioctl(filters[a].handle, DMX_SET_FILTER, &sctFilterParams) >= 0) + filters[a].inuse = true; + else + { + esyslog(LOG_ERR, "ERROR: can't set filter"); + close(filters[a].handle); + return false; + } + // dsyslog(LOG_INFO, " Registered filter handle %04x, pid = %02d, tid = %02d", filters[a].handle, filters[a].pid, filters[a].tid); + } + else + { + esyslog(LOG_ERR, "ERROR: can't open filter handle"); + return false; + } return true; } } + esyslog(LOG_ERR, "ERROR: too many filters"); return false; } @@ -1294,27 +1319,19 @@ bool cSIProcessor::SetUseTSTime(bool use) } /** */ -bool cSIProcessor::ShutDownFilters() +bool cSIProcessor::ShutDownFilters(void) { - if (fsvbi < 0) - return false; - - bool ret = true; - for (int a = 0; a < MAX_FILTERS; a++) { - if (filters[a].inuse == true) + if (filters[a].inuse) { - if (ioctl(fsvbi, VIDIOCSSHUTDOWNFILTER, &filters[a].handle) < 0) - ret = false; - + close(filters[a].handle); // dsyslog(LOG_INFO, "Deregistered filter handle %04x, pid = %02d, tid = %02d", filters[a].handle, filters[a].pid, filters[a].tid); - filters[a].inuse = false; } } - return ret; + return true; // there's no real 'boolean' to return here... } /** */ @@ -1323,25 +1340,3 @@ bool cSIProcessor::SetCurrentServiceID(unsigned short servid) LOCK_THREAD; return schedules ? schedules->SetCurrentServiceID(servid) : false; } - -/** */ -bool cSIProcessor::RefreshFilters() -{ - if (fsvbi < 0) - return false; - - bool ret = true; - - ret = ShutDownFilters(); - - for (int a = 0; a < MAX_FILTERS; a++) - { - if (filters[a].inuse == false && filters[a].pid != 0 && filters[a].tid != 0) - { - if (!AddFilter(filters[a].pid, filters[a].tid)) - ret = false; - } - } - - return ret; -} -- cgit v1.2.3