Changeset 1545
- Timestamp:
- 04/26/09 08:21:42 (14 years ago)
- Files:
-
- branches/libffado-2.0/src/devicemanager.cpp (modified) (1 diff)
- branches/libffado-2.0/src/DeviceStringParser.cpp (modified) (5 diffs)
- branches/libffado-2.0/src/DeviceStringParser.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libffado-2.0/src/devicemanager.cpp
r1524 r1545 644 644 // a device id always corresponds to the same device 645 645 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(); 646 662 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; 647 681 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 648 682 it != m_avDevices.end(); branches/libffado-2.0/src/DeviceStringParser.cpp
r1147 r1545 160 160 DeviceStringParser::DeviceString::match(ConfigRom& configRom) 161 161 { 162 debugOutput(DEBUG_LEVEL_VERBOSE, "match %p \n", &configRom);162 debugOutput(DEBUG_LEVEL_VERBOSE, "match %p (%s)\n", &configRom, configRom.getGuidString().c_str()); 163 163 bool match; 164 164 switch(m_Type) { … … 172 172 match &= ((configRom.getNodeId() & 0x3F) == m_node); 173 173 } 174 if(match) { 175 debugOutput(DEBUG_LEVEL_VERBOSE, "(eBusNode) device matches device string %s\n", m_String.c_str()); 176 } 174 177 return match; 175 178 case eGUID: 176 179 //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; 178 185 case eInvalid: 179 186 default: 180 debug Output(DEBUG_LEVEL_VERBOSE, "no match %p\n", &configRom);187 debugError("invalid DeviceString type (%d)\n", m_Type); 181 188 return false; 182 189 } … … 282 289 DeviceStringParser::match(ConfigRom& c) 283 290 { 291 return matchPosition(c) != -1; 292 } 293 294 int 295 DeviceStringParser::matchPosition(ConfigRom& c) 296 { 297 int pos = 0; 284 298 for ( DeviceStringVectorIterator it = m_DeviceStrings.begin(); 285 299 it != m_DeviceStrings.end(); … … 287 301 { 288 302 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 294 310 bool 295 311 DeviceStringParser::addDeviceString(DeviceString *o) … … 370 386 } 371 387 372 373 388 void 374 389 DeviceStringParser::show() branches/libffado-2.0/src/DeviceStringParser.h
r942 r1545 74 74 75 75 bool match(ConfigRom &); 76 int matchPosition(ConfigRom& c); 76 77 77 78 bool parseString(std::string s);