Show
Ignore:
Timestamp:
03/11/08 01:37:08 (16 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/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