vdr/sections.c
Klaus Schmidinger f836711024 Version 1.3.25
- Updated the Estonian OSD texts (thanks to Arthur Konovalov).
- Some cable providers don't mark short channel names according to the standard,
  but rather go their own way and use "name>short name". VDR now splits at this
  character for cable channels (thanks to Gerhard Steiner for reporting this one).
- Added a check for Setup.DiSEqC in cDvbDevice::ProvidesTransponder(), otherwise
  the EPG scan didn't work on systems that don't use DiSEqC (thanks to Michael
  Reinelt for reporting this one).
- Made the Makefile patch friendlier (thanks to Ludwig Nussel).
- Made cOsd::isOpen an integer counter to avoid problems with messages when a
  cOsdObject uses the raw OSD (thanks to Andreas Regel for reporting this one).
- Updated the Danish OSD texts (thanks to Mogens Elneff).
- The file 'summary.vdr' has been replaced with 'info.vdr' and now contains the
  information about a recording, in the same format as the events are stored in
  'epg.data' (see man vdr(5) for details). Existing summary files can be converted
  to the new format by running the Perl script 'summary2info.pl', as in

  summary2info.pl /video

  (the parameter given has to be the video directory). If there is no 'info.vdr'
  file for a recording, an attempt is made to read a 'summary.vdr'.
- The "Summary" button in the "Recordings" menu has been renamed to "Info", and
  the page it brings up now shows the recording's information, much like the EPG
  event page. Therefore it now no longer uses the skin's SetText() function, but
  rather the SetRecording() function. Skin plugins may need to adjust that function
  accordingly (see skinsttng.c, for instance).
- The SVDRP command LSTR now lists the recording information in the same tagged
  format as the LSTE command lists the EPG data.
- The audio track menu now contains track descriptions when replaying (provided
  such descriptions were available in the EPG data when the recording was made,
  and are stored in the info.vdr file).
- Avoiding extra blanks at the end of names of instant recordings.
- Removed converting byte order on big endian systems from cDvbOsd::Flush(),
  which, according to Johannes Stezenbach and Paavo Hartikainen, is wrong.
- Added cPlayer::DeviceSetVideoDisplayFormat() (thanks to Marco Schlüßler).
- No longer saving the setup in case of a fatal error, to keep the volume level
  from being set to a wrong value (thanks to Marco Schlüßler).
- Fixed a possible hangup when ending a replay session while cIndexFile::CatchUp()
  is waiting (thanks to Marco Schlüßler).
- The SVDRP command DELR no longer deletes recordings that are currently being
  written to by a timer (thanks to Sascha Volkenandt for pointing out this one).
- Pressing the "Play" key in live viewing mode now resumes a previous replay
  session (thanks to Mirko Dölle).
- Now dropping EPG events that have a zero start time or duration (thanks to
  Oliver Endriss).
- No longer stopping Transfer Mode or replay immediately when the Power button
  is pressed (thanks to Rolf Ahrenberg).
- Moved the NPTL and UTF-8 checks after the version and help output (thanks to
  Andreas Kool for pointing out that 'vdr --version' failed on an UTF-8 system).
- Made tChannelID::operator==() inline for better performance (thanks to Georg
  Acher).
- Introduced cListBase::count for better performance (thanks to Georg Acher).
- cEvent no longer stores the channelID directly, but rather has a pointer to
  the schedule it is in.
- Now using hash tables to speed up cSchedule::GetEvent() (partially based on
  a patch from Georg Acher).
- Avoiding unnecessary calls to getLength() in libsi/si.c, and avoiding the
  '& 0xff' in CRC32::crc32() of libsi/util.c (thanks to Georg Acher).
- Speeded up deleting duplicate channels.
- Fixed listing recordings with empty episode names in the LSTR command (thanks
  to Stefan Huelswitt for pointing this out).
- Added cThread::SetPriority() and using it in cSectionHandler::Action() to
  reduce the priority of the section handler threads (as suggested by Georg Acher).
2005-05-29 18:00:00 +02:00

229 lines
5.9 KiB
C

/*
* sections.c: Section data handling
*
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: sections.c 1.11 2005/05/29 11:43:17 kls Exp $
*/
#include "sections.h"
#include <unistd.h>
#include "channels.h"
#include "device.h"
#include "thread.h"
// --- cFilterHandle----------------------------------------------------------
class cFilterHandle : public cListObject {
public:
cFilterData filterData;
int handle;
int used;
cFilterHandle(const cFilterData &FilterData);
};
cFilterHandle::cFilterHandle(const cFilterData &FilterData)
{
filterData = FilterData;
handle = -1;
used = 0;
}
// --- cSectionHandlerPrivate ------------------------------------------------
class cSectionHandlerPrivate {
public:
cChannel channel;
};
// --- cSectionHandler -------------------------------------------------------
cSectionHandler::cSectionHandler(cDevice *Device)
:cThread("Section handler")
{
shp = new cSectionHandlerPrivate;
device = Device;
active = false;
statusCount = 0;
on = false;
waitForLock = false;
lastIncompleteSection = 0;
Start();
}
cSectionHandler::~cSectionHandler()
{
active = false;
Cancel(3);
cFilter *fi;
while ((fi = filters.First()) != NULL)
Detach(fi);
delete shp;
}
int cSectionHandler::Source(void)
{
return shp->channel.Source();
}
int cSectionHandler::Transponder(void)
{
return shp->channel.Transponder();
}
const cChannel *cSectionHandler::Channel(void)
{
return &shp->channel;
}
void cSectionHandler::Add(const cFilterData *FilterData)
{
Lock();
statusCount++;
cFilterHandle *fh;
for (fh = filterHandles.First(); fh; fh = filterHandles.Next(fh)) {
if (fh->filterData.Is(FilterData->pid, FilterData->tid, FilterData->mask))
break;
}
if (!fh) {
int handle = device->OpenFilter(FilterData->pid, FilterData->tid, FilterData->mask);
if (handle >= 0) {
fh = new cFilterHandle(*FilterData);
fh->handle = handle;
filterHandles.Add(fh);
}
}
if (fh)
fh->used++;
Unlock();
}
void cSectionHandler::Del(const cFilterData *FilterData)
{
Lock();
statusCount++;
cFilterHandle *fh;
for (fh = filterHandles.First(); fh; fh = filterHandles.Next(fh)) {
if (fh->filterData.Is(FilterData->pid, FilterData->tid, FilterData->mask)) {
if (--fh->used <= 0) {
close(fh->handle);
filterHandles.Del(fh);
break;
}
}
}
Unlock();
}
void cSectionHandler::Attach(cFilter *Filter)
{
Lock();
statusCount++;
filters.Add(Filter);
Filter->sectionHandler = this;
if (on)
Filter->SetStatus(true);
Unlock();
}
void cSectionHandler::Detach(cFilter *Filter)
{
Lock();
statusCount++;
Filter->SetStatus(false);
Filter->sectionHandler = NULL;
filters.Del(Filter, false);
Unlock();
}
void cSectionHandler::SetChannel(const cChannel *Channel)
{
Lock();
shp->channel = Channel ? *Channel : cChannel();
Unlock();
}
void cSectionHandler::SetStatus(bool On)
{
Lock();
if (on != On) {
if (!On || device->HasLock()) {
statusCount++;
for (cFilter *fi = filters.First(); fi; fi = filters.Next(fi)) {
fi->SetStatus(false);
if (On)
fi->SetStatus(true);
}
on = On;
waitForLock = false;
}
else
waitForLock = On;
}
Unlock();
}
void cSectionHandler::Action(void)
{
active = true;
SetPriority(19);
while (active) {
Lock();
if (waitForLock)
SetStatus(true);
int NumFilters = filterHandles.Count();
pollfd pfd[NumFilters];
for (cFilterHandle *fh = filterHandles.First(); fh; fh = filterHandles.Next(fh)) {
int i = fh->Index();
pfd[i].fd = fh->handle;
pfd[i].events = POLLIN;
pfd[i].revents = 0;
}
int oldStatusCount = statusCount;
Unlock();
if (poll(pfd, NumFilters, 1000) > 0) {
bool DeviceHasLock = device->HasLock();
if (!DeviceHasLock)
cCondWait::SleepMs(100);
for (int i = 0; i < NumFilters; i++) {
if (pfd[i].revents & POLLIN) {
cFilterHandle *fh = NULL;
LOCK_THREAD;
if (statusCount != oldStatusCount)
break;
for (fh = filterHandles.First(); fh; fh = filterHandles.Next(fh)) {
if (pfd[i].fd == fh->handle)
break;
}
if (fh) {
// Read section data:
unsigned char buf[4096]; // max. allowed size for any EIT section
int r = safe_read(fh->handle, buf, sizeof(buf));
if (!DeviceHasLock)
continue; // we do the read anyway, to flush any data that might have come from a different transponder
if (r > 3) { // minimum number of bytes necessary to get section length
int len = (((buf[1] & 0x0F) << 8) | (buf[2] & 0xFF)) + 3;
if (len == r) {
// Distribute data to all attached filters:
int pid = fh->filterData.pid;
int tid = buf[0];
for (cFilter *fi = filters.First(); fi; fi = filters.Next(fi)) {
if (fi->Matches(pid, tid))
fi->Process(pid, tid, buf, len);
}
}
else if (time(NULL) - lastIncompleteSection > 10) { // log them only every 10 seconds
dsyslog("read incomplete section - len = %d, r = %d", len, r);
lastIncompleteSection = time(NULL);
}
}
}
}
}
}
}
}