File:  [DVB] / dvb-kernel-v4 / patches / vdr-1.3.9-v4.patch
Revision 1.1: download - view: text, annotated - select for diffs
Thu Jun 10 13:48:10 2004 UTC (19 years, 11 months ago) by hunold
Branches: MAIN
CVS tags: root-of-ARIB_extension, dvb-v5, HEAD, ARIB_extension_rev002, ARIB_extension_rev001, ARIB_extension
- add new patch against 1.3.9

diff -uraN vdr-1.3.9/Makefile pre-vdr-1.3.9/Makefile
--- vdr-1.3.9/Makefile	2004-05-16 12:51:44.000000000 +0200
+++ pre-vdr-1.3.9/Makefile	2004-06-10 15:21:28.000000000 +0200
@@ -14,7 +14,7 @@
 CXX      ?= g++
 CXXFLAGS ?= -g -O2 -Wall -Woverloaded-virtual
 
-DVBDIR   = ../DVB
+DVBDIR   = ../dvb-kernel-v4
 LSIDIR   = ./libsi
 MANDIR   = /usr/local/man
 BINDIR   = /usr/local/bin
diff -uraN vdr-1.3.9/av7110-osd.h pre-vdr-1.3.9/av7110-osd.h
--- vdr-1.3.9/av7110-osd.h	1970-01-01 01:00:00.000000000 +0100
+++ pre-vdr-1.3.9/av7110-osd.h	2004-06-10 15:21:25.000000000 +0200
@@ -0,0 +1,88 @@
+#ifndef _AV7110_OSD_H_
+#define _AV7110_OSD_H_
+
+enum av7110_osd_command {
+	/* All functions return -2 on "not open" */
+
+	OSD_Close=1,
+	/* Disables OSD and releases the buffers */
+	/* returns 0 on success */
+	OSD_Open,       /* (x0,y0,x1,y1,BitPerPixel[2/4/8](color&0x0F),mix[0..15](color&0xF0)) */
+	/* Opens OSD with this size and bit depth */
+	/* returns 0 on success, -1 on DRAM allocation error, -2 on "already open" */
+	OSD_Show,
+	/* enables OSD mode */
+	/* returns 0 on success */
+	OSD_Hide,
+	/* disables OSD mode */
+	/* returns 0 on success */
+	OSD_Clear,
+	/* Sets all pixel to color 0 */
+	/* returns 0 on success */
+	OSD_Fill,
+	/* Sets all pixel to color <col> */
+	/* returns 0 on success */
+	OSD_SetColor,   /* (color,R{x0},G{y0},B{x1},opacity{y1}) */
+	/* set palette entry <num> to <r,g,b>, <mix> and <trans> apply */
+	/* R,G,B: 0..255 */
+	/* R=Red, G=Green, B=Blue */
+	/* opacity=0:      pixel opacity 0% (only video pixel shows) */
+	/* opacity=1..254: pixel opacity as specified in header */
+	/* opacity=255:    pixel opacity 100% (only OSD pixel shows) */
+	/* returns 0 on success, -1 on error */
+	OSD_SetPalette, /* (firstcolor{color},lastcolor{x0},data) */
+	/* Set a number of entries in the palette */
+	/* sets the entries "firstcolor" through "lastcolor" from the array "data" */
+	/* data has 4 byte for each color: */
+	/* R,G,B, and a opacity value: 0->transparent, 1..254->mix, 255->pixel */
+	OSD_SetTrans,   /* (transparency{color}) */
+	/* Sets transparency of mixed pixel (0..15) */
+	/* returns 0 on success */
+	OSD_SetPixel,   /* (x0,y0,color) */
+	/* sets pixel <x>,<y> to color number <col> */
+	/* returns 0 on success, -1 on error */
+	OSD_GetPixel,   /* (x0,y0) */
+	/* returns color number of pixel <x>,<y>,  or -1 */
+	OSD_SetRow,     /* (x0,y0,x1,data) */
+	/* fills pixels x0,y through  x1,y with the content of data[] */
+	/* returns 0 on success, -1 on clipping all pixel (no pixel drawn) */
+	OSD_SetBlock,   /* (x0,y0,x1,y1,increment{color},data) */
+	/* fills pixels x0,y0 through  x1,y1 with the content of data[] */
+	/* inc contains the width of one line in the data block, */
+	/* inc<=0 uses blockwidth as linewidth */
+	/* returns 0 on success, -1 on clipping all pixel */
+	OSD_FillRow,    /* (x0,y0,x1,color) */
+	/* fills pixels x0,y through  x1,y with the color <col> */
+	/* returns 0 on success, -1 on clipping all pixel */
+	OSD_FillBlock,  /* (x0,y0,x1,y1,color) */
+	/* fills pixels x0,y0 through  x1,y1 with the color <col> */
+	/* returns 0 on success, -1 on clipping all pixel */
+	OSD_Line,       /* (x0,y0,x1,y1,color) */
+	/* draw a line from x0,y0 to x1,y1 with the color <col> */
+	/* returns 0 on success */
+	OSD_Query,      /* (x0,y0,x1,y1,xasp{color}), yasp=11 */
+	/* fills parameters with the picture dimensions and the pixel aspect ratio */
+	/* returns 0 on success */
+	OSD_Test,
+	/* draws a test picture. for debugging purposes only */
+	/* returns 0 on success */
+	/* TODO: remove "test" in final version */
+	OSD_Text,       /* (x0,y0,size,color,text) */
+	OSD_SetWindow, /* (x0) set window with number 0<x0<8 as current */
+	OSD_MoveWindow, /* move current window to (x0, y0) */
+};
+
+struct av7110_osd_cmd {
+	enum av7110_osd_command cmd;
+	int x0;
+	int y0;
+	int x1;
+	int y1;
+	int color;
+	void *data;
+};
+
+#define AV7110_OSD_SEND_CMD _IOW('D', 0xf0, struct av7110_osd_cmd)
+
+
+#endif
diff -uraN vdr-1.3.9/channels.c pre-vdr-1.3.9/channels.c
--- vdr-1.3.9/channels.c	2004-04-03 15:42:06.000000000 +0200
+++ pre-vdr-1.3.9/channels.c	2004-06-10 15:21:28.000000000 +0200
@@ -18,67 +18,67 @@
 // -- Channel Parameter Maps -------------------------------------------------
 
 const tChannelParameterMap InversionValues[] = {
-  {   0, INVERSION_OFF },
-  {   1, INVERSION_ON },
-  { 999, INVERSION_AUTO },
+  {   0, DVB_FE_INVERSION_OFF },
+  {   1, DVB_FE_INVERSION_ON },
+  { 999, DVB_FE_INVERSION_AUTO },
   { -1 }
   };
 
 const tChannelParameterMap BandwidthValues[] = {
-  {   6, BANDWIDTH_6_MHZ },
-  {   7, BANDWIDTH_7_MHZ },
-  {   8, BANDWIDTH_8_MHZ },
-  { 999, BANDWIDTH_AUTO },
+  {   6, DVB_BANDWIDTH_6_MHZ },
+  {   7, DVB_BANDWIDTH_7_MHZ },
+  {   8, DVB_BANDWIDTH_8_MHZ },
+  { 999, DVB_BANDWIDTH_AUTO },
   { -1 }
   };
 
 const tChannelParameterMap CoderateValues[] = {
-  {   0, FEC_NONE },
-  {  12, FEC_1_2 },
-  {  23, FEC_2_3 },
-  {  34, FEC_3_4 },
-  {  45, FEC_4_5 },
-  {  56, FEC_5_6 },
-  {  67, FEC_6_7 },
-  {  78, FEC_7_8 },
-  {  89, FEC_8_9 },
-  { 999, FEC_AUTO },
+  {   0, DVB_FE_FEC_NONE },
+  {  12, DVB_FE_FEC_1_2 },
+  {  23, DVB_FE_FEC_2_3 },
+  {  34, DVB_FE_FEC_3_4 },
+  {  45, DVB_FE_FEC_4_5 },
+  {  56, DVB_FE_FEC_5_6 },
+  {  67, DVB_FE_FEC_6_7 },
+  {  78, DVB_FE_FEC_7_8 },
+  {  89, DVB_FE_FEC_8_9 },
+  { 999, DVB_FE_FEC_AUTO },
   { -1 }
   };
 
 const tChannelParameterMap ModulationValues[] = {
-  {   0, QPSK },
-  {  16, QAM_16 },
-  {  32, QAM_32 },
-  {  64, QAM_64 },
-  { 128, QAM_128 },
-  { 256, QAM_256 },
-  { 999, QAM_AUTO },
+  {   0, DVB_FE_QPSK },
+  {  16, DVB_FE_QAM_16 },
+  {  32, DVB_FE_QAM_32 },
+  {  64, DVB_FE_QAM_64 },
+  { 128, DVB_FE_QAM_128 },
+  { 256, DVB_FE_QAM_256 },
+  { 999, DVB_FE_QAM_AUTO },
   { -1 }
   };
 
 const tChannelParameterMap TransmissionValues[] = {
-  {   2, TRANSMISSION_MODE_2K },
-  {   8, TRANSMISSION_MODE_8K },
-  { 999, TRANSMISSION_MODE_AUTO },
+  {   2, DVB_TRANSMISSION_MODE_2K },
+  {   8, DVB_TRANSMISSION_MODE_8K },
+  { 999, DVB_TRANSMISSION_MODE_AUTO },
   { -1 }
   };
 
 const tChannelParameterMap GuardValues[] = {
-  {   4, GUARD_INTERVAL_1_4 },
-  {   8, GUARD_INTERVAL_1_8 },
-  {  16, GUARD_INTERVAL_1_16 },
-  {  32, GUARD_INTERVAL_1_32 },
-  { 999, GUARD_INTERVAL_AUTO },
+  {   4, DVB_GUARD_INTERVAL_1_4 },
+  {   8, DVB_GUARD_INTERVAL_1_8 },
+  {  16, DVB_GUARD_INTERVAL_1_16 },
+  {  32, DVB_GUARD_INTERVAL_1_32 },
+  { 999, DVB_GUARD_INTERVAL_AUTO },
   { -1 }
   };
 
 const tChannelParameterMap HierarchyValues[] = {
-  {   0, HIERARCHY_NONE },
-  {   1, HIERARCHY_1 },
-  {   2, HIERARCHY_2 },
-  {   4, HIERARCHY_4 },
-  { 999, HIERARCHY_AUTO },
+  {   0, DVB_HIERARCHY_NONE },
+  {   1, DVB_HIERARCHY_1 },
+  {   2, DVB_HIERARCHY_2 },
+  {   4, DVB_HIERARCHY_4 },
+  { 999, DVB_HIERARCHY_AUTO },
   { -1 }
   };
 
@@ -167,14 +167,14 @@
 cChannel::cChannel(void)
 {
   memset(&__BeginData__, 0, (char *)&__EndData__ - (char *)&__BeginData__);
-  inversion    = INVERSION_AUTO;
-  bandwidth    = BANDWIDTH_AUTO;
-  coderateH    = FEC_AUTO;
-  coderateL    = FEC_AUTO;
-  modulation   = QAM_AUTO;
-  transmission = TRANSMISSION_MODE_AUTO;
-  guard        = GUARD_INTERVAL_AUTO;
-  hierarchy    = HIERARCHY_AUTO;
+  inversion    = DVB_FE_INVERSION_AUTO;
+  bandwidth    = DVB_BANDWIDTH_AUTO;
+  coderateH    = DVB_FE_FEC_AUTO;
+  coderateL    = DVB_FE_FEC_AUTO;
+  modulation   = DVB_FE_QAM_AUTO;
+  transmission = DVB_TRANSMISSION_MODE_AUTO;
+  guard        = DVB_GUARD_INTERVAL_AUTO;
+  hierarchy    = DVB_HIERARCHY_AUTO;
   modification = CHANNELMOD_NONE;
   linkChannels = NULL;
   refChannel   = NULL;
@@ -280,7 +280,7 @@
      polarization = Polarization;
      srate = Srate;
      coderateH = CoderateH;
-     modulation = QPSK;
+     modulation = DVB_FE_QPSK;
      modification |= CHANNELMOD_TRANSP;
      Channels.SetModified();
      }
diff -uraN vdr-1.3.9/ci.c pre-vdr-1.3.9/ci.c
--- vdr-1.3.9/ci.c	2004-02-08 16:02:04.000000000 +0100
+++ pre-vdr-1.3.9/ci.c	2004-06-10 15:21:28.000000000 +0200
@@ -10,7 +10,7 @@
 #include "ci.h"
 #include <asm/unaligned.h>
 #include <ctype.h>
-#include <linux/dvb/ca.h>
+#include <linux/dvb/ci.h>
 #include <malloc.h>
 #include <netinet/in.h>
 #include <poll.h>
@@ -470,7 +470,7 @@
 bool cCiTransportLayer::ResetSlot(int Slot)
 {
   dbgprotocol("Resetting slot %d...", Slot);
-  if (ioctl(fd, CA_RESET, 1 << Slot) != -1) {
+  if (ioctl(fd, DVB_CI_RESET_SLOT, Slot) != -1) {
      dbgprotocol("ok.\n");
      return true;
      }
@@ -482,10 +482,10 @@
 
 bool cCiTransportLayer::ModuleReady(int Slot)
 {
-  ca_slot_info_t sinfo;
-  sinfo.num = Slot;
-  if (ioctl(fd, CA_GET_SLOT_INFO, &sinfo) != -1)
-     return sinfo.flags & CA_CI_MODULE_READY;
+  struct dvb_ci_slot_status stat;
+  stat.slot = Slot;
+  if (ioctl(fd, DVB_CI_GET_SLOT_STATUS, &stat) != -1)
+     return stat.status & DVB_CI_CAM_READY;
   else
      esyslog("ERROR: can't get info on CAM slot %d: %m", Slot);
   return false;
@@ -1344,15 +1344,30 @@
 {
   int fd_ca = open(FileName, O_RDWR);
   if (fd_ca >= 0) {
-     ca_caps_t Caps;
-     if (ioctl(fd_ca, CA_GET_CAP, &Caps) == 0) {
-        int NumSlots = Caps.slot_num;
+     struct dvb_ci_caps Caps;
+     Caps.cap = DVB_CI_CAP_PROTOCOL;
+     if (ioctl(fd_ca, DVB_CI_GET_CAPS, &Caps) == -1) {
+        LOG_ERROR_STR(FileName);
+        return NULL;
+        }
+     if (Caps.val != DVB_CI_PROTOCOL_LINK_DEFRAG) {
+        isyslog("CI device does not support LINK_DEFRAG protocol");
+        return NULL;
+        }
+     Caps.cap = DVB_CI_CAP_MAX_TPDU_SIZE;
+     if (ioctl(fd_ca, DVB_CI_GET_CAPS, &Caps) == -1) {
+        LOG_ERROR_STR(FileName);
+        return NULL;
+        }
+     if (Caps.val > 2048) {
+        isyslog("FIXME, I'm broken: CI device sends messages larger than 2048");
+        return NULL;
+        }
+     Caps.cap = DVB_CI_CAP_NUM_SLOTS;
+     if (ioctl(fd_ca, DVB_CI_GET_CAPS, &Caps) == 0) {
+        int NumSlots = Caps.val;
         if (NumSlots > 0) {
-           //XXX dsyslog("CAM: found %d CAM slots", NumSlots); // TODO let's do this only once we can be sure that there _really_ is a CAM adapter!
-           if ((Caps.slot_type & CA_CI_LINK) != 0)
-              return new cCiHandler(fd_ca, NumSlots);
-           else
-              isyslog("CAM doesn't support link layer interface");
+           return new cCiHandler(fd_ca, NumSlots);
            }
         else
            esyslog("ERROR: no CAM slots found");
diff -uraN vdr-1.3.9/device.c pre-vdr-1.3.9/device.c
--- vdr-1.3.9/device.c	2004-05-16 14:14:47.000000000 +0200
+++ pre-vdr-1.3.9/device.c	2004-06-10 15:21:28.000000000 +0200
@@ -614,12 +614,12 @@
      }
 }
 
-bool cDevice::Poll(cPoller &Poller, int TimeoutMs)
+bool cDevice::Poll(cPoller &Poller, int TimeoutMs, bool isVideo)
 {
   return false;
 }
 
-int cDevice::PlayVideo(const uchar *Data, int Length)
+int cDevice::PlayAudioVideo(const uchar *Data, int Length, bool isVideo)
 {
   return -1;
 }
@@ -707,7 +707,7 @@
 
 void cDevice::Action(void)
 {
-  if (OpenDvr()) {
+//  if (OpenDvr()) {
      active = true;
      for (; active;) {
          // Read data from the DVR device:
@@ -727,8 +727,8 @@
          else
             break;
          }
-     CloseDvr();
-     }
+//     CloseDvr();
+//     }
 }
 
 bool cDevice::OpenDvr(void)
@@ -794,7 +794,7 @@
 
 // --- cTSBuffer -------------------------------------------------------------
 
-cTSBuffer::cTSBuffer(int File, int Size, int CardIndex)
+cTSBuffer::cTSBuffer(int File, int Size, int CardIndex, size_t mmap_size, size_t data_offset)
 {
   f = File;
   size = Size / TS_SIZE * TS_SIZE;
@@ -803,6 +803,13 @@
   buf = (f >= 0 && size >= TS_SIZE) ? MALLOC(uchar, size + TS_SIZE) : NULL;
   // the '+ TS_SIZE' allocates some extra space for handling packets that got split by a buffer roll-over
   firstRead = true;
+  mmap_buf = (uchar *) mmap(0, mmap_size, PROT_READ, MAP_SHARED, f, 0);
+  if (mmap_buf == MAP_FAILED) {
+    esyslog("mmap of recording buffer failed");
+    free(buf);
+    buf = 0;
+    }
+  data_buf = mmap_buf + data_offset;
 }
 
 cTSBuffer::~cTSBuffer()
@@ -812,6 +819,9 @@
 
 int cTSBuffer::Read(void)
 {
+  struct dvb_demux_recording_data rd;
+  int r;
+
   if (buf) {
      cPoller Poller(f, false);
      bool repeat;
@@ -819,23 +829,33 @@
      do {
         repeat = false;
         if (firstRead || Used() > TS_SIZE || Poller.Poll(100)) { // only wait if there's not enough data in the buffer
-           firstRead = false;
            if (tsRead == tsWrite)
               tsRead = tsWrite = 0; // keep the maximum buffer space available
            if (tsWrite >= size && tsRead > 0)
               tsWrite = 0;
            int free = tsRead <= tsWrite ? size - tsWrite : tsRead - tsWrite - 1;
-           if (free > 0) {
-              int r = read(f, buf + tsWrite, free);
-              if (r > 0) {
-                 total += r;
-                 tsWrite += r;
+           if (free > 0 && !firstRead) {
+              r = (ioctl(f, DVB_DEMUX_RETRIEVE_RECORDING_DATA, &rd));
+              if (errno != EAGAIN)
+                 esyslog("ERROR: DVB_DEMUX_RETRIEVE_RECORDING_DATA: %d %m", errno);
+              if (r != -1) {
+                 //isyslog("cTSBuffer::Read(): free = %d, got = %zu", free, rd.data_len);
+                 if ((int) rd.data_len > free) {
+                    esyslog("dropping %u bytes of recording data", rd.data_len - free);
+                    rd.data_len = free;
+                    }
+                 //FIXME: eleminate this stupid memcpy...
+                 memcpy(buf + tsWrite, data_buf + rd.data_offset, rd.data_len);
+                 total += rd.data_len;
+                 tsWrite += rd.data_len;
                  if (tsWrite >= size && tsRead > 0) {
                     tsWrite = 0;
                     repeat = true; // read again after a boundary roll-over
                     }
+                 CHECK(ioctl(f, DVB_DEMUX_CONFIRM_RECORDING_DATA));
                  }
               }
+           firstRead = false;
            }
         } while (repeat);
      return total;
diff -uraN vdr-1.3.9/device.h pre-vdr-1.3.9/device.h
--- vdr-1.3.9/device.h	2004-05-23 12:10:08.000000000 +0200
+++ pre-vdr-1.3.9/device.h	2004-06-10 15:21:28.000000000 +0200
@@ -367,13 +367,13 @@
        ///< all registered cAudio objects are notified.
   virtual void StillPicture(const uchar *Data, int Length);
        ///< Displays the given I-frame as a still picture.
-  virtual bool Poll(cPoller &Poller, int TimeoutMs = 0);
+  virtual bool Poll(cPoller &Poller, int TimeoutMs = 0, bool isVideo = true);
        ///< Returns true if the device itself or any of the file handles in
        ///< Poller is ready for further action.
        ///< If TimeoutMs is not zero, the device will wait up to the given number
        ///< of milleseconds before returning in case there is no immediate
        ///< need for data.
-  virtual int PlayVideo(const uchar *Data, int Length);
+  virtual int PlayAudioVideo(const uchar *Data, int Length, bool isVideo);
        ///< Actually plays the given data block as video. The data must be
        ///< part of a PES (Packetized Elementary Stream) which can contain
        ///< one video and one audio stream.
@@ -438,11 +438,13 @@
   int cardIndex;
   int tsRead;
   int tsWrite;
+  uchar *mmap_buf;
+  uchar *data_buf;
   uchar *buf;
   bool firstRead;
   int Used(void) { return tsRead <= tsWrite ? tsWrite - tsRead : size - tsRead + tsWrite; }
 public:
-  cTSBuffer(int File, int Size, int CardIndex);
+  cTSBuffer(int File, int Size, int CardIndex, size_t mmap_size, size_t data_offset);
   ~cTSBuffer();
   int Read(void);
   uchar *Get(void);
diff -uraN vdr-1.3.9/dvbdevice.c pre-vdr-1.3.9/dvbdevice.c
--- vdr-1.3.9/dvbdevice.c	2004-05-23 12:11:42.000000000 +0200
+++ pre-vdr-1.3.9/dvbdevice.c	2004-06-10 15:21:28.000000000 +0200
@@ -19,7 +19,7 @@
 #include <limits.h>
 #include <linux/videodev.h>
 #include <linux/dvb/audio.h>
-#include <linux/dvb/dmx.h>
+#include <linux/dvb/demux.h>
 #include <linux/dvb/frontend.h>
 #include <linux/dvb/video.h>
 #include <sys/ioctl.h>
@@ -41,10 +41,10 @@
 #define DEV_DVB_ADAPTER   "/dev/dvb/adapter"
 #define DEV_DVB_OSD       "osd"
 #define DEV_DVB_FRONTEND  "frontend"
-#define DEV_DVB_DVR       "dvr"
 #define DEV_DVB_DEMUX     "demux"
 #define DEV_DVB_VIDEO     "video"
 #define DEV_DVB_AUDIO     "audio"
+#define DEV_DVB_MIXER     "mixer"
 #define DEV_DVB_CA        "ca"
 
 static const char *DvbName(const char *Name, int n)
@@ -68,9 +68,8 @@
 class cDvbTuner : public cThread {
 private:
   enum eTunerStatus { tsIdle, tsSet, tsTuned, tsLocked, tsCam };
-  int fd_frontend;
   int cardIndex;
-  fe_type_t frontendType;
+  enum dvb_fe_type frontendType;
   cCiHandler *ciHandler;
   cChannel channel;
   const char *diseqcCommands;
@@ -83,14 +82,15 @@
   bool SetFrontend(void);
   virtual void Action(void);
 public:
-  cDvbTuner(int Fd_Frontend, int CardIndex, fe_type_t FrontendType, cCiHandler *CiHandler);
+  int fd_frontend;
+  cDvbTuner(int Fd_Frontend, int CardIndex, enum dvb_fe_type FrontendType, cCiHandler *CiHandler);
   virtual ~cDvbTuner();
   bool IsTunedTo(const cChannel *Channel) const;
   void Set(const cChannel *Channel, bool Tune, bool UseCa);
   bool Locked(void) { return tunerStatus >= tsLocked; }
   };
 
-cDvbTuner::cDvbTuner(int Fd_Frontend, int CardIndex, fe_type_t FrontendType, cCiHandler *CiHandler)
+cDvbTuner::cDvbTuner(int Fd_Frontend, int CardIndex, enum dvb_fe_type FrontendType, cCiHandler *CiHandler)
 {
   fd_frontend = Fd_Frontend;
   cardIndex = CardIndex;
@@ -101,7 +101,7 @@
   useCa = false;
   tunerStatus = tsIdle;
   startTime = time(NULL);
-  CHECK(ioctl(fd_frontend, FE_SET_VOLTAGE, SEC_VOLTAGE_13)); // must explicitly turn on LNB power
+  CHECK(ioctl(fd_frontend, DVB_FE_SEC_SET_VOLTAGE, DVB_SEC_VOLTAGE_13)); // must explicitly turn on LNB power
   SetDescription("tuner on device %d", cardIndex + 1);
   Start();
 }
@@ -147,7 +147,7 @@
   memset(&Frontend, 0, sizeof(Frontend));
 
   switch (frontendType) {
-    case FE_QPSK: { // DVB-S
+    case DVB_FE_DVB_S: { // DVB-S
 
          unsigned int frequency = channel.Frequency();
 
@@ -159,12 +159,12 @@
                   for (char *CurrentAction = NULL; (da = diseqc->Execute(&CurrentAction)) != cDiseqc::daNone; ) {
                       switch (da) {
                         case cDiseqc::daNone:      break;
-                        case cDiseqc::daToneOff:   CHECK(ioctl(fd_frontend, FE_SET_TONE, SEC_TONE_OFF)); break;
-                        case cDiseqc::daToneOn:    CHECK(ioctl(fd_frontend, FE_SET_TONE, SEC_TONE_ON)); break;
-                        case cDiseqc::daVoltage13: CHECK(ioctl(fd_frontend, FE_SET_VOLTAGE, SEC_VOLTAGE_13)); break;
-                        case cDiseqc::daVoltage18: CHECK(ioctl(fd_frontend, FE_SET_VOLTAGE, SEC_VOLTAGE_18)); break;
-                        case cDiseqc::daMiniA:     CHECK(ioctl(fd_frontend, FE_DISEQC_SEND_BURST, SEC_MINI_A)); break;
-                        case cDiseqc::daMiniB:     CHECK(ioctl(fd_frontend, FE_DISEQC_SEND_BURST, SEC_MINI_B)); break;
+                        case cDiseqc::daToneOff:   CHECK(ioctl(fd_frontend, DVB_FE_SEC_SET_TONE, DVB_SEC_TONE_OFF)); break;
+                        case cDiseqc::daToneOn:    CHECK(ioctl(fd_frontend, DVB_FE_SEC_SET_TONE, DVB_SEC_TONE_ON)); break;
+                        case cDiseqc::daVoltage13: CHECK(ioctl(fd_frontend, DVB_FE_SEC_SET_VOLTAGE, DVB_SEC_VOLTAGE_13)); break;
+                        case cDiseqc::daVoltage18: CHECK(ioctl(fd_frontend, DVB_FE_SEC_SET_VOLTAGE, DVB_SEC_VOLTAGE_18)); break;
+                        case cDiseqc::daMiniA:     CHECK(ioctl(fd_frontend, DVB_FE_SEC_SEND_BURST, DVB_SEC_BURST_A)); break;
+                        case cDiseqc::daMiniB:     CHECK(ioctl(fd_frontend, DVB_FE_SEC_SEND_BURST, DVB_SEC_BURST_B)); break;
                         case cDiseqc::daCodes: {
                              int n = 0;
                              uchar *codes = diseqc->Codes(n);
@@ -172,7 +172,7 @@
                                 struct dvb_diseqc_master_cmd cmd;
                                 memcpy(cmd.msg, codes, min(n, int(sizeof(cmd.msg))));
                                 cmd.msg_len = n;
-                                CHECK(ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd));
+                                CHECK(ioctl(fd_frontend, DVB_FE_DISEQC_SEND_MASTER_CMD, &cmd));
                                 }
                              }
                              break;
@@ -188,59 +188,59 @@
                }
             }
          else {
-            int tone = SEC_TONE_OFF;
+            int tone = DVB_SEC_TONE_OFF;
 
             if (frequency < (unsigned int)Setup.LnbSLOF) {
                frequency -= Setup.LnbFrequLo;
-               tone = SEC_TONE_OFF;
+               tone = DVB_SEC_TONE_OFF;
                }
             else {
                frequency -= Setup.LnbFrequHi;
-               tone = SEC_TONE_ON;
+               tone = DVB_SEC_TONE_ON;
                }
-            int volt = (channel.Polarization() == 'v' || channel.Polarization() == 'V') ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18;
-            CHECK(ioctl(fd_frontend, FE_SET_VOLTAGE, volt));
-            CHECK(ioctl(fd_frontend, FE_SET_TONE, tone));
+            int volt = (channel.Polarization() == 'v' || channel.Polarization() == 'V') ? DVB_SEC_VOLTAGE_13 : DVB_SEC_VOLTAGE_18;
+            CHECK(ioctl(fd_frontend, DVB_FE_SEC_SET_VOLTAGE, volt));
+            CHECK(ioctl(fd_frontend, DVB_FE_SEC_SET_TONE, tone));
             }
 
          frequency = abs(frequency); // Allow for C-band, where the frequency is less than the LOF
          Frontend.frequency = frequency * 1000UL;
-         Frontend.inversion = fe_spectral_inversion_t(channel.Inversion());
-         Frontend.u.qpsk.symbol_rate = channel.Srate() * 1000UL;
-         Frontend.u.qpsk.fec_inner = fe_code_rate_t(channel.CoderateH());
+         Frontend.inversion = enum dvb_fe_spectral_inversion(channel.Inversion());
+         Frontend.u.dvb_s.symbol_rate = channel.Srate() * 1000UL;
+         Frontend.u.dvb_s.fec_inner = enum dvb_fe_code_rate(channel.CoderateH());
          }
          break;
-    case FE_QAM: { // DVB-C
+    case DVB_FE_DVB_C: { // DVB-C
 
          // Frequency and symbol rate:
 
          Frontend.frequency = FrequencyToHz(channel.Frequency());
-         Frontend.inversion = fe_spectral_inversion_t(channel.Inversion());
-         Frontend.u.qam.symbol_rate = channel.Srate() * 1000UL;
-         Frontend.u.qam.fec_inner = fe_code_rate_t(channel.CoderateH());
-         Frontend.u.qam.modulation = fe_modulation_t(channel.Modulation());
+         Frontend.inversion = enum dvb_fe_spectral_inversion(channel.Inversion());
+         Frontend.u.dvb_c.symbol_rate = channel.Srate() * 1000UL;
+         Frontend.u.dvb_c.fec_inner = enum dvb_fe_code_rate(channel.CoderateH());
+         Frontend.u.dvb_c.modulation = enum dvb_fe_modulation(channel.Modulation());
          }
          break;
-    case FE_OFDM: { // DVB-T
+    case DVB_FE_DVB_T: { // DVB-T
 
          // Frequency and OFDM paramaters:
 
          Frontend.frequency = FrequencyToHz(channel.Frequency());
-         Frontend.inversion = fe_spectral_inversion_t(channel.Inversion());
-         Frontend.u.ofdm.bandwidth = fe_bandwidth_t(channel.Bandwidth());
-         Frontend.u.ofdm.code_rate_HP = fe_code_rate_t(channel.CoderateH());
-         Frontend.u.ofdm.code_rate_LP = fe_code_rate_t(channel.CoderateL());
-         Frontend.u.ofdm.constellation = fe_modulation_t(channel.Modulation());
-         Frontend.u.ofdm.transmission_mode = fe_transmit_mode_t(channel.Transmission());
-         Frontend.u.ofdm.guard_interval = fe_guard_interval_t(channel.Guard());
-         Frontend.u.ofdm.hierarchy_information = fe_hierarchy_t(channel.Hierarchy());
+         Frontend.inversion = enum dvb_fe_spectral_inversion(channel.Inversion());
+         Frontend.u.dvb_t.bandwidth = enum dvb_fe_bandwidth(channel.Bandwidth());
+         Frontend.u.dvb_t.code_rate_HP = enum dvb_fe_code_rate(channel.CoderateH());
+         Frontend.u.dvb_t.code_rate_LP = enum dvb_fe_code_rate(channel.CoderateL());
+         Frontend.u.dvb_t.constellation = enum dvb_fe_modulation(channel.Modulation());
+         Frontend.u.dvb_t.transmission_mode = enum dvb_fe_transmit_mode(channel.Transmission());
+         Frontend.u.dvb_t.guard_interval = enum dvb_fe_guard_interval(channel.Guard());
+         Frontend.u.dvb_t.hierarchy_information = enum dvb_fe_hierarchy(channel.Hierarchy());
          }
          break;
     default:
          esyslog("ERROR: attempt to set channel with unknown DVB frontend type");
          return false;
     }
-  if (ioctl(fd_frontend, FE_SET_FRONTEND, &Frontend) < 0) {
+  if (ioctl(fd_frontend, DVB_FE_SET_FRONTEND, &Frontend) < 0) {
      esyslog("ERROR: frontend %d: %m", cardIndex);
      return false;
      }
@@ -255,15 +255,15 @@
         if (tunerStatus == tsSet)
            tunerStatus = SetFrontend() ? tsTuned : tsIdle;
         if (tunerStatus == tsTuned) {
-           fe_status_t status = fe_status_t(0);
-           CHECK(ioctl(fd_frontend, FE_READ_STATUS, &status));
-           if (status & FE_HAS_LOCK)
+           enum dvb_fe_status status = enum dvb_fe_status(0);
+           CHECK(ioctl(fd_frontend, DVB_FE_READ_STATUS, &status));
+           if (status & DVB_FE_HAS_LOCK)
               tunerStatus = tsLocked;
            }
         if (tunerStatus != tsIdle) {
            dvb_frontend_event event;
-           if (ioctl(fd_frontend, FE_GET_EVENT, &event) == 0) {
-              if (event.status & FE_REINIT) {
+           if (ioctl(fd_frontend, DVB_FE_GET_EVENT, &event) == 0) {
+              if (event.status & DVB_FE_REINIT) {
                  tunerStatus = tsSet;
                  esyslog("ERROR: frontend %d was reinitialized - re-tuning", cardIndex);
                  continue;
@@ -300,10 +300,13 @@
 
 int cDvbDevice::devVideoOffset = -1;
 
+/* ugly */
+int g_fd_frontend = -1;
+
 cDvbDevice::cDvbDevice(int n)
 {
   dvbTuner = NULL;
-  frontendType = fe_type_t(-1); // don't know how else to initialize this - there is no FE_UNKNOWN
+  frontendType = enum dvb_fe_type(-1); // don't know how else to initialize this - there is no DVB_FE_UNKNOWN
   spuDecoder = NULL;
   playMode = pmNone;
 
@@ -316,11 +319,15 @@
   fd_osd      = DvbOpen(DEV_DVB_OSD,    n, O_RDWR);
   fd_video    = DvbOpen(DEV_DVB_VIDEO,  n, O_RDWR | O_NONBLOCK);
   fd_audio    = DvbOpen(DEV_DVB_AUDIO,  n, O_RDWR | O_NONBLOCK);
-  fd_stc      = DvbOpen(DEV_DVB_DEMUX,  n, O_RDWR);
+  fd_mixer    = DvbOpen(DEV_DVB_MIXER,  n, O_RDWR | O_NONBLOCK);
+  fd_demux    = DvbOpen(DEV_DVB_DEMUX,  n, O_WRONLY);
+  fd_stc      = DvbOpen(DEV_DVB_DEMUX,  n, O_RDONLY);
 
   // The DVR device (will be opened and closed as needed):
 
   fd_dvr = -1;
+  g_fd_frontend = fd_frontend;
+  OpenDvr();
 
   // The offset of the /dev/video devices:
 
@@ -353,13 +360,13 @@
 
   // Video format:
 
-  SetVideoFormat(Setup.VideoFormat ? VIDEO_FORMAT_16_9 : VIDEO_FORMAT_4_3);
+  SetVideoFormat(Setup.VideoFormat);
 
   // We only check the devices that must be present - the others will be checked before accessing them://XXX
 
   if (fd_frontend >= 0) {
      dvb_frontend_info feinfo;
-     if (ioctl(fd_frontend, FE_GET_INFO, &feinfo) >= 0) {
+     if (ioctl(fd_frontend, DVB_FE_GET_INFO, &feinfo) >= 0) {
         frontendType = feinfo.type;
         ciHandler = cCiHandler::CreateCiHandler(DvbName(DEV_DVB_CA, n));
         dvbTuner = new cDvbTuner(fd_frontend, CardIndex(), frontendType, ciHandler);
@@ -372,6 +379,8 @@
 
   aPid1 = aPid2 = 0;
 
+  SetPlayMode(pmNone);
+
   StartSectionHandler();
 }
 
@@ -555,15 +564,15 @@
 void cDvbDevice::SetVideoFormat(bool VideoFormat16_9)
 {
   if (HasDecoder())
-     CHECK(ioctl(fd_video, VIDEO_SET_FORMAT, VideoFormat16_9 ? VIDEO_FORMAT_16_9 : VIDEO_FORMAT_4_3));
+     CHECK(ioctl(fd_video, DVB_VIDEO_SET_SCREEN_ASPECT_RATIO, VideoFormat16_9 ? DVB_VIDEO_SCREEN_16_9 : DVB_VIDEO_SCREEN_4_3));
 }
 
 eVideoSystem cDvbDevice::GetVideoSystem(void)
 {
   eVideoSystem VideoSytem = vsPAL;
-  video_size_t vs;
-  if (ioctl(fd_video, VIDEO_GET_SIZE, &vs) == 0) {
-     if (vs.h == 480 || vs.h == 240)
+  struct dvb_video_sequence_header seqhdr;
+  if (ioctl(fd_video, DVB_VIDEO_GET_SEQHDR, &seqhdr) == 0) {
+     if (seqhdr.h == 480 || seqhdr.h == 240)
         VideoSytem = vsNTSC;
      }
   else
@@ -571,43 +580,66 @@
   return VideoSytem;
 }
 
-//                            ptAudio        ptVideo        ptPcr        ptTeletext        ptDolby        ptOther
-dmx_pes_type_t PesTypes[] = { DMX_PES_AUDIO, DMX_PES_VIDEO, DMX_PES_PCR, DMX_PES_TELETEXT, DMX_PES_OTHER, DMX_PES_OTHER };
-
 bool cDvbDevice::SetPid(cPidHandle *Handle, int Type, bool On)
 {
+  struct dvb_video_source vsrc;
+  struct dvb_audio_source asrc;
+
+  vsrc.format = DVB_VIDEO_MPEG2_PES;
+  vsrc.type = DVB_VIDEO_SOURCE_DEMUX;
+  vsrc.fd = -1; //FIXME
+  asrc.format = DVB_AUDIO_FORMAT_PES;
+  asrc.type = DVB_AUDIO_SOURCE_DEMUX;
+  asrc.input = -1; //FIXME
+
   if (Handle->pid) {
-     dmx_pes_filter_params pesFilterParams;
-     memset(&pesFilterParams, 0, sizeof(pesFilterParams));
      if (On) {
         if (Handle->handle < 0) {
-           Handle->handle = DvbOpen(DEV_DVB_DEMUX, CardIndex(), O_RDWR | O_NONBLOCK, true);
+           Handle->handle = DvbOpen(DEV_DVB_DEMUX, CardIndex(), O_RDONLY | O_NONBLOCK, true);
            if (Handle->handle < 0)
               return false;
            }
-        pesFilterParams.pid     = Handle->pid;
-        pesFilterParams.input   = DMX_IN_FRONTEND;
-        pesFilterParams.output  = (Type <= ptTeletext && Handle->used <= 1) ? DMX_OUT_DECODER : DMX_OUT_TS_TAP;
-        pesFilterParams.pes_type= PesTypes[Type < ptOther ? Type : ptOther];
-        pesFilterParams.flags   = DMX_IMMEDIATE_START;
-        if (ioctl(Handle->handle, DMX_SET_PES_FILTER, &pesFilterParams) < 0) {
-           LOG_ERROR;
-           return false;
+        if (Type <= ptTeletext && Handle->used <= 1) {
+           if (Type == ptAudio) {
+              asrc.input = Handle->handle;
+              CHECK(ioctl(fd_audio, DVB_AUDIO_SET_SOURCE, &asrc));
+              asrc.input = Handle->handle;
+              CHECK(ioctl(fd_audio, DVB_AUDIO_START));
+	      CHECK(ioctl(Handle->handle, DVB_DEMUX_SET_TS_DECODER_FEED, Handle->pid));
+              }
+           else if (Type == ptVideo) {
+              vsrc.fd = Handle->handle;
+              CHECK(ioctl(fd_video, DVB_VIDEO_SET_SOURCE, &vsrc));
+              vsrc.fd = Handle->handle;
+              CHECK(ioctl(fd_video, DVB_VIDEO_PLAY, 1000));
+	      CHECK(ioctl(Handle->handle, DVB_DEMUX_SET_TS_DECODER_FEED, Handle->pid));
+              }
+           //FIXME PCR/teletext
            }
+        else {
+            //FIXME
+            struct dvb_demux_recording_pids rp;
+            struct dvb_rec_pid rpid;
+            rpid.pid = Handle->pid;
+            rpid.flags = DVB_DEMUX_REC_EVENT_NONE;
+            rp.n_pids = 1;
+            rp.pids = &rpid;
+            CHECK(ioctl(fd_dvr, DVB_DEMUX_ADD_RECORDING_PIDS, &rp));
+            isyslog("cDvbDevice::SetPid(): recording 0x%04x", Handle->pid);
+          }
+        }
+     else if (Handle->used > 0) {
+        struct dvb_demux_recording_pids rp;
+        struct dvb_rec_pid rpid;
+        rpid.pid = Handle->pid;
+        rpid.flags = DVB_DEMUX_REC_EVENT_NONE;
+        rp.n_pids = 1;
+        rp.pids = &rpid;
+        CHECK(ioctl(fd_dvr, DVB_DEMUX_DEL_RECORDING_PIDS, &rp));
+        isyslog("cDvbDevice::SetPid(): stopped 0x%04x", Handle->pid);
         }
      else if (!Handle->used) {
-        CHECK(ioctl(Handle->handle, DMX_STOP));
-        if (Type <= ptTeletext) {
-           pesFilterParams.pid     = 0x1FFF;
-           pesFilterParams.input   = DMX_IN_FRONTEND;
-           pesFilterParams.output  = DMX_OUT_DECODER;
-           pesFilterParams.pes_type= PesTypes[Type];
-           pesFilterParams.flags   = DMX_IMMEDIATE_START;
-           CHECK(ioctl(Handle->handle, DMX_SET_PES_FILTER, &pesFilterParams));
-           if (PesTypes[Type] == DMX_PES_VIDEO) // let's only do this once
-              SetPlayMode(pmNone); // necessary to switch a PID from DMX_PES_VIDEO/AUDIO to DMX_PES_OTHER
-           }
-        close(Handle->handle);
+        CHECK(close(Handle->handle));
         Handle->handle = -1;
         }
      }
@@ -617,16 +649,18 @@
 int cDvbDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask)
 {
   const char *FileName = DvbName(DEV_DVB_DEMUX, CardIndex());
-  int f = open(FileName, O_RDWR | O_NONBLOCK);
+  int f = open(FileName, O_RDONLY | O_NONBLOCK);
   if (f >= 0) {
-     dmx_sct_filter_params sctFilterParams;
+     struct dvb_demux_section_filter sctFilterParams;
      memset(&sctFilterParams, 0, sizeof(sctFilterParams));
      sctFilterParams.pid = Pid;
      sctFilterParams.timeout = 0;
-     sctFilterParams.flags = DMX_IMMEDIATE_START;
-     sctFilterParams.filter.filter[0] = Tid;
-     sctFilterParams.filter.mask[0] = Mask;
-     if (ioctl(f, DMX_SET_FILTER, &sctFilterParams) >= 0)
+     sctFilterParams.flags = dvb_demux_section_filter_flags(0); //FIXME: DVB_DEMUX_CHECK_CRC
+     sctFilterParams.filter[0] = Tid;
+     sctFilterParams.mask[0] = Mask;
+     sctFilterParams.buffer_size = 8192;
+     sctFilterParams.buffer_threshold = 64; //FIXME
+     if (ioctl(f, DVB_DEMUX_SET_SECTION_FILTER, &sctFilterParams) >= 0)
         return f;
      else {
         esyslog("ERROR: can't set filter (pid=%d, tid=%02X, mask=%02X): %m", Pid, Tid, Mask);
@@ -642,10 +676,10 @@
 {
   // Avoid noise while switching:
 
-  CHECK(ioctl(fd_audio, AUDIO_SET_MUTE, true));
-  CHECK(ioctl(fd_video, VIDEO_SET_BLANK, true));
-  CHECK(ioctl(fd_audio, AUDIO_CLEAR_BUFFER));
-  CHECK(ioctl(fd_video, VIDEO_CLEAR_BUFFER));
+  CHECK(ioctl(fd_audio, DVB_AUDIO_STOP));
+  //FIXME CHECK(ioctl(fd_video, VIDEO_SET_BLANK, 1));
+  CHECK(ioctl(fd_audio, DVB_AUDIO_CLEAR_BUFFER));
+  CHECK(ioctl(fd_video, DVB_VIDEO_CLEAR_BUFFER));
 
   // Turn off live PIDs:
 
@@ -660,9 +694,9 @@
 {
   int type = Source & cSource::st_Mask;
   return type == cSource::stNone
-      || type == cSource::stCable && frontendType == FE_QAM
-      || type == cSource::stSat   && frontendType == FE_QPSK
-      || type == cSource::stTerr  && frontendType == FE_OFDM;
+      || type == cSource::stCable && frontendType == DVB_FE_DVB_C
+      || type == cSource::stSat   && frontendType == DVB_FE_DVB_S
+      || type == cSource::stTerr  && frontendType == DVB_FE_DVB_T;
   return true;
 }
 
@@ -717,12 +751,12 @@
                             || IsEncrypted && pidHandles[ptVideo].pid != Channel->Vpid() // CA channels can only be decrypted in "live" mode
                             || !IsPrimaryDevice()
                             || LiveView // for a new live view the old PIDs need to be turned off
-                            || pidHandles[ptVideo].pid == Channel->Vpid() // for recording the PIDs must be shifted from DMX_PES_AUDIO/VIDEO to DMX_PES_OTHER
+                            || pidHandles[ptVideo].pid == Channel->Vpid() // for recording the PIDs must be shifted from DEMUX_PES_AUDIO/VIDEO to DEMUX_PES_OTHER
                             );
 
   bool StartTransferMode = IsPrimaryDevice() && !IsEncrypted && !DoTune
-                           && (LiveView && HasPid(Channel->Vpid()) && pidHandles[ptVideo].pid != Channel->Vpid() // the PID is already set as DMX_PES_OTHER
-                              || !LiveView && pidHandles[ptVideo].pid == Channel->Vpid() // a recording is going to shift the PIDs from DMX_PES_AUDIO/VIDEO to DMX_PES_OTHER
+                           && (LiveView && HasPid(Channel->Vpid()) && pidHandles[ptVideo].pid != Channel->Vpid() // the PID is already set as DEMUX_PES_OTHER
+                              || !LiveView && pidHandles[ptVideo].pid == Channel->Vpid() // a recording is going to shift the PIDs from DEMUX_PES_AUDIO/VIDEO to DEMUX_PES_OTHER
                               );
 
   bool TurnOnLivePIDs = HasDecoder() && !StartTransferMode
@@ -765,7 +799,7 @@
         }
      if (IsPrimaryDevice())
         AddPid(Channel->Tpid(), ptTeletext);
-     CHECK(ioctl(fd_audio, AUDIO_SET_AV_SYNC, true));
+     CHECK(ioctl(fd_audio, DVB_AUDIO_SET_SYNC, 1));
      }
   else if (StartTransferMode)
      cControl::Launch(new cTransferControl(this, Channel->Vpid(), Channel->Apid1(), Channel->Apid2(), Channel->Dpid1(), Channel->Dpid2()));
@@ -781,9 +815,13 @@
 void cDvbDevice::SetVolumeDevice(int Volume)
 {
   if (HasDecoder()) {
-     audio_mixer_t am;
-     am.volume_left = am.volume_right = Volume;
-     CHECK(ioctl(fd_audio, AUDIO_SET_MIXER, &am));
+     struct dvb_audio_output_level ol = {
+        output: DVB_AUDIO_OUTPUT_TV,
+        level_l: Volume,
+        level_r: Volume
+        //FIXME
+     };
+     CHECK(ioctl(fd_mixer, DVB_AUDIO_SET_OUTPUT_LEVEL, &ol));
      }
 }
 
@@ -829,65 +867,62 @@
 
 bool cDvbDevice::SetPlayMode(ePlayMode PlayMode)
 {
-  if (PlayMode != pmExtern_THIS_SHOULD_BE_AVOIDED && fd_video < 0 && fd_audio < 0) {
+   struct dvb_video_source vsrc;
+   struct dvb_audio_source asrc;
+ 
+   vsrc.format = DVB_VIDEO_MPEG2_PES;
+   vsrc.type = DVB_VIDEO_SOURCE_MEMORY;
+   asrc.format = DVB_AUDIO_FORMAT_PES;
+   asrc.type = DVB_AUDIO_SOURCE_MEMORY;
+ 
+   if (PlayMode != pmExtern_THIS_SHOULD_BE_AVOIDED && fd_video < 0 && fd_audio < 0) {
      // reopen the devices
      fd_video = DvbOpen(DEV_DVB_VIDEO,  CardIndex(), O_RDWR | O_NONBLOCK);
      fd_audio = DvbOpen(DEV_DVB_AUDIO,  CardIndex(), O_RDWR | O_NONBLOCK);
+     fd_mixer = DvbOpen(DEV_DVB_MIXER,  CardIndex(), O_RDWR | O_NONBLOCK);
      SetVideoFormat(Setup.VideoFormat);
      }
 
   switch (PlayMode) {
     case pmNone:
-         // special handling to return from PCM replay:
-         CHECK(ioctl(fd_video, VIDEO_SET_BLANK, true));
-         CHECK(ioctl(fd_video, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY));
-         CHECK(ioctl(fd_video, VIDEO_PLAY));
-
-         CHECK(ioctl(fd_video, VIDEO_STOP, true));
-         CHECK(ioctl(fd_audio, AUDIO_STOP, true));
-         CHECK(ioctl(fd_video, VIDEO_CLEAR_BUFFER));
-         CHECK(ioctl(fd_audio, AUDIO_CLEAR_BUFFER));
-         CHECK(ioctl(fd_video, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX));
-         CHECK(ioctl(fd_audio, AUDIO_SELECT_SOURCE, AUDIO_SOURCE_DEMUX));
-         CHECK(ioctl(fd_audio, AUDIO_SET_AV_SYNC, true));
-         CHECK(ioctl(fd_audio, AUDIO_SET_MUTE, false));
+	 CHECK(ioctl(fd_demux, DVB_DEMUX_SET_SOURCE, &dvbTuner->fd_frontend));
+	 CHECK(ioctl(fd_video, DVB_VIDEO_CLEAR_BUFFER));
+	 CHECK(ioctl(fd_audio, DVB_AUDIO_CLEAR_BUFFER));
+	 CHECK(ioctl(fd_audio, DVB_AUDIO_SET_SYNC, 1));
+	 CHECK(ioctl(fd_audio, DVB_AUDIO_START));
          break;
     case pmAudioVideo:
          if (playMode == pmNone)
             TurnOffLiveMode();
-         // continue with next...
+	 CHECK(ioctl(fd_video, DVB_VIDEO_SET_SOURCE, &vsrc));
+	 CHECK(ioctl(fd_video, DVB_VIDEO_CLEAR_BUFFER));
+	 CHECK(ioctl(fd_video, DVB_VIDEO_PLAY, 1000));
+	 // continue with next...
     case pmAudioOnlyBlack:
-         CHECK(ioctl(fd_video, VIDEO_SET_BLANK, true));
-         CHECK(ioctl(fd_audio, AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY));
-         CHECK(ioctl(fd_audio, AUDIO_SET_AV_SYNC, PlayMode == pmAudioVideo));
-         CHECK(ioctl(fd_audio, AUDIO_PLAY));
-         CHECK(ioctl(fd_video, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY));
-         CHECK(ioctl(fd_video, VIDEO_PLAY));
-         break;
+	 //FIXME CHECK(ioctl(fd_video, VIDEO_SET_BLANK, true));
+	 CHECK(ioctl(fd_audio, DVB_AUDIO_STOP));
+	 CHECK(ioctl(fd_audio, DVB_AUDIO_SET_SOURCE, &asrc));
+	 CHECK(ioctl(fd_audio, DVB_AUDIO_CLEAR_BUFFER));
+	 CHECK(ioctl(fd_audio, DVB_AUDIO_SET_SYNC, PlayMode == pmAudioVideo))
+	 CHECK(ioctl(fd_audio, DVB_AUDIO_START));   
+	 break;
     case pmAudioOnly:
-         CHECK(ioctl(fd_video, VIDEO_SET_BLANK, true));
-         CHECK(ioctl(fd_audio, AUDIO_STOP, true));
-         CHECK(ioctl(fd_audio, AUDIO_CLEAR_BUFFER));
-         CHECK(ioctl(fd_audio, AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY));
-         CHECK(ioctl(fd_audio, AUDIO_SET_AV_SYNC, false));
-         CHECK(ioctl(fd_audio, AUDIO_PLAY));
-         CHECK(ioctl(fd_video, VIDEO_SET_BLANK, false));
-         break;
+	//FIXME CHECK(ioctl(fd_video, VIDEO_SET_BLANK, true));
+	CHECK(ioctl(fd_audio, DVB_AUDIO_STOP));
+	CHECK(ioctl(fd_audio, DVB_AUDIO_SET_SOURCE, &asrc));
+	CHECK(ioctl(fd_audio, DVB_AUDIO_CLEAR_BUFFER));
+	CHECK(ioctl(fd_audio, DVB_AUDIO_SET_SYNC, 0));
+	CHECK(ioctl(fd_audio, DVB_AUDIO_START));
+	//FIXME CHECK(ioctl(fd_video, VIDEO_SET_BLANK, false))
+	break;
     case pmVideoOnly:
-         CHECK(ioctl(fd_video, VIDEO_SET_BLANK, true));
-         CHECK(ioctl(fd_video, VIDEO_STOP, true));
-         CHECK(ioctl(fd_audio, AUDIO_SELECT_SOURCE, AUDIO_SOURCE_DEMUX));
-         CHECK(ioctl(fd_audio, AUDIO_SET_AV_SYNC, false));
-         CHECK(ioctl(fd_audio, AUDIO_PLAY));
-         CHECK(ioctl(fd_video, VIDEO_CLEAR_BUFFER));
-         CHECK(ioctl(fd_video, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY));
-         CHECK(ioctl(fd_video, VIDEO_PLAY));
          break;
     case pmExtern_THIS_SHOULD_BE_AVOIDED:
          close(fd_video);
          close(fd_audio);
-         fd_video = fd_audio = -1;
-         break;
+         close(fd_mixer);
+	 fd_video = fd_audio = fd_mixer = -1;
+	 break;
     }
   playMode = PlayMode;
   return true;
@@ -896,9 +931,8 @@
 int64_t cDvbDevice::GetSTC(void)
 {
   if (fd_stc >= 0) {
-     struct dmx_stc stc;
-     stc.num = 0;
-     if (ioctl(fd_stc, DMX_GET_STC, &stc) == -1) {
+     struct dvb_demux_stc stc;
+     if (ioctl(fd_stc, DVB_DEMUX_GET_STC, &stc) == -1) {
         esyslog("ERROR: stc %d: %m", CardIndex() + 1);
         return -1;
         }
@@ -909,16 +943,17 @@
 
 void cDvbDevice::TrickSpeed(int Speed)
 {
+esyslog("TrickSpeed %d", Speed);
   if (fd_video >= 0)
-     CHECK(ioctl(fd_video, VIDEO_SLOWMOTION, Speed));
+     CHECK(ioctl(fd_video, DVB_VIDEO_PLAY, 12000 / Speed));
 }
 
 void cDvbDevice::Clear(void)
 {
   if (fd_video >= 0)
-     CHECK(ioctl(fd_video, VIDEO_CLEAR_BUFFER));
+     CHECK(ioctl(fd_video, DVB_VIDEO_CLEAR_BUFFER));
   if (fd_audio >= 0)
-     CHECK(ioctl(fd_audio, AUDIO_CLEAR_BUFFER));
+     CHECK(ioctl(fd_audio, DVB_AUDIO_CLEAR_BUFFER));
   cDevice::Clear();
 }
 
@@ -926,13 +961,13 @@
 {
   if (playMode == pmAudioOnly || playMode == pmAudioOnlyBlack) {
      if (fd_audio >= 0)
-        CHECK(ioctl(fd_audio, AUDIO_CONTINUE));
+        CHECK(ioctl(fd_audio, DVB_AUDIO_START));
      }
   else {
      if (fd_audio >= 0)
-        CHECK(ioctl(fd_audio, AUDIO_SET_AV_SYNC, true));
+        CHECK(ioctl(fd_audio, DVB_AUDIO_SET_SYNC, 1));
      if (fd_video >= 0)
-        CHECK(ioctl(fd_video, VIDEO_CONTINUE));
+        CHECK(ioctl(fd_video, DVB_VIDEO_CONTINUE));
      }
   cDevice::Play();
 }
@@ -941,13 +976,11 @@
 {
   if (playMode == pmAudioOnly || playMode == pmAudioOnlyBlack) {
      if (fd_audio >= 0)
-        CHECK(ioctl(fd_audio, AUDIO_PAUSE));
+        CHECK(ioctl(fd_audio, DVB_AUDIO_STOP));
      }
   else {
-     if (fd_audio >= 0)
-        CHECK(ioctl(fd_audio, AUDIO_SET_AV_SYNC, false));
      if (fd_video >= 0)
-        CHECK(ioctl(fd_video, VIDEO_FREEZE));
+        CHECK(ioctl(fd_video, DVB_VIDEO_PLAY, 0));
      }
   cDevice::Freeze();
 }
@@ -955,8 +988,7 @@
 void cDvbDevice::Mute(void)
 {
   if (fd_audio >= 0) {
-     CHECK(ioctl(fd_audio, AUDIO_SET_AV_SYNC, false));
-     CHECK(ioctl(fd_audio, AUDIO_SET_MUTE, true));
+     CHECK(ioctl(fd_audio, DVB_AUDIO_STOP));
      }
   cDevice::Mute();
 }
@@ -1041,14 +1073,22 @@
            else
               i++;
            }
-     video_still_picture sp = { buf, blen };
-     CHECK(ioctl(fd_video, VIDEO_STILLPICTURE, &sp));
+     struct dvb_video_still_picture sp = {
+        format: DVB_VIDEO_STILL_IFRAME,
+        data  : buf,
+        size  : blen
+     };
+     CHECK(ioctl(fd_video, DVB_VIDEO_STILLPICTURE, &sp));
      free(buf);
      }
   else {
      // non-PES data
-     video_still_picture sp = { (char *)Data, Length };
-     CHECK(ioctl(fd_video, VIDEO_STILLPICTURE, &sp));
+     struct dvb_video_still_picture sp = {
+        format: DVB_VIDEO_STILL_IFRAME,
+        data  : (const char *) Data,
+        size  : Length
+     };
+     CHECK(ioctl(fd_video, DVB_VIDEO_STILLPICTURE, &sp));
      }
 #else
 #define MIN_IFRAME 400000
@@ -1059,18 +1099,38 @@
 #endif
 }
 
-bool cDvbDevice::Poll(cPoller &Poller, int TimeoutMs)
+bool cDvbDevice::Poll(cPoller &Poller, int TimeoutMs, bool isVideo)
 {
-  Poller.Add((playMode == pmAudioOnly || playMode == pmAudioOnlyBlack) ? fd_audio : fd_video, true);
+  if (isVideo) {
+     //isyslog("polling video");
+     Poller.Add(fd_video, true);
+     }
+  else {
+     //isyslog("polling audio");
+     Poller.Add(fd_audio, true);
+     }
   return Poller.Poll(TimeoutMs);
 }
 
-int cDvbDevice::PlayVideo(const uchar *Data, int Length)
+int cDvbDevice::PlayAudioVideo(const uchar *Data, int Length, bool isVideo)
 {
-  int fd = (playMode == pmAudioOnly || playMode == pmAudioOnlyBlack) ? fd_audio : fd_video;
-  if (fd >= 0)
-     return write(fd, Data, Length);
-  return -1;
+  int fd = isVideo ? fd_video : fd_audio;
+  int ret = -1;
+  isyslog("playing %d bytes of %s", Length, isVideo ? "video":"audio");
+  if (Data[0] != 0 || Data[1] != 0 || Data[2] != 1)
+     esyslog("playing: error not PES start");
+  else if (isVideo && (Data[3] & 0xf0) != 0xe0)
+     esyslog("playing: error not video");
+  else if (!isVideo && (Data[3] & 0xe0) != 0xc0)
+     esyslog("playing: error not audio");
+  else if ((Data[4] << 8 | Data[5]) + 6 != Length)
+     esyslog("playing: error PES Length");
+  if (fd >= 0) {
+     ret = write(fd, Data, Length);
+     if (ret != Length)
+        esyslog("playing: error write Length");
+     }
+  return ret;
 }
 
 void cDvbDevice::PlayAudio(const uchar *Data, int Length)
@@ -1079,13 +1139,43 @@
   cDevice::PlayAudio(Data, Length);
 }
 
-bool cDvbDevice::OpenDvr(void)
+bool cDvbDevice::OpenDvr()
 {
+  struct dvb_demux_caps caps;
+  struct dvb_demux_recording_filter f;
+
+  isyslog("cDvbDevice::OpenDvr()");
   CloseDvr();
-  fd_dvr = DvbOpen(DEV_DVB_DVR, CardIndex(), O_RDONLY | O_NONBLOCK, true);
-  if (fd_dvr >= 0)
-     tsBuffer = new cTSBuffer(fd_dvr, MEGABYTE(2), CardIndex() + 1);
-  return fd_dvr >= 0;
+  fd_dvr = DvbOpen(DEV_DVB_DEMUX, CardIndex(), O_RDWR | O_NONBLOCK, true);
+  if (fd_dvr < 0)
+    return false;
+
+  caps.cap = DVB_DEMUX_CAP_NUM_RECORDING_FILTERS;
+  CHECK(ioctl(fd_dvr, DVB_DEMUX_GET_CAPS, &caps));
+  isyslog("device has %d recording filters", caps.val);
+
+  caps.cap = DVB_DEMUX_CAP_RECORDING_TYPES;
+  CHECK(ioctl(fd_dvr, DVB_DEMUX_GET_CAPS, &caps));
+  isyslog("supported recording types: %c%c%c",
+	  caps.val & DVB_DEMUX_REC_TYPE_SIMPLE_READ ? 'S' : '-',
+	  caps.val & DVB_DEMUX_REC_TYPE_BUFFERED ? 'B' : '-',
+	  caps.val & DVB_DEMUX_REC_TYPE_EVENT_LOGGING ? 'E' : '-');
+
+
+  if (ioctl(fd_dvr, DVB_DEMUX_SET_SOURCE, &g_fd_frontend) == -1)
+  	return false;
+
+  memset(&f, 0, sizeof(f));
+  f.type = DVB_DEMUX_REC_TYPE_BUFFERED;
+  f.buffer_size = 128 * 1024;
+  f.buffer_threshold = 32 * 1024;
+
+  CHECK(ioctl(fd_dvr, DVB_DEMUX_SET_RECORDING_FILTER, &f));
+  isyslog("recording buffer size %zd, threshold %zd", f.buffer_size, f.buffer_threshold);
+
+  tsBuffer = new cTSBuffer(fd_dvr, MEGABYTE(2), CardIndex() + 1,
+                           f.mmap_size, f.data_offset);
+  return true;
 }
 
 void cDvbDevice::CloseDvr(void)
diff -uraN vdr-1.3.9/dvbdevice.h pre-vdr-1.3.9/dvbdevice.h
--- vdr-1.3.9/dvbdevice.h	2004-04-17 13:56:22.000000000 +0200
+++ pre-vdr-1.3.9/dvbdevice.h	2004-06-10 15:21:28.000000000 +0200
@@ -15,8 +15,8 @@
 #include "device.h"
 #include "dvbspu.h"
 
-#if DVB_API_VERSION != 3
-#error VDR requires Linux DVB driver API version 3!
+#if DVB_API_VERSION != 4
+#error VDR requires Linux DVB driver API version 4!
 #endif
 
 #define MAXDVBDEVICES  4
@@ -35,8 +35,8 @@
          ///< Must be called before accessing any DVB functions.
          ///< \return True if any devices are available.
 private:
-  fe_type_t frontendType;
-  int fd_osd, fd_audio, fd_video, fd_dvr, fd_stc;
+  enum dvb_fe_type frontendType;
+  int fd_osd, fd_audio, fd_mixer, fd_video, fd_demux, fd_dvr, fd_stc;
 protected:
   virtual void MakePrimaryDevice(bool On);
 public:
@@ -114,8 +114,8 @@
   virtual void Freeze(void);
   virtual void Mute(void);
   virtual void StillPicture(const uchar *Data, int Length);
-  virtual bool Poll(cPoller &Poller, int TimeoutMs = 0);
-  virtual int PlayVideo(const uchar *Data, int Length);
+  virtual bool Poll(cPoller &Poller, int TimeoutMs = 0, bool isVideo = true);
+  virtual int PlayAudioVideo(const uchar *Data, int Length, bool isVideo);
   virtual void PlayAudio(const uchar *Data, int Length);
 
 // Receiver facilities
diff -uraN vdr-1.3.9/dvbosd.c pre-vdr-1.3.9/dvbosd.c
--- vdr-1.3.9/dvbosd.c	2004-05-01 17:10:44.000000000 +0200
+++ pre-vdr-1.3.9/dvbosd.c	2004-06-10 15:21:28.000000000 +0200
@@ -58,10 +58,10 @@
   return Result;
 }
 
-void cDvbOsd::Cmd(OSD_Command cmd, int color, int x0, int y0, int x1, int y1, const void *data)
+void cDvbOsd::Cmd(enum av7110_osd_command cmd, int color, int x0, int y0, int x1, int y1, const void *data)
 {
   if (osdDev >= 0) {
-     osd_cmd_t dc;
+     struct av7110_osd_cmd dc;
      dc.cmd   = cmd;
      dc.color = color;
      dc.x0    = x0;
@@ -69,7 +69,7 @@
      dc.x1    = x1;
      dc.y1    = y1;
      dc.data  = (void *)data;
-     ioctl(osdDev, OSD_SEND_CMD, &dc);
+     ioctl(osdDev, AV7110_OSD_SEND_CMD, &dc);
      }
 }
 
diff -uraN vdr-1.3.9/dvbosd.h pre-vdr-1.3.9/dvbosd.h
--- vdr-1.3.9/dvbosd.h	2004-04-30 15:44:16.000000000 +0200
+++ pre-vdr-1.3.9/dvbosd.h	2004-06-10 15:21:28.000000000 +0200
@@ -10,7 +10,7 @@
 #ifndef __DVBOSD_H
 #define __DVBOSD_H
 
-#include <linux/dvb/osd.h>
+#include "av7110-osd.h"
 #include "dvbdevice.h"
 #include "osd.h"
 
@@ -18,7 +18,7 @@
 private:
   int osdDev;
   bool shown;
-  void Cmd(OSD_Command cmd, int color = 0, int x0 = 0, int y0 = 0, int x1 = 0, int y1 = 0, const void *data = NULL);
+  void Cmd(enum av7110_osd_command cmd, int color = 0, int x0 = 0, int y0 = 0, int x1 = 0, int y1 = 0, const void *data = NULL);
 public:
   cDvbOsd(int Left, int Top, int OsdDev);
   virtual ~cDvbOsd();
diff -uraN vdr-1.3.9/dvbplayer.c pre-vdr-1.3.9/dvbplayer.c
--- vdr-1.3.9/dvbplayer.c	2003-10-18 13:31:54.000000000 +0200
+++ pre-vdr-1.3.9/dvbplayer.c	2004-06-10 15:21:28.000000000 +0200
@@ -408,6 +408,7 @@
   uchar *b = NULL;
   uchar *p = NULL;
   int pc = 0;
+  int pesLen = 0;
 
   readIndex = Resume();
   if (readIndex >= 0)
@@ -418,9 +419,11 @@
   int AudioTrack = 0; // -1 = any, 0 = none, >0 = audioTrack
 
   running = true;
+  bool isVideo = false;
+  bool isAudio = false;
   while (running && (NextFile() || readIndex >= 0 || ringBuffer->Available())) {
         cPoller Poller;
-        if (DevicePoll(Poller, 100)) {
+        if (DevicePoll(Poller, 100, isVideo)) {
 
            LOCK_THREAD;
 
@@ -476,6 +479,7 @@
                     }
                  int r = nonBlockingFileReader->Read(replayFile, b, Length);
                  if (r > 0) {
+                    //isyslog("payer: read %d bytes", r);
                     if (AudioTrack == 0)
                        StripAudioPackets(b, r);
                     readFrame = new cFrame(b, -r, ftUnknown, readIndex); // hands over b to the ringBuffer
@@ -523,10 +527,34 @@
                     }
                  }
               if (p) {
-                 int w = PlayVideo(p, pc);
+                 if (!pesLen) {
+                    //search start of next PES (in case there was an error)
+                    pesLen = 0;
+                    uchar *pp = p;
+                    for (int i = pc; i > 0; --i, ++pesLen) {
+                       if (pp[0] == 0 && pp[1] == 0 && pp[2] == 1)
+                          break;
+                       }
+                    isVideo = (p[0] == 0 && p[1] == 0 && p[2] == 1 && (p[3] & 0xf0) == 0xe0);
+                    isAudio = (p[0] == 0 && p[1] == 0 && p[2] == 1 && (p[3] & 0xe0) == 0xc0);
+                    if (isAudio || isVideo)
+                       pesLen = (p[4] << 8 | p[5]) + 6;
+                    //isyslog("new frame is %d bytes of %s", pesLen, isVideo?"video":
+                    //        isAudio?"audio":"other");
+                    }
+                 int w, l = pc <= pesLen ? pc : pesLen;
+                 if (isVideo || isAudio)
+                    w = PlayAudioVideo(p, l, isVideo);
+                 else
+                    w = l; //drop
                  if (w > 0) {
                     p += w;
                     pc -= w;
+                    pesLen -= w;
+                    if (pesLen == 0) {
+                       isVideo = isAudio = false;
+                       //isyslog("frame done");
+                       }
                     }
                  else if (w < 0 && FATALERRNO) {
                     LOG_ERROR;
diff -uraN vdr-1.3.9/nit.c pre-vdr-1.3.9/nit.c
--- vdr-1.3.9/nit.c	2004-05-22 17:46:21.000000000 +0200
+++ pre-vdr-1.3.9/nit.c	2004-06-10 15:21:28.000000000 +0200
@@ -103,7 +103,7 @@
                  int Frequency = BCD2INT(sd->getFrequency()) / 100;
                  static char Polarizations[] = { 'h', 'v', 'l', 'r' };
                  char Polarization = Polarizations[sd->getPolarization()];
-                 static int CodeRates[] = { FEC_NONE, FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_7_8, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_NONE };
+                 static int CodeRates[] = { DVB_FE_FEC_NONE, DVB_FE_FEC_1_2, DVB_FE_FEC_2_3, DVB_FE_FEC_3_4, DVB_FE_FEC_5_6, DVB_FE_FEC_7_8, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_NONE };
                  int CodeRate = CodeRates[sd->getFecInner()];
                  int SymbolRate = BCD2INT(sd->getSymbolRate()) / 10;
                  if (ThisNIT >= 0) {
@@ -135,10 +135,10 @@
                  SI::CableDeliverySystemDescriptor *sd = (SI::CableDeliverySystemDescriptor *)d;
                  int Source = cSource::FromData(cSource::stCable);
                  int Frequency = BCD2INT(sd->getFrequency()) / 10;
-                 //XXX FEC_outer???
-                 static int CodeRates[] = { FEC_NONE, FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_7_8, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_NONE };
+                 //XXX DVB_FEC_outer???
+                 static int CodeRates[] = { DVB_FE_FEC_NONE, DVB_FE_FEC_1_2, DVB_FE_FEC_2_3, DVB_FE_FEC_3_4, DVB_FE_FEC_5_6, DVB_FE_FEC_7_8, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_NONE };
                  int CodeRate = CodeRates[sd->getFecInner()];
-                 static int Modulations[] = { QPSK, QAM_16, QAM_32, QAM_64, QAM_128, QAM_256, QAM_AUTO };
+                 static int Modulations[] = { DVB_FE_QPSK, DVB_FE_QAM_16, DVB_FE_QAM_32, DVB_FE_QAM_64, DVB_FE_QAM_128, DVB_FE_QAM_256, DVB_FE_QAM_AUTO };
                  int Modulation = Modulations[min(sd->getModulation(), 6)];
                  int SymbolRate = BCD2INT(sd->getSymbolRate()) / 10;
                  if (ThisNIT >= 0) {
@@ -170,18 +170,18 @@
                  SI::TerrestrialDeliverySystemDescriptor *sd = (SI::TerrestrialDeliverySystemDescriptor *)d;
                  int Source = cSource::FromData(cSource::stTerr);
                  int Frequency = sd->getFrequency() * 10;
-                 static int Bandwidths[] = { BANDWIDTH_8_MHZ, BANDWIDTH_7_MHZ, BANDWIDTH_6_MHZ, BANDWIDTH_AUTO, BANDWIDTH_AUTO, BANDWIDTH_AUTO, BANDWIDTH_AUTO, BANDWIDTH_AUTO };
+                 static int Bandwidths[] = { DVB_BANDWIDTH_8_MHZ, DVB_BANDWIDTH_7_MHZ, DVB_BANDWIDTH_6_MHZ, DVB_BANDWIDTH_AUTO, DVB_BANDWIDTH_AUTO, DVB_BANDWIDTH_AUTO, DVB_BANDWIDTH_AUTO, DVB_BANDWIDTH_AUTO };
                  int Bandwidth = Bandwidths[sd->getBandwidth()];
-                 static int Constellations[] = { QPSK, QAM_16, QAM_64, QAM_AUTO };
+                 static int Constellations[] = { DVB_FE_QPSK, DVB_FE_QAM_16, DVB_FE_QAM_64, DVB_FE_QAM_AUTO };
                  int Constellation = Constellations[sd->getConstellation()];
-                 static int Hierarchies[] = { HIERARCHY_NONE, HIERARCHY_1, HIERARCHY_2, HIERARCHY_4, HIERARCHY_AUTO, HIERARCHY_AUTO, HIERARCHY_AUTO, HIERARCHY_AUTO };
+                 static int Hierarchies[] = { DVB_HIERARCHY_NONE, DVB_HIERARCHY_1, DVB_HIERARCHY_2, DVB_HIERARCHY_4, DVB_HIERARCHY_AUTO, DVB_HIERARCHY_AUTO, DVB_HIERARCHY_AUTO, DVB_HIERARCHY_AUTO };
                  int Hierarchy = Hierarchies[sd->getHierarchy()];
-                 static int CodeRates[] = { FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_7_8, FEC_AUTO, FEC_AUTO, FEC_AUTO };
+                 static int CodeRates[] = { DVB_FE_FEC_1_2, DVB_FE_FEC_2_3, DVB_FE_FEC_3_4, DVB_FE_FEC_5_6, DVB_FE_FEC_7_8, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO, DVB_FE_FEC_AUTO };
                  int CodeRateHP = CodeRates[sd->getCodeRateHP()];
                  int CodeRateLP = CodeRates[sd->getCodeRateLP()];
-                 static int GuardIntervals[] = { GUARD_INTERVAL_1_32, GUARD_INTERVAL_1_16, GUARD_INTERVAL_1_8, GUARD_INTERVAL_1_4 };
+                 static int GuardIntervals[] = { DVB_GUARD_INTERVAL_1_32, DVB_GUARD_INTERVAL_1_16, DVB_GUARD_INTERVAL_1_8, DVB_GUARD_INTERVAL_1_4 };
                  int GuardInterval = GuardIntervals[sd->getGuardInterval()];
-                 static int TransmissionModes[] = { TRANSMISSION_MODE_2K, TRANSMISSION_MODE_8K, TRANSMISSION_MODE_AUTO, TRANSMISSION_MODE_AUTO };
+                 static int TransmissionModes[] = { DVB_TRANSMISSION_MODE_2K, DVB_TRANSMISSION_MODE_8K, DVB_TRANSMISSION_MODE_AUTO, DVB_TRANSMISSION_MODE_AUTO };
                  int TransmissionMode = TransmissionModes[sd->getTransmissionMode()];
                  if (ThisNIT >= 0) {
                     if (ISTRANSPONDER(Frequency / 1000000, Transponder())) {
diff -uraN vdr-1.3.9/player.c pre-vdr-1.3.9/player.c
--- vdr-1.3.9/player.c	2004-04-16 15:34:11.000000000 +0200
+++ pre-vdr-1.3.9/player.c	2004-06-10 15:21:28.000000000 +0200
@@ -23,10 +23,10 @@
   Detach();
 }
 
-int cPlayer::PlayVideo(const uchar *Data, int Length)
+int cPlayer::PlayAudioVideo(const uchar *Data, int Length, bool isVideo)
 {
   if (device)
-     return device->PlayVideo(Data, Length);
+     return device->PlayAudioVideo(Data, Length, isVideo);
   esyslog("ERROR: attempt to use cPlayer::PlayVideo() without attaching to a cDevice!");
   return -1;
 }
diff -uraN vdr-1.3.9/player.h pre-vdr-1.3.9/player.h
--- vdr-1.3.9/player.h	2004-04-30 15:45:59.000000000 +0200
+++ pre-vdr-1.3.9/player.h	2004-06-10 15:21:28.000000000 +0200
@@ -19,7 +19,8 @@
   cDevice *device;
   ePlayMode playMode;
 protected:
-  bool DevicePoll(cPoller &Poller, int TimeoutMs = 0) { return device ? device->Poll(Poller, TimeoutMs) : false; }
+  bool DevicePoll(cPoller &Poller, int TimeoutMs = 0, bool isVideo = true)
+      { return device ? device->Poll(Poller, TimeoutMs, isVideo) : false; }
   void DeviceTrickSpeed(int Speed) { if (device) device->TrickSpeed(Speed); }
   void DeviceClear(void) { if (device) device->Clear(); }
   void DevicePlay(void) { if (device) device->Play(); }
@@ -31,7 +32,7 @@
        // This function is called right after the cPlayer has been attached to
        // (On == true) or before it gets detached from (On == false) a cDevice.
        // It can be used to do things like starting/stopping a thread.
-  int PlayVideo(const uchar *Data, int Length);
+  int PlayAudioVideo(const uchar *Data, int Length, bool isVideo);
        // Sends the given Data to the video device and returns the number of
        // bytes that have actually been accepted by the video device (or a
        // negative value in case of an error).
diff -uraN vdr-1.3.9/remux.h pre-vdr-1.3.9/remux.h
--- vdr-1.3.9/remux.h	2004-02-14 11:40:41.000000000 +0100
+++ pre-vdr-1.3.9/remux.h	2004-06-10 15:21:28.000000000 +0200
@@ -10,8 +10,7 @@
 #ifndef __REMUX_H
 #define __REMUX_H
 
-#include <time.h> //XXX FIXME: DVB/linux/dvb/dmx.h should include <time.h> itself!!!
-#include <linux/dvb/dmx.h>
+#include <linux/dvb/demux.h>
 #include "tools.h"
 
 // Picture types:
diff -uraN vdr-1.3.9/tools.h pre-vdr-1.3.9/tools.h
--- vdr-1.3.9/tools.h	2004-05-22 14:11:44.000000000 +0200
+++ pre-vdr-1.3.9/tools.h	2004-06-10 15:21:28.000000000 +0200
@@ -24,9 +24,16 @@
 
 extern int SysLogLevel;
 
+#define LOG_TO_STDOUT
+#ifdef LOG_TO_STDOUT
+#define esyslog(f, a...) void( (SysLogLevel > 0) ? (void) printf(f , ## a), (void) putchar('\n') : void() )
+#define isyslog(f, a...) void( (SysLogLevel > 1) ? (void) printf(f , ## a), (void) putchar('\n') : void() )
+#define dsyslog(f, a...) void( (SysLogLevel > 2) ? (void) printf(f , ## a), (void) putchar('\n') : void() )
+#else
 #define esyslog(a...) void( (SysLogLevel > 0) ? syslog(LOG_ERR,   a) : void() )
 #define isyslog(a...) void( (SysLogLevel > 1) ? syslog(LOG_INFO,  a) : void() )
 #define dsyslog(a...) void( (SysLogLevel > 2) ? syslog(LOG_DEBUG, a) : void() )
+#endif
 
 #define LOG_ERROR         esyslog("ERROR (%s,%d): %m", __FILE__, __LINE__)
 #define LOG_ERROR_STR(s)  esyslog("ERROR: %s: %m", s)
@@ -42,7 +49,7 @@
 
 #define DELETENULL(p) (delete (p), p = NULL)
 
-#define CHECK(s) { if ((s) < 0) LOG_ERROR; } // used for 'ioctl()' calls
+#define CHECK(s) { if ((s) < 0) { int e = errno; LOG_ERROR; errno = e; } } // used for 'ioctl()' calls
 #define FATALERRNO (errno != EAGAIN && errno != EINTR)
 
 #ifndef __STL_CONFIG_H // in case some plugin needs to use the STL
diff -uraN vdr-1.3.9/transfer.c pre-vdr-1.3.9/transfer.c
--- vdr-1.3.9/transfer.c	2004-03-07 15:40:15.000000000 +0100
+++ pre-vdr-1.3.9/transfer.c	2004-06-10 15:21:28.000000000 +0200
@@ -101,7 +101,8 @@
                     cPoller Poller;
                     if (DevicePoll(Poller, 100)) {
                        PollTimeouts = 0;
-                       int w = PlayVideo(p, Result);
+		       bool isVideo = true;
+                       int w = PlayAudioVideo(p, Result, isVideo);
                        if (w > 0) {
                           p += w;
                           Result -= w;

LinuxTV legacy CVS <linuxtv.org/cvs>