Show
Ignore:
Timestamp:
11/28/07 05:03:31 (16 years ago)
Author:
ppalmers
Message:

merge ppalmers-streaming branch

Files:

Legend:

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

    r716 r734  
    15761576} 
    15771577 
     1578 
     1579bool 
     1580Plug::serializePlugVector( Glib::ustring basePath, 
     1581                           Util::IOSerialize& ser, 
     1582                           const PlugVector& vec) const 
     1583{ 
     1584    bool result = true; 
     1585    int i = 0; 
     1586    for ( PlugVector::const_iterator it = vec.begin(); 
     1587          it != vec.end(); 
     1588          ++it ) 
     1589    { 
     1590        const Plug* pPlug = *it; 
     1591        std::ostringstream strstrm; 
     1592        strstrm << basePath << i; 
     1593 
     1594        result &= ser.write( strstrm.str() + "/global_id", pPlug->getGlobalId() ); 
     1595        i++; 
     1596    } 
     1597    return result; 
     1598} 
     1599 
     1600bool 
     1601Plug::deserializePlugVector( Glib::ustring basePath, 
     1602                             Util::IODeserialize& deser, 
     1603                             PlugVector& vec ) 
     1604{ 
     1605    int i = 0; 
     1606    bool bFinished = false; 
     1607    bool result = true; 
     1608    do { 
     1609        std::ostringstream strstrm; 
     1610        strstrm << basePath << i; 
     1611 
     1612        // check for one element to exist. when one exist the other elements 
     1613        // must also be there. otherwise just return (last) result. 
     1614        if ( deser.isExisting( strstrm.str() + "/global_id" ) ) { 
     1615            unsigned int iPlugId; 
     1616            result &= deser.read( strstrm.str() + "/global_id", iPlugId ); 
     1617 
     1618            if ( result ) { 
     1619                Plug* pPlug = m_unit->getPlugManager().getPlug( iPlugId ); 
     1620                if ( pPlug ) { 
     1621                    vec.push_back( pPlug ); 
     1622                } else { 
     1623                    result = false; 
     1624                    bFinished = true; 
     1625                } 
     1626                i++; 
     1627            } else { 
     1628                bFinished = true; 
     1629            } 
     1630        } else { 
     1631            bFinished = true; 
     1632        } 
     1633    } while ( !bFinished ); 
     1634 
     1635    return result; 
     1636} 
     1637 
    15781638bool 
    15791639Plug::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 
     
    16231683    bool result=true; 
    16241684 
    1625     result  = deser.read( basePath + "m_subunitType", pPlug->m_subunitType ); 
    1626     result &= deser.read( basePath + "m_subunitId", pPlug->m_subunitId ); 
     1685    ESubunitType subunitType; 
     1686    result  = deser.read( basePath + "m_subunitType", subunitType ); 
     1687    subunit_t subunitId; 
     1688    result &= deser.read( basePath + "m_subunitId", subunitId ); 
     1689    pPlug->m_subunit = unit.getSubunit( subunitType, subunitType ); 
     1690 
    16271691    result &= deser.read( basePath + "m_functionBlockType", pPlug->m_functionBlockType ); 
    16281692    result &= deser.read( basePath + "m_functionBlockId", pPlug->m_functionBlockId ); 
     
    16541718bool 
    16551719Plug::deserializeUpdate( Glib::ustring basePath, 
    1656                          Util::IODeserialize& deser ) 
     1720                           Util::IODeserialize& deser ) 
    16571721{ 
    16581722    bool result; 
    16591723 
    1660     result  = deserializePlugVector( basePath + "m_inputConnections", deser, 
    1661                                      m_unit->getPlugManager(), m_inputConnections ); 
    1662     result &= deserializePlugVector( basePath + "m_outputConnections", deser, 
    1663                                      m_unit->getPlugManager(), m_outputConnections ); 
     1724    result  = deserializePlugVector( basePath + "m_inputConnections", deser, m_inputConnections ); 
     1725    result &= deserializePlugVector( basePath + "m_outputConnections", deser, m_outputConnections ); 
    16641726 
    16651727    return result; 
    1666 } 
    1667  
    1668 bool 
    1669 Plug::deserializeUpdateSubunit() 
    1670 { 
    1671     m_subunit = m_unit->getSubunit( m_subunitType, m_subunitId ); 
    1672     return true; 
    16731728} 
    16741729 
     
    21502205} 
    21512206 
    2152 bool 
    2153 PlugManager::deserializeUpdate() 
    2154 { 
    2155     bool result = true; 
    2156  
    2157     for ( PlugVector::const_iterator it = m_plugs.begin(); 
    2158           it !=  m_plugs.end(); 
    2159           ++it ) 
    2160     { 
    2161         Plug* pPlug = *it; 
    2162  
    2163         result &= pPlug->deserializeUpdateSubunit(); 
    2164     } 
    2165  
    2166     return result; 
    2167 } 
    21682207 
    21692208//////////////////////////////////// 
     
    23002339} 
    23012340 
    2302 bool 
    2303 serializePlugVector( Glib::ustring basePath, 
    2304                      Util::IOSerialize& ser, 
    2305                      const PlugVector& vec) 
    2306 
    2307     bool result = true; 
    2308     int i = 0; 
    2309     for ( PlugVector::const_iterator it = vec.begin(); 
    2310           it != vec.end(); 
    2311           ++it ) 
    2312     { 
    2313         const Plug* pPlug = *it; 
    2314         std::ostringstream strstrm; 
    2315         strstrm << basePath << i; 
    2316  
    2317         result &= ser.write( strstrm.str() + "/global_id", pPlug->getGlobalId() ); 
    2318         i++; 
    2319     } 
    2320     return result; 
    2321 
    2322  
    2323 bool 
    2324 deserializePlugVector( Glib::ustring basePath, 
    2325                        Util::IODeserialize& deser, 
    2326                        const PlugManager& plugManager, 
    2327                        PlugVector& vec ) 
    2328 
    2329     int i = 0; 
    2330     bool bFinished = false; 
    2331     bool result = true; 
    2332     do { 
    2333         std::ostringstream strstrm; 
    2334         strstrm << basePath << i; 
    2335  
    2336         // check for one element to exist. when one exist the other elements 
    2337         // must also be there. otherwise just return (last) result. 
    2338         if ( deser.isExisting( strstrm.str() + "/global_id" ) ) { 
    2339             unsigned int iPlugId; 
    2340             result &= deser.read( strstrm.str() + "/global_id", iPlugId ); 
    2341  
    2342             if ( result ) { 
    2343                 Plug* pPlug = plugManager.getPlug( iPlugId ); 
    2344                 if ( pPlug ) { 
    2345                     vec.push_back( pPlug ); 
    2346                 } else { 
    2347                     result = false; 
    2348                     bFinished = true; 
    2349                 } 
    2350                 i++; 
    2351             } else { 
    2352                 bFinished = true; 
    2353             } 
    2354         } else { 
    2355             bFinished = true; 
    2356         } 
    2357     } while ( !bFinished ); 
    2358  
    2359     return result; 
    2360 
    2361  
    2362 
     2341
  • trunk/libffado/src/libavc/general/avc_plug.h

    r716 r734  
    163163    bool deserializeUpdate( Glib::ustring basePath, 
    164164                            Util::IODeserialize& deser ); 
    165     bool deserializeUpdateSubunit(); 
    166165 
    167166 public: 
     
    257256    bool deserializeFormatInfos( Glib::ustring basePath, 
    258257                                 Util::IODeserialize& deser ); 
     258 
     259    bool serializePlugVector( Glib::ustring basePath, 
     260                              Util::IOSerialize& ser, 
     261                              const PlugVector& vec) const; 
     262    bool deserializePlugVector( Glib::ustring basePath, 
     263                                Util::IODeserialize& deser, 
     264                                PlugVector& vec ); 
    259265 
    260266protected: 
     
    279285    Unit*                       m_unit; 
    280286    Subunit*                    m_subunit; 
    281     ESubunitType                m_subunitType; 
    282     subunit_t                   m_subunitId; 
    283287    function_block_type_t       m_functionBlockType; 
    284288    function_block_id_t         m_functionBlockId; 
     
    345349    bool tidyPlugConnections(PlugConnectionVector&); 
    346350 
    347     bool deserializeUpdate(); 
    348  
    349351private: 
    350352 
     
    377379typedef std::vector<PlugConnection> PlugConnectionOwnerVector; 
    378380 
    379  
    380 bool serializePlugVector( Glib::ustring basePath, 
    381                           Util::IOSerialize& ser, 
    382                           const PlugVector& vec); 
    383  
    384 bool deserializePlugVector( Glib::ustring basePath, 
    385                             Util::IODeserialize& deser, 
    386                             const PlugManager& plugManager, 
    387                             PlugVector& vec ); 
    388  
    389381} 
    390382 
  • trunk/libffado/src/libavc/general/avc_subunit.cpp

    r716 r734  
    107107{ 
    108108    debugOutput(DEBUG_LEVEL_NORMAL, "Discovering plugs...\n"); 
    109  
     109     
    110110    PlugInfoCmd plugInfoCmd( getUnit().get1394Service(), 
    111111                             PlugInfoCmd::eSF_SerialBusIsochronousAndExternalPlug ); 
     
    147147{ 
    148148    debugOutput(DEBUG_LEVEL_NORMAL, "Discovering connections...\n"); 
    149  
     149     
    150150    for ( PlugVector::iterator it = getPlugs().begin(); 
    151151          it != getPlugs().end(); 
     
    183183            return false; 
    184184        } 
    185  
     185         
    186186        plug->setVerboseLevel(getDebugLevel()); 
    187  
     187         
    188188        if ( !plug->discover() ) { 
    189189            debugError( "plug discover failed\n" ); 
     
    232232bool 
    233233Subunit::serialize( Glib::ustring basePath, 
    234                     Util::IOSerialize& ser ) const 
     234                                   Util::IOSerialize& ser ) const 
    235235{ 
    236236    bool result; 
     
    239239    result &= ser.write( basePath + "m_sbId", m_sbId ); 
    240240    result &= ser.write( basePath + "m_verboseLevel", getDebugLevel() ); 
    241     result &= serializePlugVector( basePath + "m_plugs", ser, m_plugs ); 
    242241    result &= serializeChild( basePath, ser ); 
    243242 
     
    260259 
    261260    Subunit* pSubunit = 0; 
    262  
     261     
    263262    #warning FIXME: The derived class should be creating these 
    264263    // FIXME: The derived class should be creating these, such that discover() can become pure virtual 
     
    281280    pSubunit->m_sbType = sbType; 
    282281    result &= deser.read( basePath + "m_sbId", pSubunit->m_sbId ); 
    283     result &= deserializePlugVector( basePath + "m_plugs", deser, 
    284                                      unit.getPlugManager(), pSubunit->m_plugs ); 
    285282    int verboseLevel; 
    286283    result &= deser.read( basePath + "m_verboseLevel", verboseLevel ); 
  • trunk/libffado/src/libavc/general/avc_subunit.h

    r716 r734  
    7373 
    7474    PlugVector& getPlugs() 
    75        { return m_plugs; } 
     75    { return m_plugs; } 
    7676    Plug* getPlug(Plug::EPlugDirection direction, plug_id_t plugId); 
    7777 
     
    8080    bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
    8181    static Subunit* deserialize( Glib::ustring basePath, 
    82                                 Util::IODeserialize& deser, Unit& avDevice ); 
     82                    Util::IODeserialize& deser, Unit& avDevice ); 
    8383 protected: 
    8484    Subunit(); 
  • trunk/libffado/src/libavc/general/avc_unit.cpp

    r716 r734  
    975975    result  = ser.write( basePath + "m_verboseLevel_unit", getDebugLevel() ); 
    976976    result &= serializeVector( basePath + "Subunit", ser, m_subunits ); 
    977     result &= serializePlugVector( basePath + "PcrPlug", ser, m_pcrPlugs ); 
    978     result &= serializePlugVector( basePath + "ExternalPlug",  ser, m_externalPlugs ); 
     977    result &= serializeVector( basePath + "PcrPlug", ser, m_pcrPlugs ); 
     978    result &= serializeVector( basePath + "ExternalPlug",  ser, m_externalPlugs ); 
    979979    result &= serializeVector( basePath + "PlugConnection", ser, m_plugConnections ); 
    980980    result &= m_pPlugManager->serialize( basePath + "Plug", ser ); // serialize all av plugs 
     
    10071007    setDebugLevel( verboseLevel ); 
    10081008 
    1009     result &= deserializeVector<Subunit>( basePath + "Subunit", deser, *this, m_subunits ); 
     1009    result &= deserializeVector<Subunit>( basePath + "Subunit", deser, *this, m_subunits ); 
    10101010 
    10111011    if (m_pPlugManager) 
     
    10171017        return false; 
    10181018 
    1019     result &= deserializePlugVector( basePath + "PcrPlug", deser, getPlugManager(), m_pcrPlugs ); 
    1020     result &= deserializePlugVector( basePath + "ExternalPlug", deser, getPlugManager(), m_externalPlugs ); 
     1019    // XXX We have to deserialize the m_pcrPlugs and m_externPlugs members somehow. 
     1020    // Of course the simple following simple approach wont work at the moment. Some 
     1021    // more hacking needed :) 
     1022    //result &= deserializeVector<Plug>( basePath + "PcrPlug", deser, *this, m_pcrPlugs ); 
     1023    //result &= deserializeVector<Plug>( basePath + "ExternalPlug", deser, *this, m_externalPlugs ); 
     1024    result &= deserializePlugUpdateConnections( basePath + "PcrPlug", deser, m_pcrPlugs ); 
     1025    result &= deserializePlugUpdateConnections( basePath + "ExternalPlug", deser, m_externalPlugs ); 
    10211026    result &= deserializeVector<PlugConnection>( basePath + "PlugConnnection", deser, *this, m_plugConnections ); 
    10221027    result &= deserializeVector<Subunit>( basePath + "Subunit",  deser, *this, m_subunits ); 
    10231028    result &= deserializeSyncInfoVector( basePath + "SyncInfo", deser, m_syncInfos ); 
    10241029 
    1025     result &= deserializePlugUpdateConnections( basePath + "PcrPlug", deser, m_pcrPlugs ); 
    1026     result &= deserializePlugUpdateConnections( basePath + "ExternalPlug", deser, m_externalPlugs ); 
    1027     m_pPlugManager->deserializeUpdate(); 
    1028  
    10291030    unsigned int i; 
    10301031    result &= deser.read( basePath + "m_activeSyncInfo", i );