Changeset 1345

Show
Ignore:
Timestamp:
09/24/08 08:42:12 (15 years ago)
Author:
ppalmers
Message:

improve latency performance. always use packet_per_buffer mode since that's better suited for our problem

Files:

Legend:

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

    r1342 r1345  
    162162// time to a later time instant also causes the xmit buffer fill to be 
    163163// lower on average. 
    164 #define STREAMPROCESSORMANAGER_SIGNAL_DELAY_TICKS           (3072*6) 
     164#define STREAMPROCESSORMANAGER_SIGNAL_DELAY_TICKS           (3072*0) 
     165 
     166// causes the waitForPeriod() call to wait until sufficient 
     167// data is present in the buffer such that a transfer() will 
     168// succeed. Normally we wait for the period of time that theoretically 
     169// would mean that his is true. However sometimes the kernel hasn't 
     170// flushed everything to userspace (or the card hasn't IRQ'd). 
     171// the side-effect of this is some jitter in the return timing 
     172// whenever this occurs. 
     173#define STREAMPROCESSORMANAGER_ALLOW_DELAYED_PERIOD_SIGNAL         1 
    165174 
    166175// startup control 
  • branches/libffado-2.0/src/libieee1394/IsoHandler.cpp

    r1294 r1345  
    475475    // leave the offset field (for now?) 
    476476 
    477     debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, 
     477    debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, 
    478478                "received packet: length=%d, channel=%d, cycle=%d, at %08X\n", 
    479479                length, channel, cycle, pkt_ctr); 
     
    566566        m_last_packet_handled_at = pkt_ctr; 
    567567    } 
    568     debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, 
     568    debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, 
    569569                "sending packet: length=%d, cycle=%d, at %08X\n", 
    570570                *length, cycle, pkt_ctr); 
     
    670670    dumpInfo(); 
    671671    if (getType() == eHT_Receive) { 
    672         if(m_irq_interval > 1) { 
    673             if(raw1394_iso_recv_init(m_handle, 
    674                                     iso_receive_handler, 
    675                                     m_buf_packets, 
    676                                     m_max_packet_size, 
    677                                     m_Client->getChannel(), 
    678                                     RAW1394_DMA_BUFFERFILL, 
    679 //                                     RAW1394_DMA_PACKET_PER_BUFFER, 
    680                                     m_irq_interval)) { 
    681                 debugFatal("Could not do receive initialisation (DMA_BUFFERFILL)!\n" ); 
    682                 debugFatal("  %s\n",strerror(errno)); 
    683                 return false; 
    684             } 
    685         } else { 
    686             if(raw1394_iso_recv_init(m_handle, 
    687                                     iso_receive_handler, 
    688                                     m_buf_packets, 
    689                                     m_max_packet_size, 
    690                                     m_Client->getChannel(), 
    691                                     RAW1394_DMA_PACKET_PER_BUFFER, 
    692                                     m_irq_interval)) { 
    693                 debugFatal("Could not do receive initialisation (PACKET_PER_BUFFER)!\n" ); 
    694                 debugFatal("  %s\n",strerror(errno)); 
    695                 return false; 
    696             } 
     672        if(raw1394_iso_recv_init(m_handle, 
     673                                iso_receive_handler, 
     674                                m_buf_packets, 
     675                                m_max_packet_size, 
     676                                m_Client->getChannel(), 
     677                                RAW1394_DMA_PACKET_PER_BUFFER, 
     678                                m_irq_interval)) { 
     679            debugFatal("Could not do receive initialisation (DMA_BUFFERFILL)!\n" ); 
     680            debugFatal("  %s\n",strerror(errno)); 
     681            return false; 
    697682        } 
    698683        return true; 
  • branches/libffado-2.0/src/libieee1394/IsoHandlerManager.cpp

    r1343 r1345  
    772772 
    773773        // the interrupt/wakeup interval prediction of raw1394 is a mess... 
    774         int wanted_irq_interval = (packets_per_period-1) / MINIMUM_INTERRUPTS_PER_PERIOD; 
    775         if(wanted_irq_interval <= 0) wanted_irq_interval=1; 
    776  
    777         // mimic kernel initialization 
    778         unsigned int kern_buff_stride = RAW1394_RCV_MIN_BUF_STRIDE; 
    779         for (; kern_buff_stride < max_packet_size; kern_buff_stride *= 2); 
    780         if (kern_buff_stride > page_size) kern_buff_stride = page_size; 
    781         // kern_buff_stride is the minimal granularity of interrupts 
    782         // therefore the following will result in on-average correct interrupt timing 
    783         int irq_interval = (wanted_irq_interval * max_packet_size) / kern_buff_stride; 
     774        int irq_interval = (packets_per_period-1) / MINIMUM_INTERRUPTS_PER_PERIOD; 
     775        if(irq_interval <= 0) irq_interval=1; 
    784776 
    785777        // the receive buffer size doesn't matter for the latency, 
     
    986978    { 
    987979        if((*it)->isStreamRegistered(stream)) { 
    988             unsigned int page_size = getpagesize(); 
    989             unsigned int max_packet_size = stream->getMaxPacketSize() + 8; 
    990             int average_packet_size_bytes = stream->getAveragePacketSize(); 
    991             int irq_interval = (*it)->getIrqInterval(); 
    992  
    993             // mimic kernel initialization 
    994             unsigned int kern_buff_stride = RAW1394_RCV_MIN_BUF_STRIDE; 
    995             for (; kern_buff_stride < max_packet_size; kern_buff_stride *= 2); 
    996             if (kern_buff_stride > page_size) kern_buff_stride = page_size; 
    997              
    998             // we can only have one interrupt every kern_buff_stride bytes 
    999             int packets_per_block = kern_buff_stride / average_packet_size_bytes; 
    1000             int blocks_per_interrupt = irq_interval / packets_per_block + 1; 
    1001             return blocks_per_interrupt * packets_per_block; 
     980            return (*it)->getIrqInterval(); 
    1002981        } 
    1003982    } 
  • branches/libffado-2.0/src/libstreaming/StreamProcessorManager.cpp

    r1344 r1345  
    955955    // the period should be ready now 
    956956 
     957    #if STREAMPROCESSORMANAGER_ALLOW_DELAYED_PERIOD_SIGNAL 
    957958    // HACK: we force wait until every SP is ready. this is needed 
    958959    // since the raw1394 interface provides no control over interrupts 
     
    10011002        if(xrun_occurred | in_error | m_shutdown_needed) break; 
    10021003    } 
     1004    #else 
     1005    // check for underruns/errors on the ISO side, 
     1006    // those should make us bail out of the wait loop 
     1007    for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
     1008        it != m_ReceiveProcessors.end(); 
     1009        ++it ) { 
     1010        // xrun on data buffer side 
     1011        if (!(*it)->canConsumePeriod()) { 
     1012            xrun_occurred = true; 
     1013        } 
     1014        // a xrun has occurred on the Iso side 
     1015        xrun_occurred |= (*it)->xrunOccurred(); 
     1016        in_error |= (*it)->inError(); 
     1017    } 
     1018    for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 
     1019        it != m_TransmitProcessors.end(); 
     1020        ++it ) { 
     1021        // xrun on data buffer side 
     1022        if (!(*it)->canProducePeriod()) { 
     1023            xrun_occurred = true; 
     1024        } 
     1025        // a xrun has occurred on the Iso side 
     1026        xrun_occurred |= (*it)->xrunOccurred(); 
     1027        in_error |= (*it)->inError(); 
     1028    } 
     1029    #endif 
    10031030 
    10041031    if(xrun_occurred) {