Changeset 1780

Show
Ignore:
Timestamp:
01/04/10 14:10:14 (13 years ago)
Author:
arnonym
Message:

Bring back the peaks.

And *flush* fix compilation from the commit before.
I will not commit without a succesfull build.
I will not commit without a succesfull build.
I will not commit without a succesfull build.
I will not commit without a succesfull build.
I will not commit without a succesfull build.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/dice/dice_eap.cpp

    r1779 r1780  
    3535// ----------- helper functions ------------- 
    3636 
     37#if 0 
    3738static const char * 
    3839srcBlockToString(const char id) 
     
    6970    } 
    7071} 
     72#endif 
    7173 
    7274IMPL_DEBUG_MODULE( EAP, EAP, DEBUG_LEVEL_NORMAL ); 
     
    12031205    if(rcfg == NULL) { 
    12041206        debugError("Could not request active router configuration\n"); 
    1205         return ""
     1207        return stringlist()
    12061208    } 
    12071209    stringlist ret; 
    1208     std::vector<int> dests = rcfg->getDestinationsForSource(m_sources[srcname]); 
    1209     for (int i=0; i<dests.size(); ++i) { 
    1210         ret.push_back(m_destinations[dests[i]]); 
     1210    std::vector<unsigned char> dests = rcfg->getDestinationsForSource(m_sources[srcname]); 
     1211    for (unsigned int i=0; i<dests.size(); ++i) { 
     1212        ret.push_back(getDestinationName(dests[i])); 
    12111213    } 
    12121214    return ret; 
     
    13181320EAP::Router::getPeakValue(const std::string& dest) 
    13191321{ 
    1320     debugError("TODO: Implement getPeakValue(%s)\n", dest.c_str()); 
    1321     /*if((unsigned)source >= m_sources.size()) { 
    1322         debugWarning("source id out of range (%d)\n", source); 
    1323         return false; 
    1324     } 
    1325     Source s = m_sources.at(source); 
    1326  
    1327     if((unsigned)dest >= m_destinations.size()) { 
    1328         debugWarning("destination id out of range (%d)\n", dest); 
    1329         return false; 
    1330     } 
    1331     Destination d = m_destinations.at(dest); 
    1332  
    1333     debugOutput(DEBUG_LEVEL_VERBOSE, "getting peak info for [%d] %s => [%d] %s\n",  
    1334                                      source, s.name.c_str(), 
    1335                                      dest, d.name.c_str()); 
    1336  
    1337     // update the peak information 
    13381322    m_peak.read(); 
    1339  
    1340     // construct the routing entry to find 
    1341     RouterConfig::Route r = {s.src, s.srcChannel, d.dst, d.dstChannel, 0}; 
    1342  
    1343     // find the appropriate entry 
    1344     int idx = m_peak.getRouteIndex(r); 
    1345  
    1346     if (idx < 0) { 
    1347         // the route is not present 
    1348         return -1; 
    1349     } else { 
    1350         // the route is present 
    1351         r = m_peak.getRoute(idx); 
    1352         return r.peak; 
    1353     }*/ 
    1354     return -1; 
    1355  
     1323    unsigned char dst = m_destinations[dest]; 
     1324    return m_peak.getPeak(dst); 
    13561325} 
    13571326 
     
    13591328EAP::Router::getPeakValues() 
    13601329{ 
    1361     debugError("TODO: implement getPeakValues()\n"); 
    1362     /*m_peak.read(); 
    1363     Control::CrossbarRouter::PeakValues values; 
    1364     for (unsigned int i=0; i<m_peak.getNbRoutes(); ++i) { 
    1365         Control::CrossbarRouter::PeakValue tmp; 
    1366         RouterConfig::Route route = m_peak.getRoute(i); 
    1367         tmp.destination = getDestinationIndex(route.dst, route.dstChannel); 
    1368         tmp.peakvalue = route.peak; 
    1369         values.push_back(tmp); 
    1370     } 
    1371     return values;*/ 
    1372     return std::map<std::string, double>(); 
     1330    m_peak.read(); 
     1331    std::map<std::string, double> ret; 
     1332    std::map<unsigned char, int> peaks = m_peak.getPeaks(); 
     1333    for (std::map<unsigned char, int>::iterator it=peaks.begin(); it!=peaks.end(); ++it) { 
     1334        ret[getDestinationName(it->first)] = it->second; 
     1335    } 
     1336    return ret; 
    13731337} 
    13741338 
     
    15491513EAP::PeakSpace::read(enum eRegBase base, unsigned offset) 
    15501514{ 
    1551 #warning "Implement me again!" 
    1552 #if 0 
    1553     // first clear the current route vector 
    1554     m_routes.clear(); 
    1555  
    15561515    uint32_t nb_routes; 
    15571516    // we have to figure out the number of entries through the currently 
     
    15641523    nb_routes = rcfg->getNbRoutes(); 
    15651524 
    1566     // read the route info 
     1525    // read the peak/route info 
    15671526    uint32_t tmp_entries[nb_routes]; 
    15681527    if(!m_eap.readRegBlock(base, offset, tmp_entries, nb_routes*4)) { 
     
    15701529        return false; 
    15711530    } 
    1572  
    1573     // decode into the routing vector 
    1574     for(unsigned int i=0; i < nb_routes; i++) { 
    1575         m_routes.push_back(decodeRoute(tmp_entries[i])); 
    1576     } 
    1577 //     show(); 
    1578 #endif 
     1531    // parse the peaks into the map 
     1532    for (unsigned int i=0; i<nb_routes; ++i) { 
     1533        unsigned char dest = tmp_entries[i]&0xff; 
     1534        int peak = (tmp_entries[i]&0xfff0000)>>16; 
     1535        if (m_peaks.count(dest) == 0 || m_peaks[dest] < peak) { 
     1536            m_peaks[dest] = peak; 
     1537        } 
     1538    } 
    15791539    return true; 
    15801540} 
    15811541 
    1582 bool 
    1583 EAP::PeakSpace::write(enum eRegBase base, unsigned offset) 
    1584 { 
    1585     debugError("Peak space is read-only\n"); 
    1586     return true; 
    1587 } 
    15881542 
    15891543void 
    15901544EAP::PeakSpace::show() 
    15911545{ 
    1592     debugError("PeakSpace::show() is currently not implemented!\n"); 
    1593 #if 0 
    1594     for ( RouteVectorIterator it = m_routes.begin(); 
    1595         it != m_routes.end(); 
    1596         ++it ) 
    1597     { 
    1598         struct Route r = *it; 
    1599         printMessage("%s:%02d => %s:%02d : %06d\n", 
    1600                      srcBlockToString(r.src), r.srcChannel, 
    1601                      dstBlockToString(r.dst), r.dstChannel, 
    1602                      r.peak); 
    1603     } 
    1604 #endif 
     1546    printMessage("  %i peaks\n", m_peaks.size()); 
     1547    for (std::map<unsigned char, int>::iterator it=m_peaks.begin(); it!=m_peaks.end(); ++it) { 
     1548        printMessage("0x%02x : %i\n", it->first, it->second); 
     1549    } 
     1550
     1551 
     1552int 
     1553EAP::PeakSpace::getPeak(unsigned char dst) { 
     1554    int ret = m_peaks[dst]; 
     1555    m_peaks.erase(dst); 
     1556    return ret; 
     1557
     1558 
     1559std::map<unsigned char, int> 
     1560EAP::PeakSpace::getPeaks() { 
     1561    // Create a new empty map 
     1562    std::map<unsigned char, int> ret; 
     1563    // Swap the peak map with the new and empty one 
     1564    ret.swap(m_peaks); 
     1565    // Return the now filled map of the peaks :-) 
     1566    return ret; 
    16051567} 
    16061568 
  • trunk/libffado/src/dice/dice_eap.h

    r1779 r1780  
    203203        RouterConfig(EAP &); 
    204204        RouterConfig(EAP &, enum eRegBase, unsigned int offset); 
    205         virtual ~RouterConfig(); 
     205        ~RouterConfig(); 
    206206 
    207207    public: 
    208208 
    209         virtual bool read() {return read(m_base, m_offset);}; 
    210         virtual bool write() {return write(m_base, m_offset);}; 
    211         virtual bool read(enum eRegBase b, unsigned offset); 
    212         virtual bool write(enum eRegBase b, unsigned offset); 
    213         virtual void show(); 
    214  
    215         /** 
    216           @brief map for the routes 
    217  
    218           The key is the destination as each destination can only have audio from one source. 
    219           Sources can be routed to several destinations though. 
    220           */ 
    221         typedef std::map<unsigned char,unsigned char> RouteVectorV2; 
     209        bool read() {return read(m_base, m_offset);}; 
     210        bool write() {return write(m_base, m_offset);}; 
     211        bool read(enum eRegBase b, unsigned offset); 
     212        bool write(enum eRegBase b, unsigned offset); 
     213        void show(); 
    222214 
    223215        /** 
     
    254246        unsigned int getNbRoutes() {return m_routes2.size();}; 
    255247 
    256     protected
     248    private
    257249        EAP &m_eap; 
    258250        enum eRegBase m_base; 
    259251        unsigned int m_offset; 
     252 
     253        /** 
     254          @brief map for the routes 
     255 
     256          The key is the destination as each destination can only have audio from one source. 
     257          Sources can be routed to several destinations though. 
     258          */ 
     259        typedef std::map<unsigned char,unsigned char> RouteVectorV2; 
    260260        RouteVectorV2 m_routes2; 
    261     protected
     261    private
    262262        DECLARE_DEBUG_MODULE_REFERENCE; 
    263263    }; 
     
    266266      the peak space is a special version of a router config 
    267267      */ 
    268     class PeakSpace : public RouterConfig
     268    class PeakSpace
    269269    private: 
    270270        friend class Dice::EAP; 
    271         PeakSpace(EAP &p) : RouterConfig(p, eRT_Peak, 0) {}; 
    272         virtual ~PeakSpace() {}; 
     271        PeakSpace(EAP &p) : m_eap(p), m_base(eRT_Peak), m_offset(0), m_debugModule(p.m_debugModule) {}; 
     272        ~PeakSpace() {}; 
    273273 
    274274    public: 
    275         virtual bool read() {return read(m_base, m_offset);}; 
    276         virtual bool write() {return write(m_base, m_offset);}; 
    277         virtual bool read(enum eRegBase b, unsigned offset); 
    278         virtual bool write(enum eRegBase b, unsigned offset); 
    279         virtual void show(); 
     275        bool read() {return read(m_base, m_offset);}; 
     276        bool read(enum eRegBase b, unsigned offset); 
     277        void show(); 
     278 
     279        std::map<unsigned char, int> getPeaks(); 
     280        int getPeak(unsigned char dest); 
     281 
     282    private: 
     283        EAP &m_eap; 
     284        enum eRegBase m_base; 
     285        unsigned int m_offset; 
     286 
     287        /** 
     288          @brief maps peaks to destinations 
     289          */ 
     290        std::map<unsigned char, int> m_peaks; 
     291 
     292        DECLARE_DEBUG_MODULE_REFERENCE; 
    280293    }; 
    281294 
  • trunk/libffado/support/mixer-qt4/ffado/widgets/crossbarrouter.py

    r1779 r1780  
    2020 
    2121from PyQt4 import QtGui, QtCore 
    22 import dbus 
     22import dbus, math 
    2323 
    2424import logging 
     
    4646        value = self.level/4096 
    4747        r = self.rect() 
    48         r.setHeight(r.height() * value
     48        r.setHeight(r.height() * math.sqrt(value)
    4949        r.moveBottom(self.rect().height()) 
    5050        p.fillRect(r, self.palette().highlight()) 
     
    9191 
    9292    def peakValue(self, value): 
    93         #self.vu.updateLevel(value) 
     93        self.vu.updateLevel(value) 
    9494        pass 
    9595 
     
    132132        self.biglayout.addLayout(self.toplayout) 
    133133 
    134         self.vubtn = QtGui.QPushButton("Switch VU", self) 
     134        self.vubtn = QtGui.QPushButton("Switch peak meters", self) 
    135135        self.vubtn.setCheckable(True) 
    136136        self.connect(self.vubtn, QtCore.SIGNAL("toggled(bool)"), self.runVu) 
     
    168168        #log.debug("CrossbarRouter.updateLevels()") 
    169169        peakvalues = self.interface.getPeakValues() 
    170         log.debug("Got %i peaks" % len(peakvalues)) 
     170        #log.debug("Got %i peaks" % len(peakvalues)) 
    171171        for peak in peakvalues: 
    172172            #log.debug("peak = [%s,%s]" % (str(peak[0]),str(peak[1])))