Changeset 637

Show
Ignore:
Timestamp:
09/09/07 05:02:46 (16 years ago)
Author:
wagi
Message:

- some code cleanup (whitespace, unnecessary ';' removed, code indention, ...)
- loadFromCache: problem identified why it doesn't work. The PCPLugs and ExternaPlugs? in
AVC::Unit are not deserialized.

Files:

Legend:

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

    r630 r637  
    407407    } 
    408408 
     409    // XXX only for testing purpose here. Can be removed when loadFromCache works 
     410    AVC::Plug* inputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Input, 0 ); 
     411    if ( !inputPlug ) { 
     412        debugError( "loadFromCache: Could not retrieve iso input plug 0\n" ); 
     413    } 
     414 
    409415    return result; 
    410416} 
  • trunk/libffado/src/libavc/general/avc_plug.cpp

    r618 r637  
    124124Plug::getSubunitType() const 
    125125{ 
    126     return (m_subunit==NULL?eST_Unit:m_subunit->getSubunitType());  
    127 } 
    128  
    129 subunit_id_t  
     126    return (m_subunit==NULL?eST_Unit:m_subunit->getSubunitType()); 
     127} 
     128 
     129subunit_id_t 
    130130Plug::getSubunitId() const 
    131131{ 
     
    229229    // name already set 
    230230    if (m_name != "") return true; 
    231      
     231 
    232232    m_name = plugAddressTypeToString(getPlugAddressType()); 
    233233    m_name += " "; 
     
    256256Plug::discoverChannelName() 
    257257{ 
    258      
     258 
    259259    return true; 
    260260} 
     
    493493 
    494494    int sourcePlugGlobalId=getSignalSource(); 
    495      
     495 
    496496    if(sourcePlugGlobalId >= 0) { 
    497497        Plug *p=m_unit->getPlugManager().getPlug(sourcePlugGlobalId); 
     
    520520            return false; 
    521521        } 
    522              
     522 
    523523    } 
    524524 
     
    568568        } 
    569569    } 
    570      
     570 
    571571    if(getPlugAddressType() == eAPA_SubunitPlug) { 
    572572        if (getPlugDirection() != eAPD_Input) { 
     
    575575        } 
    576576    } 
    577      
     577 
    578578    SignalSourceCmd signalSourceCmd( m_unit->get1394Service() ); 
    579      
     579 
    580580    signalSourceCmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 
    581581    signalSourceCmd.setSubunitType( eST_Unit  ); 
     
    587587    signalSubunitAddr.m_plugId = 0xFE; 
    588588    signalSourceCmd.setSignalSource( signalSubunitAddr ); 
    589      
     589 
    590590    setDestPlugAddrToSignalCmd( signalSourceCmd, *this ); 
    591591 
     
    605605            SignalUnitAddress *usrc=dynamic_cast<SignalUnitAddress *>(src); 
    606606            if (usrc->m_plugId & 0x80) { 
    607                 p=m_unit->getPlugManager().getPlug( eST_Unit, 0xFF,  
    608                         0xFF, 0xFF, eAPA_ExternalPlug, eAPD_Input,  
     607                p=m_unit->getPlugManager().getPlug( eST_Unit, 0xFF, 
     608                        0xFF, 0xFF, eAPA_ExternalPlug, eAPD_Input, 
    609609                        usrc->m_plugId & 0x7F ); 
    610610            } else { 
    611                 p=m_unit->getPlugManager().getPlug( eST_Unit, 0xFF,  
    612                         0xFF, 0xFF, eAPA_PCR, eAPD_Input,  
     611                p=m_unit->getPlugManager().getPlug( eST_Unit, 0xFF, 
     612                        0xFF, 0xFF, eAPA_PCR, eAPD_Input, 
    613613                        usrc->m_plugId & 0x7F ); 
    614614            } 
    615615        } else if (dynamic_cast<SignalSubunitAddress *>(src)) { 
    616616            SignalSubunitAddress *susrc=dynamic_cast<SignalSubunitAddress *>(src); 
    617             p=m_unit->getPlugManager().getPlug( byteToSubunitType(susrc->m_subunitType),  
    618                     susrc->m_subunitId, 0xFF, 0xFF, eAPA_SubunitPlug,  
     617            p=m_unit->getPlugManager().getPlug( byteToSubunitType(susrc->m_subunitType), 
     618                    susrc->m_subunitId, 0xFF, 0xFF, eAPA_SubunitPlug, 
    619619                    eAPD_Output, susrc->m_plugId); 
    620620        } else return -1; 
    621          
     621 
    622622        if (p==NULL) { 
    623623            debugError("reported signal source plug not found\n"); 
    624624            return -1; 
    625625        } 
    626          
     626 
    627627        return p->getGlobalId(); 
    628628    } 
     
    657657} 
    658658 
    659 bool  
     659bool 
    660660Plug::propagateFromConnectedPlug( ) { 
    661661 
     
    668668            debugWarning("Too many input connections to propagate from, using first one.\n"); 
    669669        } 
    670          
     670 
    671671        Plug* p = *(getInputConnections().begin()); 
    672672        return propagateFromPlug( p ); 
    673          
     673 
    674674    } else if (getDirection() == eAPD_Input) { 
    675675        if (getOutputConnections().size()==0) { 
     
    680680            debugWarning("Too many output connections to propagate from, using first one.\n"); 
    681681        } 
    682          
     682 
    683683        Plug* p = *(getOutputConnections().begin()); 
    684684        return propagateFromPlug( p ); 
    685          
     685 
    686686    } else { 
    687687        debugWarning("plug with undefined direction\n"); 
     
    690690} 
    691691 
    692 bool  
     692bool 
    693693Plug::propagateFromPlug( Plug *p ) { 
    694694    debugOutput( DEBUG_LEVEL_VERBOSE, 
    695695                 "Propagating info from plug '%s' to plug '%s'\n", 
    696696                 p->getName(), getName() ); 
    697      
     697 
    698698    if (m_clusterInfos.size()==0) { 
    699699        m_clusterInfos=p->m_clusterInfos; 
    700700    } 
    701      
     701 
    702702    m_nrOfChannels=p->m_nrOfChannels; 
    703      
     703 
    704704    return true; 
    705705} 
     
    742742            cmd.m_fmt=0xFF; 
    743743            cmd.m_plug=getPlugId(); 
    744              
     744 
    745745            cmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 
    746746            cmd.setSubunitType( eST_Unit  ); 
    747747            cmd.setSubunitId( 0xff ); 
    748              
     748 
    749749            cmd.setCommandType( AVCCommand::eCT_Status ); 
    750750 
     
    753753                return 0; 
    754754            } 
    755              
     755 
    756756            if (cmd.m_fmt != 0x10 ) { 
    757757                debugWarning("Incorrect FMT response received: 0x%02X\n",cmd.m_fmt); 
    758758            } 
    759              
     759 
    760760            return fdfSfcToSampleRate(cmd.m_fdf[0]); 
    761              
     761 
    762762        } else if (getPlugDirection()==eAPD_Output) { 
    763763            OutputPlugSignalFormatCmd cmd( m_unit->get1394Service() ); 
     
    766766            cmd.m_fmt=0xFF; 
    767767            cmd.m_plug=getPlugId(); 
    768              
     768 
    769769            cmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 
    770770            cmd.setSubunitType( eST_Unit  ); 
    771771            cmd.setSubunitId( 0xff ); 
    772      
     772 
    773773            cmd.setCommandType( AVCCommand::eCT_Status ); 
    774              
     774 
    775775            if ( !cmd.fire() ) { 
    776776                debugError( "output plug signal format command failed\n" ); 
    777777                return 0; 
    778778            } 
    779              
     779 
    780780            if (cmd.m_fmt != 0x10 ) { 
    781781                debugWarning("Incorrect FMT response received: 0x%02X\n",cmd.m_fmt); 
    782782            } 
    783              
     783 
    784784            return fdfSfcToSampleRate(cmd.m_fdf[0]); 
    785          
     785 
    786786        } else { 
    787787            debugError("PCR plug with undefined direction.\n"); 
     
    789789        } 
    790790    } 
    791      
     791 
    792792    // fallback 
    793793    return convertESamplingFrequency( static_cast<ESamplingFrequency>( m_samplingFrequency ) ); 
     
    812812            cmd.setSubunitType( eST_Unit  ); 
    813813            cmd.setSubunitId( 0xff ); 
    814              
     814 
    815815            cmd.setCommandType( AVCCommand::eCT_Control ); 
    816816 
     
    835835            cmd.m_fdf[1]=0xFF; 
    836836            cmd.m_fdf[2]=0xFF; 
    837              
     837 
    838838            cmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 
    839839            cmd.setSubunitType( eST_Unit  ); 
    840840            cmd.setSubunitId( 0xff ); 
    841      
     841 
    842842            cmd.setCommandType( AVCCommand::eCT_Control ); 
    843              
     843 
    844844            if ( !cmd.fire() ) { 
    845845                debugError( "output plug signal format command failed\n" ); 
     
    860860    // fallback: BeBoB style 
    861861    ESamplingFrequency samplingFrequency = parseSampleRate(rate); 
    862      
     862 
    863863    ExtendedStreamFormatCmd extStreamFormatCmd( 
    864864        m_unit->get1394Service(), 
     
    10001000bool 
    10011001Plug::addPlugConnection( PlugVector& connections, 
    1002                            Plug& plug ) 
     1002                         Plug& plug ) 
    10031003 
    10041004{ 
     
    10601060void 
    10611061Plug::setDestPlugAddrToSignalCmd(SignalSourceCmd& signalSourceCmd, 
    1062                                    Plug& plug) 
     1062                                 Plug& plug) 
    10631063{ 
    10641064    switch( plug.getSubunitType() ) { 
     
    12281228                 getNrOfStreams() ); 
    12291229    debugOutput( DEBUG_LEVEL_VERBOSE, "\tIncoming connections from: "); 
    1230      
     1230 
    12311231    for ( PlugVector::const_iterator it = m_inputConnections.begin(); 
    12321232          it != m_inputConnections.end(); 
     
    12601260    function_block_type_t functionBlockType = 0xff; 
    12611261    function_block_id_t   functionBlockId   = 0xff; 
    1262     EPlugAddressType    addressType       = eAPA_Undefined; 
    1263     EPlugDirection      direction         = eAPD_Unknown; 
     1262    EPlugAddressType      addressType       = eAPA_Undefined; 
     1263    EPlugDirection        direction         = eAPD_Unknown; 
    12641264    plug_id_t             plugId            = 0xff; 
    12651265 
     
    13961396bool 
    13971397Plug::serializeChannelInfos( Glib::ustring basePath, 
    1398                                Util::IOSerialize& ser, 
    1399                                const ClusterInfo& clusterInfo ) const 
     1398                             Util::IOSerialize& ser, 
     1399                             const ClusterInfo& clusterInfo ) const 
    14001400{ 
    14011401    bool result = true; 
     
    14191419bool 
    14201420Plug::deserializeChannelInfos( Glib::ustring basePath, 
    1421                                  Util::IODeserialize& deser, 
    1422                                  ClusterInfo& clusterInfo ) 
     1421                               Util::IODeserialize& deser, 
     1422                               ClusterInfo& clusterInfo ) 
    14231423{ 
    14241424    int i = 0; 
     
    14551455bool 
    14561456Plug::serializeClusterInfos( Glib::ustring basePath, 
    1457                                Util::IOSerialize& ser ) const 
     1457                             Util::IOSerialize& ser ) const 
    14581458{ 
    14591459    bool result = true; 
     
    14811481bool 
    14821482Plug::deserializeClusterInfos( Glib::ustring basePath, 
    1483                                  Util::IODeserialize& deser ) 
     1483                               Util::IODeserialize& deser ) 
    14841484{ 
    14851485    int i = 0; 
     
    15191519bool 
    15201520Plug::serializeFormatInfos( Glib::ustring basePath, 
    1521                               Util::IOSerialize& ser ) const 
     1521                            Util::IOSerialize& ser ) const 
    15221522{ 
    15231523    bool result = true; 
     
    15421542bool 
    15431543Plug::deserializeFormatInfos( Glib::ustring basePath, 
    1544                                 Util::IODeserialize& deser ) 
     1544                              Util::IODeserialize& deser ) 
    15451545{ 
    15461546    int i = 0; 
     
    15791579bool 
    15801580Plug::serializePlugVector( Glib::ustring basePath, 
    1581                                Util::IOSerialize& ser, 
    1582                                const PlugVector& vec) const 
     1581                           Util::IOSerialize& ser, 
     1582                           const PlugVector& vec) const 
    15831583{ 
    15841584    bool result = true; 
     
    16001600bool 
    16011601Plug::deserializePlugVector( Glib::ustring basePath, 
    1602                                  Util::IODeserialize& deser, 
    1603                                  PlugVector& vec ) 
     1602                             Util::IODeserialize& deser, 
     1603                             PlugVector& vec ) 
    16041604{ 
    16051605    int i = 0; 
     
    16641664Plug* 
    16651665Plug::deserialize( Glib::ustring basePath, 
    1666                      Util::IODeserialize& deser, 
    1667                      Unit& unit, 
    1668                      PlugManager& plugManager ) 
     1666                   Util::IODeserialize& deser, 
     1667                   Unit& unit, 
     1668                   PlugManager& plugManager ) 
    16691669{ 
    16701670    #warning FIXME: The derived class should be creating these 
     
    16801680 
    16811681    pPlug->m_unit = &unit; 
    1682      
     1682 
    16831683    bool result=true; 
    1684      
     1684 
    16851685    ESubunitType subunitType; 
    16861686    result  = deser.read( basePath + "m_subunitType", subunitType ); 
     
    16881688    result &= deser.read( basePath + "m_subunitId", subunitId ); 
    16891689    pPlug->m_subunit = unit.getSubunit( subunitType, subunitType ); 
    1690      
     1690 
    16911691    result &= deser.read( basePath + "m_functionBlockType", pPlug->m_functionBlockType ); 
    16921692    result &= deser.read( basePath + "m_functionBlockId", pPlug->m_functionBlockId ); 
     
    18641864        } 
    18651865        plug->getInputConnections().clear(); 
    1866          
     1866 
    18671867        for ( PlugVector::const_iterator it = 
    18681868                  plug->getOutputConnections().begin(); 
     
    18741874        plug->getOutputConnections().clear(); 
    18751875    } 
    1876      
     1876 
    18771877    for ( PlugConnectionVector::iterator it = connections.begin(); 
    18781878          it != connections.end(); 
     
    18841884 
    18851885    } 
    1886      
     1886 
    18871887    return true; 
    18881888} 
     
    20022002                    strstrm << plug->getFunctionBlockType(); 
    20032003            } 
    2004              
     2004 
    20052005            if ( plug->getPlugDirection() == Plug::eAPD_Input ) { 
    20062006                printf( "\t\"(%d) %s\" -> \"(%s, ID %d)\"\n", 
     
    20572057Plug* 
    20582058PlugManager::getPlug( ESubunitType subunitType, 
    2059                         subunit_id_t subunitId, 
    2060                         function_block_type_t functionBlockType, 
    2061                         function_block_id_t functionBlockId, 
    2062                         Plug::EPlugAddressType plugAddressType, 
    2063                         Plug::EPlugDirection plugDirection, 
    2064                         plug_id_t plugId ) const 
     2059                      subunit_id_t subunitId, 
     2060                      function_block_type_t functionBlockType, 
     2061                      function_block_id_t functionBlockId, 
     2062                      Plug::EPlugAddressType plugAddressType, 
     2063                      Plug::EPlugDirection plugDirection, 
     2064                      plug_id_t plugId ) const 
    20652065{ 
    20662066    debugOutput( DEBUG_LEVEL_VERBOSE, "SBT, SBID, FBT, FBID, AT, PD, ID = " 
     
    21132113PlugVector 
    21142114PlugManager::getPlugsByType( ESubunitType subunitType, 
    2115                                subunit_id_t subunitId, 
    2116                                function_block_type_t functionBlockType, 
    2117                                function_block_id_t functionBlockId, 
    2118                                Plug::EPlugAddressType plugAddressType, 
    2119                                Plug::EPlugDirection plugDirection, 
    2120                                Plug::EPlugType type) const 
     2115                             subunit_id_t subunitId, 
     2116                             function_block_type_t functionBlockType, 
     2117                             function_block_id_t functionBlockId, 
     2118                             Plug::EPlugAddressType plugAddressType, 
     2119                             Plug::EPlugDirection plugDirection, 
     2120                             Plug::EPlugType type) const 
    21212121{ 
    21222122    debugOutput( DEBUG_LEVEL_VERBOSE, "SBT, SBID, FBT, FBID, AT, PD, T = " 
     
    21732173PlugManager* 
    21742174PlugManager::deserialize( Glib::ustring basePath, 
    2175                             Util::IODeserialize& deser, 
    2176                             Unit& unit ) 
     2175                          Util::IODeserialize& deser, 
     2176                          Unit& unit ) 
    21772177 
    21782178{ 
     
    21912191        // therefore we have to *this as additional argument 
    21922192        Plug* pPlug = Plug::deserialize( strstrm.str() + "/", 
    2193                                              deser, 
    2194                                              unit, 
    2195                                              *pMgr ); 
     2193                                         deser, 
     2194                                         unit, 
     2195                                         *pMgr ); 
    21962196        if ( pPlug ) { 
    21972197            pMgr->m_plugs.push_back( pPlug ); 
  • trunk/libffado/src/libavc/general/avc_plug.h

    r560 r637  
    106106    ESubunitType getSubunitType() const; 
    107107    subunit_id_t getSubunitId() const; 
    108      
     108 
    109109    const char* getName() const 
    110110        { return m_name.c_str(); } 
    111111    bool setName(const char *n) 
    112         { m_name=n; return true;}; 
     112        { m_name=n; return true; } 
    113113    bool setName(std::string n) 
    114         { m_name=n; return true;}; 
     114        { m_name=n; return true; } 
    115115    EPlugDirection getPlugDirection() const 
    116116        { return m_direction; } 
     
    121121    int getSampleRate() const; // 22050, 24000, 32000, ... 
    122122    bool setSampleRate( int rate ); 
    123      
     123 
    124124    int getNrOfChannels() const; 
    125125    bool setNrOfChannels(int i); 
     
    157157    bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
    158158    static Plug* deserialize( Glib::ustring basePath, 
    159                                 Util::IODeserialize& deser, 
    160                                 Unit& avDevice, 
    161                                 PlugManager& plugManager ); 
     159                              Util::IODeserialize& deser, 
     160                              Unit& avDevice, 
     161                              PlugManager& plugManager ); 
    162162 
    163163    bool deserializeUpdate( Glib::ustring basePath, 
     
    195195    virtual bool discoverConnections(); 
    196196    virtual bool propagateFromConnectedPlug( ); 
    197      
     197 
    198198protected: 
    199199    virtual bool discoverPlugType(); 
     
    258258 
    259259    bool serializePlugVector( Glib::ustring basePath, 
    260                                 Util::IOSerialize& ser, 
    261                                 const PlugVector& vec) const; 
     260                              Util::IOSerialize& ser, 
     261                              const PlugVector& vec) const; 
    262262    bool deserializePlugVector( Glib::ustring basePath, 
    263                                   Util::IODeserialize& deser, 
    264                                   PlugVector& vec ); 
     263                                Util::IODeserialize& deser, 
     264                                PlugVector& vec ); 
    265265 
    266266protected: 
     
    320320    void showPlugs() const; 
    321321 
    322     int getPlugCount()  
     322    int getPlugCount() 
    323323        { return m_plugs.size(); }; 
    324324 
     
    332332    Plug* getPlug( int iGlobalId ) const; 
    333333    PlugVector getPlugsByType( ESubunitType subunitType, 
    334                  subunit_id_t subunitId, 
    335                  function_block_type_t functionBlockType, 
    336                  function_block_id_t functionBlockId, 
    337                  Plug::EPlugAddressType plugAddressType, 
    338                  Plug::EPlugDirection plugDirection, 
    339                  Plug::EPlugType type) const; 
     334                              subunit_id_t subunitId, 
     335                              function_block_type_t functionBlockType, 
     336                              function_block_id_t functionBlockId, 
     337                              Plug::EPlugAddressType plugAddressType, 
     338                              Plug::EPlugDirection plugDirection, 
     339                              Plug::EPlugType type) const; 
    340340 
    341341    bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
    342342    static  PlugManager* deserialize( Glib::ustring basePath, 
    343                                         Util::IODeserialize& deser, 
    344                                         Unit& avDevice ); 
    345     void setVerboseLevel( int i )  
    346             {setDebugLevel(i);}; 
    347     PlugVector& getPlugs() {return m_plugs;}; 
     343                                      Util::IODeserialize& deser, 
     344                                      Unit& avDevice ); 
     345    void setVerboseLevel( int i ) 
     346        { setDebugLevel(i); } 
     347    PlugVector& getPlugs() 
     348        { return m_plugs; } 
    348349    bool tidyPlugConnections(PlugConnectionVector&); 
    349350 
     
    366367    bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
    367368    static PlugConnection* deserialize( Glib::ustring basePath, 
    368                                           Util::IODeserialize& deser, 
    369                                           Unit& avDevice ); 
     369                                       Util::IODeserialize& deser, 
     370                                       Unit& avDevice ); 
    370371private: 
    371372    PlugConnection(); 
  • trunk/libffado/src/libavc/general/avc_unit.cpp

    r636 r637  
    921921static bool 
    922922deserializePlugUpdateConnections( Glib::ustring path, 
    923                                     Util::IODeserialize& deser, 
    924                                     PlugVector& vec ) 
     923                                  Util::IODeserialize& deser, 
     924                                  PlugVector& vec ) 
    925925{ 
    926926    bool result = true; 
     
    942942    result  = ser.write( basePath + "m_verboseLevel_unit", getDebugLevel() ); 
    943943    result &= serializeVector( basePath + "Subunit", ser, m_subunits ); 
    944     result &= serializeVector( basePath + "plugConnections", ser, m_plugConnections ); 
     944    result &= serializeVector( basePath + "PcrPlug", ser, m_pcrPlugs ); 
     945    result &= serializeVector( basePath + "ExternalPlug",  ser, m_externalPlugs ); 
     946    result &= serializeVector( basePath + "PlugConnection", ser, m_plugConnections ); 
    945947    result &= m_pPlugManager->serialize( basePath + "Plug", ser ); // serialize all av plugs 
    946948    result &= serializeSyncInfoVector( basePath + "SyncInfo", ser, m_syncInfos ); 
     
    982984        return false; 
    983985 
    984     result &= deserializePlugUpdateConnections( basePath + "Plug", deser, m_pcrPlugs ); 
    985     result &= deserializePlugUpdateConnections( basePath + "Plug", deser, m_externalPlugs ); 
     986    // XXX We have to deserialize the m_pcrPlugs and m_externPlugs members somehow. 
     987    // Of course the simple following simple approach wont work at the moment. Some 
     988    // more hacking needed :) 
     989    //result &= deserializeVector<Plug>( basePath + "PcrPlug", deser, *this, m_pcrPlugs ); 
     990    //result &= deserializeVector<Plug>( basePath + "ExternalPlug", deser, *this, m_externalPlugs ); 
     991    result &= deserializePlugUpdateConnections( basePath + "PcrPlug", deser, m_pcrPlugs ); 
     992    result &= deserializePlugUpdateConnections( basePath + "ExternalPlug", deser, m_externalPlugs ); 
    986993    result &= deserializeVector<PlugConnection>( basePath + "PlugConnnection", deser, *this, m_plugConnections ); 
    987994    result &= deserializeVector<Subunit>( basePath + "Subunit",  deser, *this, m_subunits );