[mythtv] Re: DVB-C recording bug
Ben Bucksch
linux.news at bucksch.org
Mon Aug 18 21:31:06 EDT 2003
Kenneth Aafloy wrote:
>the attached diff
>
Assuming that fixes the problem (I guess so), this patch looks good. But
you should open the devices in the Open() function, then, not the
constructor.
(I didn't know that "return -1;" in a constructor would even compile ;-P .)
Attached is a patch which implements that. No garantees apart from that
it compiles. Changes:
* Move opening/closing of frontend device from the tune function
into Open/Close, so that the device is kept open for the lifetime
of the DVBChannel object (i.e. as long as recording or LiveTV is on).
* s/demux_fd/fd_demux/ to match the new properties (should be
consistent)
* Fix detection of failure to open demux devices (|fd_demux.pop();|)
in later calls to Open(). I just check for the length of the array
there, not, if the device var actually has a legal value (>0), so
make sure that all entries in the array are legal by removing
illegal ones right away.
Could you please test that as well?
BTW: Your email client now uses the right mimetype for the compressed
patch, I can actually open it without a shell, thanks for fixing it.
-------------- 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:26:58 -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)
More information about the mythtv-dev
mailing list