Changeset 930

Show
Ignore:
Timestamp:
03/11/08 01:37:08 (13 years ago)
Author:
ppalmers
Message:

Fix latency/reliability issue.
Preliminary tests indicate that this runs fine with
jackd -R -P60 -d firewire -v4 -p64 -n3
which corresponds to 331 frames of roundtrip latency on the quatafire.

For reference:
jackd -R -P60 -d freebob -p64 -n2
results in 355 frames for the same device

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/config.h.in

    r918 r930  
    4343#define IEEE1394SERVICE_MAX_FIREWIRE_PORTS  16 
    4444 
    45 #define IEEE1394SERVICE_CYCLETIMER_HELPER_RUN_REALTIME    0 
    46 #define IEEE1394SERVICE_CYCLETIMER_HELPER_PRIO_INCREASE  -5 
     45#define IEEE1394SERVICE_CYCLETIMER_HELPER_RUN_REALTIME    1 
     46#define IEEE1394SERVICE_CYCLETIMER_HELPER_PRIO_INCREASE  -10 
    4747 
    4848#define THREAD_MAX_RTPRIO                   98 
    49 #define THREAD_MIN_RTPRIO                   0 
     49#define THREAD_MIN_RTPRIO                   1 
    5050 
    5151#define MINIMUM_INTERRUPTS_PER_PERIOD       4U 
     
    6262#define ISOHANDLERMANAGER_MAX_ISO_HANDLERS_PER_PORT         16 
    6363#define ISOHANDLERMANAGER_MAX_STREAMS_PER_ISOTHREAD         16 
     64// the transmit thread should run at elevated priority since it 
     65// should push packets into the kernel ASAP 
    6466#define ISOHANDLERMANAGER_TRANSMIT_PRIO_INCREASE            1 
    65 #define ISOHANDLERMANAGER_RECEIVE_PRIO_INCREASE             0 
     67// the receive thread should have lower priority than the transmit one, since 
     68// it should be interrupted once it has flagged the semaphore that indicates 
     69// one period of frames. 
     70#define ISOHANDLERMANAGER_RECEIVE_PRIO_INCREASE             -6 
    6671 
    6772// allows to add some processing margin. This shifts the time 
  • trunk/libffado/src/libieee1394/IsoHandler.cpp

    r906 r930  
    9292   , m_prebuffers( 0 ) 
    9393   , m_State( E_Created ) 
     94#ifdef DEBUG 
     95   , m_packets ( 0 ) 
     96#endif 
    9497{ 
    9598} 
     
    107110   , m_prebuffers( 0 ) 
    108111   , m_State( E_Created ) 
     112#ifdef DEBUG 
     113   , m_packets ( 0 ) 
     114#endif 
    109115{ 
    110116} 
     
    123129   , m_prebuffers( 0 ) 
    124130   , m_State( E_Created ) 
     131#ifdef DEBUG 
     132   , m_packets ( 0 ) 
     133#endif 
    125134{ 
    126135} 
     
    414423                       length, channel, cycle); 
    415424    #ifdef DEBUG 
     425    m_packets++; 
    416426    if (length > m_max_packet_size) { 
    417427        debugWarning("(%p, %s) packet too large: len=%u max=%u\n", 
     
    435445                       "sending packet: length=%d, cycle=%d\n", 
    436446                       *length, cycle); 
     447    #ifdef DEBUG 
     448    m_packets++; 
     449    #endif 
    437450    if(m_Client) { 
    438451        enum raw1394_iso_disposition retval; 
  • trunk/libffado/src/libieee1394/IsoHandler.h

    r906 r930  
    150150    }; 
    151151    enum EHandlerStates m_State; 
     152 
     153    #ifdef DEBUG 
     154    int             m_packets; 
     155    #endif 
     156 
    152157    DECLARE_DEBUG_MODULE; 
    153158}; 
  • trunk/libffado/src/libieee1394/IsoHandlerManager.cpp

    r918 r930  
    126126    if (m_poll_nfds_shadow == 0) { 
    127127        debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, 
    128                            "(%p, %s) bypass iterate since no handlers to poll\n", 
     128                           "(%p, %8s) bypass iterate since no handlers to poll\n", 
    129129                           this, m_type==eTT_Transmit?"Transmit":"Receive"); 
    130130        usleep(m_poll_timeout * 1000); 
     
    136136 
    137137    // setup the poll here 
    138     if (m_type==eTT_Transmit) { 
    139         // if we are a transmit thread, we should only poll on 
    140         // those handlers that have a client that is ready to send 
    141         // something. poll'ing the others will only cause busy-wait 
    142         // looping. 
    143         for (i = 0; i < m_poll_nfds_shadow; i++) { 
    144             short events = 0; 
    145             if (m_IsoHandler_map_shadow[i]->tryWaitForClient()) { 
    146                 events = POLLIN | POLLPRI; 
     138    // we should prevent a poll() where no events are specified, since that will only time-out 
     139    bool no_one_to_poll = true; 
     140    while(no_one_to_poll) { 
     141        if (m_type==eTT_Transmit) { 
     142            // if we are a transmit thread, we should only poll on 
     143            // those handlers that have a client that is ready to send 
     144            // something. poll'ing the others will only cause busy-wait 
     145            // looping. 
     146            for (i = 0; i < m_poll_nfds_shadow; i++) { 
     147                short events = 0; 
     148                if (m_IsoHandler_map_shadow[i]->tryWaitForClient()) { 
     149                    events = POLLIN | POLLPRI; 
     150                    no_one_to_poll = false; 
     151                } 
     152                m_poll_fds_shadow[i].events = events; 
    147153            } 
    148             m_poll_fds_shadow[i].events = events; 
    149         } 
    150     } else { 
    151         // for receive handlers, we can do the same. we might not have to though 
    152         // FIXME: check whether this is necessary 
    153         for (i = 0; i < m_poll_nfds_shadow; i++) { 
    154             short events = 0; 
    155 //             if (m_IsoHandler_map_shadow[i]->tryWaitForClient()) { 
    156 //                 events = POLLIN | POLLERR | POLLHUP; 
    157 //             } 
    158             events = POLLIN | POLLPRI; 
    159             m_poll_fds_shadow[i].events = events; 
     154        } else { 
     155            // for receive handlers, we can do the same. we might not have to though 
     156            for (i = 0; i < m_poll_nfds_shadow; i++) { 
     157                short events = 0; 
     158                if (m_IsoHandler_map_shadow[i]->tryWaitForClient()) { 
     159                    events = POLLIN | POLLERR | POLLHUP; 
     160                    no_one_to_poll = false; 
     161                } 
     162                m_poll_fds_shadow[i].events = events; 
     163            } 
     164        } 
     165        if(no_one_to_poll) { 
     166            debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, 
     167                               "(%p, %8s) No one to poll, waiting on the first handler to become ready\n", 
     168                               this, m_type==eTT_Transmit?"Transmit":"Receive"); 
     169 
     170            m_IsoHandler_map_shadow[0]->waitForClient(); 
     171 
     172            debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, 
     173                               "(%p, %8s) handler ready\n", 
     174                               this, m_type==eTT_Transmit?"Transmit":"Receive"); 
    160175        } 
    161176    } 
     
    210225 
    211226    } 
    212  
    213227    return true; 
    214228 
  • trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp

    r907 r930  
    19051905 
    19061906void 
     1907StreamProcessor::printBufferInfo() 
     1908{ 
     1909    debugOutput(DEBUG_LEVEL_NORMAL, 
     1910                "(%p, %8s) fc: %d fill: %u\n", 
     1911                this, getTypeString(), m_data_buffer->getFrameCounter(), m_data_buffer->getBufferFill() ); 
     1912} 
     1913 
     1914void 
    19071915StreamProcessor::setVerboseLevel(int l) { 
    19081916    setDebugLevel(l); 
  • trunk/libffado/src/libstreaming/generic/StreamProcessor.h

    r906 r930  
    484484    // debug stuff 
    485485    virtual void dumpInfo(); 
     486    virtual void printBufferInfo(); 
    486487    virtual void setVerboseLevel(int l); 
    487488    const char *getStateString() 
  • trunk/libffado/src/libutil/SystemTimeSource.cpp

    r864 r930  
    5959} 
    6060 
    61 ffado_microsecs_t SystemTimeSource::getCurrentTime() { 
     61ffado_microsecs_t 
     62SystemTimeSource::getCurrentTime() { 
    6263//     struct timeval tv; 
    6364//     gettimeofday(&tv, NULL); 
     
    6869} 
    6970 
    70 ffado_microsecs_t SystemTimeSource::getCurrentTimeAsUsecs() { 
     71ffado_microsecs_t 
     72SystemTimeSource::getCurrentTimeAsUsecs() { 
    7173    return getCurrentTime(); 
    7274}