[mythtv] [patch] dvb on demand - beta/alpha or something

mian mythtv at mian.net.au
Mon Feb 9 22:29:53 EST 2004


final one hopefully, sets isOpen to false on close and fixes the problem
of not being on start channel when you use the switch cards function (I
think someone mentioned this a while back when the toggle recorders patch
was submitted).. with DVB you didn't really notice because it was tuned
but myth didnt know it was on a channel so the display function would show
blank/not on a channel yet unless you hit changed channel or hit the # of
the channel you're already tuned to.  it's all working perfect for me now
so will try move on to EPG automatic card selecting next, if there's
anything wrong with the theory behind force_channel_change with this one
let me know.

--
mian
-------------- next part --------------
--- work-orig/mythtv/libs/libmythtv/videosource.h	2004-02-09 16:41:47.000000000 +1030
+++ work/mythtv/libs/libmythtv/videosource.h	2004-02-09 16:42:04.000000000 +1030
@@ -457,6 +457,18 @@
     };
 };
 
+class DVBOnDemand: public CheckBoxSetting, public CCSetting {
+public:
+    DVBOnDemand(const CaptureCard& parent):
+        CCSetting(parent, "dvb_on_demand") {
+        setLabel(QObject::tr("Open DVB card on demand"));
+        setValue(true);
+        setHelpText(QObject::tr("This option makes the backend dvb-recorder only "
+                     "open the card when it is actually in-use leaving "
+                     "it free for other programs at other times."));
+    };
+};
+
 class DVBPidBufferSize: public SpinBoxSetting, public CCSetting {
 public:
     DVBPidBufferSize(const CaptureCard& parent):
@@ -775,6 +787,7 @@
         rec->addChild(new DVBSwFilter(parent));
         rec->addChild(new DVBRecordTS(parent));
         rec->addChild(new DVBNoSeqStart(parent));
+        rec->addChild(new DVBOnDemand(parent));
         rec->addChild(new DVBPidBufferSize(parent));
         rec->addChild(new DVBBufferSize(parent));
         addChild(rec);
--- work-orig/mythtv/libs/libmythtv/tv_rec.h	2004-02-09 16:41:47.000000000 +1030
+++ work/mythtv/libs/libmythtv/tv_rec.h	2004-02-09 16:42:04.000000000 +1030
@@ -37,6 +37,7 @@
     int wait_for_seqstart;
     int dmx_buf_size;
     int pkt_buf_size;
+    bool dvb_on_demand;
 } dvb_options_t;
 
 class TVRec
--- work-orig/mythtv/libs/libmythtv/tv_rec.cpp	2004-02-09 16:41:47.000000000 +1030
+++ work/mythtv/libs/libmythtv/tv_rec.cpp	2004-02-09 17:50:49.000000000 +1030
@@ -82,6 +82,7 @@
             channel->SwitchToInput(inputname, startchannel);
         channel->SetChannelOrdering(chanorder);
         // don't close this channel, otherwise we cannot read data
+        if (dvb_options.dvb_on_demand) ((DVBChannel *)channel)->CloseDVB();
 #else
         VERBOSE(VB_IMPORTANT, "ERROR: DVB Card configured, "
                               "but no DVB support compiled in!");
@@ -560,6 +561,7 @@
 
         nvr->SetOptionsFromProfile(&profile, videodev, audiodev, vbidev, ispip);
 
+        nvr->SetOption("dvb_on_demand", dvb_options.dvb_on_demand);
         nvr->SetOption("swfilter", dvb_options.swfilter);
         nvr->SetOption("recordts", dvb_options.recordts);
         nvr->SetOption("wait_for_seqstart", dvb_options.wait_for_seqstart);
@@ -1023,7 +1025,7 @@
                                "audioratelimit,defaultinput,cardtype,"
                                "dvb_swfilter, dvb_recordts,"
                                "dvb_wait_for_seqstart,dvb_dmx_buf_size,"
-                               "dvb_pkt_buf_size, skipbtaudio "
+                               "dvb_pkt_buf_size, skipbtaudio, dvb_on_demand "
                                "FROM capturecard WHERE cardid = %1;")
                               .arg(cardnum);
 
@@ -1065,8 +1067,8 @@
         dvb_opts.wait_for_seqstart = query.value(8).toInt();
         dvb_opts.dmx_buf_size = query.value(9).toInt();
         dvb_opts.pkt_buf_size = query.value(10).toInt();
-
         skip_bt = query.value(11).toInt();
+        dvb_opts.dvb_on_demand = query.value(12).toInt();
     }
 
     thequery = QString("SELECT if(startchan!='', startchan, '3') "
--- work-orig/mythtv/libs/libmythtv/dvbrecorder.h	2004-02-09 16:41:47.000000000 +1030
+++ work/mythtv/libs/libmythtv/dvbrecorder.h	2004-02-09 16:42:04.000000000 +1030
@@ -104,6 +104,7 @@
     QMap<long long, long long> positionMap;
     long long prev_gop_save_pos;
 
+    bool    dvb_on_demand;
     bool    isopen;
     int     cardnum;
     bool    swfilter;
--- work-orig/mythtv/libs/libmythtv/dvbrecorder.cpp	2004-02-09 16:41:47.000000000 +1030
+++ work/mythtv/libs/libmythtv/dvbrecorder.cpp	2004-02-09 16:43:54.000000000 +1030
@@ -65,6 +65,7 @@
     was_paused = true;
     channel_changed = true;
     dvbchannel = advbchannel;
+    dvb_on_demand = false;
 
     paused = false;
     mainpaused = false;
@@ -135,6 +136,10 @@
         if (expire_data_days < 1)
             expire_data_days = 1;
     }
+    else if (name == "dvb_on_demand")
+    {
+        dvb_on_demand = value;
+    }
     else
         RecorderBase::SetOption(name, value);
 }
@@ -173,6 +178,12 @@
     if (isopen)
         return true;
 
+    if (dvb_on_demand && dvbchannel->Open())
+    {
+        // this is required to trigger a re-tune
+        dvbchannel->SetChannelByString(dvbchannel->GetCurrentName());
+    }
+
     fd_dvr = open(dvbdevice(DVB_DEV_DVR,cardnum), O_RDONLY | O_NONBLOCK);
     if(fd_dvr < 0)
     {
@@ -196,11 +207,16 @@
     if (!isopen)
         return;
 
+    VERBOSE(VB_ALL, "Closing DVB recorder");
+
     CloseFilters();
 
     if (fd_dvr > 0)
         close(fd_dvr);
 
+    if (dvb_on_demand && dvbchannel)
+        dvbchannel->CloseDVB();
+
     isopen = false;
 }
 
--- work-orig/mythtv/libs/libmythtv/dvbchannel.h	2004-02-09 16:41:47.000000000 +1030
+++ work/mythtv/libs/libmythtv/dvbchannel.h	2004-02-10 13:21:59.128135000 +1030
@@ -33,6 +33,7 @@
 
     bool Open();
     void Close() {};
+    void CloseDVB();
 
     fe_type_t GetCardType() { return info.type; };
 
@@ -106,6 +107,7 @@
 
     struct dvb_frontend_info info;
 
+    bool force_channel_change;
     bool first_tune;
     dvb_channel_t   chan_opts;
     dvb_tuning_t    prev_tuning;
--- work-orig/mythtv/libs/libmythtv/dvbchannel.cpp	2004-02-09 16:41:47.000000000 +1030
+++ work/mythtv/libs/libmythtv/dvbchannel.cpp	2004-02-10 13:36:38.167500704 +1030
@@ -59,6 +59,7 @@
            : ChannelBase(parent), cardnum(aCardNum)
 {
     fd_frontend = 0;
+    force_channel_change = false;
     first_tune = true;
     isOpen = false;
     diseqc = NULL;
@@ -78,8 +79,19 @@
     if (dvbcam)
         delete dvbcam;
 
-    if (isOpen && (fd_frontend > 0))
+    CloseDVB();
+}
+
+void DVBChannel::CloseDVB()
+{
+    VERBOSE(VB_ALL, "Closing DVB channel");
+
+    if (fd_frontend > 0)
+    {
         close(fd_frontend);
+        fd_frontend = 0;
+        isOpen = false;
+    }
 }
 
 bool DVBChannel::Open()
@@ -132,17 +144,21 @@
                 dvbcam, SLOT(ChannelChanged(dvb_channel_t&, uint8_t*, int)));
     }
 
+    force_channel_change = true;
+
     return isOpen = true;
 }
 
 bool DVBChannel::SetChannelByString(const QString &chan)
 {
-    if (curchannelname == chan)
+    if (curchannelname == chan && !force_channel_change)
         return true;
 
     if (!isOpen)
         return false;
 
+    force_channel_change = false;
+
     CHANNEL(QString("Trying to tune to channel %1.").arg(chan));
 
     if (GetChannelOptions(chan) == false)


More information about the mythtv-dev mailing list