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

mian mythtv at mian.net.au
Mon Feb 9 02:31:10 EST 2004


No worries, I wondered if that was a problem when I started but couldnt
see Close() being called anywhere else, but my setup is limited.. here's a
new one with your suggestions.

Amazing the difference a motherboard can make, was using ATI's brand new
chipset based microatx however it basically has zero Linux support at the
moment so not even HD dma could be used which made it peak at 4.5mb/sec,
replaced it with a cheaper MSI-all via based mb and now my only problem is
1 DVB-T channel has a few issues but thats reception related, was
compiling latest CVS to test this patch while watching tv, name/web/mail
servers/firewall/nat is also running on the box, not 1 skip the entire
time.. on the ATI motherboard it was basically unusable just watching TV
alone :)

--
Damian

> On Monday 09 February 2004 05:17, mian wrote:
>> This patch was required for me to use both DVB and capture functions of
>> my
>> card, the current myth code keeps the DVB card open all the time, even
>> when it's not in use, which prevents using the v4l analogue capture
>> functions for external sat receiver.  By enabling the DVB on demand
>> option, the DVB card will be only be opened when it's required and then
>> closed again when it's free allowing the v4l analogue capture to be used
>> whenever the DVB function isn't.  The option is added to capture card
>> setup, under advanced DVB settings - "Open DVB card on demand"
>>
>> While it is working fine for me, I can obviously only test one setup -
>> mine, so it would be appreciated if someone else can test aswell.
>>
>> As always I'll leave the automatic SQL upgrading for Ivans updates when
>> it's been tested so
>>
>> ALTER TABLE capturecard ADD dvb_on_demand TINYINT NOT NULL DEFAULT 0
>
> I somehow felt that you would come through with a patch, I have only one
> comment, and that is that I intentionally left the ::Close empty because
> of
> the comment in tv_rec.cpp (hoping to remove some code in the future), so
> could you make what is currently the ::Close function into a ::CloseDVB
> function, since all places that this is called is either determined to be
> of
> DVBChannel class, or the ChannelBase class but determined to be a DVB
> device,
> so a cast into DVBChannel is safe, then this patch is perfect!
>
> --
>
> Kenneth (ke-aa \0 frisurf.no)
>
>
-------------- 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.385345064 +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-09 16:42:31.000000000 +1030
@@ -33,6 +33,7 @@
 
     bool Open();
     void Close() {};
+    void CloseDVB();
 
     fe_type_t GetCardType() { return info.type; };
 
--- work-orig/mythtv/libs/libmythtv/dvbchannel.cpp	2004-02-09 16:41:47.000000000 +1030
+++ work/mythtv/libs/libmythtv/dvbchannel.cpp	2004-02-09 16:43:20.000000000 +1030
@@ -78,8 +78,20 @@
     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;
+        // so SetChannelByString() will re-tune next time we open
+        curchannelname = "";
+    }
 }
 
 bool DVBChannel::Open()


More information about the mythtv-dev mailing list