no more use proprietary /dev/misc/pvr .. use linux tv api /dev/dvb/adapterX/dvrX master-2011.02
authorghost <andreas.monzner@multimedia-labs.de>
Fri, 28 Jan 2011 11:45:16 +0000 (12:45 +0100)
committerghost <andreas.monzner@multimedia-labs.de>
Fri, 28 Jan 2011 11:45:16 +0000 (12:45 +0100)
this needs new hardware drivers!!
fixed bug #672

lib/dvb/demux.cpp
lib/dvb/demux.h
lib/dvb/dvb.cpp
lib/dvb/pmt.cpp
lib/dvb/pmt.h

index 0c736c55c23e1cfc55de9e1f0a2c5a793b01a22b..37eae19f7ba2f5bf1d8bc602b861c683a599fab2 100644 (file)
@@ -85,6 +85,13 @@ int eDVBDemux::openDemux(void)
        return ::open(filename, O_RDWR);
 }
 
+int eDVBDemux::openDVR(void)
+{
+       char filename[128];
+       snprintf(filename, 128, "/dev/dvb/adapter%d/dvr%d", adapter, demux);
+       return ::open(filename, O_WRONLY);
+}
+
 DEFINE_REF(eDVBDemux)
 
 RESULT eDVBDemux::setSourceFrontend(int fenum)
index d43c41bb6733cee2760cef8fc7992f12363b2755..7dbb521a264bf400d24d221a669b219e3397d529 100644 (file)
@@ -26,7 +26,8 @@ public:
        RESULT getCADemuxID(uint8_t &id) { id = demux; return 0; }
        RESULT flush();
        RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &conn);
-       
+       int openDVR(void);
+
        int getRefCount() { return ref; }
 private:
        int adapter, demux, source;
index 414ab8da7d9419f37b86d722bf7617523ccb3cea..30d5f554a340f11eb963249c7e377b554dfca525 100644 (file)
@@ -464,7 +464,7 @@ RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtr<eDVBA
 
        ePtr<eDVBRegisteredDemux> unused;
 
-       if (m_boxtype == DM800 || m_boxtype == DM500HD || m_boxtype == DM800SE) // dm800 / 500hd
+       if (m_boxtype == DM800) // dm800
        {
                cap |= capHoldDecodeReference; // this is checked in eDVBChannel::getDemux
                for (; i != m_demux.end(); ++i, ++n)
@@ -520,7 +520,7 @@ RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtr<eDVBA
                        }
                }
        }
-       else if (m_boxtype == DM8000)
+       else if (m_boxtype == DM8000 || m_boxtype == DM500HD || m_boxtype == DM800SE)
        {
                cap |= capHoldDecodeReference; // this is checked in eDVBChannel::getDemux
                for (; i != m_demux.end(); ++i, ++n)
@@ -1790,14 +1790,28 @@ RESULT eDVBChannel::playSource(ePtr<iTsSource> &source, const char *streaminfo_f
                /* (this codepath needs to be improved anyway.) */
 #if HAVE_DVB_API_VERSION < 3
                m_pvr_fd_dst = open("/dev/pvr", O_WRONLY);
-#else
-               m_pvr_fd_dst = open("/dev/misc/pvr", O_WRONLY);
-#endif
                if (m_pvr_fd_dst < 0)
                {
-                       eDebug("can't open /dev/misc/pvr - you need to buy the new(!) $$$ box! (%m)"); // or wait for the driver to be improved.
+                       eDebug("can't open /dev/pvr - you need to buy the new(!) $$$ box! (%m)"); // or wait for the driver to be improved.
+                       return -ENODEV;
+               }
+#else
+               ePtr<eDVBAllocatedDemux> &demux = m_demux ? m_demux : m_decoder_demux;
+               if (demux)
+               {
+                       m_pvr_fd_dst = demux->get().openDVR();
+                       if (m_pvr_fd_dst < 0)
+                       {
+                               eDebug("can't open /dev/dvb/adapterX/dvrX - you need to buy the new(!) $$$ box! (%m)"); // or wait for the driver to be improved.
+                               return -ENODEV;
+                       }
+               }
+               else
+               {
+                       eDebug("no demux allocated yet.. so its not possible to open the dvr device!!");
                        return -ENODEV;
                }
+#endif
        }
 
        m_pvr_thread = new eDVBChannelFilePush();
index ca56141bc89115c4ba32bdc15f27a1bf4f465503..dc2a88562fe0da5a29697cda04ffc3f72bf3870a 100644 (file)
@@ -43,8 +43,15 @@ void eDVBServicePMTHandler::channelStateChanged(iDVBChannel *channel)
                && (state == iDVBChannel::state_ok) && (!m_demux))
        {
                if (m_channel)
-                       if (m_channel->getDemux(m_demux, (!m_use_decode_demux) ? 0 : iDVBChannel::capDecode))
+               {
+                       if (m_pvr_demux_tmp)
+                       {
+                               m_demux = m_pvr_demux_tmp;
+                               m_pvr_demux_tmp = NULL;
+                       }
+                       else if (m_channel->getDemux(m_demux, (!m_use_decode_demux) ? 0 : iDVBChannel::capDecode))
                                eDebug("Allocating %s-decoding a demux for now tuned-in channel failed.", m_use_decode_demux ? "" : "non-");
+               }
                
                serviceEvent(eventTuned);
                
@@ -792,7 +799,10 @@ int eDVBServicePMTHandler::tuneExt(eServiceReferenceDVB &ref, int use_decode_dem
                if (m_pvr_channel)
                {
                        m_pvr_channel->setCueSheet(cue);
-                       if (source)
+
+                       if (m_pvr_channel->getDemux(m_pvr_demux_tmp, (!m_use_decode_demux) ? 0 : iDVBChannel::capDecode))
+                               eDebug("Allocating %s-decoding a demux for PVR channel failed.", m_use_decode_demux ? "" : "non-");
+                       else if (source)
                                m_pvr_channel->playSource(source, streaminfo_file);
                        else
                                m_pvr_channel->playFile(ref.path.c_str());
index 86b634fc459a1b9206ca9d5ac34dfe835c3995c6..6b20d7146d4daba8e222ee7ab008908e265926e6 100644 (file)
@@ -86,8 +86,8 @@ class eDVBServicePMTHandler: public Object
        eUsePtr<iDVBChannel> m_channel;
        eUsePtr<iDVBPVRChannel> m_pvr_channel;
        ePtr<eDVBResourceManager> m_resourceManager;
-       ePtr<iDVBDemux> m_demux;
-       
+       ePtr<iDVBDemux> m_demux, m_pvr_demux_tmp;
+
        void channelStateChanged(iDVBChannel *);
        ePtr<eConnection> m_channelStateChanged_connection;
        void channelEvent(iDVBChannel *, int event);