Changeset 1776

Show
Ignore:
Timestamp:
01/02/10 15:07:26 (14 years ago)
Author:
arnonym
Message:

Reduce the LOC:

  • Use only strings as identifiers for the Dice::EAP::Router. Updating the router doesn't happen that often, using strings only is acceptable. And it eases handling so much.
  • Adapt the control interface.
  • Adapt the dbus interface.
  • Adapt the routers gui.
  • The peak-space is not yet working (I didn't actually test it), the peak-functions of EAP::Router return nothing.
  • And the test for the dice has to be adopted when the peaks are working again.

TODO:

  • Re-activate the peaks.
  • Adopt the mixer interface.
Files:

Legend:

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

    r1772 r1776  
    219219        case DICE_EAP_CAP_GENERAL_CHIP_DICEJR: 
    220220            // second audio port (unique to the junior) 
    221             addSource("InS1", eRS_InS1, 0, 8); 
     221            addSource("InS1", 0, 8, eRS_InS1); 
    222222        case DICE_EAP_CAP_GENERAL_CHIP_DICEMINI: 
    223223            /// these are common to the mini and junior 
    224224            // the AES receiver 
    225             addSource("AES", eRS_AES, 0, 8); 
     225            addSource("AES", 0, 8, eRS_AES); 
    226226            // the ADAT receiver 
    227             addSource("ADAT", eRS_ADAT, 0, 8); 
     227            addSource("ADAT", 0, 8, eRS_ADAT); 
    228228            // the Mixer outputs 
    229             addSource("MixerOut", eRS_Mixer, 0, 16); 
     229            addSource("MixerOut", 0, 16, eRS_Mixer); 
    230230            // the first audio port 
    231             addSource("InS0", eRS_InS0, 0, 8); 
     231            addSource("InS0", 0, 8, eRS_InS0); 
    232232            // the ARM audio port 
    233             addSource("ARM", eRS_ARM, 0, 8); 
     233            addSource("ARM", 0, 8, eRS_ARM); 
    234234            // the 1394 stream receivers 
    235             addSource("1394_0", eRS_ARX0, 0, 16); 
    236             addSource("1394_1", eRS_ARX1, 0, 16); 
     235            addSource("1394_0", 0, 16, eRS_ARX0); 
     236            addSource("1394_1", 0, 16, eRS_ARX1); 
    237237            // mute 
    238             addSource("Mute", eRS_Muted, 0, 1); 
     238            addSource("Mute", 0, 1, eRS_Muted); 
    239239            break; 
    240240        default: 
     
    253253        case DICE_EAP_CAP_GENERAL_CHIP_DICEJR: 
    254254            // second audio port (unique to the junior) 
    255             addDestination("InS1", eRD_InS1, 0, 8); 
     255            addDestination("InS1", 0, 8, eRD_InS1); 
    256256        case DICE_EAP_CAP_GENERAL_CHIP_DICEMINI: 
    257257            /// these are common to the mini and junior 
    258258            // the AES receiver 
    259             addDestination("AES", eRD_AES, 0, 8); 
     259            addDestination("AES", 0, 8, eRD_AES); 
    260260            // the ADAT receiver 
    261             addDestination("ADAT", eRD_ADAT, 0, 8); 
     261            addDestination("ADAT", 0, 8, eRD_ADAT); 
    262262            // the Mixer outputs 
    263             addDestination("MixerIn", eRD_Mixer0, 0, 16); 
    264             addDestination("MixerIn", eRD_Mixer1, 16, 2); 
     263            addDestination("MixerIn", 0, 16, eRD_Mixer0); 
     264            addDestination("MixerIn", 0, 2, eRD_Mixer1, 16); 
    265265            // the first audio port 
    266             addDestination("InS0", eRD_InS0, 0, 8); 
     266            addDestination("InS0", 0, 8, eRD_InS0); 
    267267            // the ARM audio port 
    268             addDestination("ARM", eRD_ARM, 0, 8); 
     268            addDestination("ARM", 0, 8, eRD_ARM); 
    269269            // the 1394 stream receivers 
    270             addDestination("1394_0", eRD_ATX0, 0, 16); 
    271             addDestination("1394_1", eRD_ATX1, 0, 16); 
     270            addDestination("1394_0", 0, 16, eRD_ATX0); 
     271            addDestination("1394_1", 0, 16, eRD_ATX1); 
    272272            // mute 
    273             addDestination("Mute", eRD_Muted, 0, 1); 
     273            addDestination("Mute", 0, 1, eRD_Muted); 
    274274            break; 
    275275        default: 
     
    280280 
    281281void 
    282 EAP::addSource( const std::string name, enum eRouteSource srcid, unsigned int base, unsigned int count ) { 
    283     m_router->setupSourcesAddSource(name.c_str(), srcid, base, count); 
     282EAP::addSource(const std::string name, unsigned int base, unsigned int count, 
     283               enum eRouteSource srcid, unsigned int offset) 
     284
     285    m_router->addSource(name, srcid, base, count, offset); 
    284286} 
    285287void 
    286 EAP::addDestination( const std::string name, enum eRouteDestination destid, unsigned int base, unsigned int count ) { 
    287     m_router->setupDestinationsAddDestination(name.c_str(), destid, base, count); 
     288EAP::addDestination(const std::string name, unsigned int base, unsigned int count, 
     289                    enum eRouteDestination destid, unsigned int offset) 
     290
     291    m_router->addDestination(name, destid, base, count, offset); 
    288292} 
    289293 
     
    496500                                     (m_mixer_readonly?"not ":""), 
    497501                                     (m_mixer_flashstored?"":"not ")); 
    498     printMessage("         tx id: %s [%d], rx id: %s [%d]\n",  
    499                                      dstBlockToString(m_mixer_tx_id), m_mixer_tx_id
    500                                      srcBlockToString(m_mixer_rx_id), m_mixer_rx_id); 
     502    printMessage("         tx id: (%d==eRD_Mixer0) ? %s, rx id: (%d==eRS_Mixer) ? %s\n",  
     503                                     m_mixer_tx_id, (m_mixer_tx_id == eRD_Mixer0)?"true":"false"
     504                                     m_mixer_rx_id, (m_mixer_rx_id == eRS_Mixer) ?"true":"false"); 
    501505    printMessage("         nb tx channels: %d, nb rx channels: %d\n", m_mixer_nb_tx, m_mixer_nb_rx); 
    502506    printMessage(" General: dynamic stream config %ssupported\n", 
     
    10921096} 
    10931097 
     1098// 
    10941099// ----------- Router ------------- 
    1095 // FIXME: some more efficient datastructure for the  
    1096 //        sources and destinations might be good 
    1097  
     1100// 
    10981101 
    10991102EAP::Router::Router(EAP &p) 
     
    11111114 
    11121115void 
    1113 EAP::Router::setupSourcesAddSource(const char *basename, enum eRouteSource srcid,  
    1114                                            unsigned int base, unsigned int cnt) 
    1115 
    1116     unsigned int i=0; 
    1117     char name[16]; 
    1118     for (i=0; i<cnt; i++) { 
    1119         snprintf(name, 16, "%s:%02d", basename, base+i); 
    1120         struct Source s = {name, srcid, i}; 
    1121         m_sources.push_back(s); 
     1116EAP::Router::addSource(const std::string& basename, enum eRouteSource srcid, 
     1117                       unsigned int base, unsigned int cnt, unsigned int offset) 
     1118
     1119    std::string name = basename + ":"; 
     1120    char tmp[4]; 
     1121    for (unsigned int i=0; i<cnt; i++) { 
     1122        snprintf(tmp, 4, "%02d", offset+i); 
     1123        m_sources[name+tmp] = (srcid<<4) + base+i; 
    11221124    } 
    11231125} 
    11241126 
    11251127void 
    1126 EAP::Router::setupDestinationsAddDestination(const char *basename, enum eRouteDestination dstid, 
    1127                                                      unsigned int base, unsigned int cnt) 
    1128 
    1129     unsigned int i=0; 
    1130     char name[16]; 
    1131     for (i=0; i<cnt; i++) { 
    1132         snprintf(name, 16, "%s:%02d", basename, base+i); 
    1133         struct Destination d = {name, dstid, i}; 
    1134         m_destinations.push_back(d); 
     1128EAP::Router::addDestination(const std::string& basename, enum eRouteDestination dstid, 
     1129                            unsigned int base, unsigned int cnt, unsigned int offset) 
     1130
     1131    std::string name = basename + ":"; 
     1132    char tmp[4]; 
     1133    for (unsigned int i=0; i<cnt; i++) { 
     1134        snprintf(tmp, 4, "%02d", offset+i); 
     1135        m_destinations[name+tmp] = (dstid<<4) + base+i; 
    11351136    } 
    11361137} 
     
    11391140EAP::Router::getSourceName(const int srcid) 
    11401141{ 
    1141     if((unsigned)srcid < m_sources.size()) { 
    1142         return m_sources.at(srcid).name; 
    1143     } else { 
    1144         debugWarning("source id out of range (%d)\n", srcid); 
    1145         return ""; 
    1146     } 
     1142    for (std::map<std::string, int>::iterator it=m_sources.begin(); it!=m_sources.end(); ++it) { 
     1143        if (it->second == srcid) { 
     1144            return it->first; 
     1145        } 
     1146    } 
     1147    return ""; 
    11471148} 
    11481149 
     
    11501151EAP::Router::getDestinationName(const int dstid) 
    11511152{ 
    1152     if((unsigned)dstid < m_destinations.size()) { 
    1153         return m_destinations.at(dstid).name; 
    1154     } else { 
    1155         debugWarning("destination id out of range (%d)\n", dstid); 
    1156         return ""; 
    1157     } 
     1153    debugWarning("TODO: Implement getDestinationName(0x%02x)\n", dstid); 
     1154    for (std::map<std::string, int>::iterator it=m_destinations.begin(); it!=m_destinations.end(); ++it) { 
     1155        if (it->second == dstid) { 
     1156            return it->first; 
     1157        } 
     1158    } 
     1159    return ""; 
    11581160} 
    11591161 
     
    11611163EAP::Router::getSourceIndex(std::string name) 
    11621164{ 
    1163     int i = 0; 
    1164     for ( SourceVectorIterator it = m_sources.begin(); 
    1165         it != m_sources.end(); 
    1166         ++it ) 
    1167     { 
    1168         if(it->name == name) return i; 
    1169         i++; 
    1170     } 
    1171     return -1; 
     1165    if (m_sources.count(name) < 1) 
     1166        return -1; 
     1167    return m_sources[name]; 
    11721168} 
    11731169 
     
    11751171EAP::Router::getDestinationIndex(std::string name) 
    11761172{ 
    1177     int i = 0; 
    1178     for ( DestinationVectorIterator it = m_destinations.begin(); 
    1179         it != m_destinations.end(); 
    1180         ++it ) 
    1181     { 
    1182         if(it->name == name) return i; 
    1183         i++; 
    1184     } 
    1185     return -1; 
    1186 
    1187  
    1188 int 
    1189 EAP::Router::getSourceIndex(enum eRouteSource srcid, int channel) 
    1190 
    1191     int i = 0; 
    1192     for ( SourceVectorIterator it = m_sources.begin(); 
    1193         it != m_sources.end(); 
    1194         ++it ) 
    1195     { 
    1196         if((it->src == srcid) && (it->srcChannel == channel)) return i; 
    1197         i++; 
    1198     } 
    1199     return -1; 
    1200 
    1201  
    1202 int 
    1203 EAP::Router::getDestinationIndex(enum eRouteDestination dstid, int channel) 
    1204 
    1205     int i = 0; 
    1206     for ( DestinationVectorIterator it = m_destinations.begin(); 
    1207         it != m_destinations.end(); 
    1208         ++it ) 
    1209     { 
    1210         if((it->dst == dstid) && (it->dstChannel == channel)) return i; 
    1211         i++; 
    1212     } 
    1213     return -1; 
    1214 
    1215  
    1216 Control::CrossbarRouter::NameVector 
     1173    if (m_destinations.count(name) < 1) 
     1174        return -1; 
     1175    return m_destinations[name]; 
     1176
     1177 
     1178stringlist 
    12171179EAP::Router::getSourceNames() 
    12181180{ 
    1219     Control::CrossbarRouter::NameVector n; 
    1220     for ( SourceVectorIterator it = m_sources.begin(); 
    1221         it != m_sources.end(); 
    1222         ++it ) 
    1223     { 
    1224         n.push_back(it->name); 
    1225     } 
     1181    stringlist n; 
     1182    for (std::map<std::string, int>::iterator it=m_sources.begin(); it!=m_sources.end(); ++it) 
     1183        n.push_back(it->first); 
    12261184    return n; 
    12271185} 
    12281186 
    1229 Control::CrossbarRouter::NameVector 
     1187stringlist 
    12301188EAP::Router::getDestinationNames() 
    12311189{ 
    1232     Control::CrossbarRouter::NameVector n; 
    1233     for ( DestinationVectorIterator it = m_destinations.begin(); 
    1234         it != m_destinations.end(); 
    1235         ++it ) 
    1236     { 
    1237         n.push_back(it->name); 
    1238     } 
     1190    stringlist n; 
     1191    for (std::map<std::string, int>::iterator it=m_destinations.begin(); it!=m_destinations.end(); ++it) 
     1192        n.push_back(it->first); 
    12391193    return n; 
    12401194} 
    12411195 
    1242 Control::CrossbarRouter::Groups 
    1243 EAP::Router::getSources() 
    1244 
    1245     debugError("EAP::Router::getSources() is not yet implemented!"); 
    1246     return Control::CrossbarRouter::Groups(); 
    1247 
    1248  
    1249 Control::CrossbarRouter::Groups 
    1250 EAP::Router::getDestinations() 
    1251 
    1252     debugError("EAP::Router::getDestinations() is not yet implemented!"); 
    1253     return Control::CrossbarRouter::Groups(); 
    1254 
    1255  
    1256 Control::CrossbarRouter::IntVector 
    1257 EAP::Router::getDestinationsForSource(const int srcid) 
    1258 
    1259     IntVector retval; 
    1260     if((unsigned)srcid < m_sources.size()) { 
    1261         Source s = m_sources.at(srcid); 
    1262  
    1263         // get the routing configuration 
    1264         RouterConfig *rcfg = m_eap.getActiveRouterConfig(); 
    1265         if(rcfg == NULL) { 
    1266             debugError("Could not request active router configuration\n"); 
    1267             return retval; 
    1268         } 
    1269         // get the source routes 
    1270         RouterConfig::RouteVector v = rcfg->getRoutesForSource(s.src, s.srcChannel); 
    1271  
    1272         for ( RouterConfig::RouteVectorIterator it = v.begin(); 
    1273             it != v.end(); 
    1274             ++it ) 
    1275         { 
    1276             // FIXME: some more efficient datastructure might be good to 
    1277             // avoid this loop 
    1278             RouterConfig::Route &r = *it; 
    1279             int i = 0; 
    1280             for ( DestinationVectorIterator it = m_destinations.begin(); 
    1281                 it != m_destinations.end(); 
    1282                 ++it ) 
    1283             { 
    1284                 if((it->dst == r.dst) && (it->dstChannel == r.dstChannel)) { 
    1285                     retval.push_back(i); 
    1286                     break; // can only match once 
    1287                 } 
    1288                 i++; 
    1289             } 
    1290         } 
    1291         return retval; 
    1292     } else { 
    1293         debugWarning("source id out of range (%d)\n", srcid); 
    1294         return retval; 
    1295     } 
    1296 
    1297  
    1298 int 
    1299 EAP::Router::getSourceForDestination(const int dstid) 
    1300 
    1301     if((unsigned)dstid < m_destinations.size()) { 
    1302         Destination d = m_destinations.at(dstid); 
    1303  
    1304         // get the routing configuration 
    1305         RouterConfig *rcfg = m_eap.getActiveRouterConfig(); 
    1306         if(rcfg == NULL) { 
    1307             debugError("Could not request active router configuration\n"); 
    1308             return false; 
    1309         } 
    1310  
    1311         RouterConfig::Route r = rcfg->getRouteForDestination(d.dst, d.dstChannel); 
    1312         if(r.src == eRS_Invalid) { 
    1313             return -1; 
    1314         } else { 
    1315             // FIXME: some more efficient datastructure might be good to 
    1316             // avoid this loop 
    1317             int i = 0; 
    1318             for ( SourceVectorIterator it = m_sources.begin(); 
    1319                 it != m_sources.end(); 
    1320                 ++it ) 
    1321             { 
    1322                 if((it->src == r.src) && (it->srcChannel == r.srcChannel)) return i; 
    1323                 i++; 
    1324             } 
    1325             return -1; 
    1326         } 
    1327     } else { 
    1328         debugWarning("destination id out of range (%d)\n", dstid); 
    1329         return -1; 
    1330     } 
    1331 
    1332  
    1333 int 
    1334 EAP::Router::getNbSources() 
    1335 
    1336     return m_sources.size(); 
    1337 
    1338  
    1339 int 
    1340 EAP::Router::getNbDestinations() 
    1341 
    1342     return m_destinations.size(); 
    1343 
     1196stringlist 
     1197EAP::Router::getDestinationsForSource(const std::string& srcname) { 
     1198    debugWarning("TODO: Implement getDestinationsForSource(%s)\n", srcname.c_str()); 
     1199    return stringlist(); 
     1200
     1201std::string 
     1202EAP::Router::getSourceForDestination(const std::string& dstname) { 
     1203    RouterConfig* rcfg = m_eap.getActiveRouterConfig(); 
     1204    if(rcfg == NULL) { 
     1205        debugError("Could not request active router configuration\n"); 
     1206        return ""; 
     1207    } 
     1208    eRouteDestination dst = eRouteDestination(m_destinations[dstname]>>4); 
     1209    int dstChannel = m_destinations[dstname]&0xf; 
     1210    RouterConfig::Route r = rcfg->getRouteForDestination(dst, dstChannel); 
     1211    if (r.src == eRS_Invalid) { 
     1212        return ""; 
     1213    } 
     1214    return getSourceName((r.src<<4)+r.srcChannel); 
     1215
     1216 
    13441217 
    13451218bool 
    13461219EAP::Router::canConnect(const int source, const int dest) 
    13471220{ 
    1348     if((unsigned)source >= m_sources.size()) { 
     1221    debugWarning("TODO: Implement canConnect(0x%02x, 0x%02x)\n", source, dest); 
     1222    /*if((unsigned)source >= m_sources.size()) { 
    13491223        debugWarning("source id out of range (%d)\n", source); 
    13501224        return false; 
     
    13561230        return false; 
    13571231    } 
    1358     Destination d = m_destinations.at(dest); 
     1232    Destination d = m_destinations.at(dest);*/ 
    13591233 
    13601234    // we can connect anything 
     
    13661240EAP::Router::setConnectionState(const int source, const int dest, const bool enable) 
    13671241{ 
    1368     if((unsigned)source >= m_sources.size()) { 
    1369         debugWarning("source id out of range (%d)\n", source); 
    1370         return false; 
    1371     } 
    1372     Source s = m_sources.at(source); 
    1373  
    1374     if((unsigned)dest >= m_destinations.size()) { 
    1375         debugWarning("destination id out of range (%d)\n", dest); 
    1376         return false; 
    1377     } 
    1378     Destination d = m_destinations.at(dest); 
    1379  
    13801242    // get the routing configuration 
    13811243    RouterConfig *rcfg = m_eap.getActiveRouterConfig(); 
     
    13851247    } 
    13861248 
    1387     // build a new routing configuration 
    1388     RouterConfig newcfg = EAP::RouterConfig(*rcfg); 
    1389  
    1390     // construct the routing entry to find 
    1391     RouterConfig::Route r = {s.src, s.srcChannel, d.dst, d.dstChannel}; 
    1392  
    1393     // find the appropriate entry 
    1394     int idx = newcfg.getRouteIndex(r); 
    1395  
    1396     if (idx < 0) { 
    1397         // we have to add the route 
    1398         newcfg.insertRoute(r); 
    1399     } else { 
    1400         // the route is already present, so we can replace it 
    1401         if(enable) { 
    1402             debugOutput(DEBUG_LEVEL_VERBOSE, "connection %d => %d already present\n", source, dest); 
    1403             //return true; 
    1404         } else { 
    1405             // remove the route 
    1406             newcfg.removeRoute(idx); 
    1407         } 
    1408     } 
    1409  
    1410     // if we get here it means we have to upload a new router config 
    1411     if(!m_eap.updateCurrentRouterConfig(newcfg)) { 
    1412         debugError("Could not update router config\n"); 
    1413         return false; 
    1414     } 
    1415  
    1416     return true; 
     1249    RouterConfig::Route r = rcfg->getRouteForDestination(eRouteDestination(dest>>4), dest&0xf); 
     1250    if ( r.srcChannel == -1 && r.dstChannel == -1 && enable ) { 
     1251        r.src = eRouteSource(source>>4); 
     1252        r.srcChannel = source&0xf; 
     1253        r.dst = eRouteDestination(dest>>4); 
     1254        r.dstChannel = dest&0xf; 
     1255        int ret = rcfg->insertRoute(r); 
     1256        m_eap.updateCurrentRouterConfig(*rcfg); 
     1257        return ret; 
     1258    } 
     1259    if ( r.dst != (dest>>4) || r.dstChannel != (dest&0xf) ) { 
     1260        debugError("Route exists but isn't correct? strange...\n"); 
     1261        debugError(" wanted: 0x%02x got: 0x%02x\n", dest, (r.dst<<4)+r.dstChannel); 
     1262        return false; 
     1263    } 
     1264    if ( !enable ) { 
     1265        int ret = rcfg->removeRoute(r); 
     1266        m_eap.updateCurrentRouterConfig(*rcfg); 
     1267        return ret; 
     1268    } 
     1269    if ( enable ) { 
     1270        int index = rcfg->getRouteIndex(r); 
     1271        r.src = eRouteSource(source>>4); 
     1272        r.srcChannel = (source&0xf); 
     1273        int ret = rcfg->replaceRoute(index, r); 
     1274        m_eap.updateCurrentRouterConfig(*rcfg); 
     1275        return ret; 
     1276    } 
     1277 
     1278    // When we reach this point, something went wrong. Return false by default... 
     1279    return false; 
    14171280} 
    14181281 
     
    14201283EAP::Router::getConnectionState(const int source, const int dest) 
    14211284{ 
    1422     if((unsigned)source >= m_sources.size()) { 
    1423         debugWarning("source id out of range (%d)\n", source); 
    1424         return false; 
    1425     } 
    1426     Source s = m_sources.at(source); 
    1427  
    1428     if((unsigned)dest >= m_destinations.size()) { 
    1429         debugWarning("destination id out of range (%d)\n", dest); 
    1430         return false; 
    1431     } 
    1432     Destination d = m_destinations.at(dest); 
    1433  
    14341285    // get the routing configuration 
    14351286    RouterConfig *rcfg = m_eap.getActiveRouterConfig(); 
     
    14381289        return false; 
    14391290    } 
    1440  
    1441     // build a new routing configuration 
    1442     RouterConfig newcfg = EAP::RouterConfig(*rcfg); 
    1443  
    1444     // construct the routing entry to find 
    1445     RouterConfig::Route r = {s.src, s.srcChannel, d.dst, d.dstChannel}; 
    1446  
    1447     // find the appropriate entry 
    1448     int idx = newcfg.getRouteIndex(r); 
    1449  
    1450     if (idx < 0) { 
    1451         // the route is not present 
    1452         return false; 
    1453     } else { 
    1454         // the route is already present 
    1455         return true; 
    1456     } 
    1457 
    1458  
    1459 bool 
    1460 EAP::Router::canConnect(std::string src, std::string dst) 
     1291    // Construct a route 
     1292    RouterConfig::Route r = { eRouteSource(source>>4), source&0xf, eRouteDestination(dest>>4), dest&0xf }; 
     1293    // get the routes index... 
     1294    int idx = rcfg->getRouteIndex(r); 
     1295    // ...and return true if it exists 
     1296    return (idx>=0); 
     1297
     1298 
     1299bool 
     1300EAP::Router::canConnect(const std::string& src, const std::string& dst) 
    14611301{ 
    14621302    int srcidx = getSourceIndex(src); 
     
    14661306 
    14671307bool 
    1468 EAP::Router::setConnectionState(std::string src, std::string dst, const bool enable) 
     1308EAP::Router::setConnectionState(const std::string& src, const std::string& dst, const bool enable) 
    14691309{ 
    14701310    int srcidx = getSourceIndex(src); 
     
    14741314 
    14751315bool 
    1476 EAP::Router::getConnectionState(std::string src, std::string dst) 
     1316EAP::Router::getConnectionState(const std::string& src, const std::string& dst) 
    14771317{ 
    14781318    int srcidx = getSourceIndex(src); 
     
    14811321} 
    14821322 
    1483 // the map is organized as a matrix where the  
    1484 // rows are the destinations and the columns are 
    1485 // the sources 
    1486  
    1487 // note that map as assumed to be big enough and 
    1488 // allocated by the user 
    1489 bool 
    1490 EAP::Router::getConnectionMap(int *map) 
    1491 { 
    1492     unsigned int nb_sources = getNbSources(); 
    1493     unsigned int nb_destinations = getNbDestinations(); 
    1494  
    1495     // clear the map 
    1496     memset(map, 0, nb_sources * nb_destinations * sizeof(int)); 
    1497  
    1498     // get the routing configuration 
    1499     RouterConfig *rcfg = m_eap.getActiveRouterConfig(); 
    1500     if(rcfg == NULL) { 
    1501         debugError("Could not request active router configuration\n"); 
    1502         return false; 
    1503     } 
    1504  
    1505     unsigned int nb_routes = rcfg->getNbRoutes(); 
    1506  
    1507     for(unsigned int i=0; i<nb_routes; i++) { 
    1508         struct RouterConfig::Route r = rcfg->getRoute(i); 
    1509         int srcidx = getSourceIndex(r.src, r.srcChannel); 
    1510         int dstidx = getDestinationIndex(r.dst, r.dstChannel); 
    1511         if(srcidx < 0) { 
    1512             debugWarning("bogus source (%d, %d) in route table\n", r.src, r.srcChannel); 
    1513         } else if(dstidx < 0) { 
    1514             debugWarning("bogus destination (%d, %d) in route table\n", r.dst, r.dstChannel); 
    1515         } else { 
    1516             int *ptr = map; 
    1517             ptr += dstidx * nb_sources; 
    1518             ptr += srcidx; 
    1519             *ptr = 1; // route present 
    1520         } 
    1521     } 
    1522     return true; 
    1523 } 
    1524  
    1525 bool 
    1526 EAP::Router::setConnectionMap(int *map) 
    1527 { 
    1528     return false; 
    1529 } 
    15301323 
    15311324bool 
     
    15501343 
    15511344double 
    1552 EAP::Router::getPeakValue(const int source, const int dest) 
    1553 
    1554     if((unsigned)source >= m_sources.size()) { 
     1345EAP::Router::getPeakValue(const std::string& dest) 
     1346
     1347    debugError("TODO: Implement getPeakValue(%s)\n", dest.c_str()); 
     1348    /*if((unsigned)source >= m_sources.size()) { 
    15551349        debugWarning("source id out of range (%d)\n", source); 
    15561350        return false; 
     
    15841378        r = m_peak.getRoute(idx); 
    15851379        return r.peak; 
    1586     } 
    1587  
    1588 
    1589  
    1590 Control::CrossbarRouter::PeakValues 
     1380    }*/ 
     1381    return -1; 
     1382 
     1383
     1384 
     1385std::map<std::string, double> 
    15911386EAP::Router::getPeakValues() 
    15921387{ 
    1593     m_peak.read(); 
     1388    debugError("TODO: implement getPeakValues()\n"); 
     1389    /*m_peak.read(); 
    15941390    Control::CrossbarRouter::PeakValues values; 
    15951391    for (unsigned int i=0; i<m_peak.getNbRoutes(); ++i) { 
     
    16001396        values.push_back(tmp); 
    16011397    } 
    1602     return values; 
     1398    return values;*/ 
     1399    return std::map<std::string, double>(); 
    16031400} 
    16041401 
     
    16071404{ 
    16081405    // print the peak space as it also contains the routing configuration 
    1609     printMessage("Active router config:\n"); 
    1610     m_peak.read(); 
    1611     m_peak.show(); 
     1406    printMessage("Router sources:\n"); 
     1407    for ( std::map<std::string, int>::iterator it=m_sources.begin(); it!=m_sources.end(); ++it ) { 
     1408        printMessage(" 0x%02x : %s\n", (*it).second, (*it).first.c_str()); 
     1409    } 
     1410    printMessage("Router destinations:\n"); 
     1411    for ( std::map<std::string, int>::iterator it=m_destinations.begin(); it!=m_destinations.end(); ++it ) { 
     1412        printMessage(" 0x%02x : %s\n", (*it).second, (*it).first.c_str()); 
     1413    } 
     1414    printMessage("Router connections:\n"); 
     1415    stringlist sources = getSourceNames(); 
     1416    stringlist destinations = getDestinationNames(); 
     1417    for (stringlist::iterator it1=sources.begin(); it1!=sources.end(); ++it1) { 
     1418        for (stringlist::iterator it2=destinations.begin(); it2!=destinations.end(); ++it2) { 
     1419            if (getConnectionState(*it1, *it2)) { 
     1420                printMessage(" %s -> %s\n", it1->c_str(), it2->c_str()); 
     1421            } 
     1422        } 
     1423    } 
     1424    //printMessage("Active router config:\n"); 
     1425    //m_peak.read(); 
     1426    //m_peak.show(); 
    16121427} 
    16131428 
     
    18631678    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "%s:%02d source can't be found\n", 
    18641679                                          dstBlockToString((int)dst), channel); 
    1865     struct Route r = {eRS_Invalid, -1, eRD_Invalid, 0, 0}; 
     1680    struct Route r = {eRS_Invalid, -1, eRD_Invalid, -1, 0}; 
    18661681    return r; 
    18671682} 
  • trunk/libffado/src/dice/dice_eap.h

    r1772 r1776  
    223223        virtual void show(); 
    224224 
    225  
    226225        bool insertRoute(struct Route r) 
    227226            {return insertRoute(r, m_routes.size());}; 
     
    367366      */ 
    368367    class Router : public Control::CrossbarRouter { 
    369     private: 
    370         struct Source { 
    371             std::string name; 
    372             enum eRouteSource src; 
    373             int srcChannel; 
    374         }; 
    375         typedef std::vector<Source> SourceVector; 
    376         typedef std::vector<Source>::iterator SourceVectorIterator; 
    377  
    378         struct Destination { 
    379             std::string name; 
    380             enum eRouteDestination dst; 
    381             int dstChannel; 
    382         }; 
    383         typedef std::vector<Destination> DestinationVector; 
    384         typedef std::vector<Destination>::iterator DestinationVectorIterator; 
    385  
    386368    public: 
    387369        Router(EAP &); 
     
    390372        void show(); 
    391373 
    392         void setupDestinationsAddDestination(const char *name, enum eRouteDestination dstid, 
    393                                              unsigned int base, unsigned int cnt); 
    394         void setupSourcesAddSource(const char *name, enum eRouteSource srcid, 
    395                                    unsigned int base, unsigned int cnt); 
    396  
    397         int getDestinationIndex(enum eRouteDestination dstid, int channel); 
    398         int getSourceIndex(enum eRouteSource srcid, int channel); 
     374        void addDestination(const std::string& name, enum eRouteDestination dstid, 
     375                            unsigned int base, unsigned int cnt, unsigned int offset=0); 
     376        void addSource(const std::string& name, enum eRouteSource srcid, 
     377                       unsigned int base, unsigned int cnt, unsigned int offset=0); 
    399378 
    400379        // per-coefficient access 
     
    403382        virtual int getSourceIndex(std::string); 
    404383        virtual int getDestinationIndex(std::string); 
    405         virtual NameVector getSourceNames(); 
    406         virtual NameVector getDestinationNames(); 
    407  
    408         virtual Control::CrossbarRouter::Groups getSources(); 
    409         virtual Control::CrossbarRouter::Groups getDestinations(); 
    410  
    411         virtual IntVector getDestinationsForSource(const int); 
    412         virtual int getSourceForDestination(const int); 
    413  
    414         virtual bool canConnect( const int source, const int dest); 
    415         virtual bool setConnectionState( const int source, const int dest, const bool enable); 
    416         virtual bool getConnectionState( const int source, const int dest ); 
    417  
    418         virtual bool canConnect(std::string, std::string); 
    419         virtual bool setConnectionState(std::string, std::string, const bool enable); 
    420         virtual bool getConnectionState(std::string, std::string); 
     384        virtual stringlist getSourceNames(); 
     385        virtual stringlist getDestinationNames(); 
     386 
     387        std::string getSourceForDestination(const std::string& dstname); 
     388        stringlist getDestinationsForSource(const std::string& srcname); 
     389 
     390        virtual bool canConnect(const int srcidx, const int dstidx); 
     391        virtual bool setConnectionState(const int srcidx, const int dstidx, const bool enable); 
     392        virtual bool getConnectionState(const int srcidx, const int dstidx); 
     393 
     394        virtual bool canConnect(const std::string& srcname, const std::string& dstname); 
     395        virtual bool setConnectionState(const std::string& srcname, const std::string& dstname, const bool enable); 
     396        virtual bool getConnectionState(const std::string& srcname, const std::string& dstname); 
    421397 
    422398        virtual bool clearAllConnections(); 
    423  
    424         virtual int getNbSources(); 
    425         virtual int getNbDestinations(); 
    426  
    427         // functions to access the entire routing map at once 
    428         // idea is that the row/col nodes that are 1 get a routing entry 
    429         virtual bool getConnectionMap(int *); 
    430         virtual bool setConnectionMap(int *); 
    431399 
    432400        // peak metering support 
    433401        virtual bool hasPeakMetering(); 
    434         virtual bool getPeakValues(double &) {return false;}; 
    435         virtual double getPeakValue(const int source, const int dest); 
    436         virtual Control::CrossbarRouter::PeakValues getPeakValues(); 
     402        virtual double getPeakValue(const std::string& dest); 
     403        virtual std::map<std::string, double> getPeakValues(); 
    437404 
    438405    private: 
    439406        EAP &m_eap; 
    440         // these contain the sources and destinations available for this 
    441         // router 
    442         SourceVector      m_sources; 
    443         DestinationVector m_destinations; 
     407        /** 
     408          @{ 
     409          @brief Name-Index pairs for the sources and destinations 
     410 
     411          The index is 'artificial' and is the block/channel combination used in the dice. 
     412          */ 
     413        std::map<std::string, int> m_sources; 
     414        std::map<std::string, int> m_destinations; 
     415        // @} 
    444416 
    445417        PeakSpace &m_peak; 
     
    528500      @brief Actually add the source 
    529501      */ 
    530     void addSource( const std::string name, enum eRouteSource srcid
    531             unsigned int base, unsigned int count ); 
     502    void addSource(const std::string name, unsigned int base, unsigned int count
     503                   enum eRouteSource srcid, unsigned int offset=0); 
    532504    /** 
    533505      @brief Actually add the destination 
    534506      */ 
    535     void addDestination( const std::string name, enum eRouteDestination destid
    536             unsigned int base, unsigned int count ); 
     507    void addDestination(const std::string name, unsigned int base, unsigned int count
     508                        enum eRouteDestination destid, unsigned int offset=0); 
    537509 
    538510private: 
  • trunk/libffado/src/dice/focusrite/saffire_pro24.cpp

    r1775 r1776  
    4545 
    4646void SaffirePro24::SaffirePro24EAP::setupSources() { 
    47     addSource("SPDIF",    eRS_AES,   6, 2); 
    48     addSource("ADAT",     eRS_ADAT,  0, 8); 
    49     addSource("INS0",     eRS_InS0,  0, 4); 
    50     addSource("MixerOut", eRS_Mixer, 0, 16); 
    51     addSource("1394",     eRS_ARX0,  0, 8); 
     47    addSource("SPDIF",  6, 2, eRS_AES); 
     48    addSource("ADAT",   0, 8, eRS_ADAT); 
     49    addSource("Analog", 0, 4, eRS_InS0); 
     50    addSource("Mixer",  0, 16, eRS_Mixer); 
     51    addSource("1394",   0, 8, eRS_ARX0); 
    5252} 
    5353void SaffirePro24::SaffirePro24EAP::setupDestinations() { 
    54     addDestination("SPDIF", eRD_AES, 6, 2); 
    55     addDestination("INS0", eRD_InS0, 0, 6); 
    56     addDestination("MixerIn", eRD_Mixer0, 0, 16); 
    57     addDestination("MixerIn", eRD_Mixer1, 16, 2); 
    58     addDestination("1394", eRD_ATX0, 0, 16); 
     54    addDestination("SPDIF", 6, 2, eRD_AES); 
     55    addDestination("Analog", 0, 6, eRD_InS0); 
     56    addDestination("Mixer",  0, 16, eRD_Mixer0); 
     57    addDestination("Mixer",  0, 2, eRD_Mixer1, 16); 
     58    addDestination("1394",   0, 16, eRD_ATX0); 
    5959} 
    6060 
  • trunk/libffado/src/libcontrol/CrossbarRouter.h

    r1655 r1776  
    2626 
    2727#include "debugmodule/debugmodule.h" 
     28#include "ffadotypes.h" 
    2829 
    2930#include "Element.h" 
     
    3132#include <vector> 
    3233#include <string> 
     34#include <map> 
    3335 
    3436namespace Control { 
     
    4749    virtual void show() = 0; 
    4850 
    49     typedef std::vector<std::string> NameVector; 
    50     typedef std::vector<std::string>::iterator NameVectorIterator; 
    51     typedef std::vector<int> IntVector; 
    52     typedef std::vector<int>::iterator IntVectorIterator; 
     51    virtual stringlist getSourceNames() = 0; 
     52    virtual stringlist getDestinationNames() = 0; 
    5353 
    54     struct PeakValue 
    55     { 
    56         int destination; 
    57         double peakvalue; 
    58     }; 
    59     typedef std::vector<PeakValue> PeakValues; 
     54    virtual std::string getSourceForDestination(const std::string& dstname) = 0; 
     55    virtual stringlist getDestinationsForSource(const std::string& srcname) = 0; 
    6056 
    61     struct Group 
    62     { 
    63         std::string name; 
    64         int nbchannels; 
    65     }; 
    66     typedef std::vector<Group> Groups; 
    67  
    68     virtual std::string getSourceName(const int) = 0; 
    69     virtual std::string getDestinationName(const int) = 0; 
    70     virtual int getSourceIndex(std::string) = 0; 
    71     virtual int getDestinationIndex(std::string) = 0; 
    72  
    73     virtual NameVector getSourceNames() = 0; 
    74     virtual NameVector getDestinationNames() = 0; 
    75  
    76     virtual Groups getSources() = 0; 
    77     virtual Groups getDestinations() = 0; 
    78  
    79     virtual IntVector getDestinationsForSource(const int) = 0; 
    80     virtual int getSourceForDestination(const int) = 0; 
    81  
    82     virtual bool canConnect(const int source, const int dest) = 0; 
    83     virtual bool setConnectionState(const int source, const int dest, const bool enable) = 0; 
    84     virtual bool getConnectionState(const int source, const int dest) = 0; 
    85  
    86     virtual bool canConnect(std::string, std::string) = 0; 
    87     virtual bool setConnectionState(std::string, std::string, const bool enable) = 0; 
    88     virtual bool getConnectionState(std::string, std::string) = 0; 
     57    virtual bool canConnect(const std::string& srcname, const std::string& dstname) = 0; 
     58    virtual bool setConnectionState(const std::string& srcname, const std::string& dstname, const bool enable) = 0; 
     59    virtual bool getConnectionState(const std::string& srcname, const std::string& dstname) = 0; 
    8960 
    9061    virtual bool clearAllConnections() = 0; 
    9162 
    92     virtual int getNbSources() = 0; 
    93     virtual int getNbDestinations() = 0; 
    94  
    95     // functions to access the entire routing map at once 
    96     // idea is that the row/col nodes that are 1 get a routing entry 
    97     virtual bool getConnectionMap(int *) = 0; 
    98     virtual bool setConnectionMap(int *) = 0; 
    99  
    10063    // peak metering 
    10164    virtual bool hasPeakMetering() = 0; 
    102     virtual double getPeakValue(const int source, const int dest) = 0; 
    103     virtual bool getPeakValues(double &) = 0; 
    104     virtual PeakValues getPeakValues() = 0; 
     65    virtual double getPeakValue(const std::string& dest) = 0; 
     66    virtual std::map<std::string, double> getPeakValues() = 0; 
    10567 
    10668protected: 
  • trunk/libffado/support/dbus/control-interface.xml

    r1742 r1776  
    240240 
    241241  <interface name="org.ffado.Control.Element.CrossbarRouter"> 
    242       <method name="getSourceName"> 
    243           <arg type="i" name="srcid" direction="in"/> 
    244           <arg type="s" name="sourcename" direction="out"/> 
    245       </method> 
    246       <method name="getDestinationName"> 
    247           <arg type="i" name="dstid" direction="in"/> 
    248           <arg type="s" name="destinationname" direction="out"/> 
    249       </method> 
    250       <method name="getSourceIndex"> 
    251           <arg type="s" name="sourcename" direction="in"/> 
    252           <arg type="i" name="srcid" direction="out"/> 
    253       </method> 
    254       <method name="getDestinationIndex"> 
    255           <arg type="s" name="destinationname" direction="in"/> 
    256           <arg type="i" name="dstid" direction="out"/> 
    257       </method> 
    258242      <method name="getSourceNames"> 
    259243          <arg type="as" name="sourcenames" direction="out"/> 
    260244      </method> 
    261       <method name="getSources"> 
    262           <arg type="a(si)" name="sources" direction="out"/> 
    263       </method> 
    264       <method name="getDestinations"> 
    265           <arg type="a(si)" name="sources" direction="out"/> 
    266       </method> 
    267245      <method name="getDestinationNames"> 
    268246          <arg type="as" name="destinationnames" direction="out"/> 
    269247      </method> 
     248      <method name="getSourceForDestination"> 
     249          <arg type="s" name="dstid" direction="in"/> 
     250          <arg type="s" name="srcid" direction="out"/> 
     251      </method> 
    270252      <method name="getDestinationsForSource"> 
    271           <arg type="i" name="srcid" direction="in"/> 
    272           <arg type="ai" name="dstids" direction="out"/> 
    273       </method> 
    274       <method name="getSourceForDestination"> 
    275           <arg type="i" name="dstid" direction="in"/> 
    276           <arg type="i" name="srcid" direction="out"/> 
     253          <arg type="s" name="srcid" direction="in"/> 
     254          <arg type="as" name="dstids" direction="out"/> 
    277255      </method> 
    278256      <method name="canConnect"> 
    279           <arg type="i" name="srcid" direction="in"/> 
    280           <arg type="i" name="dstid" direction="in"/> 
     257          <arg type="s" name="srcid" direction="in"/> 
     258          <arg type="s" name="dstid" direction="in"/> 
    281259          <arg type="b" name="canconnect" direction="out"/> 
    282260      </method> 
    283261      <method name="setConnectionState"> 
    284           <arg type="i" name="srcid" direction="in"/> 
    285           <arg type="i" name="dstid" direction="in"/> 
     262          <arg type="s" name="srcid" direction="in"/> 
     263          <arg type="s" name="dstid" direction="in"/> 
    286264          <arg type="b" name="state" direction="in"/> 
    287265          <arg type="b" name="result" direction="out"/> 
    288266      </method> 
    289267      <method name="getConnectionState"> 
    290           <arg type="i" name="srcid" direction="in"/> 
    291           <arg type="i" name="dstid" direction="in"/> 
    292           <arg type="b" name="state" direction="out"/> 
    293       </method> 
    294       <method name="canConnectNamed"> 
    295           <arg type="s" name="srcname" direction="in"/> 
    296           <arg type="s" name="dstname" direction="in"/> 
    297           <arg type="b" name="canconnect" direction="out"/> 
    298       </method> 
    299       <method name="setConnectionStateNamed"> 
    300           <arg type="s" name="srcname" direction="in"/> 
    301           <arg type="s" name="dstname" direction="in"/> 
    302           <arg type="b" name="state" direction="in"/> 
    303           <arg type="b" name="result" direction="out"/> 
    304       </method> 
    305       <method name="getConnectionStateNamed"> 
    306           <arg type="s" name="srcname" direction="in"/> 
    307           <arg type="s" name="dstname" direction="in"/> 
     268          <arg type="s" name="srcid" direction="in"/> 
     269          <arg type="s" name="dstid" direction="in"/> 
    308270          <arg type="b" name="state" direction="out"/> 
    309271      </method> 
     
    311273          <arg type="b" name="state" direction="out"/> 
    312274      </method> 
    313       <method name="getNbSources"> 
    314           <arg type="i" name="state" direction="out"/> 
    315       </method> 
    316       <method name="getNbDestinations"> 
    317           <arg type="i" name="state" direction="out"/> 
    318       </method> 
    319       <method name="getConnectionMap"> 
    320           <arg type="ai" name="map" direction="out"/> 
    321       </method> 
    322       <method name="setConnectionMap"> 
    323           <arg type="ai" name="map" direction="in"/> 
    324           <arg type="i" name="state" direction="out"/> 
    325       </method> 
    326275      <method name="hasPeakMetering"> 
    327276          <arg type="b" name="hasmetering" direction="out"/> 
    328277      </method> 
    329278      <method name="getPeakValue"> 
    330           <arg type="i" name="srcid" direction="in"/> 
    331           <arg type="i" name="dstid" direction="in"/> 
     279          <arg type="s" name="dstid" direction="in"/> 
    332280          <arg type="d" name="value" direction="out"/> 
    333281      </method> 
    334282      <method name="getPeakValues"> 
    335           <arg type="a(id)" name="values" direction="out"/> 
     283          <arg type="a(sd)" name="values" direction="out"/> 
    336284      </method> 
    337285  </interface> 
  • trunk/libffado/support/dbus/controlserver.cpp

    r1742 r1776  
    868868} 
    869869 
    870 DBus::String 
    871 CrossbarRouter::getSourceName(const DBus::Int32 &idx) 
    872 
    873     return m_Slave.getSourceName(idx); 
    874 
    875  
    876 DBus::String 
    877 CrossbarRouter::getDestinationName(const DBus::Int32 &idx) 
    878 
    879     return m_Slave.getDestinationName(idx); 
    880 
    881  
    882 DBus::Int32 
     870/*DBus::Int32 
    883871CrossbarRouter::getSourceIndex(const DBus::String &name) 
    884872{ 
     
    890878{ 
    891879    return m_Slave.getDestinationIndex(name); 
    892 } 
     880}*/ 
    893881 
    894882std::vector< DBus::String > 
     
    904892} 
    905893 
    906 std::vector< DBus::Struct<DBus::String, int> > 
    907 CrossbarRouter::getSources() 
    908 
    909     return std::vector< DBus::Struct<DBus::String, int> >(); 
    910 
    911  
    912 std::vector< DBus::Struct<DBus::String, int> > 
    913 CrossbarRouter::getDestinations() 
    914 
    915     return std::vector< DBus::Struct<DBus::String, int> >(); 
    916 
    917  
    918 std::vector< DBus::Int32 > 
    919 CrossbarRouter::getDestinationsForSource(const DBus::Int32 &idx) 
     894std::vector< DBus::String > 
     895CrossbarRouter::getDestinationsForSource(const DBus::String &idx) 
    920896{ 
    921897    return m_Slave.getDestinationsForSource(idx); 
    922898} 
    923899 
    924 DBus::Int32 
    925 CrossbarRouter::getSourceForDestination(const DBus::Int32 &idx) 
     900DBus::String 
     901CrossbarRouter::getSourceForDestination(const DBus::String &idx) 
    926902{ 
    927903    return m_Slave.getSourceForDestination(idx); 
     
    929905 
    930906DBus::Bool 
    931 CrossbarRouter::canConnect(const DBus::Int32 &source, const DBus::Int32 &dest) 
     907CrossbarRouter::canConnect(const DBus::String &source, const DBus::String &dest) 
    932908{ 
    933909    return m_Slave.canConnect(source, dest); 
     
    935911 
    936912DBus::Bool 
    937 CrossbarRouter::setConnectionState(const DBus::Int32 &source, const DBus::Int32 &dest, const DBus::Bool &enable) 
     913CrossbarRouter::setConnectionState(const DBus::String &source, const DBus::String &dest, const DBus::Bool &enable) 
    938914{ 
    939915    return m_Slave.setConnectionState(source, dest, enable); 
     
    941917 
    942918DBus::Bool 
    943 CrossbarRouter::getConnectionState(const DBus::Int32 &source, const DBus::Int32 &dest) 
     919CrossbarRouter::getConnectionState(const DBus::String &source, const DBus::String &dest) 
    944920{ 
    945921    return m_Slave.getConnectionState(source, dest); 
     
    947923 
    948924DBus::Bool 
    949 CrossbarRouter::canConnectNamed(const DBus::String& source, const DBus::String& dest) 
    950 { 
    951     return m_Slave.canConnect(source, dest); 
    952 } 
    953  
    954 DBus::Bool 
    955 CrossbarRouter::setConnectionStateNamed(const DBus::String &source, const DBus::String &dest, const DBus::Bool &enable) 
    956 { 
    957     return m_Slave.setConnectionState(source, dest, enable); 
    958 } 
    959  
    960 DBus::Bool 
    961 CrossbarRouter::getConnectionStateNamed(const DBus::String &source, const DBus::String &dest) 
    962 { 
    963     return m_Slave.getConnectionState(source, dest); 
    964 } 
    965  
    966 DBus::Bool 
    967925CrossbarRouter::clearAllConnections() 
    968926{ 
     
    970928} 
    971929 
    972 DBus::Int32 
    973 CrossbarRouter::getNbSources() 
    974 { 
    975     return m_Slave.getNbSources(); 
    976 } 
    977  
    978 DBus::Int32 
    979 CrossbarRouter::getNbDestinations() 
    980 { 
    981     return m_Slave.getNbDestinations(); 
    982 } 
    983  
    984930DBus::Bool 
    985931CrossbarRouter::hasPeakMetering() 
     
    989935 
    990936DBus::Double 
    991 CrossbarRouter::getPeakValue(const DBus::Int32 &source, const DBus::Int32 &dest) 
    992 { 
    993     return m_Slave.getPeakValue(source, dest); 
    994 } 
    995 std::vector< DBus::Struct<int, double> > 
     937CrossbarRouter::getPeakValue(const DBus::String &dest) 
     938{ 
     939    return m_Slave.getPeakValue(dest); 
     940} 
     941std::vector< DBus::Struct<DBus::String, double> > 
    996942CrossbarRouter::getPeakValues() 
    997943{ 
    998     //return std::vector< DBus::Struct<int, int, double> >(); 
    999     std::vector< DBus::Struct<int, double> > out; 
     944    return std::vector< DBus::Struct<DBus::String, double> >(); 
     945    /*std::vector< DBus::Struct<int, double> > out; 
    1000946    Control::CrossbarRouter::PeakValues values = m_Slave.getPeakValues(); 
    1001947    for ( unsigned int i=0; i<values.size(); ++i ) { 
     
    1005951        out.push_back(tmp); 
    1006952    } 
    1007     return out; 
    1008 
    1009  
    1010 std::vector< DBus::Int32 > 
    1011 CrossbarRouter::getConnectionMap() 
    1012 
    1013     std::vector< DBus::Int32 >connmap; 
    1014     unsigned int nb_sources = m_Slave.getNbSources(); 
    1015     unsigned int nb_destinations = m_Slave.getNbDestinations(); 
    1016     unsigned int nb_entries = nb_sources * nb_destinations; 
    1017  
    1018     int map_data[nb_entries]; 
    1019  
    1020     if(!m_Slave.getConnectionMap(map_data)) { 
    1021         debugError("Could not fetch connection map\n"); 
    1022         return connmap; 
    1023     } 
    1024  
    1025     for(unsigned int i=0; i<nb_entries; i++) { 
    1026         connmap.push_back(map_data[i]); 
    1027     } 
    1028     return connmap; 
    1029 
    1030  
    1031 DBus::Int32 
    1032 CrossbarRouter::setConnectionMap(const std::vector< DBus::Int32 >&connmap) 
    1033 
    1034     unsigned int nb_sources = m_Slave.getNbSources(); 
    1035     unsigned int nb_destinations = m_Slave.getNbDestinations(); 
    1036     unsigned int nb_entries = nb_sources * nb_destinations; 
    1037  
    1038     if(connmap.size() != nb_entries) { 
    1039         debugError("bogus map size\n"); 
    1040         return false; 
    1041     } 
    1042  
    1043     int map_data[nb_entries]; 
    1044     for (unsigned int i=0; i<nb_entries; i++) { 
    1045         map_data[i] = connmap.at(i); 
    1046     } 
    1047     return m_Slave.setConnectionMap(map_data); 
     953    return out;*/ 
    1048954} 
    1049955 
  • trunk/libffado/support/dbus/controlserver.h

    r1742 r1776  
    339339                  Control::CrossbarRouter &slave ); 
    340340 
    341     DBus::String getSourceName(const DBus::Int32 &); 
    342     DBus::String getDestinationName(const DBus::Int32 &); 
    343     DBus::Int32 getSourceIndex(const DBus::String &); 
    344     DBus::Int32 getDestinationIndex(const DBus::String &); 
    345  
    346341    std::vector< DBus::String > getSourceNames(); 
    347342    std::vector< DBus::String > getDestinationNames(); 
    348343 
    349     std::vector< DBus::Struct<DBus::String, int> > getSources(); 
    350     std::vector< DBus::Struct<DBus::String, int> > getDestinations(); 
    351  
    352     std::vector< DBus::Int32 > getDestinationsForSource(const DBus::Int32 &); 
    353     DBus::Int32 getSourceForDestination(const DBus::Int32 &); 
    354  
    355     DBus::Bool  canConnect(const DBus::Int32 &source, const DBus::Int32 &dest); 
    356     DBus::Bool  setConnectionState(const DBus::Int32 &source, const DBus::Int32 &dest, const DBus::Bool &enable); 
    357     DBus::Bool  getConnectionState(const DBus::Int32 &source, const DBus::Int32 &dest); 
    358  
    359     DBus::Bool  canConnectNamed(const DBus::String&, const DBus::String&); 
    360     DBus::Bool  setConnectionStateNamed(const DBus::String&, const DBus::String&, const DBus::Bool &enable); 
    361     DBus::Bool  getConnectionStateNamed(const DBus::String&, const DBus::String&); 
     344    std::vector< DBus::String > getDestinationsForSource(const DBus::String &); 
     345    DBus::String getSourceForDestination(const DBus::String &); 
     346 
     347    DBus::Bool  canConnect(const DBus::String &source, const DBus::String &dest); 
     348    DBus::Bool  setConnectionState(const DBus::String &source, const DBus::String &dest, const DBus::Bool &enable); 
     349    DBus::Bool  getConnectionState(const DBus::String &source, const DBus::String &dest); 
    362350 
    363351    DBus::Bool  clearAllConnections(); 
    364352 
    365     DBus::Int32 getNbSources(); 
    366     DBus::Int32 getNbDestinations(); 
    367  
    368353    DBus::Bool  hasPeakMetering(); 
    369     DBus::Double getPeakValue(const DBus::Int32 &source, const DBus::Int32 &dest); 
    370  
    371     std::vector< DBus::Struct<int, double> > getPeakValues(); 
    372  
    373     std::vector< DBus::Int32 > getConnectionMap(); 
    374     DBus::Int32 setConnectionMap(const std::vector< DBus::Int32 >&); 
     354    DBus::Double getPeakValue(const DBus::String &dest); 
     355    std::vector< DBus::Struct<DBus::String, double> > getPeakValues(); 
    375356 
    376357private: 
  • trunk/libffado/support/mixer-qt4/ffado/widgets/crossbarrouter.py

    r1739 r1776  
    8080        self.layout.addWidget(self.lbl, 0, 0) 
    8181 
    82         self.vu = VuMeter(self.interface, self.interface.getDestinationIndex(outname), parent=self) 
    83         self.layout.addWidget(self.vu, 0, 1) 
     82        #self.vu = VuMeter(self.interface, self.interface.getDestinationIndex(outname), parent=self) 
     83        #self.layout.addWidget(self.vu, 0, 1) 
    8484 
    8585        sources = self.interface.getSourceNames() 
     
    8989        self.combo.addItem("Disconnected") 
    9090        self.combo.addItems(sources) 
    91         idx = self.interface.getDestinationIndex(self.outname) 
    92         sourceidx = self.interface.getSourceForDestination(idx) 
    93         if sourceidx > -1: 
    94             source = self.interface.getSourceName(sourceidx) 
    95             self.combo.setCurrentIndex(sources.index(source)+1
     91        src = self.interface.getSourceForDestination(self.outname) 
     92        if src != "": 
     93            self.combo.setCurrentIndex(self.combo.findText(src)) 
     94        else: 
     95            self.combo.setCurrentIndex(0
    9696        self.connect(self.combo, QtCore.SIGNAL("activated(QString)"), self.comboCurrentChanged) 
    9797 
    9898 
    9999    def peakValue(self, value): 
    100         self.vu.updateLevel(value) 
     100        #self.vu.updateLevel(value) 
     101        pass 
    101102 
    102103    def comboCurrentChanged(self, inname): 
     
    105106            return 
    106107        if self.lastin != "": 
    107             self.interface.setConnectionStateNamed(self.lastin, self.outname, False) 
     108            self.interface.setConnectionState(self.lastin, self.outname, False) 
    108109 
    109110        if inname != "Disconnected": 
    110             if self.interface.setConnectionStateNamed(str(inname), self.outname, True): 
     111            if self.interface.setConnectionState(str(inname), self.outname, True): 
    111112                self.lastin = str(inname) 
    112113            else: 
     
    124125 
    125126        self.settings = QtCore.QSettings(self) 
    126  
    127         log.info(self.interface.getDestinations()) 
    128127 
    129128        destinations = self.interface.getDestinationNames() 
     
    152151            btn = OutputSwitcher(self.interface, out, self) 
    153152            self.layout.addWidget(btn, int(out.split(":")[-1]) + 1, self.outgroups.index(out.split(":")[0])) 
    154             self.switchers[self.interface.getDestinationIndex(out)] = btn 
     153            self.switchers[out] = btn 
    155154 
    156155        self.timer = QtCore.QTimer(self) 
  • trunk/libffado/tests/test-dice-eap.cpp

    r1773 r1776  
    295295//                     } 
    296296//                 } 
    297                 #define NELEMS 10 
    298                 double peaks[NELEMS]; 
    299                 int srcids[NELEMS]; 
    300                 int dstidx = c->getDestinationIndex("MixerIn:00"); 
    301                 for(int i=0; i<NELEMS; i++) { 
    302                     srcids[i] = c->getSourceForDestination(dstidx + i); 
    303                     peaks[i] = c->getPeakValue(srcids[i], dstidx + i); 
    304                 } 
    305                 for(int i=0; i<NELEMS; i++) { 
    306                     std::string srcname = c->getSourceName(srcids[i]); 
    307                     std::string dstname = c->getDestinationName(dstidx + i); 
    308                     printMessage("Peak %3d (%10s => %10s): %f\n", i, srcname.c_str(), dstname.c_str(), peaks[i]); 
    309                 } 
     297//                #define NELEMS 10 
     298//                double peaks[NELEMS]; 
     299//                int srcids[NELEMS]; 
     300//                int dstidx = c->getDestinationIndex("MixerIn:00"); 
     301//                for(int i=0; i<NELEMS; i++) { 
     302//                    srcids[i] = c->getSourceForDestination(dstidx + i); 
     303//                    peaks[i] = c->getPeakValue(srcids[i], dstidx + i); 
     304//                } 
     305//                for(int i=0; i<NELEMS; i++) { 
     306//                    std::string srcname = c->getSourceName(srcids[i]); 
     307//                    std::string dstname = c->getDestinationName(dstidx + i); 
     308//                    printMessage("Peak %3d (%10s => %10s): %f\n", i, srcname.c_str(), dstname.c_str(), peaks[i]); 
     309//                } 
    310310            } 
    311311        }