Changeset 734 for trunk/libffado/src/libavc/general
- Timestamp:
- 11/28/07 05:03:31 (16 years ago)
- Files:
-
- trunk/libffado/src/libavc/general/avc_plug.cpp (modified) (5 diffs)
- trunk/libffado/src/libavc/general/avc_plug.h (modified) (5 diffs)
- trunk/libffado/src/libavc/general/avc_subunit.cpp (modified) (7 diffs)
- trunk/libffado/src/libavc/general/avc_subunit.h (modified) (2 diffs)
- trunk/libffado/src/libavc/general/avc_unit.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/libavc/general/avc_plug.cpp
r716 r734 1576 1576 } 1577 1577 1578 1579 bool 1580 Plug::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 1600 bool 1601 Plug::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 1578 1638 bool 1579 1639 Plug::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const … … 1623 1683 bool result=true; 1624 1684 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 1627 1691 result &= deser.read( basePath + "m_functionBlockType", pPlug->m_functionBlockType ); 1628 1692 result &= deser.read( basePath + "m_functionBlockId", pPlug->m_functionBlockId ); … … 1654 1718 bool 1655 1719 Plug::deserializeUpdate( Glib::ustring basePath, 1656 Util::IODeserialize& deser )1720 Util::IODeserialize& deser ) 1657 1721 { 1658 1722 bool result; 1659 1723 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 ); 1664 1726 1665 1727 return result; 1666 }1667 1668 bool1669 Plug::deserializeUpdateSubunit()1670 {1671 m_subunit = m_unit->getSubunit( m_subunitType, m_subunitId );1672 return true;1673 1728 } 1674 1729 … … 2150 2205 } 2151 2206 2152 bool2153 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 }2168 2207 2169 2208 //////////////////////////////////// … … 2300 2339 } 2301 2340 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 163 163 bool deserializeUpdate( Glib::ustring basePath, 164 164 Util::IODeserialize& deser ); 165 bool deserializeUpdateSubunit();166 165 167 166 public: … … 257 256 bool deserializeFormatInfos( Glib::ustring basePath, 258 257 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 ); 259 265 260 266 protected: … … 279 285 Unit* m_unit; 280 286 Subunit* m_subunit; 281 ESubunitType m_subunitType;282 subunit_t m_subunitId;283 287 function_block_type_t m_functionBlockType; 284 288 function_block_id_t m_functionBlockId; … … 345 349 bool tidyPlugConnections(PlugConnectionVector&); 346 350 347 bool deserializeUpdate();348 349 351 private: 350 352 … … 377 379 typedef std::vector<PlugConnection> PlugConnectionOwnerVector; 378 380 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 389 381 } 390 382 trunk/libffado/src/libavc/general/avc_subunit.cpp
r716 r734 107 107 { 108 108 debugOutput(DEBUG_LEVEL_NORMAL, "Discovering plugs...\n"); 109 109 110 110 PlugInfoCmd plugInfoCmd( getUnit().get1394Service(), 111 111 PlugInfoCmd::eSF_SerialBusIsochronousAndExternalPlug ); … … 147 147 { 148 148 debugOutput(DEBUG_LEVEL_NORMAL, "Discovering connections...\n"); 149 149 150 150 for ( PlugVector::iterator it = getPlugs().begin(); 151 151 it != getPlugs().end(); … … 183 183 return false; 184 184 } 185 185 186 186 plug->setVerboseLevel(getDebugLevel()); 187 187 188 188 if ( !plug->discover() ) { 189 189 debugError( "plug discover failed\n" ); … … 232 232 bool 233 233 Subunit::serialize( Glib::ustring basePath, 234 Util::IOSerialize& ser ) const234 Util::IOSerialize& ser ) const 235 235 { 236 236 bool result; … … 239 239 result &= ser.write( basePath + "m_sbId", m_sbId ); 240 240 result &= ser.write( basePath + "m_verboseLevel", getDebugLevel() ); 241 result &= serializePlugVector( basePath + "m_plugs", ser, m_plugs );242 241 result &= serializeChild( basePath, ser ); 243 242 … … 260 259 261 260 Subunit* pSubunit = 0; 262 261 263 262 #warning FIXME: The derived class should be creating these 264 263 // FIXME: The derived class should be creating these, such that discover() can become pure virtual … … 281 280 pSubunit->m_sbType = sbType; 282 281 result &= deser.read( basePath + "m_sbId", pSubunit->m_sbId ); 283 result &= deserializePlugVector( basePath + "m_plugs", deser,284 unit.getPlugManager(), pSubunit->m_plugs );285 282 int verboseLevel; 286 283 result &= deser.read( basePath + "m_verboseLevel", verboseLevel ); trunk/libffado/src/libavc/general/avc_subunit.h
r716 r734 73 73 74 74 PlugVector& getPlugs() 75 75 { return m_plugs; } 76 76 Plug* getPlug(Plug::EPlugDirection direction, plug_id_t plugId); 77 77 … … 80 80 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 81 81 static Subunit* deserialize( Glib::ustring basePath, 82 82 Util::IODeserialize& deser, Unit& avDevice ); 83 83 protected: 84 84 Subunit(); trunk/libffado/src/libavc/general/avc_unit.cpp
r716 r734 975 975 result = ser.write( basePath + "m_verboseLevel_unit", getDebugLevel() ); 976 976 result &= serializeVector( basePath + "Subunit", ser, m_subunits ); 977 result &= serialize PlugVector( basePath + "PcrPlug", ser, m_pcrPlugs );978 result &= serialize PlugVector( basePath + "ExternalPlug", ser, m_externalPlugs );977 result &= serializeVector( basePath + "PcrPlug", ser, m_pcrPlugs ); 978 result &= serializeVector( basePath + "ExternalPlug", ser, m_externalPlugs ); 979 979 result &= serializeVector( basePath + "PlugConnection", ser, m_plugConnections ); 980 980 result &= m_pPlugManager->serialize( basePath + "Plug", ser ); // serialize all av plugs … … 1007 1007 setDebugLevel( verboseLevel ); 1008 1008 1009 result &= deserializeVector<Subunit>( basePath + "Subunit", deser, *this, m_subunits );1009 result &= deserializeVector<Subunit>( basePath + "Subunit", deser, *this, m_subunits ); 1010 1010 1011 1011 if (m_pPlugManager) … … 1017 1017 return false; 1018 1018 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 ); 1021 1026 result &= deserializeVector<PlugConnection>( basePath + "PlugConnnection", deser, *this, m_plugConnections ); 1022 1027 result &= deserializeVector<Subunit>( basePath + "Subunit", deser, *this, m_subunits ); 1023 1028 result &= deserializeSyncInfoVector( basePath + "SyncInfo", deser, m_syncInfos ); 1024 1029 1025 result &= deserializePlugUpdateConnections( basePath + "PcrPlug", deser, m_pcrPlugs );1026 result &= deserializePlugUpdateConnections( basePath + "ExternalPlug", deser, m_externalPlugs );1027 m_pPlugManager->deserializeUpdate();1028 1029 1030 unsigned int i; 1030 1031 result &= deser.read( basePath + "m_activeSyncInfo", i );