Changeset 478
- Timestamp:
- 06/02/07 08:06:28 (17 years ago)
- Files:
-
- trunk/libffado/configure.ac (modified) (3 diffs)
- trunk/libffado/src/devicemanager.cpp (modified) (2 diffs)
- trunk/libffado/src/devicemanager.h (modified) (2 diffs)
- trunk/libffado/src/libieee1394/configrom.cpp (modified) (1 diff)
- trunk/libffado/src/libieee1394/configrom.h (modified) (1 diff)
- trunk/libffado/src/Makefile.am (modified) (1 diff)
- trunk/libffado/src/ser.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/configure.ac
r470 r478 1 1 # configure.ac - Configure script for FFADO. 2 # Copyright (C) 2005,06 by Daniel Wagner.2 # Copyright (C) 2005,06,07 by Daniel Wagner. 3 3 # Copyright (C) 2006,07 by Pieter Palmers. 4 4 # … … 26 26 m4_define(ffado_major_version, 1) 27 27 m4_define(ffado_minor_version, 999) 28 m4_define(ffado_micro_version, 4)28 m4_define(ffado_micro_version, 5) 29 29 30 30 m4_define(ffado_version, ffado_major_version.ffado_minor_version.ffado_micro_version) … … 300 300 301 301 CFLAGS="$CFLAGS -Wall -std=gnu99" 302 CXXFLAGS="$CXXFLAGS -Wall -DDATADIR=\\\"\$(datadir)\\\"" 303 302 CXXFLAGS="$CXXFLAGS -Wall -DDATADIR=\\\"\$(datadir)\\\" -DCACHEDIR=\\\"\$(localstatedir)\\\"" 304 303 if test "${debug}" = true; then 305 304 CFLAGS="$CFLAGS -g -DDEBUG" trunk/libffado/src/devicemanager.cpp
r445 r478 486 486 487 487 bool 488 DeviceManager::saveCache( Glib::ustring fileName ) 489 { 490 int i; 491 i=0; // avoids unused warning 492 488 DeviceManager::buildCache() 489 { 490 bool result = true; 493 491 for ( IAvDeviceVectorIterator it = m_avDevices.begin(); 494 492 it != m_avDevices.end(); 495 493 ++it ) 496 494 { 497 IAvDevice* pAvDevice; 498 pAvDevice = *it; // avoids unused warning 499 500 #ifdef ENABLE_BEBOB 495 IAvDevice* pAvDevice = *it; 496 501 497 BeBoB::AvDevice* pBeBoBDevice = reinterpret_cast< BeBoB::AvDevice* >( pAvDevice ); 502 498 if ( pBeBoBDevice ) { 503 // Let's use a very simple path to find the devices later. 504 // Since under hood there will an xml node name this should 505 // adhere the needed naming rules. Of course we could give it 506 // a good node name and add an attribute but that would mean 507 // we have to expose a bigger interface from IOSerialize/IODesialize, 508 // which is just not needed. KISS. 509 ostringstream strstrm; 510 strstrm << "id" << i; 511 Glib::ustring basePath = "BeBoB/" + strstrm.str() + "/"; 512 513 Util::XMLSerialize ser( fileName ); 514 pBeBoBDevice->serialize( basePath, ser ); 515 516 i++; 517 std::cout << "a bebob device serialized" << std::endl; 518 } 519 #endif 520 } 521 return true; 522 } 523 524 bool 525 DeviceManager::loadCache( Glib::ustring fileName ) 526 { 527 int i; 528 i=0; // avoids unused warning 529 Util::XMLDeserialize deser( fileName ); 530 531 typedef std::vector<ConfigRom*> ConfigRomVector; 532 ConfigRomVector configRoms; 533 499 result &= saveCache( pBeBoBDevice ); 500 } 501 } 502 503 return result; 504 } 505 506 Glib::ustring 507 DeviceManager::getCachePath() 508 { 509 Glib::ustring cachePath; 510 char* pCachePath; 511 if ( asprintf( &pCachePath, "%s/cache/libfreebob/", CACHEDIR ) < 0 ) { 512 debugError( "saveCache: Could not create path string for cache pool (trying '/var/cache/freebob' instead)\n" ); 513 cachePath == "/var/cache/freebob/"; 514 } else { 515 cachePath = pCachePath; 516 free( pCachePath ); 517 } 518 return cachePath; 519 } 520 521 bool 522 DeviceManager::saveCache( IAvDevice* pAvDevice ) 523 { 524 BeBoB::AvDevice* pBeBoBDevice = reinterpret_cast<BeBoB::AvDevice*>( pAvDevice ); 525 if ( !pBeBoBDevice ) { 526 return true; 527 } 528 529 Glib::ustring sFileName = getCachePath() + pAvDevice->getConfigRom().getGuidString() + ".xml"; 530 debugOutput( DEBUG_LEVEL_NORMAL, "filename %s\n", sFileName.c_str() ); 531 532 Util::XMLSerialize ser( sFileName ); 533 return pBeBoBDevice->serialize( "/", ser ); 534 } 535 536 bool 537 DeviceManager::loadCache( Glib::ustring cachePath ) 538 { 534 539 for ( fb_nodeid_t nodeId = 0; 535 540 nodeId < m_1394Service->getNodeCount(); … … 550 555 continue; 551 556 } 552 configRoms.push_back( pConfigRom ); 553 } 554 555 #ifdef ENABLE_BEBOB 556 BeBoB::AvDevice* pBeBoBDevice = 0; 557 do { 558 ostringstream strstrm; 559 strstrm << "id" << i; 560 pBeBoBDevice = BeBoB::AvDevice::deserialize( 561 "BeBoB/" + strstrm.str() + "/", 562 deser, 563 *m_1394Service ); 564 565 ++i; 566 if ( pBeBoBDevice ) { 567 for (ConfigRomVector::iterator it = configRoms.begin(); 568 it != configRoms.end(); 569 ++it ) 570 { 571 ConfigRom* pConfigRom = *it; 572 573 if ( pBeBoBDevice->getConfigRom() == *pConfigRom ) { 574 pBeBoBDevice->getConfigRom().setNodeId( pConfigRom->getNodeId() ); 575 // m_avDevices.push_back( pBeBoBDevice ); 576 577 } 578 } 579 } 580 } while ( pBeBoBDevice ); 581 #endif 557 558 Glib::ustring sFileName = getCachePath() + pConfigRom->getGuidString() + ".xml"; 559 560 if ( access( sFileName.c_str(), R_OK ) == 0 ) { 561 debugOutput( DEBUG_LEVEL_NORMAL, "load from %s\n", sFileName.c_str() ); 562 Util::XMLDeserialize deser( sFileName ); 563 564 BeBoB::AvDevice* pBeBoBDevice = BeBoB::AvDevice::deserialize( "/", deser, *m_1394Service ); 565 if ( pBeBoBDevice ) { 566 debugOutput( DEBUG_LEVEL_NORMAL, "loadCache: could create valid bebob driver from %s\n", sFileName.c_str() ); 567 pBeBoBDevice->getConfigRom().setNodeId( pConfigRom->getNodeId() ); 568 m_avDevices.push_back( pBeBoBDevice ); 569 } 570 } 571 572 // throw away this config rom instance, the deserialize code has created it's own from 573 // the cache. 574 delete pConfigRom; 575 } 582 576 583 577 return true; trunk/libffado/src/devicemanager.h
r445 r478 69 69 unsigned int getAvDeviceCount(); 70 70 71 bool saveCache( Glib::ustring fileName);72 bool loadCache( Glib::ustring fileName);71 bool buildCache(); 72 bool loadCache( Glib::ustring cachePath = "" ); 73 73 74 74 Streaming::StreamProcessor *getSyncSource(); … … 78 78 int id ); 79 79 IAvDevice* getSlaveDriver( std::auto_ptr<ConfigRom>( configRom ) ); 80 81 82 Glib::ustring getCachePath(); 83 bool saveCache( IAvDevice* pAvDevice ); 80 84 81 85 protected: trunk/libffado/src/libieee1394/configrom.cpp
r462 r478 384 384 { 385 385 return m_guid; 386 } 387 388 const Glib::ustring 389 ConfigRom::getGuidString() const 390 { 391 char* buf; 392 asprintf( &buf, "%08x%08x", 393 ( unsigned int ) ( getGuid() >> 32 ), 394 ( unsigned int ) ( getGuid() & 0xffffffff ) ); 395 Glib::ustring result = buf; 396 free( buf ); 397 return result; 386 398 } 387 399 trunk/libffado/src/libieee1394/configrom.h
r445 r478 52 52 const fb_nodeid_t getNodeId() const; 53 53 const fb_octlet_t getGuid() const; 54 const Glib::ustring getGuidString() const; 54 55 const Glib::ustring getModelName() const; 55 56 const Glib::ustring getVendorName() const; trunk/libffado/src/Makefile.am
r456 r478 173 173 maudio/fwap.xml 174 174 175 install-data-hook: 176 mkdir -p $(localstatedir)/cache/libffado 177 175 178 # programs intended for installation in the 'bin' directory 176 179 # generic trunk/libffado/src/ser.cpp
r445 r478 27 27 #include <iostream> 28 28 29 const char FileName[] = " serialize-test.xml";29 const char FileName[] = "bebob.xml"; 30 30 31 31 static bool 32 serialize( const char* pFileName , int port)32 serialize( const char* pFileName ) 33 33 { 34 34 DeviceManager devMgr; 35 if (!devMgr.initialize( port )) { 36 std::cerr << "could not init DeviceManager" << std::endl; 35 if ( !devMgr.initialize( 0 ) ) 37 36 return false; 38 } 39 40 // devMgr.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 41 42 if (!devMgr.discover( )) { 43 std::cerr << "could not discover devices" << std::endl; 37 if ( !devMgr.discover() ) 44 38 return false; 45 }46 return devMgr. saveCache( pFileName);39 devMgr.setVerboseLevel( 4 ); 40 return devMgr.buildCache(); 47 41 } 48 42 … … 51 45 { 52 46 DeviceManager devMgr; 53 if (!devMgr.initialize( 0 )) { 54 std::cerr << "could not init DeviceManager" << std::endl; 47 if ( !devMgr.initialize( 0 ) ) 55 48 return false; 56 } 49 50 devMgr.setVerboseLevel( 4 ); 57 51 return devMgr.loadCache( pFileName ); 58 52 } … … 61 55 main( int argc, char** argv ) 62 56 { 63 int port=0; 64 if (argc==2) { 65 port=atoi(argv[1]); 66 } 67 68 if ( !serialize( FileName, port ) ) { 57 if ( !serialize( FileName ) ) { 69 58 std::cerr << "serializing failed" << std::endl; 70 59 return -1;