Changeset 376
- Timestamp:
- 01/20/07 10:25:59 (17 years ago)
- Files:
-
- trunk/libfreebob/src/bebob/bebob_avdevice.cpp (modified) (6 diffs)
- trunk/libfreebob/src/bebob/bebob_avdevice_subunit.cpp (modified) (18 diffs)
- trunk/libfreebob/src/bebob/bebob_avdevice_subunit.h (modified) (4 diffs)
- trunk/libfreebob/src/bebob/bebob_avplug.cpp (modified) (8 diffs)
- trunk/libfreebob/src/bebob/bebob_avplug.h (modified) (4 diffs)
- trunk/libfreebob/src/bebob/bebob_functionblock.cpp (modified) (1 diff)
- trunk/libfreebob/src/bebob/bebob_functionblock.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libfreebob/src/bebob/bebob_avdevice.cpp
r375 r376 552 552 switch( subunit_type ) { 553 553 case AVCCommand::eST_Audio: 554 subunit = new AvDeviceSubunitAudio( *this, subunitId, 554 subunit = new AvDeviceSubunitAudio( *this, 555 subunitId, 555 556 m_verboseLevel ); 556 557 if ( !subunit ) { … … 564 565 break; 565 566 case AVCCommand::eST_Music: 566 subunit = new AvDeviceSubunitMusic( *this, subunitId, 567 subunit = new AvDeviceSubunitMusic( *this, 568 subunitId, 567 569 m_verboseLevel ); 568 570 if ( !subunit ) { … … 1248 1250 template <typename T, typename VT> bool deserializeVector( Glib::ustring path, 1249 1251 Util::IODeserialize& deser, 1250 Ieee1394Service& ieee1394Service, 1251 ConfigRom& configRom, 1252 AvPlugManager& plugManager, 1252 AvDevice& avDevice, 1253 1253 VT& vec ) 1254 1254 { … … 1260 1260 T* ptr = T::deserialize( strstrm.str() + "/", 1261 1261 deser, 1262 ieee1394Service, 1263 configRom, 1264 plugManager ); 1262 avDevice ); 1265 1263 if ( ptr ) { 1266 1264 vec.push_back( ptr ); … … 1325 1323 bool result; 1326 1324 result = deser.read( basePath + "m_verboseLevel", pDev->m_verboseLevel ); 1327 pDev->m_pPlugManager = AvPlugManager::deserialize( basePath + "AvPlug", deser, ieee1394Service, *pDev->m_pConfigRom.get());1325 pDev->m_pPlugManager = AvPlugManager::deserialize( basePath + "AvPlug", deser, *pDev ); 1328 1326 if ( !pDev->m_pPlugManager ) { 1329 1327 delete pDev; … … 1332 1330 result &= deserializeAvPlugUpdateConnections( basePath + "AvPlug", deser, pDev->m_pcrPlugs ); 1333 1331 result &= deserializeAvPlugUpdateConnections( basePath + "AvPlug", deser, pDev->m_externalPlugs ); 1334 result &= deserializeVector<AvPlugConnection>( basePath + "PlugConnnection", deser, ieee1394Service, *pDev->m_pConfigRom.get(), *pDev->m_pPlugManager, pDev->m_plugConnections );1335 result &= deserializeVector<AvDeviceSubunit>( basePath + "Subunit", deser, ieee1394Service, *pDev->m_pConfigRom.get(), *pDev->m_pPlugManager, pDev->m_subunits );1332 result &= deserializeVector<AvPlugConnection>( basePath + "PlugConnnection", deser, *pDev, pDev->m_plugConnections ); 1333 result &= deserializeVector<AvDeviceSubunit>( basePath + "Subunit", deser, *pDev, pDev->m_subunits ); 1336 1334 1337 1335 // XXX ... trunk/libfreebob/src/bebob/bebob_avdevice_subunit.cpp
r375 r376 1 1 /* bebob_avdevice_subunit.cpp 2 * Copyright (C) 2005,06 by Daniel Wagner2 * Copyright (C) 2005,06,07 by Daniel Wagner 3 3 * 4 4 * This file is part of FreeBoB. … … 29 29 #include "libfreebobavc/avc_serialize.h" 30 30 31 namespace BeBoB { 32 33 IMPL_DEBUG_MODULE( AvDeviceSubunit,AvDeviceSubunit, DEBUG_LEVEL_VERBOSE );31 #include <sstream> 32 33 IMPL_DEBUG_MODULE( BeBoB::AvDeviceSubunit, BeBoB::AvDeviceSubunit, DEBUG_LEVEL_VERBOSE ); 34 34 35 35 //////////////////////////////////////////// 36 36 37 AvDeviceSubunit::AvDeviceSubunit( AvDevice& avDevice,38 AVCCommand::ESubunitType type,39 subunit_t id,40 int verboseLevel )37 BeBoB::AvDeviceSubunit::AvDeviceSubunit( AvDevice& avDevice, 38 AVCCommand::ESubunitType type, 39 subunit_t id, 40 int verboseLevel ) 41 41 : m_avDevice( &avDevice ) 42 42 , m_sbType( type ) … … 47 47 } 48 48 49 AvDeviceSubunit::~AvDeviceSubunit() 49 BeBoB::AvDeviceSubunit::AvDeviceSubunit() 50 { 51 } 52 53 BeBoB::AvDeviceSubunit::~AvDeviceSubunit() 50 54 { 51 55 for ( AvPlugVector::iterator it = m_plugs.begin(); … … 58 62 59 63 bool 60 AvDeviceSubunit::discover()64 BeBoB::AvDeviceSubunit::discover() 61 65 { 62 66 if ( !discoverPlugs() ) { … … 69 73 70 74 bool 71 AvDeviceSubunit::discoverPlugs()75 BeBoB::AvDeviceSubunit::discoverPlugs() 72 76 { 73 77 PlugInfoCmd plugInfoCmd( m_avDevice->get1394Service(), … … 107 111 108 112 bool 109 AvDeviceSubunit::discoverConnections()113 BeBoB::AvDeviceSubunit::discoverConnections() 110 114 { 111 115 for ( AvPlugVector::iterator it = m_plugs.begin(); … … 125 129 126 130 bool 127 AvDeviceSubunit::discoverPlugs(AvPlug::EAvPlugDirection plugDirection,128 plug_id_t plugMaxId )131 BeBoB::AvDeviceSubunit::discoverPlugs(AvPlug::EAvPlugDirection plugDirection, 132 plug_id_t plugMaxId ) 129 133 { 130 134 for ( int plugIdx = 0; … … 158 162 159 163 bool 160 AvDeviceSubunit::addPlug( AvPlug& plug )164 BeBoB::AvDeviceSubunit::addPlug( AvPlug& plug ) 161 165 { 162 166 m_plugs.push_back( &plug ); … … 165 169 166 170 167 AvPlug*168 AvDeviceSubunit::getPlug(AvPlug::EAvPlugDirection direction, plug_id_t plugId)171 BeBoB::AvPlug* 172 BeBoB::AvDeviceSubunit::getPlug(AvPlug::EAvPlugDirection direction, plug_id_t plugId) 169 173 { 170 174 for ( AvPlugVector::iterator it = m_plugs.begin(); … … 184 188 185 189 bool 186 AvDeviceSubunit::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 187 { 188 return true; 189 } 190 191 AvDeviceSubunit* 192 AvDeviceSubunit::deserialize( Glib::ustring basePath, 193 Util::IODeserialize& deser, 194 Ieee1394Service& ieee1394Service, 195 ConfigRom& configRom, 196 AvPlugManager& plugManager ) 197 { 198 return 0; 190 BeBoB::AvDeviceSubunit::serialize( Glib::ustring basePath, 191 Util::IOSerialize& ser ) const 192 { 193 bool result; 194 195 result = ser.write( basePath + "m_sbType", m_sbType ); 196 result &= ser.write( basePath + "m_sbId", m_sbId ); 197 result &= ser.write( basePath + "m_verboseLevel", m_verboseLevel ); 198 result &= serializeChild( basePath, ser ); 199 200 return result; 201 } 202 203 BeBoB::AvDeviceSubunit* 204 BeBoB::AvDeviceSubunit::deserialize( Glib::ustring basePath, 205 Util::IODeserialize& deser, 206 AvDevice& avDevice ) 207 { 208 bool result; 209 AVCCommand::ESubunitType sbType; 210 result = deser.read( basePath + "m_sbType", sbType ); 211 212 AvDeviceSubunit* pSubunit = 0; 213 switch( sbType ) { 214 case AVCCommand::eST_Audio: 215 pSubunit = new AvDeviceSubunitAudio; 216 break; 217 case AVCCommand::eST_Music: 218 pSubunit = new AvDeviceSubunitMusic; 219 break; 220 default: 221 pSubunit = 0; 222 } 223 224 if ( !pSubunit ) { 225 return 0; 226 } 227 228 pSubunit->m_avDevice = &avDevice; 229 pSubunit->m_sbType = sbType; 230 result &= deser.read( basePath + "m_sbId", pSubunit->m_sbId ); 231 result &= deser.read( basePath + "m_verboseLevel", pSubunit->m_verboseLevel ); 232 result &= pSubunit->deserializeChild( basePath, deser, avDevice ); 233 234 if ( !result ) { 235 delete pSubunit; 236 return 0; 237 } 238 239 return pSubunit; 199 240 } 200 241 201 242 //////////////////////////////////////////// 202 243 203 AvDeviceSubunitAudio::AvDeviceSubunitAudio( AvDevice& avDevice,204 subunit_t id,205 int verboseLevel )244 BeBoB::AvDeviceSubunitAudio::AvDeviceSubunitAudio( AvDevice& avDevice, 245 subunit_t id, 246 int verboseLevel ) 206 247 : AvDeviceSubunit( avDevice, AVCCommand::eST_Audio, id, verboseLevel ) 207 248 { 208 249 } 209 250 210 AvDeviceSubunitAudio::~AvDeviceSubunitAudio() 251 BeBoB::AvDeviceSubunitAudio::AvDeviceSubunitAudio() 252 : AvDeviceSubunit() 253 { 254 } 255 256 BeBoB::AvDeviceSubunitAudio::~AvDeviceSubunitAudio() 211 257 { 212 258 for ( FunctionBlockVector::iterator it = m_functions.begin(); … … 219 265 220 266 bool 221 AvDeviceSubunitAudio::discover()267 BeBoB::AvDeviceSubunitAudio::discover() 222 268 { 223 269 if ( !AvDeviceSubunit::discover() ) { … … 234 280 235 281 bool 236 AvDeviceSubunitAudio::discoverConnections()282 BeBoB::AvDeviceSubunitAudio::discoverConnections() 237 283 { 238 284 if ( !AvDeviceSubunit::discoverConnections() ) { … … 256 302 257 303 const char* 258 AvDeviceSubunitAudio::getName()304 BeBoB::AvDeviceSubunitAudio::getName() 259 305 { 260 306 return "AudioSubunit"; … … 262 308 263 309 bool 264 AvDeviceSubunitAudio::discoverFunctionBlocks()310 BeBoB::AvDeviceSubunitAudio::discoverFunctionBlocks() 265 311 { 266 312 if ( !discoverFunctionBlocksDo( … … 293 339 294 340 bool 295 AvDeviceSubunitAudio::discoverFunctionBlocksDo(341 BeBoB::AvDeviceSubunitAudio::discoverFunctionBlocksDo( 296 342 ExtendedSubunitInfoCmd::EFunctionBlockType fbType ) 297 343 { … … 341 387 342 388 bool 343 AvDeviceSubunitAudio::createFunctionBlock(389 BeBoB::AvDeviceSubunitAudio::createFunctionBlock( 344 390 ExtendedSubunitInfoCmd::EFunctionBlockType fbType, 345 391 ExtendedSubunitInfoPageData& data ) … … 436 482 } 437 483 438 FunctionBlock::ESpecialPurpose439 AvDeviceSubunitAudio::convertSpecialPurpose(484 BeBoB::FunctionBlock::ESpecialPurpose 485 BeBoB::AvDeviceSubunitAudio::convertSpecialPurpose( 440 486 function_block_special_purpose_t specialPurpose ) 441 487 { … … 454 500 } 455 501 502 bool 503 BeBoB::AvDeviceSubunitAudio::serializeChild( Glib::ustring basePath, 504 Util::IOSerialize& ser ) const 505 { 506 bool result = true; 507 int i = 0; 508 509 for ( FunctionBlockVector::const_iterator it = m_functions.begin(); 510 it != m_functions.end(); 511 ++it ) 512 { 513 FunctionBlock* pFB = *it; 514 std::ostringstream strstrm; 515 strstrm << basePath << "FunctionBlock" << i << "/"; 516 517 result &= pFB->serialize( strstrm.str() , ser ); 518 519 i++; 520 } 521 522 return result; 523 } 524 525 bool 526 BeBoB::AvDeviceSubunitAudio::deserializeChild( Glib::ustring basePath, 527 Util::IODeserialize& deser, 528 AvDevice& avDevice ) 529 { 530 int i = 0; 531 bool bFinished = false; 532 do { 533 std::ostringstream strstrm; 534 strstrm << basePath << "FunctionBlock" << i << "/"; 535 FunctionBlock* pFB = FunctionBlock::deserialize( strstrm.str(), 536 deser, 537 avDevice ); 538 if ( pFB ) { 539 m_functions.push_back( pFB ); 540 i++; 541 } else { 542 bFinished = true; 543 } 544 } while ( !bFinished ); 545 546 return true; 547 } 456 548 457 549 //////////////////////////////////////////// 458 550 459 AvDeviceSubunitMusic::AvDeviceSubunitMusic( AvDevice& avDevice,460 subunit_t id,461 int verboseLevel )551 BeBoB::AvDeviceSubunitMusic::AvDeviceSubunitMusic( AvDevice& avDevice, 552 subunit_t id, 553 int verboseLevel ) 462 554 : AvDeviceSubunit( avDevice, AVCCommand::eST_Music, id, verboseLevel ) 463 555 { 464 556 } 465 557 466 AvDeviceSubunitMusic::~AvDeviceSubunitMusic() 558 BeBoB::AvDeviceSubunitMusic::AvDeviceSubunitMusic() 559 : AvDeviceSubunit() 560 { 561 } 562 563 BeBoB::AvDeviceSubunitMusic::~AvDeviceSubunitMusic() 467 564 { 468 565 } 469 566 470 567 const char* 471 AvDeviceSubunitMusic::getName()568 BeBoB::AvDeviceSubunitMusic::getName() 472 569 { 473 570 return "MusicSubunit"; 474 571 } 475 572 476 } 573 bool 574 BeBoB::AvDeviceSubunitMusic::serializeChild( Glib::ustring basePath, 575 Util::IOSerialize& ser ) const 576 { 577 return true; 578 } 579 580 bool 581 BeBoB::AvDeviceSubunitMusic::deserializeChild( Glib::ustring basePath, 582 Util::IODeserialize& deser, 583 AvDevice& avDevice ) 584 { 585 return true; 586 } trunk/libfreebob/src/bebob/bebob_avdevice_subunit.h
r375 r376 67 67 static AvDeviceSubunit* deserialize( Glib::ustring basePath, 68 68 Util::IODeserialize& deser, 69 Ieee1394Service& ieee1394Service, 70 ConfigRom& configRom, 71 AvPlugManager& plugManager ); 69 AvDevice& avDevice ); 72 70 protected: 71 AvDeviceSubunit(); 72 73 73 bool discoverPlugs(); 74 74 bool discoverPlugs(AvPlug::EAvPlugDirection plugDirection, 75 75 plug_id_t plugMaxId ); 76 77 virtual bool serializeChild( Glib::ustring basePath, 78 Util::IOSerialize& ser ) const = 0; 79 virtual bool deserializeChild( Glib::ustring basePath, 80 Util::IODeserialize& deser, 81 AvDevice& avDevice ) = 0; 76 82 77 83 protected: … … 95 101 subunit_t id, 96 102 int verboseLevel ); 103 AvDeviceSubunitAudio(); 97 104 virtual ~AvDeviceSubunitAudio(); 98 105 … … 114 121 function_block_special_purpose_t specialPurpose ); 115 122 123 virtual bool serializeChild( Glib::ustring basePath, 124 Util::IOSerialize& ser ) const; 125 virtual bool deserializeChild( Glib::ustring basePath, 126 Util::IODeserialize& deser, 127 AvDevice& avDevice ); 128 116 129 protected: 117 130 FunctionBlockVector m_functions; … … 125 138 subunit_t id, 126 139 int verboseLevel ); 140 AvDeviceSubunitMusic(); 127 141 virtual ~AvDeviceSubunitMusic(); 128 142 129 143 virtual const char* getName(); 144 145 protected: 146 virtual bool serializeChild( Glib::ustring basePath, 147 Util::IOSerialize& ser ) const; 148 virtual bool deserializeChild( Glib::ustring basePath, 149 Util::IODeserialize& deser, 150 AvDevice& avDevice ); 130 151 }; 131 152 trunk/libfreebob/src/bebob/bebob_avplug.cpp
r375 r376 20 20 21 21 #include "bebob/bebob_avplug.h" 22 #include "bebob/bebob_avdevice.h" 22 23 #include "configrom.h" 23 24 … … 119 120 AvPlug::~AvPlug() 120 121 { 121 m_plugManager->remPlug( *this ); 122 if ( m_plugManager ) { 123 m_plugManager->remPlug( *this ); 124 } 122 125 } 123 126 … … 1704 1707 AvPlug::deserialize( Glib::ustring basePath, 1705 1708 Util::IODeserialize& deser, 1706 Ieee1394Service& ieee1394Service, 1707 ConfigRom& configRom, 1709 AvDevice& avDevice, 1708 1710 AvPlugManager& plugManager ) 1709 1711 { … … 1713 1715 } 1714 1716 1715 pPlug->m_p1394Service = & ieee1394Service;1716 pPlug->m_pConfigRom = &configRom;1717 pPlug->m_plugManager = &plugManager;1717 pPlug->m_p1394Service = &avDevice.get1394Service(); 1718 pPlug->m_pConfigRom = &avDevice.getConfigRom(); 1719 pPlug->m_plugManager = &plugManager; 1718 1720 bool result; 1719 1721 result = deser.read( basePath + "m_subunitType", pPlug->m_subunitType ); … … 2130 2132 AvPlugManager::deserialize( Glib::ustring basePath, 2131 2133 Util::IODeserialize& deser, 2132 Ieee1394Service& ieee1394Service,2133 ConfigRom& configRom ) 2134 AvDevice& avDevice ) 2135 2134 2136 { 2135 2137 AvPlugManager* pMgr = new AvPlugManager; … … 2144 2146 std::ostringstream strstrm; 2145 2147 strstrm << basePath << i; 2148 // avDevice still holds a null pointer for the plug manager 2149 // therefore we have to *this as additional argument 2146 2150 AvPlug* pPlug = AvPlug::deserialize( strstrm.str() + "/", 2147 2151 deser, 2148 ieee1394Service, 2149 configRom, 2152 avDevice, 2150 2153 *pMgr ); 2151 2154 if ( pPlug ) { … … 2187 2190 AvPlugConnection::deserialize( Glib::ustring basePath, 2188 2191 Util::IODeserialize& deser, 2189 Ieee1394Service& /* ieee1394Service */, 2190 ConfigRom& /* configRom */, 2191 AvPlugManager& plugManager ) 2192 AvDevice& avDevice ) 2192 2193 { 2193 2194 AvPlugConnection* pConnection = new AvPlugConnection; … … 2207 2208 } 2208 2209 2209 pConnection->m_srcPlug = plugManager.getPlug( iSrcPlugId );2210 pConnection->m_destPlug = plugManager.getPlug( iDestPlugId );2210 pConnection->m_srcPlug = avDevice.getPlugManager().getPlug( iSrcPlugId ); 2211 pConnection->m_destPlug = avDevice.getPlugManager().getPlug( iDestPlugId ); 2211 2212 2212 2213 if ( !pConnection->m_srcPlug || !pConnection->m_destPlug ) { trunk/libfreebob/src/bebob/bebob_avplug.h
r375 r376 41 41 namespace BeBoB { 42 42 43 class AvDevice; 43 44 class AvPlugManager; 44 45 class AvPlug; … … 141 142 static AvPlug* deserialize( Glib::ustring basePath, 142 143 Util::IODeserialize& deser, 143 Ieee1394Service& ieee1394Service, 144 ConfigRom& configRom, 144 AvDevice& avDevice, 145 145 AvPlugManager& plugManager ); 146 146 147 bool deserializeUpdate( Glib::ustring basePath, 147 148 Util::IODeserialize& deser ); … … 317 318 static AvPlugManager* deserialize( Glib::ustring basePath, 318 319 Util::IODeserialize& deser, 319 Ieee1394Service& ieee1394Service,320 ConfigRom& configRom ); 320 AvDevice& avDevice ); 321 321 322 private: 322 323 AvPlugManager(); … … 340 341 static AvPlugConnection* deserialize( Glib::ustring basePath, 341 342 Util::IODeserialize& deser, 342 Ieee1394Service& ieee1394Service, 343 ConfigRom& configRom, 344 AvPlugManager& plugManager ); 343 AvDevice& avDevice ); 345 344 private: 346 345 AvPlugConnection(); trunk/libfreebob/src/bebob/bebob_functionblock.cpp
r375 r376 147 147 } 148 148 149 bool 150 FunctionBlock::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 151 { 152 int dummy = 42; 153 return ser.write( basePath + "dummy", dummy ); 154 } 155 156 FunctionBlock* 157 FunctionBlock::deserialize( Glib::ustring basePath, 158 Util::IODeserialize& deser, 159 AvDevice& avDevice ) 160 { 161 return 0; 162 } 163 149 164 /////////////////////// 150 165 trunk/libfreebob/src/bebob/bebob_functionblock.h
r341 r376 62 62 virtual const char* getName() = 0; 63 63 64 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 65 static FunctionBlock* deserialize( Glib::ustring basePath, 66 Util::IODeserialize& deser, 67 AvDevice& avDevice ); 64 68 protected: 65 69 bool discoverPlugs( AvPlug::EAvPlugDirection plugDirection,