fix marking non playable services in channellist
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sat, 3 Dec 2005 15:53:37 +0000 (15:53 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sat, 3 Dec 2005 15:53:37 +0000 (15:53 +0000)
lib/dvb/db.cpp
lib/dvb/dvb.cpp
lib/dvb/dvb.h
lib/dvb/idvb.h
lib/python/Components/ServiceList.py
lib/python/Screens/ChannelSelection.py
lib/service/iservice.h
lib/service/listboxservice.cpp
lib/service/listboxservice.h
lib/service/service.cpp

index 38a062a..658c586 100644 (file)
@@ -1,5 +1,6 @@
 #include <errno.h>
 #include <lib/dvb/db.h>
+#include <lib/dvb/dvb.h>
 #include <lib/dvb/frontend.h>
 #include <lib/dvb/epgcache.h>
 #include <lib/base/eerror.h>
@@ -154,6 +155,21 @@ RESULT eDVBService::getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &
        return eEPGCache::getInstance()->lookupEventTime(ref, t, ptr);
 }
 
+bool eDVBService::isPlayable(const eServiceReference &ref, const eServiceReference &ignore)
+{
+       ePtr<eDVBResourceManager> res_mgr;
+       if ( eDVBResourceManager::getInstance( res_mgr ) )
+               eDebug("isPlayble... no res manager!!");
+       else
+       {
+               eDVBChannelID chid, chid_ignore;
+               ((const eServiceReferenceDVB&)ref).getChannelID(chid);
+               ((const eServiceReferenceDVB&)ignore).getChannelID(chid_ignore);
+               return res_mgr->canAllocateChannel(chid, chid_ignore);
+       }
+       return false;
+}
+
 int eDVBService::checkFilter(const eServiceReferenceDVB &ref, const eDVBChannelQuery &query)
 {
        int res = 0;
index 4107c22..aa79581 100644 (file)
@@ -406,14 +406,13 @@ RESULT eDVBResourceManager::connectChannelAdded(const Slot1<void,eDVBChannel*> &
        return 0;
 }
 
-bool eDVBResourceManager::canAllocateFrontend(ePtr<iDVBFrontendParameters> &feparm, int used_tuner_mask)
+bool eDVBResourceManager::canAllocateFrontend(ePtr<iDVBFrontendParameters> &feparm)
 {
-       eDebug("canAllocateFrontend mask %08x", used_tuner_mask);
        ePtr<eDVBRegisteredFrontend> best;
        int bestval = 0;
 
        for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i)
-               if ( !(used_tuner_mask & (1<<i->m_frontend->getID())) )
+               if (!i->m_inuse)
                {
                        int c = i->m_frontend->isCompatibleWith(feparm);
                        if (c > bestval)
@@ -423,16 +422,11 @@ bool eDVBResourceManager::canAllocateFrontend(ePtr<iDVBFrontendParameters> &fepa
        return bestval>0;
 }
 
-bool eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid)
+bool eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, const eDVBChannelID& ignore)
 {
-       return true;
-#if 0
-       int used_tuner_mask=0;
-
                /* first, check if a channel is already existing. */
 //     eDebug("allocate channel.. %04x:%04x", channelid.transport_stream_id.get(), channelid.original_network_id.get());
-       int cnt=0;
-       for (std::list<active_channel>::iterator i(m_active_channels.begin()); i != m_active_channels.end(); ++i, ++cnt)
+       for (std::list<active_channel>::iterator i(m_active_channels.begin()); i != m_active_channels.end(); ++i)
        {
 //             eDebug("available channel.. %04x:%04x", i->m_channel_id.transport_stream_id.get(), i->m_channel_id.original_network_id.get());
                if (i->m_channel_id == channelid)
@@ -440,28 +434,33 @@ bool eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid)
 //                     eDebug("found shared channel..");
                        return true;
                }
+       }
+
+       int *decremented_fe_usecount=NULL;
 
-               eDebug("activeChannel %d, NonDecoderDemux %p, DecoderDemux %p",
-                       cnt, i->m_channel->getNonDecoderDemux(), i->m_channel->getDecoderDemux() );
-               if ( i->m_channel->getNonDecoderDemux() )
+       for (std::list<active_channel>::iterator i(m_active_channels.begin()); i != m_active_channels.end(); ++i)
+       {
+//             eDebug("available channel.. %04x:%04x", i->m_channel_id.transport_stream_id.get(), i->m_channel_id.original_network_id.get());
+               if (i->m_channel_id == ignore)
                {
-                       ePtr<iDVBFrontend> fe;
-                       if (!i->m_channel->getFrontend(fe))
+                       eDVBChannel *channel = (eDVBChannel*) &(*i->m_channel);
+                       if (channel->getUseCount() == 1)  // channel only used once..
                        {
-                               if (fe)
+                               ePtr<iDVBFrontend> fe;
+                               if (!i->m_channel->getFrontend(fe))
                                {
                                        for (eSmartPtrList<eDVBRegisteredFrontend>::iterator ii(m_frontend.begin()); ii != m_frontend.end(); ++ii)
                                        {
                                                if ( &(*fe) == &(*ii->m_frontend) )
                                                {
-                                                       used_tuner_mask |= (1 << ii->m_frontend->getID());
+                                                       --ii->m_inuse;
+                                                       decremented_fe_usecount = &ii->m_inuse;
                                                        break;
                                                }
                                        }
                                }
-                               else
-                                       eDebug("fe kaputt");
                        }
+                       break;
                }
        }
 
@@ -478,8 +477,12 @@ bool eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid)
                return false;
        }
 
-       return canAllocateFrontend(feparm, used_tuner_mask);
-#endif
+       bool ret = canAllocateFrontend(feparm);
+
+       if (decremented_fe_usecount)
+               ++(*decremented_fe_usecount);
+
+       return ret;
 }
 
 DEFINE_REF(eDVBChannel);
index 5c3c515..6a9e633 100644 (file)
@@ -142,7 +142,7 @@ class eDVBResourceManager: public iObject
        Signal1<void,eDVBChannel*> m_channelRemoved;
        Signal1<void,iDVBChannel*> m_channelRunning;
 
-       bool canAllocateFrontend(ePtr<iDVBFrontendParameters> &feparm, int used_tuner_mask);
+       bool canAllocateFrontend(ePtr<iDVBFrontendParameters> &feparm);
 public:
        eDVBResourceManager();
        virtual ~eDVBResourceManager();
@@ -167,7 +167,7 @@ public:
        RESULT connectChannelRemoved(const Slot1<void,eDVBChannel*> &channelRemoved, ePtr<eConnection> &connection);
        RESULT connectChannelRunning(const Slot1<void,iDVBChannel*> &channelRemoved, ePtr<eConnection> &connection);
 
-       bool canAllocateChannel(const eDVBChannelID &channelid);
+       bool canAllocateChannel(const eDVBChannelID &channelid, const eDVBChannelID &ignore);
 };
 
 class eFilePushThread;
@@ -201,6 +201,7 @@ public:
                           there is an unknown amount of buffers in between */
        RESULT seekToPosition(iDVBDemux *decoding_demux, const off_t &off);
 
+       int getUseCount() { return m_use_count; }
 private:
        ePtr<eDVBAllocatedFrontend> m_frontend;
        ePtr<eDVBAllocatedDemux> m_demux, m_decoder_demux;
index c7e2239..a14e0af 100644 (file)
@@ -219,7 +219,8 @@ public:
        // iStaticServiceInformation
        RESULT getName(const eServiceReference &ref, std::string &name);
        RESULT getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &ptr);
-       
+       bool isPlayable(const eServiceReference &ref, const eServiceReference &ignore);
+
                /* for filtering: */
        int checkFilter(const eServiceReferenceDVB &ref, const eDVBChannelQuery &query);
 };
index 84e9e82..d008c47 100644 (file)
@@ -70,6 +70,9 @@ class ServiceList(HTMLComponent, GUIComponent):
        def setNumberOffset(self, offset):
                self.l.setNumberOffset(offset)
 
+       def setPlayableIgnoreService(self, ref):
+               self.l.setIgnoreService(ref)
+
        def setRoot(self, root):
                self.root = root
                self.l.setRoot(root)
index ae344dc..03182ab 100644 (file)
@@ -364,6 +364,14 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit):
                                "0": self.keyNumberGlobal
                        })
                self["actions"].csel = self
+               self.onShown.append(self.onShow)
+
+       def onShow(self):
+               ref = self.session.nav.getCurrentlyPlayingServiceReference()
+               if ref.valid() and ref.getPath() == "":
+                       self.servicelist.setPlayableIgnoreService(ref)
+               else:
+                       self.servicelist.setPlayableIgnoreService(eServiceReference())
 
        def showEPGList(self):
                ref=self.servicelist.getCurrent()
@@ -430,6 +438,9 @@ class SimpleChannelSelection(ChannelSelectionBase):
                                "cancel": self.cancel,
                                "ok": self.channelSelected,
                                "showFavourites": self.showFavourites,
+                               "showAllServices": self.showAllServices,
+                               "showProviders": self.showProviders,
+                               "showSatellites": self.showSatellites,
                                "1": self.keyNumberGlobal,
                                "2": self.keyNumberGlobal,
                                "3": self.keyNumberGlobal,
@@ -445,6 +456,7 @@ class SimpleChannelSelection(ChannelSelectionBase):
 
        def onExecCallback(self):
                print "onExecCallback"
+               self.showFavourites()
                self.session.currentDialog.instance.setTitle(self.title)
 
        def channelSelected(self): # just return selected service
index ab95ef7..232e66f 100644 (file)
@@ -175,6 +175,8 @@ public:
                // doesn't need to be implemented, should return -1 then.
        virtual int getLength(const eServiceReference &ref);
        virtual SWIG_VOID(RESULT) getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &SWIG_OUTPUT);
+               // returns true when not implemented
+       virtual bool isPlayable(const eServiceReference &ref, const eServiceReference &ignore);
 };
 
 TEMPLATE_TYPEDEF(ePtr<iStaticServiceInformation>, iStaticServiceInformationPtr);
@@ -264,7 +266,6 @@ public:
 
 TEMPLATE_TYPEDEF(ePtr<iAudioTrackSelection>, iAudioTrackSelectionPtr);
 
-
 class iPlayableService: public iObject
 {
        friend class iServiceHandler;
index 4e20fcb..035658e 100644 (file)
@@ -335,28 +335,12 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const
 {
        painter.clip(eRect(offset, m_itemsize));
 
-       bool tuneable=true;
-
-#if 0
-       if (m_res_mgr && cursorValid() && !((m_cursor->flags & eServiceReference::flagDirectory) == eServiceReference::flagDirectory))
-       {
-               eServiceReferenceDVB &ref = (eServiceReferenceDVB&) *m_cursor;
-               eDVBChannelID chid;
-               ref.getChannelID(chid);
-               tuneable = m_res_mgr->canAllocateChannel(chid);
-       }
-#endif
-
        if (m_current_marked && selected)
                style.setStyle(painter, eWindowStyle::styleListboxMarked);
        else if (cursorValid() && isMarked(*m_cursor))
                style.setStyle(painter, eWindowStyle::styleListboxMarked);
        else
-       {
                style.setStyle(painter, selected ? eWindowStyle::styleListboxSelected : eWindowStyle::styleListboxNormal);
-               if (!tuneable)
-                       painter.setForegroundColor(gRGB(0xbbbbbb));
-       }
        painter.clear();
        
        if (cursorValid())
@@ -364,7 +348,10 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const
                        /* get service information */
                ePtr<iStaticServiceInformation> service_info;
                m_service_center->info(*m_cursor, service_info);
-               
+
+               if (m_is_playable_ignore.valid() && !service_info->isPlayable(*m_cursor, m_is_playable_ignore))
+                       painter.setForegroundColor(gRGB(0xbbbbbb));
+
                for (int e = 0; e < celElements; ++e)
                {
                        if (!m_element_font[e])
@@ -447,3 +434,7 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const
        painter.clippop();
 }
 
+void eListboxServiceContent::setIgnoreService( const eServiceReference &service )
+{
+       m_is_playable_ignore=service;
+}
index b1cc249..a742b06 100644 (file)
@@ -10,6 +10,8 @@ class eListboxServiceContent: public virtual iListboxContent
        DECLARE_REF(eListboxServiceContent);
 public:
        eListboxServiceContent();
+
+       void setIgnoreService( const eServiceReference &service );
        void setRoot(const eServiceReference &ref);
        void getCurrent(eServiceReference &ref);
        
@@ -96,6 +98,8 @@ private:
        bool m_current_marked;
 
        int m_numberoffset;
+
+       eServiceReference m_is_playable_ignore;
 };
 
 #endif
index a7f6e52..c043a58 100644 (file)
@@ -144,8 +144,13 @@ int iStaticServiceInformation::getLength(const eServiceReference &ref)
        return -1;
 }
 
+bool iStaticServiceInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore)
+{
+       return true;
+}
+
 RESULT iServiceInformation::getEvent(ePtr<eServiceEvent> &evt, int m_nownext)
-{      
+{
        evt = 0;
        return -1;
 }