Changeset 750 for trunk/libffado/src
- Timestamp:
- 11/30/07 14:18:26 (16 years ago)
- Files:
-
- trunk/libffado/src/bebob/bebob_avdevice.cpp (modified) (3 diffs)
- trunk/libffado/src/bebob/bebob_avdevice.h (modified) (2 diffs)
- trunk/libffado/src/bebob/focusrite/focusrite_generic.cpp (modified) (1 diff)
- trunk/libffado/src/bebob/focusrite/focusrite_generic.h (modified) (1 diff)
- trunk/libffado/src/bebob/focusrite/focusrite_saffire.cpp (modified) (1 diff)
- trunk/libffado/src/bebob/focusrite/focusrite_saffire.h (modified) (1 diff)
- trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp (modified) (1 diff)
- trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.h (modified) (1 diff)
- trunk/libffado/src/bebob/terratec/terratec_device.cpp (modified) (1 diff)
- trunk/libffado/src/bebob/terratec/terratec_device.h (modified) (1 diff)
- trunk/libffado/src/devicemanager.cpp (modified) (19 diffs)
- trunk/libffado/src/devicemanager.h (modified) (5 diffs)
- trunk/libffado/src/dice/dice_avdevice.cpp (modified) (2 diffs)
- trunk/libffado/src/dice/dice_avdevice.h (modified) (1 diff)
- trunk/libffado/src/ffado.cpp (modified) (23 diffs)
- trunk/libffado/src/ffadodevice.cpp (modified) (1 diff)
- trunk/libffado/src/ffadodevice.h (modified) (4 diffs)
- trunk/libffado/src/fireworks/audiofire/audiofire_device.cpp (modified) (1 diff)
- trunk/libffado/src/fireworks/audiofire/audiofire_device.h (modified) (1 diff)
- trunk/libffado/src/fireworks/fireworks_device.cpp (modified) (3 diffs)
- trunk/libffado/src/fireworks/fireworks_device.h (modified) (1 diff)
- trunk/libffado/src/genericavc/avc_avdevice.cpp (modified) (3 diffs)
- trunk/libffado/src/genericavc/avc_avdevice.h (modified) (1 diff)
- trunk/libffado/src/libieee1394/ieee1394service.cpp (modified) (10 diffs)
- trunk/libffado/src/libieee1394/ieee1394service.h (modified) (4 diffs)
- trunk/libffado/src/libieee1394/IsoHandler.cpp (moved) (moved from trunk/libffado/src/libstreaming/util/IsoHandler.cpp) (24 diffs)
- trunk/libffado/src/libieee1394/IsoHandler.h (moved) (moved from trunk/libffado/src/libstreaming/util/IsoHandler.h) (9 diffs)
- trunk/libffado/src/libieee1394/IsoHandlerManager.cpp (moved) (moved from trunk/libffado/src/libstreaming/util/IsoHandlerManager.cpp) (25 diffs)
- trunk/libffado/src/libieee1394/IsoHandlerManager.h (moved) (moved from trunk/libffado/src/libstreaming/util/IsoHandlerManager.h) (8 diffs)
- trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp (modified) (3 diffs)
- trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h (modified) (2 diffs)
- trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (modified) (5 diffs)
- trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h (modified) (2 diffs)
- trunk/libffado/src/libstreaming/generic/Port.cpp (modified) (1 diff)
- trunk/libffado/src/libstreaming/generic/PortManager.cpp (modified) (3 diffs)
- trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp (modified) (30 diffs)
- trunk/libffado/src/libstreaming/generic/StreamProcessor.h (modified) (8 diffs)
- trunk/libffado/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp (modified) (6 diffs)
- trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp (modified) (6 diffs)
- trunk/libffado/src/libstreaming/StreamProcessorManager.cpp (modified) (17 diffs)
- trunk/libffado/src/libstreaming/StreamProcessorManager.h (modified) (7 diffs)
- trunk/libffado/src/libutil/PosixThread.cpp (modified) (6 diffs)
- trunk/libffado/src/maudio/maudio_avdevice.cpp (modified) (2 diffs)
- trunk/libffado/src/maudio/maudio_avdevice.h (modified) (1 diff)
- trunk/libffado/src/motu/motu_avdevice.cpp (modified) (2 diffs)
- trunk/libffado/src/motu/motu_avdevice.h (modified) (1 diff)
- trunk/libffado/src/SConscript (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/bebob/bebob_avdevice.cpp
r744 r750 55 55 namespace BeBoB { 56 56 57 AvDevice::AvDevice( std::auto_ptr< ConfigRom >( configRom ) )58 : GenericAVC::AvDevice( configRom )57 AvDevice::AvDevice( DeviceManager& d, std::auto_ptr< ConfigRom >( configRom ) ) 58 : GenericAVC::AvDevice( d, configRom ) 59 59 , m_Mixer ( 0 ) 60 60 { … … 90 90 91 91 FFADODevice * 92 AvDevice::createDevice( std::auto_ptr<ConfigRom>( configRom ))92 AvDevice::createDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 93 93 { 94 94 unsigned int vendorId = configRom->getNodeVendorId(); … … 97 97 switch (vendorId) { 98 98 case FW_VENDORID_TERRATEC: 99 return new Terratec::PhaseSeriesDevice( configRom);99 return new Terratec::PhaseSeriesDevice(d, configRom); 100 100 case FW_VENDORID_FOCUSRITE: 101 101 switch(modelId) { 102 102 case 0x00000003: 103 103 case 0x00000006: 104 return new Focusrite::SaffireProDevice( configRom);104 return new Focusrite::SaffireProDevice(d, configRom); 105 105 case 0x00000000: 106 return new Focusrite::SaffireDevice( configRom);106 return new Focusrite::SaffireDevice(d, configRom); 107 107 default: // return a plain BeBoB device 108 return new AvDevice( configRom);108 return new AvDevice(d, configRom); 109 109 } 110 110 default: 111 return new AvDevice( configRom);111 return new AvDevice(d, configRom); 112 112 } 113 113 return NULL; trunk/libffado/src/bebob/bebob_avdevice.h
r744 r750 60 60 class AvDevice : public GenericAVC::AvDevice { 61 61 public: 62 AvDevice( std::auto_ptr<ConfigRom>( configRom ));62 AvDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 63 63 virtual ~AvDevice(); 64 64 … … 68 68 virtual bool discover(); 69 69 70 static FFADODevice * createDevice( std::auto_ptr<ConfigRom>( configRom ));70 static FFADODevice * createDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 71 71 72 72 virtual AVC::Subunit* createSubunit(AVC::Unit& unit, trunk/libffado/src/bebob/focusrite/focusrite_generic.cpp
r742 r750 30 30 namespace Focusrite { 31 31 32 FocusriteDevice::FocusriteDevice( std::auto_ptr<ConfigRom>( configRom ))33 : BeBoB::AvDevice( configRom)32 FocusriteDevice::FocusriteDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 33 : BeBoB::AvDevice( d, configRom) 34 34 { 35 35 debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::Focusrite::FocusriteDevice (NodeID %d)\n", trunk/libffado/src/bebob/focusrite/focusrite_generic.h
r742 r750 136 136 class FocusriteDevice : public BeBoB::AvDevice { 137 137 public: 138 FocusriteDevice( std::auto_ptr<ConfigRom>( configRom ));138 FocusriteDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 139 139 virtual ~FocusriteDevice() {}; 140 140 trunk/libffado/src/bebob/focusrite/focusrite_saffire.cpp
r742 r750 28 28 namespace Focusrite { 29 29 30 SaffireDevice::SaffireDevice( std::auto_ptr<ConfigRom>( configRom ))31 : FocusriteDevice( configRom)30 SaffireDevice::SaffireDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 31 : FocusriteDevice( d, configRom) 32 32 { 33 33 debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::Focusrite::SaffireDevice (NodeID %d)\n", trunk/libffado/src/bebob/focusrite/focusrite_saffire.h
r742 r750 142 142 class SaffireDevice : public FocusriteDevice { 143 143 public: 144 SaffireDevice( std::auto_ptr<ConfigRom>( configRom ));144 SaffireDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 145 145 virtual ~SaffireDevice() {}; 146 146 trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp
r742 r750 28 28 namespace Focusrite { 29 29 30 SaffireProDevice::SaffireProDevice( std::auto_ptr<ConfigRom>( configRom ))31 : FocusriteDevice( configRom )30 SaffireProDevice::SaffireProDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 31 : FocusriteDevice( d, configRom ) 32 32 , m_MixerContainer( NULL ) 33 33 , m_ControlContainer( NULL ) trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.h
r742 r750 302 302 303 303 public: 304 SaffireProDevice( std::auto_ptr<ConfigRom>( configRom ));304 SaffireProDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 305 305 virtual ~SaffireProDevice(); 306 306 trunk/libffado/src/bebob/terratec/terratec_device.cpp
r742 r750 27 27 namespace Terratec { 28 28 29 PhaseSeriesDevice::PhaseSeriesDevice( std::auto_ptr<ConfigRom>( configRom ))30 : BeBoB::AvDevice( configRom)29 PhaseSeriesDevice::PhaseSeriesDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 30 : BeBoB::AvDevice( d, configRom) 31 31 { 32 32 debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::Terratec::PhaseSeriesDevice (NodeID %d)\n", trunk/libffado/src/bebob/terratec/terratec_device.h
r742 r750 34 34 class PhaseSeriesDevice : public BeBoB::AvDevice { 35 35 public: 36 PhaseSeriesDevice( std::auto_ptr<ConfigRom>( configRom ));36 PhaseSeriesDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 37 37 virtual ~PhaseSeriesDevice(); 38 38 trunk/libffado/src/devicemanager.cpp
r745 r750 32 32 33 33 #include "libstreaming/generic/StreamProcessor.h" 34 #include "libstreaming/StreamProcessorManager.h" 34 35 35 36 #include "debugmodule/debugmodule.h" … … 111 112 } 112 113 113 void 114 DeviceManager::setVerboseLevel(int l) 115 { 116 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 117 setDebugLevel(l); 118 Control::Element::setVerboseLevel(l); 119 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 120 it != m_avDevices.end(); 121 ++it ) 122 { 123 (*it)->setVerboseLevel(l); 114 bool 115 DeviceManager::setThreadParameters(bool rt, int priority) { 116 if (!m_processorManager.setThreadParameters(rt, priority)) { 117 debugError("Could not set processor manager thread parameters\n"); 118 return false; 124 119 } 125 120 for ( Ieee1394ServiceVectorIterator it = m_1394Services.begin(); … … 127 122 ++it ) 128 123 { 129 (*it)->setVerboseLevel(l); 130 } 131 } 132 133 void 134 DeviceManager::show() { 135 debugOutput(DEBUG_LEVEL_NORMAL, "===== Device Manager =====\n"); 136 Control::Element::show(); 137 138 int i=0; 139 for ( Ieee1394ServiceVectorIterator it = m_1394Services.begin(); 140 it != m_1394Services.end(); 141 ++it ) 142 { 143 debugOutput(DEBUG_LEVEL_NORMAL, "--- IEEE1394 Service %2d ---\n", i++); 144 (*it)->show(); 145 } 146 147 i=0; 148 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 149 it != m_avDevices.end(); 150 ++it ) 151 { 152 FFADODevice* avDevice = *it; 153 debugOutput(DEBUG_LEVEL_NORMAL, "--- Device %2d ---\n", i++); 154 avDevice->showDevice(); 155 156 debugOutput(DEBUG_LEVEL_NORMAL, "Clock sync sources:\n"); 157 FFADODevice::ClockSourceVector sources=avDevice->getSupportedClockSources(); 158 for ( FFADODevice::ClockSourceVector::const_iterator it 159 = sources.begin(); 160 it != sources.end(); 161 ++it ) 162 { 163 FFADODevice::ClockSource c=*it; 164 debugOutput(DEBUG_LEVEL_NORMAL, " Type: %s, Id: %2d, Valid: %1d, Active: %1d, Locked %1d, Slipping: %1d, Description: %s\n", 165 FFADODevice::ClockSourceTypeToString(c.type), c.id, c.valid, c.active, c.locked, c.slipping, c.description.c_str()); 166 } 167 } 124 if (!(*it)->setThreadParameters(rt, priority)) { 125 debugError("Could not set 1394 service thread parameters\n"); 126 return false; 127 } 128 } 129 m_thread_realtime = rt; 130 m_thread_priority = priority; 131 return true; 168 132 } 169 133 … … 186 150 return false; 187 151 } 152 tmp1394Service->setVerboseLevel( getDebugLevel() ); 188 153 m_1394Services.push_back(tmp1394Service); 189 154 155 tmp1394Service->setThreadParameters(m_thread_realtime, m_thread_priority); 190 156 if ( !tmp1394Service->initialize( port ) ) { 191 157 debugFatal( "Could not initialize Ieee1349Service object for port %d\n", port ); … … 203 169 204 170 tmp1394Service->addBusResetHandler( tmp_busreset_functor ); 205 tmp1394Service->setVerboseLevel( getDebugLevel() );206 } 171 } 172 207 173 return true; 208 174 } … … 333 299 avDevice->setVerboseLevel( getDebugLevel() ); 334 300 } else if ( avDevice->discover() ) { 335 debugOutput( DEBUG_LEVEL_VERBOSE, "discover ingsuccessful\n" );301 debugOutput( DEBUG_LEVEL_VERBOSE, "discovery successful\n" ); 336 302 } else { 337 303 debugError( "could not discover device\n" ); … … 354 320 debugOutput( DEBUG_LEVEL_VERBOSE, "No cached version of AVC model created\n" ); 355 321 } 356 357 322 m_avDevices.push_back( avDevice ); 358 323 … … 382 347 } 383 348 } 384 show ();349 showDeviceInfo(); 385 350 return true; 386 351 } else { // slave mode … … 434 399 } 435 400 401 bool 402 DeviceManager::initStreaming() 403 { 404 // iterate over the found devices 405 // add the stream processors of the devices to the managers 406 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 407 it != m_avDevices.end(); 408 ++it ) 409 { 410 FFADODevice *device = *it; 411 assert(device); 412 413 debugOutput(DEBUG_LEVEL_VERBOSE, "Locking device (%p)\n", device); 414 415 if (!device->lock()) { 416 debugWarning("Could not lock device, skipping device (%p)!\n", device); 417 continue; 418 } 419 420 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting samplerate to %d for (%p)\n", 421 m_processorManager.getNominalRate(), device); 422 423 // Set the device's sampling rate to that requested 424 // FIXME: does this really belong here? If so we need to handle errors. 425 if (!device->setSamplingFrequency(m_processorManager.getNominalRate())) { 426 debugOutput(DEBUG_LEVEL_VERBOSE, " => Retry setting samplerate to %d for (%p)\n", 427 m_processorManager.getNominalRate(), device); 428 429 // try again: 430 if (!device->setSamplingFrequency(m_processorManager.getNominalRate())) { 431 debugFatal("Could not set sampling frequency to %d\n",m_processorManager.getNominalRate()); 432 return false; 433 } 434 } 435 // prepare the device 436 device->prepare(); 437 } 438 439 // set the sync source 440 if (!m_processorManager.setSyncSource(getSyncSource())) { 441 debugWarning("Could not set processorManager sync source (%p)\n", 442 getSyncSource()); 443 } 444 return true; 445 } 446 447 bool 448 DeviceManager::prepareStreaming() 449 { 450 if (!m_processorManager.prepare()) { 451 debugFatal("Could not prepare streaming...\n"); 452 return false; 453 } 454 return true; 455 } 456 457 bool 458 DeviceManager::finishStreaming() { 459 bool result = true; 460 // iterate over the found devices 461 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 462 it != m_avDevices.end(); 463 ++it ) 464 { 465 debugOutput(DEBUG_LEVEL_VERBOSE, "Unlocking device (%p)\n", *it); 466 467 if (!(*it)->unlock()) { 468 debugWarning("Could not unlock device (%p)!\n", *it); 469 result = false; 470 } 471 } 472 return result; 473 } 474 475 bool 476 DeviceManager::startStreaming() { 477 // create the connections for all devices 478 // iterate over the found devices 479 // add the stream processors of the devices to the managers 480 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 481 it != m_avDevices.end(); 482 ++it ) 483 { 484 FFADODevice *device = *it; 485 assert(device); 486 487 int j=0; 488 for(j=0; j < device->getStreamCount(); j++) { 489 debugOutput(DEBUG_LEVEL_VERBOSE,"Starting stream %d of device %p\n", j, device); 490 // start the stream 491 if (!device->startStreamByIndex(j)) { 492 debugWarning("Could not start stream %d of device %p\n", j, device); 493 continue; 494 } 495 } 496 497 if (!device->enableStreaming()) { 498 debugWarning("Could not enable streaming on device %p!\n", device); 499 } 500 } 501 502 if(m_processorManager.start()) { 503 return true; 504 } else { 505 stopStreaming(); 506 return false; 507 } 508 } 509 510 bool 511 DeviceManager::resetStreaming() { 512 return true; 513 } 514 515 bool 516 DeviceManager::stopStreaming() 517 { 518 bool result = true; 519 m_processorManager.stop(); 520 521 // create the connections for all devices 522 // iterate over the found devices 523 // add the stream processors of the devices to the managers 524 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 525 it != m_avDevices.end(); 526 ++it ) 527 { 528 FFADODevice *device = *it; 529 assert(device); 530 531 if (!device->disableStreaming()) { 532 debugWarning("Could not disable streaming on device %p!\n", device); 533 } 534 535 int j=0; 536 for(j=0; j < device->getStreamCount(); j++) { 537 debugOutput(DEBUG_LEVEL_VERBOSE,"Stopping stream %d of device %p\n", j, device); 538 // stop the stream 539 // start the stream 540 if (!device->stopStreamByIndex(j)) { 541 debugWarning("Could not stop stream %d of device %p\n", j, device); 542 result = false; 543 continue; 544 } 545 } 546 } 547 return result; 548 } 549 550 bool 551 DeviceManager::waitForPeriod() { 552 if(m_processorManager.waitForPeriod()) { 553 return true; 554 } else { 555 debugWarning("XRUN detected\n"); 556 // do xrun recovery 557 m_processorManager.handleXrun(); 558 return false; 559 } 560 } 561 562 bool 563 DeviceManager::setStreamingParams(unsigned int period, unsigned int rate, unsigned int nb_buffers) { 564 m_processorManager.setPeriodSize(period); 565 m_processorManager.setNominalRate(rate); 566 m_processorManager.setNbBuffers(nb_buffers); 567 return true; 568 } 569 436 570 FFADODevice* 437 571 DeviceManager::getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ), … … 441 575 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying BeBoB...\n" ); 442 576 if ( BeBoB::AvDevice::probe( *configRom.get() ) ) { 443 return BeBoB::AvDevice::createDevice( configRom );577 return BeBoB::AvDevice::createDevice( *this, configRom ); 444 578 } 445 579 #endif … … 448 582 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Generic AV/C...\n" ); 449 583 if ( GenericAVC::AvDevice::probe( *configRom.get() ) ) { 450 return GenericAVC::AvDevice::createDevice( configRom );584 return GenericAVC::AvDevice::createDevice( *this, configRom ); 451 585 } 452 586 #endif … … 455 589 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying ECHO Audio FireWorks...\n" ); 456 590 if ( FireWorks::Device::probe( *configRom.get() ) ) { 457 return FireWorks::Device::createDevice( configRom );591 return FireWorks::Device::createDevice( *this, configRom ); 458 592 } 459 593 #endif … … 462 596 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying M-Audio...\n" ); 463 597 if ( MAudio::AvDevice::probe( *configRom.get() ) ) { 464 return MAudio::AvDevice::createDevice( configRom );598 return MAudio::AvDevice::createDevice( *this, configRom ); 465 599 } 466 600 #endif … … 469 603 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Motu...\n" ); 470 604 if ( Motu::MotuDevice::probe( *configRom.get() ) ) { 471 return Motu::MotuDevice::createDevice( configRom );605 return Motu::MotuDevice::createDevice( *this, configRom ); 472 606 } 473 607 #endif … … 476 610 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Dice...\n" ); 477 611 if ( Dice::DiceAvDevice::probe( *configRom.get() ) ) { 478 return Dice::DiceAvDevice::createDevice( configRom );612 return Dice::DiceAvDevice::createDevice( *this, configRom ); 479 613 } 480 614 #endif … … 483 617 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Metric Halo...\n" ); 484 618 if ( MetricHalo::MHAvDevice::probe( *configRom.get() ) ) { 485 return MetricHalo::MHAvDevice::createDevice( configRom );619 return MetricHalo::MHAvDevice::createDevice( *this, configRom ); 486 620 } 487 621 #endif … … 490 624 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying RME...\n" ); 491 625 if ( Rme::RmeDevice::probe( *configRom.get() ) ) { 492 return Rme::RmeDevice::createDevice( configRom );626 return Rme::RmeDevice::createDevice( *this, configRom ); 493 627 } 494 628 #endif … … 497 631 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Bounce...\n" ); 498 632 if ( Bounce::BounceDevice::probe( *configRom.get() ) ) { 499 return Bounce::BounceDevice::createDevice( configRom );633 return Bounce::BounceDevice::createDevice( *this, configRom ); 500 634 } 501 635 #endif … … 615 749 return true; 616 750 } 751 752 753 void 754 DeviceManager::setVerboseLevel(int l) 755 { 756 setDebugLevel(l); 757 Control::Element::setVerboseLevel(l); 758 m_processorManager.setVerboseLevel(l); 759 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 760 it != m_avDevices.end(); 761 ++it ) 762 { 763 (*it)->setVerboseLevel(l); 764 } 765 for ( Ieee1394ServiceVectorIterator it = m_1394Services.begin(); 766 it != m_1394Services.end(); 767 ++it ) 768 { 769 (*it)->setVerboseLevel(l); 770 } 771 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 772 } 773 774 void 775 DeviceManager::showDeviceInfo() { 776 debugOutput(DEBUG_LEVEL_NORMAL, "===== Device Manager =====\n"); 777 Control::Element::show(); 778 779 int i=0; 780 for ( Ieee1394ServiceVectorIterator it = m_1394Services.begin(); 781 it != m_1394Services.end(); 782 ++it ) 783 { 784 debugOutput(DEBUG_LEVEL_NORMAL, "--- IEEE1394 Service %2d ---\n", i++); 785 (*it)->show(); 786 } 787 788 i=0; 789 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 790 it != m_avDevices.end(); 791 ++it ) 792 { 793 FFADODevice* avDevice = *it; 794 debugOutput(DEBUG_LEVEL_NORMAL, "--- Device %2d ---\n", i++); 795 avDevice->showDevice(); 796 797 debugOutput(DEBUG_LEVEL_NORMAL, "Clock sync sources:\n"); 798 FFADODevice::ClockSourceVector sources=avDevice->getSupportedClockSources(); 799 for ( FFADODevice::ClockSourceVector::const_iterator it 800 = sources.begin(); 801 it != sources.end(); 802 ++it ) 803 { 804 FFADODevice::ClockSource c=*it; 805 debugOutput(DEBUG_LEVEL_NORMAL, " Type: %s, Id: %2d, Valid: %1d, Active: %1d, Locked %1d, Slipping: %1d, Description: %s\n", 806 FFADODevice::ClockSourceTypeToString(c.type), c.id, c.valid, c.active, c.locked, c.slipping, c.description.c_str()); 807 } 808 } 809 } 810 void 811 DeviceManager::showStreamingInfo() { 812 m_processorManager.dumpInfo(); 813 } trunk/libffado/src/devicemanager.h
r742 r750 31 31 #include "libieee1394/ieee1394service.h" 32 32 33 #include "libstreaming/StreamProcessorManager.h" 34 33 35 #include "libutil/OptionContainer.h" 34 36 #include "libcontrol/BasicElements.h" … … 62 64 ~DeviceManager(); 63 65 66 bool setThreadParameters(bool rt, int priority); 67 64 68 bool initialize(); 65 69 bool deinitialize(); … … 69 73 70 74 bool discover(); 75 bool initStreaming(); 76 bool prepareStreaming(); 77 bool finishStreaming(); 78 bool startStreaming(); 79 bool stopStreaming(); 80 bool resetStreaming(); 81 bool waitForPeriod(); 82 bool setStreamingParams(unsigned int period, unsigned int rate, unsigned int nb_buffers); 71 83 72 84 bool isValidNode( int node ); … … 80 92 Streaming::StreamProcessor *getSyncSource(); 81 93 82 void show(); 94 void showDeviceInfo(); 95 void showStreamingInfo(); 83 96 84 97 // the Control::Container functions … … 102 115 FunctorVector m_busreset_functors; 103 116 117 public: // FIXME: this should be better 118 Streaming::StreamProcessorManager& getStreamProcessorManager() 119 {return m_processorManager;}; 120 private: 121 Streaming::StreamProcessorManager m_processorManager; 122 protected: 104 123 std::vector<std::string> m_SpecStrings; 124 125 bool m_thread_realtime; 126 int m_thread_priority; 105 127 106 128 // debug stuff trunk/libffado/src/dice/dice_avdevice.cpp
r748 r750 52 52 }; 53 53 54 DiceAvDevice::DiceAvDevice( std::auto_ptr<ConfigRom>( configRom ))55 : FFADODevice( configRom )54 DiceAvDevice::DiceAvDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 55 : FFADODevice( d, configRom ) 56 56 , m_model( NULL ) 57 57 , m_global_reg_offset (0xFFFFFFFFLU) … … 107 107 108 108 FFADODevice * 109 DiceAvDevice::createDevice( std::auto_ptr<ConfigRom>( configRom ))109 DiceAvDevice::createDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 110 110 { 111 return new DiceAvDevice( configRom );111 return new DiceAvDevice( d, configRom ); 112 112 } 113 113 trunk/libffado/src/dice/dice_avdevice.h
r745 r750 57 57 class DiceNotifier; 58 58 public: 59 DiceAvDevice( std::auto_ptr<ConfigRom>( configRom ));59 DiceAvDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 60 60 ~DiceAvDevice(); 61 61 62 62 static bool probe( ConfigRom& configRom ); 63 static FFADODevice * createDevice( std::auto_ptr<ConfigRom>( configRom ));63 static FFADODevice * createDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 64 64 virtual bool discover(); 65 65 trunk/libffado/src/ffado.cpp
r742 r750 30 30 31 31 #include "../libffado/ffado.h" 32 #include "libstreaming/generic/StreamProcessor.h" 33 #include "libstreaming/generic/Port.h" 32 34 33 35 #include "debugmodule/debugmodule.h" … … 35 37 #include "devicemanager.h" 36 38 #include "ffadodevice.h" 37 #include "libstreaming/StreamProcessorManager.h"38 39 39 40 #include <stdio.h> … … 82 83 } 83 84 84 85 using namespace Streaming;86 87 85 struct _ffado_device 88 86 { 89 87 DeviceManager * m_deviceManager; 90 StreamProcessorManager *processorManager;91 88 92 89 ffado_options_t options; … … 117 114 118 115 dev->m_deviceManager->setVerboseLevel(dev->options.verbose); 119 if ( !dev->m_deviceManager->initialize() ) { 120 debugFatal( "Could not initialize device manager\n" ); 121 delete dev->m_deviceManager; 122 delete dev; 123 return 0; 124 } 116 dev->m_deviceManager->setThreadParameters(dev->options.realtime, dev->options.packetizer_priority); 125 117 126 118 for (i = 0; i < device_info.nb_device_spec_strings; i++) { … … 133 125 } 134 126 } 135 136 137 127 // create a processor manager to manage the actual stream 138 128 // processors 139 dev->processorManager = new StreamProcessorManager( dev->options.period_size, 140 dev->options.sample_rate, 141 dev->options.nb_buffers); 142 if(!dev->processorManager) { 143 debugFatal("Could not create StreamProcessorManager\n"); 144 delete dev->m_deviceManager; 145 delete dev; 146 return 0; 147 } 148 149 dev->processorManager->setThreadParameters(dev->options.realtime, dev->options.packetizer_priority); 150 151 dev->processorManager->setVerboseLevel(dev->options.verbose); 152 if(!dev->processorManager->init()) { 153 debugFatal("Could not init StreamProcessorManager\n"); 154 delete dev->processorManager; 155 delete dev->m_deviceManager; 156 delete dev; 157 return 0; 129 if ( !dev->m_deviceManager->setStreamingParams(dev->options.period_size, 130 dev->options.sample_rate, 131 dev->options.nb_buffers)) 132 { 133 debugFatal( "Could not set streaming parameters of device manager\n" ); 134 delete dev->m_deviceManager; 135 delete dev; 136 return 0; 158 137 } 159 138 … … 171 150 } 172 151 152 if ( !dev->m_deviceManager->initialize() ) { 153 debugFatal( "Could not initialize device manager\n" ); 154 delete dev->m_deviceManager; 155 delete dev; 156 return 0; 157 } 173 158 // discover the devices on the bus 174 159 if(!dev->m_deviceManager->discover()) { 175 debugFatal("Could not discover devices\n"); 176 delete dev->processorManager; 177 delete dev->m_deviceManager; 178 delete dev; 179 return 0; 180 } 181 160 debugFatal("Could not discover devices\n"); 161 delete dev->m_deviceManager; 162 delete dev; 163 return 0; 164 } 182 165 // are there devices on the bus? 183 if(dev->m_deviceManager->getAvDeviceCount()==0) { 184 debugFatal("There are no devices on the bus\n"); 185 delete dev->processorManager; 186 delete dev->m_deviceManager; 187 delete dev; 188 return 0; 189 } 190 191 // iterate over the found devices 192 // add the stream processors of the devices to the managers 193 for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 194 FFADODevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 195 assert(device); 196 197 debugOutput(DEBUG_LEVEL_VERBOSE, "Locking device (%p)\n", device); 198 199 if (!device->lock()) { 200 debugWarning("Could not lock device, skipping device (%p)!\n", device); 201 continue; 202 } 203 204 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting samplerate to %d for (%p)\n", 205 dev->options.sample_rate, device); 206 207 // Set the device's sampling rate to that requested 208 // FIXME: does this really belong here? If so we need to handle errors. 209 if (!device->setSamplingFrequency(dev->options.sample_rate)) { 210 debugOutput(DEBUG_LEVEL_VERBOSE, " => Retry setting samplerate to %d for (%p)\n", 211 dev->options.sample_rate, device); 212 213 // try again: 214 if (!device->setSamplingFrequency(dev->options.sample_rate)) { 215 delete dev->processorManager; 216 delete dev->m_deviceManager; 217 delete dev; 218 debugFatal("Could not set sampling frequency to %d\n",dev->options.sample_rate); 219 return 0; 220 } 221 } 222 223 // prepare the device 224 device->prepare(); 225 int j=0; 226 for(j=0; j<device->getStreamCount();j++) { 227 StreamProcessor *streamproc=device->getStreamProcessorByIndex(j); 228 debugOutput(DEBUG_LEVEL_VERBOSE, "Registering stream processor %d of device %d with processormanager\n",j,i); 229 if (!dev->processorManager->registerProcessor(streamproc)) { 230 delete dev->processorManager; 231 delete dev->m_deviceManager; 232 delete dev; 233 debugFatal("Could not register stream processor (%p) with the Processor manager\n", streamproc); 234 return 0; 235 } 236 } 237 } 238 239 // set the sync source 240 if (!dev->processorManager->setSyncSource(dev->m_deviceManager->getSyncSource())) { 241 debugWarning("Could not set processorManager sync source (%p)\n", 242 dev->m_deviceManager->getSyncSource()); 243 } 244 166 if(dev->m_deviceManager->getAvDeviceCount() == 0) { 167 debugFatal("There are no devices on the bus\n"); 168 delete dev->m_deviceManager; 169 delete dev; 170 return 0; 171 } 172 // prepare here or there are no ports for jack 173 if(!dev->m_deviceManager->initStreaming()) { 174 debugFatal("Could not init the streaming system\n"); 175 return 0; 176 } 245 177 // we are ready! 246 debugOutputShort(DEBUG_LEVEL_VERBOSE, "\n\n");247 178 return dev; 248 249 179 } 250 180 251 181 int ffado_streaming_prepare(ffado_device_t *dev) { 252 182 debugOutput(DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 253 254 if (!dev->processorManager->prepare()) { 255 debugFatal("Could not prepare streaming...\n"); 256 return false; 257 } 258 259 return true; 183 // prepare here or there are no ports for jack 184 if(!dev->m_deviceManager->prepareStreaming()) { 185 debugFatal("Could not prepare the streaming system\n"); 186 return 0; 187 } 188 return 0; 260 189 } 261 190 262 191 void ffado_streaming_finish(ffado_device_t *dev) { 263 unsigned int i=0;264 265 192 assert(dev); 266 267 // iterate over the found devices 268 for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 269 FFADODevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 270 assert(device); 271 272 debugOutput(DEBUG_LEVEL_VERBOSE, "Unlocking device (%p)\n", device); 273 274 if (!device->unlock()) { 275 debugWarning("Could not unlock device (%p)!\n", device); 276 } 277 } 278 279 delete dev->processorManager; 193 if(!dev->m_deviceManager->finishStreaming()) { 194 debugError("Could not finish the streaming\n"); 195 } 280 196 delete dev->m_deviceManager; 281 197 delete dev; 282 283 198 return; 284 199 } 285 200 286 201 int ffado_streaming_start(ffado_device_t *dev) { 287 unsigned int i=0;288 202 debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Start -------------\n"); 289 290 // create the connections for all devices 291 // iterate over the found devices 292 // add the stream processors of the devices to the managers 293 for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 294 FFADODevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 295 assert(device); 296 297 int j=0; 298 for(j=0; j<device->getStreamCount();j++) { 299 debugOutput(DEBUG_LEVEL_VERBOSE,"Starting stream %d of device %d\n",j,i); 300 // start the stream 301 if (!device->startStreamByIndex(j)) { 302 debugWarning("Could not start stream %d of device %d\n",j,i); 303 continue; 304 } 305 } 306 307 if (!device->enableStreaming()) { 308 debugWarning("Could not enable streaming on device %d!\n",i); 309 } 310 } 311 312 if(dev->processorManager->start()) { 313 return 0; 314 } else { 315 ffado_streaming_stop(dev); 316 return -1; 317 } 203 if(!dev->m_deviceManager->startStreaming()) { 204 debugFatal("Could not start the streaming system\n"); 205 return -1; 206 } 207 return 0; 318 208 } 319 209 320 210 int ffado_streaming_stop(ffado_device_t *dev) { 321 unsigned int i;322 211 debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Stop -------------\n"); 323 324 dev->processorManager->stop(); 325 326 // create the connections for all devices 327 // iterate over the found devices 328 // add the stream processors of the devices to the managers 329 for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 330 FFADODevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 331 assert(device); 332 333 if (!device->disableStreaming()) { 334 debugWarning("Could not disable streaming on device %d!\n",i); 335 } 336 337 int j=0; 338 for(j=0; j<device->getStreamCount();j++) { 339 debugOutput(DEBUG_LEVEL_VERBOSE,"Stopping stream %d of device %d\n",j,i); 340 // stop the stream 341 // start the stream 342 if (!device->stopStreamByIndex(j)) { 343 debugWarning("Could not stop stream %d of device %d\n",j,i); 344 continue; 345 } 346 } 347 } 348 212 if(!dev->m_deviceManager->stopStreaming()) { 213 debugFatal("Could not stop the streaming system\n"); 214 return -1; 215 } 349 216 return 0; 350 217 } … … 352 219 int ffado_streaming_reset(ffado_device_t *dev) { 353 220 debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Reset -------------\n"); 354 355 // dev->processorManager->reset(); 356 221 if(!dev->m_deviceManager->resetStreaming()) { 222 debugFatal("Could not reset the streaming system\n"); 223 return -1; 224 } 357 225 return 0; 358 226 } … … 367 235 debugOutputShort(DEBUG_LEVEL_VERBOSE, "\nffado_streaming_wait\n"); 368 236 debugOutputShort(DEBUG_LEVEL_VERBOSE, "============================================\n"); 369 debugOutputShort(DEBUG_LEVEL_VERBOSE, "Xruns: %d\n", xruns);237 debugOutputShort(DEBUG_LEVEL_VERBOSE, "Xruns: %d\n", xruns); 370 238 debugOutputShort(DEBUG_LEVEL_VERBOSE, "============================================\n"); 371 dev-> processorManager->dumpInfo();239 dev->m_deviceManager->showStreamingInfo(); 372 240 debugOutputShort(DEBUG_LEVEL_VERBOSE, "\n"); 373 241 periods_print+=100; 374 242 } 375 243 376 if(dev-> processorManager->waitForPeriod()) {244 if(dev->m_deviceManager->waitForPeriod()) { 377 245 return dev->options.period_size; 378 246 } else { 379 debugWarning("XRUN detected\n");380 381 // do xrun recovery382 dev->processorManager->handleXrun();383 247 xruns++; 384 248 return -1; … … 387 251 388 252 int ffado_streaming_transfer_capture_buffers(ffado_device_t *dev) { 389 return dev-> processorManager->transfer(StreamProcessor::ePT_Receive);253 return dev->m_deviceManager->getStreamProcessorManager().transfer(Streaming::StreamProcessor::ePT_Receive); 390 254 } 391 255 392 256 int ffado_streaming_transfer_playback_buffers(ffado_device_t *dev) { 393 return dev-> processorManager->transfer(StreamProcessor::ePT_Transmit);257 return dev->m_deviceManager->getStreamProcessorManager().transfer(Streaming::StreamProcessor::ePT_Transmit); 394 258 } 395 259 396 260 int ffado_streaming_transfer_buffers(ffado_device_t *dev) { 397 return dev-> processorManager->transfer();261 return dev->m_deviceManager->getStreamProcessorManager().transfer(); 398 262 } 399 263 400 264 401 265 int ffado_streaming_write(ffado_device_t *dev, int i, ffado_sample_t *buffer, int nsamples) { 402 Port *p=dev->processorManager->getPortByIndex(i,Port::E_Playback);266 Streaming::Port *p = dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, Streaming::Port::E_Playback); 403 267 // use an assert here performancewise, 404 268 // it should already have failed before, if not correct … … 409 273 410 274 int ffado_streaming_read(ffado_device_t *dev, int i, ffado_sample_t *buffer, int nsamples) { 411 Port *p=dev->processorManager->getPortByIndex(i,Port::E_Capture);275 Streaming::Port *p=dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, Streaming::Port::E_Capture); 412 276 // use an assert here performancewise, 413 277 // it should already have failed before, if not correct … … 418 282 419 283 int ffado_streaming_get_nb_capture_streams(ffado_device_t *dev) { 420 return dev-> processorManager->getPortCount(Port::E_Capture);284 return dev->m_deviceManager->getStreamProcessorManager().getPortCount(Streaming::Port::E_Capture); 421 285 } 422 286 423 287 int ffado_streaming_get_nb_playback_streams(ffado_device_t *dev) { 424 return dev-> processorManager->getPortCount(Port::E_Playback);288 return dev->m_deviceManager->getStreamProcessorManager().getPortCount(Streaming::Port::E_Playback); 425 289 } 426 290 427 291 int ffado_streaming_get_capture_stream_name(ffado_device_t *dev, int i, char* buffer, size_t buffersize) { 428 Port *p=dev->processorManager->getPortByIndex(i,Port::E_Capture);292 Streaming::Port *p = dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, Streaming::Port::E_Capture); 429 293 if(!p) { 430 294 debugWarning("Could not get capture port at index %d\n",i); … … 440 304 441 305 int ffado_streaming_get_playback_stream_name(ffado_device_t *dev, int i, char* buffer, size_t buffersize) { 442 Port *p=dev->processorManager->getPortByIndex(i,Port::E_Playback);306 Streaming::Port *p = dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, Streaming::Port::E_Playback); 443 307 if(!p) { 444 308 debugWarning("Could not get playback port at index %d\n",i); … … 454 318 455 319 ffado_streaming_stream_type ffado_streaming_get_capture_stream_type(ffado_device_t *dev, int i) { 456 Port *p=dev->processorManager->getPortByIndex(i,Port::E_Capture);320 Streaming::Port *p = dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, Streaming::Port::E_Capture); 457 321 if(!p) { 458 322 debugWarning("Could not get capture port at index %d\n",i); … … 460 324 } 461 325 switch(p->getPortType()) { 462 case Port::E_Audio:326 case Streaming::Port::E_Audio: 463 327 return ffado_stream_type_audio; 464 case Port::E_Midi:328 case Streaming::Port::E_Midi: 465 329 return ffado_stream_type_midi; 466 case Port::E_Control:330 case Streaming::Port::E_Control: 467 331 return ffado_stream_type_control; 468 332 default: … … 472 336 473 337 ffado_streaming_stream_type ffado_streaming_get_playback_stream_type(ffado_device_t *dev, int i) { 474 Port *p=dev->processorManager->getPortByIndex(i,Port::E_Playback);338 Streaming::Port *p = dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, Streaming::Port::E_Playback); 475 339 if(!p) { 476 340 debugWarning("Could not get playback port at index %d\n",i); … … 478 342 } 479 343 switch(p->getPortType()) { 480 case Port::E_Audio:344 case Streaming::Port::E_Audio: 481 345 return ffado_stream_type_audio; 482 case Port::E_Midi:346 case Streaming::Port::E_Midi: 483 347 return ffado_stream_type_midi; 484 case Port::E_Control:348 case Streaming::Port::E_Control: 485 349 return ffado_stream_type_control; 486 350 default: … … 490 354 491 355 int ffado_streaming_set_stream_buffer_type(ffado_device_t *dev, int i, 492 ffado_streaming_buffer_type t, enum Port::E_Direction direction) {493 494 Port *p=dev->processorManager->getPortByIndex(i, direction);356 ffado_streaming_buffer_type t, enum Streaming::Port::E_Direction direction) { 357 358 Streaming::Port *p = dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, direction); 495 359 if(!p) { 496 360 debugWarning("Could not get %s port at index %d\n", 497 (direction== Port::E_Playback?"Playback":"Capture"),i);361 (direction==Streaming::Port::E_Playback?"Playback":"Capture"),i); 498 362 return -1; 499 363 } … … 501 365 switch(t) { 502 366 case ffado_buffer_type_int24: 503 if (!p->setDataType( Port::E_Int24)) {367 if (!p->setDataType(Streaming::Port::E_Int24)) { 504 368 debugWarning("%s: Could not set data type to Int24\n",p->getName().c_str()); 505 369 return -1; 506 370 } 507 if (!p->setBufferType( Port::E_PointerBuffer)) {371 if (!p->setBufferType(Streaming::Port::E_PointerBuffer)) { 508 372 debugWarning("%s: Could not set buffer type to Pointerbuffer\n",p->getName().c_str()); 509 373 return -1; … … 511 375 break; 512 376 case ffado_buffer_type_float: 513 if (!p->setDataType( Port::E_Float)) {377 if (!p->setDataType(Streaming::Port::E_Float)) { 514 378 debugWarning("%s: Could not set data type to Float\n",p->getName().c_str()); 515 379 return -1; 516 380 } 517 if (!p->setBufferType( Port::E_PointerBuffer)) {381 if (!p->setBufferType(Streaming::Port::E_PointerBuffer)) { 518 382 debugWarning("%s: Could not set buffer type to Pointerbuffer\n",p->getName().c_str()); 519 383 return -1; … … 521 385 break; 522 386 case ffado_buffer_type_midi: 523 if (!p->setDataType( Port::E_MidiEvent)) {387 if (!p->setDataType(Streaming::Port::E_MidiEvent)) { 524 388 debugWarning("%s: Could not set data type to MidiEvent\n",p->getName().c_str()); 525 389 return -1; 526 390 } 527 if (!p->setBufferType( Port::E_RingBuffer)) {391 if (!p->setBufferType(Streaming::Port::E_RingBuffer)) { 528 392 debugWarning("%s: Could not set buffer type to Ringbuffer\n",p->getName().c_str()); 529 393 return -1; … … 539 403 540 404 int ffado_streaming_set_playback_buffer_type(ffado_device_t *dev, int i, ffado_streaming_buffer_type t) { 541 return ffado_streaming_set_stream_buffer_type(dev, i, t, Port::E_Playback);405 return ffado_streaming_set_stream_buffer_type(dev, i, t, Streaming::Port::E_Playback); 542 406 } 543 407 544 408 int ffado_streaming_set_capture_buffer_type(ffado_device_t *dev, int i, ffado_streaming_buffer_type t) { 545 return ffado_streaming_set_stream_buffer_type(dev, i, t, Port::E_Capture);409 return ffado_streaming_set_stream_buffer_type(dev, i, t, Streaming::Port::E_Capture); 546 410 } 547 411 548 412 int ffado_streaming_stream_onoff(ffado_device_t *dev, int i, 549 int on, enum Port::E_Direction direction) {550 Port *p=dev->processorManager->getPortByIndex(i, direction);413 int on, enum Streaming::Port::E_Direction direction) { 414 Streaming::Port *p = dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, direction); 551 415 if(!p) { 552 416 debugWarning("Could not get %s port at index %d\n", 553 (direction== Port::E_Playback?"Playback":"Capture"),i);417 (direction==Streaming::Port::E_Playback?"Playback":"Capture"),i); 554 418 return -1; 555 419 } … … 563 427 564 428 int ffado_streaming_playback_stream_onoff(ffado_device_t *dev, int number, int on) { 565 return ffado_streaming_stream_onoff(dev, number, on, Port::E_Playback);429 return ffado_streaming_stream_onoff(dev, number, on, Streaming::Port::E_Playback); 566 430 } 567 431 568 432 int ffado_streaming_capture_stream_onoff(ffado_device_t *dev, int number, int on) { 569 return ffado_streaming_stream_onoff(dev, number, on, Port::E_Capture);433 return ffado_streaming_stream_onoff(dev, number, on, Streaming::Port::E_Capture); 570 434 } 571 435 572 436 // TODO: the way port buffers are set in the C api doesn't satisfy me 573 437 int ffado_streaming_set_capture_stream_buffer(ffado_device_t *dev, int i, char *buff) { 574 Port *p=dev->processorManager->getPortByIndex(i,Port::E_Capture);438 Streaming::Port *p = dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, Streaming::Port::E_Capture); 575 439 576 440 // use an assert here performancewise, … … 586 450 587 451 int ffado_streaming_set_playback_stream_buffer(ffado_device_t *dev, int i, char *buff) { 588 Port *p=dev->processorManager->getPortByIndex(i,Port::E_Playback);452 Streaming::Port *p = dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, Streaming::Port::E_Playback); 589 453 // use an assert here performancewise, 590 454 // it should already have failed before, if not correct trunk/libffado/src/ffadodevice.cpp
r745 r750 35 35 IMPL_DEBUG_MODULE( FFADODevice, FFADODevice, DEBUG_LEVEL_NORMAL ); 36 36 37 FFADODevice::FFADODevice( std::auto_ptr<ConfigRom>( configRom ))37 FFADODevice::FFADODevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ) ) 38 38 : Control::Container() 39 , m_pDeviceManager( d ) 39 40 , m_pConfigRom( configRom ) 40 41 { trunk/libffado/src/ffadodevice.h
r745 r750 34 34 #include <string> 35 35 36 class DeviceManager; 36 37 class ConfigRom; 37 38 class Ieee1394Service; … … 39 40 namespace Streaming { 40 41 class StreamProcessor; 42 class StreamProcessorManager; 41 43 } 42 44 … … 53 55 { 54 56 public: 55 FFADODevice( std::auto_ptr< ConfigRom >( configRom ) );57 FFADODevice( DeviceManager&, std::auto_ptr< ConfigRom >( configRom ) ); 56 58 57 59 virtual ~FFADODevice(); … … 418 420 { return false; }; 419 421 420 422 DeviceManager& getDeviceManager() 423 {return m_pDeviceManager;}; 421 424 private: 422 425 std::auto_ptr<ConfigRom>( m_pConfigRom ); 426 DeviceManager& m_pDeviceManager; 423 427 protected: 424 428 DECLARE_DEBUG_MODULE; trunk/libffado/src/fireworks/audiofire/audiofire_device.cpp
r742 r750 30 30 namespace ECHO { 31 31 32 AudioFire::AudioFire( std::auto_ptr<ConfigRom>( configRom ))33 : FireWorks::Device( configRom)32 AudioFire::AudioFire( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 33 : FireWorks::Device( d, configRom) 34 34 { 35 35 debugOutput( DEBUG_LEVEL_VERBOSE, "Created FireWorks::ECHO::AudioFire (NodeID %d)\n", trunk/libffado/src/fireworks/audiofire/audiofire_device.h
r742 r750 35 35 36 36 public: 37 AudioFire( std::auto_ptr<ConfigRom>( configRom ));37 AudioFire( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 38 38 virtual ~AudioFire(); 39 39 trunk/libffado/src/fireworks/fireworks_device.cpp
r745 r750 43 43 namespace FireWorks { 44 44 45 Device::Device( std::auto_ptr<ConfigRom>( configRom ))46 : GenericAVC::AvDevice( configRom)45 Device::Device(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 46 : GenericAVC::AvDevice( d, configRom) 47 47 , m_efc_discovery_done ( false ) 48 48 , m_MixerContainer ( NULL ) … … 146 146 147 147 FFADODevice * 148 Device::createDevice( std::auto_ptr<ConfigRom>( configRom ))148 Device::createDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 149 149 { 150 150 unsigned int vendorId = configRom->getNodeVendorId(); … … 152 152 153 153 switch(vendorId) { 154 case FW_VENDORID_ECHO: return new ECHO::AudioFire( configRom );155 default: return new Device( configRom );154 case FW_VENDORID_ECHO: return new ECHO::AudioFire(d, configRom ); 155 default: return new Device(d, configRom ); 156 156 } 157 157 } trunk/libffado/src/fireworks/fireworks_device.h
r742 r750 42 42 class Device : public GenericAVC::AvDevice { 43 43 public: 44 Device( std::auto_ptr<ConfigRom>( configRom ));44 Device( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ) ); 45 45 virtual ~Device(); 46 46 47 47 static bool probe( ConfigRom& configRom ); 48 static FFADODevice * createDevice( std::auto_ptr<ConfigRom>( configRom ));48 static FFADODevice * createDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 49 49 virtual bool discover(); 50 50 trunk/libffado/src/genericavc/avc_avdevice.cpp
r748 r750 51 51 IMPL_DEBUG_MODULE( AvDevice, AvDevice, DEBUG_LEVEL_NORMAL ); 52 52 53 AvDevice::AvDevice( std::auto_ptr<ConfigRom>( configRom ))54 : FFADODevice( configRom )53 AvDevice::AvDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 54 : FFADODevice( d, configRom ) 55 55 { 56 56 debugOutput( DEBUG_LEVEL_VERBOSE, "Created GenericAVC::AvDevice (NodeID %d)\n", … … 74 74 75 75 FFADODevice * 76 AvDevice::createDevice( std::auto_ptr<ConfigRom>( configRom ))77 { 78 return new AvDevice( configRom );76 AvDevice::createDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 77 { 78 return new AvDevice(d, configRom ); 79 79 } 80 80 … … 418 418 return false; 419 419 } 420 p =new Streaming::AmdtpReceiveStreamProcessor(*this,420 p = new Streaming::AmdtpReceiveStreamProcessor(*this, 421 421 outputPlug->getNrOfChannels()); 422 422 trunk/libffado/src/genericavc/avc_avdevice.h
r742 r750 48 48 class AvDevice : public FFADODevice, public AVC::Unit { 49 49 public: 50 AvDevice( std::auto_ptr<ConfigRom>( configRom ));50 AvDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 51 51 virtual ~AvDevice() {}; 52 52 53 53 static bool probe( ConfigRom& configRom ); 54 54 virtual bool discover(); 55 static FFADODevice * createDevice( std::auto_ptr<ConfigRom>( configRom ));55 static FFADODevice * createDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 56 56 57 57 virtual bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; trunk/libffado/src/libieee1394/ieee1394service.cpp
r748 r750 26 26 #include "ARMHandler.h" 27 27 #include "cycletimer.h" 28 #include "IsoHandlerManager.h" 28 29 29 30 #include <libavc1394/avc1394.h> … … 39 40 #include <iomanip> 40 41 41 #define FFADO_MAX_FIREWIRE_PORTS 842 #define FFADO_MAX_FIREWIRE_PORTS 16 42 43 43 44 IMPL_DEBUG_MODULE( Ieee1394Service, Ieee1394Service, DEBUG_LEVEL_NORMAL ); … … 47 48 , m_port( -1 ) 48 49 , m_threadRunning( false ) 50 , m_isoManager( new IsoHandlerManager( *this ) ) 49 51 { 50 52 pthread_mutex_init( &m_mutex, 0 ); … … 63 65 Ieee1394Service::~Ieee1394Service() 64 66 { 67 delete m_isoManager; 65 68 stopRHThread(); 66 69 for ( arm_handler_vec_t::iterator it = m_armHandlers.begin(); … … 79 82 raw1394_destroy_handle( m_handle ); 80 83 } 81 82 84 if ( m_resetHandle ) { 83 85 raw1394_destroy_handle( m_resetHandle ); … … 148 150 } 149 151 152 // test the cycle timer read function 153 int err; 154 uint32_t cycle_timer; 155 uint64_t local_time; 156 err=raw1394_read_cycle_timer(m_handle, &cycle_timer, &local_time); 157 if(err) { 158 debugError("raw1394_read_cycle_timer failed.\n"); 159 debugError(" Error: %s\n", strerror(err)); 160 debugError(" Your system doesn't seem to support the raw1394_read_cycle_timer call\n"); 161 return false; 162 } 163 150 164 m_port = port; 151 165 152 166 // obtain port name 167 raw1394handle_t tmp_handle = raw1394_new_handle(); 168 if ( tmp_handle == NULL ) { 169 debugError("Could not get temporaty libraw1394 handle.\n"); 170 return false; 171 } 153 172 struct raw1394_portinfo pinf[FFADO_MAX_FIREWIRE_PORTS]; 154 int nb_detected_ports = raw1394_get_port_info(m_handle, pinf, FFADO_MAX_FIREWIRE_PORTS); 173 int nb_detected_ports = raw1394_get_port_info(tmp_handle, pinf, FFADO_MAX_FIREWIRE_PORTS); 174 raw1394_destroy_handle(tmp_handle); 175 176 if (nb_detected_ports < 0) { 177 debugError("Failed to detect number of ports\n"); 178 return false; 179 } 155 180 156 181 if(nb_detected_ports && port < FFADO_MAX_FIREWIRE_PORTS) { … … 165 190 raw1394_set_userdata( m_handle, this ); 166 191 raw1394_set_userdata( m_resetHandle, this ); 192 raw1394_set_userdata( m_rtHandle, this ); 167 193 raw1394_set_bus_reset_handler( m_resetHandle, 168 194 this->resetHandlerLowLevel ); … … 171 197 this->armHandlerLowLevel ); 172 198 199 if(!m_isoManager) { 200 debugFatal("No IsoHandlerManager available, bad!\n"); 201 return false; 202 } 203 m_isoManager->setVerboseLevel(getDebugLevel()); 204 if(!m_isoManager->init()) { 205 debugFatal("Could not initialize IsoHandlerManager\n"); 206 return false; 207 } 208 173 209 startRHThread(); 174 175 210 return true; 211 } 212 213 bool 214 Ieee1394Service::setThreadParameters(bool rt, int priority) { 215 if (m_isoManager) { 216 return m_isoManager->setThreadParameters(rt, priority); 217 } else { 218 return true; 219 } 176 220 } 177 221 … … 930 974 Ieee1394Service::setVerboseLevel(int l) 931 975 { 976 if (m_isoManager) m_isoManager->setVerboseLevel(l); 977 setDebugLevel(l); 932 978 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 933 setDebugLevel(l);934 979 } 935 980 … … 939 984 debugOutput( DEBUG_LEVEL_VERBOSE, "Port: %d\n", getPort() ); 940 985 debugOutput( DEBUG_LEVEL_VERBOSE, " Name: %s\n", getPortName().c_str() ); 941 } 986 debugOutputShort( DEBUG_LEVEL_NORMAL, "Iso handler info:\n"); 987 if (m_isoManager) m_isoManager->dumpInfo(); 988 } trunk/libffado/src/libieee1394/ieee1394service.h
r748 r750 40 40 41 41 class ARMHandler; 42 class IsoHandlerManager; 42 43 43 44 class Ieee1394Service : public IEC61883 { … … 47 48 48 49 bool initialize( int port ); 49 50 bool setThreadParameters(bool rt, int priority); 50 51 /** 51 52 * @brief get number of ports (firewire adapters) in this machine … … 220 221 bool freeIsoChannel(signed int channel); 221 222 223 IsoHandlerManager& getIsoHandlerManager() {return *m_isoManager;}; 222 224 private: 223 225 enum EAllocType { … … 273 275 bool m_threadRunning; 274 276 277 IsoHandlerManager* m_isoManager; 278 275 279 typedef std::vector< Functor* > reset_handler_vec_t; 276 280 reset_handler_vec_t m_busResetHandlers; trunk/libffado/src/libieee1394/IsoHandler.cpp
r748 r750 23 23 24 24 #include "IsoHandler.h" 25 #include "../generic/StreamProcessor.h" 26 27 #include "libutil/TimeSource.h" 28 #include "libutil/SystemTimeSource.h" 25 #include "ieee1394service.h" 26 27 #include "libstreaming/generic/StreamProcessor.h" 29 28 30 29 #include <errno.h> … … 36 35 #include <iostream> 37 36 using namespace std; 38 39 namespace Streaming 40 { 37 using namespace Streaming; 41 38 42 39 IMPL_DEBUG_MODULE( IsoHandler, IsoHandler, DEBUG_LEVEL_NORMAL ); … … 78 75 79 76 /* Base class implementation */ 80 IsoHandler::IsoHandler(int port) 81 : m_handle(0), m_handle_util(0), m_port(port), 82 m_buf_packets(400), m_max_packet_size(1024), m_irq_interval(-1), 83 m_packetcount(0), m_dropped(0), m_Client(0), 84 m_State(E_Created) 85 { 86 } 87 88 IsoHandler::IsoHandler(int port, unsigned int buf_packets, unsigned int max_packet_size, int irq) 89 : m_handle(0), m_port(port), 90 m_buf_packets(buf_packets), m_max_packet_size( max_packet_size), 91 m_irq_interval(irq), 92 m_packetcount(0), m_dropped(0), m_Client(0), 93 m_State(E_Created) 77 IsoHandler::IsoHandler(IsoHandlerManager& manager) 78 : m_manager(manager) 79 , m_handle(0) 80 , m_buf_packets(400) 81 , m_max_packet_size(1024) 82 , m_irq_interval(-1) 83 , m_packetcount(0) 84 , m_dropped(0) 85 , m_Client(0) 86 , m_State(E_Created) 87 { 88 } 89 90 IsoHandler::IsoHandler(IsoHandlerManager& manager, unsigned int buf_packets, unsigned int max_packet_size, int irq) 91 : m_manager(manager) 92 , m_handle(0) 93 , m_buf_packets(buf_packets) 94 , m_max_packet_size( max_packet_size) 95 , m_irq_interval(irq) 96 , m_packetcount(0) 97 , m_dropped(0) 98 , m_Client(0) 99 , m_State(E_Created) 94 100 { 95 101 } … … 102 108 // raw1394_destroy_handle() will do any iso system shutdown required. 103 109 // raw1394_iso_shutdown(m_handle); 104 105 110 if(m_handle) { 106 111 if (m_State == E_Running) { 107 stop(); 108 } 109 112 disable(); 113 } 110 114 raw1394_destroy_handle(m_handle); 111 115 } 112 113 if(m_handle_util) raw1394_destroy_handle(m_handle_util);114 115 116 } 116 117 … … 136 137 { 137 138 debugOutput( DEBUG_LEVEL_VERBOSE, "IsoHandler (%p) enter...\n",this); 138 139 139 // check the state 140 140 if(m_State != E_Created) { … … 144 144 145 145 // the main handle for the ISO traffic 146 m_handle = raw1394_new_handle_on_port( m_ port);146 m_handle = raw1394_new_handle_on_port( m_manager.get1394Service().getPort() ); 147 147 if ( !m_handle ) { 148 148 if ( !errno ) { … … 155 155 } 156 156 raw1394_set_userdata(m_handle, static_cast<void *>(this)); 157 158 // a second handle for utility stuff159 m_handle_util = raw1394_new_handle_on_port( m_port );160 if ( !m_handle_util ) {161 if ( !errno ) {162 debugError("libraw1394 not compatible\n");163 } else {164 debugError("Could not get 1394 handle: %s\n", strerror(errno) );165 debugError("Are ieee1394 and raw1394 drivers loaded?\n");166 }167 168 raw1394_destroy_handle(m_handle);169 return false;170 }171 raw1394_set_userdata(m_handle_util, static_cast<void *>(this));172 157 173 158 // bus reset handling … … 181 166 } 182 167 183 // test the cycle timer read function184 int err;185 uint32_t cycle_timer;186 uint64_t local_time;187 err=raw1394_read_cycle_timer(m_handle_util, &cycle_timer, &local_time);188 if(err) {189 debugError("raw1394_read_cycle_timer failed.\n");190 debugError(" Error: %s\n", strerror(err));191 debugError(" Your system doesn't seem to support the raw1394_read_cycle_timer call\n");192 return false;193 }194 195 168 // update the internal state 196 169 m_State=E_Initialized; 197 198 170 return true; 199 171 } … … 201 173 bool IsoHandler::prepare() 202 174 { 203 debugOutput( DEBUG_LEVEL_VERBOSE, "IsoHandler (%p) enter...\n",this); 204 175 debugOutput( DEBUG_LEVEL_VERBOSE, "IsoHandler (%p) prepare...\n", this); 205 176 // check the state 206 177 if(m_State != E_Initialized) { … … 208 179 return false; 209 180 } 210 211 181 // Don't call until libraw1394's raw1394_new_handle() function has been 212 182 // fixed to correctly initialise the iso_packet_infos field. Bug is 213 183 // confirmed present in libraw1394 1.2.1. 214 215 184 // raw1394_iso_shutdown(m_handle); 216 217 185 m_State = E_Prepared; 218 219 return true; 220 } 221 222 bool IsoHandler::start(int cycle) 186 return true; 187 } 188 189 bool IsoHandler::enable(int cycle) 223 190 { 224 191 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 225 226 // check the state 227 if(m_State != E_Prepared) { 228 debugError("Incorrect state, expected E_Prepared, got %d\n",(int)m_State); 229 return false; 230 } 231 232 m_State=E_Running; 233 234 return true; 235 } 236 237 bool IsoHandler::stop() 192 m_State = E_Running; 193 return true; 194 } 195 196 bool IsoHandler::disable() 238 197 { 239 198 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 240 199 241 200 // check state 201 if(m_State == E_Prepared) return true; 242 202 if(m_State != E_Running) { 243 203 debugError("Incorrect state, expected E_Running, got %d\n",(int)m_State); … … 249 209 // don't know if it will help though. 250 210 raw1394_iso_xmit_sync(m_handle); 251 252 211 raw1394_iso_stop(m_handle); 253 254 m_State=E_Prepared; 255 212 m_State = E_Prepared; 256 213 return true; 257 214 } … … 281 238 if (m_Client) channel=m_Client->getChannel(); 282 239 283 debugOutputShort( DEBUG_LEVEL_NORMAL, " Handler type 240 debugOutputShort( DEBUG_LEVEL_NORMAL, " Handler type................: %s\n", 284 241 (this->getType()==EHT_Receive ? "Receive" : "Transmit")); 285 debugOutputShort( DEBUG_LEVEL_NORMAL, " Port, Channel : %2d, %2d\n", 286 m_port, channel); 287 debugOutputShort( DEBUG_LEVEL_NORMAL, " Packet count : %10d (%5d dropped)\n", 242 debugOutputShort( DEBUG_LEVEL_NORMAL, " Port, Channel...............: %2d, %2d\n", 243 m_manager.get1394Service().getPort(), channel); 244 debugOutputShort( DEBUG_LEVEL_NORMAL, " Buffer, MaxPacketSize, IRQ..: %4d, %4d, %4d\n", 245 m_buf_packets, m_max_packet_size, m_irq_interval); 246 debugOutputShort( DEBUG_LEVEL_NORMAL, " Packet count................: %10d (%5d dropped)\n", 288 247 this->getPacketCount(), this->getDroppedCount()); 289 248 } … … 304 263 } 305 264 m_Client=stream; 306 m_Client->setHandler(this);307 265 return true; 308 266 } … … 317 275 return false; 318 276 } 319 320 m_Client->clearHandler();321 322 277 m_Client=0; 323 278 return true; 324 325 279 } 326 280 327 281 /* Child class implementations */ 328 282 329 IsoRecvHandler::IsoRecvHandler( int port)330 : IsoHandler( port)283 IsoRecvHandler::IsoRecvHandler(IsoHandlerManager& manager) 284 : IsoHandler(manager) 331 285 { 332 286 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 333 287 } 334 IsoRecvHandler::IsoRecvHandler( int port, unsigned int buf_packets,288 IsoRecvHandler::IsoRecvHandler(IsoHandlerManager& manager, unsigned int buf_packets, 335 289 unsigned int max_packet_size, int irq) 336 : IsoHandler( port, buf_packets,max_packet_size,irq)290 : IsoHandler(manager, buf_packets,max_packet_size,irq) 337 291 { 338 292 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); … … 342 296 { 343 297 298 } 299 300 void IsoRecvHandler::flush() 301 { 302 raw1394_iso_recv_flush(m_handle); 344 303 } 345 304 … … 375 334 bool IsoRecvHandler::prepare() 376 335 { 377 336 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing iso receive handler (%p, client=%p)\n", this, m_Client); 378 337 // prepare the generic IsoHandler 379 338 if(!IsoHandler::prepare()) { 380 339 return false; 381 340 } 382 383 341 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing iso receive handler (%p)\n",this); 384 342 debugOutput( DEBUG_LEVEL_VERBOSE, " Buffers : %d \n", m_buf_packets); … … 419 377 } 420 378 421 bool IsoRecvHandler:: start(int cycle)379 bool IsoRecvHandler::enable(int cycle) 422 380 { 423 381 debugOutput( DEBUG_LEVEL_VERBOSE, "start on cycle %d\n", cycle); 424 425 // start the generic IsoHandler 426 if(!IsoHandler::start(cycle)) { 427 return false; 428 } 429 382 // check the state 383 if(m_State != E_Prepared) { 384 if(!prepare()) { 385 debugFatal("Could not prepare recv handler\n"); 386 return false; 387 } 388 } 430 389 if(raw1394_iso_recv_start(m_handle, cycle, -1, 0)) { 431 390 debugFatal("Could not start receive handler (%s)\n",strerror(errno)); 391 dumpInfo(); 392 return false; 393 } 394 // start the generic IsoHandler 395 if(!IsoHandler::enable(cycle)) { 432 396 return false; 433 397 } … … 449 413 /* ----------------- XMIT --------------- */ 450 414 451 IsoXmitHandler::IsoXmitHandler( int port)452 : IsoHandler( port), m_prebuffers(0)415 IsoXmitHandler::IsoXmitHandler(IsoHandlerManager& manager) 416 : IsoHandler(manager), m_prebuffers(0) 453 417 { 454 418 debugOutput( DEBUG_LEVEL_VERBOSE, "IsoXmitHandler enter...\n"); 455 419 456 420 } 457 IsoXmitHandler::IsoXmitHandler( int port, unsigned int buf_packets,421 IsoXmitHandler::IsoXmitHandler(IsoHandlerManager& manager, unsigned int buf_packets, 458 422 unsigned int max_packet_size, int irq) 459 : IsoHandler( port, buf_packets, max_packet_size,irq),423 : IsoHandler(manager, buf_packets, max_packet_size,irq), 460 424 m_speed(RAW1394_ISO_SPEED_400), m_prebuffers(0) 461 425 { … … 463 427 464 428 } 465 IsoXmitHandler::IsoXmitHandler( int port, unsigned int buf_packets,429 IsoXmitHandler::IsoXmitHandler(IsoHandlerManager& manager, unsigned int buf_packets, 466 430 unsigned int max_packet_size, int irq, 467 431 enum raw1394_iso_speed speed) 468 : IsoHandler( port, buf_packets,max_packet_size,irq),432 : IsoHandler(manager, buf_packets,max_packet_size,irq), 469 433 m_speed(speed), m_prebuffers(0) 470 434 { … … 492 456 bool IsoXmitHandler::prepare() 493 457 { 494 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing iso transmit handler (%p, client=%p)\n",this,m_Client); 495 458 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing iso transmit handler (%p, client=%p)\n", this, m_Client); 496 459 if(!(IsoHandler::prepare())) { 497 460 return false; … … 503 466 debugOutput( DEBUG_LEVEL_VERBOSE, " Speed : %d \n",m_speed); 504 467 debugOutput( DEBUG_LEVEL_VERBOSE, " Irq interval : %d \n",m_irq_interval); 505 506 468 if(raw1394_iso_xmit_init(m_handle, 507 469 iso_transmit_handler, … … 515 477 return false; 516 478 } 517 518 return true; 519 } 520 521 bool IsoXmitHandler::start(int cycle) 479 return true; 480 } 481 482 bool IsoXmitHandler::enable(int cycle) 522 483 { 523 484 debugOutput( DEBUG_LEVEL_VERBOSE, "start on cycle %d, %d prebuffers\n", 524 485 cycle, m_prebuffers); 525 526 if(!(IsoHandler::start(cycle))) { 527 return false; 528 } 529 486 // check the state 487 if(m_State != E_Prepared) { 488 if(!prepare()) { 489 debugFatal("Could not prepare xmit handler\n"); 490 return false; 491 } 492 } 530 493 if(raw1394_iso_xmit_start(m_handle, cycle, m_prebuffers)) { 531 494 debugFatal("Could not start xmit handler (%s)\n",strerror(errno)); 495 dumpInfo(); 496 return false; 497 } 498 if(!(IsoHandler::enable(cycle))) { 532 499 return false; 533 500 } … … 549 516 return m_Client->getPacket(data, length, tag, sy, cycle, dropped, m_max_packet_size); 550 517 } 551 552 518 return RAW1394_ISO_OK; 553 519 } … … 556 522 debugOutput( DEBUG_LEVEL_VERBOSE, "bus reset...\n"); 557 523 //TODO: implement busreset 558 559 524 // pass on the busreset signal 560 525 if(IsoHandler::handleBusReset(generation)) { 561 526 return -1; 562 527 } 563 564 528 return 0; 565 529 } 566 530 567 } 568 569 /* multichannel receive */ 570 #if 0 571 IsoRecvHandler::IsoRecvHandler(int port) 572 : IsoHandler(port) 573 { 574 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 575 } 576 IsoRecvHandler::IsoRecvHandler(int port, unsigned int buf_packets, 577 unsigned int max_packet_size, int irq) 578 : IsoHandler(port, buf_packets,max_packet_size,irq) 579 { 580 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 581 582 } 583 IsoRecvHandler::~IsoRecvHandler() 584 { 585 // Don't call until libraw1394's raw1394_new_handle() function has been 586 // fixed to correctly initialise the iso_packet_infos field. Bug is 587 // confirmed present in libraw1394 1.2.1. In any case, 588 // raw1394_destroy_handle() (in the base class destructor) will do any iso 589 // system shutdown required. 590 raw1394_iso_shutdown(m_handle); 591 592 } 593 594 bool 595 IsoRecvHandler::initialize() { 596 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 597 598 IsoHandler *base=static_cast<IsoHandler *>(this); 599 600 if(!(base->initialize())) { 601 return false; 602 } 603 604 raw1394_set_userdata(m_handle, static_cast<void *>(this)); 605 606 if(raw1394_iso_multichannel_recv_init(m_handle, 607 iso_receive_handler, 608 m_buf_packets, 609 m_max_packet_size, 610 m_irq_interval)) { 611 debugFatal("Could not do multichannel receive initialisation!\n" ); 612 613 return false; 614 } 615 616 return true; 617 618 } 619 620 enum raw1394_iso_disposition IsoRecvHandler::putPacket(unsigned char *data, unsigned int length, 621 unsigned char channel, unsigned char tag, unsigned char sy, 622 unsigned int cycle, unsigned int dropped) { 623 624 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, 625 "received packet: length=%d, channel=%d, cycle=%d\n", 626 length, channel, cycle ); 627 628 return RAW1394_ISO_OK; 629 } 630 631 // an recv handler can have multiple destination StreamProcessors 632 // NOTE: this implementation even allows for already registered 633 // streams to be registered again. 634 int IsoRecvHandler::registerStream(IsoRecvStream *stream) 635 { 636 assert(stream); 637 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 638 639 m_Clients.push_back(stream); 640 641 listen(stream->getChannel()); 642 return 0; 643 644 } 645 646 int IsoRecvHandler::unregisterStream(IsoRecvStream *stream) 647 { 648 assert(stream); 649 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 650 651 for ( IsoRecvStreamVectorIterator it = m_Clients.begin(); 652 it != m_Clients.end(); 653 ++it ) 654 { 655 IsoRecvStream* s = *it; 656 if ( s == stream ) { 657 unListen(s->getChannel()); 658 m_Clients.erase(it); 659 return 0; 660 } 661 } 662 663 return -1; //not found 664 665 } 666 667 void IsoRecvHandler::listen(int channel) { 668 int retval; 669 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 670 671 retval=raw1394_iso_recv_listen_channel(m_handle, channel); 672 673 } 674 675 void IsoRecvHandler::unListen(int channel) { 676 int retval; 677 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 678 679 retval=raw1394_iso_recv_unlisten_channel(m_handle, channel); 680 681 } 682 683 int IsoRecvHandler::start(int cycle) 684 { 685 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 686 return raw1394_iso_recv_start(m_handle, cycle, -1, 0); 687 } 688 #endif 531 void IsoXmitHandler::dumpInfo() 532 { 533 IsoHandler::dumpInfo(); 534 debugOutputShort( DEBUG_LEVEL_NORMAL, " Speed, PreBuffers...........: %2d, %2d\n", 535 m_speed, m_prebuffers); 536 } trunk/libffado/src/libieee1394/IsoHandler.h
r748 r750 26 26 27 27 #include "debugmodule/debugmodule.h" 28 29 #include <libraw1394/raw1394.h> 30 28 #include "IsoHandlerManager.h" 31 29 32 30 enum raw1394_iso_disposition ; 33 namespace Streaming 34 { 35 36 class StreamProcessor; 31 32 namespace Streaming { 33 class StreamProcessor; 34 } 35 37 36 /*! 38 37 \brief The Base Class for ISO Handlers 39 38 40 39 These classes perform the actual ISO communication through libraw1394. 41 They are different from Stream Processors because one handler can provide multiple40 They are different from Streaming::StreamProcessors because one handler can provide multiple 42 41 streams with packets in case of ISO multichannel receive. 43 42 … … 46 45 class IsoHandler 47 46 { 48 protected: 49 50 public: 51 52 enum EHandlerType { 53 EHT_Receive, 54 EHT_Transmit 55 }; 56 57 IsoHandler(int port); 58 59 IsoHandler(int port, unsigned int buf_packets, unsigned int max_packet_size, int irq); 60 61 virtual ~IsoHandler(); 62 63 virtual bool init(); 64 virtual bool prepare(); 65 virtual bool start(int cycle); 66 virtual bool stop(); 67 68 bool iterate(); 69 70 void setVerboseLevel(int l); 71 72 // no setter functions, because those would require a re-init 73 unsigned int getMaxPacketSize() { return m_max_packet_size;}; 74 unsigned int getNbBuffers() { return m_buf_packets;}; 75 int getWakeupInterval() { return m_irq_interval;}; 76 77 int getPacketCount() {return m_packetcount;}; 78 void resetPacketCount() {m_packetcount=0;}; 79 80 int getDroppedCount() {return m_dropped;}; 81 void resetDroppedCount() {m_dropped=0;}; 82 83 virtual enum EHandlerType getType() = 0; 84 85 int getFileDescriptor() { return raw1394_get_fd(m_handle);}; 86 87 void dumpInfo(); 88 89 bool inUse() {return (m_Client != 0) ;}; 90 virtual bool isStreamRegistered(StreamProcessor *s) {return (m_Client == s);}; 91 92 virtual bool registerStream(StreamProcessor *); 93 virtual bool unregisterStream(StreamProcessor *); 94 95 int getLocalNodeId() {return raw1394_get_local_id( m_handle );}; 96 int getPort() {return m_port;}; 97 98 protected: 47 public: 48 enum EHandlerType { 49 EHT_Receive, 50 EHT_Transmit 51 }; 52 IsoHandler(IsoHandlerManager& manager); 53 IsoHandler(IsoHandlerManager& manager, unsigned int buf_packets, unsigned int max_packet_size, int irq); 54 55 virtual ~IsoHandler(); 56 57 virtual bool init(); 58 virtual bool prepare(); 59 60 bool iterate(); 61 void setVerboseLevel(int l); 62 63 virtual bool enable() {return enable(-1);}; 64 virtual bool enable(int cycle); 65 virtual bool disable(); 66 67 virtual void flush() = 0; 68 69 bool isEnabled() 70 {return m_State == E_Running;}; 71 72 // no setter functions, because those would require a re-init 73 unsigned int getMaxPacketSize() { return m_max_packet_size;}; 74 unsigned int getNbBuffers() { return m_buf_packets;}; 75 int getPacketLatency() { return m_irq_interval;}; 76 77 int getPacketCount() {return m_packetcount;}; 78 void resetPacketCount() {m_packetcount=0;}; 79 80 int getDroppedCount() {return m_dropped;}; 81 void resetDroppedCount() {m_dropped=0;}; 82 83 virtual enum EHandlerType getType() = 0; 84 85 int getFileDescriptor() { return raw1394_get_fd(m_handle);}; 86 87 virtual void dumpInfo(); 88 89 bool inUse() {return (m_Client != 0) ;}; 90 virtual bool isStreamRegistered(Streaming::StreamProcessor *s) {return (m_Client == s);}; 91 92 virtual bool registerStream(Streaming::StreamProcessor *); 93 virtual bool unregisterStream(Streaming::StreamProcessor *); 94 95 protected: 96 IsoHandlerManager& m_manager; 99 97 raw1394handle_t m_handle; 100 raw1394handle_t m_handle_util;101 int m_port;102 98 unsigned int m_buf_packets; 103 99 unsigned int m_max_packet_size; … … 106 102 int m_packetcount; 107 103 int m_dropped; 108 109 StreamProcessor *m_Client; 104 Streaming::StreamProcessor *m_Client; 110 105 111 106 virtual int handleBusReset(unsigned int generation); 112 113 114 107 DECLARE_DEBUG_MODULE; 115 116 108 private: 117 109 static int busreset_handler(raw1394handle_t handle, unsigned int generation); 118 110 119 111 // the state machine 120 pr ivate:112 protected: 121 113 enum EHandlerStates { 122 114 E_Created, … … 126 118 E_Error 127 119 }; 128 129 120 enum EHandlerStates m_State; 130 131 121 }; 132 122 … … 139 129 140 130 public: 141 IsoRecvHandler( int port);142 IsoRecvHandler( int port, unsigned int buf_packets, unsigned int max_packet_size, int irq);131 IsoRecvHandler(IsoHandlerManager& manager); 132 IsoRecvHandler(IsoHandlerManager& manager, unsigned int buf_packets, unsigned int max_packet_size, int irq); 143 133 virtual ~IsoRecvHandler(); 144 134 145 135 bool init(); 146 147 136 enum EHandlerType getType() { return EHT_Receive;}; 148 149 bool start(int cycle); 150 151 bool prepare(); 137 bool enable(int cycle); 138 virtual bool prepare(); 139 virtual void flush(); 152 140 153 141 protected: 154 142 int handleBusReset(unsigned int generation); 155 156 143 private: 157 144 static enum raw1394_iso_disposition … … 165 152 unsigned char channel, unsigned char tag, unsigned char sy, 166 153 unsigned int cycle, unsigned int dropped); 167 168 154 }; 169 155 … … 175 161 { 176 162 public: 177 IsoXmitHandler( int port);178 IsoXmitHandler( int port, unsigned int buf_packets,163 IsoXmitHandler(IsoHandlerManager& manager); 164 IsoXmitHandler(IsoHandlerManager& manager, unsigned int buf_packets, 179 165 unsigned int max_packet_size, int irq); 180 IsoXmitHandler( int port, unsigned int buf_packets,166 IsoXmitHandler(IsoHandlerManager& manager, unsigned int buf_packets, 181 167 unsigned int max_packet_size, int irq, 182 168 enum raw1394_iso_speed speed); … … 184 170 185 171 bool init(); 186 187 172 enum EHandlerType getType() { return EHT_Transmit;}; 188 189 173 unsigned int getPreBuffers() {return m_prebuffers;}; 190 174 void setPreBuffers(unsigned int n) {m_prebuffers=n;}; 191 192 bool start(int cycle);193 194 bool prepare(); 195 175 virtual bool enable(int cycle); 176 virtual bool prepare(); 177 virtual void flush() {}; 178 179 void dumpInfo(); 196 180 protected: 197 181 int handleBusReset(unsigned int generation); … … 208 192 209 193 enum raw1394_iso_speed m_speed; 210 211 194 unsigned int m_prebuffers; 212 213 195 }; 214 196 215 }216 217 197 #endif /* __FFADO_ISOHANDLER__ */ 218 198 trunk/libffado/src/libieee1394/IsoHandlerManager.cpp
r747 r750 23 23 24 24 #include "IsoHandlerManager.h" 25 #include "ieee1394service.h" 25 26 #include "IsoHandler.h" 26 #include "../generic/StreamProcessor.h" 27 27 #include "libstreaming/generic/StreamProcessor.h" 28 29 #include "libutil/Atomic.h" 28 30 #include "libutil/PosixThread.h" 29 31 … … 33 35 #define PACKETS_PER_INTERRUPT 4U 34 36 35 namespace Streaming 36 { 37 #define FFADO_ISOHANDLERMANAGER_PRIORITY_INCREASE 7 37 38 38 39 IMPL_DEBUG_MODULE( IsoHandlerManager, IsoHandlerManager, DEBUG_LEVEL_NORMAL ); 39 40 40 IsoHandlerManager::IsoHandlerManager() : 41 m_State(E_Created), 42 m_poll_timeout(100), m_poll_fds(0), m_poll_nfds(0), 43 m_realtime(false), m_priority(0), m_xmit_nb_frames( 20 ) 41 using namespace Streaming; 42 43 IsoHandlerManager::IsoHandlerManager(Ieee1394Service& service) 44 : m_State(E_Created) 45 , m_service( service ) 46 , m_poll_timeout(100), m_poll_nfds_shadow(0) 47 , m_realtime(false), m_priority(0), m_xmit_nb_frames( 20 ) 44 48 {} 45 49 46 IsoHandlerManager::IsoHandlerManager(bool run_rt, unsigned int rt_prio) : 47 m_State(E_Created), 48 m_poll_timeout(100), m_poll_fds(0), m_poll_nfds(0), 49 m_realtime(run_rt), m_priority(rt_prio), m_xmit_nb_frames( 20 ) 50 IsoHandlerManager::IsoHandlerManager(Ieee1394Service& service, bool run_rt, unsigned int rt_prio) 51 : m_State(E_Created) 52 , m_service( service ) 53 , m_poll_timeout(100), m_poll_nfds_shadow(0) 54 , m_realtime(run_rt), m_priority(rt_prio), m_xmit_nb_frames( 20 ) 50 55 {} 51 56 57 IsoHandlerManager::~IsoHandlerManager() 58 { 59 stopHandlers(); 60 } 61 62 bool 63 IsoHandlerManager::setThreadParameters(bool rt, int priority) { 64 if (m_isoManagerThread) { 65 if (rt) { 66 unsigned int prio = priority + FFADO_ISOHANDLERMANAGER_PRIORITY_INCREASE; 67 if (prio > 98) prio = 98; 68 m_isoManagerThread->AcquireRealTime(prio); 69 } else { 70 m_isoManagerThread->DropRealTime(); 71 } 72 } 73 m_realtime = rt; 74 m_priority = priority; 75 return true; 76 } 77 52 78 bool IsoHandlerManager::init() 53 79 { 80 debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing ISO manager %p...\n", this); 81 // check state 82 if(m_State != E_Created) { 83 debugError("Manager already initialized...\n"); 84 return false; 85 } 86 54 87 // the tread that performs the actual packet transfer 55 88 // needs high priority 56 unsigned int prio =m_priority+6;57 58 if (prio>98) prio=98; 59 60 m_isoManagerThread =new Util::PosixThread(89 unsigned int prio = m_priority + FFADO_ISOHANDLERMANAGER_PRIORITY_INCREASE; 90 debugOutput( DEBUG_LEVEL_VERBOSE, " thread should have prio %d, base is %d...\n", prio, m_priority); 91 92 if (prio > 98) prio = 98; 93 m_isoManagerThread = new Util::PosixThread( 61 94 this, 62 95 m_realtime, prio, … … 67 100 return false; 68 101 } 69 70 102 // propagate the debug level 71 103 m_isoManagerThread->setVerboseLevel(getDebugLevel()); 72 104 105 debugOutput( DEBUG_LEVEL_VERBOSE, "Starting ISO iterator thread...\n"); 106 // note: libraw1394 doesn't like it if you poll() and/or iterate() before 107 // starting the streams. this is prevented by the isEnabled() on a handler 108 // start the iso runner thread 109 if (m_isoManagerThread->Start() == 0) { 110 m_State=E_Running; 111 requestShadowUpdate(); 112 } else { 113 m_State=E_Error; 114 } 73 115 return true; 74 116 } … … 77 119 { 78 120 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 79 pthread_mutex_init(&m_debug_lock, NULL);80 81 121 return true; 82 122 } … … 97 137 bool IsoHandlerManager::Execute() 98 138 { 99 // updateCycleTimers();100 101 pthread_mutex_lock(&m_debug_lock);102 103 139 if(!iterate()) { 104 140 debugFatal("Could not iterate the isoManager\n"); 105 pthread_mutex_unlock(&m_debug_lock);106 141 return false; 107 142 } 108 109 pthread_mutex_unlock(&m_debug_lock);110 111 143 return true; 144 } 145 146 /** 147 * Update the shadow variables. Should only be called from 148 * the iso handler iteration thread 149 */ 150 void 151 IsoHandlerManager::updateShadowVars() 152 { 153 debugOutput( DEBUG_LEVEL_VERBOSE, "updating shadow vars...\n"); 154 unsigned int i; 155 m_poll_nfds_shadow = m_IsoHandlers.size(); 156 if(m_poll_nfds_shadow > FFADO_MAX_ISO_HANDLERS_PER_PORT) { 157 debugWarning("Too much ISO Handlers in manager...\n"); 158 m_poll_nfds_shadow = FFADO_MAX_ISO_HANDLERS_PER_PORT; 159 } 160 for (i = 0; i < m_poll_nfds_shadow; i++) { 161 IsoHandler *h = m_IsoHandlers.at(i); 162 assert(h); 163 m_IsoHandler_map_shadow[i] = h; 164 165 m_poll_fds_shadow[i].fd = h->getFileDescriptor(); 166 m_poll_fds_shadow[i].revents = 0; 167 if (h->isEnabled()) { 168 m_poll_fds_shadow[i].events = POLLIN; 169 } else { 170 m_poll_fds_shadow[i].events = 0; 171 } 172 } 173 debugOutput( DEBUG_LEVEL_VERBOSE, " updated shadow vars...\n"); 112 174 } 113 175 … … 121 183 { 122 184 int err; 123 int i=0; 124 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "poll %d fd's, timeout = %dms...\n", m_poll_nfds, m_poll_timeout); 125 126 err = poll (m_poll_fds, m_poll_nfds, m_poll_timeout); 185 int i; 186 187 // update the shadow variables if requested 188 if(m_request_fdmap_update) { 189 updateShadowVars(); 190 ZERO_ATOMIC((SInt32*)&m_request_fdmap_update); 191 } 192 193 // bypass if no handlers are registered 194 if (m_poll_nfds_shadow == 0) { 195 usleep(m_poll_timeout * 1000); 196 return true; 197 } 198 199 // Use a shadow map of the fd's such that the poll call is not in a critical section 200 201 err = poll (m_poll_fds_shadow, m_poll_nfds_shadow, m_poll_timeout); 127 202 128 203 if (err == -1) { … … 135 210 136 211 // #ifdef DEBUG 137 // for (i = 0; i < m_poll_nfds ; i++) {138 // IsoHandler *s = m_IsoHandler s.at(i);212 // for (i = 0; i < m_poll_nfds_shadow; i++) { 213 // IsoHandler *s = m_IsoHandler_map_shadow[i]; 139 214 // assert(s); 140 // debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " (%d) handler %p: iterate? %d, revents: %08X\n",141 // i, s, (m_poll_fds[i].revents & (POLLIN) == 1), m_poll_fds[i].revents);215 // debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "post poll: (%d) handler %p: enabled? %d, events: %08X, revents: %08X\n", 216 // i, s, s->isEnabled(), m_poll_fds_shadow[i].events, m_poll_fds_shadow[i].revents); 142 217 // } 143 218 // #endif 144 219 145 for (i = 0; i < m_poll_nfds ; i++) {146 if (m_poll_fds [i].revents & POLLERR) {220 for (i = 0; i < m_poll_nfds_shadow; i++) { 221 if (m_poll_fds_shadow[i].revents & POLLERR) { 147 222 debugWarning("error on fd for %d\n",i); 148 223 } 149 224 150 if (m_poll_fds [i].revents & POLLHUP) {225 if (m_poll_fds_shadow[i].revents & POLLHUP) { 151 226 debugWarning("hangup on fd for %d\n",i); 152 227 } 153 228 154 if(m_poll_fds[i].revents & (POLLIN)) { 155 IsoHandler *s = m_IsoHandlers.at(i); 156 assert(s); 157 s->iterate(); 158 } 159 } 160 229 if(m_poll_fds_shadow[i].revents & (POLLIN)) { 230 m_IsoHandler_map_shadow[i]->iterate(); 231 } 232 } 161 233 return true; 162 163 234 } 164 235 … … 167 238 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 168 239 assert(handler); 240 handler->setVerboseLevel(getDebugLevel()); 169 241 170 242 m_IsoHandlers.push_back(handler); 171 172 handler->setVerboseLevel(getDebugLevel()); 243 requestShadowUpdate(); 173 244 174 245 // rebuild the fd map for poll()'ing. 175 return rebuildFdMap(); 176 246 return true; 177 247 } 178 248 … … 187 257 { 188 258 if ( *it == handler ) { 189 // erase the iso handler from the list190 259 m_IsoHandlers.erase(it); 191 // rebuild the fd map for poll()'ing.192 return rebuildFdMap();260 requestShadowUpdate(); 261 return true; 193 262 } 194 263 } 195 264 debugFatal("Could not find handler (%p)\n", handler); 196 197 265 return false; //not found 198 199 } 200 201 bool IsoHandlerManager::rebuildFdMap() {266 } 267 268 void 269 IsoHandlerManager::requestShadowUpdate() { 202 270 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 271 int i; 272 273 if (m_isoManagerThread == NULL) { 274 debugOutput( DEBUG_LEVEL_VERBOSE, "No thread running, so no shadow variables needed.\n"); 275 return; 276 } 277 278 // the m_request_fdmap_update variable is zeroed by the 279 // handler thread when it has accepted the new FD map 280 // and copied it over to it's shadow variables. 281 while(m_request_fdmap_update && m_isoManagerThread) { 282 usleep(1000); 283 } 284 285 debugOutput(DEBUG_LEVEL_VERBOSE, " requesting update of shadow variables...\n"); 286 // request that the handler thread updates it's FD shadow 287 INC_ATOMIC((SInt32*)&m_request_fdmap_update); 288 289 debugOutput(DEBUG_LEVEL_VERBOSE, " waiting for update of shadow variables to complete...\n"); 290 // the m_request_fdmap_update variable is zeroed by the 291 // handler thread when it has accepted the new FD map 292 // and copied it over to it's shadow variables. 293 while(m_request_fdmap_update && m_isoManagerThread) { 294 usleep(1000); 295 } 296 debugOutput(DEBUG_LEVEL_VERBOSE, " shadow variables updated...\n"); 297 } 298 299 bool 300 IsoHandlerManager::disable(IsoHandler *h) { 301 bool result; 203 302 int i=0; 204 205 m_poll_nfds=0; 206 if(m_poll_fds) free(m_poll_fds); 207 208 // count the number of handlers 209 m_poll_nfds=m_IsoHandlers.size(); 210 211 // allocate the fd array 212 m_poll_fds = (struct pollfd *) calloc (m_poll_nfds, sizeof (struct pollfd)); 213 if(!m_poll_fds) { 214 debugFatal("Could not allocate memory for poll FD array\n"); 215 return false; 216 } 217 218 // fill the fd map 219 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 220 it != m_IsoHandlers.end(); 221 ++it ) 222 { 223 m_poll_fds[i].fd=(*it)->getFileDescriptor(); 224 m_poll_fds[i].events = POLLIN; 225 i++; 226 } 227 228 return true; 229 } 230 231 void IsoHandlerManager::disablePolling(StreamProcessor *stream) { 232 int i=0; 233 234 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Disable polling on stream %p\n",stream); 235 303 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Disable on IsoHandler %p\n", h); 236 304 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 237 305 it != m_IsoHandlers.end(); 238 306 ++it ) 239 307 { 240 if ((*it) ->isStreamRegistered(stream)) {241 m_poll_fds[i].events = 0;242 m_poll_fds[i].revents = 0;243 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " pollingdisabled\n");244 }245 308 if ((*it) == h) { 309 result = h->disable(); 310 requestShadowUpdate(); 311 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " disabled\n"); 312 return result; 313 } 246 314 i++; 247 315 } 248 } 249 250 void IsoHandlerManager::enablePolling(StreamProcessor *stream) { 316 debugError("Handler not found\n"); 317 return false; 318 } 319 320 bool 321 IsoHandlerManager::enable(IsoHandler *h) { 322 bool result; 251 323 int i=0; 252 253 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Enable polling on stream %p\n",stream); 254 324 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Enable on IsoHandler %p\n", h); 255 325 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 256 326 it != m_IsoHandlers.end(); 257 327 ++it ) 258 328 { 259 if ((*it) ->isStreamRegistered(stream)) {260 m_poll_fds[i].events = POLLIN;261 m_poll_fds[i].revents = 0;262 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " pollingenabled\n");263 }264 329 if ((*it) == h) { 330 result = h->enable(); 331 requestShadowUpdate(); 332 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " enabled\n"); 333 return result; 334 } 265 335 i++; 266 336 } 267 } 268 337 debugError("Handler not found\n"); 338 return false; 339 } 269 340 270 341 /** … … 293 364 { 294 365 if((*it)->isStreamRegistered(stream)) { 295 debugWarning( "stream already registered!\n"); 296 (*it)->unregisterStream(stream); 297 366 debugError( "stream already registered!\n"); 367 return false; 298 368 } 299 369 } … … 367 437 but it has a minimal value in order for libraw to operate correctly (300) */ 368 438 int buffers=400; 369 439 //max_packet_size = getpagesize(); // HACK 440 //irq_interval=2; // HACK 370 441 // create the actual handler 371 IsoRecvHandler *h = new IsoRecvHandler( stream->getPort(), buffers,442 IsoRecvHandler *h = new IsoRecvHandler(*this, buffers, 372 443 max_packet_size, irq_interval); 373 444 … … 405 476 unsigned int packets_per_period = stream->getPacketsPerPeriod(); 406 477 407 #if 1408 478 // hardware interrupts occur when one DMA block is full, and the size of one DMA 409 479 // block = PAGE_SIZE. Setting the max_packet_size makes sure that the HW irq … … 422 492 423 493 unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; 424 if(irq_interval <= 0) irq_interval=1; 425 #else 426 // hardware interrupts occur when one DMA block is full, and the size of one DMA 427 // block = PAGE_SIZE. Setting the max_packet_size enables control over the IRQ 428 // frequency, as the controller uses max_packet_size, and not the effective size 429 // when writing to the DMA buffer. 430 431 // configure it such that we have an irq for every PACKETS_PER_INTERRUPT packets 432 unsigned int irq_interval = PACKETS_PER_INTERRUPT; 433 434 // unless the period size doesn't allow this 435 if ((packets_per_period/MINIMUM_INTERRUPTS_PER_PERIOD) < irq_interval) { 436 irq_interval = 1; 437 } 438 439 // FIXME: test 440 irq_interval = 1; 441 #warning Using fixed irq_interval 442 443 unsigned int max_packet_size = getpagesize() / irq_interval; 444 445 if (max_packet_size < stream->getMaxPacketSize()) { 446 max_packet_size = stream->getMaxPacketSize(); 447 } 448 449 // Ensure we don't request a packet size bigger than the 450 // kernel-enforced maximum which is currently 1 page. 451 if (max_packet_size > (unsigned int)getpagesize()) 452 max_packet_size = getpagesize(); 453 #endif 494 if(irq_interval <= 0) irq_interval = 1; 495 454 496 // the transmit buffer size should be as low as possible for latency. 455 497 // note however that the raw1394 subsystem tries to keep this buffer … … 461 503 // buffers get transfered, meaning that we should have at least some 462 504 // margin here 463 // int buffers=irq_interval * 2; 464 465 // the SPM specifies how many packets to buffer 466 int buffers = stream->getNominalPacketsNeeded(m_xmit_nb_frames); 505 //irq_interval=2; 506 //int buffers=30; 507 //max_packet_size = getpagesize(); // HACK 508 509 // the SP specifies how many packets to buffer 510 int buffers = stream->getNbPacketsIsoXmitBuffer(); 467 511 468 512 // create the actual handler 469 IsoXmitHandler *h = new IsoXmitHandler( stream->getPort(), buffers,513 IsoXmitHandler *h = new IsoXmitHandler(*this, buffers, 470 514 max_packet_size, irq_interval); 471 515 … … 498 542 debugOutput( DEBUG_LEVEL_VERBOSE, " registered stream (%p) with handler (%p)\n",stream,h); 499 543 } 500 501 544 m_StreamProcessors.push_back(stream); 502 545 debugOutput( DEBUG_LEVEL_VERBOSE, " %d streams, %d handlers registered\n", 503 546 m_StreamProcessors.size(), m_IsoHandlers.size()); 504 505 547 return true; 506 548 } … … 521 563 return false; 522 564 } 523 524 565 debugOutput( DEBUG_LEVEL_VERBOSE, " unregistered stream (%p) from handler (%p)...\n",stream,*it); 525 566 } … … 536 577 if ( *it == stream ) { 537 578 m_StreamProcessors.erase(it); 538 539 579 debugOutput( DEBUG_LEVEL_VERBOSE, " deleted stream (%p) from list...\n", *it); 540 580 return true; 541 581 } 542 582 } 543 544 583 return false; //not found 545 546 } 547 584 } 585 586 /** 587 * @brief unregister a handler from the manager 588 * @note called without the lock held. 589 */ 548 590 void IsoHandlerManager::pruneHandlers() { 549 591 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); … … 566 608 { 567 609 unregisterHandler(*it); 610 568 611 debugOutput( DEBUG_LEVEL_VERBOSE, " deleting handler (%p)\n",*it); 569 612 … … 578 621 delete *it; 579 622 } 580 581 } 582 583 584 bool IsoHandlerManager::prepare() 585 { 623 } 624 625 bool 626 IsoHandlerManager::stopHandlerForStream(Streaming::StreamProcessor *stream) { 627 // check state 628 if(m_State != E_Running) { 629 debugError("Incorrect state, expected E_Running, got %s\n", eHSToString(m_State)); 630 return false; 631 } 632 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 633 it != m_IsoHandlers.end(); 634 ++it ) 635 { 636 if((*it)->isStreamRegistered(stream)) { 637 bool result; 638 debugOutput( DEBUG_LEVEL_VERBOSE, " stopping handler %p for stream %p\n", *it, stream); 639 result = (*it)->disable(); 640 //requestShadowUpdate(); 641 if(!result) { 642 debugOutput( DEBUG_LEVEL_VERBOSE, " could not disable handler (%p)\n",*it); 643 return false; 644 } 645 return true; 646 } 647 } 648 debugError("Stream %p has no attached handler\n", stream); 649 return false; 650 } 651 652 int 653 IsoHandlerManager::getPacketLatencyForStream(Streaming::StreamProcessor *stream) { 654 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 655 it != m_IsoHandlers.end(); 656 ++it ) 657 { 658 if((*it)->isStreamRegistered(stream)) { 659 return (*it)->getPacketLatency(); 660 } 661 } 662 debugError("Stream %p has no attached handler\n", stream); 663 return 0; 664 } 665 666 void 667 IsoHandlerManager::flushHandlerForStream(Streaming::StreamProcessor *stream) { 668 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 669 it != m_IsoHandlers.end(); 670 ++it ) 671 { 672 if((*it)->isStreamRegistered(stream)) { 673 return (*it)->flush(); 674 } 675 } 676 debugError("Stream %p has no attached handler\n", stream); 677 return; 678 } 679 680 bool 681 IsoHandlerManager::startHandlerForStream(Streaming::StreamProcessor *stream) { 682 return startHandlerForStream(stream, -1); 683 } 684 685 bool 686 IsoHandlerManager::startHandlerForStream(Streaming::StreamProcessor *stream, int cycle) { 687 // check state 688 if(m_State != E_Running) { 689 debugError("Incorrect state, expected E_Running, got %s\n", eHSToString(m_State)); 690 return false; 691 } 692 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 693 it != m_IsoHandlers.end(); 694 ++it ) 695 { 696 if((*it)->isStreamRegistered(stream)) { 697 bool result; 698 debugOutput( DEBUG_LEVEL_VERBOSE, " starting handler %p for stream %p\n", *it, stream); 699 result = (*it)->enable(cycle); 700 requestShadowUpdate(); 701 if(!result) { 702 debugOutput( DEBUG_LEVEL_VERBOSE, " could not enable handler (%p)\n",*it); 703 return false; 704 } 705 return true; 706 } 707 } 708 debugError("Stream %p has no attached handler\n", stream); 709 return false; 710 } 711 712 bool IsoHandlerManager::stopHandlers() { 713 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 714 715 // check state 716 if(m_State != E_Running) { 717 debugError("Incorrect state, expected E_Running, got %s\n", eHSToString(m_State)); 718 return false; 719 } 720 586 721 bool retval=true; 587 588 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 589 590 // check state 591 if(m_State != E_Created) { 592 debugError("Incorrect state, expected E_Created, got %d\n",(int)m_State); 593 return false; 594 } 595 596 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 597 it != m_IsoHandlers.end(); 598 ++it ) 599 { 600 if(!(*it)->prepare()) { 601 debugFatal("Could not prepare handlers\n"); 722 debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping ISO iterator thread...\n"); 723 724 m_isoManagerThread->Stop(); 725 m_isoManagerThread = NULL; 726 ZERO_ATOMIC((SInt32*)&m_request_fdmap_update); 727 728 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 729 it != m_IsoHandlers.end(); 730 ++it ) 731 { 732 debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping handler (%p)\n",*it); 733 if(!(*it)->disable()){ 734 debugOutput( DEBUG_LEVEL_VERBOSE, " could not stop handler (%p)\n",*it); 602 735 retval=false; 603 736 } 604 737 } 738 requestShadowUpdate(); 605 739 606 740 if (retval) { … … 609 743 m_State=E_Error; 610 744 } 611 612 return retval;613 }614 615 bool IsoHandlerManager::startHandlers() {616 return startHandlers(-1);617 }618 619 bool IsoHandlerManager::startHandlers(int cycle) {620 bool retval=true;621 622 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");623 624 // check state625 if(m_State != E_Prepared) {626 debugError("Incorrect state, expected E_Prepared, got %d\n",(int)m_State);627 return false;628 }629 630 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin();631 it != m_IsoHandlers.end();632 ++it )633 {634 debugOutput( DEBUG_LEVEL_VERBOSE, " starting handler (%p)\n",*it);635 if(!(*it)->start(cycle)) {636 debugOutput( DEBUG_LEVEL_VERBOSE, " could not start handler (%p)\n",*it);637 retval=false;638 }639 }640 641 debugOutput( DEBUG_LEVEL_VERBOSE, "Starting ISO iterator thread...\n");642 643 // note: libraw1394 doesn't like it if you poll() and/or iterate() before644 // starting the streams.645 // start the iso runner thread646 m_isoManagerThread->Start();647 648 if (retval) {649 m_State=E_Running;650 } else {651 m_State=E_Error;652 }653 654 return retval;655 }656 657 bool IsoHandlerManager::stopHandlers() {658 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");659 660 // check state661 if(m_State != E_Running) {662 debugError("Incorrect state, expected E_Running, got %d\n",(int)m_State);663 return false;664 }665 666 bool retval=true;667 668 debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping ISO iterator thread...\n");669 m_isoManagerThread->Stop();670 671 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin();672 it != m_IsoHandlers.end();673 ++it )674 {675 debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping handler (%p)\n",*it);676 if(!(*it)->stop()){677 debugOutput( DEBUG_LEVEL_VERBOSE, " could not stop handler (%p)\n",*it);678 retval=false;679 }680 }681 682 if (retval) {683 m_State=E_Prepared;684 } else {685 m_State=E_Error;686 }687 688 745 return retval; 689 746 } … … 691 748 bool IsoHandlerManager::reset() { 692 749 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 693 694 750 // check state 695 751 if(m_State == E_Error) { … … 697 753 return false; 698 754 } 699 700 755 // if not in an error condition, reset means stop the handlers 701 756 return stopHandlers(); … … 705 760 void IsoHandlerManager::setVerboseLevel(int i) { 706 761 setDebugLevel(i); 707 708 762 // propagate the debug level 709 763 if(m_isoManagerThread) { 710 764 m_isoManagerThread->setVerboseLevel(getDebugLevel()); 711 765 } 712 713 766 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 714 767 it != m_IsoHandlers.end(); … … 721 774 void IsoHandlerManager::dumpInfo() { 722 775 int i=0; 723 724 776 debugOutputShort( DEBUG_LEVEL_NORMAL, "Dumping IsoHandlerManager Stream handler information...\n"); 725 777 debugOutputShort( DEBUG_LEVEL_NORMAL, " State: %d\n",(int)m_State); … … 730 782 { 731 783 debugOutputShort( DEBUG_LEVEL_NORMAL, " IsoHandler %d (%p)\n",i++,*it); 732 733 784 (*it)->dumpInfo(); 734 785 } 735 736 } 737 738 } // end of namespace Streaming 739 786 } 787 788 const char * 789 IsoHandlerManager::eHSToString(enum eHandlerStates s) { 790 switch (s) { 791 default: return "Invalid"; 792 case E_Created: return "Created"; 793 case E_Prepared: return "Prepared"; 794 case E_Running: return "Running"; 795 case E_Error: return "Error"; 796 } 797 } trunk/libffado/src/libieee1394/IsoHandlerManager.h
r747 r750 34 34 #include <vector> 35 35 36 #define FFADO_MAX_ISO_HANDLERS_PER_PORT 16 37 36 38 #define USLEEP_AFTER_UPDATE_FAILURE 10 37 39 #define USLEEP_AFTER_UPDATE 100 38 40 #define MAX_UPDATE_TRIES 10 41 class Ieee1394Service; 39 42 namespace Util { 40 43 class PosixThread; 41 44 } 42 45 43 namespace Streaming44 {45 46 class IsoHandler; 46 class StreamProcessor; 47 namespace Streaming { 48 class StreamProcessor; 49 class StreamProcessorManager; 50 typedef std::vector<StreamProcessor *> StreamProcessorVector; 51 typedef std::vector<StreamProcessor *>::iterator StreamProcessorVectorIterator; 52 } 47 53 48 54 typedef std::vector<IsoHandler *> IsoHandlerVector; 49 55 typedef std::vector<IsoHandler *>::iterator IsoHandlerVectorIterator; 50 51 typedef std::vector<StreamProcessor *> StreamProcessorVector;52 typedef std::vector<StreamProcessor *>::iterator StreamProcessorVectorIterator;53 54 56 55 57 /*! … … 57 59 58 60 This class manages the use of ISO handlers by ISO streams. 59 You can register an Stream Processor with an IsoHandlerManager. This61 You can register an Streaming::StreamProcessor with an IsoHandlerManager. This 60 62 manager will assign an IsoHandler to the stream. If nescessary 61 63 the manager allocates a new handler. If there is already a handler 62 that can handle the Stream Processor (e.g. in case of multichannel receive),64 that can handle the Streaming::StreamProcessor (e.g. in case of multichannel receive), 63 65 it can be assigned. 64 66 65 67 */ 66 67 68 class IsoHandlerManager : public Util::RunnableInterface 68 69 { 69 friend class Stream ProcessorManager;70 friend class Streaming::StreamProcessorManager; 70 71 71 72 public: 72 73 73 IsoHandlerManager(); 74 IsoHandlerManager(bool run_rt, unsigned int rt_prio); 75 virtual ~IsoHandlerManager() {}; 74 IsoHandlerManager(Ieee1394Service& service); 75 IsoHandlerManager(Ieee1394Service& service, bool run_rt, unsigned int rt_prio); 76 virtual ~IsoHandlerManager(); 77 78 bool setThreadParameters(bool rt, int priority); 76 79 77 80 void setPollTimeout(int t) {m_poll_timeout=t;}; ///< set the timeout used for poll() … … 85 88 void dumpInfo(); ///< print some information about the manager to stdout/stderr 86 89 87 bool registerStream(Stream Processor *); ///< register an iso stream with the manager88 bool unregisterStream(Stream Processor *); ///< unregister an iso stream from the manager90 bool registerStream(Streaming::StreamProcessor *); ///< register an iso stream with the manager 91 bool unregisterStream(Streaming::StreamProcessor *); ///< unregister an iso stream from the manager 89 92 90 93 bool startHandlers(); ///< start the managed ISO handlers … … 93 96 94 97 bool reset(); ///< reset the ISO manager and all streams 95 96 bool prepare(); ///< prepare the ISO manager and all streams97 98 98 bool init(); 99 99 100 void disablePolling(StreamProcessor *); ///< disables polling on a stream 101 void enablePolling(StreamProcessor *); ///< enables polling on a stream 100 bool disable(IsoHandler *); ///< disables a handler 101 bool enable(IsoHandler *); ///< enables a handler 102 ///> disables the handler attached to the stream 103 bool stopHandlerForStream(Streaming::StreamProcessor *); 104 ///> starts the handler attached to the specific stream 105 bool startHandlerForStream(Streaming::StreamProcessor *); 106 ///> starts the handler attached to the specific stream on a specific cycle 107 bool startHandlerForStream(Streaming::StreamProcessor *, int cycle); 102 108 109 /** 110 * returns the latency of a wake-up for this stream. 111 * The latency is the time it takes for a packet is delivered to the 112 * stream after it has been received (was on the wire). 113 * expressed in cycles 114 */ 115 int getPacketLatencyForStream(Streaming::StreamProcessor *); 116 117 void flushHandlerForStream(Streaming::StreamProcessor *stream); 118 119 Ieee1394Service& get1394Service() {return m_service;}; 103 120 // RunnableInterface interface 104 121 public: 105 122 bool Execute(); // note that this is called in we while(running) loop 106 123 bool Init(); 107 pthread_mutex_t m_debug_lock; 124 125 // protects the operations on the lists 126 // (FIXME: should be changed into a lock-free approach) 127 pthread_mutex_t m_list_lock; 108 128 109 129 // the state machine 110 130 private: 111 enum EHandlerStates {131 enum eHandlerStates { 112 132 E_Created, 113 133 E_Prepared, … … 116 136 }; 117 137 118 enum EHandlerStates m_State;119 138 enum eHandlerStates m_State; 139 const char *eHSToString(enum eHandlerStates); 120 140 private: 121 141 /// iterate all child handlers … … 123 143 124 144 private: 145 Ieee1394Service& m_service; 125 146 // note: there is a disctinction between streams and handlers 126 147 // because one handler can serve multiple streams (in case of … … 139 160 140 161 // the collection of streams 141 Stream ProcessorVector m_StreamProcessors;162 Streaming::StreamProcessorVector m_StreamProcessors; 142 163 143 164 // poll stuff 144 165 int m_poll_timeout; 145 struct pollfd *m_poll_fds; 146 int m_poll_nfds; 166 // FD map sync requested 167 int32_t m_request_fdmap_update; 168 void updateShadowVars(); 147 169 148 bool rebuildFdMap(); 170 // shadow variables 171 struct pollfd m_poll_fds_shadow[FFADO_MAX_ISO_HANDLERS_PER_PORT]; 172 IsoHandler *m_IsoHandler_map_shadow[FFADO_MAX_ISO_HANDLERS_PER_PORT]; 173 unsigned int m_poll_nfds_shadow; 174 175 void requestShadowUpdate(); 149 176 150 177 // threading … … 161 188 }; 162 189 163 }164 165 190 #endif /* __FFADO_ISOHANDLERMANAGER__ */ 166 191 trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp
r748 r750 25 25 #include "AmdtpPort.h" 26 26 #include "../StreamProcessorManager.h" 27 27 #include "devicemanager.h" 28 29 #include "libieee1394/ieee1394service.h" 30 #include "libieee1394/IsoHandlerManager.h" 28 31 #include "libieee1394/cycletimer.h" 29 32 … … 40 43 {} 41 44 42 bool AmdtpReceiveStreamProcessor::prepareChild() { 43 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing (%p)...\n", this); 44 45 switch (m_manager->getNominalRate()) { 45 unsigned int 46 AmdtpReceiveStreamProcessor::getSytInterval() { 47 switch (m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate()) { 46 48 case 32000: 47 49 case 44100: 48 50 case 48000: 49 m_syt_interval = 8; 50 break; 51 return 8; 51 52 case 88200: 52 53 case 96000: 53 m_syt_interval = 16; 54 break; 54 return 16; 55 55 case 176400: 56 56 case 192000: 57 m_syt_interval = 32; 58 break; 57 return 32; 59 58 default: 60 debugError("Unsupported rate: %d\n", m_manager->getNominalRate()); 61 return false; 62 } 59 debugError("Unsupported rate: %d\n", m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate()); 60 return 0; 61 } 62 } 63 64 bool AmdtpReceiveStreamProcessor::prepareChild() { 65 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing (%p)...\n", this); 66 m_syt_interval = getSytInterval(); 63 67 return true; 64 68 } … … 89 93 (length >= 2*sizeof(quadlet_t)); 90 94 if(ok) { 91 uint64_t now = m_ parent.get1394Service().getCycleTimer();95 uint64_t now = m_Parent.get1394Service().getCycleTimer(); 92 96 //=> convert the SYT to a full timestamp in ticks 93 97 m_last_timestamp = sytRecvToFullTicks((uint32_t)ntohs(packet->syt), trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h
r748 r750 91 91 {return 4;}; 92 92 virtual unsigned int getMaxPacketSize() 93 {return 4 * (2 + m_syt_interval* m_dimension);};93 {return 4 * (2 + getSytInterval() * m_dimension);}; 94 94 virtual unsigned int getEventsPerFrame() 95 95 { return m_dimension; }; 96 96 virtual unsigned int getNominalFramesPerPacket() 97 {return m_syt_interval;};97 {return getSytInterval();}; 98 98 99 99 protected: … … 103 103 bool decodePacketPorts(quadlet_t *data, unsigned int nevents, unsigned int dbc); 104 104 int decodeMBLAEventsToPort(AmdtpAudioPort *, quadlet_t *data, unsigned int offset, unsigned int nevents); 105 106 unsigned int getSytInterval(); 105 107 106 108 int m_dimension; trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp
r748 r750 25 25 #include "AmdtpPort.h" 26 26 #include "../StreamProcessorManager.h" 27 27 #include "devicemanager.h" 28 29 #include "libieee1394/ieee1394service.h" 30 #include "libieee1394/IsoHandlerManager.h" 28 31 #include "libieee1394/cycletimer.h" 29 32 … … 57 60 /* Our node ID can change after a bus reset, so it is best to fetch 58 61 * our node ID for each packet. */ 59 packet->sid = m_ handler->getLocalNodeId() & 0x3f;62 packet->sid = m_Parent.get1394Service().getLocalNodeId() & 0x3f; 60 63 61 64 packet->dbs = m_dimension; … … 276 279 /* Our node ID can change after a bus reset, so it is best to fetch 277 280 * our node ID for each packet. */ 278 packet->sid = m_ handler->getLocalNodeId() & 0x3f;281 packet->sid = m_Parent.get1394Service().getLocalNodeId() & 0x3f; 279 282 280 283 packet->dbs = m_dimension; … … 345 348 } 346 349 350 unsigned int 351 AmdtpTransmitStreamProcessor::getSytInterval() { 352 switch (m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate()) { 353 case 32000: 354 case 44100: 355 case 48000: 356 return 8; 357 case 88200: 358 case 96000: 359 return 16; 360 case 176400: 361 case 192000: 362 return 32; 363 default: 364 debugError("Unsupported rate: %d\n", m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate()); 365 return 0; 366 } 367 } 368 unsigned int 369 AmdtpTransmitStreamProcessor::getFDF() { 370 switch (m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate()) { 371 case 32000: return IEC61883_FDF_SFC_32KHZ; 372 case 44100: return IEC61883_FDF_SFC_44K1HZ; 373 case 48000: return IEC61883_FDF_SFC_48KHZ; 374 case 88200: return IEC61883_FDF_SFC_88K2HZ; 375 case 96000: return IEC61883_FDF_SFC_96KHZ; 376 case 176400: return IEC61883_FDF_SFC_176K4HZ; 377 case 192000: return IEC61883_FDF_SFC_192KHZ; 378 default: 379 debugError("Unsupported rate: %d\n", m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate()); 380 return 0; 381 } 382 } 383 347 384 bool AmdtpTransmitStreamProcessor::prepareChild() 348 385 { 349 386 debugOutput ( DEBUG_LEVEL_VERBOSE, "Preparing (%p)...\n", this ); 350 switch ( m_manager->getNominalRate() ) 351 { 352 case 32000: 353 m_syt_interval = 8; 354 m_fdf = IEC61883_FDF_SFC_32KHZ; 355 break; 356 case 44100: 357 m_syt_interval = 8; 358 m_fdf = IEC61883_FDF_SFC_44K1HZ; 359 break; 360 default: 361 case 48000: 362 m_syt_interval = 8; 363 m_fdf = IEC61883_FDF_SFC_48KHZ; 364 break; 365 case 88200: 366 m_syt_interval = 16; 367 m_fdf = IEC61883_FDF_SFC_88K2HZ; 368 break; 369 case 96000: 370 m_syt_interval = 16; 371 m_fdf = IEC61883_FDF_SFC_96KHZ; 372 break; 373 case 176400: 374 m_syt_interval = 32; 375 m_fdf = IEC61883_FDF_SFC_176K4HZ; 376 break; 377 case 192000: 378 m_syt_interval = 32; 379 m_fdf = IEC61883_FDF_SFC_192KHZ; 380 break; 381 } 387 m_syt_interval = getSytInterval(); 388 m_fdf = getFDF(); 382 389 383 390 iec61883_cip_init ( … … 385 392 IEC61883_FMT_AMDTP, 386 393 m_fdf, 387 m_ manager->getNominalRate(),394 m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate(), 388 395 m_dimension, 389 396 m_syt_interval ); trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h
r748 r750 98 98 {return 4;}; 99 99 virtual unsigned int getMaxPacketSize() 100 {return 4 * (2 + m_syt_interval* m_dimension);};100 {return 4 * (2 + getSytInterval() * m_dimension);}; 101 101 virtual unsigned int getEventsPerFrame() 102 102 { return m_dimension; }; 103 103 virtual unsigned int getNominalFramesPerPacket() 104 {return m_syt_interval;};104 {return getSytInterval();}; 105 105 106 106 protected: … … 123 123 unsigned int offset, unsigned int nevents); 124 124 125 unsigned int getFDF(); 126 unsigned int getSytInterval(); 127 125 128 struct iec61883_cip m_cip_status; 126 129 int m_dimension; trunk/libffado/src/libstreaming/generic/Port.cpp
r742 r750 63 63 */ 64 64 bool Port::init() { 65 if (m_State != E_Created) { 66 debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 65 debugOutput( DEBUG_LEVEL_VERBOSE, "Initialize port %s\n", m_Name.c_str()); 66 if (m_State != E_Created) { 67 debugFatal("Port (%s) not in E_Created state: %d\n", m_Name.c_str(), m_State); 67 68 return false; 68 69 } trunk/libffado/src/libstreaming/generic/PortManager.cpp
r742 r750 102 102 debugOutput( DEBUG_LEVEL_VERBOSE, "Adding port %s, type: %d, dir: %d, dtype: %d\n", 103 103 port->getName().c_str(), port->getPortType(), port->getDirection(), port->getDataType()); 104 104 105 port->setVerboseLevel(getDebugLevel()); 106 105 107 if (makeNameUnique(port)) { 106 108 m_Ports.push_back(port); … … 178 180 179 181 void PortManager::setVerboseLevel(int i) { 180 181 182 setDebugLevel(i); 182 183 183 for ( PortVectorIterator it = m_Ports.begin(); 184 184 it != m_Ports.end(); … … 187 187 (*it)->setVerboseLevel(i); 188 188 } 189 190 189 } 191 190 trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp
r749 r750 23 23 24 24 #include "StreamProcessor.h" 25 #include "../StreamProcessorManager.h" 26 27 #include "devicemanager.h" 28 29 #include "libieee1394/ieee1394service.h" 30 #include "libieee1394/IsoHandlerManager.h" 25 31 #include "libieee1394/cycletimer.h" 26 #include "../StreamProcessorManager.h"27 32 28 33 #include "libutil/Atomic.h" … … 40 45 , m_next_state( ePS_Invalid ) 41 46 , m_cycle_to_switch_state( 0 ) 42 , m_ parent( parent )47 , m_Parent( parent ) 43 48 , m_channel( -1 ) 44 , m_handler( NULL )45 49 , m_dropped(0) 46 50 , m_last_timestamp(0) … … 48 52 , m_scratch_buffer( NULL ) 49 53 , m_scratch_buffer_size_bytes( 0 ) 50 , m_manager( NULL )51 54 , m_ticks_per_frame( 0 ) 52 55 , m_last_cycle( -1 ) … … 59 62 60 63 StreamProcessor::~StreamProcessor() { 64 m_Parent.getDeviceManager().getStreamProcessorManager().unregisterProcessor(this); 65 if(!m_Parent.get1394Service().getIsoHandlerManager().unregisterStream(this)) { 66 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not unregister stream processor with the Iso manager\n"); 67 } 68 61 69 if (m_data_buffer) delete m_data_buffer; 62 70 if (m_scratch_buffer) delete[] m_scratch_buffer; … … 64 72 65 73 uint64_t StreamProcessor::getTimeNow() { 66 return m_ parent.get1394Service().getCycleTimerTicks();74 return m_Parent.get1394Service().getCycleTimerTicks(); 67 75 } 68 76 69 77 int StreamProcessor::getMaxFrameLatency() { 70 78 if (getType() == ePT_Receive) { 71 return (int)(m_ handler->getWakeupInterval() * TICKS_PER_CYCLE);79 return (int)(m_Parent.get1394Service().getIsoHandlerManager().getPacketLatencyForStream( this ) * TICKS_PER_CYCLE); 72 80 } else { 73 return (int)(m_ handler->getWakeupInterval() * TICKS_PER_CYCLE);81 return (int)(m_Parent.get1394Service().getIsoHandlerManager().getPacketLatencyForStream( this ) * TICKS_PER_CYCLE); 74 82 } 75 83 } … … 78 86 StreamProcessor::getNominalPacketsNeeded(unsigned int nframes) 79 87 { 80 unsigned int nominal_frames_per_second = m_manager->getNominalRate(); 88 unsigned int nominal_frames_per_second 89 = m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate(); 81 90 uint64_t nominal_ticks_per_frame = TICKS_PER_SECOND / nominal_frames_per_second; 82 91 uint64_t nominal_ticks = nominal_ticks_per_frame * nframes; … … 88 97 StreamProcessor::getPacketsPerPeriod() 89 98 { 90 return getNominalPacketsNeeded(m_ manager->getPeriodSize());99 return getNominalPacketsNeeded(m_Parent.getDeviceManager().getStreamProcessorManager().getPeriodSize()); 91 100 } 92 101 … … 95 104 * Buffer management and manipulation * 96 105 ***********************************************/ 106 void StreamProcessor::flush() { 107 m_Parent.get1394Service().getIsoHandlerManager().flushHandlerForStream(this); 108 } 109 97 110 int StreamProcessor::getBufferFill() { 98 111 return m_data_buffer->getBufferFill(); … … 112 125 // pass before these packets are processed. Adding this extra term makes that 113 126 // the period boundary is signalled later 114 time_at_period = addTicks(time_at_period, m_ manager->getSyncSource().getSyncDelay());115 116 uint64_t cycle_timer=m_ parent.get1394Service().getCycleTimerTicks();127 time_at_period = addTicks(time_at_period, m_Parent.getDeviceManager().getStreamProcessorManager().getSyncSource().getSyncDelay()); 128 129 uint64_t cycle_timer=m_Parent.get1394Service().getCycleTimerTicks(); 117 130 118 131 // calculate the time until the next period … … 146 159 { 147 160 if (getType() == ePT_Receive) { 148 ffado_timestamp_t next_period_boundary=m_data_buffer->getTimestampFromHead(m_ manager->getPeriodSize());161 ffado_timestamp_t next_period_boundary=m_data_buffer->getTimestampFromHead(m_Parent.getDeviceManager().getStreamProcessorManager().getPeriodSize()); 149 162 150 163 #ifdef DEBUG … … 159 172 return (uint64_t)next_period_boundary; 160 173 } else { 161 ffado_timestamp_t next_period_boundary=m_data_buffer->getTimestampFromTail((m_ manager->getNbBuffers()-1) * m_manager->getPeriodSize());174 ffado_timestamp_t next_period_boundary=m_data_buffer->getTimestampFromTail((m_Parent.getDeviceManager().getStreamProcessorManager().getNbBuffers()-1) * m_Parent.getDeviceManager().getStreamProcessorManager().getPeriodSize()); 162 175 163 176 #ifdef DEBUG … … 423 436 // we the packet we are constructing will be sent out 424 437 // on 'cycle', not 'now'. 425 unsigned int ctr = m_ parent.get1394Service().getCycleTimer();438 unsigned int ctr = m_Parent.get1394Service().getCycleTimer(); 426 439 int now_cycles = (int)CYCLE_TIMER_GET_CYCLES(ctr); 427 440 … … 615 628 // use the ts parameter. It specifies the time of the block's 616 629 // last sample. 617 float srate = m_ manager->getSyncSource().getTicksPerFrame();630 float srate = m_Parent.getDeviceManager().getStreamProcessorManager().getSyncSource().getTicksPerFrame(); 618 631 assert(srate != 0.0); 619 632 int64_t this_block_length_in_ticks = (int64_t)(((float)nbframes) * srate); … … 801 814 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "init...\n"); 802 815 816 if(!m_Parent.get1394Service().getIsoHandlerManager().registerStream(this)) { 817 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not register stream processor with the Iso manager\n"); 818 return false; 819 } 820 if(!m_Parent.getDeviceManager().getStreamProcessorManager().registerProcessor(this)) { 821 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not register stream processor with the SP manager\n"); 822 return false; 823 } 824 803 825 // initialization can be done without requesting it 804 826 // from the packet loop … … 810 832 { 811 833 debugOutput( DEBUG_LEVEL_VERBOSE, "Prepare SP (%p)...\n", this); 812 if(!m_manager) {813 debugFatal("Not attached to a manager!\n");814 return false;815 }816 834 817 835 // make the scratch buffer one period of frames long 818 m_scratch_buffer_size_bytes = m_ manager->getPeriodSize() * getEventsPerFrame() * getEventSize();836 m_scratch_buffer_size_bytes = m_Parent.getDeviceManager().getStreamProcessorManager().getPeriodSize() * getEventsPerFrame() * getEventSize(); 819 837 debugOutput( DEBUG_LEVEL_VERBOSE, " Allocate scratch buffer of %d quadlets\n"); 820 838 if(m_scratch_buffer) delete[] m_scratch_buffer; … … 832 850 debugOutput( DEBUG_LEVEL_VERBOSE, "Prepared for:\n"); 833 851 debugOutput( DEBUG_LEVEL_VERBOSE, " Samplerate: %d\n", 834 m_ manager->getNominalRate());852 m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate()); 835 853 debugOutput( DEBUG_LEVEL_VERBOSE, " PeriodSize: %d, NbBuffers: %d\n", 836 m_ manager->getPeriodSize(), m_manager->getNbBuffers());854 m_Parent.getDeviceManager().getStreamProcessorManager().getPeriodSize(), m_Parent.getDeviceManager().getStreamProcessorManager().getNbBuffers()); 837 855 debugOutput( DEBUG_LEVEL_VERBOSE, " Port: %d, Channel: %d\n", 838 getPort(), m_channel);856 m_Parent.get1394Service().getPort(), m_channel); 839 857 840 858 // initialization can be done without requesting it … … 873 891 uint64_t tx; 874 892 if (t < 0) { 875 tx = addTicks(m_ parent.get1394Service().getCycleTimerTicks(), 200 * TICKS_PER_CYCLE);893 tx = addTicks(m_Parent.get1394Service().getCycleTimerTicks(), 200 * TICKS_PER_CYCLE); 876 894 } else { 877 895 tx = t; 878 896 } 897 uint64_t start_handler_ticks = substractTicks(tx, 100 * TICKS_PER_CYCLE); 898 879 899 debugOutput(DEBUG_LEVEL_VERBOSE,"for %s SP (%p)\n", ePTToString(getType()), this); 880 uint64_t now = m_ parent.get1394Service().getCycleTimerTicks();900 uint64_t now = m_Parent.get1394Service().getCycleTimerTicks(); 881 901 debugOutput(DEBUG_LEVEL_VERBOSE," Now : %011llu (%03us %04uc %04ut)\n", 882 902 now, … … 890 910 (unsigned int)TICKS_TO_OFFSET(tx)); 891 911 if (m_state == ePS_Stopped) { 912 if(!m_Parent.get1394Service().getIsoHandlerManager().startHandlerForStream( 913 this, TICKS_TO_CYCLES(start_handler_ticks))) { 914 debugError("Could not start handler for SP %p\n", this); 915 return false; 916 } 892 917 return scheduleStateTransition(ePS_WaitingForStream, tx); 893 918 } else if (m_state == ePS_Running) { … … 902 927 uint64_t tx; 903 928 if (t < 0) { 904 tx = addTicks(m_ parent.get1394Service().getCycleTimerTicks(), 200 * TICKS_PER_CYCLE);929 tx = addTicks(m_Parent.get1394Service().getCycleTimerTicks(), 200 * TICKS_PER_CYCLE); 905 930 } else { 906 931 tx = t; 907 932 } 908 933 debugOutput(DEBUG_LEVEL_VERBOSE,"for %s SP (%p)\n", ePTToString(getType()), this); 909 uint64_t now = m_ parent.get1394Service().getCycleTimerTicks();934 uint64_t now = m_Parent.get1394Service().getCycleTimerTicks(); 910 935 debugOutput(DEBUG_LEVEL_VERBOSE," Now : %011llu (%03us %04uc %04ut)\n", 911 936 now, … … 924 949 uint64_t tx; 925 950 if (t < 0) { 926 tx = addTicks(m_ parent.get1394Service().getCycleTimerTicks(), 200 * TICKS_PER_CYCLE);951 tx = addTicks(m_Parent.get1394Service().getCycleTimerTicks(), 200 * TICKS_PER_CYCLE); 927 952 } else { 928 953 tx = t; 929 954 } 930 955 debugOutput(DEBUG_LEVEL_VERBOSE,"for %s SP (%p)\n", ePTToString(getType()), this); 931 uint64_t now = m_ parent.get1394Service().getCycleTimerTicks();956 uint64_t now = m_Parent.get1394Service().getCycleTimerTicks(); 932 957 debugOutput(DEBUG_LEVEL_VERBOSE," Now : %011llu (%03us %04uc %04ut)\n", 933 958 now, … … 940 965 (unsigned int)TICKS_TO_CYCLES(tx), 941 966 (unsigned int)TICKS_TO_OFFSET(tx)); 967 942 968 return scheduleStateTransition(ePS_Stopped, tx); 943 969 } … … 946 972 uint64_t tx; 947 973 if (t < 0) { 948 tx = addTicks(m_ parent.get1394Service().getCycleTimerTicks(), 200 * TICKS_PER_CYCLE);974 tx = addTicks(m_Parent.get1394Service().getCycleTimerTicks(), 200 * TICKS_PER_CYCLE); 949 975 } else { 950 976 tx = t; 951 977 } 952 978 debugOutput(DEBUG_LEVEL_VERBOSE,"for %s SP (%p)\n", ePTToString(getType()), this); 953 uint64_t now = m_ parent.get1394Service().getCycleTimerTicks();979 uint64_t now = m_Parent.get1394Service().getCycleTimerTicks(); 954 980 debugOutput(DEBUG_LEVEL_VERBOSE," Now : %011llu (%03us %04uc %04ut)\n", 955 981 now, … … 1032 1058 { 1033 1059 float ticks_per_frame; 1034 unsigned int ringbuffer_size_frames = (m_ manager->getNbBuffers() + 1) * m_manager->getPeriodSize();1060 unsigned int ringbuffer_size_frames = (m_Parent.getDeviceManager().getStreamProcessorManager().getNbBuffers() + 1) * m_Parent.getDeviceManager().getStreamProcessorManager().getPeriodSize(); 1035 1061 1036 1062 debugOutput(DEBUG_LEVEL_VERBOSE, "Enter from state: %s\n", ePSToString(m_state)); … … 1044 1070 1045 1071 // prepare the framerate estimate 1046 ticks_per_frame = (TICKS_PER_SECOND*1.0) / ((float)m_ manager->getNominalRate());1072 ticks_per_frame = (TICKS_PER_SECOND*1.0) / ((float)m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate()); 1047 1073 m_ticks_per_frame = ticks_per_frame; 1048 1074 debugOutput(DEBUG_LEVEL_VERBOSE,"Initializing remote ticks/frame to %f\n", ticks_per_frame); … … 1056 1082 result &= m_data_buffer->setUpdatePeriod( getNominalFramesPerPacket() ); 1057 1083 } else { 1058 result &= m_data_buffer->setUpdatePeriod( m_ manager->getPeriodSize() );1084 result &= m_data_buffer->setUpdatePeriod( m_Parent.getDeviceManager().getStreamProcessorManager().getPeriodSize() ); 1059 1085 } 1060 1086 result &= m_data_buffer->setNominalRate(ticks_per_frame); … … 1070 1096 { 1071 1097 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting up port %s\n",(*it)->getName().c_str()); 1072 if(!(*it)->setBufferSize(m_ manager->getPeriodSize())) {1073 debugFatal("Could not set buffer size to %d\n",m_ manager->getPeriodSize());1098 if(!(*it)->setBufferSize(m_Parent.getDeviceManager().getStreamProcessorManager().getPeriodSize())) { 1099 debugFatal("Could not set buffer size to %d\n",m_Parent.getDeviceManager().getStreamProcessorManager().getPeriodSize()); 1074 1100 return false; 1075 1101 } … … 1125 1151 break; 1126 1152 case ePS_DryRunning: 1127 // what to do here? 1153 if(!m_Parent.get1394Service().getIsoHandlerManager().stopHandlerForStream(this)) { 1154 debugError("Could not stop handler for SP %p\n", this); 1155 return false; 1156 } 1128 1157 break; 1129 1158 default: … … 1251 1280 } 1252 1281 if (getType() == ePT_Transmit) { 1253 ringbuffer_size_frames = m_ manager->getNbBuffers() * m_manager->getPeriodSize();1282 ringbuffer_size_frames = m_Parent.getDeviceManager().getStreamProcessorManager().getNbBuffers() * m_Parent.getDeviceManager().getStreamProcessorManager().getPeriodSize(); 1254 1283 debugOutput(DEBUG_LEVEL_VERBOSE, "Prefill transmit SP %p with %u frames\n", this, ringbuffer_size_frames); 1255 1284 // prefill the buffer … … 1530 1559 { 1531 1560 debugOutputShort( DEBUG_LEVEL_NORMAL, " StreamProcessor %p information\n", this); 1532 debugOutputShort( DEBUG_LEVEL_NORMAL, " Port, Channel : %d, %d\n", getPort(), m_channel);1561 debugOutputShort( DEBUG_LEVEL_NORMAL, " Port, Channel : %d, %d\n", m_Parent.get1394Service().getPort(), m_channel); 1533 1562 debugOutputShort( DEBUG_LEVEL_NORMAL, " StreamProcessor info:\n"); 1534 if (m_handler) { 1535 uint64_t now = m_parent.get1394Service().getCycleTimerTicks(); 1536 debugOutputShort( DEBUG_LEVEL_NORMAL, " Now : %011llu (%03us %04uc %04ut)\n", 1537 now, 1538 (unsigned int)TICKS_TO_SECS(now), 1539 (unsigned int)TICKS_TO_CYCLES(now), 1540 (unsigned int)TICKS_TO_OFFSET(now)); 1541 } 1563 uint64_t now = m_Parent.get1394Service().getCycleTimerTicks(); 1564 debugOutputShort( DEBUG_LEVEL_NORMAL, " Now : %011llu (%03us %04uc %04ut)\n", 1565 now, 1566 (unsigned int)TICKS_TO_SECS(now), 1567 (unsigned int)TICKS_TO_CYCLES(now), 1568 (unsigned int)TICKS_TO_OFFSET(now)); 1542 1569 debugOutputShort( DEBUG_LEVEL_NORMAL, " Xruns : %s\n", (m_in_xrun ? "True":"False")); 1543 1570 debugOutputShort( DEBUG_LEVEL_NORMAL, " State : %s\n", ePSToString(m_state)); … … 1545 1572 debugOutputShort( DEBUG_LEVEL_NORMAL, " transition at : %u\n", m_cycle_to_switch_state); 1546 1573 debugOutputShort( DEBUG_LEVEL_NORMAL, " Buffer : %p\n", m_data_buffer); 1547 debugOutputShort( DEBUG_LEVEL_NORMAL, " Nominal framerate : %u\n", m_ manager->getNominalRate());1574 debugOutputShort( DEBUG_LEVEL_NORMAL, " Nominal framerate : %u\n", m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate()); 1548 1575 debugOutputShort( DEBUG_LEVEL_NORMAL, " Device framerate : Sync: %f, Buffer %f\n", 1549 24576000.0/m_ manager->getSyncSource().m_data_buffer->getRate(),1576 24576000.0/m_Parent.getDeviceManager().getStreamProcessorManager().getSyncSource().m_data_buffer->getRate(), 1550 1577 24576000.0/m_data_buffer->getRate() 1551 1578 ); trunk/libffado/src/libstreaming/generic/StreamProcessor.h
r748 r750 26 26 27 27 #include "ffadodevice.h" 28 #include "libieee1394/ieee1394service.h"29 28 30 29 #include "PortManager.h" 31 #include "../util/IsoHandler.h"32 30 33 31 #include "libutil/StreamStatistics.h" … … 54 52 public Util::OptionContainer 55 53 { 56 57 54 friend class StreamProcessorManager; // FIXME: get rid of this 58 55 … … 136 133 virtual ~StreamProcessor(); 137 134 protected: 138 FFADODevice& m_ parent;135 FFADODevice& m_Parent; 139 136 140 137 public: // the public receive/transmit functions … … 179 176 */ 180 177 bool putSilenceFrames(unsigned int nbframes, int64_t ts); 181 178 182 179 /** 183 180 * @brief Shifts the stream with the specified number of frames … … 191 188 */ 192 189 bool shiftStream(int nframes); 190 191 /** 192 * @brief tries to fill/sink the stream as far as possible 193 */ 194 void flush(); 195 193 196 protected: // the helper receive/transmit functions 194 197 enum eChildReturnValue { … … 260 263 bool setChannel(int c) 261 264 {m_channel = c; return true;}; 262 int getPort() {return m_parent.get1394Service().getPort();}; 265 266 virtual unsigned int getNbPacketsIsoXmitBuffer() 267 {return (getPacketsPerPeriod() * 750)/1000;}; 263 268 virtual unsigned int getPacketsPerPeriod(); 264 269 virtual unsigned int getMaxPacketSize() = 0; 265 // do we need the handler?266 void setHandler( IsoHandler * h) {m_handler = h;};267 void clearHandler() {m_handler = NULL;};268 270 private: 269 271 int m_channel; 270 protected:271 IsoHandler *m_handler; // needed for local id and cycle counter272 272 273 273 protected: // FIXME: move to private … … 298 298 byte_t* m_scratch_buffer; 299 299 size_t m_scratch_buffer_size_bytes; 300 300 301 protected: 301 StreamProcessorManager *m_manager;302 303 302 // frame counter & sync stuff 304 303 public: … … 442 441 private: 443 442 bool m_in_xrun; 444 445 protected: // SPM related446 void setManager(StreamProcessorManager *manager) {m_manager=manager;};447 void clearManager() {m_manager=NULL;};448 443 449 444 public: trunk/libffado/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp
r748 r750 26 26 #include "MotuPort.h" 27 27 #include "../StreamProcessorManager.h" 28 28 #include "devicemanager.h" 29 30 #include "libieee1394/ieee1394service.h" 31 #include "libieee1394/IsoHandlerManager.h" 29 32 #include "libieee1394/cycletimer.h" 30 33 … … 74 77 unsigned int 75 78 MotuReceiveStreamProcessor::getMaxPacketSize() { 76 int framerate = m_ manager->getNominalRate();79 int framerate = m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate(); 77 80 return framerate<=48000?616:(framerate<=96000?1032:1160); 78 81 } … … 80 83 unsigned int 81 84 MotuReceiveStreamProcessor::getNominalFramesPerPacket() { 82 int framerate = m_ manager->getNominalRate();85 int framerate = m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate(); 83 86 return framerate<=48000?8:(framerate<=96000?16:32); 84 87 } … … 90 93 // prepare the framerate estimate 91 94 // FIXME: not needed anymore? 92 //m_ticks_per_frame = (TICKS_PER_SECOND*1.0) / ((float)m_ manager->getNominalRate());95 //m_ticks_per_frame = (TICKS_PER_SECOND*1.0) / ((float)m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate()); 93 96 94 97 return true; … … 137 140 // we can just pick it straight from the packet. 138 141 uint32_t last_sph = ntohl(*(quadlet_t *)(data+8+(n_events-1)*event_length)); 139 m_last_timestamp = sphRecvToFullTicks(last_sph, m_ parent.get1394Service().getCycleTimer());142 m_last_timestamp = sphRecvToFullTicks(last_sph, m_Parent.get1394Service().getCycleTimer()); 140 143 return eCRV_OK; 141 144 } else { … … 178 181 #ifdef DEBUG 179 182 if(isRunning()) { 180 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"STMP: %lluticks | buff=%d,tpf=%f\n",181 m_last_timestamp, m_handler->getWakeupInterval(),getTicksPerFrame());183 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"STMP: %lluticks | tpf=%f\n", 184 m_last_timestamp, getTicksPerFrame()); 182 185 } 183 186 #endif trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp
r749 r750 26 26 #include "MotuPort.h" 27 27 #include "../StreamProcessorManager.h" 28 28 #include "devicemanager.h" 29 30 #include "libieee1394/ieee1394service.h" 31 #include "libieee1394/IsoHandlerManager.h" 29 32 #include "libieee1394/cycletimer.h" 30 33 … … 67 70 unsigned int 68 71 MotuTransmitStreamProcessor::getMaxPacketSize() { 69 int framerate = m_ manager->getNominalRate();72 int framerate = m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate(); 70 73 return framerate<=48000?616:(framerate<=96000?1032:1160); 71 74 } … … 73 76 unsigned int 74 77 MotuTransmitStreamProcessor::getNominalFramesPerPacket() { 75 int framerate = m_ manager->getNominalRate();78 int framerate = m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate(); 76 79 return framerate<=48000?8:(framerate<=96000?16:32); 77 80 } … … 285 288 286 289 if (m_data_buffer->readFrames(n_events, (char *)(data + 8))) { 287 float ticks_per_frame = m_ manager->getSyncSource().getActualRate();290 float ticks_per_frame = m_Parent.getDeviceManager().getStreamProcessorManager().getSyncSource().getActualRate(); 288 291 289 292 #if TESTTONE … … 378 381 // present. For data-less packets the dbc is the same as the previously 379 382 // transmitted block. 380 *quadlet = htonl(0x00000400 | ((m_ handler->getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16));383 *quadlet = htonl(0x00000400 | ((m_Parent.get1394Service().getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16)); 381 384 quadlet++; 382 385 *quadlet = htonl(0x8222ffff); … … 395 398 // present. For data-less packets the dbc is the same as the previously 396 399 // transmitted block. 397 *quadlet = htonl(0x00000400 | ((m_ handler->getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16));400 *quadlet = htonl(0x00000400 | ((m_Parent.get1394Service().getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16)); 398 401 quadlet++; 399 402 *quadlet = htonl(0x8222ffff); trunk/libffado/src/libstreaming/StreamProcessorManager.cpp
r748 r750 45 45 46 46 IMPL_DEBUG_MODULE( StreamProcessorManager, StreamProcessorManager, DEBUG_LEVEL_VERBOSE ); 47 48 StreamProcessorManager::StreamProcessorManager() 49 : m_is_slave( false ) 50 , m_SyncSource(NULL) 51 , m_nb_buffers( 0 ) 52 , m_period( 0 ) 53 , m_nominal_framerate ( 0 ) 54 , m_xruns(0) 55 , m_xrun_happened( false ) 56 , m_nbperiods(0) 57 { 58 addOption(Util::OptionContainer::Option("slaveMode",false)); 59 } 47 60 48 61 StreamProcessorManager::StreamProcessorManager(unsigned int period, unsigned int framerate, unsigned int nb_buffers) … … 53 66 , m_nominal_framerate ( framerate ) 54 67 , m_xruns(0) 55 , m_ isoManager(0)68 , m_xrun_happened( false ) 56 69 , m_nbperiods(0) 57 70 { … … 60 73 61 74 StreamProcessorManager::~StreamProcessorManager() { 62 if (m_isoManager) delete m_isoManager;63 75 } 64 76 … … 78 90 debugOutput( DEBUG_LEVEL_VERBOSE, "Registering processor (%p)\n",processor); 79 91 assert(processor); 80 assert(m_isoManager);81 82 92 if (processor->getType() == StreamProcessor::ePT_Receive) { 83 93 processor->setVerboseLevel(getDebugLevel()); // inherit debug level 84 85 94 m_ReceiveProcessors.push_back(processor); 86 processor->setManager(this);87 95 return true; 88 96 } … … 90 98 if (processor->getType() == StreamProcessor::ePT_Transmit) { 91 99 processor->setVerboseLevel(getDebugLevel()); // inherit debug level 92 93 100 m_TransmitProcessors.push_back(processor); 94 processor->setManager(this);95 101 return true; 96 102 } … … 113 119 if ( *it == processor ) { 114 120 m_ReceiveProcessors.erase(it); 115 processor->clearManager();116 if(!m_isoManager->unregisterStream(processor)) {117 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not unregister receive stream processor from the Iso manager\n");118 return false;119 }120 121 return true; 121 122 } … … 130 131 if ( *it == processor ) { 131 132 m_TransmitProcessors.erase(it); 132 processor->clearManager();133 if(!m_isoManager->unregisterStream(processor)) {134 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not unregister transmit stream processor from the Iso manager\n");135 return false;136 }137 133 return true; 138 134 } … … 147 143 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting sync source to (%p)\n", s); 148 144 m_SyncSource=s; 149 return true;150 }151 152 bool StreamProcessorManager::init()153 {154 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");155 m_isoManager = new IsoHandlerManager(m_thread_realtime, m_thread_priority + 1);156 if(!m_isoManager) {157 debugFatal("Could not create IsoHandlerManager\n");158 return false;159 }160 m_isoManager->setVerboseLevel(getDebugLevel());161 162 // try to queue up 75% of the frames in the transmit buffer163 unsigned int nb_frames = (getNbBuffers() - 1) * getPeriodSize() * 1000 / 2000;164 m_isoManager->setTransmitBufferNbFrames(nb_frames);165 166 if(!m_isoManager->init()) {167 debugFatal("Could not initialize IsoHandlerManager\n");168 return false;169 }170 171 m_xrun_happened=false;172 145 return true; 173 146 } … … 528 501 bool StreamProcessorManager::start() { 529 502 debugOutput( DEBUG_LEVEL_VERBOSE, "Starting Processors...\n"); 530 assert(m_isoManager);531 532 debugOutput( DEBUG_LEVEL_VERBOSE, "Creating handlers for the StreamProcessors...\n");533 debugOutput( DEBUG_LEVEL_VERBOSE, " Receive processors...\n");534 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin();535 it != m_ReceiveProcessors.end();536 ++it )537 {538 if (!m_isoManager->registerStream(*it)) {539 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not register receive stream processor (%p) with the Iso manager\n",*it);540 return false;541 }542 }543 debugOutput( DEBUG_LEVEL_VERBOSE, " Transmit processors...\n");544 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin();545 it != m_TransmitProcessors.end();546 ++it )547 {548 if (!m_isoManager->registerStream(*it)) {549 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not register transmit stream processor (%p) with the Iso manager\n",*it);550 return false;551 }552 }553 554 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing IsoHandlerManager...\n");555 if (!m_isoManager->prepare()) {556 debugFatal("Could not prepare isoManager\n");557 return false;558 }559 560 debugOutput( DEBUG_LEVEL_VERBOSE, "Starting IsoHandlers...\n");561 if (!m_isoManager->startHandlers(0)) {562 debugFatal("Could not start handlers...\n");563 return false;564 }565 503 566 504 // put all SP's into dry-running state … … 575 513 return false; 576 514 } 577 578 // dump the iso stream information when in verbose mode579 if(getDebugLevel()>=DEBUG_LEVEL_VERBOSE) {580 m_isoManager->dumpInfo();581 }582 583 515 return true; 584 516 } … … 586 518 bool StreamProcessorManager::stop() { 587 519 debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping...\n"); 588 assert(m_isoManager);589 520 590 521 debugOutput( DEBUG_LEVEL_VERBOSE, " scheduling stop for all SP's...\n"); 591 592 522 // switch SP's over to the dry-running state 593 523 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); … … 668 598 debugOutput(DEBUG_LEVEL_VERBOSE, " Timeout waiting for the SP's to stop\n"); 669 599 return false; 670 }671 672 debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping handlers...\n");673 if(!m_isoManager->stopHandlers()) {674 debugFatal("Could not stop ISO handlers\n");675 return false;676 }677 678 debugOutput( DEBUG_LEVEL_VERBOSE, "Unregistering processors from handlers...\n");679 // now unregister all streams from iso manager680 debugOutput( DEBUG_LEVEL_VERBOSE, " Receive processors...\n");681 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin();682 it != m_ReceiveProcessors.end();683 ++it ) {684 if (!m_isoManager->unregisterStream(*it)) {685 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not unregister receive stream processor (%p) from the Iso manager\n",*it);686 return false;687 }688 }689 debugOutput( DEBUG_LEVEL_VERBOSE, " Transmit processors...\n");690 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin();691 it != m_TransmitProcessors.end();692 ++it ) {693 if (!m_isoManager->unregisterStream(*it)) {694 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not unregister transmit stream processor (%p) from the Iso manager\n",*it);695 return false;696 }697 600 } 698 601 return true; … … 806 709 #endif 807 710 bool ready_for_transfer = false; 711 bool ready; 808 712 xrun_occurred = false; 809 713 while (!ready_for_transfer && !xrun_occurred) { … … 812 716 it != m_ReceiveProcessors.end(); 813 717 ++it ) { 814 ready_for_transfer &= ((*it)->canClientTransferFrames(m_period)); 718 ready = ((*it)->canClientTransferFrames(m_period)); 719 ready_for_transfer &= ready; 720 if (!ready) (*it)->flush(); 815 721 xrun_occurred |= (*it)->xrunOccurred(); 816 722 } … … 818 724 it != m_TransmitProcessors.end(); 819 725 ++it ) { 820 ready_for_transfer &= ((*it)->canClientTransferFrames(m_period)); 726 ready = ((*it)->canClientTransferFrames(m_period)); 727 ready_for_transfer &= ready; 728 if (!ready) (*it)->flush(); 821 729 xrun_occurred |= (*it)->xrunOccurred(); 822 730 } 823 731 if (!ready_for_transfer) { 732 824 733 usleep(125); // MAGIC: one cycle sleep... 825 734 735 #if 0 826 736 // in order to avoid this in the future, we increase the sync delay of the sync source SP 827 737 int d = m_SyncSource->getSyncDelay() + TICKS_PER_CYCLE; 828 738 m_SyncSource->setSyncDelay(d); 739 #endif 829 740 830 741 #ifdef DEBUG … … 1048 959 } 1049 960 1050 debugOutputShort( DEBUG_LEVEL_NORMAL, "Iso handler info:\n");1051 m_isoManager->dumpInfo();1052 961 debugOutputShort( DEBUG_LEVEL_NORMAL, "----------------------------------------------------\n"); 1053 962 … … 1056 965 void StreamProcessorManager::setVerboseLevel(int l) { 1057 966 setDebugLevel(l); 1058 1059 if (m_isoManager) m_isoManager->setVerboseLevel(l);1060 967 1061 968 debugOutput( DEBUG_LEVEL_VERBOSE, " Receive processors...\n"); trunk/libffado/src/libstreaming/StreamProcessorManager.h
r742 r750 27 27 #include "generic/Port.h" 28 28 #include "generic/StreamProcessor.h" 29 #include "util/IsoHandlerManager.h"30 29 31 30 #include "debugmodule/debugmodule.h" … … 39 38 40 39 class StreamProcessor; 41 class IsoHandlerManager;42 40 43 41 typedef std::vector<StreamProcessor *> StreamProcessorVector; … … 53 51 public: 54 52 53 StreamProcessorManager(); 55 54 StreamProcessorManager(unsigned int period, unsigned int rate, unsigned int nb_buffers); 56 55 virtual ~StreamProcessorManager(); 57 56 58 bool init(); ///< to be called immediately after the construction59 57 bool prepare(); ///< to be called after the processors are registered 60 58 … … 69 67 bool unregisterProcessor(StreamProcessor *processor); ///< stop managing a streamprocessor 70 68 71 void setPeriodSize(unsigned int period); 72 void setPeriodSize(unsigned int period, unsigned int nb_buffers); 73 unsigned int getPeriodSize() {return m_period;}; 69 void setPeriodSize(unsigned int period) 70 {m_period = period;}; 71 unsigned int getPeriodSize() 72 {return m_period;}; 74 73 75 void setNbBuffers(unsigned int nb_buffers); 76 int getNbBuffers() {return m_nb_buffers;}; 74 void setNbBuffers(unsigned int nb_buffers) 75 {m_nb_buffers = nb_buffers;}; 76 int getNbBuffers() 77 {return m_nb_buffers;}; 77 78 78 79 int getPortCount(enum Port::E_PortType, enum Port::E_Direction); … … 94 95 int getXrunCount() {return m_xruns;}; 95 96 97 void setNominalRate(unsigned int r) {m_nominal_framerate = r;}; 96 98 unsigned int getNominalRate() {return m_nominal_framerate;}; 97 99 uint64_t getTimeOfLastTransfer() { return m_time_of_transfer;}; … … 128 130 // thread sync primitives 129 131 bool m_xrun_happened; 130 131 132 bool m_thread_realtime; 132 133 int m_thread_priority; … … 141 142 unsigned int m_xruns; 142 143 143 IsoHandlerManager *m_isoManager;144 145 144 unsigned int m_nbperiods; 146 145 trunk/libffado/src/libutil/PosixThread.cpp
r742 r750 74 74 } 75 75 76 debugOutput( DEBUG_LEVEL_VERBOSE, "ThreadHandler: start \n");76 debugOutput( DEBUG_LEVEL_VERBOSE, "ThreadHandler: start %p\n", obj); 77 77 78 78 // If Init succeed start the thread loop … … 83 83 } 84 84 85 debugOutput( DEBUG_LEVEL_VERBOSE, "ThreadHandler: exit \n");85 debugOutput( DEBUG_LEVEL_VERBOSE, "ThreadHandler: exit %p\n", obj); 86 86 return 0; 87 87 } … … 94 94 if (fRealTime) { 95 95 96 debugOutput( DEBUG_LEVEL_VERBOSE, "Create RT thread with priority %d\n", fPriority);96 debugOutput( DEBUG_LEVEL_VERBOSE, "Create RT thread %p with priority %d\n", this, fPriority); 97 97 98 98 /* Get the client thread to run as an RT-FIFO … … 138 138 return 0; 139 139 } else { 140 debugOutput( DEBUG_LEVEL_VERBOSE, "Create non RT thread \n");140 debugOutput( DEBUG_LEVEL_VERBOSE, "Create non RT thread %p\n", this); 141 141 142 142 if ((res = pthread_create(&fThread, 0, ThreadHandler, this))) { … … 152 152 { 153 153 if (fThread) { // If thread has been started 154 debugOutput( DEBUG_LEVEL_VERBOSE, "PosixThread::Kill \n");154 debugOutput( DEBUG_LEVEL_VERBOSE, "PosixThread::Kill %p\n", this); 155 155 void* status; 156 156 pthread_cancel(fThread); 157 157 pthread_join(fThread, &status); 158 debugOutput( DEBUG_LEVEL_VERBOSE, "PosixThread::Killed %p\n", this); 158 159 return 0; 159 160 } else { … … 165 166 { 166 167 if (fThread) { // If thread has been started 167 debugOutput( DEBUG_LEVEL_VERBOSE, "PosixThread::Stop \n");168 debugOutput( DEBUG_LEVEL_VERBOSE, "PosixThread::Stop %p\n", this); 168 169 void* status; 169 170 fRunning = false; // Request for the thread to stop 170 171 pthread_join(fThread, &status); 172 debugOutput( DEBUG_LEVEL_VERBOSE, "PosixThread::Stopped %p\n", this); 171 173 return 0; 172 174 } else { trunk/libffado/src/maudio/maudio_avdevice.cpp
r742 r750 40 40 namespace MAudio { 41 41 42 AvDevice::AvDevice( std::auto_ptr<ConfigRom>( configRom ))43 : BeBoB::AvDevice( configRom)42 AvDevice::AvDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 43 : BeBoB::AvDevice( d, configRom) 44 44 , m_model ( NULL ) 45 45 { … … 81 81 82 82 FFADODevice * 83 AvDevice::createDevice( std::auto_ptr<ConfigRom>( configRom ))83 AvDevice::createDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 84 84 { 85 return new AvDevice( configRom );85 return new AvDevice( d, configRom ); 86 86 } 87 87 trunk/libffado/src/maudio/maudio_avdevice.h
r742 r750 54 54 class AvDevice : public BeBoB::AvDevice { 55 55 public: 56 AvDevice( std::auto_ptr<ConfigRom>( configRom ));56 AvDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 57 57 virtual ~AvDevice(); 58 58 59 59 static bool probe( ConfigRom& configRom ); 60 static FFADODevice * createDevice( std::auto_ptr<ConfigRom>( configRom ));60 static FFADODevice * createDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 61 61 virtual bool discover(); 62 62 trunk/libffado/src/motu/motu_avdevice.cpp
r748 r750 186 186 }; 187 187 188 MotuDevice::MotuDevice( std::auto_ptr<ConfigRom>( configRom ))189 : FFADODevice( configRom )188 MotuDevice::MotuDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 189 : FFADODevice( d, configRom ) 190 190 , m_motu_model( MOTUFW_MODEL_NONE ) 191 191 , m_iso_recv_channel ( -1 ) … … 239 239 240 240 FFADODevice * 241 MotuDevice::createDevice( std::auto_ptr<ConfigRom>( configRom ))242 { 243 return new MotuDevice( configRom);241 MotuDevice::createDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 242 { 243 return new MotuDevice(d, configRom); 244 244 } 245 245 trunk/libffado/src/motu/motu_avdevice.h
r742 r750 125 125 public: 126 126 127 MotuDevice( std::auto_ptr<ConfigRom>( configRom ));127 MotuDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ) ); 128 128 virtual ~MotuDevice(); 129 129 130 130 static bool probe( ConfigRom& configRom ); 131 static FFADODevice * createDevice( std::auto_ptr<ConfigRom>( configRom ));131 static FFADODevice * createDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 132 132 static int getConfigurationId( ); 133 133 virtual bool discover(); trunk/libffado/src/SConscript
r747 r750 62 62 libieee1394/ieee1394service.cpp \ 63 63 libieee1394/IEC61883.cpp \ 64 libieee1394/IsoHandler.cpp \ 65 libieee1394/IsoHandlerManager.cpp \ 64 66 libstreaming/StreamProcessorManager.cpp \ 65 67 libstreaming/util/cip.c \ 66 libstreaming/util/IsoHandler.cpp \67 libstreaming/util/IsoHandlerManager.cpp \68 68 libstreaming/generic/StreamProcessor.cpp \ 69 69 libstreaming/generic/Port.cpp \