Changeset 1545

Show
Ignore:
Timestamp:
04/26/09 08:21:42 (14 years ago)
Author:
ppalmers
Message:

fixes #201

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0/src/devicemanager.cpp

    r1524 r1545  
    644644        // a device id always corresponds to the same device 
    645645        sort(m_avDevices.begin(), m_avDevices.end(), FFADODevice::compareGUID); 
     646 
     647        // first map the devices to a position using the device spec strings 
     648        std::map<fb_octlet_t, int> positionMap; 
     649        for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
     650            it != m_avDevices.end(); 
     651            ++it ) 
     652        { 
     653            int pos = m_deviceStringParser->matchPosition((*it)->getConfigRom()); 
     654            fb_octlet_t guid = (*it)->getConfigRom().getGuid(); 
     655            positionMap[guid] = pos; 
     656            debugOutput( DEBUG_LEVEL_VERBOSE, "Mapping %s to position %d...\n", (*it)->getConfigRom().getGuidString().c_str(), pos ); 
     657        } 
     658 
     659        // now run over all positions, and add the devices that belong to it 
     660        FFADODeviceVector sorted; 
     661        int nbPositions = m_deviceStringParser->countDeviceStrings(); 
    646662        int i=0; 
     663        for (i=0; i < nbPositions; i++) { 
     664            for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
     665                it != m_avDevices.end(); 
     666                ++it ) 
     667            { 
     668                fb_octlet_t guid = (*it)->getConfigRom().getGuid(); 
     669                if(positionMap[guid] == i) { 
     670                    sorted.push_back(*it); 
     671                } 
     672            } 
     673        } 
     674 
     675        // assign the new vector 
     676        assert(sorted.size() == m_avDevices.size()); 
     677        m_avDevices = sorted; 
     678 
     679        // set device id's 
     680        i = 0; 
    647681        for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
    648682            it != m_avDevices.end(); 
  • branches/libffado-2.0/src/DeviceStringParser.cpp

    r1147 r1545  
    160160DeviceStringParser::DeviceString::match(ConfigRom& configRom) 
    161161{ 
    162     debugOutput(DEBUG_LEVEL_VERBOSE, "match %p\n", &configRom); 
     162    debugOutput(DEBUG_LEVEL_VERBOSE, "match %p (%s)\n", &configRom, configRom.getGuidString().c_str()); 
    163163    bool match; 
    164164    switch(m_Type) { 
     
    172172                match &= ((configRom.getNodeId() & 0x3F) == m_node); 
    173173            } 
     174            if(match) { 
     175                debugOutput(DEBUG_LEVEL_VERBOSE, "(eBusNode) device matches device string %s\n", m_String.c_str()); 
     176            } 
    174177            return match; 
    175178        case eGUID: 
    176179            //GUID should not be 0 
    177             return m_guid && (m_guid == configRom.getGuid()); 
     180            match = m_guid && (m_guid == configRom.getGuid()); 
     181            if(match) { 
     182                debugOutput(DEBUG_LEVEL_VERBOSE, "(eGUID) device matches device string %s\n", m_String.c_str()); 
     183            } 
     184            return match; 
    178185        case eInvalid: 
    179186        default: 
    180             debugOutput(DEBUG_LEVEL_VERBOSE, "no match %p\n", &configRom); 
     187            debugError("invalid DeviceString type (%d)\n", m_Type); 
    181188            return false; 
    182189    } 
     
    282289DeviceStringParser::match(ConfigRom& c) 
    283290{ 
     291    return matchPosition(c) != -1; 
     292} 
     293 
     294int 
     295DeviceStringParser::matchPosition(ConfigRom& c) 
     296{ 
     297    int pos = 0; 
    284298    for ( DeviceStringVectorIterator it = m_DeviceStrings.begin(); 
    285299      it != m_DeviceStrings.end(); 
     
    287301    { 
    288302        if((*it)->match(c)) { 
    289             return true; 
    290         } 
    291     } 
    292     return false; 
    293 
     303            return pos; 
     304        } 
     305        pos++; 
     306    } 
     307    return -1; 
     308
     309 
    294310bool 
    295311DeviceStringParser::addDeviceString(DeviceString *o) 
     
    370386} 
    371387 
    372  
    373388void 
    374389DeviceStringParser::show() 
  • branches/libffado-2.0/src/DeviceStringParser.h

    r942 r1545  
    7474 
    7575    bool match(ConfigRom &); 
     76    int matchPosition(ConfigRom& c); 
    7677 
    7778    bool parseString(std::string s);