Changeset 630
- Timestamp:
- 09/08/07 09:19:40 (16 years ago)
- Files:
-
- trunk/libffado/src/bebob/bebob_avdevice.cpp (modified) (12 diffs)
- trunk/libffado/src/bebob/bebob_avdevice.h (modified) (1 diff)
- trunk/libffado/src/genericavc/avc_avdevice.cpp (modified) (2 diffs)
- trunk/libffado/src/genericavc/avc_avdevice.h (modified) (3 diffs)
- trunk/libffado/src/libavc/general/avc_unit.cpp (modified) (12 diffs)
- trunk/libffado/src/libavc/general/avc_unit.h (modified) (4 diffs)
- trunk/libffado/src/libutil/cmd_serialize.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/bebob/bebob_avdevice.cpp
r620 r630 57 57 std::auto_ptr< ConfigRom >( configRom ) ) 58 58 : GenericAVC::AvDevice( ieee1394service, configRom ) 59 , m_Mixer ( NULL)59 , m_Mixer ( 0 ) 60 60 { 61 61 debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::AvDevice (NodeID %d)\n", … … 65 65 AvDevice::~AvDevice() 66 66 { 67 if(m_Mixer != NULL) { 68 delete m_Mixer; 69 } 67 delete m_Mixer; 70 68 } 71 69 … … 78 76 GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_bebob.txt" ); 79 77 if ( vendorModel.parse() ) { 80 vendorModel.printTable();81 78 return vendorModel.isPresent( vendorId, modelId ); 82 79 } … … 143 140 // this removes the mixer if it already exists 144 141 // note: a mixer self-registers to it's parent 145 if(m_Mixer != NULL) { 146 delete m_Mixer; 147 } 148 149 // create the mixer & register it 142 delete m_Mixer; 143 144 // create the mixer & register it 150 145 if(getAudioSubunit(0) == NULL) { 151 146 debugWarning("Could not find audio subunit, mixer not available.\n"); 152 m_Mixer = NULL;147 m_Mixer = 0; 153 148 } else { 154 149 m_Mixer = new Mixer(*this); … … 221 216 { 222 217 ExtendedStreamFormatCmd extStreamFormatCmd( *m_p1394Service ); 223 UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 224 getNodeId() ); 218 UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 0 ); 225 219 extStreamFormatCmd.setPlugAddress( PlugAddress( PlugAddress::ePD_Input, 226 220 PlugAddress::ePAM_Unit, … … 335 329 } 336 330 337 338 template <typename T> bool serializeVector( Glib::ustring path,339 Util::IOSerialize& ser,340 const T& vec )341 {342 bool result = true; // if vec.size() == 0343 int i = 0;344 for ( typename T::const_iterator it = vec.begin(); it != vec.end(); ++it ) {345 std::ostringstream strstrm;346 strstrm << path << i;347 result &= ( *it )->serialize( strstrm.str() + "/", ser );348 i++;349 }350 return result;351 }352 353 template <typename T, typename VT> bool deserializeVector( Glib::ustring path,354 Util::IODeserialize& deser,355 Unit& avDevice,356 VT& vec )357 {358 int i = 0;359 bool bFinished = false;360 do {361 std::ostringstream strstrm;362 strstrm << path << i << "/";363 T* ptr = T::deserialize( strstrm.str(),364 deser,365 avDevice );366 if ( ptr ) {367 vec.push_back( ptr );368 i++;369 } else {370 bFinished = true;371 }372 } while ( !bFinished );373 374 return true;375 }376 377 331 bool 378 332 AvDevice::serialize( Glib::ustring basePath, 379 333 Util::IOSerialize& ser ) const 380 334 { 381 382 335 bool result; 383 result = m_pConfigRom->serialize( basePath + "m_pConfigRom/", ser ); 384 result &= ser.write( basePath + "m_verboseLevel", getDebugLevel() ); 385 result &= m_pPlugManager->serialize( basePath + "Plug", ser ); // serialize all av plugs 386 result &= serializeVector( basePath + "PlugConnection", ser, m_plugConnections ); 387 result &= serializeVector( basePath + "Subunit", ser, m_subunits ); 388 #warning broken at echoaudio merge 389 //result &= serializeSyncInfoVector( basePath + "SyncInfo", ser, m_syncInfos ); 390 391 int i = 0; 392 for ( SyncInfoVector::const_iterator it = m_syncInfos.begin(); 393 it != m_syncInfos.end(); 394 ++it ) 395 { 396 const SyncInfo& info = *it; 397 if ( m_activeSyncInfo == &info ) { 398 result &= ser.write( basePath + "m_activeSyncInfo", i ); 399 break; 400 } 401 i++; 402 } 403 404 result &= serializeOptions( basePath + "Options", ser ); 405 406 // result &= ser.write( basePath + "m_id", id ); 407 336 result = GenericAVC::AvDevice::serialize( basePath, ser ); 408 337 return result; 409 338 } 410 339 411 AvDevice* 340 bool 412 341 AvDevice::deserialize( Glib::ustring basePath, 413 Util::IODeserialize& deser, 414 Ieee1394Service& ieee1394Service ) 415 { 416 417 // ConfigRom *configRom = 418 // ConfigRom::deserialize( basePath + "m_pConfigRom/", deser, ieee1394Service ); 419 // 420 // if ( !configRom ) { 421 // return NULL; 422 // } 423 // 424 // AvDevice* pDev = new AvDevice( 425 // std::auto_ptr<ConfigRom>(configRom), 426 // ieee1394Service, getConfigRom().getNodeId()); 427 // 428 // if ( pDev ) { 429 // bool result; 430 // int verboseLevel; 431 // result = deser.read( basePath + "m_verboseLevel", verboseLevel ); 432 // setDebugLevel( verboseLevel ); 433 // 434 // result &= AVC::Unit::deserialize(basePath, pDev, deser, ieee1394Service); 435 // 436 // result &= deserializeOptions( basePath + "Options", deser, *pDev ); 437 // } 438 // 439 // return pDev; 440 return NULL; 342 Util::IODeserialize& deser ) 343 { 344 bool result; 345 result = GenericAVC::AvDevice::deserialize( basePath, deser ); 346 return result; 441 347 } 442 348 … … 446 352 Glib::ustring cachePath; 447 353 char* pCachePath; 448 if ( asprintf( &pCachePath, "%s/cache/", CACHEDIR ) < 0 ) { 354 355 string path = CACHEDIR; 356 if ( path.size() && path[0] == '~' ) { 357 path.erase( 0, 1 ); // remove ~ 358 path.insert( 0, getenv( "HOME" ) ); // prepend the home path 359 } 360 361 if ( asprintf( &pCachePath, "%s/cache/", path.c_str() ) < 0 ) { 449 362 debugError( "Could not create path string for cache pool (trying '/var/cache/libffado' instead)\n" ); 450 363 cachePath == "/var/cache/libffado/"; … … 459 372 AvDevice::loadFromCache() 460 373 { 461 /* Glib::ustring sDevicePath = getCachePath() + m_pConfigRom->getGuidString(); 374 // XXX disable this part as long it is not correctly working 375 return false; 376 377 Glib::ustring sDevicePath = getCachePath() + m_pConfigRom->getGuidString(); 462 378 463 379 char* configId; … … 472 388 debugOutput( DEBUG_LEVEL_NORMAL, "filename %s\n", sFileName.c_str() ); 473 389 474 Util::XMLDeserialize deser( sFileName, m_verboseLevel ); 390 struct stat buf; 391 if ( stat( sFileName.c_str(), &buf ) != 0 ) { 392 debugOutput( DEBUG_LEVEL_NORMAL, "\"%s\" does not exist\n", sFileName.c_str() ); 393 return false; 394 } else { 395 if ( !S_ISREG( buf.st_mode ) ) { 396 debugOutput( DEBUG_LEVEL_NORMAL, "\"%s\" is not a regular file\n", sFileName.c_str() ); 397 return false; 398 } 399 } 400 401 Util::XMLDeserialize deser( sFileName, getDebugLevel() ); 475 402 476 403 bool result = deserialize( "", deser ); … … 480 407 } 481 408 482 return result;*/ 483 return false; 409 return result; 484 410 } 485 411 … … 491 417 string tmp_path = getCachePath() + m_pConfigRom->getGuidString(); 492 418 493 // the following piece should do something like 'mkdir -p some/path/with/some/dirs/which/do/not/exist' 419 // the following piece should do something like 420 // 'mkdir -p some/path/with/some/dirs/which/do/not/exist' 494 421 vector<string> tokens; 495 422 tokenize( tmp_path, tokens, "/" ); … … 499 426 ++it ) 500 427 { 501 if ( path == "" ) { 502 if ( *it == "~" ) 503 path = getenv( "HOME" ); 504 else 505 path = *it; 506 } else { 507 path = path + "/" + *it; 508 } 428 path += "/" + *it; 509 429 510 430 struct stat buf; trunk/libffado/src/bebob/bebob_avdevice.h
r584 r630 87 87 88 88 public: 89 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 90 static AvDevice* deserialize( Glib::ustring basePath, 91 Util::IODeserialize& deser, 92 Ieee1394Service& ieee1394Service ); 89 virtual bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 90 virtual bool deserialize( Glib::ustring basePath, Util::IODeserialize& deser ); 91 93 92 int getConfigurationIdSampleRate(); 94 93 int getConfigurationIdNumberOfChannel( AVC::PlugAddress::EPlugDirection ePlugDirection ); trunk/libffado/src/genericavc/avc_avdevice.cpp
r612 r630 96 96 unsigned int vendorId = m_pConfigRom->getNodeVendorId(); 97 97 unsigned int modelId = m_pConfigRom->getModelId(); 98 98 99 99 GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_genericavc.txt" ); 100 100 if ( vendorModel.parse() ) { 101 101 m_model = vendorModel.find( vendorId, modelId ); 102 102 } 103 103 104 104 if (!GenericAVC::VendorModel::isValid(m_model)) { 105 105 return false; … … 591 591 } 592 592 593 } 593 bool 594 AvDevice::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 595 { 596 bool result; 597 result = AVC::Unit::serialize( basePath, ser ); 598 result &= serializeOptions( basePath + "Options", ser ); 599 return result; 600 } 601 602 bool 603 AvDevice::deserialize( Glib::ustring basePath, Util::IODeserialize& deser ) 604 { 605 bool result; 606 result = AVC::Unit::deserialize( basePath, deser ); 607 return result; 608 } 609 610 } trunk/libffado/src/genericavc/avc_avdevice.h
r607 r630 54 54 virtual bool discover(); 55 55 static FFADODevice * createDevice( Ieee1394Service& ieee1394Service, 56 std::auto_ptr<ConfigRom>( configRom )); 57 56 std::auto_ptr<ConfigRom>( configRom )); 57 58 virtual bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 59 virtual bool deserialize( Glib::ustring basePath, Util::IODeserialize& deser ); 60 58 61 virtual void setVerboseLevel(int l); 59 62 virtual void showDevice(); … … 71 74 virtual bool startStreamByIndex(int i); 72 75 virtual bool stopStreamByIndex(int i); 73 76 74 77 // redefinition to resolve ambiguity 75 78 virtual Ieee1394Service& get1394Service() 76 79 { return FFADODevice::get1394Service(); }; 77 virtual ConfigRom& getConfigRom() const 80 virtual ConfigRom& getConfigRom() const 78 81 { return FFADODevice::getConfigRom(); }; 79 82 80 83 protected: 81 84 virtual bool addPlugToProcessor( AVC::Plug& plug, Streaming::StreamProcessor *processor, … … 84 87 AVC::Plug::EPlugDirection direction, 85 88 AVC::ESamplingFrequency samplingFrequency );*/ 86 89 87 90 struct VendorModelEntry m_model; 88 91 89 92 // streaming stuff 90 93 typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector; 91 94 StreamProcessorVector m_receiveProcessors; 92 95 StreamProcessorVector m_transmitProcessors; 93 96 94 97 DECLARE_DEBUG_MODULE; 95 98 }; trunk/libffado/src/libavc/general/avc_unit.cpp
r618 r630 103 103 } 104 104 105 Subunit* 105 Subunit* 106 106 Unit::createSubunit(Unit& unit, 107 107 ESubunitType type, 108 subunit_t id ) 108 subunit_t id ) 109 109 { 110 110 Subunit* s=NULL; … … 222 222 return false; 223 223 } 224 224 225 225 subunit->setVerboseLevel(getDebugLevel()); 226 226 227 227 if ( !subunit->discover() ) { 228 228 debugError( "enumerateSubUnits: Could not discover " … … 236 236 m_subunits.push_back( subunit ); 237 237 } 238 238 239 239 break; 240 240 case eST_Music: … … 244 244 return false; 245 245 } 246 246 247 247 subunit->setVerboseLevel(getDebugLevel()); 248 248 249 249 if ( !subunit->discover() ) { 250 250 debugError( "enumerateSubUnits: Could not discover " … … 633 633 634 634 } 635 635 636 636 PlugVector syncExternalInputPlugs = getPlugsByType( m_externalPlugs, 637 637 Plug::eAPD_Input, … … 809 809 } 810 810 811 template <typename T> bool serializeVector( Glib::ustring path, 812 Util::IOSerialize& ser, 813 const T& vec ) 811 template <typename T> 812 bool 813 serializeVector( Glib::ustring path, 814 Util::IOSerialize& ser, 815 const T& vec ) 814 816 { 815 817 bool result = true; // if vec.size() == 0 … … 824 826 } 825 827 826 template <typename T, typename VT> bool deserializeVector( Glib::ustring path, 827 Util::IODeserialize& deser, 828 Unit& unit, 829 VT& vec ) 828 template <typename T, typename VT> 829 bool 830 deserializeVector( Glib::ustring path, 831 Util::IODeserialize& deser, 832 Unit& unit, 833 VT& vec ) 830 834 { 831 835 int i = 0; … … 850 854 bool 851 855 Unit::serializeSyncInfoVector( Glib::ustring basePath, 852 853 const SyncInfoVector& vec )856 Util::IOSerialize& ser, 857 const SyncInfoVector& vec ) const 854 858 { 855 859 bool result = true; … … 877 881 bool 878 882 Unit::deserializeSyncInfoVector( Glib::ustring basePath, 879 880 883 Util::IODeserialize& deser, 884 SyncInfoVector& vec ) 881 885 { 882 886 int i = 0; … … 933 937 bool 934 938 Unit::serialize( Glib::ustring basePath, 935 Util::IOSerialize& ser ) const 936 { 937 939 Util::IOSerialize& ser ) const 940 { 938 941 bool result; 939 942 result = ser.write( basePath + "m_verboseLevel_unit", getDebugLevel() ); 943 result &= serializeVector( basePath + "Subunit", ser, m_subunits ); 944 result &= serializeVector( basePath + "plugConnections", ser, m_plugConnections ); 940 945 result &= m_pPlugManager->serialize( basePath + "Plug", ser ); // serialize all av plugs 941 result &= serializeVector( basePath + "PlugConnection", ser, m_plugConnections ); 942 result &= serializeVector( basePath + "Subunit", ser, m_subunits ); 943 #warning this fails after the echoaudio merge 944 // result &= serializeSyncInfoVector( basePath + "SyncInfo", ser, m_syncInfos ); 945 946 result &= serializeSyncInfoVector( basePath + "SyncInfo", ser, m_syncInfos ); 947 946 948 int i = 0; 947 949 for ( SyncInfoVector::const_iterator it = m_syncInfos.begin(); … … 962 964 bool 963 965 Unit::deserialize( Glib::ustring basePath, 964 Util::IODeserialize& deser, 965 Ieee1394Service& ieee1394Service ) 966 Util::IODeserialize& deser ) 966 967 { 967 968 bool result; 968 969 969 970 int verboseLevel; 970 971 result = deser.read( basePath + "m_verboseLevel_unit", verboseLevel ); 971 972 setDebugLevel( verboseLevel ); 972 973 if (m_pPlugManager) delete m_pPlugManager; 973 974 result &= deserializeVector<Subunit>( basePath + "Subunit", deser, *this, m_subunits ); 975 976 if (m_pPlugManager) 977 delete m_pPlugManager; 978 974 979 m_pPlugManager = PlugManager::deserialize( basePath + "Plug", deser, *this ); 975 if ( !m_pPlugManager ) { 976 return false;977 }978 980 981 if ( !m_pPlugManager ) 982 return false; 983 979 984 result &= deserializePlugUpdateConnections( basePath + "Plug", deser, m_pcrPlugs ); 980 985 result &= deserializePlugUpdateConnections( basePath + "Plug", deser, m_externalPlugs ); … … 983 988 result &= deserializeSyncInfoVector( basePath + "SyncInfo", deser, m_syncInfos ); 984 989 985 986 990 unsigned int i; 987 991 result &= deser.read( basePath + "m_activeSyncInfo", i ); trunk/libffado/src/libavc/general/avc_unit.h
r560 r630 60 60 /// Returns the ConfigRom 61 61 virtual ConfigRom& getConfigRom() const = 0; 62 62 63 63 /// Discovers the unit's internals 64 64 virtual bool discover(); … … 90 90 virtual const SyncInfo* getActiveSyncInfo() const 91 91 { return m_activeSyncInfo; } 92 92 93 93 virtual bool setActiveSync( const SyncInfo& syncInfo ); 94 94 95 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 96 bool deserialize( Glib::ustring basePath, 97 Util::IODeserialize& deser, 98 Ieee1394Service& ieee1394Service ); 95 virtual bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 96 virtual bool deserialize( Glib::ustring basePath, Util::IODeserialize& deser ); 97 99 98 SubunitAudio* getAudioSubunit( subunit_id_t subunitId ) 100 99 { return dynamic_cast<SubunitAudio*>( … … 133 132 std::string syncDescription ); 134 133 virtual Plug* getSyncPlug( int maxPlugId, Plug::EPlugDirection ); 135 134 136 135 unsigned int getNrOfSubunits( subunit_type_t subunitType ) const; 137 136 PlugConnection* getPlugConnection( Plug& srcPlug ) const; … … 152 151 153 152 bool serializeSyncInfoVector( Glib::ustring basePath, 154 155 const SyncInfoVector& vec );153 Util::IOSerialize& ser, 154 const SyncInfoVector& vec ) const; 156 155 bool deserializeSyncInfoVector( Glib::ustring basePath, 157 158 156 Util::IODeserialize& deser, 157 SyncInfoVector& vec ); 159 158 protected: 160 159 SubunitVector m_subunits; trunk/libffado/src/libutil/cmd_serialize.cpp
r618 r630 41 41 CoutSerializer::write( byte_t d, const char* name ) 42 42 { 43 debugOutput( DEBUG_LEVEL_NORMAL, " %3d: 0x%02x % 40s\n", m_cnt, d, name );43 debugOutput( DEBUG_LEVEL_NORMAL, " %3d: 0x%02x %-40.40s\n", m_cnt, d, name ); 44 44 m_cnt += sizeof( byte_t ); 45 45 … … 50 50 CoutSerializer::write( uint16_t d, const char* name ) 51 51 { 52 debugOutput( DEBUG_LEVEL_NORMAL, " %3d: 0x%04x % 40s\n", m_cnt, d, name );52 debugOutput( DEBUG_LEVEL_NORMAL, " %3d: 0x%04x %-40.40s\n", m_cnt, d, name ); 53 53 m_cnt += sizeof( uint16_t ); 54 54 … … 59 59 CoutSerializer::write( quadlet_t d, const char* name ) 60 60 { 61 debugOutput( DEBUG_LEVEL_NORMAL, " %3d: 0x%08x % 40s\n", m_cnt, d, name );61 debugOutput( DEBUG_LEVEL_NORMAL, " %3d: 0x%08x %-40.40s\n", m_cnt, d, name ); 62 62 m_cnt += sizeof( quadlet_t ); 63 63 return true; … … 67 67 CoutSerializer::write( const char * v, size_t len, const char* name ) 68 68 { 69 debugOutput( DEBUG_LEVEL_NORMAL, " %3d: %s % 40s\n", m_cnt, v, name );69 debugOutput( DEBUG_LEVEL_NORMAL, " %3d: %s %-40.40s\n", m_cnt, v, name ); 70 70 m_cnt += len; 71 71 return true; … … 145 145 byte_t hi = (value & 0xFF00) >> 8; 146 146 byte_t lo = value & 0xFF; 147 147 148 148 bool result = false; 149 149 if ( isCurPosValid() ) {