Changeset 507
- Timestamp:
- 07/29/07 03:27:38 (16 years ago)
- Files:
-
- branches/echoaudio/src/bebob/bebob_avdevice.cpp (modified) (40 diffs)
- branches/echoaudio/src/bebob/bebob_avdevice.h (modified) (6 diffs)
- branches/echoaudio/src/bebob/bebob_avdevice_subunit.cpp (modified) (17 diffs)
- branches/echoaudio/src/bebob/bebob_avdevice_subunit.h (modified) (4 diffs)
- branches/echoaudio/src/bebob/bebob_avplug.cpp (modified) (30 diffs)
- branches/echoaudio/src/bebob/bebob_avplug.h (modified) (3 diffs)
- branches/echoaudio/src/bebob/bebob_functionblock.cpp (modified) (39 diffs)
- branches/echoaudio/src/bebob/bebob_functionblock.h (modified) (9 diffs)
- branches/echoaudio/src/libavc/general/avc_plug.cpp (copied) (copied from branches/echoaudio/src/bebob/bebob_avplug.cpp) (77 diffs)
- branches/echoaudio/src/libavc/general/avc_plug.h (copied) (copied from branches/echoaudio/src/bebob/bebob_avplug.h) (9 diffs)
- branches/echoaudio/src/libavc/general/avc_subunit.cpp (copied) (copied from branches/echoaudio/src/bebob/bebob_avdevice_subunit.cpp) (14 diffs)
- branches/echoaudio/src/libavc/general/avc_subunit.h (copied) (copied from branches/echoaudio/src/bebob/bebob_avdevice_subunit.h) (3 diffs)
- branches/echoaudio/src/libavc/general/avc_unit.cpp (copied) (copied from branches/echoaudio/src/bebob/bebob_avdevice.cpp) (24 diffs)
- branches/echoaudio/src/libavc/general/avc_unit.h (copied) (copied from branches/echoaudio/src/bebob/bebob_avdevice.h) (6 diffs)
- branches/echoaudio/src/libutil/TimestampedBuffer.h (modified) (1 diff)
- branches/echoaudio/src/Makefile.am (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/echoaudio/src/bebob/bebob_avdevice.cpp
r504 r507 45 45 namespace BeBoB { 46 46 47 IMPL_DEBUG_MODULE( AvDevice, AvDevice, DEBUG_LEVEL_VERBOSE ); 48 47 49 static VendorModelEntry supportedDeviceList[] = 48 50 { … … 73 75 int nodeId ) 74 76 : FFADODevice( configRom, ieee1394service, nodeId ) 75 , m_pPlugManager( new AvPlugManager( DEBUG_LEVEL_NORMAL ) ) 76 , m_activeSyncInfo( 0 ) 77 , AVC::Unit( configRom, ieee1394service, nodeId ) 77 78 , m_model ( NULL ) 78 79 , m_Mixer ( NULL ) … … 92 93 } 93 94 94 for ( AvDeviceSubunitVector::iterator it = m_subunits.begin();95 for ( SubunitVector::iterator it = m_subunits.begin(); 95 96 it != m_subunits.end(); 96 97 ++it ) … … 98 99 delete *it; 99 100 } 100 for ( AvPlugConnectionVector::iterator it = m_plugConnections.begin();101 for ( PlugConnectionVector::iterator it = m_plugConnections.begin(); 101 102 it != m_plugConnections.end(); 102 103 ++it ) … … 104 105 delete *it; 105 106 } 106 for ( AvPlugVector::iterator it = m_pcrPlugs.begin();107 for ( PlugVector::iterator it = m_pcrPlugs.begin(); 107 108 it != m_pcrPlugs.end(); 108 109 ++it ) … … 110 111 delete *it; 111 112 } 112 for ( AvPlugVector::iterator it = m_externalPlugs.begin();113 for ( PlugVector::iterator it = m_externalPlugs.begin(); 113 114 it != m_externalPlugs.end(); 114 115 ++it ) … … 121 122 AvDevice::setVerboseLevel(int l) 122 123 { 123 //m_pPlugManager->setVerboseLevel(l);124 m_pPlugManager->setVerboseLevel(l); 124 125 125 126 FFADODevice::setVerboseLevel(l); … … 170 171 } else return false; 171 172 172 if ( !enumerateSubUnits() ) { 173 debugError( "Could not enumarate sub units\n" ); 174 return false; 175 } 173 if ( !Unit::discover() ) { 174 debugError( "Could not discover unit\n" ); 175 return false; 176 } 177 178 if((getAudioSubunit( 0 ) == NULL)) { 179 debugError( "Unit doesn't have an Audio subunit.\n"); 180 return false; 181 } 182 if((getMusicSubunit( 0 ) == NULL)) { 183 debugError( "Unit doesn't have a Music subunit.\n"); 184 return false; 185 } 186 187 // replaced by the previous Unit discovery 188 // if ( !enumerateSubUnits() ) { 189 // debugError( "Could not enumarate sub units\n" ); 190 // return false; 191 // } 176 192 177 193 if ( !discoverPlugs() ) { … … 243 259 plugInfoCmd.m_externalOutputPlugs ); 244 260 245 if ( !discoverPlugsPCR( AvPlug::eAPD_Input,261 if ( !discoverPlugsPCR( Plug::eAPD_Input, 246 262 plugInfoCmd.m_serialBusIsochronousInputPlugs ) ) 247 263 { … … 250 266 } 251 267 252 if ( !discoverPlugsPCR( AvPlug::eAPD_Output,268 if ( !discoverPlugsPCR( Plug::eAPD_Output, 253 269 plugInfoCmd.m_serialBusIsochronousOutputPlugs ) ) 254 270 { … … 257 273 } 258 274 259 if ( !discoverPlugsExternal( AvPlug::eAPD_Input,275 if ( !discoverPlugsExternal( Plug::eAPD_Input, 260 276 plugInfoCmd.m_externalInputPlugs ) ) 261 277 { … … 264 280 } 265 281 266 if ( !discoverPlugsExternal( AvPlug::eAPD_Output,282 if ( !discoverPlugsExternal( Plug::eAPD_Output, 267 283 plugInfoCmd.m_externalOutputPlugs ) ) 268 284 { … … 275 291 276 292 bool 277 AvDevice::discoverPlugsPCR( AvPlug::EAvPlugDirection plugDirection,293 AvDevice::discoverPlugsPCR( Plug::EPlugDirection plugDirection, 278 294 plug_id_t plugMaxId ) 279 295 { … … 282 298 ++plugId ) 283 299 { 284 AvPlug* plug = new AvPlug( *m_p1394Service, 285 *m_pConfigRom, 286 *m_pPlugManager, 287 eST_Unit, 288 0xff, 289 0xff, 290 0xff, 291 AvPlug::eAPA_PCR, 292 plugDirection, 293 plugId, 294 m_verboseLevel ); 300 AVC::Plug* plug = new Plug( this, 301 NULL, 302 0xff, 303 0xff, 304 Plug::eAPA_PCR, 305 plugDirection, 306 plugId ); 295 307 if ( !plug || !plug->discover() ) { 296 308 debugError( "plug discovering failed\n" ); … … 308 320 309 321 bool 310 AvDevice::discoverPlugsExternal( AvPlug::EAvPlugDirection plugDirection,322 AvDevice::discoverPlugsExternal( Plug::EPlugDirection plugDirection, 311 323 plug_id_t plugMaxId ) 312 324 { … … 315 327 ++plugId ) 316 328 { 317 AvPlug* plug = new AvPlug( *m_p1394Service, 318 *m_pConfigRom, 319 *m_pPlugManager, 320 eST_Unit, 321 0xff, 322 0xff, 323 0xff, 324 AvPlug::eAPA_ExternalPlug, 325 plugDirection, 326 plugId, 327 m_verboseLevel ); 329 AVC::Plug* plug = new Plug( this, NULL, 330 0xff, 331 0xff, 332 Plug::eAPA_ExternalPlug, 333 plugDirection, 334 plugId ); 328 335 if ( !plug || !plug->discover() ) { 329 336 debugError( "plug discovering failed\n" ); … … 342 349 AvDevice::discoverPlugConnections() 343 350 { 344 for ( AvPlugVector::iterator it = m_pcrPlugs.begin();351 for ( PlugVector::iterator it = m_pcrPlugs.begin(); 345 352 it != m_pcrPlugs.end(); 346 353 ++it ) 347 354 { 348 A vPlug* plug = *it;355 AVC::Plug* plug = *it; 349 356 if ( !plug->discoverConnections() ) { 350 357 debugError( "Could not discover plug connections\n" ); … … 352 359 } 353 360 } 354 for ( AvPlugVector::iterator it = m_externalPlugs.begin();361 for ( PlugVector::iterator it = m_externalPlugs.begin(); 355 362 it != m_externalPlugs.end(); 356 363 ++it ) 357 364 { 358 A vPlug* plug = *it;365 AVC::Plug* plug = *it; 359 366 if ( !plug->discoverConnections() ) { 360 367 debugError( "Could not discover plug connections\n" ); … … 369 376 AvDevice::discoverSubUnitsPlugConnections() 370 377 { 371 for ( AvDeviceSubunitVector::iterator it = m_subunits.begin();372 it != m_subunits.end();373 ++it )374 {375 AvDeviceSubunit* subunit = *it;376 if ( !subunit->discoverConnections() ) {377 debugError( "Subunit '%s' plug connections failed\n",378 subunit->getName() );379 return false;380 }381 }378 // for ( SubunitVector::iterator it = m_subunits.begin(); 379 // it != m_subunits.end(); 380 // ++it ) 381 // { 382 // Subunit* subunit = *it; 383 // if ( !subunit->discoverConnections() ) { 384 // debugError( "Subunit '%s' plug connections failed\n", 385 // subunit->getName() ); 386 // return false; 387 // } 388 // } 382 389 return true; 383 390 } … … 404 411 // MSU input means subunit-to-device 405 412 406 AvPlugVector syncPCRInputPlugs = getPlugsByType( m_pcrPlugs,407 AvPlug::eAPD_Input,408 AvPlug::eAPT_Sync );413 PlugVector syncPCRInputPlugs = getPlugsByType( m_pcrPlugs, 414 Plug::eAPD_Input, 415 Plug::eAPT_Sync ); 409 416 if ( !syncPCRInputPlugs.size() ) { 410 417 debugWarning( "No PCR sync input plug found\n" ); 411 418 } 412 419 413 AvPlugVector syncPCROutputPlugs = getPlugsByType( m_pcrPlugs,414 AvPlug::eAPD_Output,415 AvPlug::eAPT_Sync );420 PlugVector syncPCROutputPlugs = getPlugsByType( m_pcrPlugs, 421 Plug::eAPD_Output, 422 Plug::eAPT_Sync ); 416 423 if ( !syncPCROutputPlugs.size() ) { 417 424 debugWarning( "No PCR sync output plug found\n" ); 418 425 } 419 426 420 AvPlugVector isoPCRInputPlugs = getPlugsByType( m_pcrPlugs,421 AvPlug::eAPD_Input,422 AvPlug::eAPT_IsoStream );427 PlugVector isoPCRInputPlugs = getPlugsByType( m_pcrPlugs, 428 Plug::eAPD_Input, 429 Plug::eAPT_IsoStream ); 423 430 if ( !isoPCRInputPlugs.size() ) { 424 431 debugWarning( "No PCR iso input plug found\n" ); … … 426 433 } 427 434 428 AvPlugVector isoPCROutputPlugs = getPlugsByType( m_pcrPlugs,429 AvPlug::eAPD_Output,430 AvPlug::eAPT_IsoStream );435 PlugVector isoPCROutputPlugs = getPlugsByType( m_pcrPlugs, 436 Plug::eAPD_Output, 437 Plug::eAPT_IsoStream ); 431 438 if ( !isoPCROutputPlugs.size() ) { 432 439 debugWarning( "No PCR iso output plug found\n" ); … … 434 441 } 435 442 436 AvPlugVector digitalPCRInputPlugs = getPlugsByType( m_externalPlugs,437 AvPlug::eAPD_Input,438 AvPlug::eAPT_Digital );439 440 AvPlugVector syncMSUInputPlugs = m_pPlugManager->getPlugsByType(443 PlugVector digitalPCRInputPlugs = getPlugsByType( m_externalPlugs, 444 Plug::eAPD_Input, 445 Plug::eAPT_Digital ); 446 447 PlugVector syncMSUInputPlugs = m_pPlugManager->getPlugsByType( 441 448 eST_Music, 442 449 0, 443 450 0xff, 444 451 0xff, 445 AvPlug::eAPA_SubunitPlug,446 AvPlug::eAPD_Input,447 AvPlug::eAPT_Sync );452 Plug::eAPA_SubunitPlug, 453 Plug::eAPD_Input, 454 Plug::eAPT_Sync ); 448 455 if ( !syncMSUInputPlugs.size() ) { 449 456 debugWarning( "No sync input plug for MSU subunit found\n" ); 450 457 } 451 458 452 AvPlugVector syncMSUOutputPlugs = m_pPlugManager->getPlugsByType(459 PlugVector syncMSUOutputPlugs = m_pPlugManager->getPlugsByType( 453 460 eST_Music, 454 461 0, 455 462 0xff, 456 463 0xff, 457 AvPlug::eAPA_SubunitPlug,458 AvPlug::eAPD_Output,459 AvPlug::eAPT_Sync );464 Plug::eAPA_SubunitPlug, 465 Plug::eAPD_Output, 466 Plug::eAPT_Sync ); 460 467 if ( !syncMSUOutputPlugs.size() ) { 461 468 debugWarning( "No sync output plug for MSU subunit found\n" ); … … 463 470 464 471 debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Sync Input Plugs:\n" ); 465 show AvPlugs( syncPCRInputPlugs );472 showPlugs( syncPCRInputPlugs ); 466 473 debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Sync Output Plugs:\n" ); 467 show AvPlugs( syncPCROutputPlugs );474 showPlugs( syncPCROutputPlugs ); 468 475 debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Iso Input Plugs:\n" ); 469 show AvPlugs( isoPCRInputPlugs );476 showPlugs( isoPCRInputPlugs ); 470 477 debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Iso Output Plugs:\n" ); 471 show AvPlugs( isoPCROutputPlugs );478 showPlugs( isoPCROutputPlugs ); 472 479 debugOutput( DEBUG_LEVEL_VERBOSE, "PCR digital Input Plugs:\n" ); 473 show AvPlugs( digitalPCRInputPlugs );480 showPlugs( digitalPCRInputPlugs ); 474 481 debugOutput( DEBUG_LEVEL_VERBOSE, "MSU Sync Input Plugs:\n" ); 475 show AvPlugs( syncMSUInputPlugs );482 showPlugs( syncMSUInputPlugs ); 476 483 debugOutput( DEBUG_LEVEL_VERBOSE, "MSU Sync Output Plugs:\n" ); 477 show AvPlugs( syncMSUOutputPlugs );484 showPlugs( syncMSUOutputPlugs ); 478 485 479 486 // Check all possible PCR input to MSU input connections … … 510 517 // status, source unknown, destination MSU sync input plug 511 518 512 for ( AvPlugVector::const_iterator it = syncMSUInputPlugs.begin();519 for ( PlugVector::const_iterator it = syncMSUInputPlugs.begin(); 513 520 it != syncMSUInputPlugs.end(); 514 521 ++it ) 515 522 { 516 A vPlug* msuPlug = *it;517 for ( AvPlugVector::const_iterator jt =523 AVC::Plug* msuPlug = *it; 524 for ( PlugVector::const_iterator jt = 518 525 msuPlug->getInputConnections().begin(); 519 526 jt != msuPlug->getInputConnections().end(); 520 527 ++jt ) 521 528 { 522 A vPlug* plug = *jt;529 AVC::Plug* plug = *jt; 523 530 524 531 for ( SyncInfoVector::iterator it = m_syncInfos.begin(); … … 545 552 546 553 bool 547 AvDevice::enumerateSubUnits()548 {549 bool musicSubunitFound=false;550 bool audioSubunitFound=false;551 552 SubUnitInfoCmd subUnitInfoCmd( *m_p1394Service );553 //subUnitInfoCmd.setVerbose( 1 );554 subUnitInfoCmd.setCommandType( AVCCommand::eCT_Status );555 556 // BeBoB has always exactly one audio and one music subunit. This557 // means is fits into the first page of the SubUnitInfo command.558 // So there is no need to do more than needed559 560 subUnitInfoCmd.m_page = 0;561 subUnitInfoCmd.setNodeId( m_pConfigRom->getNodeId() );562 subUnitInfoCmd.setVerbose( m_verboseLevel );563 if ( !subUnitInfoCmd.fire() ) {564 debugError( "Subunit info command failed\n" );565 // shouldn't this be an error situation?566 return false;567 }568 569 for ( int i = 0; i < subUnitInfoCmd.getNrOfValidEntries(); ++i ) {570 subunit_type_t subunit_type571 = subUnitInfoCmd.m_table[i].m_subunit_type;572 573 unsigned int subunitId = getNrOfSubunits( subunit_type );574 575 debugOutput( DEBUG_LEVEL_VERBOSE,576 "subunit_id = %2d, subunit_type = %2d (%s)\n",577 subunitId,578 subunit_type,579 subunitTypeToString( subunit_type ) );580 581 AvDeviceSubunit* subunit = 0;582 switch( subunit_type ) {583 case eST_Audio:584 subunit = new AvDeviceSubunitAudio( *this,585 subunitId,586 m_verboseLevel );587 if ( !subunit ) {588 debugFatal( "Could not allocate AvDeviceSubunitAudio\n" );589 return false;590 }591 if ( !subunit ) {592 debugFatal( "Could not allocate AvDeviceSubunitMusic\n" );593 return false;594 }595 596 if ( !subunit->discover() ) {597 debugError( "enumerateSubUnits: Could not discover "598 "subunit_id = %2d, subunit_type = %2d (%s)\n",599 subunitId,600 subunit_type,601 subunitTypeToString( subunit_type ) );602 delete subunit;603 return false;604 } else {605 m_subunits.push_back( subunit );606 audioSubunitFound=true;607 }608 609 break;610 case eST_Music:611 subunit = new AvDeviceSubunitMusic( *this,612 subunitId,613 m_verboseLevel );614 if ( !subunit ) {615 debugFatal( "Could not allocate AvDeviceSubunitMusic\n" );616 return false;617 }618 if ( !subunit->discover() ) {619 debugError( "enumerateSubUnits: Could not discover "620 "subunit_id = %2d, subunit_type = %2d (%s)\n",621 subunitId,622 subunit_type,623 subunitTypeToString( subunit_type ) );624 delete subunit;625 return false;626 } else {627 m_subunits.push_back( subunit );628 musicSubunitFound=true;629 }630 631 break;632 default:633 debugOutput( DEBUG_LEVEL_NORMAL,634 "Unsupported subunit found, subunit_type = %d (%s)\n",635 subunit_type,636 subunitTypeToString( subunit_type ) );637 continue;638 639 }640 641 }642 643 // a BeBoB always has an audio and a music subunit644 return (musicSubunitFound && audioSubunitFound);645 }646 647 648 AvDeviceSubunit*649 AvDevice::getSubunit( subunit_type_t subunitType,650 subunit_id_t subunitId ) const651 {652 for ( AvDeviceSubunitVector::const_iterator it = m_subunits.begin();653 it != m_subunits.end();654 ++it )655 {656 AvDeviceSubunit* subunit = *it;657 if ( ( subunitType == subunit->getSubunitType() )658 && ( subunitId == subunit->getSubunitId() ) )659 {660 return subunit;661 }662 }663 664 return 0;665 }666 667 668 unsigned int669 AvDevice::getNrOfSubunits( subunit_type_t subunitType ) const670 {671 unsigned int nrOfSubunits = 0;672 673 for ( AvDeviceSubunitVector::const_iterator it = m_subunits.begin();674 it != m_subunits.end();675 ++it )676 {677 AvDeviceSubunit* subunit = *it;678 if ( subunitType == subunit->getSubunitType() ) {679 nrOfSubunits++;680 }681 }682 683 return nrOfSubunits;684 }685 686 AvPlugConnection*687 AvDevice::getPlugConnection( AvPlug& srcPlug ) const688 {689 for ( AvPlugConnectionVector::const_iterator it690 = m_plugConnections.begin();691 it != m_plugConnections.end();692 ++it )693 {694 AvPlugConnection* plugConnection = *it;695 if ( &( plugConnection->getSrcPlug() ) == &srcPlug ) {696 return plugConnection;697 }698 }699 700 return 0;701 }702 703 AvPlug*704 AvDevice::getPlugById( AvPlugVector& plugs,705 AvPlug::EAvPlugDirection plugDirection,706 int id )707 {708 for ( AvPlugVector::iterator it = plugs.begin();709 it != plugs.end();710 ++it )711 {712 AvPlug* plug = *it;713 if ( ( id == plug->getPlugId() )714 && ( plugDirection == plug->getPlugDirection() ) )715 {716 return plug;717 }718 }719 720 return 0;721 }722 723 AvPlugVector724 AvDevice::getPlugsByType( AvPlugVector& plugs,725 AvPlug::EAvPlugDirection plugDirection,726 AvPlug::EAvPlugType type)727 {728 AvPlugVector plugVector;729 for ( AvPlugVector::iterator it = plugs.begin();730 it != plugs.end();731 ++it )732 {733 AvPlug* plug = *it;734 if ( ( type == plug->getPlugType() )735 && ( plugDirection == plug->getPlugDirection() ) )736 {737 plugVector.push_back( plug );738 }739 }740 741 return plugVector;742 }743 744 AvPlug*745 AvDevice::getSyncPlug( int maxPlugId, AvPlug::EAvPlugDirection )746 {747 return 0;748 }749 750 bool751 554 AvDevice::setSamplingFrequency( int s ) 752 555 { … … 766 569 return true; 767 570 } else { 768 A vPlug* plug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Input, 0 );571 AVC::Plug* plug = getPlugById( m_pcrPlugs, Plug::eAPD_Input, 0 ); 769 572 if ( !plug ) { 770 573 debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); … … 773 576 774 577 if ( !setSamplingFrequencyPlug( *plug, 775 AvPlug::eAPD_Input,578 Plug::eAPD_Input, 776 579 samplingFrequency ) ) 777 580 { … … 780 583 } 781 584 782 plug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Output, 0 );585 plug = getPlugById( m_pcrPlugs, Plug::eAPD_Output, 0 ); 783 586 if ( !plug ) { 784 587 debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); … … 787 590 788 591 if ( !setSamplingFrequencyPlug( *plug, 789 AvPlug::eAPD_Output,592 Plug::eAPD_Output, 790 593 samplingFrequency ) ) 791 594 { … … 805 608 int 806 609 AvDevice::getSamplingFrequency( ) { 807 A vPlug* inputPlug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Input, 0 );610 AVC::Plug* inputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Input, 0 ); 808 611 if ( !inputPlug ) { 809 612 debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); 810 613 return false; 811 614 } 812 A vPlug* outputPlug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Output, 0 );615 AVC::Plug* outputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Output, 0 ); 813 616 if ( !outputPlug ) { 814 617 debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); … … 827 630 828 631 bool 829 AvDevice::setSamplingFrequencyPlug( A vPlug& plug,830 AvPlug::EAvPlugDirection direction,632 AvDevice::setSamplingFrequencyPlug( AVC::Plug& plug, 633 Plug::EPlugDirection direction, 831 634 ESamplingFrequency samplingFrequency ) 832 635 { … … 840 643 extStreamFormatCmd.setPlugAddress( 841 644 PlugAddress( 842 AvPlug::convertPlugDirection(direction ),645 Plug::convertPlugDirection(direction ), 843 646 PlugAddress::ePAM_Unit, 844 647 unitPlugAddress ) ); … … 937 740 } 938 741 939 void 940 AvDevice::showAvPlugs( AvPlugVector& plugs ) const 941 { 942 int i = 0; 943 for ( AvPlugVector::const_iterator it = plugs.begin(); 944 it != plugs.end(); 945 ++it, ++i ) 946 { 947 AvPlug* plug = *it; 948 debugOutput( DEBUG_LEVEL_VERBOSE, "Plug %d\n", i ); 949 plug->showPlug(); 950 } 951 } 952 953 bool 954 AvDevice::checkSyncConnectionsAndAddToList( AvPlugVector& plhs, 955 AvPlugVector& prhs, 742 bool 743 AvDevice::checkSyncConnectionsAndAddToList( PlugVector& plhs, 744 PlugVector& prhs, 956 745 std::string syncDescription ) 957 746 { 958 for ( AvPlugVector::iterator plIt = plhs.begin();747 for ( PlugVector::iterator plIt = plhs.begin(); 959 748 plIt != plhs.end(); 960 749 ++plIt ) 961 750 { 962 A vPlug* pl = *plIt;963 for ( AvPlugVector::iterator prIt = prhs.begin();751 AVC::Plug* pl = *plIt; 752 for ( PlugVector::iterator prIt = prhs.begin(); 964 753 prIt != prhs.end(); 965 754 ++prIt ) 966 755 { 967 A vPlug* pr = *prIt;756 AVC::Plug* pr = *prIt; 968 757 if ( pl->inquireConnnection( *pr ) ) { 969 758 m_syncInfos.push_back( SyncInfo( *pl, *pr, syncDescription ) ); … … 1024 813 // get plugs 1025 814 1026 A vPlug* inputPlug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Input, 0 );815 AVC::Plug* inputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Input, 0 ); 1027 816 if ( !inputPlug ) { 1028 817 debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); 1029 818 return false; 1030 819 } 1031 A vPlug* outputPlug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Output, 0 );820 AVC::Plug* outputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Output, 0 ); 1032 821 if ( !outputPlug ) { 1033 822 debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); … … 1109 898 bool 1110 899 AvDevice::addPlugToProcessor( 1111 A vPlug& plug,900 AVC::Plug& plug, 1112 901 Streaming::StreamProcessor *processor, 1113 902 Streaming::AmdtpAudioPort::E_Direction direction) { … … 1118 907 } 1119 908 1120 AvPlug::ClusterInfoVector& clusterInfos = plug.getClusterInfos();1121 for ( AvPlug::ClusterInfoVector::const_iterator it = clusterInfos.begin();909 Plug::ClusterInfoVector& clusterInfos = plug.getClusterInfos(); 910 for ( Plug::ClusterInfoVector::const_iterator it = clusterInfos.begin(); 1122 911 it != clusterInfos.end(); 1123 912 ++it ) 1124 913 { 1125 const AvPlug::ClusterInfo* clusterInfo = &( *it );1126 1127 AvPlug::ChannelInfoVector channelInfos = clusterInfo->m_channelInfos;1128 for ( AvPlug::ChannelInfoVector::const_iterator it = channelInfos.begin();914 const Plug::ClusterInfo* clusterInfo = &( *it ); 915 916 Plug::ChannelInfoVector channelInfos = clusterInfo->m_channelInfos; 917 for ( Plug::ChannelInfoVector::const_iterator it = channelInfos.begin(); 1129 918 it != channelInfos.end(); 1130 919 ++it ) 1131 920 { 1132 const AvPlug::ChannelInfo* channelInfo = &( *it );921 const Plug::ChannelInfo* channelInfo = &( *it ); 1133 922 std::ostringstream portname; 1134 923 … … 1355 1144 template <typename T, typename VT> bool deserializeVector( Glib::ustring path, 1356 1145 Util::IODeserialize& deser, 1357 AvDevice& avDevice,1146 Unit& avDevice, 1358 1147 VT& vec ) 1359 1148 { … … 1378 1167 1379 1168 bool 1380 AvDevice::serializeSyncInfoVector( Glib::ustring basePath,1381 Util::IOSerialize& ser,1382 const SyncInfoVector& vec )1383 {1384 bool result = true;1385 int i = 0;1386 1387 for ( SyncInfoVector::const_iterator it = vec.begin();1388 it != vec.end();1389 ++it )1390 {1391 const SyncInfo& info = *it;1392 1393 std::ostringstream strstrm;1394 strstrm << basePath << i << "/";1395 1396 result &= ser.write( strstrm.str() + "m_source", info.m_source->getGlobalId() );1397 result &= ser.write( strstrm.str() + "m_destination", info.m_destination->getGlobalId() );1398 result &= ser.write( strstrm.str() + "m_description", Glib::ustring( info.m_description ) );1399 1400 i++;1401 }1402 1403 return result;1404 }1405 1406 bool1407 AvDevice::deserializeSyncInfoVector( Glib::ustring basePath,1408 Util::IODeserialize& deser,1409 AvDevice& avDevice,1410 SyncInfoVector& vec )1411 {1412 int i = 0;1413 bool bFinished = false;1414 do {1415 bool result;1416 std::ostringstream strstrm;1417 strstrm << basePath << i << "/";1418 1419 plug_id_t sourceId;1420 plug_id_t destinationId;1421 Glib::ustring description;1422 1423 result = deser.read( strstrm.str() + "m_source", sourceId );1424 result &= deser.read( strstrm.str() + "m_destination", destinationId );1425 result &= deser.read( strstrm.str() + "m_description", description );1426 1427 if ( result ) {1428 SyncInfo syncInfo;1429 syncInfo.m_source = avDevice.getPlugManager().getPlug( sourceId );1430 syncInfo.m_destination = avDevice.getPlugManager().getPlug( destinationId );1431 syncInfo.m_description = description;1432 1433 vec.push_back( syncInfo );1434 i++;1435 } else {1436 bFinished = true;1437 }1438 } while ( !bFinished );1439 1440 return true;1441 }1442 1443 static bool1444 deserializeAvPlugUpdateConnections( Glib::ustring path,1445 Util::IODeserialize& deser,1446 AvPlugVector& vec )1447 {1448 bool result = true;1449 for ( AvPlugVector::iterator it = vec.begin();1450 it != vec.end();1451 ++it )1452 {1453 AvPlug* pPlug = *it;1454 result &= pPlug->deserializeUpdate( path, deser );1455 }1456 return result;1457 }1458 1459 bool1460 1169 AvDevice::serialize( Glib::ustring basePath, 1461 1170 Util::IOSerialize& ser ) const … … 1464 1173 bool result; 1465 1174 result = m_pConfigRom->serialize( basePath + "m_pConfigRom/", ser ); 1466 result &= ser.write( basePath + "m_verboseLevel", m_verboseLevel);1467 result &= m_pPlugManager->serialize( basePath + " AvPlug", ser ); // serialize all av plugs1175 result &= ser.write( basePath + "m_verboseLevel", getDebugLevel() ); 1176 result &= m_pPlugManager->serialize( basePath + "Plug", ser ); // serialize all av plugs 1468 1177 result &= serializeVector( basePath + "PlugConnection", ser, m_plugConnections ); 1469 1178 result &= serializeVector( basePath + "Subunit", ser, m_subunits ); … … 1509 1218 if ( pDev ) { 1510 1219 bool result; 1511 result = deser.read( basePath + "m_verboseLevel", pDev->m_verboseLevel ); 1512 1513 if (pDev->m_pPlugManager) delete pDev->m_pPlugManager; 1514 pDev->m_pPlugManager = AvPlugManager::deserialize( basePath + "AvPlug", deser, *pDev ); 1515 if ( !pDev->m_pPlugManager ) { 1516 delete pDev; 1517 return 0; 1518 } 1519 result &= deserializeAvPlugUpdateConnections( basePath + "AvPlug", deser, pDev->m_pcrPlugs ); 1520 result &= deserializeAvPlugUpdateConnections( basePath + "AvPlug", deser, pDev->m_externalPlugs ); 1521 result &= deserializeVector<AvPlugConnection>( basePath + "PlugConnnection", deser, *pDev, pDev->m_plugConnections ); 1522 result &= deserializeVector<AvDeviceSubunit>( basePath + "Subunit", deser, *pDev, pDev->m_subunits ); 1523 result &= deserializeSyncInfoVector( basePath + "SyncInfo", deser, *pDev, pDev->m_syncInfos ); 1524 1525 unsigned int i; 1526 result &= deser.read( basePath + "m_activeSyncInfo", i ); 1527 1528 if ( result ) { 1529 if ( i < pDev->m_syncInfos.size() ) { 1530 pDev->m_activeSyncInfo = &pDev->m_syncInfos[i]; 1531 } 1532 } 1220 int verboseLevel; 1221 result = deser.read( basePath + "m_verboseLevel", verboseLevel ); 1222 setDebugLevel( verboseLevel ); 1223 1224 result &= AVC::Unit::deserialize(basePath, pDev, deser, ieee1394Service); 1533 1225 1534 1226 result &= deserializeOptions( basePath + "Options", deser, *pDev ); branches/echoaudio/src/bebob/bebob_avdevice.h
r504 r507 30 30 #include "libavc/avc_definitions.h" 31 31 #include "libavc/general/avc_extended_cmd_generic.h" 32 #include "libavc/general/avc_unit.h" 33 #include "libavc/general/avc_subunit.h" 34 #include "libavc/general/avc_plug.h" 32 35 33 36 #include "bebob/bebob_avplug.h" … … 58 61 }; 59 62 60 class AvDevice : public FFADODevice {63 class AvDevice : public FFADODevice, public AVC::Unit { 61 64 public: 62 65 AvDevice( std::auto_ptr<ConfigRom>( configRom ), … … 85 88 virtual void showDevice(); 86 89 87 Ieee1394Service& get1394Service()88 { return *m_p1394Service; }89 90 AvPlugManager& getPlugManager()91 { return *m_pPlugManager; }92 93 struct SyncInfo {94 SyncInfo( AvPlug& source,95 AvPlug& destination,96 std::string description )97 : m_source( &source )98 , m_destination( &destination )99 , m_description( description )100 {}101 SyncInfo()102 : m_source( 0 )103 , m_destination( 0 )104 , m_description( "" )105 {}106 AvPlug* m_source;107 AvPlug* m_destination;108 std::string m_description;109 };110 111 typedef std::vector<SyncInfo> SyncInfoVector;112 const SyncInfoVector& getSyncInfos() const113 { return m_syncInfos; }114 const SyncInfo* getActiveSyncInfo() const115 { return m_activeSyncInfo; }116 90 bool setActiveSync( const SyncInfo& syncInfo ); 117 91 … … 119 93 static AvDevice* deserialize( Glib::ustring basePath, 120 94 Util::IODeserialize& deser, 121 Ieee1394Service& ieee1394Service ); 122 AvDeviceSubunitAudio* getAudioSubunit( AVC::subunit_id_t subunitId ) 123 { return dynamic_cast<AvDeviceSubunitAudio*>( 124 getSubunit( AVC1394_SUBUNIT_AUDIO , subunitId ));}; 95 Ieee1394Service& ieee1394Service ); 125 96 97 // redefinition to resolve ambiguity 98 Ieee1394Service& get1394Service() 99 { return *m_p1394Service; } 100 ConfigRom& getConfigRom() const 101 {return FFADODevice::getConfigRom();}; 102 126 103 protected: 127 104 128 bool enumerateSubUnits();129 130 105 bool discoverPlugs(); 131 bool discoverPlugsPCR( A vPlug::EAvPlugDirection plugDirection,106 bool discoverPlugsPCR( AVC::Plug::EPlugDirection plugDirection, 132 107 AVC::plug_id_t plugMaxId ); 133 bool discoverPlugsExternal( A vPlug::EAvPlugDirection plugDirection,108 bool discoverPlugsExternal( AVC::Plug::EPlugDirection plugDirection, 134 109 AVC::plug_id_t plugMaxId ); 135 110 bool discoverPlugConnections(); … … 137 112 bool discoverSubUnitsPlugConnections(); 138 113 139 AvDeviceSubunit* getSubunit( AVC::subunit_type_t subunitType, 140 AVC::subunit_id_t subunitId ) const; 141 142 unsigned int getNrOfSubunits( AVC::subunit_type_t subunitType ) const; 143 AvPlugConnection* getPlugConnection( AvPlug& srcPlug ) const; 144 145 AvPlug* getSyncPlug( int maxPlugId, AvPlug::EAvPlugDirection ); 146 147 AvPlug* getPlugById( AvPlugVector& plugs, 148 AvPlug::EAvPlugDirection plugDireciton, 149 int id ); 150 AvPlugVector getPlugsByType( AvPlugVector& plugs, 151 AvPlug::EAvPlugDirection plugDirection, 152 AvPlug::EAvPlugType type); 153 154 bool addPlugToProcessor( AvPlug& plug, Streaming::StreamProcessor *processor, 114 bool addPlugToProcessor( AVC::Plug& plug, Streaming::StreamProcessor *processor, 155 115 Streaming::AmdtpAudioPort::E_Direction direction); 156 116 157 bool setSamplingFrequencyPlug( A vPlug& plug,158 A vPlug::EAvPlugDirection direction,117 bool setSamplingFrequencyPlug( AVC::Plug& plug, 118 AVC::Plug::EPlugDirection direction, 159 119 AVC::ESamplingFrequency samplingFrequency ); 160 120 161 void showAvPlugs( AvPlugVector& plugs ) const; 162 163 bool checkSyncConnectionsAndAddToList( AvPlugVector& plhs, 164 AvPlugVector& prhs, 121 bool checkSyncConnectionsAndAddToList( AVC::PlugVector& plhs, 122 AVC::PlugVector& prhs, 165 123 std::string syncDescription ); 166 124 167 static bool serializeSyncInfoVector( Glib::ustring basePath,168 Util::IOSerialize& ser,169 const SyncInfoVector& vec );170 static bool deserializeSyncInfoVector( Glib::ustring basePath,171 Util::IODeserialize& deser,172 AvDevice& avDevice,173 SyncInfoVector& vec );174 125 protected: 175 AvPlugVector m_pcrPlugs;176 AvPlugVector m_externalPlugs;177 AvPlugConnectionVector m_plugConnections;178 AvDeviceSubunitVector m_subunits;179 AvPlugManager* m_pPlugManager;180 SyncInfoVector m_syncInfos;181 SyncInfo* m_activeSyncInfo;182 126 struct VendorModelEntry* m_model; 183 127 GenericMixer* m_Mixer; … … 187 131 StreamProcessorVector m_receiveProcessors; 188 132 StreamProcessorVector m_transmitProcessors; 133 134 DECLARE_DEBUG_MODULE; 189 135 }; 190 136 branches/echoaudio/src/bebob/bebob_avdevice_subunit.cpp
r503 r507 36 36 using namespace AVC; 37 37 38 IMPL_DEBUG_MODULE( BeBoB::AvDeviceSubunit, BeBoB::AvDeviceSubunit, DEBUG_LEVEL_VERBOSE ); 39 40 //////////////////////////////////////////// 41 42 BeBoB::AvDeviceSubunit::AvDeviceSubunit( AvDevice& avDevice, 43 ESubunitType type, 44 subunit_t id, 45 int verboseLevel ) 46 : m_avDevice( &avDevice ) 47 , m_sbType( type ) 48 , m_sbId( id ) 49 , m_verboseLevel( verboseLevel ) 50 { 51 setDebugLevel( m_verboseLevel ); 52 } 53 54 BeBoB::AvDeviceSubunit::AvDeviceSubunit() 55 { 56 } 57 58 BeBoB::AvDeviceSubunit::~AvDeviceSubunit() 59 { 60 for ( AvPlugVector::iterator it = m_plugs.begin(); 61 it != m_plugs.end(); 62 ++it ) 63 { 64 delete *it; 65 } 66 } 67 68 bool 69 BeBoB::AvDeviceSubunit::discover() 70 { 71 if ( !discoverPlugs() ) { 72 debugError( "plug discovering failed\n" ); 73 return false; 74 } 75 76 return true; 77 } 78 79 bool 80 BeBoB::AvDeviceSubunit::discoverPlugs() 81 { 82 PlugInfoCmd plugInfoCmd( m_avDevice->get1394Service(), 83 PlugInfoCmd::eSF_SerialBusIsochronousAndExternalPlug ); 84 plugInfoCmd.setNodeId( m_avDevice->getConfigRom().getNodeId() ); 85 plugInfoCmd.setCommandType( AVCCommand::eCT_Status ); 86 plugInfoCmd.setSubunitType( m_sbType ); 87 plugInfoCmd.setSubunitId( m_sbId ); 88 plugInfoCmd.setVerbose( m_verboseLevel ); 89 90 if ( !plugInfoCmd.fire() ) { 91 debugError( "plug info command failed\n" ); 92 return false; 93 } 94 95 debugOutput( DEBUG_LEVEL_NORMAL, "number of source plugs = %d\n", 96 plugInfoCmd.m_sourcePlugs ); 97 debugOutput( DEBUG_LEVEL_NORMAL, "number of destination output " 98 "plugs = %d\n", plugInfoCmd.m_destinationPlugs ); 99 100 if ( !discoverPlugs( AvPlug::eAPD_Input, 101 plugInfoCmd.m_destinationPlugs ) ) 102 { 103 debugError( "destination plug discovering failed\n" ); 104 return false; 105 } 106 107 if ( !discoverPlugs( AvPlug::eAPD_Output, 108 plugInfoCmd.m_sourcePlugs ) ) 109 { 110 debugError( "source plug discovering failed\n" ); 111 return false; 112 } 113 114 return true; 115 } 116 117 bool 118 BeBoB::AvDeviceSubunit::discoverConnections() 119 { 120 for ( AvPlugVector::iterator it = m_plugs.begin(); 121 it != m_plugs.end(); 122 ++it ) 123 { 124 AvPlug* plug = *it; 125 if ( !plug->discoverConnections() ) { 126 debugError( "plug connection discovering failed ('%s')\n", 127 plug->getName() ); 128 return false; 129 } 130 } 131 132 return true; 133 } 134 135 bool 136 BeBoB::AvDeviceSubunit::discoverPlugs(AvPlug::EAvPlugDirection plugDirection, 137 plug_id_t plugMaxId ) 138 { 139 for ( int plugIdx = 0; 140 plugIdx < plugMaxId; 141 ++plugIdx ) 142 { 143 ESubunitType subunitType = 144 static_cast<ESubunitType>( getSubunitType() ); 145 AvPlug* plug = new AvPlug( m_avDevice->get1394Service(), 146 m_avDevice->getConfigRom(), 147 m_avDevice->getPlugManager(), 148 subunitType, 149 getSubunitId(), 150 0xff, 151 0xff, 152 AvPlug::eAPA_SubunitPlug, 153 plugDirection, 154 plugIdx, 155 m_verboseLevel ); 156 if ( !plug || !plug->discover() ) { 157 debugError( "plug discover failed\n" ); 158 return false; 159 } 160 161 debugOutput( DEBUG_LEVEL_NORMAL, "plug '%s' found\n", 162 plug->getName() ); 163 m_plugs.push_back( plug ); 164 } 165 return true; 166 } 167 168 bool 169 BeBoB::AvDeviceSubunit::addPlug( AvPlug& plug ) 170 { 171 m_plugs.push_back( &plug ); 172 return true; 173 } 174 175 176 BeBoB::AvPlug* 177 BeBoB::AvDeviceSubunit::getPlug(AvPlug::EAvPlugDirection direction, plug_id_t plugId) 178 { 179 for ( AvPlugVector::iterator it = m_plugs.begin(); 180 it != m_plugs.end(); 181 ++it ) 182 { 183 AvPlug* plug = *it; 184 if ( ( plug->getPlugId() == plugId ) 185 && ( plug->getDirection() == direction ) ) 186 { 187 return plug; 188 } 189 } 190 return 0; 191 } 192 193 194 bool 195 BeBoB::AvDeviceSubunit::serialize( Glib::ustring basePath, 196 Util::IOSerialize& ser ) const 197 { 198 bool result; 199 200 result = ser.write( basePath + "m_sbType", m_sbType ); 201 result &= ser.write( basePath + "m_sbId", m_sbId ); 202 result &= ser.write( basePath + "m_verboseLevel", m_verboseLevel ); 203 result &= serializeChild( basePath, ser ); 204 205 return result; 206 } 207 208 BeBoB::AvDeviceSubunit* 209 BeBoB::AvDeviceSubunit::deserialize( Glib::ustring basePath, 210 Util::IODeserialize& deser, 211 AvDevice& avDevice ) 212 { 213 bool result; 214 ESubunitType sbType; 215 result = deser.read( basePath + "m_sbType", sbType ); 216 217 AvDeviceSubunit* pSubunit = 0; 218 switch( sbType ) { 219 case eST_Audio: 220 pSubunit = new AvDeviceSubunitAudio; 221 break; 222 case eST_Music: 223 pSubunit = new AvDeviceSubunitMusic; 224 break; 225 default: 226 pSubunit = 0; 227 } 228 229 if ( !pSubunit ) { 230 return 0; 231 } 232 233 pSubunit->m_avDevice = &avDevice; 234 pSubunit->m_sbType = sbType; 235 result &= deser.read( basePath + "m_sbId", pSubunit->m_sbId ); 236 result &= deser.read( basePath + "m_verboseLevel", pSubunit->m_verboseLevel ); 237 result &= pSubunit->deserializeChild( basePath, deser, avDevice ); 238 239 if ( !result ) { 240 delete pSubunit; 241 return 0; 242 } 243 244 return pSubunit; 245 } 246 247 //////////////////////////////////////////// 248 249 BeBoB::AvDeviceSubunitAudio::AvDeviceSubunitAudio( AvDevice& avDevice, 250 subunit_t id, 251 int verboseLevel ) 252 : AvDeviceSubunit( avDevice, eST_Audio, id, verboseLevel ) 253 { 254 } 255 256 BeBoB::AvDeviceSubunitAudio::AvDeviceSubunitAudio() 257 : AvDeviceSubunit() 258 { 259 } 260 261 BeBoB::AvDeviceSubunitAudio::~AvDeviceSubunitAudio() 262 { 263 for ( FunctionBlockVector::iterator it = m_functions.begin(); 264 it != m_functions.end(); 265 ++it ) 266 { 267 delete *it; 268 } 269 } 270 271 bool 272 BeBoB::AvDeviceSubunitAudio::discover() 38 39 BeBoB::SubunitAudio::SubunitAudio( AVC::Unit& avDevice, 40 subunit_t id ) 41 : AVC::SubunitAudio( avDevice, id ) 42 { 43 } 44 45 BeBoB::SubunitAudio::SubunitAudio() 46 : AVC::SubunitAudio() 47 { 48 } 49 50 BeBoB::SubunitAudio::~SubunitAudio() 51 { 52 53 } 54 55 bool 56 BeBoB::SubunitAudio::discover() 273 57 { 274 58 debugOutput(DEBUG_LEVEL_NORMAL, "Discovering Audio Subunit...\n"); 275 59 276 if ( !A vDeviceSubunit::discover() ) {60 if ( !AVC::SubunitAudio::discover() ) { 277 61 return false; 278 62 } … … 287 71 288 72 bool 289 BeBoB:: AvDeviceSubunitAudio::discoverConnections()73 BeBoB::SubunitAudio::discoverConnections() 290 74 { 291 75 debugOutput(DEBUG_LEVEL_NORMAL, "Discovering connections...\n"); 292 if ( ! AvDeviceSubunit::discoverConnections() ) {76 if ( !Subunit::discoverConnections() ) { 293 77 return false; 294 78 } … … 310 94 311 95 const char* 312 BeBoB:: AvDeviceSubunitAudio::getName()313 { 314 return " AudioSubunit";315 } 316 317 bool 318 BeBoB:: AvDeviceSubunitAudio::discoverFunctionBlocks()96 BeBoB::SubunitAudio::getName() 97 { 98 return "BeBoB::AudioSubunit"; 99 } 100 101 bool 102 BeBoB::SubunitAudio::discoverFunctionBlocks() 319 103 { 320 104 debugOutput( DEBUG_LEVEL_NORMAL, … … 348 132 // print a function block list 349 133 #ifdef DEBUG 350 if ( getDebugLevel() >= DEBUG_LEVEL_NORMAL) {134 if ((int)getDebugLevel() >= DEBUG_LEVEL_NORMAL) { 351 135 352 136 for ( FunctionBlockVector::iterator it = m_functions.begin(); … … 366 150 367 151 bool 368 BeBoB:: AvDeviceSubunitAudio::discoverFunctionBlocksDo(152 BeBoB::SubunitAudio::discoverFunctionBlocksDo( 369 153 ExtendedSubunitInfoCmd::EFunctionBlockType fbType ) 370 154 { … … 375 159 do { 376 160 ExtendedSubunitInfoCmd 377 extSubunitInfoCmd( m_avDevice->get1394Service() );378 extSubunitInfoCmd.setNodeId( m_ avDevice->getConfigRom().getNodeId() );161 extSubunitInfoCmd( m_unit->get1394Service() ); 162 extSubunitInfoCmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 379 163 extSubunitInfoCmd.setCommandType( AVCCommand::eCT_Status ); 380 164 extSubunitInfoCmd.setSubunitId( getSubunitId() ); 381 165 extSubunitInfoCmd.setSubunitType( getSubunitType() ); 382 extSubunitInfoCmd.setVerbose( m_verboseLevel);166 extSubunitInfoCmd.setVerbose( (int)getDebugLevel() ); 383 167 384 168 extSubunitInfoCmd.m_fbType = fbType; … … 414 198 415 199 bool 416 BeBoB:: AvDeviceSubunitAudio::createFunctionBlock(200 BeBoB::SubunitAudio::createFunctionBlock( 417 201 ExtendedSubunitInfoCmd::EFunctionBlockType fbType, 418 202 ExtendedSubunitInfoPageData& data ) … … 431 215 data.m_noOfInputPlugs, 432 216 data.m_noOfOutputPlugs, 433 m_verboseLevel);217 (int)getDebugLevel() ); 434 218 } 435 219 break; … … 441 225 data.m_noOfInputPlugs, 442 226 data.m_noOfOutputPlugs, 443 m_verboseLevel);227 (int)getDebugLevel() ); 444 228 } 445 229 break; … … 454 238 data.m_noOfInputPlugs, 455 239 data.m_noOfOutputPlugs, 456 m_verboseLevel);240 (int)getDebugLevel() ); 457 241 } 458 242 break; … … 471 255 data.m_noOfInputPlugs, 472 256 data.m_noOfOutputPlugs, 473 m_verboseLevel);257 (int)getDebugLevel() ); 474 258 debugWarning( "Dummy function block processing created. " 475 259 "Implementation is missing\n" ); … … 484 268 data.m_noOfInputPlugs, 485 269 data.m_noOfOutputPlugs, 486 m_verboseLevel);270 (int)getDebugLevel() ); 487 271 debugWarning( "Dummy function block codec created. " 488 272 "Implementation is missing\n" ); … … 510 294 511 295 BeBoB::FunctionBlock::ESpecialPurpose 512 BeBoB:: AvDeviceSubunitAudio::convertSpecialPurpose(296 BeBoB::SubunitAudio::convertSpecialPurpose( 513 297 function_block_special_purpose_t specialPurpose ) 514 298 { … … 528 312 529 313 bool 530 BeBoB:: AvDeviceSubunitAudio::serializeChild( Glib::ustring basePath,314 BeBoB::SubunitAudio::serializeChild( Glib::ustring basePath, 531 315 Util::IOSerialize& ser ) const 532 316 { … … 551 335 552 336 bool 553 BeBoB:: AvDeviceSubunitAudio::deserializeChild( Glib::ustring basePath,337 BeBoB::SubunitAudio::deserializeChild( Glib::ustring basePath, 554 338 Util::IODeserialize& deser, 555 A vDevice& avDevice )339 AVC::Unit& avDevice ) 556 340 { 557 341 int i = 0; … … 577 361 //////////////////////////////////////////// 578 362 579 BeBoB::AvDeviceSubunitMusic::AvDeviceSubunitMusic( AvDevice& avDevice, 580 subunit_t id, 581 int verboseLevel ) 582 : AvDeviceSubunit( avDevice, eST_Music, id, verboseLevel ) 583 { 584 } 585 586 BeBoB::AvDeviceSubunitMusic::AvDeviceSubunitMusic() 587 : AvDeviceSubunit() 588 { 589 } 590 591 BeBoB::AvDeviceSubunitMusic::~AvDeviceSubunitMusic() 363 BeBoB::SubunitMusic::SubunitMusic( AVC::Unit& avDevice, 364 subunit_t id ) 365 : AVC::SubunitMusic( avDevice, id ) 366 { 367 } 368 369 BeBoB::SubunitMusic::SubunitMusic() 370 : AVC::SubunitMusic() 371 { 372 } 373 374 BeBoB::SubunitMusic::~SubunitMusic() 592 375 { 593 376 } 594 377 595 378 const char* 596 BeBoB:: AvDeviceSubunitMusic::getName()597 { 598 return " MusicSubunit";599 } 600 601 bool 602 BeBoB:: AvDeviceSubunitMusic::serializeChild( Glib::ustring basePath,379 BeBoB::SubunitMusic::getName() 380 { 381 return "BeBoB::MusicSubunit"; 382 } 383 384 bool 385 BeBoB::SubunitMusic::serializeChild( Glib::ustring basePath, 603 386 Util::IOSerialize& ser ) const 604 387 { … … 607 390 608 391 bool 609 BeBoB:: AvDeviceSubunitMusic::deserializeChild( Glib::ustring basePath,392 BeBoB::SubunitMusic::deserializeChild( Glib::ustring basePath, 610 393 Util::IODeserialize& deser, 611 A vDevice& avDevice )612 { 613 return true; 614 } 394 AVC::Unit& avDevice ) 395 { 396 return true; 397 } branches/echoaudio/src/bebob/bebob_avdevice_subunit.h
r503 r507 35 35 #include <vector> 36 36 37 #include "libavc/general/avc_subunit.h" 38 #include "libavc/general/avc_plug.h" 39 37 40 namespace BeBoB { 38 39 class AvDevice;40 41 class AvDeviceSubunit {42 public:43 AvDeviceSubunit( AvDevice& avDevice,44 AVC::ESubunitType type,45 AVC::subunit_t id,46 int verboseLevel );47 virtual ~AvDeviceSubunit();48 49 virtual bool discover();50 virtual bool discoverConnections();51 virtual const char* getName() = 0;52 53 bool addPlug( AvPlug& plug );54 55 AVC::subunit_t getSubunitId()56 { return m_sbId; }57 AVC::ESubunitType getSubunitType()58 { return m_sbType; }59 60 AvPlugVector& getPlugs()61 { return m_plugs; }62 AvPlug* getPlug(AvPlug::EAvPlugDirection direction, AVC::plug_id_t plugId);63 64 65 AvDevice& getAvDevice() const66 { return *m_avDevice; }67 68 69 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;70 static AvDeviceSubunit* deserialize( Glib::ustring basePath,71 Util::IODeserialize& deser,72 AvDevice& avDevice );73 protected:74 AvDeviceSubunit();75 76 bool discoverPlugs();77 bool discoverPlugs(AvPlug::EAvPlugDirection plugDirection,78 AVC::plug_id_t plugMaxId );79 80 virtual bool serializeChild( Glib::ustring basePath,81 Util::IOSerialize& ser ) const = 0;82 virtual bool deserializeChild( Glib::ustring basePath,83 Util::IODeserialize& deser,84 AvDevice& avDevice ) = 0;85 86 protected:87 AvDevice* m_avDevice;88 AVC::ESubunitType m_sbType;89 AVC::subunit_t m_sbId;90 int m_verboseLevel;91 92 AvPlugVector m_plugs;93 94 DECLARE_DEBUG_MODULE;95 };96 97 typedef std::vector<AvDeviceSubunit*> AvDeviceSubunitVector;98 41 99 42 ///////////////////////////// 100 43 101 class AvDeviceSubunitAudio: public AvDeviceSubunit{44 class SubunitAudio: public AVC::SubunitAudio { 102 45 public: 103 AvDeviceSubunitAudio( AvDevice& avDevice, 104 AVC::subunit_t id, 105 int verboseLevel ); 106 AvDeviceSubunitAudio(); 107 virtual ~AvDeviceSubunitAudio(); 46 SubunitAudio( AVC::Unit& avDevice, 47 AVC::subunit_t id ); 48 SubunitAudio(); 49 virtual ~SubunitAudio(); 108 50 109 51 virtual bool discover(); … … 129 71 virtual bool deserializeChild( Glib::ustring basePath, 130 72 Util::IODeserialize& deser, 131 A vDevice& avDevice);73 AVC::Unit& unit ); 132 74 133 75 protected: … … 137 79 ///////////////////////////// 138 80 139 class AvDeviceSubunitMusic: public AvDeviceSubunit{81 class SubunitMusic: public AVC::SubunitMusic { 140 82 public: 141 AvDeviceSubunitMusic( AvDevice& avDevice, 142 AVC::subunit_t id, 143 int verboseLevel ); 144 AvDeviceSubunitMusic(); 145 virtual ~AvDeviceSubunitMusic(); 83 SubunitMusic( AVC::Unit& avDevice, 84 AVC::subunit_t id ); 85 SubunitMusic(); 86 virtual ~SubunitMusic(); 146 87 147 88 virtual const char* getName(); … … 152 93 virtual bool deserializeChild( Glib::ustring basePath, 153 94 Util::IODeserialize& deser, 154 A vDevice& avDevice);95 AVC::Unit& unit ); 155 96 }; 156 97 branches/echoaudio/src/bebob/bebob_avplug.cpp
r503 r507 35 35 namespace BeBoB { 36 36 37 int AvPlug::m_globalIdCounter = 0; 38 39 IMPL_DEBUG_MODULE( AvPlug, AvPlug, DEBUG_LEVEL_NORMAL ); 40 IMPL_DEBUG_MODULE( AvPlugManager, AvPlugManager, DEBUG_LEVEL_NORMAL ); 41 42 AvPlug::AvPlug( Ieee1394Service& ieee1394Service, 43 ConfigRom& configRom, 44 AvPlugManager& plugManager, 45 ESubunitType subunitType, 46 subunit_id_t subunitId, 47 function_block_type_t functionBlockType, 48 function_block_id_t functionBlockId, 49 EAvPlugAddressType plugAddressType, 50 EAvPlugDirection plugDirection, 51 plug_id_t plugId, 52 int verboseLevel ) 53 : m_p1394Service( &ieee1394Service ) 54 , m_pConfigRom( &configRom ) 55 , m_subunitType( subunitType ) 56 , m_subunitId( subunitId ) 57 , m_functionBlockType( functionBlockType ) 58 , m_functionBlockId( functionBlockId ) 59 , m_addressType( plugAddressType ) 60 , m_direction( plugDirection ) 61 , m_id( plugId ) 62 , m_infoPlugType( eAPT_Unknown ) 63 , m_nrOfChannels( 0 ) 64 , m_plugManager( &plugManager ) 65 , m_verboseLevel( verboseLevel ) 66 , m_globalId( m_globalIdCounter++ ) 67 { 68 setDebugLevel( m_verboseLevel ); 69 debugOutput( DEBUG_LEVEL_VERBOSE, 70 "nodeId = %d, subunitType = %d, " 71 "subunitId = %d, functionBlockType = %d, " 72 "functionBlockId = %d, addressType = %d, " 73 "direction = %d, id = %d\n", 74 m_pConfigRom->getNodeId(), 75 m_subunitType, 76 m_subunitId, 77 m_functionBlockType, 78 m_functionBlockId, 79 m_addressType, 80 m_direction, 81 m_id ); 82 } 83 84 AvPlug::AvPlug( const AvPlug& rhs ) 85 : m_p1394Service( rhs.m_p1394Service ) 86 , m_pConfigRom( rhs.m_pConfigRom ) 87 , m_subunitType( rhs.m_subunitType ) 88 , m_subunitId( rhs.m_subunitId ) 89 , m_functionBlockType( rhs.m_functionBlockType ) 90 , m_functionBlockId( rhs.m_functionBlockId ) 91 , m_addressType( rhs.m_addressType ) 92 , m_direction( rhs.m_direction ) 93 , m_id( rhs.m_id ) 94 , m_infoPlugType( rhs.m_infoPlugType ) 95 , m_nrOfChannels( rhs.m_nrOfChannels ) 96 , m_name( rhs.m_name ) 97 , m_clusterInfos( rhs.m_clusterInfos ) 98 , m_formatInfos( rhs.m_formatInfos ) 99 , m_plugManager( rhs.m_plugManager ) 100 , m_verboseLevel( rhs.m_verboseLevel ) 101 { 102 if ( m_verboseLevel ) { 103 setDebugLevel( DEBUG_LEVEL_VERBOSE ); 104 } 105 } 106 107 AvPlug::AvPlug() 108 : m_p1394Service( 0 ) 109 , m_pConfigRom( 0 ) 110 , m_subunitType( eST_Reserved ) // a good value for unknown/undefined? 111 , m_subunitId( 0 ) 112 , m_functionBlockType( 0 ) 113 , m_functionBlockId( 0 ) 114 , m_addressType( eAPA_Undefined ) 115 , m_direction( eAPD_Unknown ) 116 , m_id( 0 ) 117 , m_infoPlugType( eAPT_Unknown ) 118 , m_nrOfChannels( 0 ) 119 , m_plugManager( 0 ) 120 , m_verboseLevel( 0 ) 121 , m_globalId( 0 ) 122 { 123 } 124 125 AvPlug::~AvPlug() 126 { 127 if ( m_plugManager ) { 128 m_plugManager->remPlug( *this ); 129 } 130 } 131 132 bool 133 AvPlug::discover() 37 Plug::Plug( AVC::Unit* unit, 38 AVC::Subunit* subunit, 39 AVC::function_block_type_t functionBlockType, 40 AVC::function_block_type_t functionBlockId, 41 AVC::Plug::EPlugAddressType plugAddressType, 42 AVC::Plug::EPlugDirection plugDirection, 43 AVC::plug_id_t plugId ) 44 : AVC::Plug( unit, 45 subunit, 46 functionBlockType, 47 functionBlockId, 48 plugAddressType, 49 plugDirection, 50 plugId ) 51 { 52 53 } 54 55 Plug::Plug( const Plug& rhs ) 56 : AVC::Plug( rhs ) 57 { 58 } 59 60 Plug::Plug() 61 : AVC::Plug() 62 { 63 } 64 65 Plug::~Plug() 66 { 67 68 } 69 70 bool 71 Plug::discover() 134 72 { 135 73 if ( !discoverPlugType() ) { 136 74 debugError( "discover: Could not discover plug type (%d,%d,%d,%d,%d)\n", 137 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );75 m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 138 76 return false; 139 77 } … … 141 79 if ( !discoverName() ) { 142 80 debugError( "Could not discover name (%d,%d,%d,%d,%d)\n", 143 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );81 m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 144 82 return false; 145 83 } … … 148 86 debugError( "Could not discover number of channels " 149 87 "(%d,%d,%d,%d,%d)\n", 150 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );88 m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 151 89 return false; 152 90 } … … 155 93 debugError( "Could not discover channel positions " 156 94 "(%d,%d,%d,%d,%d)\n", 157 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );95 m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 158 96 return false; 159 97 } … … 162 100 debugError( "Could not discover channel name " 163 101 "(%d,%d,%d,%d,%d)\n", 164 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );102 m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 165 103 return false; 166 104 } … … 169 107 debugError( "Could not discover channel name " 170 108 "(%d,%d,%d,%d,%d)\n", 171 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );109 m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 172 110 return false; 173 111 } … … 176 114 debugError( "Could not discover stream format " 177 115 "(%d,%d,%d,%d,%d)\n", 178 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );116 m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 179 117 return false; 180 118 } … … 183 121 debugError( "Could not discover supported stream formats " 184 122 "(%d,%d,%d,%d,%d)\n", 185 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );186 return false; 187 } 188 189 return m_ plugManager->addPlug( *this );190 } 191 192 bool 193 AvPlug::discoverConnections()123 m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 124 return false; 125 } 126 127 return m_unit->getPlugManager().addPlug( *this ); 128 } 129 130 bool 131 Plug::discoverConnections() 194 132 { 195 133 return discoverConnectionsInput() && discoverConnectionsOutput(); … … 197 135 198 136 bool 199 AvPlug::inquireConnnection( AvPlug& plug ) 200 { 201 SignalSourceCmd signalSourceCmd = setSrcPlugAddrToSignalCmd(); 202 setDestPlugAddrToSignalCmd( signalSourceCmd, plug ); 203 signalSourceCmd.setCommandType( AVCCommand::eCT_SpecificInquiry ); 204 signalSourceCmd.setVerbose( m_verboseLevel ); 205 206 if ( !signalSourceCmd.fire() ) { 207 debugError( "Could not inquire connection between '%s' and '%s'\n", 208 getName(), plug.getName() ); 209 return false; 210 } 211 212 if ( signalSourceCmd.getResponse() == AVCCommand::eR_Implemented ) { 213 debugOutput( DEBUG_LEVEL_VERBOSE, 214 "Connection possible between '%s' and '%s'\n", 215 getName(), plug.getName() ); 216 return true; 217 } 218 debugOutput( DEBUG_LEVEL_VERBOSE, 219 "Connection not possible between '%s' and '%s'\n", 220 getName(), plug.getName() ); 221 return false; 222 } 223 224 bool 225 AvPlug::setConnection( AvPlug& plug ) 226 { 227 SignalSourceCmd signalSourceCmd = setSrcPlugAddrToSignalCmd(); 228 setDestPlugAddrToSignalCmd( signalSourceCmd, plug ); 229 signalSourceCmd.setCommandType( AVCCommand::eCT_Control ); 230 signalSourceCmd.setVerbose( m_verboseLevel ); 231 232 if ( !signalSourceCmd.fire() ) { 233 debugError( "Could not set connection between '%s' and '%s'\n", 234 getName(), plug.getName() ); 235 return false; 236 } 237 238 if ( signalSourceCmd.getResponse() == AVCCommand::eR_Accepted ) { 239 debugOutput( DEBUG_LEVEL_VERBOSE, 240 "Could set connection between '%s' and '%s'\n", 241 getName(), plug.getName() ); 242 return true; 243 } 244 debugOutput( DEBUG_LEVEL_VERBOSE, 245 "Could not set connection between '%s' and '%s'\n", 246 getName(), plug.getName() ); 247 return false; 248 } 249 250 int 251 AvPlug::getNrOfStreams() const 252 { 253 int nrOfChannels = 0; 254 for ( ClusterInfoVector::const_iterator it = m_clusterInfos.begin(); 255 it != m_clusterInfos.end(); 256 ++it ) 257 { 258 const ClusterInfo* clusterInfo = &( *it ); 259 nrOfChannels += clusterInfo->m_nrOfChannels; 260 } 261 return nrOfChannels; 262 } 263 264 int 265 AvPlug::getNrOfChannels() const 266 { 267 return m_nrOfChannels; 268 } 269 270 int 271 AvPlug::getSampleRate() const 272 { 273 return convertESamplingFrequency( static_cast<ESamplingFrequency>( m_samplingFrequency ) ); 274 } 275 276 bool 277 AvPlug::discoverPlugType() 137 Plug::discoverPlugType() 278 138 { 279 139 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); … … 282 142 extendedPlugInfoInfoType.initialize(); 283 143 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 284 extPlugInfoCmd.setVerbose( m_verboseLevel);144 extPlugInfoCmd.setVerbose( getDebugLevel() ); 285 145 286 146 if ( !extPlugInfoCmd.fire() ) { … … 338 198 339 199 bool 340 AvPlug::discoverName()200 Plug::discoverName() 341 201 { 342 202 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); … … 345 205 extendedPlugInfoInfoType.initialize(); 346 206 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 347 extPlugInfoCmd.setVerbose( m_verboseLevel);207 extPlugInfoCmd.setVerbose( getDebugLevel() ); 348 208 349 209 if ( !extPlugInfoCmd.fire() ) { … … 370 230 371 231 bool 372 AvPlug::discoverNoOfChannels()232 Plug::discoverNoOfChannels() 373 233 { 374 234 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); … … 378 238 extendedPlugInfoInfoType.initialize(); 379 239 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 380 extPlugInfoCmd.setVerbose( m_verboseLevel);240 extPlugInfoCmd.setVerbose( getDebugLevel() ); 381 241 382 242 if ( !extPlugInfoCmd.fire() ) { … … 403 263 404 264 bool 405 AvPlug::discoverChannelPosition()265 Plug::discoverChannelPosition() 406 266 { 407 267 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); … … 410 270 extendedPlugInfoInfoType.initialize(); 411 271 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 412 extPlugInfoCmd.setVerbose( m_verboseLevel);272 extPlugInfoCmd.setVerbose( getDebugLevel() ); 413 273 414 274 if ( !extPlugInfoCmd.fire() ) { … … 439 299 440 300 bool 441 AvPlug::discoverChannelName()301 Plug::discoverChannelName() 442 302 { 443 303 for ( ClusterInfoVector::iterator clit = m_clusterInfos.begin(); … … 458 318 extendedPlugInfoInfoType.initialize(); 459 319 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 460 extPlugInfoCmd.setVerbose( m_verboseLevel);320 extPlugInfoCmd.setVerbose( getDebugLevel() ); 461 321 462 322 ExtendedPlugInfoInfoType* infoType = … … 491 351 492 352 bool 493 AvPlug::discoverClusterInfo()353 Plug::discoverClusterInfo() 494 354 { 495 355 if ( m_infoPlugType == eAPT_Sync ) … … 518 378 extendedPlugInfoInfoType.initialize(); 519 379 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 520 extPlugInfoCmd.setVerbose( m_verboseLevel);380 extPlugInfoCmd.setVerbose( getDebugLevel() ); 521 381 522 382 extPlugInfoCmd.getInfoType()->m_plugClusterInfo->m_clusterIndex = … … 551 411 552 412 bool 553 AvPlug::discoverStreamFormat()413 Plug::discoverStreamFormat() 554 414 { 555 415 ExtendedStreamFormatCmd extStreamFormatCmd = 556 416 setPlugAddrToStreamFormatCmd( ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommand ); 557 extStreamFormatCmd.setVerbose( m_verboseLevel);417 extStreamFormatCmd.setVerbose( getDebugLevel() ); 558 418 559 419 if ( !extStreamFormatCmd.fire() ) { … … 674 534 675 535 bool 676 AvPlug::discoverSupportedStreamFormats()536 Plug::discoverSupportedStreamFormats() 677 537 { 678 538 ExtendedStreamFormatCmd extStreamFormatCmd = 679 539 setPlugAddrToStreamFormatCmd( 680 540 ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommandList); 681 extStreamFormatCmd.setVerbose( m_verboseLevel);541 extStreamFormatCmd.setVerbose( getDebugLevel() ); 682 542 683 543 int i = 0; … … 770 630 771 631 bool 772 AvPlug::discoverConnectionsInput()632 Plug::discoverConnectionsInput() 773 633 { 774 634 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); … … 777 637 extendedPlugInfoInfoType.initialize(); 778 638 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 779 extPlugInfoCmd.setVerbose( m_verboseLevel);639 extPlugInfoCmd.setVerbose( getDebugLevel() ); 780 640 781 641 if ( !extPlugInfoCmd.fire() ) { … … 822 682 823 683 bool 824 AvPlug::discoverConnectionsOutput()684 Plug::discoverConnectionsOutput() 825 685 { 826 686 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); … … 829 689 extendedPlugInfoInfoType.initialize(); 830 690 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 831 extPlugInfoCmd.setVerbose( m_verboseLevel);691 extPlugInfoCmd.setVerbose( getDebugLevel() ); 832 692 833 693 if ( !extPlugInfoCmd.fire() ) { … … 885 745 } 886 746 887 bool888 AvPlug::discoverConnectionsFromSpecificData(889 EAvPlugDirection discoverDirection,890 PlugAddressSpecificData* plugAddress,891 AvPlugVector& connections )892 {893 UnitPlugSpecificDataPlugAddress* pUnitPlugAddress =894 dynamic_cast<UnitPlugSpecificDataPlugAddress*>895 ( plugAddress->m_plugAddressData );896 897 SubunitPlugSpecificDataPlugAddress* pSubunitPlugAddress =898 dynamic_cast<SubunitPlugSpecificDataPlugAddress*>899 ( plugAddress->m_plugAddressData );900 901 FunctionBlockPlugSpecificDataPlugAddress*902 pFunctionBlockPlugAddress =903 dynamic_cast<FunctionBlockPlugSpecificDataPlugAddress*>904 ( plugAddress->m_plugAddressData );905 906 AvPlug* plug = getPlugDefinedBySpecificData(907 pUnitPlugAddress,908 pSubunitPlugAddress,909 pFunctionBlockPlugAddress );910 911 if ( plug ) {912 debugOutput( DEBUG_LEVEL_VERBOSE,913 "'(%d) %s' has a connection to '(%d) %s'\n",914 getGlobalId(),915 getName(),916 plug->getGlobalId(),917 plug->getName() );918 addPlugConnection( connections, *plug );919 } else {920 debugError( "no corresponding plug found for '(%d) %s'\n",921 getGlobalId(),922 getName() );923 return false;924 }925 926 return true;927 }928 929 bool930 AvPlug::addPlugConnection( AvPlugVector& connections,931 AvPlug& plug )932 933 {934 for ( AvPlugVector::iterator it = connections.begin();935 it != connections.end();936 ++it )937 {938 AvPlug* cPlug = *it;939 if ( cPlug == &plug ) {940 debugOutput( DEBUG_LEVEL_VERBOSE,941 "plug '%s' already in connection list\n",942 plug.getName() );943 return true;944 }945 }946 947 connections.push_back( &plug );948 return true;949 }950 951 747 ExtendedPlugInfoCmd 952 AvPlug::setPlugAddrToPlugInfoCmd()953 { 954 ExtendedPlugInfoCmd extPlugInfoCmd( *m_p1394Service);955 956 switch( m_subunitType) {748 Plug::setPlugAddrToPlugInfoCmd() 749 { 750 ExtendedPlugInfoCmd extPlugInfoCmd( m_unit->get1394Service() ); 751 752 switch( getSubunitType() ) { 957 753 case eST_Unit: 958 754 { … … 1016 812 } 1017 813 1018 extPlugInfoCmd.setNodeId( m_ pConfigRom->getNodeId() );814 extPlugInfoCmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 1019 815 extPlugInfoCmd.setCommandType( AVCCommand::eCT_Status ); 1020 extPlugInfoCmd.setSubunitId( m_subunitId);1021 extPlugInfoCmd.setSubunitType( m_subunitType);816 extPlugInfoCmd.setSubunitId( getSubunitId() ); 817 extPlugInfoCmd.setSubunitType( getSubunitType() ); 1022 818 1023 819 return extPlugInfoCmd; … … 1025 821 1026 822 ExtendedStreamFormatCmd 1027 AvPlug::setPlugAddrToStreamFormatCmd(823 Plug::setPlugAddrToStreamFormatCmd( 1028 824 ExtendedStreamFormatCmd::ESubFunction subFunction) 1029 825 { 1030 826 ExtendedStreamFormatCmd extStreamFormatInfoCmd( 1031 *m_p1394Service,827 m_unit->get1394Service(), 1032 828 subFunction ); 1033 switch( m_subunitType) {829 switch( getSubunitType() ) { 1034 830 case eST_Unit: 1035 831 { … … 1091 887 } 1092 888 1093 extStreamFormatInfoCmd.setNodeId( m_ pConfigRom->getNodeId() );889 extStreamFormatInfoCmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 1094 890 extStreamFormatInfoCmd.setCommandType( AVCCommand::eCT_Status ); 1095 extStreamFormatInfoCmd.setSubunitId( m_subunitId);1096 extStreamFormatInfoCmd.setSubunitType( m_subunitType);891 extStreamFormatInfoCmd.setSubunitId( getSubunitId() ); 892 extStreamFormatInfoCmd.setSubunitType( getSubunitType() ); 1097 893 1098 894 return extStreamFormatInfoCmd; 1099 895 } 1100 896 1101 SignalSourceCmd 1102 AvPlug::setSrcPlugAddrToSignalCmd() 1103 { 1104 SignalSourceCmd signalSourceCmd( *m_p1394Service ); 1105 1106 switch( m_subunitType ) { 1107 case eST_Unit: 1108 { 1109 SignalUnitAddress signalUnitAddr; 1110 if ( getPlugAddressType() == eAPA_ExternalPlug ) { 1111 signalUnitAddr.m_plugId = m_id + 0x80; 1112 } else { 1113 signalUnitAddr.m_plugId = m_id; 1114 } 1115 signalSourceCmd.setSignalSource( signalUnitAddr ); 1116 } 1117 break; 1118 case eST_Music: 1119 case eST_Audio: 1120 { 1121 SignalSubunitAddress signalSubunitAddr; 1122 signalSubunitAddr.m_subunitType = m_subunitType; 1123 signalSubunitAddr.m_subunitId = m_subunitId; 1124 signalSubunitAddr.m_plugId = m_id; 1125 signalSourceCmd.setSignalSource( signalSubunitAddr ); 1126 } 1127 break; 1128 default: 1129 debugError( "Unknown subunit type\n" ); 1130 } 1131 1132 signalSourceCmd.setNodeId( m_pConfigRom->getNodeId() ); 1133 signalSourceCmd.setSubunitType( eST_Unit ); 1134 signalSourceCmd.setSubunitId( 0xff ); 1135 1136 return signalSourceCmd; 1137 } 1138 1139 void 1140 AvPlug::setDestPlugAddrToSignalCmd(SignalSourceCmd& signalSourceCmd, 1141 AvPlug& plug) 1142 { 1143 switch( plug.m_subunitType ) { 1144 case eST_Unit: 1145 { 1146 SignalUnitAddress signalUnitAddr; 1147 if ( plug.getPlugAddressType() == eAPA_ExternalPlug ) { 1148 signalUnitAddr.m_plugId = plug.m_id + 0x80; 1149 } else { 1150 signalUnitAddr.m_plugId = plug.m_id; 1151 } 1152 signalSourceCmd.setSignalDestination( signalUnitAddr ); 1153 } 1154 break; 1155 case eST_Music: 1156 case eST_Audio: 1157 { 1158 SignalSubunitAddress signalSubunitAddr; 1159 signalSubunitAddr.m_subunitType = plug.m_subunitType; 1160 signalSubunitAddr.m_subunitId = plug.m_subunitId; 1161 signalSubunitAddr.m_plugId = plug.m_id; 1162 signalSourceCmd.setSignalDestination( signalSubunitAddr ); 1163 } 1164 break; 1165 default: 1166 debugError( "Unknown subunit type\n" ); 1167 } 1168 } 1169 1170 1171 bool 1172 AvPlug::copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData& 1173 channelPositionData ) 1174 { 1175 int index = 1; 1176 for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfoVector::const_iterator it 1177 = channelPositionData.m_clusterInfos.begin(); 1178 it != channelPositionData.m_clusterInfos.end(); 1179 ++it ) 1180 { 1181 const ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfo* 1182 extPlugSpClusterInfo = &( *it ); 1183 1184 ClusterInfo clusterInfo; 1185 clusterInfo.m_nrOfChannels = extPlugSpClusterInfo->m_nrOfChannels; 1186 clusterInfo.m_index = index; 1187 index++; 1188 1189 for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfoVector::const_iterator cit 1190 = extPlugSpClusterInfo->m_channelInfos.begin(); 1191 cit != extPlugSpClusterInfo->m_channelInfos.end(); 1192 ++cit ) 1193 { 1194 const ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfo* 1195 extPlugSpChannelInfo = &( *cit ); 1196 1197 ChannelInfo channelInfo; 1198 channelInfo.m_streamPosition = 1199 extPlugSpChannelInfo->m_streamPosition; 1200 channelInfo.m_location = 1201 extPlugSpChannelInfo->m_location; 1202 1203 clusterInfo.m_channelInfos.push_back( channelInfo ); 1204 } 1205 m_clusterInfos.push_back( clusterInfo ); 1206 } 1207 1208 return true; 1209 } 1210 1211 void 1212 AvPlug::debugOutputClusterInfos( int debugLevel ) 1213 { 1214 for ( ClusterInfoVector::const_iterator it = m_clusterInfos.begin(); 1215 it != m_clusterInfos.end(); 1216 ++it ) 1217 { 1218 const ClusterInfo* clusterInfo = &( *it ); 1219 1220 debugOutput( debugLevel, "number of channels: %d\n", 1221 clusterInfo->m_nrOfChannels ); 1222 1223 for ( ChannelInfoVector::const_iterator cit 1224 = clusterInfo->m_channelInfos.begin(); 1225 cit != clusterInfo->m_channelInfos.end(); 1226 ++cit ) 1227 { 1228 const ChannelInfo* channelInfo = &( *cit ); 1229 channelInfo = channelInfo; 1230 debugOutput( debugLevel, 1231 "stream position: %d\n", 1232 channelInfo->m_streamPosition ); 1233 debugOutput( debugLevel, 1234 "location: %d\n", 1235 channelInfo->m_location ); 1236 } 1237 } 1238 } 1239 1240 const AvPlug::ClusterInfo* 1241 AvPlug::getClusterInfoByIndex(int index) const 1242 { 1243 for ( AvPlug::ClusterInfoVector::const_iterator clit = 1244 m_clusterInfos.begin(); 1245 clit != m_clusterInfos.end(); 1246 ++clit ) 1247 { 1248 const ClusterInfo* info = &*clit; 1249 if ( info->m_index == index ) { 1250 return info; 1251 } 1252 } 1253 return 0; 1254 } 1255 1256 PlugAddress::EPlugDirection 1257 AvPlug::convertPlugDirection( EAvPlugDirection direction ) 1258 { 1259 PlugAddress::EPlugDirection dir; 1260 switch ( direction ) { 1261 case AvPlug::eAPD_Input: 1262 dir = PlugAddress::ePD_Input; 1263 break; 1264 case AvPlug::eAPD_Output: 1265 dir = PlugAddress::ePD_Output; 1266 break; 1267 default: 1268 dir = PlugAddress::ePD_Undefined; 1269 } 1270 return dir; 1271 } 1272 1273 void 1274 AvPlug::showPlug() const 1275 { 1276 debugOutput( DEBUG_LEVEL_VERBOSE, "\tName = %s\n", 1277 getName() ); 1278 debugOutput( DEBUG_LEVEL_VERBOSE, "\tType = %s\n", 1279 extendedPlugInfoPlugTypeToString( getPlugType() ) ); 1280 debugOutput( DEBUG_LEVEL_VERBOSE, "\tAddress Type = %s\n", 1281 avPlugAddressTypeToString( getPlugAddressType() ) ); 1282 debugOutput( DEBUG_LEVEL_VERBOSE, "\tId = %d\n", 1283 getPlugId() ); 1284 debugOutput( DEBUG_LEVEL_VERBOSE, "\tSubunitType = %d\n", 1285 getSubunitType() ); 1286 debugOutput( DEBUG_LEVEL_VERBOSE, "\tSubunitId = %d\n", 1287 getSubunitId() ); 1288 debugOutput( DEBUG_LEVEL_VERBOSE, "\tDirection = %s\n", 1289 avPlugDirectionToString( getPlugDirection() ) ); 1290 debugOutput( DEBUG_LEVEL_VERBOSE, "\tSampling Rate = %d\n", 1291 getSampleRate() ); 1292 debugOutput( DEBUG_LEVEL_VERBOSE, "\tNumber of Channels = %d\n", 1293 getNrOfChannels() ); 1294 debugOutput( DEBUG_LEVEL_VERBOSE, "\tNumber of Streams = %d\n", 1295 getNrOfStreams() ); 1296 } 1297 1298 1299 AvPlug* 1300 AvPlug::getPlugDefinedBySpecificData( 1301 UnitPlugSpecificDataPlugAddress* pUnitPlugAddress, 1302 SubunitPlugSpecificDataPlugAddress* pSubunitPlugAddress, 1303 FunctionBlockPlugSpecificDataPlugAddress* pFunctionBlockPlugAddress ) 1304 { 1305 subunit_type_t subunitType = 0xff; 1306 subunit_id_t subunitId = 0xff; 1307 function_block_type_t functionBlockType = 0xff; 1308 function_block_id_t functionBlockId = 0xff; 1309 EAvPlugAddressType addressType = eAPA_Undefined; 1310 EAvPlugDirection direction = eAPD_Unknown; 1311 plug_id_t plugId = 0xff; 1312 1313 if ( !pUnitPlugAddress 1314 && !pSubunitPlugAddress 1315 && !pFunctionBlockPlugAddress ) 1316 { 1317 debugError( "No correct specific data found\n" ); 1318 return 0; 1319 } 1320 1321 if ( pUnitPlugAddress ) { 1322 subunitType = eST_Unit; 1323 switch ( pUnitPlugAddress->m_plugType ) { 1324 case UnitPlugSpecificDataPlugAddress::ePT_PCR: 1325 addressType = eAPA_PCR; 1326 break; 1327 case UnitPlugSpecificDataPlugAddress::ePT_ExternalPlug: 1328 addressType = eAPA_ExternalPlug; 1329 break; 1330 case UnitPlugSpecificDataPlugAddress::ePT_AsynchronousPlug: 1331 addressType = eAPA_AsynchronousPlug; 1332 break; 1333 } 1334 // unit plug have only connections to subunits 1335 if ( getPlugAddressType() == eAPA_SubunitPlug ) { 1336 direction = getDirection(); 1337 } else { 1338 debugError( "Function block has connection from/to unknown " 1339 "plug type\n" ); 1340 direction = eAPD_Unknown; 1341 } 1342 plugId = pUnitPlugAddress->m_plugId; 1343 1344 debugOutput( DEBUG_LEVEL_VERBOSE, 1345 "'(%d) %s': Remote plug is a unit plug " 1346 "(%s, %s, %d)\n", 1347 getGlobalId(), 1348 getName(), 1349 avPlugAddressTypeToString( addressType ), 1350 avPlugDirectionToString( direction ), 1351 plugId ); 1352 } 1353 1354 if ( pSubunitPlugAddress ) { 1355 subunitType = pSubunitPlugAddress->m_subunitType; 1356 subunitId = pSubunitPlugAddress->m_subunitId; 1357 addressType = eAPA_SubunitPlug; 1358 1359 if ( getPlugAddressType() == eAPA_FunctionBlockPlug ) { 1360 direction = getDirection(); 1361 } else if ( getPlugAddressType() == eAPA_SubunitPlug ) { 1362 direction = toggleDirection( getDirection() ); 1363 } else { 1364 // unit 1365 direction = getDirection(); 1366 } 1367 1368 plugId = pSubunitPlugAddress->m_plugId; 1369 debugOutput( DEBUG_LEVEL_VERBOSE, 1370 "'(%d) %s': Remote plug is a subunit plug " 1371 "(%d, %d, %s, %d)\n", 1372 getGlobalId(), 1373 getName(), 1374 subunitType, 1375 subunitId, 1376 avPlugDirectionToString( direction ), 1377 plugId ); 1378 } 1379 1380 if ( pFunctionBlockPlugAddress ) { 1381 subunitType = pFunctionBlockPlugAddress->m_subunitType; 1382 subunitId = pFunctionBlockPlugAddress->m_subunitId; 1383 functionBlockType = pFunctionBlockPlugAddress->m_functionBlockType; 1384 functionBlockId = pFunctionBlockPlugAddress->m_functionBlockId; 1385 addressType = eAPA_FunctionBlockPlug; 1386 1387 if ( getPlugAddressType() == eAPA_FunctionBlockPlug ) { 1388 direction = toggleDirection( getDirection() ); 1389 } else if ( getPlugAddressType() == eAPA_SubunitPlug ){ 1390 direction = getDirection(); 1391 } else { 1392 debugError( "Function block has connection from/to unknown " 1393 "plug type\n" ); 1394 direction = eAPD_Unknown; 1395 } 1396 1397 plugId = pFunctionBlockPlugAddress->m_plugId; 1398 1399 debugOutput( DEBUG_LEVEL_VERBOSE, 1400 "'(%d) %s': Remote plug is a functionblock plug " 1401 "(%d, %d, %d, %d, %s, %d)\n", 1402 getGlobalId(), 1403 getName(), 1404 subunitType, 1405 subunitId, 1406 functionBlockType, 1407 functionBlockId, 1408 avPlugDirectionToString( direction ), 1409 plugId ); 1410 } 1411 1412 ESubunitType enumSubunitType = 1413 static_cast<ESubunitType>( subunitType ); 1414 1415 return m_plugManager->getPlug( 1416 enumSubunitType, 1417 subunitId, 1418 functionBlockType, 1419 functionBlockId, 1420 addressType, 1421 direction, 1422 plugId ); 1423 } 1424 1425 AvPlug::EAvPlugDirection 1426 AvPlug::toggleDirection( EAvPlugDirection direction ) const 1427 { 1428 EAvPlugDirection newDirection; 1429 switch ( direction ) { 1430 case eAPD_Output: 1431 newDirection = eAPD_Input; 1432 break; 1433 case eAPD_Input: 1434 newDirection = eAPD_Output; 1435 break; 1436 default: 1437 newDirection = direction; 1438 } 1439 1440 return newDirection; 1441 } 1442 1443 bool 1444 AvPlug::serializeChannelInfos( Glib::ustring basePath, 1445 Util::IOSerialize& ser, 1446 const ClusterInfo& clusterInfo ) const 1447 { 1448 bool result = true; 1449 int i = 0; 1450 for ( ChannelInfoVector::const_iterator it = clusterInfo.m_channelInfos.begin(); 1451 it != clusterInfo.m_channelInfos.end(); 1452 ++it ) 1453 { 1454 const ChannelInfo& info = *it; 1455 std::ostringstream strstrm; 1456 strstrm << basePath << i; 1457 1458 result &= ser.write( strstrm.str() + "/m_streamPosition", info.m_streamPosition ); 1459 result &= ser.write( strstrm.str() + "/m_location", info.m_location ); 1460 result &= ser.write( strstrm.str() + "/m_name", info.m_name ); 1461 } 1462 1463 return result; 1464 } 1465 1466 bool 1467 AvPlug::deserializeChannelInfos( Glib::ustring basePath, 1468 Util::IODeserialize& deser, 1469 ClusterInfo& clusterInfo ) 1470 { 1471 int i = 0; 1472 bool bFinished = false; 1473 bool result = true; 1474 do { 1475 std::ostringstream strstrm; 1476 strstrm << basePath << i; 1477 1478 // check for one element to exist. when one exist the other elements 1479 // must also be there. otherwise just return (last) result. 1480 if ( deser.isExisting( strstrm.str() + "/m_streamPosition" ) ) { 1481 ChannelInfo info; 1482 1483 result &= deser.read( strstrm.str() + "/m_streamPosition", info.m_streamPosition ); 1484 result &= deser.read( strstrm.str() + "/m_location", info.m_location ); 1485 result &= deser.read( strstrm.str() + "/m_name", info.m_name ); 1486 1487 if ( result ) { 1488 clusterInfo.m_channelInfos.push_back( info ); 1489 i++; 1490 } else { 1491 bFinished = true; 1492 } 1493 } else { 1494 bFinished = true; 1495 } 1496 } while ( !bFinished ); 1497 1498 return result; 1499 } 1500 1501 1502 bool 1503 AvPlug::serializeClusterInfos( Glib::ustring basePath, 1504 Util::IOSerialize& ser ) const 1505 { 1506 bool result = true; 1507 int i = 0; 1508 for ( ClusterInfoVector::const_iterator it = m_clusterInfos.begin(); 1509 it != m_clusterInfos.end(); 1510 ++it ) 1511 { 1512 const ClusterInfo& info = *it; 1513 std::ostringstream strstrm; 1514 strstrm << basePath << i; 1515 1516 result &= ser.write( strstrm.str() + "/m_index", info.m_index ); 1517 result &= ser.write( strstrm.str() + "/m_portType", info.m_portType ); 1518 result &= ser.write( strstrm.str() + "/m_name", info.m_name ); 1519 result &= ser.write( strstrm.str() + "/m_nrOfChannels", info.m_nrOfChannels ); 1520 result &= serializeChannelInfos( strstrm.str() + "/m_channelInfo", ser, info ); 1521 result &= ser.write( strstrm.str() + "/m_streamFormat", info.m_streamFormat ); 1522 1523 } 1524 1525 return result; 1526 } 1527 1528 bool 1529 AvPlug::deserializeClusterInfos( Glib::ustring basePath, 1530 Util::IODeserialize& deser ) 1531 { 1532 int i = 0; 1533 bool bFinished = false; 1534 bool result = true; 1535 do { 1536 std::ostringstream strstrm; 1537 strstrm << basePath << i; 1538 1539 // check for one element to exist. when one exist the other elements 1540 // must also be there. otherwise just return (last) result. 1541 if ( deser.isExisting( strstrm.str() + "/m_index" ) ) { 1542 ClusterInfo info; 1543 1544 result &= deser.read( strstrm.str() + "/m_index", info.m_index ); 1545 result &= deser.read( strstrm.str() + "/m_portType", info.m_portType ); 1546 result &= deser.read( strstrm.str() + "/m_name", info.m_name ); 1547 result &= deser.read( strstrm.str() + "/m_nrOfChannels", info.m_nrOfChannels ); 1548 result &= deserializeChannelInfos( strstrm.str() + "/m_channelInfo", deser, info ); 1549 result &= deser.read( strstrm.str() + "/m_streamFormat", info.m_streamFormat ); 1550 1551 if ( result ) { 1552 m_clusterInfos.push_back( info ); 1553 i++; 1554 } else { 1555 bFinished = true; 1556 } 1557 } else { 1558 bFinished = true; 1559 } 1560 } while ( !bFinished ); 1561 1562 return result; 1563 } 1564 1565 1566 bool 1567 AvPlug::serializeFormatInfos( Glib::ustring basePath, 1568 Util::IOSerialize& ser ) const 1569 { 1570 bool result = true; 1571 int i = 0; 1572 for ( FormatInfoVector::const_iterator it = m_formatInfos.begin(); 1573 it != m_formatInfos.end(); 1574 ++it ) 1575 { 1576 const FormatInfo& info = *it; 1577 std::ostringstream strstrm; 1578 strstrm << basePath << i; 1579 1580 result &= ser.write( strstrm.str() + "/m_samplingFrequency", info.m_samplingFrequency ); 1581 result &= ser.write( strstrm.str() + "/m_isSyncStream", info.m_isSyncStream ); 1582 result &= ser.write( strstrm.str() + "/m_audioChannels", info.m_audioChannels ); 1583 result &= ser.write( strstrm.str() + "/m_midiChannels", info.m_midiChannels ); 1584 result &= ser.write( strstrm.str() + "/m_index", info.m_index ); 1585 } 1586 return result; 1587 } 1588 1589 bool 1590 AvPlug::deserializeFormatInfos( Glib::ustring basePath, 1591 Util::IODeserialize& deser ) 1592 { 1593 int i = 0; 1594 bool bFinished = false; 1595 bool result = true; 1596 do { 1597 std::ostringstream strstrm; 1598 strstrm << basePath << i; 1599 1600 // check for one element to exist. when one exist the other elements 1601 // must also be there. otherwise just return (last) result. 1602 if ( deser.isExisting( strstrm.str() + "/m_samplingFrequency" ) ) { 1603 FormatInfo info; 1604 1605 result &= deser.read( strstrm.str() + "/m_samplingFrequency", info.m_samplingFrequency ); 1606 result &= deser.read( strstrm.str() + "/m_isSyncStream", info.m_isSyncStream ); 1607 result &= deser.read( strstrm.str() + "/m_audioChannels", info.m_audioChannels ); 1608 result &= deser.read( strstrm.str() + "/m_midiChannels", info.m_midiChannels ); 1609 result &= deser.read( strstrm.str() + "/m_index", info.m_index ); 1610 1611 if ( result ) { 1612 m_formatInfos.push_back( info ); 1613 i++; 1614 } else { 1615 bFinished = true; 1616 } 1617 } else { 1618 bFinished = true; 1619 } 1620 } while ( !bFinished ); 1621 1622 return result; 1623 } 1624 1625 1626 bool 1627 AvPlug::serializeAvPlugVector( Glib::ustring basePath, 1628 Util::IOSerialize& ser, 1629 const AvPlugVector& vec) const 1630 { 1631 bool result = true; 1632 int i = 0; 1633 for ( AvPlugVector::const_iterator it = vec.begin(); 1634 it != vec.end(); 1635 ++it ) 1636 { 1637 const AvPlug* pPlug = *it; 1638 std::ostringstream strstrm; 1639 strstrm << basePath << i; 1640 1641 result &= ser.write( strstrm.str() + "/global_id", pPlug->getGlobalId() ); 1642 i++; 1643 } 1644 return result; 1645 } 1646 1647 bool 1648 AvPlug::deserializeAvPlugVector( Glib::ustring basePath, 1649 Util::IODeserialize& deser, 1650 AvPlugVector& vec ) 1651 { 1652 int i = 0; 1653 bool bFinished = false; 1654 bool result = true; 1655 do { 1656 std::ostringstream strstrm; 1657 strstrm << basePath << i; 1658 1659 // check for one element to exist. when one exist the other elements 1660 // must also be there. otherwise just return (last) result. 1661 if ( deser.isExisting( strstrm.str() + "/global_id" ) ) { 1662 unsigned int iPlugId; 1663 result &= deser.read( strstrm.str() + "/global_id", iPlugId ); 1664 1665 if ( result ) { 1666 AvPlug* pPlug = m_plugManager->getPlug( iPlugId ); 1667 if ( pPlug ) { 1668 vec.push_back( pPlug ); 1669 } else { 1670 result = false; 1671 bFinished = true; 1672 } 1673 i++; 1674 } else { 1675 bFinished = true; 1676 } 1677 } else { 1678 bFinished = true; 1679 } 1680 } while ( !bFinished ); 1681 1682 return result; 1683 } 1684 1685 bool 1686 AvPlug::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 1687 { 1688 bool result; 1689 result = ser.write( basePath + "m_subunitType", m_subunitType ); 1690 result &= ser.write( basePath + "m_subunitId", m_subunitId ); 1691 result &= ser.write( basePath + "m_functionBlockType", m_functionBlockType); 1692 result &= ser.write( basePath + "m_functionBlockId", m_functionBlockId); 1693 result &= ser.write( basePath + "m_addressType", m_addressType ); 1694 result &= ser.write( basePath + "m_direction", m_direction); 1695 result &= ser.write( basePath + "m_id", m_id); 1696 result &= ser.write( basePath + "m_infoPlugType", m_infoPlugType); 1697 result &= ser.write( basePath + "m_nrOfChannels", m_nrOfChannels); 1698 result &= ser.write( basePath + "m_name", m_name); 1699 result &= serializeClusterInfos( basePath + "m_clusterInfos", ser ); 1700 result &= ser.write( basePath + "m_samplingFrequency", m_samplingFrequency); 1701 result &= serializeFormatInfos( basePath + "m_formatInfo", ser ); 1702 result &= serializeAvPlugVector( basePath + "m_inputConnections", ser, m_inputConnections ); 1703 result &= serializeAvPlugVector( basePath + "m_outputConnections", ser, m_outputConnections ); 1704 result &= ser.write( basePath + "m_verboseLevel", m_verboseLevel); 1705 result &= ser.write( basePath + "m_globalId", m_globalId); 1706 result &= ser.write( basePath + "m_globalIdCounter", m_globalIdCounter ); 1707 1708 return result; 1709 } 1710 1711 AvPlug* 1712 AvPlug::deserialize( Glib::ustring basePath, 1713 Util::IODeserialize& deser, 1714 AvDevice& avDevice, 1715 AvPlugManager& plugManager ) 1716 { 1717 AvPlug* pPlug = new AvPlug; 1718 if ( !pPlug ) { 1719 return 0; 1720 } 1721 1722 pPlug->m_p1394Service = &avDevice.get1394Service(); 1723 pPlug->m_pConfigRom = &avDevice.getConfigRom(); 1724 pPlug->m_plugManager = &plugManager; 1725 bool result; 1726 result = deser.read( basePath + "m_subunitType", pPlug->m_subunitType ); 1727 result &= deser.read( basePath + "m_subunitId", pPlug->m_subunitId ); 1728 result &= deser.read( basePath + "m_functionBlockType", pPlug->m_functionBlockType ); 1729 result &= deser.read( basePath + "m_functionBlockId", pPlug->m_functionBlockId ); 1730 result &= deser.read( basePath + "m_addressType", pPlug->m_addressType ); 1731 result &= deser.read( basePath + "m_direction", pPlug->m_direction ); 1732 result &= deser.read( basePath + "m_id", pPlug->m_id ); 1733 result &= deser.read( basePath + "m_infoPlugType", pPlug->m_infoPlugType ); 1734 result &= deser.read( basePath + "m_nrOfChannels", pPlug->m_nrOfChannels ); 1735 result &= deser.read( basePath + "m_name", pPlug->m_name ); 1736 result &= pPlug->deserializeClusterInfos( basePath + "m_clusterInfos", deser ); 1737 result &= deser.read( basePath + "m_samplingFrequency", pPlug->m_samplingFrequency ); 1738 result &= pPlug->deserializeFormatInfos( basePath + "m_formatInfos", deser ); 1739 // input and output connections can't be processed here because not all plugs might 1740 // deserialized at this point. so we do that in deserializeUpdate. 1741 result &= deser.read( basePath + "m_verboseLevel", pPlug->m_verboseLevel ); 1742 result &= deser.read( basePath + "m_globalId", pPlug->m_globalId ); 1743 result &= deser.read( basePath + "m_globalIdCounter", pPlug->m_globalIdCounter ); 1744 1745 if ( !result ) { 1746 delete pPlug; 1747 return 0; 1748 } 1749 1750 return pPlug; 1751 } 1752 1753 bool 1754 AvPlug::deserializeUpdate( Glib::ustring basePath, 1755 Util::IODeserialize& deser ) 1756 { 1757 bool result; 1758 1759 result = deserializeAvPlugVector( basePath + "m_inputConnections", deser, m_inputConnections ); 1760 result &= deserializeAvPlugVector( basePath + "m_outputConnections", deser, m_outputConnections ); 1761 1762 return result; 1763 } 1764 1765 ///////////////////////////////////////// 1766 ///////////////////////////////////////// 1767 1768 const char* avPlugAddressTypeStrings[] = 1769 { 1770 "PCR", 1771 "external", 1772 "asynchronous", 1773 "subunit", 1774 "functionblock", 1775 "undefined", 1776 }; 1777 1778 const char* avPlugAddressTypeToString( AvPlug::EAvPlugAddressType type ) 1779 { 1780 if ( type > ( int )( sizeof( avPlugAddressTypeStrings ) 1781 / sizeof( avPlugAddressTypeStrings[0] ) ) ) 1782 { 1783 type = AvPlug::eAPA_Undefined; 1784 } 1785 return avPlugAddressTypeStrings[type]; 1786 } 1787 1788 const char* avPlugTypeStrings[] = 1789 { 1790 "IsoStream", 1791 "AsyncStream", 1792 "MIDI", 1793 "Sync", 1794 "Analog", 1795 "Digital", 1796 "Unknown", 1797 }; 1798 1799 const char* avPlugTypeToString( AvPlug::EAvPlugType type ) 1800 { 1801 if ( type > ( int )( sizeof( avPlugTypeStrings ) 1802 / sizeof( avPlugTypeStrings[0] ) ) ) 1803 { 1804 type = AvPlug::eAPT_Unknown; 1805 } 1806 return avPlugTypeStrings[type]; 1807 } 1808 1809 const char* avPlugDirectionStrings[] = 1810 { 1811 "Input", 1812 "Output", 1813 "Unknown", 1814 }; 1815 1816 const char* avPlugDirectionToString( AvPlug::EAvPlugDirection type ) 1817 { 1818 if ( type > ( int )( sizeof( avPlugDirectionStrings ) 1819 / sizeof( avPlugDirectionStrings[0] ) ) ) 1820 { 1821 type = AvPlug::eAPD_Unknown; 1822 } 1823 return avPlugDirectionStrings[type]; 1824 } 1825 1826 ///////////////////////////////////// 1827 1828 1829 AvPlugManager::AvPlugManager( int verboseLevel ) 1830 : m_verboseLevel( verboseLevel ) 1831 { 1832 setDebugLevel( m_verboseLevel ); 1833 } 1834 1835 AvPlugManager::AvPlugManager() 1836 : m_verboseLevel( 0 ) 1837 { 1838 setDebugLevel( 0 ); 1839 } 1840 1841 AvPlugManager::AvPlugManager( const AvPlugManager& rhs ) 1842 : m_verboseLevel( rhs.m_verboseLevel ) 1843 { 1844 setDebugLevel( m_verboseLevel ); 1845 } 1846 1847 AvPlugManager::~AvPlugManager() 1848 { 1849 } 1850 1851 bool 1852 AvPlugManager::addPlug( AvPlug& plug ) 1853 { 1854 m_plugs.push_back( &plug ); 1855 return true; 1856 } 1857 1858 bool 1859 AvPlugManager::remPlug( AvPlug& plug ) 1860 { 1861 for ( AvPlugVector::iterator it = m_plugs.begin(); 1862 it != m_plugs.end(); 1863 ++it ) 1864 { 1865 AvPlug* plugIt = *it; 1866 if ( plugIt == &plug ) { 1867 m_plugs.erase( it ); 1868 return true; 1869 } 1870 } 1871 return false; 1872 } 1873 1874 // helper function 1875 static void addConnection( AvPlugConnectionOwnerVector& connections, 1876 AvPlug& srcPlug, 1877 AvPlug& destPlug ) 1878 { 1879 for ( AvPlugConnectionOwnerVector::iterator it = connections.begin(); 1880 it != connections.end(); 1881 ++it ) 1882 { 1883 AvPlugConnection& con = *it; 1884 if ( ( &( con.getSrcPlug() ) == &srcPlug ) 1885 && ( &( con.getDestPlug() ) == &destPlug ) ) 1886 { 1887 return; 1888 } 1889 } 1890 connections.push_back( AvPlugConnection( srcPlug, destPlug ) ); 1891 } 1892 1893 void 1894 AvPlugManager::showPlugs() const 1895 { 1896 // \todo The information provided here could be better arranged. For a start it is ok, but 1897 // there is room for improvement. Something for a lazy sunday afternoon (tip: maybe drink some 1898 // beer to get into the mood) 1899 1900 printf( "\nSummary\n" ); 1901 printf( "-------\n\n" ); 1902 printf( "Nr | AddressType | Direction | SubUnitType | SubUnitId | FunctionBlockType | FunctionBlockId | Id | Type |Name\n" ); 1903 printf( "---+-----------------+-----------+-------------+-----------+-------------------+-----------------+------+--------------+------\n" ); 1904 1905 for ( AvPlugVector::const_iterator it = m_plugs.begin(); 1906 it != m_plugs.end(); 1907 ++it ) 1908 { 1909 AvPlug* plug = *it; 1910 1911 printf( "%2d | %15s | %9s | %11s | 0x%02x | 0x%02x | 0x%02x | 0x%02x | %12s | %s\n", 1912 plug->getGlobalId(), 1913 avPlugAddressTypeToString( plug->getPlugAddressType() ), 1914 avPlugDirectionToString( plug->getDirection() ), 1915 subunitTypeToString( plug->getSubunitType() ), 1916 plug->getSubunitId(), 1917 plug->getFunctionBlockType(), 1918 plug->getFunctionBlockId(), 1919 plug->getPlugId(), 1920 avPlugTypeToString( plug->getPlugType() ), 1921 plug->getName() ); 1922 } 1923 1924 printf( "\nConnections\n" ); 1925 printf( "-----------\n" ); 1926 1927 AvPlugConnectionOwnerVector connections; 1928 1929 for ( AvPlugVector::const_iterator it = m_plugs.begin(); 1930 it != m_plugs.end(); 1931 ++it ) 1932 { 1933 AvPlug* plug = *it; 1934 for ( AvPlugVector::const_iterator it = 1935 plug->getInputConnections().begin(); 1936 it != plug->getInputConnections().end(); 1937 ++it ) 1938 { 1939 addConnection( connections, *( *it ), *plug ); 1940 } 1941 for ( AvPlugVector::const_iterator it = 1942 plug->getOutputConnections().begin(); 1943 it != plug->getOutputConnections().end(); 1944 ++it ) 1945 { 1946 addConnection( connections, *plug, *( *it ) ); 1947 } 1948 } 1949 1950 printf( "digraph avcconnections {\n" ); 1951 for ( AvPlugConnectionOwnerVector::iterator it = connections.begin(); 1952 it != connections.end(); 1953 ++it ) 1954 { 1955 AvPlugConnection& con = *it; 1956 printf( "\t\"(%d) %s\" -> \"(%d) %s\"\n", 1957 con.getSrcPlug().getGlobalId(), 1958 con.getSrcPlug().getName(), 1959 con.getDestPlug().getGlobalId(), 1960 con.getDestPlug().getName() ); 1961 } 1962 for ( AvPlugVector::const_iterator it = m_plugs.begin(); 1963 it != m_plugs.end(); 1964 ++it ) 1965 { 1966 AvPlug* plug = *it; 1967 if ( plug->getFunctionBlockType() != 0xff ) { 1968 std::ostringstream strstrm; 1969 switch(plug->getFunctionBlockType()) { 1970 case 0x80: 1971 strstrm << "Selector FB"; 1972 break; 1973 case 0x81: 1974 strstrm << "Feature FB"; 1975 break; 1976 case 0x82: 1977 strstrm << "Processing FB"; 1978 break; 1979 case 0x83: 1980 strstrm << "CODEC FB"; 1981 break; 1982 default: 1983 strstrm << plug->getFunctionBlockType(); 1984 } 1985 1986 if ( plug->getPlugDirection() == AvPlug::eAPD_Input ) { 1987 printf( "\t\"(%d) %s\" -> \"(%s, ID %d)\"\n", 1988 plug->getGlobalId(), 1989 plug->getName(), 1990 strstrm.str().c_str(), 1991 plug->getFunctionBlockId() ); 1992 } else { 1993 printf( "\t\"(%s, ID %d)\" -> \t\"(%d) %s\"\n", 1994 strstrm.str().c_str(), 1995 plug->getFunctionBlockId(), 1996 plug->getGlobalId(), 1997 plug->getName() ); 1998 } 1999 } 2000 } 2001 2002 const char* colorStrings[] = { 2003 "coral", 2004 "slateblue", 2005 "white", 2006 "green", 2007 "yellow", 2008 "grey", 2009 }; 2010 2011 for ( AvPlugVector::const_iterator it = m_plugs.begin(); 2012 it != m_plugs.end(); 2013 ++it ) 2014 { 2015 AvPlug* plug = *it; 2016 printf( "\t\"(%d) %s\" [color=%s,style=filled];\n", 2017 plug->getGlobalId(), plug->getName(), 2018 colorStrings[plug->getPlugAddressType() ] ); 2019 } 2020 2021 printf("}\n" ); 2022 printf( "Use \"dot -Tps FILENAME.dot -o FILENAME.ps\" " 2023 "to generate graph\n"); 2024 2025 debugOutput( DEBUG_LEVEL_VERBOSE, "Plug details\n" ); 2026 debugOutput( DEBUG_LEVEL_VERBOSE, "------------\n" ); 2027 for ( AvPlugVector::const_iterator it = m_plugs.begin(); 2028 it != m_plugs.end(); 2029 ++it ) 2030 { 2031 AvPlug* plug = *it; 2032 debugOutput( DEBUG_LEVEL_VERBOSE, "Plug %d:\n", plug->getGlobalId() ); 2033 plug->showPlug(); 2034 2035 } 2036 } 2037 2038 AvPlug* 2039 AvPlugManager::getPlug( ESubunitType subunitType, 2040 subunit_id_t subunitId, 2041 function_block_type_t functionBlockType, 2042 function_block_id_t functionBlockId, 2043 AvPlug::EAvPlugAddressType plugAddressType, 2044 AvPlug::EAvPlugDirection plugDirection, 2045 plug_id_t plugId ) const 2046 { 2047 debugOutput( DEBUG_LEVEL_VERBOSE, "SBT, SBID, FBT, FBID, AT, PD, ID = " 2048 "(0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x)\n", 2049 subunitType, 2050 subunitId, 2051 functionBlockType, 2052 functionBlockId, 2053 plugAddressType, 2054 plugDirection, 2055 plugId ); 2056 2057 for ( AvPlugVector::const_iterator it = m_plugs.begin(); 2058 it != m_plugs.end(); 2059 ++it ) 2060 { 2061 AvPlug* plug = *it; 2062 2063 if ( ( subunitType == plug->getSubunitType() ) 2064 && ( subunitId == plug->getSubunitId() ) 2065 && ( functionBlockType == plug->getFunctionBlockType() ) 2066 && ( functionBlockId == plug->getFunctionBlockId() ) 2067 && ( plugAddressType == plug->getPlugAddressType() ) 2068 && ( plugDirection == plug->getPlugDirection() ) 2069 && ( plugId == plug->getPlugId() ) ) 2070 { 2071 return plug; 2072 } 2073 } 2074 2075 return 0; 2076 } 2077 2078 AvPlug* 2079 AvPlugManager::getPlug( int iGlobalId ) const 2080 { 2081 for ( AvPlugVector::const_iterator it = m_plugs.begin(); 2082 it != m_plugs.end(); 2083 ++it ) 2084 { 2085 AvPlug* pPlug = *it; 2086 if ( pPlug->getGlobalId() == iGlobalId ) { 2087 return pPlug; 2088 } 2089 } 2090 2091 return 0; 2092 } 2093 2094 AvPlugVector 2095 AvPlugManager::getPlugsByType( ESubunitType subunitType, 2096 subunit_id_t subunitId, 2097 function_block_type_t functionBlockType, 2098 function_block_id_t functionBlockId, 2099 AvPlug::EAvPlugAddressType plugAddressType, 2100 AvPlug::EAvPlugDirection plugDirection, 2101 AvPlug::EAvPlugType type) const 2102 { 2103 debugOutput( DEBUG_LEVEL_VERBOSE, "SBT, SBID, FBT, FBID, AT, PD, T = " 2104 "(0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x)\n", 2105 subunitType, 2106 subunitId, 2107 functionBlockType, 2108 functionBlockId, 2109 plugAddressType, 2110 plugDirection, 2111 type ); 2112 2113 AvPlugVector plugVector; 2114 for ( AvPlugVector::const_iterator it = m_plugs.begin(); 2115 it != m_plugs.end(); 2116 ++it ) 2117 { 2118 AvPlug* pPlug = *it; 2119 2120 if ( ( subunitType == pPlug->getSubunitType() ) 2121 && ( subunitId == pPlug->getSubunitId() ) 2122 && ( functionBlockType == pPlug->getFunctionBlockType() ) 2123 && ( functionBlockId == pPlug->getFunctionBlockId() ) 2124 && ( plugAddressType == pPlug->getPlugAddressType() ) 2125 && ( plugDirection == pPlug->getPlugDirection() ) 2126 && ( type == pPlug->getPlugType() ) ) 2127 { 2128 plugVector.push_back( pPlug ); 2129 } 2130 } 2131 2132 return plugVector; 2133 } 2134 2135 bool 2136 AvPlugManager::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 2137 { 2138 bool result = true; 2139 int i = 0; 2140 for ( AvPlugVector::const_iterator it = m_plugs.begin(); 2141 it != m_plugs.end(); 2142 ++it ) 2143 { 2144 AvPlug* pPlug = *it; 2145 std::ostringstream strstrm; 2146 strstrm << basePath << i; 2147 result &= pPlug->serialize( strstrm.str() + "/", ser ); 2148 i++; 2149 } 2150 2151 return result; 2152 } 2153 2154 AvPlugManager* 2155 AvPlugManager::deserialize( Glib::ustring basePath, 2156 Util::IODeserialize& deser, 2157 AvDevice& avDevice ) 2158 2159 { 2160 AvPlugManager* pMgr = new AvPlugManager; 2161 2162 if ( !pMgr ) { 2163 return 0; 2164 } 2165 2166 int i = 0; 2167 bool bFinished = false; 2168 do { 2169 std::ostringstream strstrm; 2170 strstrm << basePath << i; 2171 // avDevice still holds a null pointer for the plug manager 2172 // therefore we have to *this as additional argument 2173 AvPlug* pPlug = AvPlug::deserialize( strstrm.str() + "/", 2174 deser, 2175 avDevice, 2176 *pMgr ); 2177 if ( pPlug ) { 2178 pMgr->m_plugs.push_back( pPlug ); 2179 i++; 2180 } else { 2181 bFinished = true; 2182 } 2183 } while ( !bFinished ); 2184 2185 return pMgr; 2186 } 2187 2188 2189 //////////////////////////////////// 2190 2191 AvPlugConnection::AvPlugConnection( AvPlug& srcPlug, AvPlug& destPlug ) 2192 : m_srcPlug( &srcPlug ) 2193 , m_destPlug( &destPlug ) 2194 { 2195 } 2196 2197 AvPlugConnection::AvPlugConnection() 2198 : m_srcPlug( 0 ) 2199 , m_destPlug( 0 ) 2200 { 2201 } 2202 2203 bool 2204 AvPlugConnection::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 2205 { 2206 bool result; 2207 result = ser.write( basePath + "m_srcPlug", m_srcPlug->getGlobalId() ); 2208 result &= ser.write( basePath + "m_destPlug", m_destPlug->getGlobalId() ); 2209 return result; 2210 } 2211 2212 AvPlugConnection* 2213 AvPlugConnection::deserialize( Glib::ustring basePath, 2214 Util::IODeserialize& deser, 2215 AvDevice& avDevice ) 2216 { 2217 AvPlugConnection* pConnection = new AvPlugConnection; 2218 if ( !pConnection ) { 2219 return 0; 2220 } 2221 2222 bool result; 2223 int iSrcPlugId; 2224 int iDestPlugId; 2225 result = deser.read( basePath + "m_srcPlug", iSrcPlugId ); 2226 result &= deser.read( basePath + "m_destPlug", iDestPlugId ); 2227 2228 if ( !result ) { 2229 delete pConnection; 2230 return 0; 2231 } 2232 2233 pConnection->m_srcPlug = avDevice.getPlugManager().getPlug( iSrcPlugId ); 2234 pConnection->m_destPlug = avDevice.getPlugManager().getPlug( iDestPlugId ); 2235 2236 if ( !pConnection->m_srcPlug || !pConnection->m_destPlug ) { 2237 delete pConnection; 2238 return 0; 2239 } 2240 2241 return pConnection; 2242 } 2243 2244 } 897 } branches/echoaudio/src/bebob/bebob_avplug.h
r505 r507 31 31 #include "libavc/avc_definitions.h" 32 32 #include "libavc/general/avc_generic.h" 33 #include "libavc/general/avc_plug.h" 33 34 34 35 #include "libutil/serialize.h" … … 44 45 45 46 class AvDevice; 46 class AvPlugManager;47 class AvPlug;48 47 49 typedef std::vector<AvPlug*> AvPlugVector; 50 51 class AvPlug { 48 class Plug : public AVC::Plug { 52 49 public: 53 50 54 enum EAvPlugAddressType {55 eAPA_PCR,56 eAPA_ExternalPlug,57 eAPA_AsynchronousPlug,58 eAPA_SubunitPlug,59 eAPA_FunctionBlockPlug,60 eAPA_Undefined,61 };62 63 enum EAvPlugType {64 eAPT_IsoStream,65 eAPT_AsyncStream,66 eAPT_Midi,67 eAPT_Sync,68 eAPT_Analog,69 eAPT_Digital,70 eAPT_Unknown,71 };72 73 enum EAvPlugDirection {74 eAPD_Input,75 eAPD_Output,76 eAPD_Unknown,77 };78 79 51 // \todo This constructors sucks. too many parameters. fix it. 80 AvPlug( Ieee1394Service& ieee1394Service, 81 ConfigRom& configRom, 82 AvPlugManager& plugManager, 83 AVC::ESubunitType subunitType, 84 AVC::subunit_id_t subunitId, 85 AVC::function_block_type_t functionBlockType, 86 AVC::function_block_type_t functionBlockId, 87 EAvPlugAddressType plugAddressType, 88 EAvPlugDirection plugDirection, 89 AVC::plug_id_t plugId, 90 int verboseLevel ); 91 AvPlug( const AvPlug& rhs ); 92 virtual ~AvPlug(); 52 Plug( AVC::Unit* unit, 53 AVC::Subunit* subunit, 54 AVC::function_block_type_t functionBlockType, 55 AVC::function_block_type_t functionBlockId, 56 AVC::Plug::EPlugAddressType plugAddressType, 57 AVC::Plug::EPlugDirection plugDirection, 58 AVC::plug_id_t plugId ); 59 Plug( const Plug& rhs ); 60 virtual ~Plug(); 93 61 94 62 bool discover(); 95 63 bool discoverConnections(); 96 64 97 bool inquireConnnection( AvPlug& plug );98 bool setConnection( AvPlug& plug );99 100 int getGlobalId() const101 { return m_globalId; }102 AVC::plug_id_t getPlugId() const103 { return m_id; }104 AVC::ESubunitType getSubunitType() const105 { return m_subunitType; }106 AVC::subunit_id_t getSubunitId() const107 { return m_subunitId; }108 const char* getName() const109 { return m_name.c_str(); }110 EAvPlugDirection getPlugDirection() const111 { return m_direction; }112 AVC::sampling_frequency_t getSamplingFrequency() const113 { return m_samplingFrequency; }114 int getSampleRate() const; // 22050, 24000, 32000, ...115 int getNrOfChannels() const;116 int getNrOfStreams() const;117 118 EAvPlugDirection getDirection() const119 { return m_direction; }120 EAvPlugAddressType getPlugAddressType() const121 { return m_addressType; }122 EAvPlugType getPlugType() const123 { return m_infoPlugType; }124 125 AVC::function_block_type_t getFunctionBlockType() const126 { return m_functionBlockType; }127 AVC::function_block_id_t getFunctionBlockId() const128 { return m_functionBlockId; }129 130 const AvPlugVector& getInputConnections() const131 { return m_inputConnections; }132 const AvPlugVector& getOutputConnections() const133 { return m_outputConnections; }134 135 static AVC::PlugAddress::EPlugDirection convertPlugDirection(136 EAvPlugDirection direction);137 138 void showPlug() const;139 140 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;141 static AvPlug* deserialize( Glib::ustring basePath,142 Util::IODeserialize& deser,143 AvDevice& avDevice,144 AvPlugManager& plugManager );145 146 bool deserializeUpdate( Glib::ustring basePath,147 Util::IODeserialize& deser );148 149 65 public: 150 struct ChannelInfo {151 AVC::stream_position_t m_streamPosition;152 AVC::stream_position_location_t m_location;153 Glib::ustring m_name;154 };155 typedef std::vector<ChannelInfo> ChannelInfoVector;156 157 struct ClusterInfo {158 int m_index;159 AVC::port_type_t m_portType;160 Glib::ustring m_name;161 162 AVC::nr_of_channels_t m_nrOfChannels;163 ChannelInfoVector m_channelInfos;164 AVC::stream_format_t m_streamFormat;165 };166 typedef std::vector<ClusterInfo> ClusterInfoVector;167 168 ClusterInfoVector& getClusterInfos()169 { return m_clusterInfos; }170 66 171 67 protected: 172 AvPlug();68 Plug(); 173 69 174 70 bool discoverPlugType(); … … 188 84 AVC::ExtendedStreamFormatCmd::ESubFunction subFunction); 189 85 190 AVC::SignalSourceCmd setSrcPlugAddrToSignalCmd(); 86 private: 191 87 192 void setDestPlugAddrToSignalCmd(193 AVC::SignalSourceCmd& signalSourceCmd, AvPlug& plug );194 195 void debugOutputClusterInfos( int debugLevel );196 197 bool copyClusterInfo(AVC::ExtendedPlugInfoPlugChannelPositionSpecificData&198 channelPositionData );199 200 bool addPlugConnection( AvPlugVector& connections, AvPlug& plug );201 202 bool discoverConnectionsFromSpecificData(203 EAvPlugDirection discoverDirection,204 AVC::PlugAddressSpecificData* plugAddress,205 AvPlugVector& connections );206 207 AvPlug* getPlugDefinedBySpecificData(208 AVC::UnitPlugSpecificDataPlugAddress* pUnitPlugAddress,209 AVC::SubunitPlugSpecificDataPlugAddress* pSubunitPlugAddress,210 AVC::FunctionBlockPlugSpecificDataPlugAddress* pFunctionBlockPlugAddress );211 212 EAvPlugDirection toggleDirection( EAvPlugDirection direction ) const;213 214 const ClusterInfo* getClusterInfoByIndex( int index ) const;215 216 bool serializeChannelInfos( Glib::ustring basePath,217 Util::IOSerialize& ser,218 const ClusterInfo& clusterInfo ) const;219 bool deserializeChannelInfos( Glib::ustring basePath,220 Util::IODeserialize& deser,221 ClusterInfo& clusterInfo );222 223 bool serializeClusterInfos( Glib::ustring basePath,224 Util::IOSerialize& ser ) const;225 bool deserializeClusterInfos( Glib::ustring basePath,226 Util::IODeserialize& deser );227 228 bool serializeFormatInfos( Glib::ustring basePath,229 Util::IOSerialize& ser ) const;230 bool deserializeFormatInfos( Glib::ustring basePath,231 Util::IODeserialize& deser );232 233 bool serializeAvPlugVector( Glib::ustring basePath,234 Util::IOSerialize& ser,235 const AvPlugVector& vec) const;236 bool deserializeAvPlugVector( Glib::ustring basePath,237 Util::IODeserialize& deser,238 AvPlugVector& vec );239 240 private:241 // Supported stream formats242 struct FormatInfo {243 FormatInfo()244 : m_samplingFrequency( AVC::eSF_DontCare )245 , m_isSyncStream( false )246 , m_audioChannels( 0 )247 , m_midiChannels( 0 )248 , m_index( 0xff )249 {}250 AVC::sampling_frequency_t m_samplingFrequency;251 bool m_isSyncStream;252 AVC::number_of_channels_t m_audioChannels;253 AVC::number_of_channels_t m_midiChannels;254 byte_t m_index;255 };256 typedef std::vector<FormatInfo> FormatInfoVector;257 258 259 Ieee1394Service* m_p1394Service;260 ConfigRom* m_pConfigRom;261 AVC::ESubunitType m_subunitType;262 AVC::subunit_id_t m_subunitId;263 AVC::function_block_type_t m_functionBlockType;264 AVC::function_block_id_t m_functionBlockId;265 EAvPlugAddressType m_addressType;266 EAvPlugDirection m_direction;267 AVC::plug_id_t m_id;268 EAvPlugType m_infoPlugType;269 AVC::nr_of_channels_t m_nrOfChannels;270 Glib::ustring m_name;271 ClusterInfoVector m_clusterInfos;272 AVC::sampling_frequency_t m_samplingFrequency;273 FormatInfoVector m_formatInfos;274 AvPlugVector m_inputConnections;275 AvPlugVector m_outputConnections;276 AvPlugManager* m_plugManager;277 int m_verboseLevel;278 int m_globalId;279 static int m_globalIdCounter;280 281 DECLARE_DEBUG_MODULE;282 88 }; 283 284 const char* avPlugAddressTypeToString( AvPlug::EAvPlugAddressType addressType );285 const char* avPlugTypeToString( AvPlug::EAvPlugType type );286 const char* avPlugDirectionToString( AvPlug::EAvPlugDirection direction );287 288 class AvPlugManager289 {290 public:291 AvPlugManager( int verboseLevel );292 AvPlugManager( const AvPlugManager& rhs );293 ~AvPlugManager();294 295 bool addPlug( AvPlug& plug );296 bool remPlug( AvPlug& plug );297 298 void showPlugs() const;299 300 AvPlug* getPlug( AVC::ESubunitType subunitType,301 AVC::subunit_id_t subunitId,302 AVC::function_block_type_t functionBlockType,303 AVC::function_block_id_t functionBlockId,304 AvPlug::EAvPlugAddressType plugAddressType,305 AvPlug::EAvPlugDirection plugDirection,306 AVC::plug_id_t plugId ) const;307 AvPlug* getPlug( int iGlobalId ) const;308 AvPlugVector getPlugsByType( AVC::ESubunitType subunitType,309 AVC::subunit_id_t subunitId,310 AVC::function_block_type_t functionBlockType,311 AVC::function_block_id_t functionBlockId,312 AvPlug::EAvPlugAddressType plugAddressType,313 AvPlug::EAvPlugDirection plugDirection,314 AvPlug::EAvPlugType type) const;315 316 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;317 static AvPlugManager* deserialize( Glib::ustring basePath,318 Util::IODeserialize& deser,319 AvDevice& avDevice );320 321 private:322 AvPlugManager();323 324 int m_verboseLevel;325 AvPlugVector m_plugs;326 327 DECLARE_DEBUG_MODULE;328 };329 330 class AvPlugConnection {331 public:332 AvPlugConnection( AvPlug& srcPlug, AvPlug& destPlug );333 334 AvPlug& getSrcPlug() const335 { return *m_srcPlug; }336 AvPlug& getDestPlug() const337 { return *m_destPlug; }338 339 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;340 static AvPlugConnection* deserialize( Glib::ustring basePath,341 Util::IODeserialize& deser,342 AvDevice& avDevice );343 private:344 AvPlugConnection();345 346 private:347 AvPlug* m_srcPlug;348 AvPlug* m_destPlug;349 };350 351 typedef std::vector<AvPlugConnection*> AvPlugConnectionVector;352 typedef std::vector<AvPlugConnection> AvPlugConnectionOwnerVector;353 89 354 90 } branches/echoaudio/src/bebob/bebob_functionblock.cpp
r503 r507 29 29 using namespace AVC; 30 30 31 IMPL_DEBUG_MODULE( BeBoB::FunctionBlock, BeBoB::FunctionBlock, DEBUG_LEVEL_NORMAL ); 32 33 BeBoB::FunctionBlock::FunctionBlock( 34 AvDeviceSubunit& subunit, 31 namespace BeBoB { 32 33 IMPL_DEBUG_MODULE( FunctionBlock, FunctionBlock, DEBUG_LEVEL_NORMAL ); 34 35 FunctionBlock::FunctionBlock( 36 Subunit& subunit, 35 37 function_block_type_t type, 36 38 function_block_type_t subtype, … … 52 54 } 53 55 54 BeBoB::FunctionBlock::FunctionBlock( const FunctionBlock& rhs )56 FunctionBlock::FunctionBlock( const FunctionBlock& rhs ) 55 57 : m_subunit( rhs.m_subunit ) 56 58 , m_type( rhs.m_type ) … … 64 66 } 65 67 66 BeBoB::FunctionBlock::FunctionBlock()67 { 68 } 69 70 BeBoB::FunctionBlock::~FunctionBlock()71 { 72 for ( AvPlugVector::iterator it = m_plugs.begin();68 FunctionBlock::FunctionBlock() 69 { 70 } 71 72 FunctionBlock::~FunctionBlock() 73 { 74 for ( PlugVector::iterator it = m_plugs.begin(); 73 75 it != m_plugs.end(); 74 76 ++it ) … … 80 82 81 83 bool 82 BeBoB::FunctionBlock::discover()84 FunctionBlock::discover() 83 85 { 84 86 debugOutput( DEBUG_LEVEL_NORMAL, … … 89 91 m_nrOfOutputPlugs ); 90 92 91 if ( !discoverPlugs( A vPlug::eAPD_Input, m_nrOfInputPlugs ) ) {93 if ( !discoverPlugs( AVC::Plug::eAPD_Input, m_nrOfInputPlugs ) ) { 92 94 debugError( "Could not discover input plug for '%s'\n", 93 95 getName() ); … … 95 97 } 96 98 97 if ( !discoverPlugs( A vPlug::eAPD_Output, m_nrOfOutputPlugs ) ) {99 if ( !discoverPlugs( AVC::Plug::eAPD_Output, m_nrOfOutputPlugs ) ) { 98 100 debugError( "Could not discover output plugs for '%s'\n", 99 101 getName() ); … … 105 107 106 108 bool 107 BeBoB::FunctionBlock::discoverPlugs( AvPlug::EAvPlugDirection plugDirection,109 FunctionBlock::discoverPlugs( AVC::Plug::EPlugDirection plugDirection, 108 110 plug_id_t plugMaxId ) 109 111 { 110 112 for ( int plugId = 0; plugId < plugMaxId; ++plugId ) { 111 AvPlug* plug = new AvPlug( 112 m_subunit->getAvDevice().get1394Service(), 113 m_subunit->getAvDevice().getConfigRom(), 114 m_subunit->getAvDevice().getPlugManager(), 115 m_subunit->getSubunitType(), 116 m_subunit->getSubunitId(), 113 AVC::Plug* plug = new BeBoB::Plug( 114 &m_subunit->getUnit(), 115 m_subunit, 117 116 m_type, 118 117 m_id, 119 A vPlug::eAPA_FunctionBlockPlug,118 AVC::Plug::eAPA_FunctionBlockPlug, 120 119 plugDirection, 121 plugId, 122 m_verbose ); 120 plugId); 123 121 124 122 if ( !plug || !plug->discover() ) { … … 138 136 139 137 bool 140 BeBoB::FunctionBlock::discoverConnections()138 FunctionBlock::discoverConnections() 141 139 { 142 140 debugOutput( DEBUG_LEVEL_VERBOSE, … … 144 142 getName() ); 145 143 146 for ( AvPlugVector::iterator it = m_plugs.begin();144 for ( PlugVector::iterator it = m_plugs.begin(); 147 145 it != m_plugs.end(); 148 146 ++it ) 149 147 { 150 A vPlug* plug = *it;148 AVC::Plug* plug = *it; 151 149 if ( !plug->discoverConnections() ) { 152 150 debugError( "Could not discover plug connections\n" ); … … 158 156 159 157 bool 160 serialize AvPlugVector( Glib::ustring basePath,158 serializePlugVector( Glib::ustring basePath, 161 159 Util::IOSerialize& ser, 162 const BeBoB::AvPlugVector& vec )160 const PlugVector& vec ) 163 161 { 164 162 bool result = true; 165 163 int i = 0; 166 for ( BeBoB::AvPlugVector::const_iterator it = vec.begin();164 for ( PlugVector::const_iterator it = vec.begin(); 167 165 it != vec.end(); 168 166 ++it ) … … 177 175 178 176 bool 179 deserialize AvPlugVector( Glib::ustring basePath,177 deserializePlugVector( Glib::ustring basePath, 180 178 Util::IODeserialize& deser, 181 BeBoB::AvDevice& avDevice,182 BeBoB::AvPlugVector& vec )179 AVC::Unit& unit, 180 PlugVector& vec ) 183 181 { 184 182 int i = 0; … … 191 189 192 190 result &= deser.read( strstrm.str(), plugId ); 193 BeBoB::AvPlug* pPlug = avDevice.getPlugManager().getPlug( plugId );191 AVC::Plug* pPlug = unit.getPlugManager().getPlug( plugId ); 194 192 195 193 if ( pPlug ) { … … 205 203 206 204 bool 207 BeBoB::FunctionBlock::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const205 FunctionBlock::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 208 206 { 209 207 bool result; … … 216 214 result &= ser.write( basePath + "m_nrOfOutputPlugs", m_nrOfOutputPlugs ); 217 215 result &= ser.write( basePath + "m_verbose", m_verbose ); 218 result &= serialize AvPlugVector( basePath + "m_plugs", ser, m_plugs );216 result &= serializePlugVector( basePath + "m_plugs", ser, m_plugs ); 219 217 220 218 return result; 221 219 } 222 220 223 BeBoB::FunctionBlock*224 BeBoB::FunctionBlock::deserialize( Glib::ustring basePath,221 FunctionBlock* 222 FunctionBlock::deserialize( Glib::ustring basePath, 225 223 Util::IODeserialize& deser, 226 A vDevice& avDevice,227 A vDeviceSubunit& subunit )224 AVC::Unit& unit, 225 AVC::Subunit& subunit ) 228 226 { 229 227 bool result; … … 272 270 result &= deser.read( basePath + "m_nrOfOutputPlugs", pFB->m_nrOfOutputPlugs ); 273 271 result &= deser.read( basePath + "m_verbose", pFB->m_verbose ); 274 result &= deserialize AvPlugVector( basePath + "m_plugs", deser, avDevice, pFB->m_plugs );272 result &= deserializePlugVector( basePath + "m_plugs", deser, unit, pFB->m_plugs ); 275 273 276 274 return 0; … … 279 277 /////////////////////// 280 278 281 BeBoB::FunctionBlockSelector::FunctionBlockSelector(282 A vDeviceSubunit& subunit,279 FunctionBlockSelector::FunctionBlockSelector( 280 AVC::Subunit& subunit, 283 281 function_block_id_t id, 284 282 ESpecialPurpose purpose, … … 297 295 } 298 296 299 BeBoB::FunctionBlockSelector::FunctionBlockSelector(297 FunctionBlockSelector::FunctionBlockSelector( 300 298 const FunctionBlockSelector& rhs ) 301 299 : FunctionBlock( rhs ) … … 303 301 } 304 302 305 BeBoB::FunctionBlockSelector::FunctionBlockSelector()303 FunctionBlockSelector::FunctionBlockSelector() 306 304 : FunctionBlock() 307 305 { 308 306 } 309 307 310 BeBoB::FunctionBlockSelector::~FunctionBlockSelector()308 FunctionBlockSelector::~FunctionBlockSelector() 311 309 { 312 310 } 313 311 314 312 const char* 315 BeBoB::FunctionBlockSelector::getName()313 FunctionBlockSelector::getName() 316 314 { 317 315 return "Selector"; … … 319 317 320 318 bool 321 BeBoB::FunctionBlockSelector::serializeChild( Glib::ustring basePath,319 FunctionBlockSelector::serializeChild( Glib::ustring basePath, 322 320 Util::IOSerialize& ser ) const 323 321 { … … 326 324 327 325 bool 328 BeBoB::FunctionBlockSelector::deserializeChild( Glib::ustring basePath,326 FunctionBlockSelector::deserializeChild( Glib::ustring basePath, 329 327 Util::IODeserialize& deser, 330 AvDevice& avDevice)328 AvDevice& unit ) 331 329 { 332 330 return true; … … 335 333 /////////////////////// 336 334 337 BeBoB::FunctionBlockFeature::FunctionBlockFeature(338 A vDeviceSubunit& subunit,335 FunctionBlockFeature::FunctionBlockFeature( 336 AVC::Subunit& subunit, 339 337 function_block_id_t id, 340 338 ESpecialPurpose purpose, … … 353 351 } 354 352 355 BeBoB::FunctionBlockFeature::FunctionBlockFeature(353 FunctionBlockFeature::FunctionBlockFeature( 356 354 const FunctionBlockFeature& rhs ) 357 355 : FunctionBlock( rhs ) … … 359 357 } 360 358 361 BeBoB::FunctionBlockFeature::FunctionBlockFeature()359 FunctionBlockFeature::FunctionBlockFeature() 362 360 : FunctionBlock() 363 361 { 364 362 } 365 363 366 BeBoB::FunctionBlockFeature::~FunctionBlockFeature()364 FunctionBlockFeature::~FunctionBlockFeature() 367 365 { 368 366 } 369 367 370 368 const char* 371 BeBoB::FunctionBlockFeature::getName()369 FunctionBlockFeature::getName() 372 370 { 373 371 return "Feature"; … … 375 373 376 374 bool 377 BeBoB::FunctionBlockFeature::serializeChild( Glib::ustring basePath,375 FunctionBlockFeature::serializeChild( Glib::ustring basePath, 378 376 Util::IOSerialize& ser ) const 379 377 { … … 382 380 383 381 bool 384 BeBoB::FunctionBlockFeature::deserializeChild( Glib::ustring basePath,382 FunctionBlockFeature::deserializeChild( Glib::ustring basePath, 385 383 Util::IODeserialize& deser, 386 AvDevice& avDevice)384 AvDevice& unit ) 387 385 { 388 386 return true; … … 391 389 /////////////////////// 392 390 393 BeBoB::FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer(394 A vDeviceSubunit& subunit,391 FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer( 392 AVC::Subunit& subunit, 395 393 function_block_id_t id, 396 394 ESpecialPurpose purpose, … … 409 407 } 410 408 411 BeBoB::FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer(409 FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer( 412 410 const FunctionBlockEnhancedMixer& rhs ) 413 411 : FunctionBlock( rhs ) … … 415 413 } 416 414 417 BeBoB::FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer()415 FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer() 418 416 : FunctionBlock() 419 417 { 420 418 } 421 419 422 BeBoB::FunctionBlockEnhancedMixer::~FunctionBlockEnhancedMixer()420 FunctionBlockEnhancedMixer::~FunctionBlockEnhancedMixer() 423 421 { 424 422 } 425 423 426 424 const char* 427 BeBoB::FunctionBlockEnhancedMixer::getName()425 FunctionBlockEnhancedMixer::getName() 428 426 { 429 427 return "EnhancedMixer"; … … 431 429 432 430 bool 433 BeBoB::FunctionBlockEnhancedMixer::serializeChild( Glib::ustring basePath,431 FunctionBlockEnhancedMixer::serializeChild( Glib::ustring basePath, 434 432 Util::IOSerialize& ser ) const 435 433 { … … 438 436 439 437 bool 440 BeBoB::FunctionBlockEnhancedMixer::deserializeChild( Glib::ustring basePath,438 FunctionBlockEnhancedMixer::deserializeChild( Glib::ustring basePath, 441 439 Util::IODeserialize& deser, 442 AvDevice& avDevice)440 AvDevice& unit ) 443 441 { 444 442 return true; … … 447 445 /////////////////////// 448 446 449 BeBoB::FunctionBlockProcessing::FunctionBlockProcessing(450 A vDeviceSubunit& subunit,447 FunctionBlockProcessing::FunctionBlockProcessing( 448 AVC::Subunit& subunit, 451 449 function_block_id_t id, 452 450 ESpecialPurpose purpose, … … 465 463 } 466 464 467 BeBoB::FunctionBlockProcessing::FunctionBlockProcessing(465 FunctionBlockProcessing::FunctionBlockProcessing( 468 466 const FunctionBlockProcessing& rhs ) 469 467 : FunctionBlock( rhs ) … … 471 469 } 472 470 473 BeBoB::FunctionBlockProcessing::FunctionBlockProcessing()471 FunctionBlockProcessing::FunctionBlockProcessing() 474 472 : FunctionBlock() 475 473 { 476 474 } 477 475 478 BeBoB::FunctionBlockProcessing::~FunctionBlockProcessing()476 FunctionBlockProcessing::~FunctionBlockProcessing() 479 477 { 480 478 } 481 479 482 480 const char* 483 BeBoB::FunctionBlockProcessing::getName()481 FunctionBlockProcessing::getName() 484 482 { 485 483 return "Dummy Processing"; … … 487 485 488 486 bool 489 BeBoB::FunctionBlockProcessing::serializeChild( Glib::ustring basePath,487 FunctionBlockProcessing::serializeChild( Glib::ustring basePath, 490 488 Util::IOSerialize& ser ) const 491 489 { … … 494 492 495 493 bool 496 BeBoB::FunctionBlockProcessing::deserializeChild( Glib::ustring basePath,494 FunctionBlockProcessing::deserializeChild( Glib::ustring basePath, 497 495 Util::IODeserialize& deser, 498 AvDevice& avDevice)496 AvDevice& unit ) 499 497 { 500 498 return true; … … 503 501 /////////////////////// 504 502 505 BeBoB::FunctionBlockCodec::FunctionBlockCodec(506 A vDeviceSubunit& subunit,503 FunctionBlockCodec::FunctionBlockCodec( 504 AVC::Subunit& subunit, 507 505 function_block_id_t id, 508 506 ESpecialPurpose purpose, … … 521 519 } 522 520 523 BeBoB::FunctionBlockCodec::FunctionBlockCodec( const FunctionBlockCodec& rhs )521 FunctionBlockCodec::FunctionBlockCodec( const FunctionBlockCodec& rhs ) 524 522 : FunctionBlock( rhs ) 525 523 { 526 524 } 527 525 528 BeBoB::FunctionBlockCodec::FunctionBlockCodec()526 FunctionBlockCodec::FunctionBlockCodec() 529 527 : FunctionBlock() 530 528 { 531 529 } 532 530 533 BeBoB::FunctionBlockCodec::~FunctionBlockCodec()531 FunctionBlockCodec::~FunctionBlockCodec() 534 532 { 535 533 } 536 534 537 535 const char* 538 BeBoB::FunctionBlockCodec::getName()536 FunctionBlockCodec::getName() 539 537 { 540 538 return "Dummy Codec"; … … 542 540 543 541 bool 544 BeBoB::FunctionBlockCodec::serializeChild( Glib::ustring basePath,542 FunctionBlockCodec::serializeChild( Glib::ustring basePath, 545 543 Util::IOSerialize& ser ) const 546 544 { … … 549 547 550 548 bool 551 BeBoB::FunctionBlockCodec::deserializeChild( Glib::ustring basePath,549 FunctionBlockCodec::deserializeChild( Glib::ustring basePath, 552 550 Util::IODeserialize& deser, 553 AvDevice& avDevice ) 554 { 555 return true; 556 } 551 AvDevice& unit ) 552 { 553 return true; 554 } 555 556 } branches/echoaudio/src/bebob/bebob_functionblock.h
r503 r507 28 28 29 29 #include "libavc/avc_definitions.h" 30 // #include "libavc/general/avc_subunit.h" 31 30 32 #include "debugmodule/debugmodule.h" 31 33 34 namespace AVC { 35 class Subunit; 36 } 37 32 38 namespace BeBoB { 33 34 class AvDeviceSubunit;35 39 36 40 class FunctionBlock { … … 50 54 }; 51 55 52 FunctionBlock( A vDeviceSubunit& subunit,53 AVC::function_block_type_t type,56 FunctionBlock( AVC::Subunit& subunit, 57 AVC::function_block_type_t type, 54 58 AVC::function_block_type_t subtype, 55 59 AVC::function_block_id_t id, … … 74 78 static FunctionBlock* deserialize( Glib::ustring basePath, 75 79 Util::IODeserialize& deser, 76 A vDevice& avDevice,77 AvDeviceSubunit& subunit);78 protected: 79 bool discoverPlugs( A vPlug::EAvPlugDirection plugDirection,80 AVC::Unit& unit, 81 AVC::Subunit& subunit); 82 protected: 83 bool discoverPlugs( AVC::Plug::EPlugDirection plugDirection, 80 84 AVC::plug_id_t plugMaxId ); 81 85 82 86 protected: 83 A vDeviceSubunit* m_subunit;87 AVC::Subunit* m_subunit; 84 88 AVC::function_block_type_t m_type; 85 89 AVC::function_block_type_t m_subtype; … … 89 93 AVC::no_of_output_plugs_t m_nrOfOutputPlugs; 90 94 int m_verbose; 91 A vPlugVector m_plugs;95 AVC::PlugVector m_plugs; 92 96 93 97 DECLARE_DEBUG_MODULE; … … 102 106 { 103 107 public: 104 FunctionBlockSelector(A vDeviceSubunit& subunit,108 FunctionBlockSelector(AVC::Subunit& subunit, 105 109 AVC::function_block_id_t id, 106 110 ESpecialPurpose purpose, … … 127 131 { 128 132 public: 129 FunctionBlockFeature(A vDeviceSubunit& subunit,133 FunctionBlockFeature(AVC::Subunit& subunit, 130 134 AVC::function_block_id_t id, 131 135 ESpecialPurpose purpose, … … 169 173 { 170 174 public: 171 FunctionBlockEnhancedMixer( A vDeviceSubunit& subunit,175 FunctionBlockEnhancedMixer( AVC::Subunit& subunit, 172 176 AVC::function_block_id_t id, 173 177 ESpecialPurpose purpose, … … 194 198 { 195 199 public: 196 FunctionBlockProcessing( A vDeviceSubunit& subunit,200 FunctionBlockProcessing( AVC::Subunit& subunit, 197 201 AVC::function_block_id_t id, 198 202 ESpecialPurpose purpose, … … 219 223 { 220 224 public: 221 FunctionBlockCodec(A vDeviceSubunit& subunit,225 FunctionBlockCodec(AVC::Subunit& subunit, 222 226 AVC::function_block_id_t id, 223 227 ESpecialPurpose purpose, branches/echoaudio/src/libavc/general/avc_plug.cpp
r503 r507 1 1 /* 2 * Copyright (C) 2007 by Pieter Palmers 2 3 * Copyright (C) 2005-2007 by Daniel Wagner 3 4 * … … 22 23 */ 23 24 24 #include " bebob/bebob_avplug.h"25 #include " bebob/bebob_avdevice.h"25 #include "avc_plug.h" 26 #include "avc_unit.h" 26 27 #include "libieee1394/configrom.h" 27 28 28 29 #include "libieee1394/ieee1394service.h" 29 #include " libavc/util/avc_serialize.h"30 #include "../util/avc_serialize.h" 30 31 31 32 #include <sstream> 32 33 33 using namespace AVC; 34 35 namespace BeBoB { 36 37 int AvPlug::m_globalIdCounter = 0; 38 39 IMPL_DEBUG_MODULE( AvPlug, AvPlug, DEBUG_LEVEL_NORMAL ); 40 IMPL_DEBUG_MODULE( AvPlugManager, AvPlugManager, DEBUG_LEVEL_NORMAL ); 41 42 AvPlug::AvPlug( Ieee1394Service& ieee1394Service, 43 ConfigRom& configRom, 44 AvPlugManager& plugManager, 45 ESubunitType subunitType, 46 subunit_id_t subunitId, 47 function_block_type_t functionBlockType, 48 function_block_id_t functionBlockId, 49 EAvPlugAddressType plugAddressType, 50 EAvPlugDirection plugDirection, 51 plug_id_t plugId, 52 int verboseLevel ) 53 : m_p1394Service( &ieee1394Service ) 54 , m_pConfigRom( &configRom ) 55 , m_subunitType( subunitType ) 56 , m_subunitId( subunitId ) 34 namespace AVC { 35 36 int Plug::m_globalIdCounter = 0; 37 38 IMPL_DEBUG_MODULE( Plug, Plug, DEBUG_LEVEL_NORMAL ); 39 IMPL_DEBUG_MODULE( PlugManager, PlugManager, DEBUG_LEVEL_NORMAL ); 40 41 Plug::Plug( Unit* unit, 42 Subunit* subunit, 43 function_block_type_t functionBlockType, 44 function_block_id_t functionBlockId, 45 EPlugAddressType plugAddressType, 46 EPlugDirection plugDirection, 47 plug_id_t plugId ) 48 : m_unit(unit) 49 , m_subunit(subunit) 57 50 , m_functionBlockType( functionBlockType ) 58 51 , m_functionBlockId( functionBlockId ) … … 62 55 , m_infoPlugType( eAPT_Unknown ) 63 56 , m_nrOfChannels( 0 ) 64 , m_plugManager( &plugManager )65 , m_verboseLevel( verboseLevel )66 57 , m_globalId( m_globalIdCounter++ ) 67 58 { 68 setDebugLevel( m_verboseLevel );69 59 debugOutput( DEBUG_LEVEL_VERBOSE, 70 60 "nodeId = %d, subunitType = %d, " … … 72 62 "functionBlockId = %d, addressType = %d, " 73 63 "direction = %d, id = %d\n", 74 m_ pConfigRom->getNodeId(),75 m_subunitType,76 m_subunitId,64 m_unit->getConfigRom().getNodeId(), 65 getSubunitType(), 66 getSubunitId(), 77 67 m_functionBlockType, 78 68 m_functionBlockId, … … 82 72 } 83 73 84 AvPlug::AvPlug( const AvPlug& rhs ) 85 : m_p1394Service( rhs.m_p1394Service ) 86 , m_pConfigRom( rhs.m_pConfigRom ) 87 , m_subunitType( rhs.m_subunitType ) 88 , m_subunitId( rhs.m_subunitId ) 74 Plug::Plug( const Plug& rhs ) 75 : m_unit ( rhs.m_unit ) 76 , m_subunit ( rhs.m_subunit ) 89 77 , m_functionBlockType( rhs.m_functionBlockType ) 90 78 , m_functionBlockId( rhs.m_functionBlockId ) … … 97 85 , m_clusterInfos( rhs.m_clusterInfos ) 98 86 , m_formatInfos( rhs.m_formatInfos ) 99 , m_plugManager( rhs.m_plugManager ) 100 , m_verboseLevel( rhs.m_verboseLevel ) 101 { 102 if ( m_verboseLevel ) { 87 { 88 if ( getDebugLevel() ) { 103 89 setDebugLevel( DEBUG_LEVEL_VERBOSE ); 104 90 } 105 91 } 106 92 107 AvPlug::AvPlug() 108 : m_p1394Service( 0 ) 109 , m_pConfigRom( 0 ) 110 , m_subunitType( eST_Reserved ) // a good value for unknown/undefined? 111 , m_subunitId( 0 ) 93 Plug::Plug() 94 : m_unit( NULL ) 95 , m_subunit( NULL ) 112 96 , m_functionBlockType( 0 ) 113 97 , m_functionBlockId( 0 ) … … 117 101 , m_infoPlugType( eAPT_Unknown ) 118 102 , m_nrOfChannels( 0 ) 119 , m_plugManager( 0 )120 , m_verboseLevel( 0 )121 103 , m_globalId( 0 ) 122 104 { 123 105 } 124 106 125 AvPlug::~AvPlug() 126 { 127 if ( m_plugManager ) { 128 m_plugManager->remPlug( *this ); 129 } 130 } 131 132 bool 133 AvPlug::discover() 107 Plug::~Plug() 108 { 109 m_unit->getPlugManager().remPlug( *this ); 110 } 111 112 ESubunitType 113 Plug::getSubunitType() const 114 { 115 return (m_subunit==NULL?eST_Unit:m_subunit->getSubunitType()); 116 } 117 118 subunit_id_t 119 Plug::getSubunitId() const 120 { 121 return (m_subunit==NULL?eST_Unit:m_subunit->getSubunitId()); 122 } 123 124 /* 125 bool 126 Plug::discover() 134 127 { 135 128 if ( !discoverPlugType() ) { 136 129 debugError( "discover: Could not discover plug type (%d,%d,%d,%d,%d)\n", 137 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );130 m_unit->getConfigRom().getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 138 131 return false; 139 132 } … … 141 134 if ( !discoverName() ) { 142 135 debugError( "Could not discover name (%d,%d,%d,%d,%d)\n", 143 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );136 m_unit->getConfigRom().getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 144 137 return false; 145 138 } … … 148 141 debugError( "Could not discover number of channels " 149 142 "(%d,%d,%d,%d,%d)\n", 150 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );143 m_unit->getConfigRom().getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 151 144 return false; 152 145 } … … 155 148 debugError( "Could not discover channel positions " 156 149 "(%d,%d,%d,%d,%d)\n", 157 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );150 m_unit->getConfigRom().getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 158 151 return false; 159 152 } … … 162 155 debugError( "Could not discover channel name " 163 156 "(%d,%d,%d,%d,%d)\n", 164 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );157 m_unit->getConfigRom().getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 165 158 return false; 166 159 } … … 169 162 debugError( "Could not discover channel name " 170 163 "(%d,%d,%d,%d,%d)\n", 171 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );164 m_unit->getConfigRom().getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 172 165 return false; 173 166 } … … 176 169 debugError( "Could not discover stream format " 177 170 "(%d,%d,%d,%d,%d)\n", 178 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );171 m_unit->getConfigRom().getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 179 172 return false; 180 173 } … … 183 176 debugError( "Could not discover supported stream formats " 184 177 "(%d,%d,%d,%d,%d)\n", 185 m_ pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id );178 m_unit->getConfigRom().getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 186 179 return false; 187 180 } 188 181 189 return m_plugManager->addPlug( *this );190 } 191 192 bool 193 AvPlug::discoverConnections()182 return unit->getPlugManager().addPlug( *this ); 183 } 184 185 bool 186 Plug::discoverConnections() 194 187 { 195 188 return discoverConnectionsInput() && discoverConnectionsOutput(); 196 189 } 197 198 bool 199 AvPlug::inquireConnnection( AvPlug& plug ) 190 */ 191 192 bool 193 Plug::inquireConnnection( Plug& plug ) 200 194 { 201 195 SignalSourceCmd signalSourceCmd = setSrcPlugAddrToSignalCmd(); 202 196 setDestPlugAddrToSignalCmd( signalSourceCmd, plug ); 203 197 signalSourceCmd.setCommandType( AVCCommand::eCT_SpecificInquiry ); 204 signalSourceCmd.setVerbose( m_verboseLevel);198 signalSourceCmd.setVerbose( getDebugLevel() ); 205 199 206 200 if ( !signalSourceCmd.fire() ) { … … 223 217 224 218 bool 225 AvPlug::setConnection( AvPlug& plug )219 Plug::setConnection( Plug& plug ) 226 220 { 227 221 SignalSourceCmd signalSourceCmd = setSrcPlugAddrToSignalCmd(); 228 222 setDestPlugAddrToSignalCmd( signalSourceCmd, plug ); 229 223 signalSourceCmd.setCommandType( AVCCommand::eCT_Control ); 230 signalSourceCmd.setVerbose( m_verboseLevel);224 signalSourceCmd.setVerbose( getDebugLevel() ); 231 225 232 226 if ( !signalSourceCmd.fire() ) { … … 249 243 250 244 int 251 AvPlug::getNrOfStreams() const245 Plug::getNrOfStreams() const 252 246 { 253 247 int nrOfChannels = 0; … … 263 257 264 258 int 265 AvPlug::getNrOfChannels() const259 Plug::getNrOfChannels() const 266 260 { 267 261 return m_nrOfChannels; … … 269 263 270 264 int 271 AvPlug::getSampleRate() const265 Plug::getSampleRate() const 272 266 { 273 267 return convertESamplingFrequency( static_cast<ESamplingFrequency>( m_samplingFrequency ) ); … … 275 269 276 270 bool 277 AvPlug::discoverPlugType() 278 { 279 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); 280 ExtendedPlugInfoInfoType extendedPlugInfoInfoType( 281 ExtendedPlugInfoInfoType::eIT_PlugType ); 282 extendedPlugInfoInfoType.initialize(); 283 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 284 extPlugInfoCmd.setVerbose( m_verboseLevel ); 285 286 if ( !extPlugInfoCmd.fire() ) { 287 debugError( "plug type command failed\n" ); 288 return false; 289 } 290 291 m_infoPlugType = eAPT_Unknown; 292 293 if ( extPlugInfoCmd.getResponse() == AVCCommand::eR_Implemented ) { 294 295 ExtendedPlugInfoInfoType* infoType = extPlugInfoCmd.getInfoType(); 296 if ( infoType 297 && infoType->m_plugType ) 298 { 299 plug_type_t plugType = infoType->m_plugType->m_plugType; 300 301 debugOutput( DEBUG_LEVEL_VERBOSE, 302 "plug %d is of type %d (%s)\n", 303 m_id, 304 plugType, 305 extendedPlugInfoPlugTypeToString( plugType ) ); 306 switch ( plugType ) { 307 case ExtendedPlugInfoPlugTypeSpecificData::eEPIPT_IsoStream: 308 m_infoPlugType = eAPT_IsoStream; 309 break; 310 case ExtendedPlugInfoPlugTypeSpecificData::eEPIPT_AsyncStream: 311 m_infoPlugType = eAPT_AsyncStream; 312 break; 313 case ExtendedPlugInfoPlugTypeSpecificData::eEPIPT_Midi: 314 m_infoPlugType = eAPT_Midi; 315 break; 316 case ExtendedPlugInfoPlugTypeSpecificData::eEPIPT_Sync: 317 m_infoPlugType = eAPT_Sync; 318 break; 319 case ExtendedPlugInfoPlugTypeSpecificData::eEPIPT_Analog: 320 m_infoPlugType = eAPT_Analog; 321 break; 322 case ExtendedPlugInfoPlugTypeSpecificData::eEPIPT_Digital: 323 m_infoPlugType = eAPT_Digital; 324 break; 325 default: 326 m_infoPlugType = eAPT_Unknown; 327 328 } 329 } 330 } else { 331 debugError( "Plug does not implement extended plug info plug " 332 "type info command\n" ); 333 return false; 334 } 335 336 return true; 337 } 338 339 bool 340 AvPlug::discoverName() 341 { 342 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); 343 ExtendedPlugInfoInfoType extendedPlugInfoInfoType( 344 ExtendedPlugInfoInfoType::eIT_PlugName ); 345 extendedPlugInfoInfoType.initialize(); 346 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 347 extPlugInfoCmd.setVerbose( m_verboseLevel ); 348 349 if ( !extPlugInfoCmd.fire() ) { 350 debugError( "name command failed\n" ); 351 return false; 352 } 353 354 ExtendedPlugInfoInfoType* infoType = extPlugInfoCmd.getInfoType(); 355 if ( infoType 356 && infoType->m_plugName ) 357 { 358 std::string name = 359 infoType->m_plugName->m_name; 360 361 debugOutput( DEBUG_LEVEL_VERBOSE, 362 "plug %d has name '%s'\n", 363 m_id, 364 name.c_str() ); 365 366 m_name = name; 367 } 368 return true; 369 } 370 371 bool 372 AvPlug::discoverNoOfChannels() 373 { 374 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); 375 //extPlugInfoCmd.setVerbose( true ); 376 ExtendedPlugInfoInfoType extendedPlugInfoInfoType( 377 ExtendedPlugInfoInfoType::eIT_NoOfChannels ); 378 extendedPlugInfoInfoType.initialize(); 379 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 380 extPlugInfoCmd.setVerbose( m_verboseLevel ); 381 382 if ( !extPlugInfoCmd.fire() ) { 383 debugError( "number of channels command failed\n" ); 384 return false; 385 } 386 387 ExtendedPlugInfoInfoType* infoType = extPlugInfoCmd.getInfoType(); 388 if ( infoType 389 && infoType->m_plugNrOfChns ) 390 { 391 nr_of_channels_t nrOfChannels 392 = infoType->m_plugNrOfChns->m_nrOfChannels; 393 394 debugOutput( DEBUG_LEVEL_VERBOSE, 395 "plug %d has %d channels\n", 396 m_id, 397 nrOfChannels ); 398 399 m_nrOfChannels = nrOfChannels; 400 } 401 return true; 402 } 403 404 bool 405 AvPlug::discoverChannelPosition() 406 { 407 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); 408 ExtendedPlugInfoInfoType extendedPlugInfoInfoType( 409 ExtendedPlugInfoInfoType::eIT_ChannelPosition ); 410 extendedPlugInfoInfoType.initialize(); 411 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 412 extPlugInfoCmd.setVerbose( m_verboseLevel ); 413 414 if ( !extPlugInfoCmd.fire() ) { 415 debugError( "channel position command failed\n" ); 416 return false; 417 } 418 419 ExtendedPlugInfoInfoType* infoType = extPlugInfoCmd.getInfoType(); 420 if ( infoType 421 && infoType->m_plugChannelPosition ) 422 { 423 if ( !copyClusterInfo( *( infoType->m_plugChannelPosition ) ) ) { 424 debugError( "Could not copy channel position " 425 "information\n" ); 426 return false; 427 } 428 429 debugOutput( DEBUG_LEVEL_VERBOSE, 430 "plug %d: channel position information " 431 "retrieved\n", 432 m_id ); 433 434 debugOutputClusterInfos( DEBUG_LEVEL_VERBOSE ); 435 } 436 437 return true; 438 } 439 440 bool 441 AvPlug::discoverChannelName() 442 { 443 for ( ClusterInfoVector::iterator clit = m_clusterInfos.begin(); 444 clit != m_clusterInfos.end(); 445 ++clit ) 446 { 447 ClusterInfo* clitInfo = &*clit; 448 449 for ( ChannelInfoVector::iterator pit = clitInfo->m_channelInfos.begin(); 450 pit != clitInfo->m_channelInfos.end(); 451 ++pit ) 452 { 453 ChannelInfo* channelInfo = &*pit; 454 455 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); 456 ExtendedPlugInfoInfoType extendedPlugInfoInfoType( 457 ExtendedPlugInfoInfoType::eIT_ChannelName ); 458 extendedPlugInfoInfoType.initialize(); 459 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 460 extPlugInfoCmd.setVerbose( m_verboseLevel ); 461 462 ExtendedPlugInfoInfoType* infoType = 463 extPlugInfoCmd.getInfoType(); 464 if ( infoType ) { 465 infoType->m_plugChannelName->m_streamPosition = 466 channelInfo->m_streamPosition; 467 } 468 if ( !extPlugInfoCmd.fire() ) { 469 debugError( "channel name command failed\n" ); 470 return false; 471 } 472 infoType = extPlugInfoCmd.getInfoType(); 473 if ( infoType 474 && infoType->m_plugChannelName ) 475 { 476 debugOutput( DEBUG_LEVEL_VERBOSE, 477 "plug %d stream " 478 "position %d: channel name = %s\n", 479 m_id, 480 channelInfo->m_streamPosition, 481 infoType->m_plugChannelName->m_plugChannelName.c_str() ); 482 channelInfo->m_name = 483 infoType->m_plugChannelName->m_plugChannelName; 484 } 485 486 } 487 } 488 489 return true; 490 } 491 492 bool 493 AvPlug::discoverClusterInfo() 494 { 495 if ( m_infoPlugType == eAPT_Sync ) 496 { 497 // If the plug is of type sync it is either a normal 2 channel 498 // stream (not compound stream) or it is a compound stream 499 // with exactly one cluster. This depends on the 500 // extended stream format command version which is used. 501 // We are not interested in this plug so we skip it. 502 debugOutput( DEBUG_LEVEL_VERBOSE, 503 "%s plug %d is of type sync -> skip\n", 504 getName(), 505 m_id ); 506 return true; 507 } 508 509 for ( ClusterInfoVector::iterator clit = m_clusterInfos.begin(); 510 clit != m_clusterInfos.end(); 511 ++clit ) 512 { 513 ClusterInfo* clusterInfo = &*clit; 514 515 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); 516 ExtendedPlugInfoInfoType extendedPlugInfoInfoType( 517 ExtendedPlugInfoInfoType::eIT_ClusterInfo ); 518 extendedPlugInfoInfoType.initialize(); 519 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 520 extPlugInfoCmd.setVerbose( m_verboseLevel ); 521 522 extPlugInfoCmd.getInfoType()->m_plugClusterInfo->m_clusterIndex = 523 clusterInfo->m_index; 524 525 if ( !extPlugInfoCmd.fire() ) { 526 debugError( "cluster info command failed\n" ); 527 return false; 528 } 529 530 ExtendedPlugInfoInfoType* infoType = extPlugInfoCmd.getInfoType(); 531 if ( infoType 532 && infoType->m_plugClusterInfo ) 533 { 534 debugOutput( DEBUG_LEVEL_VERBOSE, 535 "%s plug %d: cluster index = %d, " 536 "portType %s, cluster name = %s\n", 537 getName(), 538 m_id, 539 infoType->m_plugClusterInfo->m_clusterIndex, 540 extendedPlugInfoClusterInfoPortTypeToString( 541 infoType->m_plugClusterInfo->m_portType ), 542 infoType->m_plugClusterInfo->m_clusterName.c_str() ); 543 544 clusterInfo->m_portType = infoType->m_plugClusterInfo->m_portType; 545 clusterInfo->m_name = infoType->m_plugClusterInfo->m_clusterName; 546 } 547 } 548 549 return true; 550 } 551 552 bool 553 AvPlug::discoverStreamFormat() 554 { 555 ExtendedStreamFormatCmd extStreamFormatCmd = 556 setPlugAddrToStreamFormatCmd( ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommand ); 557 extStreamFormatCmd.setVerbose( m_verboseLevel ); 558 559 if ( !extStreamFormatCmd.fire() ) { 560 debugError( "stream format command failed\n" ); 561 return false; 562 } 563 564 if ( ( extStreamFormatCmd.getStatus() == ExtendedStreamFormatCmd::eS_NoStreamFormat ) 565 || ( extStreamFormatCmd.getStatus() == ExtendedStreamFormatCmd::eS_NotUsed ) ) 566 { 567 debugOutput( DEBUG_LEVEL_VERBOSE, 568 "No stream format information available\n" ); 569 return true; 570 } 571 572 if ( !extStreamFormatCmd.getFormatInformation() ) { 573 debugWarning( "No stream format information for plug found -> skip\n" ); 574 return true; 575 } 576 577 if ( extStreamFormatCmd.getFormatInformation()->m_root 578 != FormatInformation::eFHR_AudioMusic ) 579 { 580 debugWarning( "Format hierarchy root is not Audio&Music -> skip\n" ); 581 return true; 582 } 583 584 FormatInformation* formatInfo = 585 extStreamFormatCmd.getFormatInformation(); 586 FormatInformationStreamsCompound* compoundStream 587 = dynamic_cast< FormatInformationStreamsCompound* > ( 588 formatInfo->m_streams ); 589 if ( compoundStream ) { 590 m_samplingFrequency = 591 compoundStream->m_samplingFrequency; 592 debugOutput( DEBUG_LEVEL_VERBOSE, 593 "%s plug %d uses " 594 "sampling frequency %d, nr of stream infos = %d\n", 595 getName(), 596 m_id, 597 m_samplingFrequency, 598 compoundStream->m_numberOfStreamFormatInfos ); 599 600 for ( int i = 1; 601 i <= compoundStream->m_numberOfStreamFormatInfos; 602 ++i ) 603 { 604 ClusterInfo* clusterInfo = 605 const_cast<ClusterInfo*>( getClusterInfoByIndex( i ) ); 606 607 if ( !clusterInfo ) { 608 debugError( "No matching cluster " 609 "info found for index %d\n", i ); 610 return false; 611 } 612 StreamFormatInfo* streamFormatInfo = 613 compoundStream->m_streamFormatInfos[ i - 1 ]; 614 615 debugOutput( DEBUG_LEVEL_VERBOSE, 616 "number of channels = %d, stream format = %d\n", 617 streamFormatInfo->m_numberOfChannels, 618 streamFormatInfo->m_streamFormat ); 619 620 int nrOfChannels = clusterInfo->m_nrOfChannels; 621 if ( streamFormatInfo->m_streamFormat == 622 FormatInformation::eFHL2_AM824_MIDI_CONFORMANT ) 623 { 624 // 8 logical midi channels fit into 1 channel 625 nrOfChannels = ( ( nrOfChannels + 7 ) / 8 ); 626 } 627 // sanity check 628 if ( nrOfChannels != streamFormatInfo->m_numberOfChannels ) 629 { 630 debugWarning( "Number of channels " 631 "mismatch: '%s' plug discovering reported " 632 "%d channels for cluster '%s', while stream " 633 "format reported %d\n", 634 getName(), 635 nrOfChannels, 636 clusterInfo->m_name.c_str(), 637 streamFormatInfo->m_numberOfChannels); 638 } 639 clusterInfo->m_streamFormat = streamFormatInfo->m_streamFormat; 640 641 debugOutput( DEBUG_LEVEL_VERBOSE, 642 "%s plug %d cluster info %d ('%s'): " 643 "stream format %d\n", 644 getName(), 645 m_id, 646 i, 647 clusterInfo->m_name.c_str(), 648 clusterInfo->m_streamFormat ); 649 } 650 } 651 652 FormatInformationStreamsSync* syncStream 653 = dynamic_cast< FormatInformationStreamsSync* > ( 654 formatInfo->m_streams ); 655 if ( syncStream ) { 656 m_samplingFrequency = 657 syncStream->m_samplingFrequency; 658 debugOutput( DEBUG_LEVEL_VERBOSE, 659 "%s plug %d is sync stream with sampling frequency %d\n", 660 getName(), 661 m_id, 662 m_samplingFrequency ); 663 } 664 665 666 if ( !compoundStream && !syncStream ) 667 { 668 debugError( "Unsupported stream format\n" ); 669 return false; 670 } 671 672 return true; 673 } 674 675 bool 676 AvPlug::discoverSupportedStreamFormats() 677 { 678 ExtendedStreamFormatCmd extStreamFormatCmd = 679 setPlugAddrToStreamFormatCmd( 680 ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommandList); 681 extStreamFormatCmd.setVerbose( m_verboseLevel ); 682 683 int i = 0; 684 bool cmdSuccess = false; 685 686 do { 687 extStreamFormatCmd.setIndexInStreamFormat( i ); 688 extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); 689 cmdSuccess = extStreamFormatCmd.fire(); 690 if ( cmdSuccess 691 && ( extStreamFormatCmd.getResponse() 692 == AVCCommand::eR_Implemented ) ) 693 { 694 FormatInfo formatInfo; 695 formatInfo.m_index = i; 696 bool formatInfoIsValid = true; 697 698 FormatInformationStreamsSync* syncStream 699 = dynamic_cast< FormatInformationStreamsSync* > 700 ( extStreamFormatCmd.getFormatInformation()->m_streams ); 701 if ( syncStream ) { 702 formatInfo.m_samplingFrequency = 703 syncStream->m_samplingFrequency; 704 formatInfo.m_isSyncStream = true ; 705 } 706 707 FormatInformationStreamsCompound* compoundStream 708 = dynamic_cast< FormatInformationStreamsCompound* > 709 ( extStreamFormatCmd.getFormatInformation()->m_streams ); 710 if ( compoundStream ) { 711 formatInfo.m_samplingFrequency = 712 compoundStream->m_samplingFrequency; 713 formatInfo.m_isSyncStream = false; 714 for ( int j = 0; 715 j < compoundStream->m_numberOfStreamFormatInfos; 716 ++j ) 717 { 718 switch ( compoundStream->m_streamFormatInfos[j]->m_streamFormat ) { 719 case AVC1394_STREAM_FORMAT_AM824_IEC60968_3: 720 formatInfo.m_audioChannels += 721 compoundStream->m_streamFormatInfos[j]->m_numberOfChannels; 722 break; 723 case AVC1394_STREAM_FORMAT_AM824_MULTI_BIT_LINEAR_AUDIO_RAW: 724 formatInfo.m_audioChannels += 725 compoundStream->m_streamFormatInfos[j]->m_numberOfChannels; 726 break; 727 case AVC1394_STREAM_FORMAT_AM824_MIDI_CONFORMANT: 728 formatInfo.m_midiChannels += 729 compoundStream->m_streamFormatInfos[j]->m_numberOfChannels; 730 break; 731 default: 732 formatInfoIsValid = false; 733 debugWarning("unknown stream format (0x%02x) for channel " 734 "(%d)\n", 735 compoundStream->m_streamFormatInfos[j]->m_streamFormat, 736 j ); 737 } 738 } 739 } 740 741 if ( formatInfoIsValid ) { 742 debugOutput( DEBUG_LEVEL_VERBOSE, 743 "[%s:%d] formatInfo[%d].m_samplingFrequency " 744 "= %d\n", 745 getName(), m_id, 746 i, formatInfo.m_samplingFrequency ); 747 debugOutput( DEBUG_LEVEL_VERBOSE, 748 "[%s:%d] formatInfo[%d].m_isSyncStream = %d\n", 749 getName(), m_id, 750 i, formatInfo.m_isSyncStream ); 751 debugOutput( DEBUG_LEVEL_VERBOSE, 752 "[%s:%d] formatInfo[%d].m_audioChannels = %d\n", 753 getName(), m_id, 754 i, formatInfo.m_audioChannels ); 755 debugOutput( DEBUG_LEVEL_VERBOSE, 756 "[%s:%d] formatInfo[%d].m_midiChannels = %d\n", 757 getName(), m_id, 758 i, formatInfo.m_midiChannels ); 759 m_formatInfos.push_back( formatInfo ); 760 } 761 } 762 763 ++i; 764 } while ( cmdSuccess && ( extStreamFormatCmd.getResponse() 765 == ExtendedStreamFormatCmd::eR_Implemented ) ); 766 767 return true; 768 } 769 770 771 bool 772 AvPlug::discoverConnectionsInput() 773 { 774 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); 775 ExtendedPlugInfoInfoType extendedPlugInfoInfoType( 776 ExtendedPlugInfoInfoType::eIT_PlugInput ); 777 extendedPlugInfoInfoType.initialize(); 778 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 779 extPlugInfoCmd.setVerbose( m_verboseLevel ); 780 781 if ( !extPlugInfoCmd.fire() ) { 782 debugError( "plug type command failed\n" ); 783 return false; 784 } 785 786 if ( extPlugInfoCmd.getResponse() == AVCCommand::eR_Rejected ) { 787 // Plugs does not like to be asked about connections 788 debugOutput( DEBUG_LEVEL_VERBOSE, "Plug '%s' rejects " 789 "connections command\n", 790 getName() ); 791 return true; 792 } 793 794 ExtendedPlugInfoInfoType* infoType = extPlugInfoCmd.getInfoType(); 795 if ( infoType 796 && infoType->m_plugInput ) 797 { 798 PlugAddressSpecificData* plugAddress 799 = infoType->m_plugInput->m_plugAddress; 800 801 if ( plugAddress->m_addressMode == 802 PlugAddressSpecificData::ePAM_Undefined ) 803 { 804 // This plug has no input connection 805 return true; 806 } 807 808 if ( !discoverConnectionsFromSpecificData( eAPD_Input, 809 plugAddress, 810 m_inputConnections ) ) 811 { 812 debugWarning( "Could not discover connnections for plug '%s'\n", 813 getName() ); 814 } 815 } else { 816 debugError( "no valid info type for plug '%s'\n", getName() ); 817 return false; 818 } 819 820 return true; 821 } 822 823 bool 824 AvPlug::discoverConnectionsOutput() 825 { 826 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); 827 ExtendedPlugInfoInfoType extendedPlugInfoInfoType( 828 ExtendedPlugInfoInfoType::eIT_PlugOutput ); 829 extendedPlugInfoInfoType.initialize(); 830 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 831 extPlugInfoCmd.setVerbose( m_verboseLevel ); 832 833 if ( !extPlugInfoCmd.fire() ) { 834 debugError( "plug type command failed\n" ); 835 return false; 836 } 837 838 if ( extPlugInfoCmd.getResponse() == AVCCommand::eR_Rejected ) { 839 // Plugs does not like to be asked about connections 840 debugOutput( DEBUG_LEVEL_VERBOSE, "Plug '%s' rejects " 841 "connections command\n", 842 getName() ); 843 return true; 844 } 845 846 ExtendedPlugInfoInfoType* infoType = extPlugInfoCmd.getInfoType(); 847 if ( infoType 848 && infoType->m_plugOutput ) 849 { 850 if ( infoType->m_plugOutput->m_nrOfOutputPlugs 851 != infoType->m_plugOutput->m_outputPlugAddresses.size() ) 852 { 853 debugError( "number of output plugs (%d) disagree with " 854 "number of elements in plug address vector (%d)\n", 855 infoType->m_plugOutput->m_nrOfOutputPlugs, 856 infoType->m_plugOutput->m_outputPlugAddresses.size()); 857 } 858 859 if ( infoType->m_plugOutput->m_nrOfOutputPlugs == 0 ) { 860 // This plug has no output connections 861 return true; 862 } 863 864 for ( unsigned int i = 0; 865 i < infoType->m_plugOutput->m_outputPlugAddresses.size(); 866 ++i ) 867 { 868 PlugAddressSpecificData* plugAddress 869 = infoType->m_plugOutput->m_outputPlugAddresses[i]; 870 871 if ( !discoverConnectionsFromSpecificData( eAPD_Output, 872 plugAddress, 873 m_outputConnections ) ) 874 { 875 debugWarning( "Could not discover connnections for " 876 "plug '%s'\n", getName() ); 877 } 878 } 879 } else { 880 debugError( "no valid info type for plug '%s'\n", getName() ); 881 return false; 882 } 883 884 return true; 885 } 886 887 bool 888 AvPlug::discoverConnectionsFromSpecificData( 889 EAvPlugDirection discoverDirection, 271 Plug::discoverConnectionsFromSpecificData( 272 EPlugDirection discoverDirection, 890 273 PlugAddressSpecificData* plugAddress, 891 AvPlugVector& connections )274 PlugVector& connections ) 892 275 { 893 276 UnitPlugSpecificDataPlugAddress* pUnitPlugAddress = … … 904 287 ( plugAddress->m_plugAddressData ); 905 288 906 AvPlug* plug = getPlugDefinedBySpecificData(289 Plug* plug = getPlugDefinedBySpecificData( 907 290 pUnitPlugAddress, 908 291 pSubunitPlugAddress, … … 928 311 929 312 bool 930 AvPlug::addPlugConnection( AvPlugVector& connections,931 AvPlug& plug )932 933 { 934 for ( AvPlugVector::iterator it = connections.begin();313 Plug::addPlugConnection( PlugVector& connections, 314 Plug& plug ) 315 316 { 317 for ( PlugVector::iterator it = connections.begin(); 935 318 it != connections.end(); 936 319 ++it ) 937 320 { 938 AvPlug* cPlug = *it;321 Plug* cPlug = *it; 939 322 if ( cPlug == &plug ) { 940 323 debugOutput( DEBUG_LEVEL_VERBOSE, … … 949 332 } 950 333 951 ExtendedPlugInfoCmd952 AvPlug::setPlugAddrToPlugInfoCmd()953 {954 ExtendedPlugInfoCmd extPlugInfoCmd( *m_p1394Service );955 956 switch( m_subunitType ) {957 case eST_Unit:958 {959 UnitPlugAddress::EPlugType ePlugType =960 UnitPlugAddress::ePT_Unknown;961 switch ( m_addressType ) {962 case eAPA_PCR:963 ePlugType = UnitPlugAddress::ePT_PCR;964 break;965 case eAPA_ExternalPlug:966 ePlugType = UnitPlugAddress::ePT_ExternalPlug;967 break;968 case eAPA_AsynchronousPlug:969 ePlugType = UnitPlugAddress::ePT_AsynchronousPlug;970 break;971 default:972 ePlugType = UnitPlugAddress::ePT_Unknown;973 }974 UnitPlugAddress unitPlugAddress( ePlugType,975 m_id );976 extPlugInfoCmd.setPlugAddress(977 PlugAddress( convertPlugDirection( getPlugDirection() ),978 PlugAddress::ePAM_Unit,979 unitPlugAddress ) );980 }981 break;982 case eST_Music:983 case eST_Audio:984 {985 switch( m_addressType ) {986 case eAPA_SubunitPlug:987 {988 SubunitPlugAddress subunitPlugAddress( m_id );989 extPlugInfoCmd.setPlugAddress(990 PlugAddress(991 convertPlugDirection( getPlugDirection() ),992 PlugAddress::ePAM_Subunit,993 subunitPlugAddress ) );994 }995 break;996 case eAPA_FunctionBlockPlug:997 {998 FunctionBlockPlugAddress functionBlockPlugAddress(999 m_functionBlockType,1000 m_functionBlockId,1001 m_id );1002 extPlugInfoCmd.setPlugAddress(1003 PlugAddress(1004 convertPlugDirection( getPlugDirection() ),1005 PlugAddress::ePAM_FunctionBlock,1006 functionBlockPlugAddress ) );1007 }1008 break;1009 default:1010 extPlugInfoCmd.setPlugAddress(PlugAddress());1011 }1012 }1013 break;1014 default:1015 debugError( "Unknown subunit type\n" );1016 }1017 1018 extPlugInfoCmd.setNodeId( m_pConfigRom->getNodeId() );1019 extPlugInfoCmd.setCommandType( AVCCommand::eCT_Status );1020 extPlugInfoCmd.setSubunitId( m_subunitId );1021 extPlugInfoCmd.setSubunitType( m_subunitType );1022 1023 return extPlugInfoCmd;1024 }1025 1026 ExtendedStreamFormatCmd1027 AvPlug::setPlugAddrToStreamFormatCmd(1028 ExtendedStreamFormatCmd::ESubFunction subFunction)1029 {1030 ExtendedStreamFormatCmd extStreamFormatInfoCmd(1031 *m_p1394Service,1032 subFunction );1033 switch( m_subunitType ) {1034 case eST_Unit:1035 {1036 UnitPlugAddress::EPlugType ePlugType =1037 UnitPlugAddress::ePT_Unknown;1038 switch ( m_addressType ) {1039 case eAPA_PCR:1040 ePlugType = UnitPlugAddress::ePT_PCR;1041 break;1042 case eAPA_ExternalPlug:1043 ePlugType = UnitPlugAddress::ePT_ExternalPlug;1044 break;1045 case eAPA_AsynchronousPlug:1046 ePlugType = UnitPlugAddress::ePT_AsynchronousPlug;1047 break;1048 default:1049 ePlugType = UnitPlugAddress::ePT_Unknown;1050 }1051 UnitPlugAddress unitPlugAddress( ePlugType,1052 m_id );1053 extStreamFormatInfoCmd.setPlugAddress(1054 PlugAddress( convertPlugDirection( getPlugDirection() ),1055 PlugAddress::ePAM_Unit,1056 unitPlugAddress ) );1057 }1058 break;1059 case eST_Music:1060 case eST_Audio:1061 {1062 switch( m_addressType ) {1063 case eAPA_SubunitPlug:1064 {1065 SubunitPlugAddress subunitPlugAddress( m_id );1066 extStreamFormatInfoCmd.setPlugAddress(1067 PlugAddress( convertPlugDirection( getPlugDirection() ),1068 PlugAddress::ePAM_Subunit,1069 subunitPlugAddress ) );1070 }1071 break;1072 case eAPA_FunctionBlockPlug:1073 {1074 FunctionBlockPlugAddress functionBlockPlugAddress(1075 m_functionBlockType,1076 m_functionBlockId,1077 m_id );1078 extStreamFormatInfoCmd.setPlugAddress(1079 PlugAddress( convertPlugDirection( getPlugDirection() ),1080 PlugAddress::ePAM_FunctionBlock,1081 functionBlockPlugAddress ) );1082 }1083 break;1084 default:1085 extStreamFormatInfoCmd.setPlugAddress(PlugAddress());1086 }1087 }1088 break;1089 default:1090 debugError( "Unknown subunit type\n" );1091 }1092 1093 extStreamFormatInfoCmd.setNodeId( m_pConfigRom->getNodeId() );1094 extStreamFormatInfoCmd.setCommandType( AVCCommand::eCT_Status );1095 extStreamFormatInfoCmd.setSubunitId( m_subunitId );1096 extStreamFormatInfoCmd.setSubunitType( m_subunitType );1097 1098 return extStreamFormatInfoCmd;1099 }1100 1101 334 SignalSourceCmd 1102 AvPlug::setSrcPlugAddrToSignalCmd()1103 { 1104 SignalSourceCmd signalSourceCmd( *m_p1394Service);1105 1106 switch( m_subunitType) {335 Plug::setSrcPlugAddrToSignalCmd() 336 { 337 SignalSourceCmd signalSourceCmd( m_unit->get1394Service() ); 338 339 switch( getSubunitType() ) { 1107 340 case eST_Unit: 1108 341 { … … 1120 353 { 1121 354 SignalSubunitAddress signalSubunitAddr; 1122 signalSubunitAddr.m_subunitType = m_subunitType;1123 signalSubunitAddr.m_subunitId = m_subunitId;355 signalSubunitAddr.m_subunitType = getSubunitType(); 356 signalSubunitAddr.m_subunitId = getSubunitId(); 1124 357 signalSubunitAddr.m_plugId = m_id; 1125 358 signalSourceCmd.setSignalSource( signalSubunitAddr ); … … 1130 363 } 1131 364 1132 signalSourceCmd.setNodeId( m_ pConfigRom->getNodeId() );365 signalSourceCmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 1133 366 signalSourceCmd.setSubunitType( eST_Unit ); 1134 367 signalSourceCmd.setSubunitId( 0xff ); … … 1138 371 1139 372 void 1140 AvPlug::setDestPlugAddrToSignalCmd(SignalSourceCmd& signalSourceCmd,1141 AvPlug& plug)1142 { 1143 switch( plug. m_subunitType) {373 Plug::setDestPlugAddrToSignalCmd(SignalSourceCmd& signalSourceCmd, 374 Plug& plug) 375 { 376 switch( plug.getSubunitType() ) { 1144 377 case eST_Unit: 1145 378 { … … 1157 390 { 1158 391 SignalSubunitAddress signalSubunitAddr; 1159 signalSubunitAddr.m_subunitType = plug. m_subunitType;1160 signalSubunitAddr.m_subunitId = plug. m_subunitId;392 signalSubunitAddr.m_subunitType = plug.getSubunitType(); 393 signalSubunitAddr.m_subunitId = plug.getSubunitId(); 1161 394 signalSubunitAddr.m_plugId = plug.m_id; 1162 395 signalSourceCmd.setSignalDestination( signalSubunitAddr ); … … 1170 403 1171 404 bool 1172 AvPlug::copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData&405 Plug::copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData& 1173 406 channelPositionData ) 1174 407 { … … 1210 443 1211 444 void 1212 AvPlug::debugOutputClusterInfos( int debugLevel )445 Plug::debugOutputClusterInfos( int debugLevel ) 1213 446 { 1214 447 for ( ClusterInfoVector::const_iterator it = m_clusterInfos.begin(); … … 1238 471 } 1239 472 1240 const AvPlug::ClusterInfo*1241 AvPlug::getClusterInfoByIndex(int index) const1242 { 1243 for ( AvPlug::ClusterInfoVector::const_iterator clit =473 const Plug::ClusterInfo* 474 Plug::getClusterInfoByIndex(int index) const 475 { 476 for ( Plug::ClusterInfoVector::const_iterator clit = 1244 477 m_clusterInfos.begin(); 1245 478 clit != m_clusterInfos.end(); … … 1255 488 1256 489 PlugAddress::EPlugDirection 1257 AvPlug::convertPlugDirection( EAvPlugDirection direction )490 Plug::convertPlugDirection( EPlugDirection direction ) 1258 491 { 1259 492 PlugAddress::EPlugDirection dir; 1260 493 switch ( direction ) { 1261 case AvPlug::eAPD_Input:494 case Plug::eAPD_Input: 1262 495 dir = PlugAddress::ePD_Input; 1263 496 break; 1264 case AvPlug::eAPD_Output:497 case Plug::eAPD_Output: 1265 498 dir = PlugAddress::ePD_Output; 1266 499 break; … … 1272 505 1273 506 void 1274 AvPlug::showPlug() const507 Plug::showPlug() const 1275 508 { 1276 509 debugOutput( DEBUG_LEVEL_VERBOSE, "\tName = %s\n", … … 1297 530 1298 531 1299 AvPlug*1300 AvPlug::getPlugDefinedBySpecificData(532 Plug* 533 Plug::getPlugDefinedBySpecificData( 1301 534 UnitPlugSpecificDataPlugAddress* pUnitPlugAddress, 1302 535 SubunitPlugSpecificDataPlugAddress* pSubunitPlugAddress, … … 1307 540 function_block_type_t functionBlockType = 0xff; 1308 541 function_block_id_t functionBlockId = 0xff; 1309 E AvPlugAddressType addressType = eAPA_Undefined;1310 E AvPlugDirection direction = eAPD_Unknown;542 EPlugAddressType addressType = eAPA_Undefined; 543 EPlugDirection direction = eAPD_Unknown; 1311 544 plug_id_t plugId = 0xff; 1312 545 … … 1413 646 static_cast<ESubunitType>( subunitType ); 1414 647 1415 return m_ plugManager->getPlug(648 return m_unit->getPlugManager().getPlug( 1416 649 enumSubunitType, 1417 650 subunitId, … … 1423 656 } 1424 657 1425 AvPlug::EAvPlugDirection1426 AvPlug::toggleDirection( EAvPlugDirection direction ) const1427 { 1428 E AvPlugDirection newDirection;658 Plug::EPlugDirection 659 Plug::toggleDirection( EPlugDirection direction ) const 660 { 661 EPlugDirection newDirection; 1429 662 switch ( direction ) { 1430 663 case eAPD_Output: … … 1442 675 1443 676 bool 1444 AvPlug::serializeChannelInfos( Glib::ustring basePath,677 Plug::serializeChannelInfos( Glib::ustring basePath, 1445 678 Util::IOSerialize& ser, 1446 679 const ClusterInfo& clusterInfo ) const … … 1465 698 1466 699 bool 1467 AvPlug::deserializeChannelInfos( Glib::ustring basePath,700 Plug::deserializeChannelInfos( Glib::ustring basePath, 1468 701 Util::IODeserialize& deser, 1469 702 ClusterInfo& clusterInfo ) … … 1501 734 1502 735 bool 1503 AvPlug::serializeClusterInfos( Glib::ustring basePath,736 Plug::serializeClusterInfos( Glib::ustring basePath, 1504 737 Util::IOSerialize& ser ) const 1505 738 { … … 1527 760 1528 761 bool 1529 AvPlug::deserializeClusterInfos( Glib::ustring basePath,762 Plug::deserializeClusterInfos( Glib::ustring basePath, 1530 763 Util::IODeserialize& deser ) 1531 764 { … … 1565 798 1566 799 bool 1567 AvPlug::serializeFormatInfos( Glib::ustring basePath,800 Plug::serializeFormatInfos( Glib::ustring basePath, 1568 801 Util::IOSerialize& ser ) const 1569 802 { … … 1588 821 1589 822 bool 1590 AvPlug::deserializeFormatInfos( Glib::ustring basePath,823 Plug::deserializeFormatInfos( Glib::ustring basePath, 1591 824 Util::IODeserialize& deser ) 1592 825 { … … 1625 858 1626 859 bool 1627 AvPlug::serializeAvPlugVector( Glib::ustring basePath,860 Plug::serializePlugVector( Glib::ustring basePath, 1628 861 Util::IOSerialize& ser, 1629 const AvPlugVector& vec) const862 const PlugVector& vec) const 1630 863 { 1631 864 bool result = true; 1632 865 int i = 0; 1633 for ( AvPlugVector::const_iterator it = vec.begin();866 for ( PlugVector::const_iterator it = vec.begin(); 1634 867 it != vec.end(); 1635 868 ++it ) 1636 869 { 1637 const AvPlug* pPlug = *it;870 const Plug* pPlug = *it; 1638 871 std::ostringstream strstrm; 1639 872 strstrm << basePath << i; … … 1646 879 1647 880 bool 1648 AvPlug::deserializeAvPlugVector( Glib::ustring basePath,881 Plug::deserializePlugVector( Glib::ustring basePath, 1649 882 Util::IODeserialize& deser, 1650 AvPlugVector& vec )883 PlugVector& vec ) 1651 884 { 1652 885 int i = 0; … … 1664 897 1665 898 if ( result ) { 1666 AvPlug* pPlug = m_plugManager->getPlug( iPlugId );899 Plug* pPlug = m_unit->getPlugManager().getPlug( iPlugId ); 1667 900 if ( pPlug ) { 1668 901 vec.push_back( pPlug ); … … 1684 917 1685 918 bool 1686 AvPlug::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const1687 { 1688 bool result ;1689 result = ser.write( basePath + "m_subunitType", m_subunitType);1690 result &= ser.write( basePath + "m_subunitId", m_subunitId);919 Plug::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 920 { 921 bool result=true; 922 result &= ser.write( basePath + "m_subunitType", getSubunitType()); 923 result &= ser.write( basePath + "m_subunitId", getSubunitId()); 1691 924 result &= ser.write( basePath + "m_functionBlockType", m_functionBlockType); 1692 925 result &= ser.write( basePath + "m_functionBlockId", m_functionBlockId); … … 1700 933 result &= ser.write( basePath + "m_samplingFrequency", m_samplingFrequency); 1701 934 result &= serializeFormatInfos( basePath + "m_formatInfo", ser ); 1702 result &= serialize AvPlugVector( basePath + "m_inputConnections", ser, m_inputConnections );1703 result &= serialize AvPlugVector( basePath + "m_outputConnections", ser, m_outputConnections );1704 result &= ser.write( basePath + "m_verbose Level", m_verboseLevel);935 result &= serializePlugVector( basePath + "m_inputConnections", ser, m_inputConnections ); 936 result &= serializePlugVector( basePath + "m_outputConnections", ser, m_outputConnections ); 937 result &= ser.write( basePath + "m_verbose_level", getDebugLevel()); 1705 938 result &= ser.write( basePath + "m_globalId", m_globalId); 1706 939 result &= ser.write( basePath + "m_globalIdCounter", m_globalIdCounter ); … … 1709 942 } 1710 943 1711 AvPlug*1712 AvPlug::deserialize( Glib::ustring basePath,944 Plug* 945 Plug::deserialize( Glib::ustring basePath, 1713 946 Util::IODeserialize& deser, 1714 AvDevice& avDevice,1715 AvPlugManager& plugManager )1716 { 1717 AvPlug* pPlug = new AvPlug;947 Unit& unit, 948 PlugManager& plugManager ) 949 { 950 Plug* pPlug = new Plug; 1718 951 if ( !pPlug ) { 1719 952 return 0; 1720 953 } 1721 954 1722 pPlug->m_p1394Service = &avDevice.get1394Service(); 1723 pPlug->m_pConfigRom = &avDevice.getConfigRom(); 1724 pPlug->m_plugManager = &plugManager; 1725 bool result; 1726 result = deser.read( basePath + "m_subunitType", pPlug->m_subunitType ); 1727 result &= deser.read( basePath + "m_subunitId", pPlug->m_subunitId ); 955 pPlug->m_unit = &unit; 956 957 bool result=true; 958 959 ESubunitType subunitType; 960 result = deser.read( basePath + "m_subunitType", subunitType ); 961 subunit_t subunitId; 962 result &= deser.read( basePath + "m_subunitId", subunitId ); 963 pPlug->m_subunit = unit.getSubunit( subunitType, subunitType ); 964 1728 965 result &= deser.read( basePath + "m_functionBlockType", pPlug->m_functionBlockType ); 1729 966 result &= deser.read( basePath + "m_functionBlockId", pPlug->m_functionBlockId ); … … 1739 976 // input and output connections can't be processed here because not all plugs might 1740 977 // deserialized at this point. so we do that in deserializeUpdate. 1741 result &= deser.read( basePath + "m_verboseLevel", pPlug->m_verboseLevel ); 978 int level; 979 result &= deser.read( basePath + "m_verbose_level", level ); 980 setDebugLevel(level); 1742 981 result &= deser.read( basePath + "m_globalId", pPlug->m_globalId ); 1743 982 result &= deser.read( basePath + "m_globalIdCounter", pPlug->m_globalIdCounter ); … … 1752 991 1753 992 bool 1754 AvPlug::deserializeUpdate( Glib::ustring basePath,993 Plug::deserializeUpdate( Glib::ustring basePath, 1755 994 Util::IODeserialize& deser ) 1756 995 { 1757 996 bool result; 1758 997 1759 result = deserialize AvPlugVector( basePath + "m_inputConnections", deser, m_inputConnections );1760 result &= deserialize AvPlugVector( basePath + "m_outputConnections", deser, m_outputConnections );998 result = deserializePlugVector( basePath + "m_inputConnections", deser, m_inputConnections ); 999 result &= deserializePlugVector( basePath + "m_outputConnections", deser, m_outputConnections ); 1761 1000 1762 1001 return result; … … 1776 1015 }; 1777 1016 1778 const char* avPlugAddressTypeToString( AvPlug::EAvPlugAddressType type )1017 const char* avPlugAddressTypeToString( Plug::EPlugAddressType type ) 1779 1018 { 1780 1019 if ( type > ( int )( sizeof( avPlugAddressTypeStrings ) 1781 1020 / sizeof( avPlugAddressTypeStrings[0] ) ) ) 1782 1021 { 1783 type = AvPlug::eAPA_Undefined;1022 type = Plug::eAPA_Undefined; 1784 1023 } 1785 1024 return avPlugAddressTypeStrings[type]; … … 1797 1036 }; 1798 1037 1799 const char* avPlugTypeToString( AvPlug::EAvPlugType type )1038 const char* avPlugTypeToString( Plug::EPlugType type ) 1800 1039 { 1801 1040 if ( type > ( int )( sizeof( avPlugTypeStrings ) 1802 1041 / sizeof( avPlugTypeStrings[0] ) ) ) 1803 1042 { 1804 type = AvPlug::eAPT_Unknown;1043 type = Plug::eAPT_Unknown; 1805 1044 } 1806 1045 return avPlugTypeStrings[type]; … … 1814 1053 }; 1815 1054 1816 const char* avPlugDirectionToString( AvPlug::EAvPlugDirection type )1055 const char* avPlugDirectionToString( Plug::EPlugDirection type ) 1817 1056 { 1818 1057 if ( type > ( int )( sizeof( avPlugDirectionStrings ) 1819 1058 / sizeof( avPlugDirectionStrings[0] ) ) ) 1820 1059 { 1821 type = AvPlug::eAPD_Unknown;1060 type = Plug::eAPD_Unknown; 1822 1061 } 1823 1062 return avPlugDirectionStrings[type]; … … 1827 1066 1828 1067 1829 AvPlugManager::AvPlugManager( int verboseLevel ) 1830 : m_verboseLevel( verboseLevel ) 1831 { 1832 setDebugLevel( m_verboseLevel ); 1833 } 1834 1835 AvPlugManager::AvPlugManager() 1836 : m_verboseLevel( 0 ) 1837 { 1838 setDebugLevel( 0 ); 1839 } 1840 1841 AvPlugManager::AvPlugManager( const AvPlugManager& rhs ) 1842 : m_verboseLevel( rhs.m_verboseLevel ) 1843 { 1844 setDebugLevel( m_verboseLevel ); 1845 } 1846 1847 AvPlugManager::~AvPlugManager() 1848 { 1849 } 1850 1851 bool 1852 AvPlugManager::addPlug( AvPlug& plug ) 1068 PlugManager::PlugManager( ) 1069 { 1070 1071 } 1072 1073 PlugManager::PlugManager( const PlugManager& rhs ) 1074 { 1075 setDebugLevel( rhs.getDebugLevel() ); 1076 } 1077 1078 PlugManager::~PlugManager() 1079 { 1080 } 1081 1082 bool 1083 PlugManager::addPlug( Plug& plug ) 1853 1084 { 1854 1085 m_plugs.push_back( &plug ); … … 1857 1088 1858 1089 bool 1859 AvPlugManager::remPlug( AvPlug& plug )1860 { 1861 for ( AvPlugVector::iterator it = m_plugs.begin();1090 PlugManager::remPlug( Plug& plug ) 1091 { 1092 for ( PlugVector::iterator it = m_plugs.begin(); 1862 1093 it != m_plugs.end(); 1863 1094 ++it ) 1864 1095 { 1865 AvPlug* plugIt = *it;1096 Plug* plugIt = *it; 1866 1097 if ( plugIt == &plug ) { 1867 1098 m_plugs.erase( it ); … … 1873 1104 1874 1105 // helper function 1875 static void addConnection( AvPlugConnectionOwnerVector& connections,1876 AvPlug& srcPlug,1877 AvPlug& destPlug )1878 { 1879 for ( AvPlugConnectionOwnerVector::iterator it = connections.begin();1106 static void addConnection( PlugConnectionOwnerVector& connections, 1107 Plug& srcPlug, 1108 Plug& destPlug ) 1109 { 1110 for ( PlugConnectionOwnerVector::iterator it = connections.begin(); 1880 1111 it != connections.end(); 1881 1112 ++it ) 1882 1113 { 1883 AvPlugConnection& con = *it;1114 PlugConnection& con = *it; 1884 1115 if ( ( &( con.getSrcPlug() ) == &srcPlug ) 1885 1116 && ( &( con.getDestPlug() ) == &destPlug ) ) … … 1888 1119 } 1889 1120 } 1890 connections.push_back( AvPlugConnection( srcPlug, destPlug ) );1121 connections.push_back( PlugConnection( srcPlug, destPlug ) ); 1891 1122 } 1892 1123 1893 1124 void 1894 AvPlugManager::showPlugs() const1125 PlugManager::showPlugs() const 1895 1126 { 1896 1127 // \todo The information provided here could be better arranged. For a start it is ok, but … … 1903 1134 printf( "---+-----------------+-----------+-------------+-----------+-------------------+-----------------+------+--------------+------\n" ); 1904 1135 1905 for ( AvPlugVector::const_iterator it = m_plugs.begin();1136 for ( PlugVector::const_iterator it = m_plugs.begin(); 1906 1137 it != m_plugs.end(); 1907 1138 ++it ) 1908 1139 { 1909 AvPlug* plug = *it;1140 Plug* plug = *it; 1910 1141 1911 1142 printf( "%2d | %15s | %9s | %11s | 0x%02x | 0x%02x | 0x%02x | 0x%02x | %12s | %s\n", … … 1925 1156 printf( "-----------\n" ); 1926 1157 1927 AvPlugConnectionOwnerVector connections;1928 1929 for ( AvPlugVector::const_iterator it = m_plugs.begin();1158 PlugConnectionOwnerVector connections; 1159 1160 for ( PlugVector::const_iterator it = m_plugs.begin(); 1930 1161 it != m_plugs.end(); 1931 1162 ++it ) 1932 1163 { 1933 AvPlug* plug = *it;1934 for ( AvPlugVector::const_iterator it =1164 Plug* plug = *it; 1165 for ( PlugVector::const_iterator it = 1935 1166 plug->getInputConnections().begin(); 1936 1167 it != plug->getInputConnections().end(); … … 1939 1170 addConnection( connections, *( *it ), *plug ); 1940 1171 } 1941 for ( AvPlugVector::const_iterator it =1172 for ( PlugVector::const_iterator it = 1942 1173 plug->getOutputConnections().begin(); 1943 1174 it != plug->getOutputConnections().end(); … … 1949 1180 1950 1181 printf( "digraph avcconnections {\n" ); 1951 for ( AvPlugConnectionOwnerVector::iterator it = connections.begin();1182 for ( PlugConnectionOwnerVector::iterator it = connections.begin(); 1952 1183 it != connections.end(); 1953 1184 ++it ) 1954 1185 { 1955 AvPlugConnection& con = *it;1186 PlugConnection& con = *it; 1956 1187 printf( "\t\"(%d) %s\" -> \"(%d) %s\"\n", 1957 1188 con.getSrcPlug().getGlobalId(), … … 1960 1191 con.getDestPlug().getName() ); 1961 1192 } 1962 for ( AvPlugVector::const_iterator it = m_plugs.begin();1193 for ( PlugVector::const_iterator it = m_plugs.begin(); 1963 1194 it != m_plugs.end(); 1964 1195 ++it ) 1965 1196 { 1966 AvPlug* plug = *it;1197 Plug* plug = *it; 1967 1198 if ( plug->getFunctionBlockType() != 0xff ) { 1968 1199 std::ostringstream strstrm; … … 1984 1215 } 1985 1216 1986 if ( plug->getPlugDirection() == AvPlug::eAPD_Input ) {1217 if ( plug->getPlugDirection() == Plug::eAPD_Input ) { 1987 1218 printf( "\t\"(%d) %s\" -> \"(%s, ID %d)\"\n", 1988 1219 plug->getGlobalId(), … … 2009 1240 }; 2010 1241 2011 for ( AvPlugVector::const_iterator it = m_plugs.begin();1242 for ( PlugVector::const_iterator it = m_plugs.begin(); 2012 1243 it != m_plugs.end(); 2013 1244 ++it ) 2014 1245 { 2015 AvPlug* plug = *it;1246 Plug* plug = *it; 2016 1247 printf( "\t\"(%d) %s\" [color=%s,style=filled];\n", 2017 1248 plug->getGlobalId(), plug->getName(), … … 2025 1256 debugOutput( DEBUG_LEVEL_VERBOSE, "Plug details\n" ); 2026 1257 debugOutput( DEBUG_LEVEL_VERBOSE, "------------\n" ); 2027 for ( AvPlugVector::const_iterator it = m_plugs.begin();1258 for ( PlugVector::const_iterator it = m_plugs.begin(); 2028 1259 it != m_plugs.end(); 2029 1260 ++it ) 2030 1261 { 2031 AvPlug* plug = *it;1262 Plug* plug = *it; 2032 1263 debugOutput( DEBUG_LEVEL_VERBOSE, "Plug %d:\n", plug->getGlobalId() ); 2033 1264 plug->showPlug(); … … 2036 1267 } 2037 1268 2038 AvPlug*2039 AvPlugManager::getPlug( ESubunitType subunitType,1269 Plug* 1270 PlugManager::getPlug( ESubunitType subunitType, 2040 1271 subunit_id_t subunitId, 2041 1272 function_block_type_t functionBlockType, 2042 1273 function_block_id_t functionBlockId, 2043 AvPlug::EAvPlugAddressType plugAddressType,2044 AvPlug::EAvPlugDirection plugDirection,1274 Plug::EPlugAddressType plugAddressType, 1275 Plug::EPlugDirection plugDirection, 2045 1276 plug_id_t plugId ) const 2046 1277 { … … 2055 1286 plugId ); 2056 1287 2057 for ( AvPlugVector::const_iterator it = m_plugs.begin();1288 for ( PlugVector::const_iterator it = m_plugs.begin(); 2058 1289 it != m_plugs.end(); 2059 1290 ++it ) 2060 1291 { 2061 AvPlug* plug = *it;1292 Plug* plug = *it; 2062 1293 2063 1294 if ( ( subunitType == plug->getSubunitType() ) … … 2076 1307 } 2077 1308 2078 AvPlug*2079 AvPlugManager::getPlug( int iGlobalId ) const2080 { 2081 for ( AvPlugVector::const_iterator it = m_plugs.begin();1309 Plug* 1310 PlugManager::getPlug( int iGlobalId ) const 1311 { 1312 for ( PlugVector::const_iterator it = m_plugs.begin(); 2082 1313 it != m_plugs.end(); 2083 1314 ++it ) 2084 1315 { 2085 AvPlug* pPlug = *it;1316 Plug* pPlug = *it; 2086 1317 if ( pPlug->getGlobalId() == iGlobalId ) { 2087 1318 return pPlug; … … 2092 1323 } 2093 1324 2094 AvPlugVector2095 AvPlugManager::getPlugsByType( ESubunitType subunitType,1325 PlugVector 1326 PlugManager::getPlugsByType( ESubunitType subunitType, 2096 1327 subunit_id_t subunitId, 2097 1328 function_block_type_t functionBlockType, 2098 1329 function_block_id_t functionBlockId, 2099 AvPlug::EAvPlugAddressType plugAddressType,2100 AvPlug::EAvPlugDirection plugDirection,2101 AvPlug::EAvPlugType type) const1330 Plug::EPlugAddressType plugAddressType, 1331 Plug::EPlugDirection plugDirection, 1332 Plug::EPlugType type) const 2102 1333 { 2103 1334 debugOutput( DEBUG_LEVEL_VERBOSE, "SBT, SBID, FBT, FBID, AT, PD, T = " … … 2111 1342 type ); 2112 1343 2113 AvPlugVector plugVector;2114 for ( AvPlugVector::const_iterator it = m_plugs.begin();1344 PlugVector plugVector; 1345 for ( PlugVector::const_iterator it = m_plugs.begin(); 2115 1346 it != m_plugs.end(); 2116 1347 ++it ) 2117 1348 { 2118 AvPlug* pPlug = *it;1349 Plug* pPlug = *it; 2119 1350 2120 1351 if ( ( subunitType == pPlug->getSubunitType() ) … … 2134 1365 2135 1366 bool 2136 AvPlugManager::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const1367 PlugManager::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 2137 1368 { 2138 1369 bool result = true; 2139 1370 int i = 0; 2140 for ( AvPlugVector::const_iterator it = m_plugs.begin();1371 for ( PlugVector::const_iterator it = m_plugs.begin(); 2141 1372 it != m_plugs.end(); 2142 1373 ++it ) 2143 1374 { 2144 AvPlug* pPlug = *it;1375 Plug* pPlug = *it; 2145 1376 std::ostringstream strstrm; 2146 1377 strstrm << basePath << i; … … 2152 1383 } 2153 1384 2154 AvPlugManager*2155 AvPlugManager::deserialize( Glib::ustring basePath,1385 PlugManager* 1386 PlugManager::deserialize( Glib::ustring basePath, 2156 1387 Util::IODeserialize& deser, 2157 AvDevice& avDevice)2158 2159 { 2160 AvPlugManager* pMgr = new AvPlugManager;1388 Unit& unit ) 1389 1390 { 1391 PlugManager* pMgr = new PlugManager; 2161 1392 2162 1393 if ( !pMgr ) { … … 2169 1400 std::ostringstream strstrm; 2170 1401 strstrm << basePath << i; 2171 // avDevicestill holds a null pointer for the plug manager1402 // unit still holds a null pointer for the plug manager 2172 1403 // therefore we have to *this as additional argument 2173 AvPlug* pPlug = AvPlug::deserialize( strstrm.str() + "/",1404 Plug* pPlug = Plug::deserialize( strstrm.str() + "/", 2174 1405 deser, 2175 avDevice,1406 unit, 2176 1407 *pMgr ); 2177 1408 if ( pPlug ) { … … 2189 1420 //////////////////////////////////// 2190 1421 2191 AvPlugConnection::AvPlugConnection( AvPlug& srcPlug, AvPlug& destPlug )1422 PlugConnection::PlugConnection( Plug& srcPlug, Plug& destPlug ) 2192 1423 : m_srcPlug( &srcPlug ) 2193 1424 , m_destPlug( &destPlug ) … … 2195 1426 } 2196 1427 2197 AvPlugConnection::AvPlugConnection()1428 PlugConnection::PlugConnection() 2198 1429 : m_srcPlug( 0 ) 2199 1430 , m_destPlug( 0 ) … … 2202 1433 2203 1434 bool 2204 AvPlugConnection::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const1435 PlugConnection::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 2205 1436 { 2206 1437 bool result; … … 2210 1441 } 2211 1442 2212 AvPlugConnection*2213 AvPlugConnection::deserialize( Glib::ustring basePath,1443 PlugConnection* 1444 PlugConnection::deserialize( Glib::ustring basePath, 2214 1445 Util::IODeserialize& deser, 2215 AvDevice& avDevice)2216 { 2217 AvPlugConnection* pConnection = new AvPlugConnection;1446 Unit& unit ) 1447 { 1448 PlugConnection* pConnection = new PlugConnection; 2218 1449 if ( !pConnection ) { 2219 1450 return 0; … … 2231 1462 } 2232 1463 2233 pConnection->m_srcPlug = avDevice.getPlugManager().getPlug( iSrcPlugId );2234 pConnection->m_destPlug = avDevice.getPlugManager().getPlug( iDestPlugId );1464 pConnection->m_srcPlug = unit.getPlugManager().getPlug( iSrcPlugId ); 1465 pConnection->m_destPlug = unit.getPlugManager().getPlug( iDestPlugId ); 2235 1466 2236 1467 if ( !pConnection->m_srcPlug || !pConnection->m_destPlug ) { branches/echoaudio/src/libavc/general/avc_plug.h
r505 r507 1 1 /* 2 * Copyright (C) 2007 by Pieter Palmers 2 3 * Copyright (C) 2005-2007 by Daniel Wagner 3 4 * … … 22 23 */ 23 24 24 #ifndef BEBOB_AVPLUG_H25 #define BEBOB_AVPLUG_H26 27 #include " libavc/ccm/avc_signal_source.h"28 #include " libavc/streamformat/avc_extended_stream_format.h"29 #include " libavc/general/avc_extended_plug_info.h"30 #include " libavc/general/avc_extended_cmd_generic.h"31 #include " libavc/avc_definitions.h"32 #include " libavc/general/avc_generic.h"25 #ifndef AVC_PLUG 26 #define AVC_PLUG 27 28 #include "../ccm/avc_signal_source.h" 29 #include "../streamformat/avc_extended_stream_format.h" 30 #include "avc_extended_plug_info.h" 31 #include "avc_extended_cmd_generic.h" 32 #include "../avc_definitions.h" 33 #include "avc_generic.h" 33 34 34 35 #include "libutil/serialize.h" … … 41 42 class ConfigRom; 42 43 43 namespace BeBoB { 44 45 class AvDevice; 46 class AvPlugManager; 47 class AvPlug; 48 49 typedef std::vector<AvPlug*> AvPlugVector; 50 51 class AvPlug { 44 namespace AVC { 45 46 class Unit; 47 class Subunit; 48 class PlugManager; 49 class Plug; 50 51 typedef std::vector<Plug*> PlugVector; 52 53 class Plug { 52 54 public: 53 55 54 enum E AvPlugAddressType {55 eAPA_PCR,56 eAPA_ExternalPlug,57 eAPA_AsynchronousPlug,58 eAPA_SubunitPlug,59 eAPA_FunctionBlockPlug,60 eAPA_Undefined,61 }; 62 63 enum E AvPlugType {56 enum EPlugAddressType { 57 eAPA_PCR, 58 eAPA_ExternalPlug, 59 eAPA_AsynchronousPlug, 60 eAPA_SubunitPlug, 61 eAPA_FunctionBlockPlug, 62 eAPA_Undefined, 63 }; 64 65 enum EPlugType { 64 66 eAPT_IsoStream, 65 67 eAPT_AsyncStream, … … 71 73 }; 72 74 73 enum E AvPlugDirection {74 eAPD_Input,75 eAPD_Output,76 eAPD_Unknown,75 enum EPlugDirection { 76 eAPD_Input, 77 eAPD_Output, 78 eAPD_Unknown, 77 79 }; 78 80 79 81 // \todo This constructors sucks. too many parameters. fix it. 80 AvPlug( Ieee1394Service& ieee1394Service, 81 ConfigRom& configRom, 82 AvPlugManager& plugManager, 83 AVC::ESubunitType subunitType, 84 AVC::subunit_id_t subunitId, 85 AVC::function_block_type_t functionBlockType, 86 AVC::function_block_type_t functionBlockId, 87 EAvPlugAddressType plugAddressType, 88 EAvPlugDirection plugDirection, 89 AVC::plug_id_t plugId, 90 int verboseLevel ); 91 AvPlug( const AvPlug& rhs ); 92 virtual ~AvPlug(); 93 94 bool discover(); 95 bool discoverConnections(); 96 97 bool inquireConnnection( AvPlug& plug ); 98 bool setConnection( AvPlug& plug ); 82 Plug( Unit* unit, 83 Subunit* subunit, 84 function_block_type_t functionBlockType, 85 function_block_type_t functionBlockId, 86 EPlugAddressType plugAddressType, 87 EPlugDirection plugDirection, 88 plug_id_t plugId ); 89 Plug( const Plug& rhs ); 90 virtual ~Plug(); 91 92 virtual bool discover() 93 {//FIXME: 94 #warning FIXME 95 };; 96 virtual bool discoverConnections() 97 {//FIXME: 98 #warning FIXME 99 };; 100 101 bool inquireConnnection( Plug& plug ); 102 bool setConnection( Plug& plug ); 99 103 100 104 int getGlobalId() const 101 105 { return m_globalId; } 102 AVC::plug_id_t getPlugId() const106 plug_id_t getPlugId() const 103 107 { return m_id; } 104 AVC::ESubunitType getSubunitType() const 105 { return m_subunitType; } 106 AVC::subunit_id_t getSubunitId() const 107 { return m_subunitId; } 108 ESubunitType getSubunitType() const; 109 subunit_id_t getSubunitId() const; 110 108 111 const char* getName() const 109 112 { return m_name.c_str(); } 110 E AvPlugDirection getPlugDirection() const113 EPlugDirection getPlugDirection() const 111 114 { return m_direction; } 112 AVC::sampling_frequency_t getSamplingFrequency() const115 sampling_frequency_t getSamplingFrequency() const 113 116 { return m_samplingFrequency; } 114 117 int getSampleRate() const; // 22050, 24000, 32000, ... … … 116 119 int getNrOfStreams() const; 117 120 118 E AvPlugDirection getDirection() const121 EPlugDirection getDirection() const 119 122 { return m_direction; } 120 E AvPlugAddressType getPlugAddressType() const123 EPlugAddressType getPlugAddressType() const 121 124 { return m_addressType; } 122 E AvPlugType getPlugType() const125 EPlugType getPlugType() const 123 126 { return m_infoPlugType; } 124 127 125 AVC::function_block_type_t getFunctionBlockType() const128 function_block_type_t getFunctionBlockType() const 126 129 { return m_functionBlockType; } 127 AVC::function_block_id_t getFunctionBlockId() const130 function_block_id_t getFunctionBlockId() const 128 131 { return m_functionBlockId; } 129 132 130 const AvPlugVector& getInputConnections() const133 const PlugVector& getInputConnections() const 131 134 { return m_inputConnections; } 132 const AvPlugVector& getOutputConnections() const135 const PlugVector& getOutputConnections() const 133 136 { return m_outputConnections; } 134 137 135 static AVC::PlugAddress::EPlugDirection convertPlugDirection(136 E AvPlugDirection direction);138 static PlugAddress::EPlugDirection convertPlugDirection( 139 EPlugDirection direction); 137 140 138 141 void showPlug() const; 139 142 140 143 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 141 static AvPlug* deserialize( Glib::ustring basePath,144 static Plug* deserialize( Glib::ustring basePath, 142 145 Util::IODeserialize& deser, 143 AvDevice& avDevice,144 AvPlugManager& plugManager );146 Unit& avDevice, 147 PlugManager& plugManager ); 145 148 146 149 bool deserializeUpdate( Glib::ustring basePath, … … 149 152 public: 150 153 struct ChannelInfo { 151 AVC::stream_position_t m_streamPosition;152 AVC::stream_position_location_t m_location;153 Glib::ustring 154 stream_position_t m_streamPosition; 155 stream_position_location_t m_location; 156 Glib::ustring m_name; 154 157 }; 155 158 typedef std::vector<ChannelInfo> ChannelInfoVector; 156 159 157 160 struct ClusterInfo { 158 int 159 AVC::port_type_t m_portType;160 Glib::ustring 161 162 AVC::nr_of_channels_t m_nrOfChannels;163 ChannelInfoVector 164 AVC::stream_format_t m_streamFormat;161 int m_index; 162 port_type_t m_portType; 163 Glib::ustring m_name; 164 165 nr_of_channels_t m_nrOfChannels; 166 ChannelInfoVector m_channelInfos; 167 stream_format_t m_streamFormat; 165 168 }; 166 169 typedef std::vector<ClusterInfo> ClusterInfoVector; … … 170 173 171 174 protected: 172 AvPlug(); 173 174 bool discoverPlugType(); 175 bool discoverName(); 176 bool discoverNoOfChannels(); 177 bool discoverChannelPosition(); 178 bool discoverChannelName(); 179 bool discoverClusterInfo(); 180 bool discoverStreamFormat(); 181 bool discoverSupportedStreamFormats(); 182 bool discoverConnectionsInput(); 183 bool discoverConnectionsOutput(); 184 185 AVC::ExtendedPlugInfoCmd setPlugAddrToPlugInfoCmd(); 186 187 AVC::ExtendedStreamFormatCmd setPlugAddrToStreamFormatCmd( 188 AVC::ExtendedStreamFormatCmd::ESubFunction subFunction); 189 190 AVC::SignalSourceCmd setSrcPlugAddrToSignalCmd(); 175 Plug(); 176 177 SignalSourceCmd setSrcPlugAddrToSignalCmd(); 191 178 192 179 void setDestPlugAddrToSignalCmd( 193 AVC::SignalSourceCmd& signalSourceCmd, AvPlug& plug );180 SignalSourceCmd& signalSourceCmd, Plug& plug ); 194 181 195 182 void debugOutputClusterInfos( int debugLevel ); 196 183 197 bool copyClusterInfo( AVC::ExtendedPlugInfoPlugChannelPositionSpecificData&184 bool copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData& 198 185 channelPositionData ); 199 186 200 bool addPlugConnection( AvPlugVector& connections, AvPlug& plug );187 bool addPlugConnection( PlugVector& connections, Plug& plug ); 201 188 202 189 bool discoverConnectionsFromSpecificData( 203 E AvPlugDirection discoverDirection,204 AVC::PlugAddressSpecificData* plugAddress,205 AvPlugVector& connections );206 207 AvPlug* getPlugDefinedBySpecificData(208 AVC::UnitPlugSpecificDataPlugAddress* pUnitPlugAddress,209 AVC::SubunitPlugSpecificDataPlugAddress* pSubunitPlugAddress,210 AVC::FunctionBlockPlugSpecificDataPlugAddress* pFunctionBlockPlugAddress );211 212 E AvPlugDirection toggleDirection( EAvPlugDirection direction ) const;190 EPlugDirection discoverDirection, 191 PlugAddressSpecificData* plugAddress, 192 PlugVector& connections ); 193 194 Plug* getPlugDefinedBySpecificData( 195 UnitPlugSpecificDataPlugAddress* pUnitPlugAddress, 196 SubunitPlugSpecificDataPlugAddress* pSubunitPlugAddress, 197 FunctionBlockPlugSpecificDataPlugAddress* pFunctionBlockPlugAddress ); 198 199 EPlugDirection toggleDirection( EPlugDirection direction ) const; 213 200 214 201 const ClusterInfo* getClusterInfoByIndex( int index ) const; … … 231 218 Util::IODeserialize& deser ); 232 219 233 bool serialize AvPlugVector( Glib::ustring basePath,220 bool serializePlugVector( Glib::ustring basePath, 234 221 Util::IOSerialize& ser, 235 const AvPlugVector& vec) const;236 bool deserialize AvPlugVector( Glib::ustring basePath,222 const PlugVector& vec) const; 223 bool deserializePlugVector( Glib::ustring basePath, 237 224 Util::IODeserialize& deser, 238 AvPlugVector& vec );239 240 pr ivate:225 PlugVector& vec ); 226 227 protected: 241 228 // Supported stream formats 242 229 struct FormatInfo { 243 230 FormatInfo() 244 : m_samplingFrequency( AVC::eSF_DontCare )231 : m_samplingFrequency( eSF_DontCare ) 245 232 , m_isSyncStream( false ) 246 233 , m_audioChannels( 0 ) … … 248 235 , m_index( 0xff ) 249 236 {} 250 AVC::sampling_frequency_t m_samplingFrequency;251 bool m_isSyncStream;252 AVC::number_of_channels_t m_audioChannels;253 AVC::number_of_channels_t m_midiChannels;254 byte_t m_index;237 sampling_frequency_t m_samplingFrequency; 238 bool m_isSyncStream; 239 number_of_channels_t m_audioChannels; 240 number_of_channels_t m_midiChannels; 241 byte_t m_index; 255 242 }; 256 243 typedef std::vector<FormatInfo> FormatInfoVector; 257 244 258 245 259 Ieee1394Service* m_p1394Service; 260 ConfigRom* m_pConfigRom; 261 AVC::ESubunitType m_subunitType; 262 AVC::subunit_id_t m_subunitId; 263 AVC::function_block_type_t m_functionBlockType; 264 AVC::function_block_id_t m_functionBlockId; 265 EAvPlugAddressType m_addressType; 266 EAvPlugDirection m_direction; 267 AVC::plug_id_t m_id; 268 EAvPlugType m_infoPlugType; 269 AVC::nr_of_channels_t m_nrOfChannels; 270 Glib::ustring m_name; 271 ClusterInfoVector m_clusterInfos; 272 AVC::sampling_frequency_t m_samplingFrequency; 273 FormatInfoVector m_formatInfos; 274 AvPlugVector m_inputConnections; 275 AvPlugVector m_outputConnections; 276 AvPlugManager* m_plugManager; 277 int m_verboseLevel; 278 int m_globalId; 279 static int m_globalIdCounter; 246 Unit* m_unit; 247 Subunit* m_subunit; 248 function_block_type_t m_functionBlockType; 249 function_block_id_t m_functionBlockId; 250 EPlugAddressType m_addressType; 251 EPlugDirection m_direction; 252 plug_id_t m_id; 253 EPlugType m_infoPlugType; 254 nr_of_channels_t m_nrOfChannels; 255 Glib::ustring m_name; 256 ClusterInfoVector m_clusterInfos; 257 sampling_frequency_t m_samplingFrequency; 258 FormatInfoVector m_formatInfos; 259 PlugVector m_inputConnections; 260 PlugVector m_outputConnections; 261 int m_globalId; 262 static int m_globalIdCounter; 280 263 281 264 DECLARE_DEBUG_MODULE; 282 265 }; 283 266 284 const char* avPlugAddressTypeToString( AvPlug::EAvPlugAddressType addressType );285 const char* avPlugTypeToString( AvPlug::EAvPlugType type );286 const char* avPlugDirectionToString( AvPlug::EAvPlugDirection direction );287 288 class AvPlugManager267 const char* avPlugAddressTypeToString( Plug::EPlugAddressType addressType ); 268 const char* avPlugTypeToString( Plug::EPlugType type ); 269 const char* avPlugDirectionToString( Plug::EPlugDirection direction ); 270 271 class PlugManager 289 272 { 290 273 public: 291 AvPlugManager( int verboseLevel);292 AvPlugManager( const AvPlugManager& rhs );293 ~ AvPlugManager();294 295 bool addPlug( AvPlug& plug );296 bool remPlug( AvPlug& plug );274 PlugManager( ); 275 PlugManager( const PlugManager& rhs ); 276 ~PlugManager(); 277 278 bool addPlug( Plug& plug ); 279 bool remPlug( Plug& plug ); 297 280 298 281 void showPlugs() const; 299 282 300 AvPlug* getPlug( AVC::ESubunitType subunitType,301 AVC::subunit_id_t subunitId,302 AVC::function_block_type_t functionBlockType,303 AVC::function_block_id_t functionBlockId,304 AvPlug::EAvPlugAddressType plugAddressType,305 AvPlug::EAvPlugDirection plugDirection,306 AVC::plug_id_t plugId ) const;307 AvPlug* getPlug( int iGlobalId ) const;308 AvPlugVector getPlugsByType( AVC::ESubunitType subunitType,309 AVC::subunit_id_t subunitId,310 AVC::function_block_type_t functionBlockType,311 AVC::function_block_id_t functionBlockId,312 AvPlug::EAvPlugAddressType plugAddressType,313 AvPlug::EAvPlugDirection plugDirection,314 AvPlug::EAvPlugType type) const;283 Plug* getPlug( ESubunitType subunitType, 284 subunit_id_t subunitId, 285 function_block_type_t functionBlockType, 286 function_block_id_t functionBlockId, 287 Plug::EPlugAddressType plugAddressType, 288 Plug::EPlugDirection plugDirection, 289 plug_id_t plugId ) const; 290 Plug* getPlug( int iGlobalId ) const; 291 PlugVector getPlugsByType( ESubunitType subunitType, 292 subunit_id_t subunitId, 293 function_block_type_t functionBlockType, 294 function_block_id_t functionBlockId, 295 Plug::EPlugAddressType plugAddressType, 296 Plug::EPlugDirection plugDirection, 297 Plug::EPlugType type) const; 315 298 316 299 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 317 static AvPlugManager* deserialize( Glib::ustring basePath,300 static PlugManager* deserialize( Glib::ustring basePath, 318 301 Util::IODeserialize& deser, 319 AvDevice& avDevice ); 320 302 Unit& avDevice ); 303 void setVerboseLevel( int i ) 304 {setDebugLevel(i);}; 321 305 private: 322 AvPlugManager(); 323 324 int m_verboseLevel; 325 AvPlugVector m_plugs; 306 307 PlugVector m_plugs; 326 308 327 309 DECLARE_DEBUG_MODULE; 328 310 }; 329 311 330 class AvPlugConnection {312 class PlugConnection { 331 313 public: 332 AvPlugConnection( AvPlug& srcPlug, AvPlug& destPlug );333 334 AvPlug& getSrcPlug() const314 PlugConnection( Plug& srcPlug, Plug& destPlug ); 315 316 Plug& getSrcPlug() const 335 317 { return *m_srcPlug; } 336 AvPlug& getDestPlug() const318 Plug& getDestPlug() const 337 319 { return *m_destPlug; } 338 320 339 321 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 340 static AvPlugConnection* deserialize( Glib::ustring basePath,322 static PlugConnection* deserialize( Glib::ustring basePath, 341 323 Util::IODeserialize& deser, 342 AvDevice& avDevice );324 Unit& avDevice ); 343 325 private: 344 AvPlugConnection();326 PlugConnection(); 345 327 346 328 private: 347 AvPlug* m_srcPlug;348 AvPlug* m_destPlug;329 Plug* m_srcPlug; 330 Plug* m_destPlug; 349 331 }; 350 332 351 typedef std::vector< AvPlugConnection*> AvPlugConnectionVector;352 typedef std::vector< AvPlugConnection> AvPlugConnectionOwnerVector;333 typedef std::vector<PlugConnection*> PlugConnectionVector; 334 typedef std::vector<PlugConnection> PlugConnectionOwnerVector; 353 335 354 336 } 355 337 356 #endif // BEBOB_AVPLUG_H338 #endif // AVC_PLUG branches/echoaudio/src/libavc/general/avc_subunit.cpp
r503 r507 22 22 */ 23 23 24 #include "bebob/bebob_functionblock.h" 25 #include " bebob/bebob_avdevice_subunit.h"26 #include " bebob/bebob_avdevice.h"24 25 #include "avc_subunit.h" 26 #include "avc_unit.h" 27 27 #include "bebob/bebob_avplug.h" 28 28 #include "libieee1394/configrom.h" 29 29 30 #include " libavc/general/avc_plug_info.h"31 #include " libavc/streamformat/avc_extended_stream_format.h"32 #include " libavc/util/avc_serialize.h"30 #include "../general/avc_plug_info.h" 31 #include "../streamformat/avc_extended_stream_format.h" 32 #include "../util/avc_serialize.h" 33 33 34 34 #include <sstream> 35 35 36 using namespace AVC; 37 38 IMPL_DEBUG_MODULE( BeBoB::AvDeviceSubunit, BeBoB::AvDeviceSubunit, DEBUG_LEVEL_VERBOSE );36 namespace AVC { 37 38 IMPL_DEBUG_MODULE( Subunit, Subunit, DEBUG_LEVEL_VERBOSE ); 39 39 40 40 //////////////////////////////////////////// 41 41 42 BeBoB::AvDeviceSubunit::AvDeviceSubunit( AvDevice& avDevice, 43 ESubunitType type, 44 subunit_t id, 45 int verboseLevel ) 46 : m_avDevice( &avDevice ) 42 Subunit::Subunit( Unit& unit, 43 ESubunitType type, 44 subunit_t id ) 45 : m_unit( &unit ) 47 46 , m_sbType( type ) 48 47 , m_sbId( id ) 49 , m_verboseLevel( verboseLevel ) 50 { 51 setDebugLevel( m_verboseLevel ); 52 } 53 54 BeBoB::AvDeviceSubunit::AvDeviceSubunit() 55 { 56 } 57 58 BeBoB::AvDeviceSubunit::~AvDeviceSubunit() 59 { 60 for ( AvPlugVector::iterator it = m_plugs.begin(); 48 { 49 50 } 51 52 Subunit::Subunit() 53 { 54 } 55 56 Subunit::~Subunit() 57 { 58 for ( PlugVector::iterator it = m_plugs.begin(); 61 59 it != m_plugs.end(); 62 60 ++it ) … … 67 65 68 66 bool 69 BeBoB::AvDeviceSubunit::discover() 70 { 71 if ( !discoverPlugs() ) { 72 debugError( "plug discovering failed\n" ); 73 return false; 74 } 75 67 Subunit::discover() 68 { 69 // There is nothing we can discover for a generic subunit 70 // Maybe its plugs, but there are multiple ways of doing that. 76 71 return true; 77 72 } 78 73 79 74 bool 80 BeBoB::AvDeviceSubunit::discoverPlugs() 81 { 82 PlugInfoCmd plugInfoCmd( m_avDevice->get1394Service(), 83 PlugInfoCmd::eSF_SerialBusIsochronousAndExternalPlug ); 84 plugInfoCmd.setNodeId( m_avDevice->getConfigRom().getNodeId() ); 85 plugInfoCmd.setCommandType( AVCCommand::eCT_Status ); 86 plugInfoCmd.setSubunitType( m_sbType ); 87 plugInfoCmd.setSubunitId( m_sbId ); 88 plugInfoCmd.setVerbose( m_verboseLevel ); 89 90 if ( !plugInfoCmd.fire() ) { 91 debugError( "plug info command failed\n" ); 92 return false; 93 } 94 95 debugOutput( DEBUG_LEVEL_NORMAL, "number of source plugs = %d\n", 96 plugInfoCmd.m_sourcePlugs ); 97 debugOutput( DEBUG_LEVEL_NORMAL, "number of destination output " 98 "plugs = %d\n", plugInfoCmd.m_destinationPlugs ); 99 100 if ( !discoverPlugs( AvPlug::eAPD_Input, 101 plugInfoCmd.m_destinationPlugs ) ) 102 { 103 debugError( "destination plug discovering failed\n" ); 104 return false; 105 } 106 107 if ( !discoverPlugs( AvPlug::eAPD_Output, 108 plugInfoCmd.m_sourcePlugs ) ) 109 { 110 debugError( "source plug discovering failed\n" ); 111 return false; 112 } 113 75 Subunit::addPlug( Plug& plug ) 76 { 77 m_plugs.push_back( &plug ); 114 78 return true; 115 79 } 116 80 117 bool 118 BeBoB::AvDeviceSubunit::discoverConnections() 119 { 120 for ( AvPlugVector::iterator it = m_plugs.begin(); 81 82 Plug* 83 Subunit::getPlug(Plug::EPlugDirection direction, plug_id_t plugId) 84 { 85 for ( PlugVector::iterator it = m_plugs.begin(); 121 86 it != m_plugs.end(); 122 87 ++it ) 123 88 { 124 AvPlug* plug = *it; 125 if ( !plug->discoverConnections() ) { 126 debugError( "plug connection discovering failed ('%s')\n", 127 plug->getName() ); 128 return false; 129 } 130 } 131 132 return true; 133 } 134 135 bool 136 BeBoB::AvDeviceSubunit::discoverPlugs(AvPlug::EAvPlugDirection plugDirection, 137 plug_id_t plugMaxId ) 138 { 139 for ( int plugIdx = 0; 140 plugIdx < plugMaxId; 141 ++plugIdx ) 142 { 143 ESubunitType subunitType = 144 static_cast<ESubunitType>( getSubunitType() ); 145 AvPlug* plug = new AvPlug( m_avDevice->get1394Service(), 146 m_avDevice->getConfigRom(), 147 m_avDevice->getPlugManager(), 148 subunitType, 149 getSubunitId(), 150 0xff, 151 0xff, 152 AvPlug::eAPA_SubunitPlug, 153 plugDirection, 154 plugIdx, 155 m_verboseLevel ); 156 if ( !plug || !plug->discover() ) { 157 debugError( "plug discover failed\n" ); 158 return false; 159 } 160 161 debugOutput( DEBUG_LEVEL_NORMAL, "plug '%s' found\n", 162 plug->getName() ); 163 m_plugs.push_back( plug ); 164 } 165 return true; 166 } 167 168 bool 169 BeBoB::AvDeviceSubunit::addPlug( AvPlug& plug ) 170 { 171 m_plugs.push_back( &plug ); 172 return true; 173 } 174 175 176 BeBoB::AvPlug* 177 BeBoB::AvDeviceSubunit::getPlug(AvPlug::EAvPlugDirection direction, plug_id_t plugId) 178 { 179 for ( AvPlugVector::iterator it = m_plugs.begin(); 180 it != m_plugs.end(); 181 ++it ) 182 { 183 AvPlug* plug = *it; 89 Plug* plug = *it; 184 90 if ( ( plug->getPlugId() == plugId ) 185 91 && ( plug->getDirection() == direction ) ) … … 191 97 } 192 98 193 194 bool 195 BeBoB::AvDeviceSubunit::serialize( Glib::ustring basePath, 99 bool 100 Subunit::serialize( Glib::ustring basePath, 196 101 Util::IOSerialize& ser ) const 197 102 { … … 200 105 result = ser.write( basePath + "m_sbType", m_sbType ); 201 106 result &= ser.write( basePath + "m_sbId", m_sbId ); 202 result &= ser.write( basePath + "m_verboseLevel", m_verboseLevel);107 result &= ser.write( basePath + "m_verboseLevel", getDebugLevel() ); 203 108 result &= serializeChild( basePath, ser ); 204 109 … … 206 111 } 207 112 208 BeBoB::AvDeviceSubunit*209 BeBoB::AvDeviceSubunit::deserialize( Glib::ustring basePath,113 Subunit* 114 Subunit::deserialize( Glib::ustring basePath, 210 115 Util::IODeserialize& deser, 211 AvDevice& avDevice)116 Unit& unit ) 212 117 { 213 118 bool result; … … 215 120 result = deser.read( basePath + "m_sbType", sbType ); 216 121 217 AvDeviceSubunit* pSubunit = 0;122 Subunit* pSubunit = 0; 218 123 switch( sbType ) { 219 124 case eST_Audio: 220 pSubunit = new AvDeviceSubunitAudio;125 pSubunit = new SubunitAudio; 221 126 break; 222 127 case eST_Music: 223 pSubunit = new AvDeviceSubunitMusic;128 pSubunit = new SubunitMusic; 224 129 break; 225 130 default: … … 231 136 } 232 137 233 pSubunit->m_ avDevice = &avDevice;138 pSubunit->m_unit = &unit; 234 139 pSubunit->m_sbType = sbType; 235 140 result &= deser.read( basePath + "m_sbId", pSubunit->m_sbId ); 236 result &= deser.read( basePath + "m_verboseLevel", pSubunit->m_verboseLevel ); 237 result &= pSubunit->deserializeChild( basePath, deser, avDevice ); 141 int verboseLevel; 142 result &= deser.read( basePath + "m_verboseLevel", verboseLevel ); 143 setDebugLevel(verboseLevel); 144 result &= pSubunit->deserializeChild( basePath, deser, unit ); 238 145 239 146 if ( !result ) { … … 247 154 //////////////////////////////////////////// 248 155 249 BeBoB::AvDeviceSubunitAudio::AvDeviceSubunitAudio( AvDevice& avDevice, 250 subunit_t id, 251 int verboseLevel ) 252 : AvDeviceSubunit( avDevice, eST_Audio, id, verboseLevel ) 253 { 254 } 255 256 BeBoB::AvDeviceSubunitAudio::AvDeviceSubunitAudio() 257 : AvDeviceSubunit() 258 { 259 } 260 261 BeBoB::AvDeviceSubunitAudio::~AvDeviceSubunitAudio() 262 { 263 for ( FunctionBlockVector::iterator it = m_functions.begin(); 156 SubunitAudio::SubunitAudio( Unit& unit, subunit_t id ) 157 : Subunit( unit, eST_Audio, id ) 158 { 159 } 160 161 SubunitAudio::SubunitAudio() 162 : Subunit() 163 { 164 } 165 166 SubunitAudio::~SubunitAudio() 167 { 168 for ( BeBoB::FunctionBlockVector::iterator it = m_functions.begin(); 264 169 it != m_functions.end(); 265 170 ++it ) … … 270 175 271 176 bool 272 BeBoB::AvDeviceSubunitAudio::discover()177 SubunitAudio::discover() 273 178 { 274 179 debugOutput(DEBUG_LEVEL_NORMAL, "Discovering Audio Subunit...\n"); 275 180 276 if ( ! AvDeviceSubunit::discover() ) {181 if ( !Subunit::discover() ) { 277 182 return false; 278 183 } 279 184 280 if ( !discoverFunctionBlocks() ) {281 debugError( "function block discovering failed\n" );282 return false;283 }185 // if ( !discoverBeBoB::FunctionBlocks() ) { 186 // debugError( "function block discovering failed\n" ); 187 // return false; 188 // } 284 189 285 190 return true; 286 191 } 287 192 288 bool 289 BeBoB::AvDeviceSubunitAudio::discoverConnections() 290 { 291 debugOutput(DEBUG_LEVEL_NORMAL, "Discovering connections...\n"); 292 if ( !AvDeviceSubunit::discoverConnections() ) { 293 return false; 294 } 295 296 for ( FunctionBlockVector::iterator it = m_functions.begin(); 193 194 const char* 195 SubunitAudio::getName() 196 { 197 return "AudioSubunit"; 198 } 199 200 // bool 201 // SubunitAudio::discoverConnections() 202 // { 203 // debugOutput(DEBUG_LEVEL_NORMAL, "Discovering connections...\n"); 204 // if ( !Subunit::discoverConnections() ) { 205 // return false; 206 // } 207 // 208 // for ( BeBoB::FunctionBlockVector::iterator it = m_functions.begin(); 209 // it != m_functions.end(); 210 // ++it ) 211 // { 212 // BeBoB::FunctionBlock* function = *it; 213 // if ( !function->discoverConnections() ) { 214 // debugError( "functionblock connection discovering failed ('%s')\n", 215 // function->getName() ); 216 // return false; 217 // } 218 // } 219 // 220 // return true; 221 // } 222 // bool 223 // SubunitAudio::discoverBeBoB::FunctionBlocks() 224 // { 225 // debugOutput( DEBUG_LEVEL_NORMAL, 226 // "Discovering function blocks...\n"); 227 // 228 // if ( !discoverBeBoB::FunctionBlocksDo( 229 // ExtendedSubunitInfoCmd::eFBT_AudioSubunitSelector) ) 230 // { 231 // debugError( "Could not discover function block selector\n" ); 232 // return false; 233 // } 234 // if ( !discoverBeBoB::FunctionBlocksDo( 235 // ExtendedSubunitInfoCmd::eFBT_AudioSubunitFeature) ) 236 // { 237 // debugError( "Could not discover function block feature\n" ); 238 // return false; 239 // } 240 // if ( !discoverBeBoB::FunctionBlocksDo( 241 // ExtendedSubunitInfoCmd::eFBT_AudioSubunitProcessing) ) 242 // { 243 // debugError( "Could not discover function block processing\n" ); 244 // return false; 245 // } 246 // if ( !discoverBeBoB::FunctionBlocksDo( 247 // ExtendedSubunitInfoCmd::eFBT_AudioSubunitCodec) ) 248 // { 249 // debugError( "Could not discover function block codec\n" ); 250 // return false; 251 // } 252 // 253 // // print a function block list 254 // #ifdef DEBUG 255 // if (getDebugLevel() >= DEBUG_LEVEL_NORMAL) { 256 // 257 // for ( BeBoB::FunctionBlockVector::iterator it = m_functions.begin(); 258 // it != m_functions.end(); 259 // ++it ) 260 // { 261 // debugOutput(DEBUG_LEVEL_NORMAL, "%20s FB, type 0x%X, id=%d\n", 262 // (*it)->getName(), 263 // (*it)->getType(), 264 // (*it)->getId()); 265 // } 266 // } 267 // #endif 268 // 269 // return true; 270 // } 271 // 272 // bool 273 // SubunitAudio::discoverBeBoB::FunctionBlocksDo( 274 // ExtendedSubunitInfoCmd::EBeBoB::FunctionBlockType fbType ) 275 // { 276 // int page = 0; 277 // bool cmdSuccess = false; 278 // bool finished = false; 279 // 280 // do { 281 // ExtendedSubunitInfoCmd 282 // extSubunitInfoCmd( m_unit->get1394Service() ); 283 // extSubunitInfoCmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 284 // extSubunitInfoCmd.setCommandType( AVCCommand::eCT_Status ); 285 // extSubunitInfoCmd.setSubunitId( getSubunitId() ); 286 // extSubunitInfoCmd.setSubunitType( getSubunitType() ); 287 // extSubunitInfoCmd.setVerbose( m_verboseLevel ); 288 // 289 // extSubunitInfoCmd.m_fbType = fbType; 290 // extSubunitInfoCmd.m_page = page; 291 // 292 // cmdSuccess = extSubunitInfoCmd.fire(); 293 // if ( cmdSuccess 294 // && ( extSubunitInfoCmd.getResponse() 295 // == AVCCommand::eR_Implemented ) ) 296 // { 297 // for ( ExtendedSubunitInfoPageDataVector::iterator it = 298 // extSubunitInfoCmd.m_infoPageDatas.begin(); 299 // cmdSuccess 300 // && ( it != extSubunitInfoCmd.m_infoPageDatas.end() ); 301 // ++it ) 302 // { 303 // cmdSuccess = createBeBoB::FunctionBlock( fbType, **it ); 304 // } 305 // if ( ( extSubunitInfoCmd.m_infoPageDatas.size() != 0 ) 306 // && ( extSubunitInfoCmd.m_infoPageDatas.size() == 5 ) ) 307 // { 308 // page++; 309 // } else { 310 // finished = true; 311 // } 312 // } else { 313 // finished = true; 314 // } 315 // } while ( cmdSuccess && !finished ); 316 // 317 // return cmdSuccess; 318 // } 319 // 320 // bool 321 // SubunitAudio::createBeBoB::FunctionBlock( 322 // ExtendedSubunitInfoCmd::EBeBoB::FunctionBlockType fbType, 323 // ExtendedSubunitInfoPageData& data ) 324 // { 325 // BeBoB::FunctionBlock::ESpecialPurpose purpose 326 // = convertSpecialPurpose( data.m_functionBlockSpecialPupose ); 327 // 328 // BeBoB::FunctionBlock* fb = 0; 329 // 330 // switch ( fbType ) { 331 // case ExtendedSubunitInfoCmd::eFBT_AudioSubunitSelector: 332 // { 333 // fb = new BeBoB::FunctionBlockSelector( *this, 334 // data.m_functionBlockId, 335 // purpose, 336 // data.m_noOfInputPlugs, 337 // data.m_noOfOutputPlugs, 338 // m_verboseLevel ); 339 // } 340 // break; 341 // case ExtendedSubunitInfoCmd::eFBT_AudioSubunitFeature: 342 // { 343 // fb = new BeBoB::FunctionBlockFeature( *this, 344 // data.m_functionBlockId, 345 // purpose, 346 // data.m_noOfInputPlugs, 347 // data.m_noOfOutputPlugs, 348 // m_verboseLevel ); 349 // } 350 // break; 351 // case ExtendedSubunitInfoCmd::eFBT_AudioSubunitProcessing: 352 // { 353 // switch ( data.m_functionBlockType ) { 354 // case ExtendedSubunitInfoCmd::ePT_EnhancedMixer: 355 // { 356 // fb = new BeBoB::FunctionBlockEnhancedMixer( *this, 357 // data.m_functionBlockId, 358 // purpose, 359 // data.m_noOfInputPlugs, 360 // data.m_noOfOutputPlugs, 361 // m_verboseLevel ); 362 // } 363 // break; 364 // case ExtendedSubunitInfoCmd::ePT_Mixer: 365 // case ExtendedSubunitInfoCmd::ePT_Generic: 366 // case ExtendedSubunitInfoCmd::ePT_UpDown: 367 // case ExtendedSubunitInfoCmd::ePT_DolbyProLogic: 368 // case ExtendedSubunitInfoCmd::ePT_3DStereoExtender: 369 // case ExtendedSubunitInfoCmd::ePT_Reverberation: 370 // case ExtendedSubunitInfoCmd::ePT_Chorus: 371 // case ExtendedSubunitInfoCmd::ePT_DynamicRangeCompression: 372 // default: 373 // fb = new BeBoB::FunctionBlockProcessing( *this, 374 // data.m_functionBlockId, 375 // purpose, 376 // data.m_noOfInputPlugs, 377 // data.m_noOfOutputPlugs, 378 // m_verboseLevel ); 379 // debugWarning( "Dummy function block processing created. " 380 // "Implementation is missing\n" ); 381 // } 382 // } 383 // break; 384 // case ExtendedSubunitInfoCmd::eFBT_AudioSubunitCodec: 385 // { 386 // fb = new BeBoB::FunctionBlockCodec( *this, 387 // data.m_functionBlockId, 388 // purpose, 389 // data.m_noOfInputPlugs, 390 // data.m_noOfOutputPlugs, 391 // m_verboseLevel ); 392 // debugWarning( "Dummy function block codec created. " 393 // "Implementation is missing\n" ); 394 // } 395 // break; 396 // default: 397 // debugError( "Unhandled function block type found\n" ); 398 // return false; 399 // } 400 // 401 // if ( !fb ) { 402 // debugError( "Could create function block\n" ); 403 // return false; 404 // } 405 // if ( !fb->discover() ) { 406 // debugError( "Could not discover function block %s\n", 407 // fb->getName() ); 408 // delete fb; 409 // return false; 410 // } 411 // m_functions.push_back( fb ); 412 // 413 // return true; 414 // } 415 // 416 // BeBoB::FunctionBlock::ESpecialPurpose 417 // SubunitAudio::convertSpecialPurpose( 418 // function_block_special_purpose_t specialPurpose ) 419 // { 420 // BeBoB::FunctionBlock::ESpecialPurpose p; 421 // switch ( specialPurpose ) { 422 // case ExtendedSubunitInfoPageData::eSP_InputGain: 423 // p = BeBoB::FunctionBlock::eSP_InputGain; 424 // break; 425 // case ExtendedSubunitInfoPageData::eSP_OutputVolume: 426 // p = BeBoB::FunctionBlock::eSP_OutputVolume; 427 // break; 428 // default: 429 // p = BeBoB::FunctionBlock::eSP_NoSpecialPurpose; 430 // } 431 // return p; 432 // } 433 // 434 bool 435 SubunitAudio::serializeChild( Glib::ustring basePath, 436 Util::IOSerialize& ser ) const 437 { 438 bool result = true; 439 int i = 0; 440 441 for ( BeBoB::FunctionBlockVector::const_iterator it = m_functions.begin(); 297 442 it != m_functions.end(); 298 443 ++it ) 299 444 { 300 FunctionBlock* function = *it; 301 if ( !function->discoverConnections() ) { 302 debugError( "functionblock connection discovering failed ('%s')\n", 303 function->getName() ); 304 return false; 305 } 306 } 307 308 return true; 309 } 310 311 const char* 312 BeBoB::AvDeviceSubunitAudio::getName() 313 { 314 return "AudioSubunit"; 315 } 316 317 bool 318 BeBoB::AvDeviceSubunitAudio::discoverFunctionBlocks() 319 { 320 debugOutput( DEBUG_LEVEL_NORMAL, 321 "Discovering function blocks...\n"); 322 323 if ( !discoverFunctionBlocksDo( 324 ExtendedSubunitInfoCmd::eFBT_AudioSubunitSelector) ) 325 { 326 debugError( "Could not discover function block selector\n" ); 327 return false; 328 } 329 if ( !discoverFunctionBlocksDo( 330 ExtendedSubunitInfoCmd::eFBT_AudioSubunitFeature) ) 331 { 332 debugError( "Could not discover function block feature\n" ); 333 return false; 334 } 335 if ( !discoverFunctionBlocksDo( 336 ExtendedSubunitInfoCmd::eFBT_AudioSubunitProcessing) ) 337 { 338 debugError( "Could not discover function block processing\n" ); 339 return false; 340 } 341 if ( !discoverFunctionBlocksDo( 342 ExtendedSubunitInfoCmd::eFBT_AudioSubunitCodec) ) 343 { 344 debugError( "Could not discover function block codec\n" ); 345 return false; 346 } 347 348 // print a function block list 349 #ifdef DEBUG 350 if (getDebugLevel() >= DEBUG_LEVEL_NORMAL) { 351 352 for ( FunctionBlockVector::iterator it = m_functions.begin(); 353 it != m_functions.end(); 354 ++it ) 355 { 356 debugOutput(DEBUG_LEVEL_NORMAL, "%20s FB, type 0x%X, id=%d\n", 357 (*it)->getName(), 358 (*it)->getType(), 359 (*it)->getId()); 360 } 361 } 362 #endif 363 364 return true; 365 } 366 367 bool 368 BeBoB::AvDeviceSubunitAudio::discoverFunctionBlocksDo( 369 ExtendedSubunitInfoCmd::EFunctionBlockType fbType ) 370 { 371 int page = 0; 372 bool cmdSuccess = false; 373 bool finished = false; 374 375 do { 376 ExtendedSubunitInfoCmd 377 extSubunitInfoCmd( m_avDevice->get1394Service() ); 378 extSubunitInfoCmd.setNodeId( m_avDevice->getConfigRom().getNodeId() ); 379 extSubunitInfoCmd.setCommandType( AVCCommand::eCT_Status ); 380 extSubunitInfoCmd.setSubunitId( getSubunitId() ); 381 extSubunitInfoCmd.setSubunitType( getSubunitType() ); 382 extSubunitInfoCmd.setVerbose( m_verboseLevel ); 383 384 extSubunitInfoCmd.m_fbType = fbType; 385 extSubunitInfoCmd.m_page = page; 386 387 cmdSuccess = extSubunitInfoCmd.fire(); 388 if ( cmdSuccess 389 && ( extSubunitInfoCmd.getResponse() 390 == AVCCommand::eR_Implemented ) ) 391 { 392 for ( ExtendedSubunitInfoPageDataVector::iterator it = 393 extSubunitInfoCmd.m_infoPageDatas.begin(); 394 cmdSuccess 395 && ( it != extSubunitInfoCmd.m_infoPageDatas.end() ); 396 ++it ) 397 { 398 cmdSuccess = createFunctionBlock( fbType, **it ); 399 } 400 if ( ( extSubunitInfoCmd.m_infoPageDatas.size() != 0 ) 401 && ( extSubunitInfoCmd.m_infoPageDatas.size() == 5 ) ) 402 { 403 page++; 404 } else { 405 finished = true; 406 } 407 } else { 408 finished = true; 409 } 410 } while ( cmdSuccess && !finished ); 411 412 return cmdSuccess; 413 } 414 415 bool 416 BeBoB::AvDeviceSubunitAudio::createFunctionBlock( 417 ExtendedSubunitInfoCmd::EFunctionBlockType fbType, 418 ExtendedSubunitInfoPageData& data ) 419 { 420 FunctionBlock::ESpecialPurpose purpose 421 = convertSpecialPurpose( data.m_functionBlockSpecialPupose ); 422 423 FunctionBlock* fb = 0; 424 425 switch ( fbType ) { 426 case ExtendedSubunitInfoCmd::eFBT_AudioSubunitSelector: 427 { 428 fb = new FunctionBlockSelector( *this, 429 data.m_functionBlockId, 430 purpose, 431 data.m_noOfInputPlugs, 432 data.m_noOfOutputPlugs, 433 m_verboseLevel ); 434 } 435 break; 436 case ExtendedSubunitInfoCmd::eFBT_AudioSubunitFeature: 437 { 438 fb = new FunctionBlockFeature( *this, 439 data.m_functionBlockId, 440 purpose, 441 data.m_noOfInputPlugs, 442 data.m_noOfOutputPlugs, 443 m_verboseLevel ); 444 } 445 break; 446 case ExtendedSubunitInfoCmd::eFBT_AudioSubunitProcessing: 447 { 448 switch ( data.m_functionBlockType ) { 449 case ExtendedSubunitInfoCmd::ePT_EnhancedMixer: 450 { 451 fb = new FunctionBlockEnhancedMixer( *this, 452 data.m_functionBlockId, 453 purpose, 454 data.m_noOfInputPlugs, 455 data.m_noOfOutputPlugs, 456 m_verboseLevel ); 457 } 458 break; 459 case ExtendedSubunitInfoCmd::ePT_Mixer: 460 case ExtendedSubunitInfoCmd::ePT_Generic: 461 case ExtendedSubunitInfoCmd::ePT_UpDown: 462 case ExtendedSubunitInfoCmd::ePT_DolbyProLogic: 463 case ExtendedSubunitInfoCmd::ePT_3DStereoExtender: 464 case ExtendedSubunitInfoCmd::ePT_Reverberation: 465 case ExtendedSubunitInfoCmd::ePT_Chorus: 466 case ExtendedSubunitInfoCmd::ePT_DynamicRangeCompression: 467 default: 468 fb = new FunctionBlockProcessing( *this, 469 data.m_functionBlockId, 470 purpose, 471 data.m_noOfInputPlugs, 472 data.m_noOfOutputPlugs, 473 m_verboseLevel ); 474 debugWarning( "Dummy function block processing created. " 475 "Implementation is missing\n" ); 476 } 477 } 478 break; 479 case ExtendedSubunitInfoCmd::eFBT_AudioSubunitCodec: 480 { 481 fb = new FunctionBlockCodec( *this, 482 data.m_functionBlockId, 483 purpose, 484 data.m_noOfInputPlugs, 485 data.m_noOfOutputPlugs, 486 m_verboseLevel ); 487 debugWarning( "Dummy function block codec created. " 488 "Implementation is missing\n" ); 489 } 490 break; 491 default: 492 debugError( "Unhandled function block type found\n" ); 493 return false; 494 } 495 496 if ( !fb ) { 497 debugError( "Could create function block\n" ); 498 return false; 499 } 500 if ( !fb->discover() ) { 501 debugError( "Could not discover function block %s\n", 502 fb->getName() ); 503 delete fb; 504 return false; 505 } 506 m_functions.push_back( fb ); 507 508 return true; 509 } 510 511 BeBoB::FunctionBlock::ESpecialPurpose 512 BeBoB::AvDeviceSubunitAudio::convertSpecialPurpose( 513 function_block_special_purpose_t specialPurpose ) 514 { 515 FunctionBlock::ESpecialPurpose p; 516 switch ( specialPurpose ) { 517 case ExtendedSubunitInfoPageData::eSP_InputGain: 518 p = FunctionBlock::eSP_InputGain; 519 break; 520 case ExtendedSubunitInfoPageData::eSP_OutputVolume: 521 p = FunctionBlock::eSP_OutputVolume; 522 break; 523 default: 524 p = FunctionBlock::eSP_NoSpecialPurpose; 525 } 526 return p; 527 } 528 529 bool 530 BeBoB::AvDeviceSubunitAudio::serializeChild( Glib::ustring basePath, 531 Util::IOSerialize& ser ) const 532 { 533 bool result = true; 534 int i = 0; 535 536 for ( FunctionBlockVector::const_iterator it = m_functions.begin(); 537 it != m_functions.end(); 538 ++it ) 539 { 540 FunctionBlock* pFB = *it; 445 BeBoB::FunctionBlock* pFB = *it; 541 446 std::ostringstream strstrm; 542 strstrm << basePath << " FunctionBlock" << i << "/";447 strstrm << basePath << "BeBoB::FunctionBlock" << i << "/"; 543 448 544 449 result &= pFB->serialize( strstrm.str() , ser ); … … 551 456 552 457 bool 553 BeBoB::AvDeviceSubunitAudio::deserializeChild( Glib::ustring basePath,458 SubunitAudio::deserializeChild( Glib::ustring basePath, 554 459 Util::IODeserialize& deser, 555 AvDevice& avDevice)460 Unit& unit ) 556 461 { 557 462 int i = 0; … … 559 464 do { 560 465 std::ostringstream strstrm; 561 strstrm << basePath << " FunctionBlock" << i << "/";562 FunctionBlock* pFB =FunctionBlock::deserialize( strstrm.str(),466 strstrm << basePath << "BeBoB::FunctionBlock" << i << "/"; 467 BeBoB::FunctionBlock* pFB = BeBoB::FunctionBlock::deserialize( strstrm.str(), 563 468 deser, 564 avDevice,469 unit, 565 470 *this ); 566 471 if ( pFB ) { … … 577 482 //////////////////////////////////////////// 578 483 579 BeBoB::AvDeviceSubunitMusic::AvDeviceSubunitMusic( AvDevice& avDevice, 580 subunit_t id, 581 int verboseLevel ) 582 : AvDeviceSubunit( avDevice, eST_Music, id, verboseLevel ) 583 { 584 } 585 586 BeBoB::AvDeviceSubunitMusic::AvDeviceSubunitMusic() 587 : AvDeviceSubunit() 588 { 589 } 590 591 BeBoB::AvDeviceSubunitMusic::~AvDeviceSubunitMusic() 484 SubunitMusic::SubunitMusic( Unit& unit, subunit_t id ) 485 : Subunit( unit, eST_Music, id ) 486 { 487 } 488 489 SubunitMusic::SubunitMusic() 490 : Subunit() 491 { 492 } 493 494 SubunitMusic::~SubunitMusic() 592 495 { 593 496 } 594 497 595 498 const char* 596 BeBoB::AvDeviceSubunitMusic::getName()499 SubunitMusic::getName() 597 500 { 598 501 return "MusicSubunit"; … … 600 503 601 504 bool 602 BeBoB::AvDeviceSubunitMusic::serializeChild( Glib::ustring basePath,505 SubunitMusic::serializeChild( Glib::ustring basePath, 603 506 Util::IOSerialize& ser ) const 604 507 { … … 607 510 608 511 bool 609 BeBoB::AvDeviceSubunitMusic::deserializeChild( Glib::ustring basePath,512 SubunitMusic::deserializeChild( Glib::ustring basePath, 610 513 Util::IODeserialize& deser, 611 AvDevice& avDevice)514 Unit& unit ) 612 515 { 613 516 return true; 614 517 } 518 519 } branches/echoaudio/src/libavc/general/avc_subunit.h
r503 r507 22 22 */ 23 23 24 #ifndef BEBOB_AVDEVICESUBUNIT_H25 #define BEBOB_AVDEVICESUBUNIT_H24 #ifndef AVC_SUBUNIT_H 25 #define AVC_SUBUNIT_H 26 26 27 #include "bebob/bebob_avplug.h" 28 #include "bebob/bebob_functionblock.h" 27 #include "avc_plug.h" 29 28 30 29 #include "debugmodule/debugmodule.h" 31 #include "libavc/general/avc_extended_subunit_info.h" 32 #include "libavc/avc_definitions.h" 33 #include "libavc/general/avc_generic.h" 30 #include "../general/avc_extended_subunit_info.h" 31 #include "../avc_definitions.h" 32 #include "../general/avc_generic.h" 33 #include "../audiosubunit/avc_function_block.h" 34 34 35 35 #include <vector> 36 36 37 namespace BeBoB { 37 #warning merge with bebob functionblock 38 #include "bebob/bebob_functionblock.h" 38 39 39 class AvDevice; 40 namespace AVC { 40 41 41 class AvDeviceSubunit { 42 class Unit; 43 44 45 46 class Subunit { 42 47 public: 43 AvDeviceSubunit( AvDevice& avDevice, 44 AVC::ESubunitType type, 45 AVC::subunit_t id, 46 int verboseLevel ); 47 virtual ~AvDeviceSubunit(); 48 Subunit( Unit& avDevice, 49 ESubunitType type, 50 subunit_t id ); 51 virtual ~Subunit(); 48 52 49 53 virtual bool discover(); 50 virtual bool discoverConnections(); 54 virtual bool discoverConnections() 55 {//FIXME: 56 #warning FIXME 57 }; 58 51 59 virtual const char* getName() = 0; 52 60 53 bool addPlug( AvPlug& plug ); 61 subunit_t getSubunitId() 62 { return m_sbId; } 63 ESubunitType getSubunitType() 64 { return m_sbType; } 65 66 bool addPlug( Plug& plug ); 54 67 55 AVC::subunit_t getSubunitId() 56 { return m_sbId; } 57 AVC::ESubunitType getSubunitType() 58 { return m_sbType; } 59 60 AvPlugVector& getPlugs() 68 PlugVector& getPlugs() 61 69 { return m_plugs; } 62 AvPlug* getPlug(AvPlug::EAvPlugDirection direction, AVC::plug_id_t plugId);70 Plug* getPlug(Plug::EPlugDirection direction, plug_id_t plugId); 63 71 64 72 65 AvDevice& getAvDevice() const66 { return *m_ avDevice; }73 Unit& getUnit() const 74 { return *m_unit; } 67 75 68 76 69 77 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 70 static AvDeviceSubunit* deserialize( Glib::ustring basePath,78 static Subunit* deserialize( Glib::ustring basePath, 71 79 Util::IODeserialize& deser, 72 AvDevice& avDevice );80 Unit& avDevice ); 73 81 protected: 74 AvDeviceSubunit();82 Subunit(); 75 83 76 bool discoverPlugs();77 bool discoverPlugs(AvPlug::EAvPlugDirection plugDirection,78 AVC::plug_id_t plugMaxId );79 84 // bool discoverPlugs(); 85 // bool discoverPlugs(Plug::EPlugDirection plugDirection, 86 // plug_id_t plugMaxId ); 87 // 80 88 virtual bool serializeChild( Glib::ustring basePath, 81 89 Util::IOSerialize& ser ) const = 0; 82 90 virtual bool deserializeChild( Glib::ustring basePath, 83 91 Util::IODeserialize& deser, 84 AvDevice& avDevice ) = 0;92 Unit& avDevice ) = 0; 85 93 86 94 protected: 87 AvDevice* m_avDevice; 88 AVC::ESubunitType m_sbType; 89 AVC::subunit_t m_sbId; 90 int m_verboseLevel; 95 Unit* m_unit; 96 ESubunitType m_sbType; 97 subunit_t m_sbId; 91 98 92 AvPlugVector m_plugs;99 PlugVector m_plugs; 93 100 94 101 DECLARE_DEBUG_MODULE; 95 102 }; 96 103 97 typedef std::vector< AvDeviceSubunit*> AvDeviceSubunitVector;104 typedef std::vector<Subunit*> SubunitVector; 98 105 99 // ///////////////////////////106 // ///////////////////////////// 100 107 101 class AvDeviceSubunitAudio: public AvDeviceSubunit {108 class SubunitAudio: public Subunit { 102 109 public: 103 AvDeviceSubunitAudio( AvDevice& avDevice, 104 AVC::subunit_t id, 105 int verboseLevel ); 106 AvDeviceSubunitAudio(); 107 virtual ~AvDeviceSubunitAudio(); 110 SubunitAudio( Unit& avDevice, 111 subunit_t id ); 112 SubunitAudio(); 113 virtual ~SubunitAudio(); 108 114 109 115 virtual bool discover(); 110 virtual bool discoverConnections();111 116 // virtual bool discoverConnections(); 117 // 112 118 virtual const char* getName(); 113 114 FunctionBlockVector getFunctionBlocks() { return m_functions; };115 116 protected:117 bool discoverFunctionBlocks();118 bool discoverFunctionBlocksDo(119 AVC::ExtendedSubunitInfoCmd::EFunctionBlockType fbType );120 bool createFunctionBlock(121 AVC::ExtendedSubunitInfoCmd::EFunctionBlockType fbType,122 AVC::ExtendedSubunitInfoPageData& data );123 124 FunctionBlock::ESpecialPurpose convertSpecialPurpose(125 AVC::function_block_special_purpose_t specialPurpose );119 // 120 BeBoB::FunctionBlockVector getFunctionBlocks() { return m_functions; }; 121 // 122 // protected: 123 // bool discoverFunctionBlocks(); 124 // bool discoverFunctionBlocksDo( 125 // ExtendedSubunitInfoCmd::EFunctionBlockType fbType ); 126 // bool createFunctionBlock( 127 // ExtendedSubunitInfoCmd::EFunctionBlockType fbType, 128 // ExtendedSubunitInfoPageData& data ); 129 // 130 // FunctionBlock::ESpecialPurpose convertSpecialPurpose( 131 // function_block_special_purpose_t specialPurpose ); 126 132 127 133 virtual bool serializeChild( Glib::ustring basePath, … … 129 135 virtual bool deserializeChild( Glib::ustring basePath, 130 136 Util::IODeserialize& deser, 131 AvDevice& avDevice );137 Unit& avDevice ); 132 138 133 139 protected: 134 FunctionBlockVector m_functions;140 BeBoB::FunctionBlockVector m_functions; 135 141 }; 136 142 137 // ///////////////////////////143 // ///////////////////////////// 138 144 139 class AvDeviceSubunitMusic: public AvDeviceSubunit {145 class SubunitMusic: public Subunit { 140 146 public: 141 AvDeviceSubunitMusic( AvDevice& avDevice, 142 AVC::subunit_t id, 143 int verboseLevel ); 144 AvDeviceSubunitMusic(); 145 virtual ~AvDeviceSubunitMusic(); 147 SubunitMusic( Unit& avDevice, 148 subunit_t id ); 149 SubunitMusic(); 150 virtual ~SubunitMusic(); 146 151 147 152 virtual const char* getName(); … … 152 157 virtual bool deserializeChild( Glib::ustring basePath, 153 158 Util::IODeserialize& deser, 154 AvDevice& avDevice );159 Unit& avDevice ); 155 160 }; 156 161 branches/echoaudio/src/libavc/general/avc_unit.cpp
r504 r507 1 1 /* 2 * Copyright (C) 2007 by Pieter Palmers 2 3 * Copyright (C) 2005-2007 by Daniel Wagner 3 4 * … … 22 23 */ 23 24 24 #include " bebob/bebob_avdevice.h"25 #include " bebob/bebob_avdevice_subunit.h"26 #include " bebob/GenericMixer.h"25 #include "avc_unit.h" 26 #include "avc_subunit.h" 27 #include "avc_plug.h" 27 28 28 29 #include "libieee1394/configrom.h" 29 30 #include "libieee1394/ieee1394service.h" 30 31 31 #include " libavc/general/avc_plug_info.h"32 #include " libavc/general/avc_extended_plug_info.h"33 #include " libavc/general/avc_subunit_info.h"34 #include " libavc/streamformat/avc_extended_stream_format.h"35 #include " libavc/util/avc_serialize.h"36 #include " libavc/avc_definitions.h"32 #include "../general/avc_plug_info.h" 33 #include "../general/avc_extended_plug_info.h" 34 #include "../general/avc_subunit_info.h" 35 #include "../streamformat/avc_extended_stream_format.h" 36 #include "../util/avc_serialize.h" 37 #include "../avc_definitions.h" 37 38 38 39 #include "debugmodule/debugmodule.h" … … 41 42 #include <sstream> 42 43 43 using namespace AVC; 44 45 namespace BeBoB { 46 47 static VendorModelEntry supportedDeviceList[] = 48 { 49 {0x00000f, 0x00010065, "Mackie", "Onyx Firewire"}, 50 51 {0x0003db, 0x00010048, "Apogee Electronics", "Rosetta 200"}, 52 53 {0x0007f5, 0x00010048, "BridgeCo", "RD Audio1"}, 54 55 {0x000a92, 0x00010000, "PreSonus", "FIREBOX"}, 56 {0x000a92, 0x00010066, "PreSonus", "FirePOD"}, 57 58 {0x000aac, 0x00000003, "TerraTec Electronic GmbH", "Phase 88 FW"}, 59 {0x000aac, 0x00000004, "TerraTec Electronic GmbH", "Phase X24 FW (model version 4)"}, 60 {0x000aac, 0x00000007, "TerraTec Electronic GmbH", "Phase X24 FW (model version 7)"}, 61 62 {0x000f1b, 0x00010064, "ESI", "Quatafire 610"}, 63 64 {0x00130e, 0x00000003, "Focusrite", "Saffire Pro26IO"}, 65 {0x00130e, 0x00000006, "Focusrite", "Saffire Pro10IO"}, 66 67 {0x0040ab, 0x00010048, "EDIROL", "FA-101"}, 68 {0x0040ab, 0x00010049, "EDIROL", "FA-66"}, 69 }; 70 71 AvDevice::AvDevice( std::auto_ptr< ConfigRom >( configRom ), 72 Ieee1394Service& ieee1394service, 73 int nodeId ) 74 : FFADODevice( configRom, ieee1394service, nodeId ) 75 , m_pPlugManager( new AvPlugManager( DEBUG_LEVEL_NORMAL ) ) 44 namespace AVC { 45 46 IMPL_DEBUG_MODULE( Unit, Unit, DEBUG_LEVEL_VERBOSE ); 47 48 Unit::Unit( std::auto_ptr< ConfigRom >( configRom ), 49 Ieee1394Service& ieee1394service, 50 int nodeId ) 51 : m_pPlugManager( new PlugManager( ) ) 76 52 , m_activeSyncInfo( 0 ) 77 , m_ model ( NULL)78 , m_ Mixer ( NULL)79 { 80 debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::AvDevice(NodeID %d)\n",53 , m_puConfigRom( configRom ) 54 , m_pu1394Service( &ieee1394service ) 55 { 56 debugOutput( DEBUG_LEVEL_VERBOSE, "Created AVC::Unit (NodeID %d)\n", 81 57 nodeId ); 82 addOption(Util::OptionContainer::Option("snoopMode",false)); 83 } 84 85 AvDevice::~AvDevice() 86 { 87 if(m_Mixer != NULL) { 88 if (!removeChildOscNode(m_Mixer)) { 89 debugWarning("failed to unregister mixer from OSC namespace\n"); 90 } 91 delete m_Mixer; 92 } 93 94 for ( AvDeviceSubunitVector::iterator it = m_subunits.begin(); 58 } 59 60 Unit::~Unit() 61 { 62 for ( SubunitVector::iterator it = m_subunits.begin(); 95 63 it != m_subunits.end(); 96 64 ++it ) … … 98 66 delete *it; 99 67 } 100 for ( AvPlugConnectionVector::iterator it = m_plugConnections.begin();68 for ( PlugConnectionVector::iterator it = m_plugConnections.begin(); 101 69 it != m_plugConnections.end(); 102 70 ++it ) … … 104 72 delete *it; 105 73 } 106 for ( AvPlugVector::iterator it = m_pcrPlugs.begin();74 for ( PlugVector::iterator it = m_pcrPlugs.begin(); 107 75 it != m_pcrPlugs.end(); 108 76 ++it ) … … 110 78 delete *it; 111 79 } 112 for ( AvPlugVector::iterator it = m_externalPlugs.begin();80 for ( PlugVector::iterator it = m_externalPlugs.begin(); 113 81 it != m_externalPlugs.end(); 114 82 ++it ) … … 119 87 120 88 void 121 AvDevice::setVerboseLevel(int l) 122 { 123 // m_pPlugManager->setVerboseLevel(l); 124 125 FFADODevice::setVerboseLevel(l); 89 Unit::setVerboseLevel(int l) 90 { 91 m_pPlugManager->setVerboseLevel(l); 126 92 } 127 93 128 94 bool 129 AvDevice::probe( ConfigRom& configRom ) 130 { 131 unsigned int vendorId = configRom.getNodeVendorId(); 132 unsigned int modelId = configRom.getModelId(); 133 134 for ( unsigned int i = 0; 135 i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); 136 ++i ) 137 { 138 if ( ( supportedDeviceList[i].vendor_id == vendorId ) 139 && ( supportedDeviceList[i].model_id == modelId ) ) 140 { 141 return true; 142 } 143 } 144 145 return false; 146 } 147 148 bool 149 AvDevice::discover() 150 { 151 unsigned int vendorId = m_pConfigRom->getNodeVendorId(); 152 unsigned int modelId = m_pConfigRom->getModelId(); 153 154 for ( unsigned int i = 0; 155 i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); 156 ++i ) 157 { 158 if ( ( supportedDeviceList[i].vendor_id == vendorId ) 159 && ( supportedDeviceList[i].model_id == modelId ) 160 ) 161 { 162 m_model = &(supportedDeviceList[i]); 163 break; 164 } 165 } 166 167 if (m_model != NULL) { 168 debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 169 m_model->vendor_name, m_model->model_name); 170 } else return false; 95 Unit::discover() 96 { 171 97 172 98 if ( !enumerateSubUnits() ) { … … 175 101 } 176 102 177 if ( !discoverPlugs() ) {178 debugError( "Detecting plugs failed\n" );179 return false;180 }181 182 if ( !discoverPlugConnections() ) {183 debugError( "Detecting plug connections failed\n" );184 return false;185 }186 187 if ( !discoverSubUnitsPlugConnections() ) {188 debugError( "Detecting plug connnection failed\n" );189 return false;190 }191 192 if ( !discoverSyncModes() ) {193 debugError( "Detecting sync modes failed\n" );194 return false;195 }196 197 // create a GenericMixer and add it as an OSC child node198 // remove if already there199 if(m_Mixer != NULL) {200 if (!removeChildOscNode(m_Mixer)) {201 debugWarning("failed to unregister mixer from OSC namespace\n");202 }203 delete m_Mixer;204 }205 206 // create the mixer & register it207 if(getAudioSubunit(0) == NULL) {208 debugWarning("Could not find audio subunit, mixer not available.\n");209 m_Mixer = NULL;210 } else {211 m_Mixer = new GenericMixer(*m_p1394Service , *this);212 if (!addChildOscNode(m_Mixer)) {213 debugWarning("failed to register mixer in OSC namespace\n");214 }215 }216 103 return true; 217 104 } 218 105 219 106 bool 220 AvDevice::discoverPlugs() 221 { 222 ////////////////////////////////////////////// 223 // Get number of available isochronous input 224 // and output plugs of unit 225 226 PlugInfoCmd plugInfoCmd( *m_p1394Service ); 227 plugInfoCmd.setNodeId( m_pConfigRom->getNodeId() ); 228 plugInfoCmd.setCommandType( AVCCommand::eCT_Status ); 229 plugInfoCmd.setVerbose( m_verboseLevel ); 230 231 if ( !plugInfoCmd.fire() ) { 232 debugError( "plug info command failed\n" ); 233 return false; 234 } 235 236 debugOutput( DEBUG_LEVEL_NORMAL, "number of iso input plugs = %d\n", 237 plugInfoCmd.m_serialBusIsochronousInputPlugs ); 238 debugOutput( DEBUG_LEVEL_NORMAL, "number of iso output plugs = %d\n", 239 plugInfoCmd.m_serialBusIsochronousOutputPlugs ); 240 debugOutput( DEBUG_LEVEL_NORMAL, "number of external input plugs = %d\n", 241 plugInfoCmd.m_externalInputPlugs ); 242 debugOutput( DEBUG_LEVEL_NORMAL, "number of external output plugs = %d\n", 243 plugInfoCmd.m_externalOutputPlugs ); 244 245 if ( !discoverPlugsPCR( AvPlug::eAPD_Input, 246 plugInfoCmd.m_serialBusIsochronousInputPlugs ) ) 247 { 248 debugError( "pcr input plug discovering failed\n" ); 249 return false; 250 } 251 252 if ( !discoverPlugsPCR( AvPlug::eAPD_Output, 253 plugInfoCmd.m_serialBusIsochronousOutputPlugs ) ) 254 { 255 debugError( "pcr output plug discovering failed\n" ); 256 return false; 257 } 258 259 if ( !discoverPlugsExternal( AvPlug::eAPD_Input, 260 plugInfoCmd.m_externalInputPlugs ) ) 261 { 262 debugError( "external input plug discovering failed\n" ); 263 return false; 264 } 265 266 if ( !discoverPlugsExternal( AvPlug::eAPD_Output, 267 plugInfoCmd.m_externalOutputPlugs ) ) 268 { 269 debugError( "external output plug discovering failed\n" ); 270 return false; 271 } 272 273 return true; 274 } 275 276 bool 277 AvDevice::discoverPlugsPCR( AvPlug::EAvPlugDirection plugDirection, 278 plug_id_t plugMaxId ) 279 { 280 for ( int plugId = 0; 281 plugId < plugMaxId; 282 ++plugId ) 283 { 284 AvPlug* plug = new AvPlug( *m_p1394Service, 285 *m_pConfigRom, 286 *m_pPlugManager, 287 eST_Unit, 288 0xff, 289 0xff, 290 0xff, 291 AvPlug::eAPA_PCR, 292 plugDirection, 293 plugId, 294 m_verboseLevel ); 295 if ( !plug || !plug->discover() ) { 296 debugError( "plug discovering failed\n" ); 297 delete plug; 298 return false; 299 } 300 301 debugOutput( DEBUG_LEVEL_NORMAL, "plug '%s' found\n", 302 plug->getName() ); 303 m_pcrPlugs.push_back( plug ); 304 } 305 306 return true; 307 } 308 309 bool 310 AvDevice::discoverPlugsExternal( AvPlug::EAvPlugDirection plugDirection, 311 plug_id_t plugMaxId ) 312 { 313 for ( int plugId = 0; 314 plugId < plugMaxId; 315 ++plugId ) 316 { 317 AvPlug* plug = new AvPlug( *m_p1394Service, 318 *m_pConfigRom, 319 *m_pPlugManager, 320 eST_Unit, 321 0xff, 322 0xff, 323 0xff, 324 AvPlug::eAPA_ExternalPlug, 325 plugDirection, 326 plugId, 327 m_verboseLevel ); 328 if ( !plug || !plug->discover() ) { 329 debugError( "plug discovering failed\n" ); 330 return false; 331 } 332 333 debugOutput( DEBUG_LEVEL_NORMAL, "plug '%s' found\n", 334 plug->getName() ); 335 m_externalPlugs.push_back( plug ); 336 } 337 338 return true; 339 } 340 341 bool 342 AvDevice::discoverPlugConnections() 343 { 344 for ( AvPlugVector::iterator it = m_pcrPlugs.begin(); 345 it != m_pcrPlugs.end(); 346 ++it ) 347 { 348 AvPlug* plug = *it; 349 if ( !plug->discoverConnections() ) { 350 debugError( "Could not discover plug connections\n" ); 351 return false; 352 } 353 } 354 for ( AvPlugVector::iterator it = m_externalPlugs.begin(); 355 it != m_externalPlugs.end(); 356 ++it ) 357 { 358 AvPlug* plug = *it; 359 if ( !plug->discoverConnections() ) { 360 debugError( "Could not discover plug connections\n" ); 361 return false; 362 } 363 } 364 365 return true; 366 } 367 368 bool 369 AvDevice::discoverSubUnitsPlugConnections() 370 { 371 for ( AvDeviceSubunitVector::iterator it = m_subunits.begin(); 372 it != m_subunits.end(); 373 ++it ) 374 { 375 AvDeviceSubunit* subunit = *it; 376 if ( !subunit->discoverConnections() ) { 377 debugError( "Subunit '%s' plug connections failed\n", 378 subunit->getName() ); 379 return false; 380 } 381 } 382 return true; 383 } 384 385 bool 386 AvDevice::discoverSyncModes() 387 { 388 // Following possible sync plugs exists: 389 // - Music subunit sync output plug = internal sync (CSP) 390 // - Unit input plug 0 = SYT match 391 // - Unit input plut 1 = Sync stream 392 // 393 // If last sync mode is reported it is mostelikely not 394 // implemented *sic* 395 // 396 // Following sync sources are device specific: 397 // - All unit external input plugs which have a 398 // sync information (WS, SPDIF, ...) 399 400 // First we have to find the sync input and output plug 401 // in the music subunit. 402 403 // Note PCR input means 1394bus-to-device where as 404 // MSU input means subunit-to-device 405 406 AvPlugVector syncPCRInputPlugs = getPlugsByType( m_pcrPlugs, 407 AvPlug::eAPD_Input, 408 AvPlug::eAPT_Sync ); 409 if ( !syncPCRInputPlugs.size() ) { 410 debugWarning( "No PCR sync input plug found\n" ); 411 } 412 413 AvPlugVector syncPCROutputPlugs = getPlugsByType( m_pcrPlugs, 414 AvPlug::eAPD_Output, 415 AvPlug::eAPT_Sync ); 416 if ( !syncPCROutputPlugs.size() ) { 417 debugWarning( "No PCR sync output plug found\n" ); 418 } 419 420 AvPlugVector isoPCRInputPlugs = getPlugsByType( m_pcrPlugs, 421 AvPlug::eAPD_Input, 422 AvPlug::eAPT_IsoStream ); 423 if ( !isoPCRInputPlugs.size() ) { 424 debugWarning( "No PCR iso input plug found\n" ); 425 426 } 427 428 AvPlugVector isoPCROutputPlugs = getPlugsByType( m_pcrPlugs, 429 AvPlug::eAPD_Output, 430 AvPlug::eAPT_IsoStream ); 431 if ( !isoPCROutputPlugs.size() ) { 432 debugWarning( "No PCR iso output plug found\n" ); 433 434 } 435 436 AvPlugVector digitalPCRInputPlugs = getPlugsByType( m_externalPlugs, 437 AvPlug::eAPD_Input, 438 AvPlug::eAPT_Digital ); 439 440 AvPlugVector syncMSUInputPlugs = m_pPlugManager->getPlugsByType( 441 eST_Music, 442 0, 443 0xff, 444 0xff, 445 AvPlug::eAPA_SubunitPlug, 446 AvPlug::eAPD_Input, 447 AvPlug::eAPT_Sync ); 448 if ( !syncMSUInputPlugs.size() ) { 449 debugWarning( "No sync input plug for MSU subunit found\n" ); 450 } 451 452 AvPlugVector syncMSUOutputPlugs = m_pPlugManager->getPlugsByType( 453 eST_Music, 454 0, 455 0xff, 456 0xff, 457 AvPlug::eAPA_SubunitPlug, 458 AvPlug::eAPD_Output, 459 AvPlug::eAPT_Sync ); 460 if ( !syncMSUOutputPlugs.size() ) { 461 debugWarning( "No sync output plug for MSU subunit found\n" ); 462 } 463 464 debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Sync Input Plugs:\n" ); 465 showAvPlugs( syncPCRInputPlugs ); 466 debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Sync Output Plugs:\n" ); 467 showAvPlugs( syncPCROutputPlugs ); 468 debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Iso Input Plugs:\n" ); 469 showAvPlugs( isoPCRInputPlugs ); 470 debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Iso Output Plugs:\n" ); 471 showAvPlugs( isoPCROutputPlugs ); 472 debugOutput( DEBUG_LEVEL_VERBOSE, "PCR digital Input Plugs:\n" ); 473 showAvPlugs( digitalPCRInputPlugs ); 474 debugOutput( DEBUG_LEVEL_VERBOSE, "MSU Sync Input Plugs:\n" ); 475 showAvPlugs( syncMSUInputPlugs ); 476 debugOutput( DEBUG_LEVEL_VERBOSE, "MSU Sync Output Plugs:\n" ); 477 showAvPlugs( syncMSUOutputPlugs ); 478 479 // Check all possible PCR input to MSU input connections 480 // -> sync stream input 481 checkSyncConnectionsAndAddToList( syncPCRInputPlugs, 482 syncMSUInputPlugs, 483 "Sync Stream Input" ); 484 485 // Check all possible MSU output to PCR output connections 486 // -> sync stream output 487 checkSyncConnectionsAndAddToList( syncMSUOutputPlugs, 488 syncPCROutputPlugs, 489 "Sync Stream Output" ); 490 491 // Check all PCR iso input to MSU input connections 492 // -> SYT match 493 checkSyncConnectionsAndAddToList( isoPCRInputPlugs, 494 syncMSUInputPlugs, 495 "Syt Match" ); 496 497 // Check all MSU sync output to MSU input connections 498 // -> CSP 499 checkSyncConnectionsAndAddToList( syncMSUOutputPlugs, 500 syncMSUInputPlugs, 501 "Internal (CSP)" ); 502 503 // Check all external PCR digital input to MSU input connections 504 // -> SPDIF/ADAT sync 505 checkSyncConnectionsAndAddToList( digitalPCRInputPlugs, 506 syncMSUInputPlugs, 507 "Digital Input Sync" ); 508 509 // Currently active connection signal source cmd, command type 510 // status, source unknown, destination MSU sync input plug 511 512 for ( AvPlugVector::const_iterator it = syncMSUInputPlugs.begin(); 513 it != syncMSUInputPlugs.end(); 514 ++it ) 515 { 516 AvPlug* msuPlug = *it; 517 for ( AvPlugVector::const_iterator jt = 518 msuPlug->getInputConnections().begin(); 519 jt != msuPlug->getInputConnections().end(); 520 ++jt ) 521 { 522 AvPlug* plug = *jt; 523 524 for ( SyncInfoVector::iterator it = m_syncInfos.begin(); 525 it != m_syncInfos.end(); 526 ++it ) 527 { 528 SyncInfo* pSyncInfo = &*it; 529 if ( ( pSyncInfo->m_source == plug ) 530 && ( pSyncInfo->m_destination == msuPlug ) ) 531 { 532 m_activeSyncInfo = pSyncInfo; 533 break; 534 } 535 } 536 debugOutput( DEBUG_LEVEL_NORMAL, 537 "Active Sync Connection: '%s' -> '%s'\n", 538 plug->getName(), 539 msuPlug->getName() ); 540 } 541 } 542 543 return true; 544 } 545 546 bool 547 AvDevice::enumerateSubUnits() 548 { 549 bool musicSubunitFound=false; 550 bool audioSubunitFound=false; 551 552 SubUnitInfoCmd subUnitInfoCmd( *m_p1394Service ); 553 //subUnitInfoCmd.setVerbose( 1 ); 107 Unit::enumerateSubUnits() 108 { 109 SubUnitInfoCmd subUnitInfoCmd( *m_pu1394Service ); 554 110 subUnitInfoCmd.setCommandType( AVCCommand::eCT_Status ); 555 111 556 // BeBoB has always exactly one audio and one music subunit. This112 // NOTE: BeBoB has always exactly one audio and one music subunit. This 557 113 // means is fits into the first page of the SubUnitInfo command. 558 114 // So there is no need to do more than needed 115 // FIXME: to be fully spec compliant this needs to be fixed, but let's not 116 // do that for now 559 117 560 118 subUnitInfoCmd.m_page = 0; 561 subUnitInfoCmd.setNodeId( m_p ConfigRom->getNodeId() );562 subUnitInfoCmd.setVerbose( m_verboseLevel);119 subUnitInfoCmd.setNodeId( m_puConfigRom->getNodeId() ); 120 subUnitInfoCmd.setVerbose( getDebugLevel() ); 563 121 if ( !subUnitInfoCmd.fire() ) { 564 122 debugError( "Subunit info command failed\n" ); … … 579 137 subunitTypeToString( subunit_type ) ); 580 138 581 AvDeviceSubunit* subunit = 0;139 Subunit* subunit = 0; 582 140 switch( subunit_type ) { 583 141 case eST_Audio: 584 subunit = new AvDeviceSubunitAudio( *this, 585 subunitId, 586 m_verboseLevel ); 142 subunit = new SubunitAudio( *this, 143 subunitId ); 587 144 if ( !subunit ) { 588 debugFatal( "Could not allocate AvDeviceSubunitAudio\n" ); 589 return false; 590 } 591 if ( !subunit ) { 592 debugFatal( "Could not allocate AvDeviceSubunitMusic\n" ); 145 debugFatal( "Could not allocate SubunitAudio\n" ); 593 146 return false; 594 147 } … … 604 157 } else { 605 158 m_subunits.push_back( subunit ); 606 audioSubunitFound=true;607 159 } 608 160 609 161 break; 610 162 case eST_Music: 611 subunit = new AvDeviceSubunitMusic( *this, 612 subunitId, 613 m_verboseLevel ); 163 subunit = new SubunitMusic( *this, 164 subunitId ); 614 165 if ( !subunit ) { 615 debugFatal( "Could not allocate AvDeviceSubunitMusic\n" );166 debugFatal( "Could not allocate SubunitMusic\n" ); 616 167 return false; 617 168 } … … 626 177 } else { 627 178 m_subunits.push_back( subunit ); 628 musicSubunitFound=true;629 179 } 630 180 … … 638 188 639 189 } 640 641 } 642 643 // a BeBoB always has an audio and a music subunit 644 return (musicSubunitFound && audioSubunitFound); 645 } 646 647 648 AvDeviceSubunit* 649 AvDevice::getSubunit( subunit_type_t subunitType, 190 } 191 192 return true; 193 } 194 195 Subunit* 196 Unit::getSubunit( subunit_type_t subunitType, 650 197 subunit_id_t subunitId ) const 651 198 { 652 for ( AvDeviceSubunitVector::const_iterator it = m_subunits.begin();199 for ( SubunitVector::const_iterator it = m_subunits.begin(); 653 200 it != m_subunits.end(); 654 201 ++it ) 655 202 { 656 AvDeviceSubunit* subunit = *it;203 Subunit* subunit = *it; 657 204 if ( ( subunitType == subunit->getSubunitType() ) 658 205 && ( subunitId == subunit->getSubunitId() ) ) … … 665 212 } 666 213 667 668 214 unsigned int 669 AvDevice::getNrOfSubunits( subunit_type_t subunitType ) const215 Unit::getNrOfSubunits( subunit_type_t subunitType ) const 670 216 { 671 217 unsigned int nrOfSubunits = 0; 672 218 673 for ( AvDeviceSubunitVector::const_iterator it = m_subunits.begin();219 for ( SubunitVector::const_iterator it = m_subunits.begin(); 674 220 it != m_subunits.end(); 675 221 ++it ) 676 222 { 677 AvDeviceSubunit* subunit = *it;223 Subunit* subunit = *it; 678 224 if ( subunitType == subunit->getSubunitType() ) { 679 225 nrOfSubunits++; … … 684 230 } 685 231 686 AvPlugConnection*687 AvDevice::getPlugConnection( AvPlug& srcPlug ) const688 { 689 for ( AvPlugConnectionVector::const_iterator it232 PlugConnection* 233 Unit::getPlugConnection( Plug& srcPlug ) const 234 { 235 for ( PlugConnectionVector::const_iterator it 690 236 = m_plugConnections.begin(); 691 237 it != m_plugConnections.end(); 692 238 ++it ) 693 239 { 694 AvPlugConnection* plugConnection = *it;240 PlugConnection* plugConnection = *it; 695 241 if ( &( plugConnection->getSrcPlug() ) == &srcPlug ) { 696 242 return plugConnection; … … 701 247 } 702 248 703 AvPlug*704 AvDevice::getPlugById( AvPlugVector& plugs,705 AvPlug::EAvPlugDirection plugDirection,249 Plug* 250 Unit::getPlugById( PlugVector& plugs, 251 Plug::EPlugDirection plugDirection, 706 252 int id ) 707 253 { 708 for ( AvPlugVector::iterator it = plugs.begin();254 for ( PlugVector::iterator it = plugs.begin(); 709 255 it != plugs.end(); 710 256 ++it ) 711 257 { 712 AvPlug* plug = *it;258 Plug* plug = *it; 713 259 if ( ( id == plug->getPlugId() ) 714 260 && ( plugDirection == plug->getPlugDirection() ) ) … … 721 267 } 722 268 723 AvPlugVector724 AvDevice::getPlugsByType( AvPlugVector& plugs,725 AvPlug::EAvPlugDirection plugDirection,726 AvPlug::EAvPlugType type)727 { 728 AvPlugVector plugVector;729 for ( AvPlugVector::iterator it = plugs.begin();269 PlugVector 270 Unit::getPlugsByType( PlugVector& plugs, 271 Plug::EPlugDirection plugDirection, 272 Plug::EPlugType type) 273 { 274 PlugVector plugVector; 275 for ( PlugVector::iterator it = plugs.begin(); 730 276 it != plugs.end(); 731 277 ++it ) 732 278 { 733 AvPlug* plug = *it;279 Plug* plug = *it; 734 280 if ( ( type == plug->getPlugType() ) 735 281 && ( plugDirection == plug->getPlugDirection() ) ) … … 742 288 } 743 289 744 AvPlug*745 AvDevice::getSyncPlug( int maxPlugId, AvPlug::EAvPlugDirection )290 Plug* 291 Unit::getSyncPlug( int maxPlugId, Plug::EPlugDirection ) 746 292 { 747 293 return 0; 748 294 } 749 295 750 bool 751 AvDevice::setSamplingFrequency( int s ) 752 { 753 ESamplingFrequency samplingFrequency=parseSampleRate( s ); 754 bool snoopMode=false; 755 if(!getOption("snoopMode", snoopMode)) { 756 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 757 } 758 759 if(snoopMode) { 760 int current_sr=getSamplingFrequency(); 761 if (current_sr != convertESamplingFrequency( samplingFrequency ) ) { 762 debugError("In snoop mode it is impossible to set the sample rate.\n"); 763 debugError("Please start the client with the correct setting.\n"); 764 return false; 765 } 766 return true; 767 } else { 768 AvPlug* plug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Input, 0 ); 769 if ( !plug ) { 770 debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); 771 return false; 772 } 773 774 if ( !setSamplingFrequencyPlug( *plug, 775 AvPlug::eAPD_Input, 776 samplingFrequency ) ) 777 { 778 debugError( "setSampleRate: Setting sample rate failed\n" ); 779 return false; 780 } 781 782 plug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Output, 0 ); 783 if ( !plug ) { 784 debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); 785 return false; 786 } 787 788 if ( !setSamplingFrequencyPlug( *plug, 789 AvPlug::eAPD_Output, 790 samplingFrequency ) ) 791 { 792 debugError( "setSampleRate: Setting sample rate failed\n" ); 793 return false; 794 } 795 796 debugOutput( DEBUG_LEVEL_VERBOSE, 797 "setSampleRate: Set sample rate to %d\n", 798 convertESamplingFrequency( samplingFrequency ) ); 799 return true; 800 } 801 // not executable 802 return false; 803 } 804 805 int 806 AvDevice::getSamplingFrequency( ) { 807 AvPlug* inputPlug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Input, 0 ); 808 if ( !inputPlug ) { 809 debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); 810 return false; 811 } 812 AvPlug* outputPlug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Output, 0 ); 813 if ( !outputPlug ) { 814 debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); 815 return false; 816 } 817 818 int samplerate_playback=inputPlug->getSampleRate(); 819 int samplerate_capture=outputPlug->getSampleRate(); 820 821 if (samplerate_playback != samplerate_capture) { 822 debugWarning("Samplerates for capture and playback differ!\n"); 823 } 824 return samplerate_capture; 825 } 826 827 828 bool 829 AvDevice::setSamplingFrequencyPlug( AvPlug& plug, 830 AvPlug::EAvPlugDirection direction, 831 ESamplingFrequency samplingFrequency ) 832 { 833 834 ExtendedStreamFormatCmd extStreamFormatCmd( 835 *m_p1394Service, 836 ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommandList ); 837 UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 838 plug.getPlugId() ); 839 840 extStreamFormatCmd.setPlugAddress( 841 PlugAddress( 842 AvPlug::convertPlugDirection(direction ), 843 PlugAddress::ePAM_Unit, 844 unitPlugAddress ) ); 845 846 extStreamFormatCmd.setNodeId( m_pConfigRom->getNodeId() ); 847 extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); 848 296 void 297 Unit::showDevice() 298 { 299 m_pPlugManager->showPlugs(); 300 } 301 302 void 303 Unit::showPlugs( PlugVector& plugs ) const 304 { 849 305 int i = 0; 850 bool cmdSuccess = false; 851 bool correctFormatFound = false; 852 853 do { 854 extStreamFormatCmd.setIndexInStreamFormat( i ); 855 extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); 856 extStreamFormatCmd.setVerbose( m_verboseLevel ); 857 858 cmdSuccess = extStreamFormatCmd.fire(); 859 860 if ( cmdSuccess 861 && ( extStreamFormatCmd.getResponse() == 862 AVCCommand::eR_Implemented ) ) 863 { 864 ESamplingFrequency foundFreq = eSF_DontCare; 865 866 FormatInformation* formatInfo = 867 extStreamFormatCmd.getFormatInformation(); 868 FormatInformationStreamsCompound* compoundStream 869 = dynamic_cast< FormatInformationStreamsCompound* > ( 870 formatInfo->m_streams ); 871 if ( compoundStream ) { 872 foundFreq = 873 static_cast< ESamplingFrequency >( 874 compoundStream->m_samplingFrequency ); 875 } 876 877 FormatInformationStreamsSync* syncStream 878 = dynamic_cast< FormatInformationStreamsSync* > ( 879 formatInfo->m_streams ); 880 if ( syncStream ) { 881 foundFreq = 882 static_cast< ESamplingFrequency >( 883 syncStream->m_samplingFrequency ); 884 } 885 886 if ( foundFreq == samplingFrequency ) 887 { 888 correctFormatFound = true; 889 break; 890 } 891 } 892 893 ++i; 894 } while ( cmdSuccess 895 && ( extStreamFormatCmd.getResponse() == 896 ExtendedStreamFormatCmd::eR_Implemented ) ); 897 898 if ( !cmdSuccess ) { 899 debugError( "setSampleRatePlug: Failed to retrieve format info\n" ); 900 return false; 901 } 902 903 if ( !correctFormatFound ) { 904 debugError( "setSampleRatePlug: %s plug %d does not support " 905 "sample rate %d\n", 906 plug.getName(), 907 plug.getPlugId(), 908 convertESamplingFrequency( samplingFrequency ) ); 909 return false; 910 } 911 912 extStreamFormatCmd.setSubFunction( 913 ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommand ); 914 extStreamFormatCmd.setCommandType( AVCCommand::eCT_Control ); 915 extStreamFormatCmd.setVerbose( m_verboseLevel ); 916 917 if ( !extStreamFormatCmd.fire() ) { 918 debugError( "setSampleRate: Could not set sample rate %d " 919 "to %s plug %d\n", 920 convertESamplingFrequency( samplingFrequency ), 921 plug.getName(), 922 plug.getPlugId() ); 923 return false; 924 } 925 926 return true; 927 } 928 929 void 930