Show
Ignore:
Timestamp:
08/24/07 08:09:49 (17 years ago)
Author:
ppalmers
Message:

- Sort the FFADODevice vector on GUID before assigning device id's

This results in the same device id for identical device setups,
independent of the way they are connected or the node numbers they
have been assigned.

- Sanitized debug message reporting a bit
- Cosmetic changes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/bebob/bebob_avdevice.cpp

    r557 r560  
    9999} 
    100100 
     101void 
     102AvDevice::showDevice() 
     103{ 
     104    debugOutput(DEBUG_LEVEL_NORMAL, "Device is a BeBoB device\n"); 
     105    GenericAVC::AvDevice::showDevice(); 
     106    flushDebugOutput(); 
     107} 
     108 
    101109AVC::Subunit* 
    102110AvDevice::createSubunit(AVC::Unit& unit, 
    103                                AVC::ESubunitType type, 
    104                                AVC::subunit_t id ) 
    105 
     111                        AVC::ESubunitType type, 
     112                        AVC::subunit_t id ) 
     113
     114    AVC::Subunit* s=NULL; 
    106115    switch (type) { 
    107         case AVC::eST_Audio: 
    108             return new BeBoB::SubunitAudio(unit, id ); 
    109         case AVC::eST_Music: 
    110             return new BeBoB::SubunitMusic(unit, id ); 
     116        case eST_Audio: 
     117            s=new BeBoB::SubunitAudio(unit, id ); 
     118            break; 
     119        case eST_Music: 
     120            s=new BeBoB::SubunitMusic(unit, id ); 
     121            break; 
    111122        default: 
    112             return NULL; 
    113     } 
    114 
     123            s=NULL; 
     124            break; 
     125    } 
     126    if(s) s->setVerboseLevel(getDebugLevel()); 
     127    return s; 
     128
     129 
    115130 
    116131AVC::Plug * 
    117132AvDevice::createPlug( AVC::Unit* unit, 
    118                      AVC::Subunit* subunit, 
    119                      AVC::function_block_type_t functionBlockType, 
    120                      AVC::function_block_type_t functionBlockId, 
    121                      AVC::Plug::EPlugAddressType plugAddressType, 
    122                      AVC::Plug::EPlugDirection plugDirection, 
    123                      AVC::plug_id_t plugId ) 
    124 
    125  
    126     return new BeBoB::Plug( unit, 
    127                      subunit, 
    128                      functionBlockType, 
    129                      functionBlockId, 
    130                      plugAddressType, 
    131                      plugDirection, 
    132                      plugId ); 
     133                      AVC::Subunit* subunit, 
     134                      AVC::function_block_type_t functionBlockType, 
     135                      AVC::function_block_type_t functionBlockId, 
     136                      AVC::Plug::EPlugAddressType plugAddressType, 
     137                      AVC::Plug::EPlugDirection plugDirection, 
     138                      AVC::plug_id_t plugId ) 
     139
     140 
     141    Plug *p= new BeBoB::Plug( unit, 
     142                              subunit, 
     143                              functionBlockType, 
     144                              functionBlockId, 
     145                              plugAddressType, 
     146                              plugDirection, 
     147                              plugId ); 
     148    if (p) p->setVerboseLevel(getDebugLevel()); 
     149    return p; 
    133150} 
    134151 
  • trunk/libffado/src/bebob/bebob_avdevice.h

    r556 r560  
    7979                                   AVC::plug_id_t plugId ); 
    8080 
     81    virtual void showDevice(); 
    8182protected: 
    8283    virtual bool propagatePlugInfo(); 
  • trunk/libffado/src/devicemanager.cpp

    r557 r560  
    6868#include <sstream> 
    6969 
     70#include <algorithm> 
     71 
    7072using namespace std; 
    7173 
     
    101103DeviceManager::setVerboseLevel(int l) 
    102104{ 
    103     debugOutput( DEBUG_LEVEL_NORMAL, "Setting verbose level to %d...\n", l ); 
     105    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 
    104106    setDebugLevel(l); 
    105107 
     
    113115    { 
    114116        (*it)->setVerboseLevel(l); 
     117    } 
     118} 
     119 
     120void 
     121DeviceManager::show() { 
     122    debugOutput(DEBUG_LEVEL_NORMAL, "===== Device Manager =====\n"); 
     123    if (m_1394Service) debugOutput(DEBUG_LEVEL_NORMAL, "1394 port: %d\n", m_1394Service->getPort()); 
     124 
     125    int i=0; 
     126    for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
     127        it != m_avDevices.end(); 
     128        ++it ) 
     129    { 
     130        FFADODevice* avDevice = *it; 
     131        debugOutput(DEBUG_LEVEL_NORMAL, "--- Device %2d ---\n", i++); 
     132        avDevice->showDevice(); 
    115133    } 
    116134} 
     
    233251                             nodeId ); 
    234252 
     253                avDevice->setVerboseLevel( getDebugLevel() ); 
    235254                bool isFromCache = false; 
    236255                if ( avDevice->loadFromCache() ) { 
     
    239258                } else if ( avDevice->discover() ) { 
    240259                    debugOutput( DEBUG_LEVEL_VERBOSE, "discovering successful\n" ); 
    241                     avDevice->setVerboseLevel( getDebugLevel() ); 
    242260                } else { 
    243261                    debugError( "could not discover device\n" ); 
    244262                    delete avDevice; 
    245263                    continue; 
    246                 } 
    247  
    248                 if ( !avDevice->setId( m_avDevices.size() ) ) { 
    249                     debugError( "setting Id failed\n" ); 
    250264                } 
    251265 
     
    261275                } 
    262276 
    263                 if ( getDebugLevel() >= DEBUG_LEVEL_VERBOSE ) { 
    264                     avDevice->showDevice(); 
    265                 } 
    266  
    267277                if ( !isFromCache && !avDevice->saveCache() ) { 
    268278                    debugOutput( DEBUG_LEVEL_VERBOSE, "No cached version of AVC model created\n" ); 
     
    280290        } 
    281291 
    282         debugOutput( DEBUG_LEVEL_NORMAL, "discovery finished...\n" ); 
    283  
     292        debugOutput( DEBUG_LEVEL_NORMAL, "Discovery finished...\n" ); 
     293 
     294        // sort the m_avDevices vector on their GUID 
     295        // then assign reassign the id's to the devices 
     296        // the side effect of this is that for the same set of attached devices, 
     297        // a device id always corresponds to the same device 
     298        sort(m_avDevices.begin(), m_avDevices.end(), FFADODevice::compareGUID); 
     299         
     300        int i=0; 
     301        for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
     302            it != m_avDevices.end(); 
     303            ++it ) 
     304        { 
     305            if ( !(*it)->setId( i++ ) ) { 
     306                debugError( "setting Id failed\n" ); 
     307            } 
     308        } 
     309 
     310        show(); 
    284311        return true; 
    285312 
  • trunk/libffado/src/devicemanager.h

    r554 r560  
    7171    Streaming::StreamProcessor *getSyncSource(); 
    7272 
     73    void show(); 
     74 
    7375protected: 
    7476    FFADODevice* getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ), 
  • trunk/libffado/src/ffadodevice.cpp

    r554 r560  
    3131#include <sstream> 
    3232 
    33 IMPL_DEBUG_MODULE( FFADODevice, FFADODevice, DEBUG_LEVEL_VERBOSE ); 
     33#include <assert.h> 
     34 
     35IMPL_DEBUG_MODULE( FFADODevice, FFADODevice, DEBUG_LEVEL_NORMAL ); 
    3436 
    3537FFADODevice::FFADODevice( std::auto_ptr< ConfigRom >( configRom ), 
     
    3941    , m_pConfigRom( configRom ) 
    4042    , m_p1394Service( &ieee1394service ) 
    41     , m_verboseLevel( DEBUG_LEVEL_NORMAL ) 
    4243    , m_nodeId ( nodeId ) 
    4344{ 
     
    5253} 
    5354 
     55bool FFADODevice::compareGUID( FFADODevice *a, FFADODevice *b ) { 
     56    assert(a); 
     57    assert(b); 
     58    return ConfigRom::compareGUID(a->getConfigRom(), b->getConfigRom()); 
     59} 
    5460 
    5561ConfigRom& 
     
    8086    debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str()); 
    8187 
    82      
    8388    retval=setOption("id",idstr.str()); 
    8489    if (retval) { 
     
    9196FFADODevice::setVerboseLevel(int l) 
    9297{ 
    93     m_verboseLevel=l
     98    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l )
    9499    setDebugLevel(l); 
    95 //     m_pConfigRom->setVerboseLevel(l); 
    96     m_p1394Service->setVerboseLevel(l); 
    97100} 
     101 
     102void 
     103FFADODevice::showDevice() 
     104{ 
     105    debugOutput(DEBUG_LEVEL_NORMAL, "Node...........: %d\n", getNodeId()); 
     106    debugOutput(DEBUG_LEVEL_NORMAL, "GUID...........: %s\n", getConfigRom().getGuidString().c_str()); 
     107     
     108    std::string id=std::string("dev? [none]"); 
     109    getOption("id", id); 
     110      
     111    debugOutput(DEBUG_LEVEL_NORMAL, "Assigned ID....: %s\n", id.c_str()); 
     112 
     113    flushDebugOutput(); 
     114} 
     115 
    98116 
    99117bool 
  • trunk/libffado/src/ffadodevice.h

    r554 r560  
    5353 
    5454    virtual ~FFADODevice() {}; 
     55 
     56     
     57    /** 
     58     * @brief Compares the GUID of two FFADODevices 
     59     * 
     60     * This function compares the GUID of two FFADODevices and returns true 
     61     * if the GUID of @ref a is larger than the GUID of @ref b . This is intended 
     62     * to be used with the STL sort() algorithm. 
     63     *  
     64     * Note that GUID's are converted to integers for this. 
     65     *  
     66     * @param a pointer to first FFADODevice 
     67     * @param b pointer to second FFADODevice 
     68     *  
     69     * @returns true if the GUID of @ref a is larger than the GUID of @ref b . 
     70     */ 
     71    static bool compareGUID( FFADODevice *a, FFADODevice *b ); 
    5572 
    5673    /// Returns the 1394 service of the FFADO device 
     
    134151     * device detected, and its configuration. 
    135152     */ 
    136     virtual void showDevice() = 0
     153    virtual void showDevice()
    137154 
    138155    /** 
     
    274291    std::auto_ptr<ConfigRom>( m_pConfigRom ); 
    275292    Ieee1394Service*          m_p1394Service; 
    276     int                       m_verboseLevel; 
    277293    int                       m_nodeId; 
    278294 
  • trunk/libffado/src/genericavc/avc_avdevice.cpp

    r548 r560  
    4848namespace GenericAVC { 
    4949 
    50 IMPL_DEBUG_MODULE( AvDevice, AvDevice, DEBUG_LEVEL_VERBOSE ); 
     50IMPL_DEBUG_MODULE( AvDevice, AvDevice, DEBUG_LEVEL_NORMAL ); 
    5151 
    5252// to define the supported devices 
     
    138138AvDevice::setVerboseLevel(int l) 
    139139{ 
     140    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 
     141 
    140142    m_pPlugManager->setVerboseLevel(l); 
    141143 
     
    251253AvDevice::showDevice() 
    252254{ 
    253     debugOutput(DEBUG_LEVEL_VERBOSE, 
    254         "%s %s at node %d\n", m_model->vendor_name, m_model->model_name, 
    255         m_nodeId); 
    256  
    257     m_pPlugManager->showPlugs(); 
     255    FFADODevice::showDevice(); 
     256     
     257    debugOutput(DEBUG_LEVEL_NORMAL, 
     258        "%s %s\n", m_model->vendor_name, m_model->model_name); 
     259 
     260    AVC::Unit::show(); 
    258261    flushDebugOutput(); 
    259262} 
  • trunk/libffado/src/libavc/general/avc_plug.cpp

    r554 r560  
    110110{ 
    111111    m_unit->getPlugManager().remPlug( *this ); 
     112} 
     113 
     114void 
     115Plug::setVerboseLevel(int l) 
     116{ 
     117    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 
     118    setDebugLevel(l); 
    112119} 
    113120 
     
    583590    signalSourceCmd.setCommandType( AVCCommand::eCT_Status ); 
    584591    signalSourceCmd.setVerbose( getDebugLevel() ); 
    585     signalSourceCmd.setVerbose( DEBUG_LEVEL_VERY_VERBOSE ); 
    586592 
    587593    if ( !signalSourceCmd.fire() ) { 
     
    19031909PlugManager::showPlugs() const 
    19041910{ 
     1911    if(getDebugLevel() < DEBUG_LEVEL_INFO) return; 
     1912 
    19051913    // \todo The information provided here could be better arranged. For a start it is ok, but 
    19061914    // there is room for improvement. Something for a lazy sunday afternoon (tip: maybe drink some 
  • trunk/libffado/src/libavc/general/avc_plug.h

    r548 r560  
    185185    ClusterInfoVector& getClusterInfos() 
    186186        { return m_clusterInfos; } 
    187          
    188     virtual void setVerboseLevel( int i )  
    189             {setDebugLevel(i);}; 
    190      
     187 
     188    virtual void setVerboseLevel( int i ); 
     189 
    191190// the discovery interface 
    192191// everything can be overloaded, or 
  • trunk/libffado/src/libavc/general/avc_subunit.cpp

    r554 r560  
    3838namespace AVC { 
    3939 
    40 IMPL_DEBUG_MODULE( Subunit, Subunit, DEBUG_LEVEL_VERBOSE ); 
     40IMPL_DEBUG_MODULE( Subunit, Subunit, DEBUG_LEVEL_NORMAL ); 
    4141 
    4242//////////////////////////////////////////// 
     
    6565    } 
    6666} 
     67 
     68void 
     69Subunit::setVerboseLevel(int l) 
     70{ 
     71    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 
     72    setDebugLevel(l); 
     73} 
     74 
    6775 
    6876Plug * 
     
    92100        return false; 
    93101    } 
    94  
    95102    return true; 
    96103} 
     
    99106Subunit::discoverPlugs() 
    100107{ 
     108    debugOutput(DEBUG_LEVEL_NORMAL, "Discovering plugs...\n"); 
     109     
    101110    PlugInfoCmd plugInfoCmd( getUnit().get1394Service(), 
    102111                             PlugInfoCmd::eSF_SerialBusIsochronousAndExternalPlug ); 
     
    112121    } 
    113122 
    114     debugOutput( DEBUG_LEVEL_NORMAL, "number of source plugs = %d\n", 
     123    debugOutput( DEBUG_LEVEL_VERBOSE, "number of source plugs = %d\n", 
    115124                 plugInfoCmd.m_sourcePlugs ); 
    116     debugOutput( DEBUG_LEVEL_NORMAL, "number of destination output " 
     125    debugOutput( DEBUG_LEVEL_VERBOSE, "number of destination output " 
    117126                 "plugs = %d\n", plugInfoCmd.m_destinationPlugs ); 
    118127 
     
    158167                                      plug_id_t plugMaxId ) 
    159168{ 
    160     debugOutput(DEBUG_LEVEL_NORMAL, "Discovering plugs...\n"); 
     169    debugOutput(DEBUG_LEVEL_VERBOSE, "Discovering plugs for direction %d...\n", plugDirection); 
    161170    for ( int plugIdx = 0; 
    162171          plugIdx < plugMaxId; 
     
    182191        } 
    183192 
    184         debugOutput( DEBUG_LEVEL_NORMAL, "plug '%s' found\n", 
     193        debugOutput( DEBUG_LEVEL_VERBOSE, "plug '%s' found\n", 
    185194                     plug->getName() ); 
    186195        getPlugs().push_back( plug ); 
  • trunk/libffado/src/libavc/general/avc_subunit.h

    r524 r560  
    7979    Plug* getPlug(Plug::EPlugDirection direction, plug_id_t plugId); 
    8080 
    81     virtual void setVerboseLevel(int l)  
    82         { setDebugLevel(l);}; 
     81    virtual void setVerboseLevel(int l); 
    8382 
    8483    bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
  • trunk/libffado/src/libavc/general/avc_unit.cpp

    r554 r560  
    4444namespace AVC { 
    4545 
    46 IMPL_DEBUG_MODULE( Unit, Unit, DEBUG_LEVEL_VERBOSE ); 
     46IMPL_DEBUG_MODULE( Unit, Unit, DEBUG_LEVEL_NORMAL ); 
    4747 
    4848Unit::Unit( ) 
     
    8484Plug * 
    8585Unit::createPlug( Unit* unit, 
    86                      Subunit* subunit, 
    87                      function_block_type_t functionBlockType, 
    88                      function_block_type_t functionBlockId, 
    89                      Plug::EPlugAddressType plugAddressType, 
    90                      Plug::EPlugDirection plugDirection, 
    91                      plug_id_t plugId ) 
    92 
    93  
    94     return new Plug( unit, 
    95                      subunit, 
    96                      functionBlockType, 
    97                      functionBlockId, 
    98                      plugAddressType, 
    99                      plugDirection, 
    100                      plugId ); 
     86                  Subunit* subunit, 
     87                  function_block_type_t functionBlockType, 
     88                  function_block_type_t functionBlockId, 
     89                  Plug::EPlugAddressType plugAddressType, 
     90                  Plug::EPlugDirection plugDirection, 
     91                  plug_id_t plugId ) 
     92
     93 
     94    Plug *p= new Plug( unit, 
     95                       subunit, 
     96                       functionBlockType, 
     97                       functionBlockId, 
     98                       plugAddressType, 
     99                       plugDirection, 
     100                       plugId ); 
     101    if (p) p->setVerboseLevel(getDebugLevel()); 
     102    return p; 
    101103} 
    102104 
     
    106108                    subunit_t id )  
    107109{ 
     110    Subunit* s=NULL; 
    108111    switch (type) { 
    109112        case eST_Audio: 
    110             return new SubunitAudio(unit, id ); 
     113            s=new SubunitAudio(unit, id ); 
     114            break; 
    111115        case eST_Music: 
    112             return new SubunitMusic(unit, id ); 
     116            s=new SubunitMusic(unit, id ); 
     117            break; 
    113118        default: 
    114             return NULL; 
    115     } 
     119            s=NULL; 
     120            break; 
     121    } 
     122    if(s) s->setVerboseLevel(getDebugLevel()); 
     123    return s; 
    116124} 
    117125 
     
    119127Unit::setVerboseLevel(int l) 
    120128{ 
     129    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 
     130    setDebugLevel(l); 
     131    for ( SubunitVector::const_iterator it = m_subunits.begin(); 
     132          it != m_subunits.end(); 
     133          ++it ) 
     134    { 
     135        (*it)->setVerboseLevel(l); 
     136    } 
     137 
    121138    m_pPlugManager->setVerboseLevel(l); 
    122139} 
     
    368385                                plugDirection, 
    369386                                plugId ); 
     387 
     388        if( plug ) plug->setVerboseLevel(getDebugLevel()); 
     389 
    370390        if ( !plug || !plug->discover() ) { 
    371391            debugError( "plug discovering failed\n" ); 
     
    397417                                plugDirection, 
    398418                                plugId ); 
     419 
     420        if( plug ) plug->setVerboseLevel(getDebugLevel()); 
     421 
    399422        if ( !plug || !plug->discover() ) { 
    400423            debugError( "plug discovering failed\n" ); 
     
    767790 
    768791void 
    769 Unit::showDevice() 
     792Unit::show() 
    770793{ 
    771794    m_pPlugManager->showPlugs(); 
  • trunk/libffado/src/libavc/general/avc_unit.h

    r554 r560  
    5353 
    5454    virtual void setVerboseLevel(int l); 
    55     virtual void showDevice(); 
     55    virtual void show(); 
    5656 
    5757    // these have to be implemented by the parent class 
  • trunk/libffado/src/libieee1394/configrom.cpp

    r478 r560  
    122122{ 
    123123    return m_guid == rhs.m_guid; 
     124} 
     125 
     126bool 
     127ConfigRom::compareGUID( const ConfigRom& a, const ConfigRom& b ) { 
     128    return a.getGuid() > b.getGuid(); 
    124129} 
    125130 
  • trunk/libffado/src/libieee1394/configrom.h

    r478 r560  
    8080    bool updatedNodeId(); 
    8181    bool setNodeId( fb_nodeid_t nodeId ); 
     82     
     83    /** 
     84     * @brief Compares the GUID of two ConfigRom's 
     85     * 
     86     * This function compares the GUID of two ConfigRom objects and returns true 
     87     * if the GUID of @ref a is larger than the GUID of @ref b . This is intended 
     88     * to be used with the STL sort() algorithm. 
     89     *  
     90     * Note that GUID's are converted to integers for this. 
     91     *  
     92     * @param a pointer to first ConfigRom 
     93     * @param b pointer to second ConfigRom 
     94     *  
     95     * @returns true if the GUID of @ref a is larger than the GUID of @ref b . 
     96     */ 
     97    static bool compareGUID(  const ConfigRom& a, const ConfigRom& b ); 
    8298 
    8399    void printConfigRom() const; 
  • trunk/libffado/src/libieee1394/ieee1394service.cpp

    r445 r560  
    3838#include <iomanip> 
    3939 
    40 IMPL_DEBUG_MODULE( Ieee1394Service, Ieee1394Service, DEBUG_LEVEL_VERBOSE ); 
     40IMPL_DEBUG_MODULE( Ieee1394Service, Ieee1394Service, DEBUG_LEVEL_NORMAL ); 
    4141 
    4242Ieee1394Service::Ieee1394Service() 
     
    831831Ieee1394Service::setVerboseLevel(int l) 
    832832{ 
     833    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 
    833834    setDebugLevel(l); 
    834835} 
  • trunk/libffado/src/libosc/OscNode.cpp

    r461 r560  
    2929namespace OSC { 
    3030 
    31 IMPL_DEBUG_MODULE( OscNode, OscNode, DEBUG_LEVEL_VERBOSE ); 
     31IMPL_DEBUG_MODULE( OscNode, OscNode, DEBUG_LEVEL_NORMAL ); 
    3232 
    3333OscNode::OscNode() 
     
    6363void 
    6464OscNode::setVerboseLevel(int l) { 
     65    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 
    6566    setDebugLevel(l); 
    6667    for ( OscNodeVectorIterator it = m_ChildNodes.begin(); 
  • trunk/libffado/src/libosc/OscServer.cpp

    r462 r560  
    3333namespace OSC { 
    3434 
    35 IMPL_DEBUG_MODULE( OscServer, OscServer, DEBUG_LEVEL_VERBOSE ); 
     35IMPL_DEBUG_MODULE( OscServer, OscServer, DEBUG_LEVEL_NORMAL ); 
    3636 
    3737OscServer::OscServer(string port) 
     
    5050void 
    5151OscServer::setVerboseLevel(int l) { 
     52    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 
    5253    setDebugLevel(l); 
    5354    if (m_rootNode) m_rootNode->setVerboseLevel(l);