[mythtv] [PATCH] tuning failure and leak fix for dvb_on_demand mode

Christopher Pascoe c.pascoe at itee.uq.edu.au
Sat Jul 10 08:01:28 EDT 2004


There are a few problems in dvbchannel.cpp that are exposed when using
dvb_on_demand mode, that I have addressed in the attached patch:

Firstly, myth does not retune after reopening a frontend device if it
still thinks it is on the same channel as it was when it closed the
device.  This causes problems as the frontend is always initialised by the
dvb-kernel drivers on reopen (which, depending on your frontend may cause
a loss of tuning), or it may have been retuned along the way.  Setting
first_tune at device open time rather than DVBChannel instantation time
fixes this.

Secondly, when closing the frontend connection, myth doesn't close its
connection to the demultiplexer, etc, and generates a new one every time
the frontend is reopened.  Moving the deletes for dvbsct and dvbcam into
CloseDVB fixes this and stops them from being leaked.  Also add a delete
for the diseqc at destruction time.

Finally a minor nitpick - there are a few tests that assume a fd of 0 is
invalid for the frontend connection.  While this may be the case in Myth
on Linux at the moment, it mightn't always be.  Fix this and use -1 for
the invalid fd.

Regards
Chris
-- 
Christopher Pascoe
IT Infrastructure Manager
School of Information Technology and Electrical Engineering
The University of Queensland   Brisbane  QLD  4072  Australia
-------------- next part --------------
Index: libs/libmythtv/dvbchannel.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/dvbchannel.cpp,v
retrieving revision 1.25
diff -p -u -r1.25 dvbchannel.cpp
--- libs/libmythtv/dvbchannel.cpp	25 Jun 2004 23:31:58 -0000	1.25
+++ libs/libmythtv/dvbchannel.cpp	10 Jul 2004 11:38:55 -0000
@@ -58,9 +58,8 @@ using namespace std;
 DVBChannel::DVBChannel(int aCardNum, TVRec *parent)
            : ChannelBase(parent), cardnum(aCardNum)
 {
-    fd_frontend = 0;
+    fd_frontend = -1;
     force_channel_change = false;
-    first_tune = true;
     isOpen = false;
     diseqc = NULL;
     monitorRunning = false;
@@ -74,10 +73,8 @@ DVBChannel::DVBChannel(int aCardNum, TVR
 
 DVBChannel::~DVBChannel()
 {
-    if (dvbsct)
-        delete dvbsct;
-    if (dvbcam)
-        delete dvbcam;
+    if (diseqc)
+        delete diseqc;
 
     CloseDVB();
 }
@@ -86,17 +83,21 @@ void DVBChannel::CloseDVB()
 {
     VERBOSE(VB_ALL, "Closing DVB channel");
 
-    if (fd_frontend > 0)
+    if (fd_frontend >= 0)
     {
         close(fd_frontend);
-        fd_frontend = 0;
+        fd_frontend = -1;
+        if (dvbcam)
+            delete dvbcam;
+        if (dvbsct)
+            delete dvbsct;
         isOpen = false;
     }
 }
 
 bool DVBChannel::Open()
 {
-    if (fd_frontend > 0)
+    if (fd_frontend >= 0)
         return true;
 
     fd_frontend = open(dvbdevice(DVB_DEV_FRONTEND, cardnum),
@@ -145,6 +146,7 @@ bool DVBChannel::Open()
     }
 
     force_channel_change = true;
+    first_tune = true;
 
     return isOpen = true;
 }
@@ -632,7 +634,7 @@ bool DVBChannel::CheckModulation(fe_modu
 
 bool DVBChannel::FillFrontendStats(dvb_stats_t& stats)
 {
-    if (fd_frontend <= 0)
+    if (fd_frontend < 0)
         return false;
 
     ioctl(fd_frontend, FE_READ_SNR, &stats.snr);


More information about the mythtv-dev mailing list