[mythtv] Re: DVB-C recording bug

Ben Bucksch linux.news at bucksch.org
Mon Aug 18 21:57:33 EDT 2003


Kenneth Aafloy wrote:

>you forgot the header changes :)
>
Wops ;-). Attached.
-------------- next part --------------
Index: dvbchannel.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/dvbchannel.cpp,v
retrieving revision 1.4
diff -u -r1.4 dvbchannel.cpp
--- dvbchannel.cpp	23 Jul 2003 16:01:42 -0000	1.4
+++ dvbchannel.cpp	18 Aug 2003 18:56:24 -0000
@@ -19,7 +19,9 @@
                        bool a_use_ts, char a_dvb_type)
   : ChannelBase(parent),
     use_ts(a_use_ts),
-    cardnum(aCardnum)
+    cardnum(aCardnum),
+    fd_frontend(0),
+    fd_sec(0)
 {
     if (a_dvb_type == 's' || a_dvb_type == 'S')
       dvb_type = DVB_S;
@@ -46,13 +48,18 @@
 
 bool DVBChannel::Open(unsigned int npids)
 {
-    if (use_ts && demux_fd.size() > 0 ||
-        demux_fd.size() >= npids)
+    if ((use_ts && fd_demux.size() > 0 ||
+         fd_demux.size() >= npids)
+        && fd_frontend > 0
+#ifdef OLDSTRUCT
+        && fd_sec > 0
+#endif
+        )
         return true;
 
 #ifdef USING_DVB
-    /* demux stuff only - the tune() function from the lib does the opening
-       of the dvr device by itself */
+
+    // Demux devices for the PIDs/TS
 
     /* See use_ts declaration in dvbchannel.h.
        If we have a budget card capable, fetch the whole TS
@@ -64,24 +71,50 @@
 
     if (use_ts)
         npids = 1;
-    for (unsigned int i = demux_fd.size(); i < npids; i++)
+    for (unsigned int i = fd_demux.size(); i < npids; i++)
     {
-        demux_fd.push_back(open(devicenodename(dvbdev_demux, cardnum), O_RDWR));
-        if (demux_fd.back() < 0)
+        fd_demux.push_back(open(devicenodename(dvbdev_demux,cardnum), O_RDWR));
+        if (fd_demux.back() < 0)
         {
-            cerr <<  "DVBChannel ERROR: open of demux device (" << i << ") failed" << endl;
+            cerr <<  "DVBChannel ERROR: open of demux device ("
+                 << i << ") failed" << endl;
+            fd_demux.pop();
             return false;
         }
     }
 
     if (use_ts)
     {
-        set_ts_filt(demux_fd[0], 8192, DMX_PES_OTHER);
+        set_ts_filt(fd_demux[0], 8192, DMX_PES_OTHER);
           /* 8192 is the magic PID to tell the hardware/driver not to filter,
              but to give us the full TS. */
     }
     // else wait for SetChannelByString() to use SetPIDs()
 
+
+    // The "frontend" device to do the hard tuning
+
+    if (fd_frontend <= 0)
+      fd_frontend = open(devicenodename(dvbdev_frontend, cardnum), O_RDWR);
+    if (fd_frontend < 0)
+    {
+        cerr << "DVBChannel ERROR: Opening DVB frontend device failed!\n";
+        return false;
+    }
+#ifdef OLDSTRUCT
+    if (fd_sec <= 0)
+      fd_sec = open(devicenodename(dvbdev_sec, cardnum), O_RDWR);
+    if (fd_sec < 0)
+    {
+        cerr << "DVBChannel ERROR: Opening DVB sec device failed!\n";
+        return false;
+    }
+#endif
+
+
+    /* The dvr device is being opened by the
+       tune_it() function from libdvbdev does the opening */
+
     return true;
 #else
     cerr << "DVB support not compiled in" << endl;
@@ -91,9 +124,20 @@
 
 void DVBChannel::Close()
 {
+    // demux
     for (vector_int::iterator i = pid.begin(); i != pid.end(); i++)
         if (*i > 0)
             close(*i);
+
+    // frontend
+    if (fd_frontend > 0)
+        close(fd_frontend);
+#ifdef OLDSTRUCT
+    if (fd_sec > 0)
+        close(fd_sec);
+#endif
+
+
     cout << "DVBChannel: Closed DVB demux devices!" << endl;
 }
 
@@ -111,19 +155,19 @@
     if (!use_ts)
     {
 #ifdef USING_DVB
-        // we already made sure using Open() that demux_fd.size() == pid.size()
-        if (demux_fd.size() != pid.size())
+        // we already made sure using Open() that fd_demux.size() == pid.size()
+        if (fd_demux.size() != pid.size())
             cerr << "aaarggg! sizes don't match" <<endl;
         for (unsigned int i = 0; i < pid.size(); i++)
         {
             // FIXME: This hurts no-one, but really,
             //   there should be a video/audio pair in the database.
             if (i==0)
-                 set_ts_filt(demux_fd[i], pid[i], DMX_PES_VIDEO);
+                 set_ts_filt(fd_demux[i], pid[i], DMX_PES_VIDEO);
             else if (i==1)
-                 set_ts_filt(demux_fd[i], pid[i], DMX_PES_AUDIO);
+                 set_ts_filt(fd_demux[i], pid[i], DMX_PES_AUDIO);
             else
-                 set_ts_filt(demux_fd[i], pid[i], DMX_PES_OTHER);
+                 set_ts_filt(fd_demux[i], pid[i], DMX_PES_OTHER);
         }
 #endif
     }
@@ -401,22 +445,8 @@
 // Do the real tuning
 bool DVBTune(const DVBTunerSettings& s, int cardnum)
 {
-    // Open
-    int fd_frontend = open(devicenodename(dvbdev_frontend, cardnum), O_RDWR);
-    if(fd_frontend < 0)
-    {
-        cerr << "DVBChannel ERROR: Opening DVB frontend device failed!\n";
-        return -1;
-    }
-    int fd_sec = 0;
-#ifdef OLDSTRUCT
-    fd_sec = open(devicenodename(dvbdev_sec, cardnum), O_RDWR);
-    if(fd_sec < 0)
-    {
-        cerr << "DVBChannel ERROR: Opening DVB sec device failed!\n";
-        return -1;
-    }
-#endif
+    if (!Open())
+        return false;
 
     // tune; from tune.h/c
     int err = tune_it(fd_frontend, fd_sec,
@@ -424,14 +454,6 @@
                       s.tone, s.inversion, s.diseqc, s.modulation,
                       s.hp_code_rate, s.lp_code_rate, s.transmission_mode,
                       s.guard_interval, s.bandwidth, s.hierarchy);
-
-    // close
-    if (fd_frontend > 0)
-        close(fd_frontend);
-#ifdef OLDSTRUCT
-    if (fd_sec > 0)
-        close(fd_sec);
-#endif
 
     // return
     if (err < 0)
Index: dvbchannel.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/dvbchannel.h,v
retrieving revision 1.4
diff -u -r1.4 dvbchannel.h
--- dvbchannel.h	23 Jul 2003 16:01:42 -0000	1.4
+++ dvbchannel.h	18 Aug 2003 18:56:24 -0000
@@ -59,8 +59,9 @@
     enum DVB_Type dvb_type;
     int cardnum; /* 0..3; for N in /dev/dvb/adapterN/frontend0,
                                    /dev/dvb/adapterN/dvr0 etc. */
-    int dvr_fd;
-    vector_int demux_fd;
+    vector_int fd_demux;
+    int fd_frontend;
+    int fd_sec;
 };
 
 #endif


More information about the mythtv-dev mailing list