Show
Ignore:
Timestamp:
11/01/07 14:27:55 (16 years ago)
Author:
ppalmers
Message:

Fix bug where the internal data structures of the AVC::Unit were not cleared before discovery. This
prevented devices from being re-discovered since all old structures remained (e.g. all of a sudden
there are 2 music subunits)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/libavc/general/avc_unit.cpp

    r637 r678  
    5656Unit::~Unit() 
    5757{ 
    58     for ( SubunitVector::iterator it = m_subunits.begin(); 
    59           it != m_subunits.end(); 
    60           ++it ) 
    61     { 
    62         delete *it; 
    63     } 
    64     for ( PlugConnectionVector::iterator it = m_plugConnections.begin(); 
    65           it != m_plugConnections.end(); 
    66           ++it ) 
    67     { 
    68         delete *it; 
    69     } 
    70     for ( PlugVector::iterator it = m_pcrPlugs.begin(); 
    71           it != m_pcrPlugs.end(); 
    72           ++it ) 
    73     { 
    74         delete *it; 
    75     } 
    76     for ( PlugVector::iterator it = m_externalPlugs.begin(); 
    77           it != m_externalPlugs.end(); 
    78           ++it ) 
    79     { 
    80         delete *it; 
    81     } 
     58    clean(); 
    8259} 
    8360 
     
    139116} 
    140117 
     118// prepare the device for a rediscovery 
     119bool 
     120Unit::clean() 
     121{ 
     122    for ( SubunitVector::iterator it = m_subunits.begin(); 
     123          it != m_subunits.end(); 
     124          ++it ) 
     125    { 
     126        delete *it; 
     127    } 
     128    m_subunits.clear(); 
     129 
     130    for ( PlugVector::iterator it = m_pcrPlugs.begin(); 
     131          it != m_pcrPlugs.end(); 
     132          ++it ) 
     133    { 
     134        delete *it; 
     135    } 
     136    m_pcrPlugs.clear(); 
     137 
     138    for ( PlugVector::iterator it = m_externalPlugs.begin(); 
     139          it != m_externalPlugs.end(); 
     140          ++it ) 
     141    { 
     142        delete *it; 
     143    } 
     144    m_externalPlugs.clear(); 
     145 
     146    for ( PlugConnectionVector::iterator it = m_plugConnections.begin(); 
     147          it != m_plugConnections.end(); 
     148          ++it ) 
     149    { 
     150        delete *it; 
     151    } 
     152    m_plugConnections.clear(); 
     153 
     154    delete m_pPlugManager; 
     155    m_pPlugManager = new PlugManager(); 
     156 
     157    if (m_pPlugManager == NULL) { 
     158        debugError("Could not create new plugmanager"); 
     159        return false; 
     160    } 
     161 
     162    m_syncInfos.clear(); 
     163 
     164    m_activeSyncInfo = NULL; 
     165 
     166    return true; 
     167} 
     168 
    141169bool 
    142170Unit::discover() 
    143171{ 
     172 
     173    if( !clean() ) { 
     174        debugError( "Could not clean unit data structures\n" ); 
     175        return false; 
     176    } 
    144177 
    145178    if ( !enumerateSubUnits() ) { 
  • trunk/libffado/src/libavc/general/avc_unit.h

    r630 r678  
    117117 
    118118protected: 
     119    /// cleans the internal data structures that are created by discovery 
     120    virtual bool clean(); 
    119121 
    120122    virtual bool enumerateSubUnits();