Changeset 1373

Show
Ignore:
Timestamp:
10/24/08 02:37:37 (12 years ago)
Author:
ppalmers
Message:

make IsoManager? and SPM settings from config.h overridable by the user/distro config file.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0/config.h.in

    r1372 r1373  
    134134#define MAX_XMIT_PACKET_SIZE                         (2048-16) 
    135135#define MAX_XMIT_NB_BUFFERS                                128 
    136 #define MAX_RECV_NB_BUFFERS                                128 
    137  
    138 // should be PAGE_SIZE (4096) for unpatched kernels 
    139 #define RAW1394_RCV_MIN_BUF_STRIDE                        4096 
     136#define MAX_RECV_NB_BUFFERS                                 64 
     137 
     138// the default ISO receive mode.  
     139// 0 = auto, 1 = packet-per-buffer, 2 = bufferfill.  
     140// 'auto' will automatically choose the mode that is expected  
     141// to perform best for the given situation. For large periods  
     142// this is 'bufferfill' mode, for small periods this is  
     143// 'packet-per-buffer' mode. The 'BUFFERFILL_MODE_THRESHOLD'  
     144// defines what a 'large period' is. 
     145#define DEFAULT_ISO_RECEIVE_MODE                             0 
     146 
     147// the number of packets required to fill one period from which 
     148// the bufferfill mode is to be used 
     149#define BUFFERFILL_MODE_THRESHOLD                           64 
     150 
    140151 
    141152#define ISOHANDLER_FLUSH_BEFORE_ITERATE                      0 
     
    187198#define STREAMPROCESSORMANAGER_SYNCSTART_TRIES              10 
    188199#define STREAMPROCESSORMANAGER_SYNC_WAIT_TIME_MSEC          200 
     200#define STREAMPROCESSORMANAGER_NB_ALIGN_TRIES               40 
    189201#define STREAMPROCESSORMANAGER_ALIGN_AVERAGE_TIME_MSEC      400 
    190 #define STREAMPROCESSORMANAGER_NB_ALIGN_TRIES               40 
    191202 
    192203#define STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY           0 
  • branches/libffado-2.0/src/devicemanager.cpp

    r1366 r1373  
    175175        tmp1394Service->setVerboseLevel( getDebugLevel() ); 
    176176        m_1394Services.push_back(tmp1394Service); 
     177 
     178        if(!tmp1394Service->useConfiguration(m_configuration)) { 
     179            debugWarning("Could not load config to 1394service\n"); 
     180        } 
    177181 
    178182        tmp1394Service->setThreadParameters(m_thread_realtime, m_thread_priority); 
  • branches/libffado-2.0/src/libieee1394/ieee1394service.cpp

    r1372 r1373  
    3535#include "libutil/Watchdog.h" 
    3636#include "libutil/PosixMutex.h" 
     37#include "libutil/Configuration.h" 
    3738 
    3839#include <errno.h> 
     
    4950 
    5051Ieee1394Service::Ieee1394Service() 
    51     : m_handle( 0 ) 
     52    : m_configuration( NULL ) 
     53    , m_handle( 0 ) 
    5254    , m_handle_lock( new Util::PosixMutex("SRCVHND") ) 
    5355    , m_resetHandle( 0 ) 
     
    7274        m_channels[i].recv_plug=-1; 
    7375    } 
     76 
    7477} 
    7578 
    7679Ieee1394Service::Ieee1394Service(bool rt, int prio) 
    77     : m_handle( 0 ) 
     80    : m_configuration( NULL ) 
     81    , m_handle( 0 ) 
    7882    , m_handle_lock( new Util::PosixMutex("SRCVHND") ) 
    7983    , m_resetHandle( 0 ) 
     
    121125        raw1394_destroy_handle( m_util_handle ); 
    122126    } 
     127} 
     128 
     129bool 
     130Ieee1394Service:: useConfiguration(Util::Configuration *c) 
     131{ 
     132    m_configuration = c; 
     133    return configurationUpdated(); 
     134} 
     135 
     136bool 
     137Ieee1394Service:: configurationUpdated() 
     138{ 
     139    if(m_configuration) { 
     140         
     141    } 
     142    return true; 
    123143} 
    124144 
     
    252272    raw1394handle_t tmp_handle = raw1394_new_handle(); 
    253273    if ( tmp_handle == NULL ) { 
    254         debugError("Could not get temporaty libraw1394 handle.\n"); 
     274        debugError("Could not get temporary libraw1394 handle.\n"); 
    255275        return false; 
    256276    } 
     
    280300                                   this->resetHandlerLowLevel ); 
    281301 
     302    int split_timeout = IEEE1394SERVICE_MIN_SPLIT_TIMEOUT_USECS; 
     303    if(m_configuration) { 
     304        m_configuration->getValueForSetting("ieee1394.min_split_timeout_usecs", split_timeout); 
     305    } 
     306 
    282307    // set SPLIT_TIMEOUT to one second to cope with DM1x00 devices that 
    283308    // send responses regardless of the timeout 
    284309    int timeout = getSplitTimeoutUsecs(getLocalNodeId()); 
    285     if (timeout < IEEE1394SERVICE_MIN_SPLIT_TIMEOUT_USECS) { 
    286         if(!setSplitTimeoutUsecs(getLocalNodeId(), IEEE1394SERVICE_MIN_SPLIT_TIMEOUT_USECS+124)) { 
    287             debugWarning("Could not set SPLIT_TIMEOUT to min requested\n"); 
     310    debugOutput(DEBUG_LEVEL_VERBOSE, "Minimum SPLIT_TIMEOUT: %d. Current: %d\n", split_timeout, timeout); 
     311    if (timeout < split_timeout) { 
     312        if(!setSplitTimeoutUsecs(getLocalNodeId(), split_timeout+124)) { 
     313            debugWarning("Could not set SPLIT_TIMEOUT to min requested (%d)\n", split_timeout); 
    288314        } 
    289315        timeout = getSplitTimeoutUsecs(getLocalNodeId()); 
    290         if (timeout < IEEE1394SERVICE_MIN_SPLIT_TIMEOUT_USECS) { 
    291             debugWarning("Set SPLIT_TIMEOUT to min requested did not succeed\n"); 
     316        if (timeout < split_timeout) { 
     317            debugWarning("Set SPLIT_TIMEOUT to min requested (%d) did not succeed\n", split_timeout); 
    292318        } 
    293319    } 
     
    309335    } 
    310336    m_pIsoManager->setVerboseLevel(getDebugLevel()); 
    311  
    312     m_pIsoManager->setReceiveMode(RAW1394_DMA_PACKET_PER_BUFFER); 
    313337 
    314338    if(!m_pIsoManager->init()) { 
  • branches/libffado-2.0/src/libieee1394/ieee1394service.h

    r1371 r1373  
    4848namespace Util { 
    4949    class Watchdog; 
     50    class Configuration; 
    5051} 
    5152 
     
    298299     */ 
    299300    int getSplitTimeoutUsecs(fb_nodeid_t nodeId); 
     301 
     302    /** 
     303     * @brief use the provided configuration for this service 
     304     * 
     305     * only update the config once, before init. not thread safe, 
     306     * and no effect when things are already running. 
     307     * 
     308     * @param c configuration to use 
     309     * @return bool if this config is ok. 
     310     */ 
     311    bool useConfiguration(Util::Configuration *c); 
     312 
     313    Util::Configuration *getConfiguration() {return m_configuration;}; 
    300314 
    301315// ISO channel stuff 
     
    335349    raw1394handle_t getHandle() {return m_handle;}; 
    336350 
     351protected: 
     352    Util::Configuration     *m_configuration; 
     353 
    337354private: 
     355    bool configurationUpdated(); 
     356 
    338357    bool startRHThread(); 
    339358    void stopRHThread(); 
  • branches/libffado-2.0/src/libieee1394/IsoHandlerManager.cpp

    r1372 r1373  
    3232#include "libutil/SystemTimeSource.h" 
    3333#include "libutil/Watchdog.h" 
     34#include "libutil/Configuration.h" 
    3435 
    3536#include <cstring> 
     
    4950    , m_running( false ) 
    5051    , m_in_busreset( false ) 
     52    , m_activity_wait_timeout_nsec (ISOHANDLERMANAGER_ISO_TASK_WAIT_TIMEOUT_USECS * 1000LL) 
    5153{ 
    5254} 
     
    388390    struct timespec ts; 
    389391    int result; 
    390     long long int timeout_nsec = ISOHANDLERMANAGER_ISO_TASK_WAIT_TIMEOUT_USECS * 1000LL; 
    391392 
    392393    if (clock_gettime(CLOCK_REALTIME, &ts) == -1) { 
     
    395396    } 
    396397 
    397     ts.tv_nsec += timeout_nsec; 
     398    ts.tv_nsec += m_activity_wait_timeout_nsec; 
    398399    while(ts.tv_nsec >= 1000000000LL) { 
    399400        ts.tv_sec += 1; 
     
    418419                        this, result); 
    419420            debugError("(%p) timeout_nsec=%lld ts.sec=%d ts.nsec=%lld\n",  
    420                        this, timeout_nsec, ts.tv_sec, ts.tv_nsec); 
     421                       this, m_activity_wait_timeout_nsec, ts.tv_sec, ts.tv_nsec); 
    421422            return eAR_Error; 
    422423        } else { 
     
    424425                        this, result, errno); 
    425426            debugError("(%p) timeout_nsec=%lld ts.sec=%d ts.nsec=%lld\n",  
    426                        this, timeout_nsec, ts.tv_sec, ts.tv_nsec); 
     427                       this, m_activity_wait_timeout_nsec, ts.tv_sec, ts.tv_nsec); 
    427428            return eAR_Error; 
    428429        } 
     
    459460   , m_IsoThreadReceive ( NULL ) 
    460461   , m_IsoTaskReceive ( NULL ) 
    461    , m_receive_mode( RAW1394_DMA_PACKET_PER_BUFFER ) 
    462462{ 
    463463} 
     
    471471   , m_IsoThreadReceive ( NULL ) 
    472472   , m_IsoTaskReceive ( NULL ) 
    473    , m_receive_mode( RAW1394_DMA_PACKET_PER_BUFFER ) 
    474473{ 
    475474} 
     
    537536    m_priority = priority; 
    538537 
     538    // grab the options from the parent 
     539    Util::Configuration *config = m_service.getConfiguration(); 
     540    int ihm_iso_prio_increase = ISOHANDLERMANAGER_ISO_PRIO_INCREASE; 
     541    int ihm_iso_prio_increase_xmit = ISOHANDLERMANAGER_ISO_PRIO_INCREASE_XMIT; 
     542    int ihm_iso_prio_increase_recv = ISOHANDLERMANAGER_ISO_PRIO_INCREASE_RECV; 
     543    if(config) { 
     544        config->getValueForSetting("ieee1394.isomanager.prio_increase", ihm_iso_prio_increase); 
     545        config->getValueForSetting("ieee1394.isomanager.prio_increase_xmit", ihm_iso_prio_increase_xmit); 
     546        config->getValueForSetting("ieee1394.isomanager.prio_increase_recv", ihm_iso_prio_increase_recv); 
     547    } 
     548 
    539549    if (m_IsoThreadTransmit) { 
    540550        if (m_realtime) { 
    541551            m_IsoThreadTransmit->AcquireRealTime(m_priority 
    542                                                  + ISOHANDLERMANAGER_ISO_PRIO_INCREASE 
    543                                                  + ISOHANDLERMANAGER_ISO_PRIO_INCREASE_XMIT); 
     552                                                 + ihm_iso_prio_increase 
     553                                                 + ihm_iso_prio_increase_xmit); 
    544554        } else { 
    545555            m_IsoThreadTransmit->DropRealTime(); 
     
    549559        if (m_realtime) { 
    550560            m_IsoThreadReceive->AcquireRealTime(m_priority  
    551                                                 + ISOHANDLERMANAGER_ISO_PRIO_INCREASE 
    552                                                 + ISOHANDLERMANAGER_ISO_PRIO_INCREASE_RECV); 
     561                                                + ihm_iso_prio_increase 
     562                                                + ihm_iso_prio_increase_recv); 
    553563        } else { 
    554564            m_IsoThreadReceive->DropRealTime(); 
     
    566576        debugError("Manager already initialized...\n"); 
    567577        return false; 
     578    } 
     579 
     580    // grab the options from the parent 
     581    Util::Configuration *config = m_service.getConfiguration(); 
     582    int ihm_iso_prio_increase = ISOHANDLERMANAGER_ISO_PRIO_INCREASE; 
     583    int ihm_iso_prio_increase_xmit = ISOHANDLERMANAGER_ISO_PRIO_INCREASE_XMIT; 
     584    int ihm_iso_prio_increase_recv = ISOHANDLERMANAGER_ISO_PRIO_INCREASE_RECV; 
     585    int64_t isotask_activity_timeout_usecs = ISOHANDLERMANAGER_ISO_TASK_WAIT_TIMEOUT_USECS; 
     586    if(config) { 
     587        config->getValueForSetting("ieee1394.isomanager.prio_increase", ihm_iso_prio_increase); 
     588        config->getValueForSetting("ieee1394.isomanager.prio_increase_xmit", ihm_iso_prio_increase_xmit); 
     589        config->getValueForSetting("ieee1394.isomanager.prio_increase_recv", ihm_iso_prio_increase_recv); 
     590        config->getValueForSetting("ieee1394.isomanager.isotask_activity_timeout_usecs", isotask_activity_timeout_usecs); 
    568591    } 
    569592 
     
    576599    } 
    577600    m_IsoTaskTransmit->setVerboseLevel(getDebugLevel()); 
     601    m_IsoTaskTransmit->m_activity_wait_timeout_nsec = isotask_activity_timeout_usecs * 1000LL; 
    578602    m_IsoThreadTransmit = new Util::PosixThread(m_IsoTaskTransmit, "ISOXMT", m_realtime, 
    579                                                 m_priority + ISOHANDLERMANAGER_ISO_PRIO_INCREASE 
    580                                                 + ISOHANDLERMANAGER_ISO_PRIO_INCREASE_XMIT
     603                                                m_priority + ihm_iso_prio_increase 
     604                                                + ihm_iso_prio_increase_xmit
    581605                                                PTHREAD_CANCEL_DEFERRED); 
    582606 
     
    595619    m_IsoTaskReceive->setVerboseLevel(getDebugLevel()); 
    596620    m_IsoThreadReceive = new Util::PosixThread(m_IsoTaskReceive, "ISORCV", m_realtime, 
    597                                                m_priority + ISOHANDLERMANAGER_ISO_PRIO_INCREASE 
    598                                                + ISOHANDLERMANAGER_ISO_PRIO_INCREASE_RECV
     621                                               m_priority + ihm_iso_prio_increase 
     622                                               + ihm_iso_prio_increase_recv
    599623                                               PTHREAD_CANCEL_DEFERRED); 
    600624 
     
    760784    // allocate a handler for this stream 
    761785    if (stream->getType()==StreamProcessor::ePT_Receive) { 
     786        // grab the options from the parent 
     787        Util::Configuration *config = m_service.getConfiguration(); 
     788        int receive_mode_setting = DEFAULT_ISO_RECEIVE_MODE; 
     789        int bufferfill_mode_threshold = BUFFERFILL_MODE_THRESHOLD; 
     790        int min_interrupts_per_period = MINIMUM_INTERRUPTS_PER_PERIOD; 
     791        int max_nb_buffers_recv = MAX_RECV_NB_BUFFERS; 
     792        if(config) { 
     793            config->getValueForSetting("ieee1394.isomanager.iso_receive_mode", receive_mode_setting); 
     794            config->getValueForSetting("ieee1394.isomanager.bufferfill_mode_threshold", bufferfill_mode_threshold); 
     795            config->getValueForSetting("ieee1394.isomanager.min_interrupts_per_period", min_interrupts_per_period); 
     796            config->getValueForSetting("ieee1394.isomanager.max_nb_buffers_recv", max_nb_buffers_recv); 
     797        } 
     798 
    762799        // setup the optimal parameters for the raw1394 ISO buffering 
    763800        unsigned int packets_per_period = stream->getPacketsPerPeriod(); 
    764801        unsigned int max_packet_size = stream->getMaxPacketSize() + 8; // bufferfill takes another 8 bytes for headers 
    765802        unsigned int page_size = getpagesize(); 
     803 
     804        enum raw1394_iso_dma_recv_mode receive_mode; 
     805        switch(receive_mode_setting) { 
     806            case 0: 
     807                if(packets_per_period < (unsigned)bufferfill_mode_threshold) { 
     808                    debugOutput( DEBUG_LEVEL_VERBOSE, "Using packet-per-buffer mode (auto) [%d, %d]\n", 
     809                                 packets_per_period, bufferfill_mode_threshold); 
     810                    receive_mode = RAW1394_DMA_PACKET_PER_BUFFER; 
     811                } else { 
     812                    debugOutput( DEBUG_LEVEL_VERBOSE, "Using bufferfill mode (auto) [%d, %d]\n", 
     813                                 packets_per_period, bufferfill_mode_threshold); 
     814                    receive_mode = RAW1394_DMA_BUFFERFILL; 
     815                } 
     816                break; 
     817            case 1:  
     818                debugOutput( DEBUG_LEVEL_VERBOSE, "Using packet-per-buffer mode (config)\n"); 
     819                receive_mode = RAW1394_DMA_PACKET_PER_BUFFER; 
     820                break; 
     821            case 2: 
     822                debugOutput( DEBUG_LEVEL_VERBOSE, "Using bufferfill mode (config)\n"); 
     823                receive_mode = RAW1394_DMA_BUFFERFILL; 
     824                break; 
     825            default: debugWarning("Bogus receive mode setting in config: %d\n", receive_mode_setting); 
     826        } 
    766827 
    767828        // Ensure we don't request a packet size bigger than the 
     
    774835 
    775836        // the interrupt/wakeup interval prediction of raw1394 is a mess... 
    776         int irq_interval = (packets_per_period-1) / MINIMUM_INTERRUPTS_PER_PERIOD
     837        int irq_interval = (packets_per_period-1) / min_interrupts_per_period
    777838        if(irq_interval <= 0) irq_interval=1; 
    778839 
     
    780841        // but it has a minimal value in order for libraw to operate correctly (300) 
    781842        int buffers=1; 
    782         while(buffers < (int)packets_per_period && buffers < MAX_RECV_NB_BUFFERS) { 
     843        while(buffers < (int)packets_per_period && buffers < max_nb_buffers_recv) { 
    783844            buffers *= 2; 
    784845        } 
     
    799860        } 
    800861 
    801         h->setReceiveMode(m_receive_mode); 
     862        h->setReceiveMode(receive_mode); 
    802863 
    803864    } else if (stream->getType()==StreamProcessor::ePT_Transmit) { 
     865        // grab the options from the parent 
     866        Util::Configuration *config = m_service.getConfiguration(); 
     867        int min_interrupts_per_period = MINIMUM_INTERRUPTS_PER_PERIOD; 
     868        int max_nb_buffers_xmit = MAX_XMIT_NB_BUFFERS; 
     869        int max_packetsize_xmit = MAX_XMIT_PACKET_SIZE; 
     870        if(config) { 
     871            config->getValueForSetting("ieee1394.isomanager.min_interrupts_per_period", min_interrupts_per_period); 
     872            config->getValueForSetting("ieee1394.isomanager.max_nb_buffers_xmit", max_nb_buffers_xmit); 
     873            config->getValueForSetting("ieee1394.isomanager.max_packetsize_xmit", max_packetsize_xmit); 
     874        } 
     875 
    804876        // setup the optimal parameters for the raw1394 ISO buffering 
    805877        unsigned int max_packet_size = stream->getMaxPacketSize(); 
    806878 
    807         if (max_packet_size > MAX_XMIT_PACKET_SIZE) { 
     879        if (max_packet_size > (unsigned)max_packetsize_xmit) { 
    808880            debugError("max packet size (%u) > MAX_XMIT_PACKET_SIZE (%u)\n", 
    809                        max_packet_size, MAX_XMIT_PACKET_SIZE); 
     881                       max_packet_size, max_packetsize_xmit); 
    810882            return false; 
    811883        } 
     
    814886        int req_buffers = stream->getNbPacketsIsoXmitBuffer(); 
    815887        int buffers=1;  
    816         while(buffers < (int)req_buffers && buffers < MAX_RECV_NB_BUFFERS) { 
     888        while(buffers < (int)req_buffers && buffers < max_nb_buffers_xmit) { 
    817889            buffers *= 2; 
    818890        } 
    819891 
    820         int irq_interval = req_buffers / MINIMUM_INTERRUPTS_PER_PERIOD
     892        int irq_interval = req_buffers / min_interrupts_per_period
    821893        if(irq_interval <= 0) irq_interval = 1; 
    822894        // ensure at least 2 hardware interrupts per ISO buffer wraparound 
  • branches/libffado-2.0/src/libieee1394/IsoHandlerManager.h

    r1372 r1373  
    5757class IsoTask : public Util::RunnableInterface 
    5858{ 
     59    friend class IsoHandlerManager; 
    5960    public: 
    6061        IsoTask(IsoHandlerManager& manager, enum IsoHandler::EHandlerType); 
     
    113114#endif 
    114115 
    115         // activity signaling 
    116         sem_t m_activity_semaphore; 
    117  
    118116        enum IsoHandler::EHandlerType m_handlerType; 
    119117        bool m_running; 
    120118        bool m_in_busreset; 
     119 
     120        // activity signaling 
     121        sem_t m_activity_semaphore; 
     122        long long int m_activity_wait_timeout_nsec; 
    121123 
    122124        // debug stuff 
     
    197199         */ 
    198200        bool handleBusReset(); 
    199  
    200         /** 
    201          * @brief set iso receive mode. doesn't have any effect if the stream is running 
    202          * @param m receive mode 
    203          */ 
    204         void setReceiveMode(enum raw1394_iso_dma_recv_mode m) 
    205             {m_receive_mode = m;} 
    206201 
    207202    // the state machine 
     
    244239        Util::Thread *  m_IsoThreadReceive; 
    245240        IsoTask *       m_IsoTaskReceive; 
    246         enum raw1394_iso_dma_recv_mode m_receive_mode; 
    247241 
    248242        // debug stuff 
  • branches/libffado-2.0/src/libstreaming/StreamProcessorManager.cpp

    r1346 r1373  
    4545    , m_parent( p ) 
    4646    , m_xrun_happened( false ) 
    47     , m_activity_wait_timeout_usec( 1000*1000 ) 
     47    , m_activity_wait_timeout_nsec( 0 ) // dynamically set 
    4848    , m_nb_buffers( 0 ) 
    4949    , m_period( 0 ) 
     
    6565    , m_parent( p ) 
    6666    , m_xrun_happened( false ) 
    67     , m_activity_wait_timeout_usec( 1000*1000 ) 
     67    , m_activity_wait_timeout_nsec( 0 ) // dynamically set 
    6868    , m_nb_buffers(nb_buffers) 
    6969    , m_period(period) 
     
    149149    int result; 
    150150 
    151     long long int timeout_nsec=0; 
    152     if (m_activity_wait_timeout_usec >= 0) { 
    153         timeout_nsec = m_activity_wait_timeout_usec * 1000LL; 
     151    if (m_activity_wait_timeout_nsec >= 0) { 
    154152 
    155153        if (clock_gettime(CLOCK_REALTIME, &ts) == -1) { 
     
    157155            return eAR_Error; 
    158156        } 
    159         ts.tv_nsec += timeout_nsec; 
     157        ts.tv_nsec += m_activity_wait_timeout_nsec; 
    160158        while(ts.tv_nsec >= 1000000000LL) { 
    161159            ts.tv_sec += 1; 
     
    164162    } 
    165163 
    166     if (m_activity_wait_timeout_usec >= 0) { 
     164    if (m_activity_wait_timeout_nsec >= 0) { 
    167165        result = sem_timedwait(&m_activity_semaphore, &ts); 
    168166    } else { 
     
    185183                        this, result); 
    186184            debugError("(%p) timeout_nsec=%lld ts.sec=%d ts.nsec=%lld\n",  
    187                        this, timeout_nsec, ts.tv_sec, ts.tv_nsec); 
     185                       this, m_activity_wait_timeout_nsec, ts.tv_sec, ts.tv_nsec); 
    188186            return eAR_Error; 
    189187        } else { 
     
    191189                        this, result, errno); 
    192190            debugError("(%p) timeout_nsec=%lld ts.sec=%d ts.nsec=%lld\n",  
    193                        this, timeout_nsec, ts.tv_sec, ts.tv_nsec); 
     191                       this, m_activity_wait_timeout_nsec, ts.tv_sec, ts.tv_nsec); 
    194192            return eAR_Error; 
    195193        } 
     
    439437bool StreamProcessorManager::syncStartAll() { 
    440438    if(m_SyncSource == NULL) return false; 
     439 
     440    // get the options 
     441    int signal_delay_ticks = STREAMPROCESSORMANAGER_SIGNAL_DELAY_TICKS; 
     442    int sync_wait_time_msec = STREAMPROCESSORMANAGER_SYNC_WAIT_TIME_MSEC; 
     443    int cycles_for_startup = STREAMPROCESSORMANAGER_CYCLES_FOR_STARTUP; 
     444    int prestart_cycles_for_xmit = STREAMPROCESSORMANAGER_PRESTART_CYCLES_FOR_XMIT; 
     445    int prestart_cycles_for_recv = STREAMPROCESSORMANAGER_PRESTART_CYCLES_FOR_RECV; 
     446    Util::Configuration &config = m_parent.getConfiguration(); 
     447    config.getValueForSetting("streaming.spm.signal_delay_ticks", signal_delay_ticks); 
     448    config.getValueForSetting("streaming.spm.sync_wait_time_msec", sync_wait_time_msec); 
     449    config.getValueForSetting("streaming.spm.cycles_for_startup", cycles_for_startup); 
     450    config.getValueForSetting("streaming.spm.prestart_cycles_for_xmit", prestart_cycles_for_xmit); 
     451    config.getValueForSetting("streaming.spm.prestart_cycles_for_recv", prestart_cycles_for_recv); 
     452 
    441453    // figure out when to get the SP's running. 
    442454    // the xmit SP's should also know the base timestamp 
     
    460472    // time to a later time instant also causes the xmit buffer fill to be 
    461473    // lower on average. 
    462     max_of_min_delay += STREAMPROCESSORMANAGER_SIGNAL_DELAY_TICKS
     474    max_of_min_delay += signal_delay_ticks
    463475 
    464476    m_SyncSource->setSyncDelay(max_of_min_delay); 
     
    479491    debugOutput( DEBUG_LEVEL_VERBOSE, "Waiting for sync...\n"); 
    480492 
    481     unsigned int nb_sync_runs = (STREAMPROCESSORMANAGER_SYNC_WAIT_TIME_MSEC * getNominalRate()); 
     493    unsigned int nb_sync_runs = (sync_wait_time_msec * getNominalRate()); 
    482494    nb_sync_runs /= 1000; 
    483495    nb_sync_runs /= getPeriodSize(); 
     
    512524    // can start wet-running correctly. 
    513525    time_of_first_sample = addTicks(time_of_first_sample, 
    514                                     STREAMPROCESSORMANAGER_CYCLES_FOR_STARTUP * TICKS_PER_CYCLE); 
     526                                    cycles_for_startup * TICKS_PER_CYCLE); 
    515527 
    516528    debugOutput( DEBUG_LEVEL_VERBOSE, "  => first sample at TS=%011llu (%03us %04uc %04ut)...\n",  
     
    523535    // such that we know it is wet-running when it should output its first sample 
    524536    uint64_t time_to_start_xmit = substractTicks(time_of_first_sample,  
    525                                                  STREAMPROCESSORMANAGER_PRESTART_CYCLES_FOR_XMIT * TICKS_PER_CYCLE); 
     537                                                 prestart_cycles_for_xmit * TICKS_PER_CYCLE); 
    526538 
    527539    uint64_t time_to_start_recv = substractTicks(time_of_first_sample, 
    528                                                  STREAMPROCESSORMANAGER_PRESTART_CYCLES_FOR_RECV * TICKS_PER_CYCLE); 
     540                                                 prestart_cycles_for_recv * TICKS_PER_CYCLE); 
    529541    debugOutput( DEBUG_LEVEL_VERBOSE, "  => xmit starts at  TS=%011llu (%03us %04uc %04ut)...\n",  
    530542        time_to_start_xmit, 
     
    585597    // note: the SP's are scheduled to start in STREAMPROCESSORMANAGER_CYCLES_FOR_STARTUP cycles, 
    586598    // so a 20 times this value should be a good timeout 
    587     int cnt = STREAMPROCESSORMANAGER_CYCLES_FOR_STARTUP * 20; // by then it should have started 
     599    int cnt = cycles_for_startup * 20; // by then it should have started 
    588600    while (!m_SyncSource->isRunning() && cnt) { 
    589601        SleepRelativeUsec(125); 
     
    649661    unsigned int i; 
    650662 
    651     unsigned int periods_per_align_try = (STREAMPROCESSORMANAGER_ALIGN_AVERAGE_TIME_MSEC * getNominalRate()); 
     663    int cnt = STREAMPROCESSORMANAGER_NB_ALIGN_TRIES; 
     664    int align_average_time_msec = STREAMPROCESSORMANAGER_ALIGN_AVERAGE_TIME_MSEC; 
     665    Util::Configuration &config = m_parent.getConfiguration(); 
     666    config.getValueForSetting("streaming.spm.align_tries", cnt); 
     667    config.getValueForSetting("streaming.spm.align_average_time_msec", align_average_time_msec); 
     668 
     669    unsigned int periods_per_align_try = (align_average_time_msec * getNominalRate()); 
    652670    periods_per_align_try /= 1000; 
    653671    periods_per_align_try /= getPeriodSize(); 
     
    655673 
    656674    bool aligned = false; 
    657     int cnt = STREAMPROCESSORMANAGER_NB_ALIGN_TRIES; 
    658675    while (!aligned && cnt--) { 
    659676        nb_sync_runs = periods_per_align_try; 
  • branches/libffado-2.0/src/libstreaming/StreamProcessorManager.h

    r1292 r1373  
    102102    // timeout occurs. 
    103103    void setActivityWaitTimeoutUsec(int usec) 
    104             {m_activity_wait_timeout_usec = usec;}; 
     104            {m_activity_wait_timeout_nsec = usec*1000LL;}; 
    105105    int getActivityWaitTimeoutUsec()  
    106             {return m_activity_wait_timeout_usec;}; 
     106            {return m_activity_wait_timeout_nsec/1000;}; 
    107107 
    108108    int getPortCount(enum Port::E_PortType, enum Port::E_Direction); 
     
    168168    // thread related vars 
    169169    bool m_xrun_happened; 
    170     int m_activity_wait_timeout_usec; 
     170    int64_t m_activity_wait_timeout_nsec; 
    171171    bool m_thread_realtime; 
    172172    int m_thread_priority; 
  • branches/libffado-2.0/src/libutil/Configuration.cpp

    r1303 r1373  
    228228} 
    229229 
     230bool 
     231Configuration::getValueForSetting(std::string path, int32_t &ref) 
     232{ 
     233    libconfig::Setting *s = getSetting( path ); 
     234    if(s) { 
     235        // FIXME: this can be done using the libconfig methods 
     236        Setting::Type t = s->getType(); 
     237        if(t == Setting::TypeInt) { 
     238            ref = *s; 
     239            debugOutput(DEBUG_LEVEL_VERBOSE, "path '%s' has value %d\n", path.c_str(), ref); 
     240            return true; 
     241        } else { 
     242            debugOutput(DEBUG_LEVEL_VERBOSE, "path '%s' has wrong type\n", path.c_str()); 
     243            return false; 
     244        } 
     245    } else { 
     246        debugOutput(DEBUG_LEVEL_VERBOSE, "path '%s' not found\n", path.c_str()); 
     247        return false; 
     248    } 
     249} 
     250 
     251bool 
     252Configuration::getValueForSetting(std::string path, int64_t &ref) 
     253{ 
     254    libconfig::Setting *s = getSetting( path ); 
     255    if(s) { 
     256        // FIXME: this can be done using the libconfig methods 
     257        Setting::Type t = s->getType(); 
     258        if(t == Setting::TypeInt64) { 
     259            ref = *s; 
     260            debugOutput(DEBUG_LEVEL_VERBOSE, "path '%s' has value %d\n", path.c_str(), ref); 
     261            return true; 
     262        } else { 
     263            debugOutput(DEBUG_LEVEL_VERBOSE, "path '%s' has wrong type\n", path.c_str()); 
     264            return false; 
     265        } 
     266    } else { 
     267        debugOutput(DEBUG_LEVEL_VERBOSE, "path '%s' not found\n", path.c_str()); 
     268        return false; 
     269    } 
     270} 
     271 
     272libconfig::Setting * 
     273Configuration::getSetting( std::string path ) 
     274{ 
     275    for ( std::vector<ConfigFile *>::iterator it = m_ConfigFiles.begin(); 
     276      it != m_ConfigFiles.end(); 
     277      ++it ) 
     278    { 
     279        ConfigFile *c = *it; 
     280        try { 
     281            Setting &s = c->lookup(path); 
     282            return &s; 
     283        } catch (...) { 
     284            debugOutput(DEBUG_LEVEL_VERBOSE, "  %s has no setting %s\n", 
     285                        c->getName().c_str(), path.c_str()); 
     286        } 
     287    } 
     288    return NULL; 
     289} 
     290 
    230291 
    231292Configuration::VendorModelEntry 
  • branches/libffado-2.0/src/libutil/Configuration.h

    r1303 r1373  
    113113    static bool isValid( const VendorModelEntry& vme ); 
    114114 
     115    // access functions 
     116    /** 
     117     * @brief retrieves a setting for a given path 
     118     *  
     119     * the value in the ref parameter is not changed if 
     120     * the function returns false. 
     121     *  
     122     * @param path path to the setting 
     123     * @param ref reference to the integer that will hold the value. 
     124     * @return true if successful, false if not 
     125     */ 
     126    bool getValueForSetting(std::string path, int32_t &ref); 
     127    bool getValueForSetting(std::string path, int64_t &ref); 
     128 
    115129    virtual void setVerboseLevel(int l) {setDebugLevel(l);}; 
    116130    virtual void show(); 
    117131 
    118132private: 
     133    libconfig::Setting *getSetting( std::string path ); 
     134 
    119135    int findFileName(std::string s); 
    120136