mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
- Fixed checking for the presence of NPTL (thanks to Jouni Karvo). - Making sure section filters are only set if the device actually has a lock (thanks to Andreas Share for pointing this out). - Fixed a possible NULL pointer assignment in cMenuText::SetText() (thanks to Marco Schlüssler). - Fixed a crash in case the last line in channels.conf is a group separator and that group is selected in the channel display (thanks to Dick Streefland). - Added cRingBufferLinear::Read() to read directly from a file handle into the ring buffer. - Using timeouts in ring buffers to avoid 'usleep()'. - Clearing the 'Transfer Mode' ring buffer after clearing the device to avoid an "almost full" ring buffer. - Removed locking from cRingBufferLinear for better performance under high load. - Using a cRingBufferLinear in cRemux to avoid unnecessary copying of data. - Using a cRingBufferLinear in cTSBuffer and filling it in a separate thread to avoid buffer overflows. Plugins using cTSBuffer will need to remove the call to the now obsolete Read() function (see cDvbDevice::GetTSPacket() for the new usage of cTSBuffer). - cRemux::Process() has been split into Put(), Get() and Del() to allow for a better decoupling of the remuxing and disk writing process. Plugins using cRemux will need to be modified accordingly. - The actual disk writing in recordings is now done in a separate thread to improve the overall throughput. - Changed cRemux so that it returns the maximum available amount of data with each call, not just 2048 byte. - Added a visual display of all cRingBufferLinear buffers for debugging. To activate it, define DEBUGRINGBUFFERS in ringbuffer.h. - Instead of cCondVar now using the new cCondWait (which also avoids a possible "near miss" condition; thanks to Sascha Volkenandt for pointing out this one). cCondVar is still present for plugins that use it (and VDR itself also still uses it in cRemote). - The cRingBuffer now does EnableGet()/EnablePut() only if the buffer is more than one third full or empty, respectively. This dramatically improves recording performance and reduces system load (thanks to Marco Schlüßler for doing some testing regarding buffer performance and giving me some hints that finally led to finding out that this was the basic problem causing buffer overflows). - Improved Transfer Mode (thanks to Marco Schlüßler for suggestions and testing). - Fixed a possible crash with inconsistent SI data (thanks to Marcel Wiesweg). - Fixed showing the replay mode if the OSD is currently in use (thanks to Kimmo Tykkala for pointing out this problem). - cOsdProvider::NewOsd() now always returns a valid pointer, even if the OSD is currently in use (it will then return a dummy cOsd object and write a message to the log file). - Added Estonian language texts (thanks to Arthur Konovalov). - Fixed 'newplugin' and libsi/Makefile to use the compiler defined in $(CXX) for generating file dependencies (thanks to Andreas Brachold). - Moved the initialization of aPid1 and aPid2 to the beginning of cDvbDevice::cDvbDevice() to have them set in case a patch references them (thanks to Wayne Keer for pointing this out). - Completed the Russian OSD texts (thanks to Vyacheslav Dikonov). - Avoiding unnecessary section filter start/stops (thanks to Marco Schlüßler). - Made the "Channel not available!" message and mtInfo instead of mtError (suggested by Wayne Keer). - Made volume control more linear (thanks to Emil Naepflein and Udo Richter). - Now skipping code table info in SI data (suggested by Milos Kapoun). - Added missing Czech characters to fontosd-iso8859-2.c (thanks to Milos Kapoun). - Fixed a crash in the time search mechanism (reported by Reinhard Nissl). - If one PID can't be added, the whole cDevice::AttachReceiver() will now fail and all PIDs added so far will be deleted (thanks to Marco Schlüßler for pointing out this one). - Now only saving channels.conf after a modification made by the user (avoids lots of disk access due to automatic channel updates). Automatic channel modifications will be saved every 10 minutes if no recording is currently active. - Removed the 'Log' parameter from the cChannel::Set... functions. Instead checking if the channel has a non-zero number. - Updated 'channels.conf.terr' for Hannover (thanks to Sven Kreiensen).
163 lines
5.7 KiB
C++
163 lines
5.7 KiB
C++
/***************************************************************************
|
|
* Copyright (c) 2003 by Marcel Wiesweg *
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
* $Id: util.h 1.4 2004/10/16 09:59:48 kls Exp $
|
|
* *
|
|
***************************************************************************/
|
|
|
|
#ifndef LIBSI_UTIL_H
|
|
#define LIBSI_UTIL_H
|
|
|
|
#include <stdint.h>
|
|
#include <sys/types.h>
|
|
#include <pthread.h>
|
|
#include <time.h>
|
|
|
|
#define HILO(x) (x##_hi << 8 | x##_lo)
|
|
#define BCD_TIME_TO_SECONDS(x) ((3600 * ((10*((x##_h & 0xF0)>>4)) + (x##_h & 0xF))) + \
|
|
(60 * ((10*((x##_m & 0xF0)>>4)) + (x##_m & 0xF))) + \
|
|
((10*((x##_s & 0xF0)>>4)) + (x##_s & 0xF)))
|
|
|
|
namespace SI {
|
|
|
|
//Holds an array of unsigned char which is deleted
|
|
//when the last object pointing to it is deleted.
|
|
//Optimized for use in libsi.
|
|
class CharArray {
|
|
public:
|
|
CharArray();
|
|
|
|
CharArray(const CharArray &source);
|
|
CharArray& operator=(const CharArray &source);
|
|
~CharArray();
|
|
|
|
//can be called exactly once
|
|
void assign(const unsigned char*data, unsigned int size, bool doCopy=true);
|
|
//compares to a null-terminated string
|
|
bool operator==(const char *string) const;
|
|
//compares to another CharArray (data not necessarily null-terminated)
|
|
bool operator==(const CharArray &other) const;
|
|
|
|
//returns another CharArray with its offset incremented by offset
|
|
CharArray operator+(const unsigned int offset) const;
|
|
|
|
//access and convenience methods
|
|
const unsigned char* getData() const { return data_->data+off; }
|
|
const unsigned char* getData(int offset) const { return data_->data+offset+off; }
|
|
template <typename T> const T* getData() const { return (T*)(data_->data+off); }
|
|
template <typename T> const T* getData(int offset) const { return (T*)(data_->data+offset+off); }
|
|
//sets p to point to data+offset, increments offset
|
|
template <typename T> void setPointerAndOffset(const T* &p, unsigned int &offset) const { p=(T*)getData(offset); offset+=sizeof(T); }
|
|
unsigned char operator[](const unsigned int index) const { return data_->data ? data_->data[off+index] : 0; }
|
|
int getLength() const { return data_->size; }
|
|
u_int16_t TwoBytes(const unsigned int index) const { return data_->data ? data_->TwoBytes(off+index) : 0; }
|
|
u_int32_t FourBytes(const unsigned int index) const { return data_->data ? data_->FourBytes(off+index) : 0; }
|
|
|
|
bool isValid() const { return data_->valid; }
|
|
bool checkSize(unsigned int offset) { return (data_->valid && (data_->valid=(off+offset < data_->size))); }
|
|
|
|
void addOffset(unsigned int offset) { off+=offset; }
|
|
private:
|
|
class Data {
|
|
public:
|
|
Data();
|
|
virtual ~Data();
|
|
|
|
virtual void assign(const unsigned char*data, unsigned int size) = 0;
|
|
virtual void Delete() = 0;
|
|
|
|
u_int16_t TwoBytes(const unsigned int index) const
|
|
{ return (data[index] << 8) | data[index+1]; }
|
|
u_int32_t FourBytes(const unsigned int index) const
|
|
{ return (data[index] << 24) | (data[index+1] << 16) | (data[index+2] << 8) | data[index+3]; }
|
|
/*#ifdef CHARARRAY_THREADSAFE
|
|
void Lock();
|
|
void Unlock();
|
|
#else
|
|
void Lock() {}
|
|
void Unlock() {}
|
|
#endif
|
|
Data(const Data& d);
|
|
void assign(unsigned int size);
|
|
*/
|
|
|
|
const unsigned char*data;
|
|
unsigned int size;
|
|
|
|
// count_ is the number of CharArray objects that point at this
|
|
// count_ must be initialized to 1 by all constructors
|
|
// (it starts as 1 since it is pointed to by the CharArray object that created it)
|
|
unsigned count_;
|
|
|
|
bool valid;
|
|
|
|
/*
|
|
pthread_mutex_t mutex;
|
|
pid_t lockingPid;
|
|
pthread_t locked;
|
|
*/
|
|
};
|
|
class DataOwnData : public Data {
|
|
public:
|
|
DataOwnData() {}
|
|
virtual ~DataOwnData();
|
|
virtual void assign(const unsigned char*data, unsigned int size);
|
|
virtual void Delete();
|
|
};
|
|
class DataForeignData : public Data {
|
|
public:
|
|
DataForeignData() {}
|
|
virtual ~DataForeignData();
|
|
virtual void assign(const unsigned char*data, unsigned int size);
|
|
virtual void Delete();
|
|
};
|
|
Data* data_;
|
|
unsigned int off;
|
|
};
|
|
|
|
|
|
|
|
//abstract base class
|
|
class Parsable {
|
|
public:
|
|
void CheckParse();
|
|
protected:
|
|
Parsable();
|
|
virtual ~Parsable() {}
|
|
//actually parses given data.
|
|
virtual void Parse() = 0;
|
|
private:
|
|
bool parsed;
|
|
};
|
|
|
|
//taken and adapted from libdtv, (c) Rolf Hakenes and VDR, (c) Klaus Schmidinger
|
|
namespace DVBTime {
|
|
time_t getTime(unsigned char date_hi, unsigned char date_lo, unsigned char timehr, unsigned char timemi, unsigned char timese);
|
|
time_t getDuration(unsigned char timehr, unsigned char timemi, unsigned char timese);
|
|
inline unsigned char bcdToDec(unsigned char b) { return ((b >> 4) & 0x0F) * 10 + (b & 0x0F); }
|
|
};
|
|
|
|
//taken and adapted from libdtv, (c) Rolf Hakenes
|
|
class CRC32 {
|
|
public:
|
|
CRC32(const char *d, int len, u_int32_t CRCvalue=0xFFFFFFFF);
|
|
bool isValid() { return crc32(data, length, value) == 0; }
|
|
static bool isValid(const char *d, int len, u_int32_t CRCvalue=0xFFFFFFFF) { return crc32(d, len, CRCvalue) == 0; }
|
|
protected:
|
|
static u_int32_t crc_table[256];
|
|
static u_int32_t crc32 (const char *d, int len, u_int32_t CRCvalue);
|
|
|
|
const char *data;
|
|
int length;
|
|
u_int32_t value;
|
|
};
|
|
|
|
} //end of namespace
|
|
|
|
#endif
|