Changeset 637
- Timestamp:
- 09/09/07 05:02:46 (16 years ago)
- Files:
-
- trunk/libffado/src/bebob/bebob_avdevice.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/general/avc_plug.cpp (modified) (43 diffs)
- trunk/libffado/src/libavc/general/avc_plug.h (modified) (8 diffs)
- trunk/libffado/src/libavc/general/avc_unit.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/bebob/bebob_avdevice.cpp
r630 r637 407 407 } 408 408 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 409 415 return result; 410 416 } trunk/libffado/src/libavc/general/avc_plug.cpp
r618 r637 124 124 Plug::getSubunitType() const 125 125 { 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 129 subunit_id_t 130 130 Plug::getSubunitId() const 131 131 { … … 229 229 // name already set 230 230 if (m_name != "") return true; 231 231 232 232 m_name = plugAddressTypeToString(getPlugAddressType()); 233 233 m_name += " "; … … 256 256 Plug::discoverChannelName() 257 257 { 258 258 259 259 return true; 260 260 } … … 493 493 494 494 int sourcePlugGlobalId=getSignalSource(); 495 495 496 496 if(sourcePlugGlobalId >= 0) { 497 497 Plug *p=m_unit->getPlugManager().getPlug(sourcePlugGlobalId); … … 520 520 return false; 521 521 } 522 522 523 523 } 524 524 … … 568 568 } 569 569 } 570 570 571 571 if(getPlugAddressType() == eAPA_SubunitPlug) { 572 572 if (getPlugDirection() != eAPD_Input) { … … 575 575 } 576 576 } 577 577 578 578 SignalSourceCmd signalSourceCmd( m_unit->get1394Service() ); 579 579 580 580 signalSourceCmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 581 581 signalSourceCmd.setSubunitType( eST_Unit ); … … 587 587 signalSubunitAddr.m_plugId = 0xFE; 588 588 signalSourceCmd.setSignalSource( signalSubunitAddr ); 589 589 590 590 setDestPlugAddrToSignalCmd( signalSourceCmd, *this ); 591 591 … … 605 605 SignalUnitAddress *usrc=dynamic_cast<SignalUnitAddress *>(src); 606 606 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, 609 609 usrc->m_plugId & 0x7F ); 610 610 } 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, 613 613 usrc->m_plugId & 0x7F ); 614 614 } 615 615 } else if (dynamic_cast<SignalSubunitAddress *>(src)) { 616 616 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, 619 619 eAPD_Output, susrc->m_plugId); 620 620 } else return -1; 621 621 622 622 if (p==NULL) { 623 623 debugError("reported signal source plug not found\n"); 624 624 return -1; 625 625 } 626 626 627 627 return p->getGlobalId(); 628 628 } … … 657 657 } 658 658 659 bool 659 bool 660 660 Plug::propagateFromConnectedPlug( ) { 661 661 … … 668 668 debugWarning("Too many input connections to propagate from, using first one.\n"); 669 669 } 670 670 671 671 Plug* p = *(getInputConnections().begin()); 672 672 return propagateFromPlug( p ); 673 673 674 674 } else if (getDirection() == eAPD_Input) { 675 675 if (getOutputConnections().size()==0) { … … 680 680 debugWarning("Too many output connections to propagate from, using first one.\n"); 681 681 } 682 682 683 683 Plug* p = *(getOutputConnections().begin()); 684 684 return propagateFromPlug( p ); 685 685 686 686 } else { 687 687 debugWarning("plug with undefined direction\n"); … … 690 690 } 691 691 692 bool 692 bool 693 693 Plug::propagateFromPlug( Plug *p ) { 694 694 debugOutput( DEBUG_LEVEL_VERBOSE, 695 695 "Propagating info from plug '%s' to plug '%s'\n", 696 696 p->getName(), getName() ); 697 697 698 698 if (m_clusterInfos.size()==0) { 699 699 m_clusterInfos=p->m_clusterInfos; 700 700 } 701 701 702 702 m_nrOfChannels=p->m_nrOfChannels; 703 703 704 704 return true; 705 705 } … … 742 742 cmd.m_fmt=0xFF; 743 743 cmd.m_plug=getPlugId(); 744 744 745 745 cmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 746 746 cmd.setSubunitType( eST_Unit ); 747 747 cmd.setSubunitId( 0xff ); 748 748 749 749 cmd.setCommandType( AVCCommand::eCT_Status ); 750 750 … … 753 753 return 0; 754 754 } 755 755 756 756 if (cmd.m_fmt != 0x10 ) { 757 757 debugWarning("Incorrect FMT response received: 0x%02X\n",cmd.m_fmt); 758 758 } 759 759 760 760 return fdfSfcToSampleRate(cmd.m_fdf[0]); 761 761 762 762 } else if (getPlugDirection()==eAPD_Output) { 763 763 OutputPlugSignalFormatCmd cmd( m_unit->get1394Service() ); … … 766 766 cmd.m_fmt=0xFF; 767 767 cmd.m_plug=getPlugId(); 768 768 769 769 cmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 770 770 cmd.setSubunitType( eST_Unit ); 771 771 cmd.setSubunitId( 0xff ); 772 772 773 773 cmd.setCommandType( AVCCommand::eCT_Status ); 774 774 775 775 if ( !cmd.fire() ) { 776 776 debugError( "output plug signal format command failed\n" ); 777 777 return 0; 778 778 } 779 779 780 780 if (cmd.m_fmt != 0x10 ) { 781 781 debugWarning("Incorrect FMT response received: 0x%02X\n",cmd.m_fmt); 782 782 } 783 783 784 784 return fdfSfcToSampleRate(cmd.m_fdf[0]); 785 785 786 786 } else { 787 787 debugError("PCR plug with undefined direction.\n"); … … 789 789 } 790 790 } 791 791 792 792 // fallback 793 793 return convertESamplingFrequency( static_cast<ESamplingFrequency>( m_samplingFrequency ) ); … … 812 812 cmd.setSubunitType( eST_Unit ); 813 813 cmd.setSubunitId( 0xff ); 814 814 815 815 cmd.setCommandType( AVCCommand::eCT_Control ); 816 816 … … 835 835 cmd.m_fdf[1]=0xFF; 836 836 cmd.m_fdf[2]=0xFF; 837 837 838 838 cmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 839 839 cmd.setSubunitType( eST_Unit ); 840 840 cmd.setSubunitId( 0xff ); 841 841 842 842 cmd.setCommandType( AVCCommand::eCT_Control ); 843 843 844 844 if ( !cmd.fire() ) { 845 845 debugError( "output plug signal format command failed\n" ); … … 860 860 // fallback: BeBoB style 861 861 ESamplingFrequency samplingFrequency = parseSampleRate(rate); 862 862 863 863 ExtendedStreamFormatCmd extStreamFormatCmd( 864 864 m_unit->get1394Service(), … … 1000 1000 bool 1001 1001 Plug::addPlugConnection( PlugVector& connections, 1002 1002 Plug& plug ) 1003 1003 1004 1004 { … … 1060 1060 void 1061 1061 Plug::setDestPlugAddrToSignalCmd(SignalSourceCmd& signalSourceCmd, 1062 1062 Plug& plug) 1063 1063 { 1064 1064 switch( plug.getSubunitType() ) { … … 1228 1228 getNrOfStreams() ); 1229 1229 debugOutput( DEBUG_LEVEL_VERBOSE, "\tIncoming connections from: "); 1230 1230 1231 1231 for ( PlugVector::const_iterator it = m_inputConnections.begin(); 1232 1232 it != m_inputConnections.end(); … … 1260 1260 function_block_type_t functionBlockType = 0xff; 1261 1261 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; 1264 1264 plug_id_t plugId = 0xff; 1265 1265 … … 1396 1396 bool 1397 1397 Plug::serializeChannelInfos( Glib::ustring basePath, 1398 1399 1398 Util::IOSerialize& ser, 1399 const ClusterInfo& clusterInfo ) const 1400 1400 { 1401 1401 bool result = true; … … 1419 1419 bool 1420 1420 Plug::deserializeChannelInfos( Glib::ustring basePath, 1421 1422 1421 Util::IODeserialize& deser, 1422 ClusterInfo& clusterInfo ) 1423 1423 { 1424 1424 int i = 0; … … 1455 1455 bool 1456 1456 Plug::serializeClusterInfos( Glib::ustring basePath, 1457 1457 Util::IOSerialize& ser ) const 1458 1458 { 1459 1459 bool result = true; … … 1481 1481 bool 1482 1482 Plug::deserializeClusterInfos( Glib::ustring basePath, 1483 1483 Util::IODeserialize& deser ) 1484 1484 { 1485 1485 int i = 0; … … 1519 1519 bool 1520 1520 Plug::serializeFormatInfos( Glib::ustring basePath, 1521 1521 Util::IOSerialize& ser ) const 1522 1522 { 1523 1523 bool result = true; … … 1542 1542 bool 1543 1543 Plug::deserializeFormatInfos( Glib::ustring basePath, 1544 1544 Util::IODeserialize& deser ) 1545 1545 { 1546 1546 int i = 0; … … 1579 1579 bool 1580 1580 Plug::serializePlugVector( Glib::ustring basePath, 1581 1582 1581 Util::IOSerialize& ser, 1582 const PlugVector& vec) const 1583 1583 { 1584 1584 bool result = true; … … 1600 1600 bool 1601 1601 Plug::deserializePlugVector( Glib::ustring basePath, 1602 1603 1602 Util::IODeserialize& deser, 1603 PlugVector& vec ) 1604 1604 { 1605 1605 int i = 0; … … 1664 1664 Plug* 1665 1665 Plug::deserialize( Glib::ustring basePath, 1666 1667 1668 1666 Util::IODeserialize& deser, 1667 Unit& unit, 1668 PlugManager& plugManager ) 1669 1669 { 1670 1670 #warning FIXME: The derived class should be creating these … … 1680 1680 1681 1681 pPlug->m_unit = &unit; 1682 1682 1683 1683 bool result=true; 1684 1684 1685 1685 ESubunitType subunitType; 1686 1686 result = deser.read( basePath + "m_subunitType", subunitType ); … … 1688 1688 result &= deser.read( basePath + "m_subunitId", subunitId ); 1689 1689 pPlug->m_subunit = unit.getSubunit( subunitType, subunitType ); 1690 1690 1691 1691 result &= deser.read( basePath + "m_functionBlockType", pPlug->m_functionBlockType ); 1692 1692 result &= deser.read( basePath + "m_functionBlockId", pPlug->m_functionBlockId ); … … 1864 1864 } 1865 1865 plug->getInputConnections().clear(); 1866 1866 1867 1867 for ( PlugVector::const_iterator it = 1868 1868 plug->getOutputConnections().begin(); … … 1874 1874 plug->getOutputConnections().clear(); 1875 1875 } 1876 1876 1877 1877 for ( PlugConnectionVector::iterator it = connections.begin(); 1878 1878 it != connections.end(); … … 1884 1884 1885 1885 } 1886 1886 1887 1887 return true; 1888 1888 } … … 2002 2002 strstrm << plug->getFunctionBlockType(); 2003 2003 } 2004 2004 2005 2005 if ( plug->getPlugDirection() == Plug::eAPD_Input ) { 2006 2006 printf( "\t\"(%d) %s\" -> \"(%s, ID %d)\"\n", … … 2057 2057 Plug* 2058 2058 PlugManager::getPlug( ESubunitType subunitType, 2059 2060 2061 2062 2063 2064 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 2065 2065 { 2066 2066 debugOutput( DEBUG_LEVEL_VERBOSE, "SBT, SBID, FBT, FBID, AT, PD, ID = " … … 2113 2113 PlugVector 2114 2114 PlugManager::getPlugsByType( ESubunitType subunitType, 2115 2116 2117 2118 2119 2120 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 2121 2121 { 2122 2122 debugOutput( DEBUG_LEVEL_VERBOSE, "SBT, SBID, FBT, FBID, AT, PD, T = " … … 2173 2173 PlugManager* 2174 2174 PlugManager::deserialize( Glib::ustring basePath, 2175 2176 2175 Util::IODeserialize& deser, 2176 Unit& unit ) 2177 2177 2178 2178 { … … 2191 2191 // therefore we have to *this as additional argument 2192 2192 Plug* pPlug = Plug::deserialize( strstrm.str() + "/", 2193 2194 2195 2193 deser, 2194 unit, 2195 *pMgr ); 2196 2196 if ( pPlug ) { 2197 2197 pMgr->m_plugs.push_back( pPlug ); trunk/libffado/src/libavc/general/avc_plug.h
r560 r637 106 106 ESubunitType getSubunitType() const; 107 107 subunit_id_t getSubunitId() const; 108 108 109 109 const char* getName() const 110 110 { return m_name.c_str(); } 111 111 bool setName(const char *n) 112 { m_name=n; return true; };112 { m_name=n; return true; } 113 113 bool setName(std::string n) 114 { m_name=n; return true; };114 { m_name=n; return true; } 115 115 EPlugDirection getPlugDirection() const 116 116 { return m_direction; } … … 121 121 int getSampleRate() const; // 22050, 24000, 32000, ... 122 122 bool setSampleRate( int rate ); 123 123 124 124 int getNrOfChannels() const; 125 125 bool setNrOfChannels(int i); … … 157 157 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 158 158 static Plug* deserialize( Glib::ustring basePath, 159 160 161 159 Util::IODeserialize& deser, 160 Unit& avDevice, 161 PlugManager& plugManager ); 162 162 163 163 bool deserializeUpdate( Glib::ustring basePath, … … 195 195 virtual bool discoverConnections(); 196 196 virtual bool propagateFromConnectedPlug( ); 197 197 198 198 protected: 199 199 virtual bool discoverPlugType(); … … 258 258 259 259 bool serializePlugVector( Glib::ustring basePath, 260 261 260 Util::IOSerialize& ser, 261 const PlugVector& vec) const; 262 262 bool deserializePlugVector( Glib::ustring basePath, 263 264 263 Util::IODeserialize& deser, 264 PlugVector& vec ); 265 265 266 266 protected: … … 320 320 void showPlugs() const; 321 321 322 int getPlugCount() 322 int getPlugCount() 323 323 { return m_plugs.size(); }; 324 324 … … 332 332 Plug* getPlug( int iGlobalId ) const; 333 333 PlugVector getPlugsByType( ESubunitType subunitType, 334 335 336 337 338 339 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; 340 340 341 341 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 342 342 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; } 348 349 bool tidyPlugConnections(PlugConnectionVector&); 349 350 … … 366 367 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 367 368 static PlugConnection* deserialize( Glib::ustring basePath, 368 369 369 Util::IODeserialize& deser, 370 Unit& avDevice ); 370 371 private: 371 372 PlugConnection(); trunk/libffado/src/libavc/general/avc_unit.cpp
r636 r637 921 921 static bool 922 922 deserializePlugUpdateConnections( Glib::ustring path, 923 924 923 Util::IODeserialize& deser, 924 PlugVector& vec ) 925 925 { 926 926 bool result = true; … … 942 942 result = ser.write( basePath + "m_verboseLevel_unit", getDebugLevel() ); 943 943 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 ); 945 947 result &= m_pPlugManager->serialize( basePath + "Plug", ser ); // serialize all av plugs 946 948 result &= serializeSyncInfoVector( basePath + "SyncInfo", ser, m_syncInfos ); … … 982 984 return false; 983 985 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 ); 986 993 result &= deserializeVector<PlugConnection>( basePath + "PlugConnnection", deser, *this, m_plugConnections ); 987 994 result &= deserializeVector<Subunit>( basePath + "Subunit", deser, *this, m_subunits );