fix error handling
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Thu, 19 Jul 2007 10:33:22 +0000 (10:33 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Thu, 19 Jul 2007 10:33:22 +0000 (10:33 +0000)
lib/dvb/dvb.cpp
lib/dvb/dvb.h
lib/dvb/frontend.cpp
lib/dvb/frontend.h

index fa15d66..4a6da01 100644 (file)
@@ -248,12 +248,12 @@ void eDVBResourceManager::addAdapter(iDVBAdapter *adapter)
        }
 }
 
-void eDVBResourceManager::setFrontendSlotInformations(ePyObject list)
+PyObject *eDVBResourceManager::setFrontendSlotInformations(ePyObject list)
 {
        if (!PyList_Check(list))
        {
                PyErr_SetString(PyExc_StandardError, "eDVBResourceManager::setFrontendSlotInformations argument should be a python list");
-               return;
+               return NULL;
        }
        if ((unsigned int)PyList_Size(list) != m_frontend.size())
        {
@@ -261,14 +261,16 @@ void eDVBResourceManager::setFrontendSlotInformations(ePyObject list)
                sprintf(blasel, "eDVBResourceManager::setFrontendSlotInformations list size incorrect %d frontends avail, but %d entries in slotlist",
                        m_frontend.size(), PyList_Size(list));
                PyErr_SetString(PyExc_StandardError, blasel);
-               return;
+               return NULL;
        }
        int pos=0;
        for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i)
        {
                ePyObject obj = PyList_GET_ITEM(list, pos++);
-               i->m_frontend->setSlotInfo(obj);
+               if (!i->m_frontend->setSlotInfo(obj))
+                       return NULL;
        }
+       Py_RETURN_NONE;
 }
 
 RESULT eDVBResourceManager::allocateFrontend(ePtr<eDVBAllocatedFrontend> &fe, ePtr<iDVBFrontendParameters> &feparm)
index f36e6f6..38d18f7 100644 (file)
@@ -210,7 +210,7 @@ public:
 #endif
        PSignal1<void,int> frontendUseMaskChanged;
        SWIG_VOID(RESULT) allocateRawChannel(eUsePtr<iDVBChannel> &SWIG_OUTPUT, int slot_index);
-       void setFrontendSlotInformations(SWIG_PYOBJECT(ePyObject) list);
+       PyObject *setFrontendSlotInformations(SWIG_PYOBJECT(ePyObject) list);
 };
 SWIG_TEMPLATE_TYPEDEF(ePtr<eDVBResourceManager>, eDVBResourceManager);
 SWIG_EXTEND(ePtr<eDVBResourceManager>,
index 1906a8f..8b21413 100644 (file)
@@ -2135,7 +2135,7 @@ int eDVBFrontend::isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm)
        return 1;
 }
 
-void eDVBFrontend::setSlotInfo(ePyObject obj)
+bool eDVBFrontend::setSlotInfo(ePyObject obj)
 {
        ePyObject Id, Descr, Enabled;
        if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 3)
@@ -2148,14 +2148,13 @@ void eDVBFrontend::setSlotInfo(ePyObject obj)
        strcpy(m_description, PyString_AS_STRING(Descr));
        m_slotid = PyInt_AsLong(Id);
        m_enabled = Enabled == Py_True;
-
        // HACK.. the rotor workaround is neede for all NIMs with LNBP21 voltage regulator...
        m_need_rotor_workaround = !!strstr(m_description, "Alps BSBE1") || !!strstr(m_description, "Alps -S");
-
        eDebug("setSlotInfo for dvb frontend %d to slotid %d, descr %s, need rotorworkaround %s, enabled %s",
                m_dvbid, m_slotid, m_description, m_need_rotor_workaround ? "Yes" : "No", m_enabled ? "Yes" : "No" );
-       return;
+       return true;
 arg_error:
        PyErr_SetString(PyExc_StandardError,
-               "eDVBFrontend::setSlotInfo must get a tuple with first param slotid and second param slot description");
+               "eDVBFrontend::setSlotInfo must get a tuple with first param slotid, second param slot description and third param enabled boolean");
+       return false;
 }
index d2070e9..6bf3646 100644 (file)
@@ -122,7 +122,7 @@ public:
        int isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm);
        int getDVBID() { return m_dvbid; }
        int getSlotID() { return m_slotid; }
-       void setSlotInfo(ePyObject obj); // get a tuple (slotid, slotdescr)
+       bool setSlotInfo(ePyObject obj); // get a tuple (slotid, slotdescr)
 
        int openFrontend();
        int closeFrontend();