Changeset 1408

Show
Ignore:
Timestamp:
11/02/08 01:36:00 (12 years ago)
Author:
ppalmers
Message:

fix up sync source selection through sync plugs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0/src/libavc/general/avc_plug.cpp

    r1288 r1408  
    267267Plug::discoverPlugType() 
    268268{ 
    269  
    270269    return true; 
    271270} 
     
    541540    debugOutput( DEBUG_LEVEL_VERBOSE, "Discovering incoming connections...\n"); 
    542541 
     542    m_inputConnections.clear(); 
    543543    int sourcePlugGlobalId=getSignalSource(); 
    544544 
     
    19901990PlugManager::tidyPlugConnections(PlugConnectionVector& connections) 
    19911991{ 
     1992    connections.clear(); 
    19921993    for ( PlugVector::const_iterator it = m_plugs.begin(); 
    19931994          it !=  m_plugs.end(); 
  • branches/libffado-2.0/src/libavc/general/avc_unit.cpp

    r1292 r1408  
    4848Unit::Unit( ) 
    4949    : m_pPlugManager( new PlugManager( ) ) 
    50     , m_activeSyncInfo( 0 ) 
    5150{ 
    5251    debugOutput( DEBUG_LEVEL_VERBOSE, "Created Unit\n" ); 
     
    163162    m_syncInfos.clear(); 
    164163 
    165     m_activeSyncInfo = NULL; 
    166  
    167164    return true; 
    168165} 
     
    171168Unit::discover() 
    172169{ 
    173  
     170    debugOutput( DEBUG_LEVEL_VERBOSE, "Discovering AVC::Unit...\n"); 
    174171    if( !clean() ) { 
    175172        debugError( "Could not clean unit data structures\n" ); 
     
    187184    } 
    188185 
     186    if ( !rediscoverConnections() ) { 
     187        debugError( "Detecting connections failed\n" ); 
     188        return false; 
     189    } 
     190 
     191    if ( !discoverSyncModes() ) { 
     192        debugError( "Detecting sync modes failed\n" ); 
     193        return false; 
     194    } 
     195 
     196    if ( !propagatePlugInfo() ) { 
     197        debugError( "Failed to propagate plug info\n" ); 
     198        return false; 
     199    } 
     200 
     201    return true; 
     202} 
     203 
     204bool 
     205Unit::rediscoverConnections() { 
     206    debugOutput( DEBUG_LEVEL_VERBOSE, "Re-discovering plug connections...\n"); 
     207 
     208    // clear the previous connections 
     209    for ( PlugConnectionVector::iterator it = m_plugConnections.begin(); 
     210          it != m_plugConnections.end(); 
     211          ++it ) 
     212    { 
     213        delete *it; 
     214    } 
     215    m_plugConnections.clear(); 
     216 
    189217    if ( !discoverPlugConnections() ) { 
    190218        debugError( "Detecting plug connections failed\n" ); 
     
    201229        return false; 
    202230    } 
    203  
    204     if ( !discoverSyncModes() ) { 
    205         debugError( "Detecting sync modes failed\n" ); 
    206         return false; 
    207     } 
    208  
    209     if ( !propagatePlugInfo() ) { 
    210         debugError( "Failed to propagate plug info\n" ); 
    211         return false; 
    212     } 
    213  
    214231    return true; 
    215232} 
     
    717734    showPlugs( syncMSUOutputPlugs ); 
    718735 
     736    m_syncInfos.clear(); 
    719737    // Currently there is no usable setup for sync streams. 
    720738    // There is no point in wasting time here. Let's skip 
     
    745763                                      "Digital Input Sync" ); 
    746764 
    747     return updateActiveSyncInfo(); 
    748 
    749  
    750 bool 
    751 Unit::updateActiveSyncInfo() 
    752 
     765    return true; 
     766
     767 
     768const Unit::SyncInfo* 
     769Unit::getActiveSyncInfo() 
     770
     771    SyncInfo* activeSyncInfo = NULL; 
    753772    PlugVector syncMSUInputPlugs = m_pPlugManager->getPlugsByType( 
    754773        eST_Music, 
     
    785804                     && ( pSyncInfo->m_destination == msuPlug ) ) 
    786805                { 
    787                     m_activeSyncInfo = pSyncInfo; 
     806                    activeSyncInfo = pSyncInfo; 
    788807                    break; 
    789808                } 
    790809            } 
    791             if(m_activeSyncInfo) { 
     810            if(activeSyncInfo) { 
    792811                debugOutput( DEBUG_LEVEL_NORMAL, 
    793812                            "Active Sync Connection: %s, '%s' -> '%s'\n", 
    794                             m_activeSyncInfo->m_description.c_str(), 
     813                            activeSyncInfo->m_description.c_str(), 
    795814                            plug->getName(), 
    796815                            msuPlug->getName() ); 
     
    798817        } 
    799818    } 
    800     return true
     819    return activeSyncInfo
    801820} 
    802821 
     
    831850bool Unit::setActiveSync(const SyncInfo& syncInfo) 
    832851{ 
    833     bool result = true; 
     852    bool retval = true; 
     853 
     854    if ( ! syncInfo.m_source->inquireConnnection( *syncInfo.m_destination ) ) { 
     855        // this should not happen 
     856        debugError("Sync connection '%s' -> '%s' not possible. This might be a bug.\n", 
     857                   syncInfo.m_source->getName(), syncInfo.m_destination->getName()); 
     858    } 
    834859 
    835860    if(!syncInfo.m_source->setConnection( *syncInfo.m_destination )) { 
    836         debugWarning("Could not set sync source connection.\n"); 
    837     } 
    838  
    839     result &= updateActiveSyncInfo(); 
    840     return result; 
     861        debugError("Could not set sync source connection while device reported it as possible.\n"); 
     862        retval = false; // proceed to rediscovery anyway 
     863    } 
     864 
     865    // we now have to rediscover the connections 
     866    if ( !rediscoverConnections() ) { 
     867        debugError( "Re-discovery of plug connections failed\n" ); 
     868        return false; 
     869    } 
     870    return retval; 
    841871} 
    842872 
     
    9851015    result &= serializeSyncInfoVector( basePath + "SyncInfo", ser, m_syncInfos ); 
    9861016 
    987     int i = 0; 
    988     for ( SyncInfoVector::const_iterator it = m_syncInfos.begin(); 
    989           it != m_syncInfos.end(); 
    990           ++it ) 
    991     { 
    992         const SyncInfo& info = *it; 
    993         if ( m_activeSyncInfo == &info ) { 
    994             result &= ser.write( basePath + "m_activeSyncInfo",  i ); 
    995             break; 
    996         } 
    997         i++; 
    998     } 
    999  
    10001017    return result; 
    10011018} 
     
    10421059    m_pPlugManager->deserializeUpdate( basePath, deser ); 
    10431060 
    1044     if ( deser.isExisting(basePath + "m_activeSyncInfo" ) ) { 
    1045         // the sync info doesn't have to be there. 
    1046  
    1047         unsigned int i; 
    1048         result &= deser.read( basePath + "m_activeSyncInfo", i ); 
    1049         if ( i < m_syncInfos.size() ) { 
    1050             m_activeSyncInfo = &m_syncInfos[i]; 
    1051             // but if it is we want it selected 
    1052             result &= setActiveSync(*m_activeSyncInfo); 
    1053         } 
    1054     } 
     1061    // this might have changed since the cache was saved 
     1062    // if the config ID doesn't account for the clock source 
     1063    if(!rediscoverConnections()) { 
     1064        debugError("Could not rediscover plug connections\n"); 
     1065    } 
     1066 
    10551067    return result; 
    10561068} 
  • branches/libffado-2.0/src/libavc/general/avc_unit.h

    r1371 r1408  
    8888    virtual const SyncInfoVector& getSyncInfos() const 
    8989        { return m_syncInfos; } 
    90     virtual const SyncInfo* getActiveSyncInfo() const 
    91         { return m_activeSyncInfo; } 
     90    virtual const SyncInfo* getActiveSyncInfo(); 
    9291 
    9392    virtual bool setActiveSync( const SyncInfo& syncInfo ); 
     
    122121 
    123122    virtual bool enumerateSubUnits(); 
     123    virtual bool rediscoverConnections(); 
    124124    virtual bool discoverPlugConnections(); 
    125125    virtual bool discoverSubUnitsPlugConnections(); 
     
    131131    virtual bool propagatePlugInfo(); 
    132132    virtual bool discoverSyncModes(); 
    133     virtual bool updateActiveSyncInfo(); 
    134133    virtual bool checkSyncConnectionsAndAddToList( AVC::PlugVector& plhs, 
    135134                                           AVC::PlugVector& prhs, 
     
    167166    PlugManager*              m_pPlugManager; 
    168167    SyncInfoVector            m_syncInfos; 
    169     SyncInfo*                 m_activeSyncInfo; 
    170168 
    171169private: