Changeset 1549

Show
Ignore:
Timestamp:
05/09/09 10:42:57 (14 years ago)
Author:
ppalmers
Message:

fixes #221, #219

Files:

Legend:

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

    r1545 r1549  
    645645        sort(m_avDevices.begin(), m_avDevices.end(), FFADODevice::compareGUID); 
    646646 
    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(); 
    662647        int i=0; 
    663         for (i=0; i < nbPositions; i++) { 
     648        if(m_deviceStringParser->countDeviceStrings()) { // only if there are devicestrings 
     649            // first map the devices to a position using the device spec strings 
     650            std::map<fb_octlet_t, int> positionMap; 
    664651            for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
    665652                it != m_avDevices.end(); 
    666653                ++it ) 
    667654            { 
     655                int pos = m_deviceStringParser->matchPosition((*it)->getConfigRom()); 
    668656                fb_octlet_t guid = (*it)->getConfigRom().getGuid(); 
    669                 if(positionMap[guid] == i) { 
    670                     sorted.push_back(*it); 
     657                positionMap[guid] = pos; 
     658                debugOutput( DEBUG_LEVEL_VERBOSE, "Mapping %s to position %d...\n", (*it)->getConfigRom().getGuidString().c_str(), pos ); 
     659            } 
     660     
     661            // now run over all positions, and add the devices that belong to it 
     662            FFADODeviceVector sorted; 
     663            int nbPositions = m_deviceStringParser->countDeviceStrings(); 
     664            for (i=0; i < nbPositions; i++) { 
     665                for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
     666                    it != m_avDevices.end(); 
     667                    ++it ) 
     668                { 
     669                    fb_octlet_t guid = (*it)->getConfigRom().getGuid(); 
     670                    if(positionMap[guid] == i) { 
     671                        sorted.push_back(*it); 
     672                    } 
    671673                } 
    672674            } 
    673         } 
    674  
    675         // assign the new vector 
    676         assert(sorted.size() == m_avDevices.size())
    677         m_avDevices = sorted; 
     675            // assign the new vector 
     676            flushDebugOutput(); 
     677            assert(sorted.size() == m_avDevices.size()); 
     678            m_avDevices = sorted
     679        } 
    678680 
    679681        // set device id's