Index: /trunk/libffado/src/libieee1394/configrom.cpp =================================================================== --- /trunk/libffado/src/libieee1394/configrom.cpp (revision 478) +++ /trunk/libffado/src/libieee1394/configrom.cpp (revision 560) @@ -122,4 +122,9 @@ { return m_guid == rhs.m_guid; +} + +bool +ConfigRom::compareGUID( const ConfigRom& a, const ConfigRom& b ) { + return a.getGuid() > b.getGuid(); } Index: /trunk/libffado/src/libieee1394/configrom.h =================================================================== --- /trunk/libffado/src/libieee1394/configrom.h (revision 478) +++ /trunk/libffado/src/libieee1394/configrom.h (revision 560) @@ -80,4 +80,20 @@ bool updatedNodeId(); bool setNodeId( fb_nodeid_t nodeId ); + + /** + * @brief Compares the GUID of two ConfigRom's + * + * This function compares the GUID of two ConfigRom objects and returns true + * if the GUID of @ref a is larger than the GUID of @ref b . This is intended + * to be used with the STL sort() algorithm. + * + * Note that GUID's are converted to integers for this. + * + * @param a pointer to first ConfigRom + * @param b pointer to second ConfigRom + * + * @returns true if the GUID of @ref a is larger than the GUID of @ref b . + */ + static bool compareGUID( const ConfigRom& a, const ConfigRom& b ); void printConfigRom() const; Index: /trunk/libffado/src/libieee1394/ieee1394service.cpp =================================================================== --- /trunk/libffado/src/libieee1394/ieee1394service.cpp (revision 445) +++ /trunk/libffado/src/libieee1394/ieee1394service.cpp (revision 560) @@ -38,5 +38,5 @@ #include -IMPL_DEBUG_MODULE( Ieee1394Service, Ieee1394Service, DEBUG_LEVEL_VERBOSE ); +IMPL_DEBUG_MODULE( Ieee1394Service, Ieee1394Service, DEBUG_LEVEL_NORMAL ); Ieee1394Service::Ieee1394Service() @@ -831,4 +831,5 @@ Ieee1394Service::setVerboseLevel(int l) { + debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); setDebugLevel(l); } Index: /trunk/libffado/src/ffadodevice.cpp =================================================================== --- /trunk/libffado/src/ffadodevice.cpp (revision 554) +++ /trunk/libffado/src/ffadodevice.cpp (revision 560) @@ -31,5 +31,7 @@ #include -IMPL_DEBUG_MODULE( FFADODevice, FFADODevice, DEBUG_LEVEL_VERBOSE ); +#include + +IMPL_DEBUG_MODULE( FFADODevice, FFADODevice, DEBUG_LEVEL_NORMAL ); FFADODevice::FFADODevice( std::auto_ptr< ConfigRom >( configRom ), @@ -39,5 +41,4 @@ , m_pConfigRom( configRom ) , m_p1394Service( &ieee1394service ) - , m_verboseLevel( DEBUG_LEVEL_NORMAL ) , m_nodeId ( nodeId ) { @@ -52,4 +53,9 @@ } +bool FFADODevice::compareGUID( FFADODevice *a, FFADODevice *b ) { + assert(a); + assert(b); + return ConfigRom::compareGUID(a->getConfigRom(), b->getConfigRom()); +} ConfigRom& @@ -80,5 +86,4 @@ debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str()); - retval=setOption("id",idstr.str()); if (retval) { @@ -91,9 +96,22 @@ FFADODevice::setVerboseLevel(int l) { - m_verboseLevel=l; + debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); setDebugLevel(l); -// m_pConfigRom->setVerboseLevel(l); - m_p1394Service->setVerboseLevel(l); } + +void +FFADODevice::showDevice() +{ + debugOutput(DEBUG_LEVEL_NORMAL, "Node...........: %d\n", getNodeId()); + debugOutput(DEBUG_LEVEL_NORMAL, "GUID...........: %s\n", getConfigRom().getGuidString().c_str()); + + std::string id=std::string("dev? [none]"); + getOption("id", id); + + debugOutput(DEBUG_LEVEL_NORMAL, "Assigned ID....: %s\n", id.c_str()); + + flushDebugOutput(); +} + bool Index: /trunk/libffado/src/devicemanager.h =================================================================== --- /trunk/libffado/src/devicemanager.h (revision 554) +++ /trunk/libffado/src/devicemanager.h (revision 560) @@ -71,4 +71,6 @@ Streaming::StreamProcessor *getSyncSource(); + void show(); + protected: FFADODevice* getDriverForDevice( std::auto_ptr( configRom ), Index: /trunk/libffado/src/ffadodevice.h =================================================================== --- /trunk/libffado/src/ffadodevice.h (revision 554) +++ /trunk/libffado/src/ffadodevice.h (revision 560) @@ -53,4 +53,21 @@ virtual ~FFADODevice() {}; + + + /** + * @brief Compares the GUID of two FFADODevices + * + * This function compares the GUID of two FFADODevices and returns true + * if the GUID of @ref a is larger than the GUID of @ref b . This is intended + * to be used with the STL sort() algorithm. + * + * Note that GUID's are converted to integers for this. + * + * @param a pointer to first FFADODevice + * @param b pointer to second FFADODevice + * + * @returns true if the GUID of @ref a is larger than the GUID of @ref b . + */ + static bool compareGUID( FFADODevice *a, FFADODevice *b ); /// Returns the 1394 service of the FFADO device @@ -134,5 +151,5 @@ * device detected, and its configuration. */ - virtual void showDevice() = 0; + virtual void showDevice(); /** @@ -274,5 +291,4 @@ std::auto_ptr( m_pConfigRom ); Ieee1394Service* m_p1394Service; - int m_verboseLevel; int m_nodeId; Index: /trunk/libffado/src/libavc/general/avc_plug.cpp =================================================================== --- /trunk/libffado/src/libavc/general/avc_plug.cpp (revision 554) +++ /trunk/libffado/src/libavc/general/avc_plug.cpp (revision 560) @@ -110,4 +110,11 @@ { m_unit->getPlugManager().remPlug( *this ); +} + +void +Plug::setVerboseLevel(int l) +{ + debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); + setDebugLevel(l); } @@ -583,5 +590,4 @@ signalSourceCmd.setCommandType( AVCCommand::eCT_Status ); signalSourceCmd.setVerbose( getDebugLevel() ); - signalSourceCmd.setVerbose( DEBUG_LEVEL_VERY_VERBOSE ); if ( !signalSourceCmd.fire() ) { @@ -1903,4 +1909,6 @@ PlugManager::showPlugs() const { + if(getDebugLevel() < DEBUG_LEVEL_INFO) return; + // \todo The information provided here could be better arranged. For a start it is ok, but // there is room for improvement. Something for a lazy sunday afternoon (tip: maybe drink some Index: /trunk/libffado/src/libavc/general/avc_plug.h =================================================================== --- /trunk/libffado/src/libavc/general/avc_plug.h (revision 548) +++ /trunk/libffado/src/libavc/general/avc_plug.h (revision 560) @@ -185,8 +185,7 @@ ClusterInfoVector& getClusterInfos() { return m_clusterInfos; } - - virtual void setVerboseLevel( int i ) - {setDebugLevel(i);}; - + + virtual void setVerboseLevel( int i ); + // the discovery interface // everything can be overloaded, or Index: /trunk/libffado/src/libavc/general/avc_unit.cpp =================================================================== --- /trunk/libffado/src/libavc/general/avc_unit.cpp (revision 554) +++ /trunk/libffado/src/libavc/general/avc_unit.cpp (revision 560) @@ -44,5 +44,5 @@ namespace AVC { -IMPL_DEBUG_MODULE( Unit, Unit, DEBUG_LEVEL_VERBOSE ); +IMPL_DEBUG_MODULE( Unit, Unit, DEBUG_LEVEL_NORMAL ); Unit::Unit( ) @@ -84,19 +84,21 @@ Plug * Unit::createPlug( Unit* unit, - Subunit* subunit, - function_block_type_t functionBlockType, - function_block_type_t functionBlockId, - Plug::EPlugAddressType plugAddressType, - Plug::EPlugDirection plugDirection, - plug_id_t plugId ) -{ - - return new Plug( unit, - subunit, - functionBlockType, - functionBlockId, - plugAddressType, - plugDirection, - plugId ); + Subunit* subunit, + function_block_type_t functionBlockType, + function_block_type_t functionBlockId, + Plug::EPlugAddressType plugAddressType, + Plug::EPlugDirection plugDirection, + plug_id_t plugId ) +{ + + Plug *p= new Plug( unit, + subunit, + functionBlockType, + functionBlockId, + plugAddressType, + plugDirection, + plugId ); + if (p) p->setVerboseLevel(getDebugLevel()); + return p; } @@ -106,12 +108,18 @@ subunit_t id ) { + Subunit* s=NULL; switch (type) { case eST_Audio: - return new SubunitAudio(unit, id ); + s=new SubunitAudio(unit, id ); + break; case eST_Music: - return new SubunitMusic(unit, id ); + s=new SubunitMusic(unit, id ); + break; default: - return NULL; - } + s=NULL; + break; + } + if(s) s->setVerboseLevel(getDebugLevel()); + return s; } @@ -119,4 +127,13 @@ Unit::setVerboseLevel(int l) { + debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); + setDebugLevel(l); + for ( SubunitVector::const_iterator it = m_subunits.begin(); + it != m_subunits.end(); + ++it ) + { + (*it)->setVerboseLevel(l); + } + m_pPlugManager->setVerboseLevel(l); } @@ -368,4 +385,7 @@ plugDirection, plugId ); + + if( plug ) plug->setVerboseLevel(getDebugLevel()); + if ( !plug || !plug->discover() ) { debugError( "plug discovering failed\n" ); @@ -397,4 +417,7 @@ plugDirection, plugId ); + + if( plug ) plug->setVerboseLevel(getDebugLevel()); + if ( !plug || !plug->discover() ) { debugError( "plug discovering failed\n" ); @@ -767,5 +790,5 @@ void -Unit::showDevice() +Unit::show() { m_pPlugManager->showPlugs(); Index: /trunk/libffado/src/libavc/general/avc_unit.h =================================================================== --- /trunk/libffado/src/libavc/general/avc_unit.h (revision 554) +++ /trunk/libffado/src/libavc/general/avc_unit.h (revision 560) @@ -53,5 +53,5 @@ virtual void setVerboseLevel(int l); - virtual void showDevice(); + virtual void show(); // these have to be implemented by the parent class Index: /trunk/libffado/src/libavc/general/avc_subunit.cpp =================================================================== --- /trunk/libffado/src/libavc/general/avc_subunit.cpp (revision 554) +++ /trunk/libffado/src/libavc/general/avc_subunit.cpp (revision 560) @@ -38,5 +38,5 @@ namespace AVC { -IMPL_DEBUG_MODULE( Subunit, Subunit, DEBUG_LEVEL_VERBOSE ); +IMPL_DEBUG_MODULE( Subunit, Subunit, DEBUG_LEVEL_NORMAL ); //////////////////////////////////////////// @@ -65,4 +65,12 @@ } } + +void +Subunit::setVerboseLevel(int l) +{ + debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); + setDebugLevel(l); +} + Plug * @@ -92,5 +100,4 @@ return false; } - return true; } @@ -99,4 +106,6 @@ Subunit::discoverPlugs() { + debugOutput(DEBUG_LEVEL_NORMAL, "Discovering plugs...\n"); + PlugInfoCmd plugInfoCmd( getUnit().get1394Service(), PlugInfoCmd::eSF_SerialBusIsochronousAndExternalPlug ); @@ -112,7 +121,7 @@ } - debugOutput( DEBUG_LEVEL_NORMAL, "number of source plugs = %d\n", + debugOutput( DEBUG_LEVEL_VERBOSE, "number of source plugs = %d\n", plugInfoCmd.m_sourcePlugs ); - debugOutput( DEBUG_LEVEL_NORMAL, "number of destination output " + debugOutput( DEBUG_LEVEL_VERBOSE, "number of destination output " "plugs = %d\n", plugInfoCmd.m_destinationPlugs ); @@ -158,5 +167,5 @@ plug_id_t plugMaxId ) { - debugOutput(DEBUG_LEVEL_NORMAL, "Discovering plugs...\n"); + debugOutput(DEBUG_LEVEL_VERBOSE, "Discovering plugs for direction %d...\n", plugDirection); for ( int plugIdx = 0; plugIdx < plugMaxId; @@ -182,5 +191,5 @@ } - debugOutput( DEBUG_LEVEL_NORMAL, "plug '%s' found\n", + debugOutput( DEBUG_LEVEL_VERBOSE, "plug '%s' found\n", plug->getName() ); getPlugs().push_back( plug ); Index: /trunk/libffado/src/libavc/general/avc_subunit.h =================================================================== --- /trunk/libffado/src/libavc/general/avc_subunit.h (revision 524) +++ /trunk/libffado/src/libavc/general/avc_subunit.h (revision 560) @@ -79,6 +79,5 @@ Plug* getPlug(Plug::EPlugDirection direction, plug_id_t plugId); - virtual void setVerboseLevel(int l) - { setDebugLevel(l);}; + virtual void setVerboseLevel(int l); bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; Index: /trunk/libffado/src/genericavc/avc_avdevice.cpp =================================================================== --- /trunk/libffado/src/genericavc/avc_avdevice.cpp (revision 548) +++ /trunk/libffado/src/genericavc/avc_avdevice.cpp (revision 560) @@ -48,5 +48,5 @@ namespace GenericAVC { -IMPL_DEBUG_MODULE( AvDevice, AvDevice, DEBUG_LEVEL_VERBOSE ); +IMPL_DEBUG_MODULE( AvDevice, AvDevice, DEBUG_LEVEL_NORMAL ); // to define the supported devices @@ -138,4 +138,6 @@ AvDevice::setVerboseLevel(int l) { + debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); + m_pPlugManager->setVerboseLevel(l); @@ -251,9 +253,10 @@ AvDevice::showDevice() { - debugOutput(DEBUG_LEVEL_VERBOSE, - "%s %s at node %d\n", m_model->vendor_name, m_model->model_name, - m_nodeId); - - m_pPlugManager->showPlugs(); + FFADODevice::showDevice(); + + debugOutput(DEBUG_LEVEL_NORMAL, + "%s %s\n", m_model->vendor_name, m_model->model_name); + + AVC::Unit::show(); flushDebugOutput(); } Index: /trunk/libffado/src/bebob/bebob_avdevice.cpp =================================================================== --- /trunk/libffado/src/bebob/bebob_avdevice.cpp (revision 557) +++ /trunk/libffado/src/bebob/bebob_avdevice.cpp (revision 560) @@ -99,36 +99,53 @@ } +void +AvDevice::showDevice() +{ + debugOutput(DEBUG_LEVEL_NORMAL, "Device is a BeBoB device\n"); + GenericAVC::AvDevice::showDevice(); + flushDebugOutput(); +} + AVC::Subunit* AvDevice::createSubunit(AVC::Unit& unit, - AVC::ESubunitType type, - AVC::subunit_t id ) -{ + AVC::ESubunitType type, + AVC::subunit_t id ) +{ + AVC::Subunit* s=NULL; switch (type) { - case AVC::eST_Audio: - return new BeBoB::SubunitAudio(unit, id ); - case AVC::eST_Music: - return new BeBoB::SubunitMusic(unit, id ); + case eST_Audio: + s=new BeBoB::SubunitAudio(unit, id ); + break; + case eST_Music: + s=new BeBoB::SubunitMusic(unit, id ); + break; default: - return NULL; - } -} + s=NULL; + break; + } + if(s) s->setVerboseLevel(getDebugLevel()); + return s; +} + AVC::Plug * AvDevice::createPlug( AVC::Unit* unit, - AVC::Subunit* subunit, - AVC::function_block_type_t functionBlockType, - AVC::function_block_type_t functionBlockId, - AVC::Plug::EPlugAddressType plugAddressType, - AVC::Plug::EPlugDirection plugDirection, - AVC::plug_id_t plugId ) -{ - - return new BeBoB::Plug( unit, - subunit, - functionBlockType, - functionBlockId, - plugAddressType, - plugDirection, - plugId ); + AVC::Subunit* subunit, + AVC::function_block_type_t functionBlockType, + AVC::function_block_type_t functionBlockId, + AVC::Plug::EPlugAddressType plugAddressType, + AVC::Plug::EPlugDirection plugDirection, + AVC::plug_id_t plugId ) +{ + + Plug *p= new BeBoB::Plug( unit, + subunit, + functionBlockType, + functionBlockId, + plugAddressType, + plugDirection, + plugId ); + if (p) p->setVerboseLevel(getDebugLevel()); + return p; } Index: /trunk/libffado/src/bebob/bebob_avdevice.h =================================================================== --- /trunk/libffado/src/bebob/bebob_avdevice.h (revision 556) +++ /trunk/libffado/src/bebob/bebob_avdevice.h (revision 560) @@ -79,4 +79,5 @@ AVC::plug_id_t plugId ); + virtual void showDevice(); protected: virtual bool propagatePlugInfo(); Index: /trunk/libffado/src/devicemanager.cpp =================================================================== --- /trunk/libffado/src/devicemanager.cpp (revision 557) +++ /trunk/libffado/src/devicemanager.cpp (revision 560) @@ -68,4 +68,6 @@ #include +#include + using namespace std; @@ -101,5 +103,5 @@ DeviceManager::setVerboseLevel(int l) { - debugOutput( DEBUG_LEVEL_NORMAL, "Setting verbose level to %d...\n", l ); + debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); setDebugLevel(l); @@ -113,4 +115,20 @@ { (*it)->setVerboseLevel(l); + } +} + +void +DeviceManager::show() { + debugOutput(DEBUG_LEVEL_NORMAL, "===== Device Manager =====\n"); + if (m_1394Service) debugOutput(DEBUG_LEVEL_NORMAL, "1394 port: %d\n", m_1394Service->getPort()); + + int i=0; + for ( FFADODeviceVectorIterator it = m_avDevices.begin(); + it != m_avDevices.end(); + ++it ) + { + FFADODevice* avDevice = *it; + debugOutput(DEBUG_LEVEL_NORMAL, "--- Device %2d ---\n", i++); + avDevice->showDevice(); } } @@ -233,4 +251,5 @@ nodeId ); + avDevice->setVerboseLevel( getDebugLevel() ); bool isFromCache = false; if ( avDevice->loadFromCache() ) { @@ -239,13 +258,8 @@ } else if ( avDevice->discover() ) { debugOutput( DEBUG_LEVEL_VERBOSE, "discovering successful\n" ); - avDevice->setVerboseLevel( getDebugLevel() ); } else { debugError( "could not discover device\n" ); delete avDevice; continue; - } - - if ( !avDevice->setId( m_avDevices.size() ) ) { - debugError( "setting Id failed\n" ); } @@ -261,8 +275,4 @@ } - if ( getDebugLevel() >= DEBUG_LEVEL_VERBOSE ) { - avDevice->showDevice(); - } - if ( !isFromCache && !avDevice->saveCache() ) { debugOutput( DEBUG_LEVEL_VERBOSE, "No cached version of AVC model created\n" ); @@ -280,6 +290,23 @@ } - debugOutput( DEBUG_LEVEL_NORMAL, "discovery finished...\n" ); - + debugOutput( DEBUG_LEVEL_NORMAL, "Discovery finished...\n" ); + + // sort the m_avDevices vector on their GUID + // then assign reassign the id's to the devices + // the side effect of this is that for the same set of attached devices, + // a device id always corresponds to the same device + sort(m_avDevices.begin(), m_avDevices.end(), FFADODevice::compareGUID); + + int i=0; + for ( FFADODeviceVectorIterator it = m_avDevices.begin(); + it != m_avDevices.end(); + ++it ) + { + if ( !(*it)->setId( i++ ) ) { + debugError( "setting Id failed\n" ); + } + } + + show(); return true; Index: /trunk/libffado/src/libosc/OscNode.cpp =================================================================== --- /trunk/libffado/src/libosc/OscNode.cpp (revision 461) +++ /trunk/libffado/src/libosc/OscNode.cpp (revision 560) @@ -29,5 +29,5 @@ namespace OSC { -IMPL_DEBUG_MODULE( OscNode, OscNode, DEBUG_LEVEL_VERBOSE ); +IMPL_DEBUG_MODULE( OscNode, OscNode, DEBUG_LEVEL_NORMAL ); OscNode::OscNode() @@ -63,4 +63,5 @@ void OscNode::setVerboseLevel(int l) { + debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); setDebugLevel(l); for ( OscNodeVectorIterator it = m_ChildNodes.begin(); Index: /trunk/libffado/src/libosc/OscServer.cpp =================================================================== --- /trunk/libffado/src/libosc/OscServer.cpp (revision 462) +++ /trunk/libffado/src/libosc/OscServer.cpp (revision 560) @@ -33,5 +33,5 @@ namespace OSC { -IMPL_DEBUG_MODULE( OscServer, OscServer, DEBUG_LEVEL_VERBOSE ); +IMPL_DEBUG_MODULE( OscServer, OscServer, DEBUG_LEVEL_NORMAL ); OscServer::OscServer(string port) @@ -50,4 +50,5 @@ void OscServer::setVerboseLevel(int l) { + debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); setDebugLevel(l); if (m_rootNode) m_rootNode->setVerboseLevel(l);