Changeset 548
- Timestamp:
- 08/21/07 10:12:58 (16 years ago)
- Files:
-
- branches/echoaudio/src/bebob/bebob_avdevice.cpp (modified) (8 diffs)
- branches/echoaudio/src/bebob/bebob_avdevice.h (modified) (4 diffs)
- branches/echoaudio/src/bebob/bebob_avplug.cpp (modified) (2 diffs)
- branches/echoaudio/src/bebob/bebob_avplug.h (modified) (1 diff)
- branches/echoaudio/src/genericavc/avc_avdevice.cpp (modified) (12 diffs)
- branches/echoaudio/src/genericavc/avc_avdevice.h (modified) (2 diffs)
- branches/echoaudio/src/libavc/general/avc_plug.cpp (modified) (4 diffs)
- branches/echoaudio/src/libavc/general/avc_plug.h (modified) (3 diffs)
- branches/echoaudio/src/libavc/general/avc_unit.cpp (modified) (2 diffs)
- branches/echoaudio/src/libavc/general/avc_unit.h (modified) (1 diff)
- branches/echoaudio/src/libavc/musicsubunit/avc_musicsubunit.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/echoaudio/src/bebob/bebob_avdevice.cpp
r543 r548 45 45 namespace BeBoB { 46 46 47 IMPL_DEBUG_MODULE( AvDevice, AvDevice, DEBUG_LEVEL_VERBOSE ); 48 49 static VendorModelEntry supportedDeviceList[] = 47 static GenericAVC::VendorModelEntry supportedDeviceList[] = 50 48 { 51 49 {0x00000f, 0x00010065, "Mackie", "Onyx Firewire"}, … … 74 72 Ieee1394Service& ieee1394service, 75 73 int nodeId ) 76 : FFADODevice( configRom, ieee1394service, nodeId ) 77 , AVC::Unit( ) 78 , m_model ( NULL ) 74 : GenericAVC::AvDevice( configRom, ieee1394service, nodeId ) 79 75 , m_Mixer ( NULL ) 80 76 { 81 77 debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::AvDevice (NodeID %d)\n", 82 78 nodeId ); 83 addOption(Util::OptionContainer::Option("snoopMode",false));84 79 } 85 80 … … 95 90 96 91 AVC::Subunit* 97 BeBoB::AvDevice::createSubunit(AVC::Unit& unit,92 AvDevice::createSubunit(AVC::Unit& unit, 98 93 AVC::ESubunitType type, 99 94 AVC::subunit_t id ) … … 110 105 111 106 AVC::Plug * 112 BeBoB::AvDevice::createPlug( AVC::Unit* unit,107 AvDevice::createPlug( AVC::Unit* unit, 113 108 AVC::Subunit* subunit, 114 109 AVC::function_block_type_t functionBlockType, … … 128 123 } 129 124 130 void131 AvDevice::setVerboseLevel(int l)132 {133 m_pPlugManager->setVerboseLevel(l);134 135 FFADODevice::setVerboseLevel(l);136 AVC::Unit::setVerboseLevel(l);137 }138 139 125 bool 140 126 AvDevice::probe( ConfigRom& configRom ) … … 144 130 145 131 for ( unsigned int i = 0; 146 i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) );132 i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); 147 133 ++i ) 148 134 { … … 163 149 164 150 for ( unsigned int i = 0; 165 i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) );151 i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); 166 152 ++i ) 167 153 { … … 223 209 224 210 bool 225 AvDevice::setSamplingFrequency( int s ) 226 { 227 ESamplingFrequency samplingFrequency=parseSampleRate( s ); 228 bool snoopMode=false; 229 if(!getOption("snoopMode", snoopMode)) { 230 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 231 } 232 233 if(snoopMode) { 234 int current_sr=getSamplingFrequency(); 235 if (current_sr != convertESamplingFrequency( samplingFrequency ) ) { 236 debugError("In snoop mode it is impossible to set the sample rate.\n"); 237 debugError("Please start the client with the correct setting.\n"); 238 return false; 239 } 240 return true; 241 } else { 242 AVC::Plug* plug = getPlugById( m_pcrPlugs, Plug::eAPD_Input, 0 ); 243 if ( !plug ) { 244 debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); 245 return false; 246 } 247 248 if ( !setSamplingFrequencyPlug( *plug, 249 Plug::eAPD_Input, 250 samplingFrequency ) ) 251 { 252 debugError( "setSampleRate: Setting sample rate failed\n" ); 253 return false; 254 } 255 256 plug = getPlugById( m_pcrPlugs, Plug::eAPD_Output, 0 ); 257 if ( !plug ) { 258 debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); 259 return false; 260 } 261 262 if ( !setSamplingFrequencyPlug( *plug, 263 Plug::eAPD_Output, 264 samplingFrequency ) ) 265 { 266 debugError( "setSampleRate: Setting sample rate failed\n" ); 267 return false; 268 } 269 270 debugOutput( DEBUG_LEVEL_VERBOSE, 271 "setSampleRate: Set sample rate to %d\n", 272 convertESamplingFrequency( samplingFrequency ) ); 273 return true; 274 } 275 // not executable 276 return false; 277 } 278 279 int 280 AvDevice::getSamplingFrequency( ) { 281 AVC::Plug* inputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Input, 0 ); 282 if ( !inputPlug ) { 283 debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); 284 return false; 285 } 286 AVC::Plug* outputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Output, 0 ); 287 if ( !outputPlug ) { 288 debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); 289 return false; 290 } 291 292 int samplerate_playback=inputPlug->getSampleRate(); 293 int samplerate_capture=outputPlug->getSampleRate(); 294 295 if (samplerate_playback != samplerate_capture) { 296 debugWarning("Samplerates for capture and playback differ!\n"); 297 } 298 return samplerate_capture; 299 } 300 301 302 bool 303 AvDevice::setSamplingFrequencyPlug( AVC::Plug& plug, 304 Plug::EPlugDirection direction, 305 ESamplingFrequency samplingFrequency ) 306 { 307 308 ExtendedStreamFormatCmd extStreamFormatCmd( 309 *m_p1394Service, 310 ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommandList ); 311 UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 312 plug.getPlugId() ); 313 314 extStreamFormatCmd.setPlugAddress( 315 PlugAddress( 316 Plug::convertPlugDirection(direction ), 317 PlugAddress::ePAM_Unit, 318 unitPlugAddress ) ); 319 320 extStreamFormatCmd.setNodeId( m_pConfigRom->getNodeId() ); 321 extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); 322 323 int i = 0; 324 bool cmdSuccess = false; 325 bool correctFormatFound = false; 326 327 do { 328 extStreamFormatCmd.setIndexInStreamFormat( i ); 329 extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); 330 extStreamFormatCmd.setVerbose( m_verboseLevel ); 331 332 cmdSuccess = extStreamFormatCmd.fire(); 333 334 if ( cmdSuccess 335 && ( extStreamFormatCmd.getResponse() == 336 AVCCommand::eR_Implemented ) ) 337 { 338 ESamplingFrequency foundFreq = eSF_DontCare; 339 340 FormatInformation* formatInfo = 341 extStreamFormatCmd.getFormatInformation(); 342 FormatInformationStreamsCompound* compoundStream 343 = dynamic_cast< FormatInformationStreamsCompound* > ( 344 formatInfo->m_streams ); 345 if ( compoundStream ) { 346 foundFreq = 347 static_cast< ESamplingFrequency >( 348 compoundStream->m_samplingFrequency ); 349 } 350 351 FormatInformationStreamsSync* syncStream 352 = dynamic_cast< FormatInformationStreamsSync* > ( 353 formatInfo->m_streams ); 354 if ( syncStream ) { 355 foundFreq = 356 static_cast< ESamplingFrequency >( 357 syncStream->m_samplingFrequency ); 358 } 359 360 if ( foundFreq == samplingFrequency ) 361 { 362 correctFormatFound = true; 363 break; 364 } 365 } 366 367 ++i; 368 } while ( cmdSuccess 369 && ( extStreamFormatCmd.getResponse() == 370 ExtendedStreamFormatCmd::eR_Implemented ) ); 371 372 if ( !cmdSuccess ) { 373 debugError( "setSampleRatePlug: Failed to retrieve format info\n" ); 374 return false; 375 } 376 377 if ( !correctFormatFound ) { 378 debugError( "setSampleRatePlug: %s plug %d does not support " 379 "sample rate %d\n", 380 plug.getName(), 381 plug.getPlugId(), 382 convertESamplingFrequency( samplingFrequency ) ); 383 return false; 384 } 385 386 extStreamFormatCmd.setSubFunction( 387 ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommand ); 388 extStreamFormatCmd.setCommandType( AVCCommand::eCT_Control ); 389 extStreamFormatCmd.setVerbose( m_verboseLevel ); 390 391 if ( !extStreamFormatCmd.fire() ) { 392 debugError( "setSampleRate: Could not set sample rate %d " 393 "to %s plug %d\n", 394 convertESamplingFrequency( samplingFrequency ), 395 plug.getName(), 396 plug.getPlugId() ); 397 return false; 398 } 399 211 AvDevice::propagatePlugInfo() { 212 // we don't have to propagate since we discover things 213 // another way 214 debugOutput(DEBUG_LEVEL_VERBOSE, "Skip plug info propagation\n"); 400 215 return true; 401 }402 403 void404 AvDevice::showDevice()405 {406 debugOutput(DEBUG_LEVEL_VERBOSE,407 "%s %s at node %d\n", m_model->vendor_name, m_model->model_name,408 m_nodeId);409 410 m_pPlugManager->showPlugs();411 flushDebugOutput();412 }413 414 415 bool416 AvDevice::lock() {417 bool snoopMode=false;418 if(!getOption("snoopMode", snoopMode)) {419 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");420 }421 422 if (snoopMode) {423 // don't lock424 } else {425 // return Unit::reserve(4);426 }427 428 return true;429 }430 431 bool432 AvDevice::unlock() {433 bool snoopMode=false;434 if(!getOption("snoopMode", snoopMode)) {435 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");436 }437 438 if (snoopMode) {439 // don't unlock440 } else {441 // return Unit::reserve(0);442 }443 return true;444 }445 446 bool447 AvDevice::prepare() {448 bool snoopMode=false;449 if(!getOption("snoopMode", snoopMode)) {450 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");451 }452 453 ///////////454 // get plugs455 456 AVC::Plug* inputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Input, 0 );457 if ( !inputPlug ) {458 debugError( "setSampleRate: Could not retrieve iso input plug 0\n" );459 return false;460 }461 AVC::Plug* outputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Output, 0 );462 if ( !outputPlug ) {463 debugError( "setSampleRate: Could not retrieve iso output plug 0\n" );464 return false;465 }466 467 int samplerate=outputPlug->getSampleRate();468 469 debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing receive processor...\n");470 // create & add streamprocessors471 Streaming::StreamProcessor *p;472 473 p=new Streaming::AmdtpReceiveStreamProcessor(474 m_p1394Service->getPort(),475 samplerate,476 outputPlug->getNrOfChannels());477 478 if(!p->init()) {479 debugFatal("Could not initialize receive processor!\n");480 delete p;481 return false;482 }483 484 if (!addPlugToProcessor(*outputPlug,p,485 Streaming::Port::E_Capture)) {486 debugFatal("Could not add plug to processor!\n");487 delete p;488 return false;489 }490 491 m_receiveProcessors.push_back(p);492 493 // do the transmit processor494 debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing transmit processor%s...\n",495 (snoopMode?" in snoop mode":""));496 if (snoopMode) {497 // we are snooping, so this is receive too.498 p=new Streaming::AmdtpReceiveStreamProcessor(499 m_p1394Service->getPort(),500 samplerate,501 inputPlug->getNrOfChannels());502 } else {503 p=new Streaming::AmdtpTransmitStreamProcessor(504 m_p1394Service->getPort(),505 samplerate,506 inputPlug->getNrOfChannels());507 }508 509 if(!p->init()) {510 debugFatal("Could not initialize transmit processor %s!\n",511 (snoopMode?" in snoop mode":""));512 delete p;513 return false;514 }515 516 if (snoopMode) {517 if (!addPlugToProcessor(*inputPlug,p,518 Streaming::Port::E_Capture)) {519 debugFatal("Could not add plug to processor!\n");520 return false;521 }522 } else {523 if (!addPlugToProcessor(*inputPlug,p,524 Streaming::Port::E_Playback)) {525 debugFatal("Could not add plug to processor!\n");526 return false;527 }528 }529 530 // we put this SP into the transmit SP vector,531 // no matter if we are in snoop mode or not532 // this allows us to find out what direction533 // a certain stream should have.534 m_transmitProcessors.push_back(p);535 536 return true;537 }538 539 bool540 AvDevice::addPlugToProcessor(541 AVC::Plug& plug,542 Streaming::StreamProcessor *processor,543 Streaming::AmdtpAudioPort::E_Direction direction) {544 545 std::string id=std::string("dev?");546 if(!getOption("id", id)) {547 debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n");548 }549 550 Plug::ClusterInfoVector& clusterInfos = plug.getClusterInfos();551 for ( Plug::ClusterInfoVector::const_iterator it = clusterInfos.begin();552 it != clusterInfos.end();553 ++it )554 {555 const Plug::ClusterInfo* clusterInfo = &( *it );556 557 Plug::ChannelInfoVector channelInfos = clusterInfo->m_channelInfos;558 for ( Plug::ChannelInfoVector::const_iterator it = channelInfos.begin();559 it != channelInfos.end();560 ++it )561 {562 const Plug::ChannelInfo* channelInfo = &( *it );563 std::ostringstream portname;564 565 portname << id << "_" << channelInfo->m_name;566 567 Streaming::Port *p=NULL;568 switch(clusterInfo->m_portType) {569 case ExtendedPlugInfoClusterInfoSpecificData::ePT_Speaker:570 case ExtendedPlugInfoClusterInfoSpecificData::ePT_Headphone:571 case ExtendedPlugInfoClusterInfoSpecificData::ePT_Microphone:572 case ExtendedPlugInfoClusterInfoSpecificData::ePT_Line:573 case ExtendedPlugInfoClusterInfoSpecificData::ePT_Analog:574 debugOutput(DEBUG_LEVEL_VERBOSE, " Adding audio channel %s (pos=0x%02X, loc=0x%02X)\n",575 channelInfo->m_name.c_str(), channelInfo->m_streamPosition-1, channelInfo->m_location-1);576 p=new Streaming::AmdtpAudioPort(577 portname.str(),578 direction,579 // \todo: streaming backend expects indexing starting from 0580 // but bebob reports it starting from 1. Decide where581 // and how to handle this (pp: here)582 // note that the descriptor mechanism specifies indexing from 0583 channelInfo->m_streamPosition-1,584 channelInfo->m_location - 1,585 Streaming::AmdtpPortInfo::E_MBLA586 );587 break;588 589 case ExtendedPlugInfoClusterInfoSpecificData::ePT_MIDI:590 debugOutput(DEBUG_LEVEL_VERBOSE, " Adding MIDI channel %s (pos=0x%02X, loc=0x%02X)\n",591 channelInfo->m_name.c_str(), channelInfo->m_streamPosition-1, processor->getPortCount(Streaming::Port::E_Midi));592 p=new Streaming::AmdtpMidiPort(593 portname.str(),594 direction,595 channelInfo->m_streamPosition-1,596 // Workaround for out-of-spec hardware597 // should be:598 // channelInfo->m_location-1,599 // but now we renumber the midi channels' location as they600 // are discovered601 processor->getPortCount(Streaming::Port::E_Midi),602 Streaming::AmdtpPortInfo::E_Midi603 );604 605 break;606 case ExtendedPlugInfoClusterInfoSpecificData::ePT_SPDIF:607 case ExtendedPlugInfoClusterInfoSpecificData::ePT_ADAT:608 case ExtendedPlugInfoClusterInfoSpecificData::ePT_TDIF:609 case ExtendedPlugInfoClusterInfoSpecificData::ePT_MADI:610 case ExtendedPlugInfoClusterInfoSpecificData::ePT_Digital:611 case ExtendedPlugInfoClusterInfoSpecificData::ePT_NoType:612 default:613 // unsupported614 break;615 }616 617 if (!p) {618 debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",channelInfo->m_name.c_str());619 } else {620 621 if (!processor->addPort(p)) {622 debugWarning("Could not register port with stream processor\n");623 return false;624 }625 }626 }627 }628 return true;629 }630 631 int632 AvDevice::getStreamCount() {633 return m_receiveProcessors.size() + m_transmitProcessors.size();634 }635 636 Streaming::StreamProcessor *637 AvDevice::getStreamProcessorByIndex(int i) {638 639 if (i<(int)m_receiveProcessors.size()) {640 return m_receiveProcessors.at(i);641 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) {642 return m_transmitProcessors.at(i-m_receiveProcessors.size());643 }644 645 return NULL;646 }647 648 bool649 AvDevice::startStreamByIndex(int i) {650 int iso_channel=-1;651 bool snoopMode=false;652 if(!getOption("snoopMode", snoopMode)) {653 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");654 }655 656 if (i<(int)m_receiveProcessors.size()) {657 int n=i;658 Streaming::StreamProcessor *p=m_receiveProcessors.at(n);659 660 if(snoopMode) { // a stream from the device to another host661 // FIXME: put this into a decent framework!662 // we should check the oPCR[n] on the device663 struct iec61883_oPCR opcr;664 if (iec61883_get_oPCRX(665 m_p1394Service->getHandle(),666 m_pConfigRom->getNodeId() | 0xffc0,667 (quadlet_t *)&opcr,668 n)) {669 670 debugWarning("Error getting the channel for SP %d\n",i);671 return false;672 }673 674 iso_channel=opcr.channel;675 } else {676 iso_channel=m_p1394Service->allocateIsoChannelCMP(677 m_pConfigRom->getNodeId() | 0xffc0, n,678 m_p1394Service->getLocalNodeId()| 0xffc0, -1);679 }680 if (iso_channel<0) {681 debugError("Could not allocate ISO channel for SP %d\n",i);682 return false;683 }684 685 debugOutput(DEBUG_LEVEL_VERBOSE, "Started SP %d on channel %d\n",i,iso_channel);686 687 p->setChannel(iso_channel);688 return true;689 690 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) {691 int n=i-m_receiveProcessors.size();692 Streaming::StreamProcessor *p=m_transmitProcessors.at(n);693 694 if(snoopMode) { // a stream from another host to the device695 // FIXME: put this into a decent framework!696 // we should check the iPCR[n] on the device697 struct iec61883_iPCR ipcr;698 if (iec61883_get_iPCRX(699 m_p1394Service->getHandle(),700 m_pConfigRom->getNodeId() | 0xffc0,701 (quadlet_t *)&ipcr,702 n)) {703 704 debugWarning("Error getting the channel for SP %d\n",i);705 return false;706 }707 708 iso_channel=ipcr.channel;709 710 } else {711 iso_channel=m_p1394Service->allocateIsoChannelCMP(712 m_p1394Service->getLocalNodeId()| 0xffc0, -1,713 m_pConfigRom->getNodeId() | 0xffc0, n);714 }715 716 if (iso_channel<0) {717 debugError("Could not allocate ISO channel for SP %d\n",i);718 return false;719 }720 721 debugOutput(DEBUG_LEVEL_VERBOSE, "Started SP %d on channel %d\n",i,iso_channel);722 723 p->setChannel(iso_channel);724 return true;725 }726 727 debugError("SP index %d out of range!\n",i);728 return false;729 }730 731 bool732 AvDevice::stopStreamByIndex(int i) {733 bool snoopMode=false;734 if(!getOption("snoopMode", snoopMode)) {735 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");736 }737 738 if (i<(int)m_receiveProcessors.size()) {739 int n=i;740 Streaming::StreamProcessor *p=m_receiveProcessors.at(n);741 742 if(snoopMode) {743 744 } else {745 // deallocate ISO channel746 if(!m_p1394Service->freeIsoChannel(p->getChannel())) {747 debugError("Could not deallocate iso channel for SP %d\n",i);748 return false;749 }750 }751 p->setChannel(-1);752 753 return true;754 755 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) {756 int n=i-m_receiveProcessors.size();757 Streaming::StreamProcessor *p=m_transmitProcessors.at(n);758 759 if(snoopMode) {760 761 } else {762 // deallocate ISO channel763 if(!m_p1394Service->freeIsoChannel(p->getChannel())) {764 debugError("Could not deallocate iso channel for SP %d\n",i);765 return false;766 }767 }768 p->setChannel(-1);769 770 return true;771 }772 773 debugError("SP index %d out of range!\n",i);774 return false;775 216 } 776 217 branches/echoaudio/src/bebob/bebob_avdevice.h
r543 r548 44 44 #include "libutil/serialize.h" 45 45 46 #include "genericavc/avc_avdevice.h" 47 46 48 #include "ffadodevice.h" 47 49 … … 54 56 namespace BeBoB { 55 57 56 struct VendorModelEntry { 57 unsigned int vendor_id; 58 unsigned int model_id; 59 char *vendor_name; 60 char *model_name; 61 }; 62 63 class AvDevice : public FFADODevice, public AVC::Unit { 58 class AvDevice : public GenericAVC::AvDevice { 64 59 public: 65 60 AvDevice( std::auto_ptr<ConfigRom>( configRom ), … … 68 63 virtual ~AvDevice(); 69 64 70 void setVerboseLevel(int l);71 72 65 static bool probe( ConfigRom& configRom ); 73 66 virtual bool discover(); 74 67 75 virtual bool setSamplingFrequency( int );76 virtual int getSamplingFrequency( );77 78 virtual int getStreamCount();79 virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);80 81 virtual bool prepare();82 bool lock();83 bool unlock();84 85 bool startStreamByIndex(int i);86 bool stopStreamByIndex(int i);87 88 virtual void showDevice();89 90 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;91 static AvDevice* deserialize( Glib::ustring basePath,92 Util::IODeserialize& deser,93 Ieee1394Service& ieee1394Service );94 95 // redefinition to resolve ambiguity96 Ieee1394Service& get1394Service()97 { return FFADODevice::get1394Service(); };98 ConfigRom& getConfigRom() const99 { return FFADODevice::getConfigRom(); };100 101 68 virtual AVC::Subunit* createSubunit(AVC::Unit& unit, 102 69 AVC::ESubunitType type, … … 109 76 AVC::Plug::EPlugDirection plugDirection, 110 77 AVC::plug_id_t plugId ); 111 protected:112 113 virtual bool addPlugToProcessor( AVC::Plug& plug, Streaming::StreamProcessor *processor,114 Streaming::AmdtpAudioPort::E_Direction direction);115 116 bool setSamplingFrequencyPlug( AVC::Plug& plug,117 AVC::Plug::EPlugDirection direction,118 AVC::ESamplingFrequency samplingFrequency );119 120 virtual bool propagateClusterInfos() {return true;};121 78 122 79 protected: 123 struct VendorModelEntry* m_model; 80 virtual bool propagatePlugInfo(); 81 82 public: 83 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 84 static AvDevice* deserialize( Glib::ustring basePath, 85 Util::IODeserialize& deser, 86 Ieee1394Service& ieee1394Service ); 87 88 protected: 124 89 GenericMixer* m_Mixer; 125 90 126 // streaming stuff127 typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;128 StreamProcessorVector m_receiveProcessors;129 StreamProcessorVector m_transmitProcessors;130 131 DECLARE_DEBUG_MODULE;132 91 }; 133 92 branches/echoaudio/src/bebob/bebob_avplug.cpp
r543 r548 312 312 313 313 bool 314 Plug::copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData& 315 channelPositionData ) 316 { 317 int index = 1; 318 for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfoVector::const_iterator it 319 = channelPositionData.m_clusterInfos.begin(); 320 it != channelPositionData.m_clusterInfos.end(); 321 ++it ) 322 { 323 const ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfo* 324 extPlugSpClusterInfo = &( *it ); 325 326 ClusterInfo clusterInfo; 327 clusterInfo.m_nrOfChannels = extPlugSpClusterInfo->m_nrOfChannels; 328 clusterInfo.m_index = index; 329 index++; 330 331 for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfoVector::const_iterator cit 332 = extPlugSpClusterInfo->m_channelInfos.begin(); 333 cit != extPlugSpClusterInfo->m_channelInfos.end(); 334 ++cit ) 335 { 336 const ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfo* 337 extPlugSpChannelInfo = &( *cit ); 338 339 ChannelInfo channelInfo; 340 channelInfo.m_streamPosition = 341 extPlugSpChannelInfo->m_streamPosition-1; 342 // FIXME: this can only become a mess with the two meanings 343 // of the location parameter. the audio style meaning 344 // starts from 1, the midi style meaning from 0 345 // lucky for us we recalculate this for the midi channels 346 // and don't use this value. 347 channelInfo.m_location = 348 extPlugSpChannelInfo->m_location; 349 350 clusterInfo.m_channelInfos.push_back( channelInfo ); 351 } 352 m_clusterInfos.push_back( clusterInfo ); 353 } 354 355 return true; 356 } 357 358 bool 314 359 Plug::discoverChannelName() 315 360 { … … 539 584 } 540 585 541 } 586 ExtendedPlugInfoCmd 587 Plug::setPlugAddrToPlugInfoCmd() 588 { 589 ExtendedPlugInfoCmd extPlugInfoCmd( m_unit->get1394Service() ); 590 591 switch( getSubunitType() ) { 592 case eST_Unit: 593 { 594 UnitPlugAddress::EPlugType ePlugType = 595 UnitPlugAddress::ePT_Unknown; 596 switch ( m_addressType ) { 597 case eAPA_PCR: 598 ePlugType = UnitPlugAddress::ePT_PCR; 599 break; 600 case eAPA_ExternalPlug: 601 ePlugType = UnitPlugAddress::ePT_ExternalPlug; 602 break; 603 case eAPA_AsynchronousPlug: 604 ePlugType = UnitPlugAddress::ePT_AsynchronousPlug; 605 break; 606 default: 607 ePlugType = UnitPlugAddress::ePT_Unknown; 608 } 609 UnitPlugAddress unitPlugAddress( ePlugType, 610 m_id ); 611 extPlugInfoCmd.setPlugAddress( 612 PlugAddress( convertPlugDirection( getPlugDirection() ), 613 PlugAddress::ePAM_Unit, 614 unitPlugAddress ) ); 615 } 616 break; 617 case eST_Music: 618 case eST_Audio: 619 { 620 switch( m_addressType ) { 621 case eAPA_SubunitPlug: 622 { 623 SubunitPlugAddress subunitPlugAddress( m_id ); 624 extPlugInfoCmd.setPlugAddress( 625 PlugAddress( 626 convertPlugDirection( getPlugDirection() ), 627 PlugAddress::ePAM_Subunit, 628 subunitPlugAddress ) ); 629 } 630 break; 631 case eAPA_FunctionBlockPlug: 632 { 633 FunctionBlockPlugAddress functionBlockPlugAddress( 634 m_functionBlockType, 635 m_functionBlockId, 636 m_id ); 637 extPlugInfoCmd.setPlugAddress( 638 PlugAddress( 639 convertPlugDirection( getPlugDirection() ), 640 PlugAddress::ePAM_FunctionBlock, 641 functionBlockPlugAddress ) ); 642 } 643 break; 644 default: 645 extPlugInfoCmd.setPlugAddress(PlugAddress()); 646 } 647 } 648 break; 649 default: 650 debugError( "Unknown subunit type\n" ); 651 } 652 653 extPlugInfoCmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 654 extPlugInfoCmd.setCommandType( AVCCommand::eCT_Status ); 655 extPlugInfoCmd.setSubunitId( getSubunitId() ); 656 extPlugInfoCmd.setSubunitType( getSubunitType() ); 657 658 return extPlugInfoCmd; 659 } 660 661 } branches/echoaudio/src/bebob/bebob_avplug.h
r524 r548 78 78 79 79 private: 80 bool copyClusterInfo(AVC::ExtendedPlugInfoPlugChannelPositionSpecificData& 81 channelPositionData ); 82 AVC::ExtendedPlugInfoCmd setPlugAddrToPlugInfoCmd(); 83 80 84 81 85 }; branches/echoaudio/src/genericavc/avc_avdevice.cpp
r541 r548 65 65 debugOutput( DEBUG_LEVEL_VERBOSE, "Created GenericAVC::AvDevice (NodeID %d)\n", 66 66 nodeId ); 67 addOption(Util::OptionContainer::Option("snoopMode",false)); 67 68 } 68 69 … … 134 135 } 135 136 137 void 138 AvDevice::setVerboseLevel(int l) 139 { 140 m_pPlugManager->setVerboseLevel(l); 141 142 FFADODevice::setVerboseLevel(l); 143 AVC::Unit::setVerboseLevel(l); 144 } 145 136 146 int 137 147 AvDevice::getSamplingFrequency( ) { … … 159 169 AvDevice::setSamplingFrequency( int s ) 160 170 { 161 ESamplingFrequency samplingFrequency=parseSampleRate( s );162 171 bool snoopMode=false; 163 172 if(!getOption("snoopMode", snoopMode)) { … … 167 176 if(snoopMode) { 168 177 int current_sr=getSamplingFrequency(); 169 if (current_sr != convertESamplingFrequency( samplingFrequency )) {178 if (current_sr != s ) { 170 179 debugError("In snoop mode it is impossible to set the sample rate.\n"); 171 180 debugError("Please start the client with the correct setting.\n"); … … 180 189 } 181 190 182 if ( !plug->setSampleRate( convertESamplingFrequency( samplingFrequency )) )191 if ( !plug->setSampleRate( s ) ) 183 192 { 184 193 debugError( "setSampleRate: Setting sample rate failed\n" ); … … 192 201 } 193 202 194 if ( !plug->setSampleRate( convertESamplingFrequency( samplingFrequency )) )203 if ( !plug->setSampleRate( s ) ) 195 204 { 196 205 debugError( "setSampleRate: Setting sample rate failed\n" ); … … 200 209 debugOutput( DEBUG_LEVEL_VERBOSE, 201 210 "setSampleRate: Set sample rate to %d\n", 202 convertESamplingFrequency( samplingFrequency ));211 s ); 203 212 return true; 204 213 } … … 348 357 Streaming::StreamProcessor *processor, 349 358 Streaming::AmdtpAudioPort::E_Direction direction) { 350 351 debugOutput(DEBUG_LEVEL_VERBOSE, " Adding plug %s to processor\n", plug.getName());352 359 353 360 std::string id=std::string("dev?"); … … 362 369 { 363 370 const Plug::ClusterInfo* clusterInfo = &( *it ); 364 365 debugOutput(DEBUG_LEVEL_VERBOSE, " Adding cluster %s\n", clusterInfo->m_name.c_str());366 371 367 372 Plug::ChannelInfoVector channelInfos = clusterInfo->m_channelInfos; … … 370 375 ++it ) 371 376 { 372 373 377 const Plug::ChannelInfo* channelInfo = &( *it ); 374 375 378 std::ostringstream portname; 376 379 … … 396 399 397 400 case ExtendedPlugInfoClusterInfoSpecificData::ePT_MIDI: 398 // HACK: for audiofire2 only !!!399 401 debugOutput(DEBUG_LEVEL_VERBOSE, " Adding MIDI channel %s (pos=0x%02X, loc=0x%02X)\n", 400 channelInfo->m_name.c_str(), (direction==Streaming::Port::E_Capture?4:6), 401 processor->getPortCount(Streaming::Port::E_Midi)); 402 channelInfo->m_name.c_str(), channelInfo->m_streamPosition, processor->getPortCount(Streaming::Port::E_Midi)); 402 403 p=new Streaming::AmdtpMidiPort( 403 404 portname.str(), 404 405 direction, 405 (direction==Streaming::Port::E_Capture?4:6), 406 // channelInfo->m_streamPosition, 406 channelInfo->m_streamPosition, 407 407 // Workaround for out-of-spec hardware 408 408 // should be: … … 420 420 case ExtendedPlugInfoClusterInfoSpecificData::ePT_MADI: 421 421 case ExtendedPlugInfoClusterInfoSpecificData::ePT_Digital: 422 debugOutput(DEBUG_LEVEL_VERBOSE, " Adding digital audio channel %s (pos=0x%02X, loc=0x%02X)\n", 423 channelInfo->m_name.c_str(), channelInfo->m_streamPosition, channelInfo->m_location); 424 p=new Streaming::AmdtpAudioPort( 425 portname.str(), 426 direction, 427 channelInfo->m_streamPosition, 428 channelInfo->m_location, 429 Streaming::AmdtpPortInfo::E_MBLA 430 ); 431 break; 432 422 433 case ExtendedPlugInfoClusterInfoSpecificData::ePT_NoType: 423 434 default: branches/echoaudio/src/genericavc/avc_avdevice.h
r542 r548 60 60 61 61 static bool probe( ConfigRom& configRom ); 62 bool discover(); 62 virtual bool discover(); 63 64 virtual void setVerboseLevel(int l); 65 virtual void showDevice(); 63 66 64 void showDevice(); 67 virtual bool setSamplingFrequency( int ); 68 virtual int getSamplingFrequency( ); 65 69 66 bool setSamplingFrequency( int);67 int getSamplingFrequency();70 virtual int getStreamCount(); 71 virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i); 68 72 69 int getStreamCount(); 70 Streaming::StreamProcessor *getStreamProcessorByIndex(int i); 73 virtual bool prepare(); 74 virtual bool lock(); 75 virtual bool unlock(); 71 76 72 bool prepare(); 73 bool lock(); 74 bool unlock(); 75 76 bool startStreamByIndex(int i); 77 bool stopStreamByIndex(int i); 77 virtual bool startStreamByIndex(int i); 78 virtual bool stopStreamByIndex(int i); 78 79 79 80 // redefinition to resolve ambiguity 80 Ieee1394Service& get1394Service()81 virtual Ieee1394Service& get1394Service() 81 82 { return FFADODevice::get1394Service(); }; 82 ConfigRom& getConfigRom() const83 virtual ConfigRom& getConfigRom() const 83 84 { return FFADODevice::getConfigRom(); }; 84 85 … … 86 87 virtual bool addPlugToProcessor( AVC::Plug& plug, Streaming::StreamProcessor *processor, 87 88 Streaming::AmdtpAudioPort::E_Direction direction); 88 bool setSamplingFrequencyPlug( AVC::Plug& plug,89 /* bool setSamplingFrequencyPlug( AVC::Plug& plug, 89 90 AVC::Plug::EPlugDirection direction, 90 AVC::ESamplingFrequency samplingFrequency ); 91 AVC::ESamplingFrequency samplingFrequency );*/ 91 92 92 93 struct VendorModelEntry *m_model; branches/echoaudio/src/libavc/general/avc_plug.cpp
r524 r548 520 520 Plug::discoverConnectionsOutput() 521 521 { 522 debugOutput( DEBUG_LEVEL_VERBOSE, "Discovering outgoing connections...\n");523 524 // int i=0;525 // int nbPlugs=m_unit->getPlugManager().getPlugCount();526 // debugOutput( DEBUG_LEVEL_VERBOSE, "checking %d plugs\n", nbPlugs);527 //528 // for (i=0;i<nbPlugs;i++) {529 // Plug *p=m_unit->getPlugManager().getPlug(i);530 //531 // if(p==NULL) {532 // debugError("could not get plug 0x%02X\n",i);533 // continue;534 // }535 //536 // if(p->getGlobalId()==getGlobalId()) continue; // skip yourself537 //538 //539 // }540 541 522 return true; 542 523 } … … 1098 1079 debugError( "Unknown subunit type\n" ); 1099 1080 } 1100 }1101 1102 1103 bool1104 Plug::copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData&1105 channelPositionData )1106 {1107 int index = 1;1108 for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfoVector::const_iterator it1109 = channelPositionData.m_clusterInfos.begin();1110 it != channelPositionData.m_clusterInfos.end();1111 ++it )1112 {1113 const ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfo*1114 extPlugSpClusterInfo = &( *it );1115 1116 ClusterInfo clusterInfo;1117 clusterInfo.m_nrOfChannels = extPlugSpClusterInfo->m_nrOfChannels;1118 clusterInfo.m_index = index;1119 index++;1120 1121 for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfoVector::const_iterator cit1122 = extPlugSpClusterInfo->m_channelInfos.begin();1123 cit != extPlugSpClusterInfo->m_channelInfos.end();1124 ++cit )1125 {1126 const ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfo*1127 extPlugSpChannelInfo = &( *cit );1128 1129 ChannelInfo channelInfo;1130 channelInfo.m_streamPosition =1131 extPlugSpChannelInfo->m_streamPosition;1132 channelInfo.m_location =1133 extPlugSpChannelInfo->m_location;1134 1135 clusterInfo.m_channelInfos.push_back( channelInfo );1136 }1137 m_clusterInfos.push_back( clusterInfo );1138 }1139 1140 return true;1141 1081 } 1142 1082 … … 2308 2248 } 2309 2249 2310 ExtendedPlugInfoCmd 2311 Plug::setPlugAddrToPlugInfoCmd() 2312 { 2313 ExtendedPlugInfoCmd extPlugInfoCmd( m_unit->get1394Service() ); 2314 2250 ExtendedStreamFormatCmd 2251 Plug::setPlugAddrToStreamFormatCmd( 2252 ExtendedStreamFormatCmd::ESubFunction subFunction) 2253 { 2254 ExtendedStreamFormatCmd extStreamFormatInfoCmd( 2255 m_unit->get1394Service(), 2256 subFunction ); 2315 2257 switch( getSubunitType() ) { 2316 2258 case eST_Unit: 2317 2259 { 2318 2260 UnitPlugAddress::EPlugType ePlugType = 2319 2261 UnitPlugAddress::ePT_Unknown; … … 2331 2273 ePlugType = UnitPlugAddress::ePT_Unknown; 2332 2274 } 2333 UnitPlugAddress unitPlugAddress( ePlugType,2334 m_id );2335 extPlugInfoCmd.setPlugAddress(2336 PlugAddress( convertPlugDirection( getPlugDirection() ),2337 PlugAddress::ePAM_Unit,2338 unitPlugAddress ) );2339 }2340 break;2341 case eST_Music:2342 case eST_Audio:2343 {2344 switch( m_addressType ) {2345 case eAPA_SubunitPlug:2346 {2347 SubunitPlugAddress subunitPlugAddress( m_id );2348 extPlugInfoCmd.setPlugAddress(2349 PlugAddress(2350 convertPlugDirection( getPlugDirection() ),2351 PlugAddress::ePAM_Subunit,2352 subunitPlugAddress ) );2353 }2354 break;2355 case eAPA_FunctionBlockPlug:2356 {2357 FunctionBlockPlugAddress functionBlockPlugAddress(2358 m_functionBlockType,2359 m_functionBlockId,2360 m_id );2361 extPlugInfoCmd.setPlugAddress(2362 PlugAddress(2363 convertPlugDirection( getPlugDirection() ),2364 PlugAddress::ePAM_FunctionBlock,2365 functionBlockPlugAddress ) );2366 }2367 break;2368 default:2369 extPlugInfoCmd.setPlugAddress(PlugAddress());2370 }2371 }2372 break;2373 default:2374 debugError( "Unknown subunit type\n" );2375 }2376 2377 extPlugInfoCmd.setNodeId( m_unit->getConfigRom().getNodeId() );2378 extPlugInfoCmd.setCommandType( AVCCommand::eCT_Status );2379 extPlugInfoCmd.setSubunitId( getSubunitId() );2380 extPlugInfoCmd.setSubunitType( getSubunitType() );2381 2382 return extPlugInfoCmd;2383 }2384 2385 ExtendedStreamFormatCmd2386 Plug::setPlugAddrToStreamFormatCmd(2387 ExtendedStreamFormatCmd::ESubFunction subFunction)2388 {2389 ExtendedStreamFormatCmd extStreamFormatInfoCmd(2390 m_unit->get1394Service(),2391 subFunction );2392 switch( getSubunitType() ) {2393 case eST_Unit:2394 {2395 UnitPlugAddress::EPlugType ePlugType =2396 UnitPlugAddress::ePT_Unknown;2397 switch ( m_addressType ) {2398 case eAPA_PCR:2399 ePlugType = UnitPlugAddress::ePT_PCR;2400 break;2401 case eAPA_ExternalPlug:2402 ePlugType = UnitPlugAddress::ePT_ExternalPlug;2403 break;2404 case eAPA_AsynchronousPlug:2405 ePlugType = UnitPlugAddress::ePT_AsynchronousPlug;2406 break;2407 default:2408 ePlugType = UnitPlugAddress::ePT_Unknown;2409 }2410 2275 UnitPlugAddress unitPlugAddress( ePlugType, 2411 2276 m_id ); branches/echoaudio/src/libavc/general/avc_plug.h
r524 r548 28 28 #include "../ccm/avc_signal_source.h" 29 29 #include "../streamformat/avc_extended_stream_format.h" 30 #include "avc_extended_plug_info.h"31 #include "avc_extended_cmd_generic.h"32 30 #include "../avc_definitions.h" 33 31 #include "avc_generic.h" … … 214 212 bool propagateFromPlug( Plug *p ); 215 213 216 ExtendedPlugInfoCmd setPlugAddrToPlugInfoCmd();217 218 214 ExtendedStreamFormatCmd setPlugAddrToStreamFormatCmd( 219 215 ExtendedStreamFormatCmd::ESubFunction subFunction); … … 228 224 229 225 void debugOutputClusterInfos( int debugLevel ); 230 231 bool copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData&232 channelPositionData );233 226 234 227 bool addPlugConnection( PlugVector& connections, Plug& plug ); branches/echoaudio/src/libavc/general/avc_unit.cpp
r524 r548 156 156 } 157 157 158 if ( !propagate ClusterInfos() ) {159 debugError( "Failed to propagate cluster info's\n" );158 if ( !propagatePlugInfo() ) { 159 debugError( "Failed to propagate plug info\n" ); 160 160 return false; 161 161 } … … 458 458 459 459 bool 460 Unit::propagate ClusterInfos()460 Unit::propagatePlugInfo() 461 461 { 462 462 debugOutput( DEBUG_LEVEL_NORMAL, "Propagating info to PCR plugs...\n"); branches/echoaudio/src/libavc/general/avc_unit.h
r524 r548 127 127 virtual bool discoverPlugsExternal( AVC::Plug::EPlugDirection plugDirection, 128 128 AVC::plug_id_t plugMaxId ); 129 virtual bool propagate ClusterInfos();129 virtual bool propagatePlugInfo(); 130 130 virtual bool discoverSyncModes(); 131 131 virtual bool checkSyncConnectionsAndAddToList( AVC::PlugVector& plhs, branches/echoaudio/src/libavc/musicsubunit/avc_musicsubunit.cpp
r524 r548 124 124 // number of channels 125 125 result &= plug.setNrOfChannels(info->m_nb_channels); 126 127 128 126 129 127 int idx=1; … … 165 163 } 166 164 165 if (plug.getDirection() == Plug::eAPD_Input) { 166 // it's an input plug to the subunit 167 // so we have to check the source field of the music plug 168 if(s.stream_position != mplug->m_source_stream_position) { 169 debugWarning("s.stream_position (= 0x%02X) != mplug->m_source_stream_position (= 0x%02X)\n", 170 s.stream_position, mplug->m_source_stream_position); 171 // use the one from the music plug 172 sinfo.m_streamPosition= mplug->m_source_stream_position; 173 } 174 if(s.stream_location != mplug->m_source_stream_location) { 175 debugWarning("s.stream_location (= 0x%02X) != mplug->m_source_stream_location (= 0x%02X)\n", 176 s.stream_location, mplug->m_source_stream_location); 177 // use the one from the music plug 178 sinfo.m_location=mplug->m_source_stream_location; 179 } 180 } else if (plug.getDirection() == Plug::eAPD_Output) { 181 // it's an output plug from the subunit 182 // so we have to check the destination field of the music plug 183 if(s.stream_position != mplug->m_dest_stream_position) { 184 debugWarning("s.stream_position (= 0x%02X) != mplug->m_dest_stream_position (= 0x%02X)\n", 185 s.stream_position, mplug->m_dest_stream_position); 186 // use the one from the music plug 187 sinfo.m_streamPosition=mplug->m_dest_stream_position; 188 } 189 if(s.stream_location != mplug->m_dest_stream_location) { 190 debugWarning("s.stream_location (= 0x%02X) != mplug->m_dest_stream_location (= 0x%02X)\n", 191 s.stream_location, mplug->m_dest_stream_location); 192 // use the one from the music plug 193 sinfo.m_location=mplug->m_dest_stream_location; 194 } 195 } else { 196 debugWarning("Invalid plug direction.\n"); 197 } 198 167 199 debugOutput(DEBUG_LEVEL_VERBOSE, "Adding signal pos=%2d loc=%2d name=%s\n", 168 200 sinfo.m_streamPosition, sinfo.m_location, mplug->getName().c_str());