Index: /trunk/libffado/src/libieee1394/IsoHandlerManager.cpp =================================================================== --- /trunk/libffado/src/libieee1394/IsoHandlerManager.cpp (revision 796) +++ /trunk/libffado/src/libieee1394/IsoHandlerManager.cpp (revision 797) @@ -337,28 +337,4 @@ unsigned int page_size = getpagesize() - 2; // for one reason or another this is necessary - // hardware interrupts can only occur when one DMA descriptor is full, - // and the size of one DMA descriptor in bufferfill mode is PAGE_SIZE. - // the number of packets that fits into this descriptor is dependent on - // the max_packet_size parameter: - // packets_per_descriptor = PAGE_SIZE / max_packet_size - // - // Hence if we want N hardware IRQ's in one period, we have to ensure that - // there are at least N descriptors for one period worth of packets - // hence: - // packets_per_interrupt = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD - // packets_per_descriptor <= packets_per_interrupt - // - // or: - // => PAGE_SIZE / max_packet_size <= packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD - // => PAGE_SIZE * MINIMUM_INTERRUPTS_PER_PERIOD / packets_per_period <= max_packet_size - - unsigned int min_max_packet_size=(MINIMUM_INTERRUPTS_PER_PERIOD * page_size) / packets_per_period; - - if (max_packet_size < min_max_packet_size) { - debugOutput(DEBUG_LEVEL_VERBOSE, "correcting stream max packet size (%u) to (%u) to ensure enough interrupts\n", - max_packet_size, min_max_packet_size); - max_packet_size = min_max_packet_size; - } - // Ensure we don't request a packet size bigger than the // kernel-enforced maximum which is currently 1 page. @@ -370,5 +346,4 @@ unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; if(irq_interval <= 0) irq_interval=1; -// unsigned int irq_interval=2; // this is not the HW IRQ interval // the receive buffer size doesn't matter for the latency, @@ -391,29 +366,5 @@ unsigned int packets_per_period = stream->getPacketsPerPeriod(); unsigned int max_packet_size = stream->getMaxPacketSize(); - unsigned int page_size = getpagesize() - 2; // for one reason or another this is necessary - - // hardware interrupts can only occur when one DMA descriptor is full, - // and the size of one DMA descriptor in bufferfill mode is PAGE_SIZE. - // the number of packets that fits into this descriptor is dependent on - // the max_packet_size parameter: - // packets_per_descriptor = PAGE_SIZE / max_packet_size - // - // Hence if we want N hardware IRQ's in one period, we have to ensure that - // there are at least N descriptors for one period worth of packets - // hence: - // packets_per_interrupt = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD - // packets_per_descriptor <= packets_per_interrupt - // - // or: - // => PAGE_SIZE / max_packet_size <= packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD - // => PAGE_SIZE * MINIMUM_INTERRUPTS_PER_PERIOD / packets_per_period <= max_packet_size - - unsigned int min_max_packet_size=(MINIMUM_INTERRUPTS_PER_PERIOD * page_size) / packets_per_period; - - if (max_packet_size < min_max_packet_size) { - debugOutput(DEBUG_LEVEL_VERBOSE, "correcting stream max packet size (%u) to (%u) to ensure enough interrupts\n", - max_packet_size, min_max_packet_size); - max_packet_size = min_max_packet_size; - } + unsigned int page_size = getpagesize(); // Ensure we don't request a packet size bigger than the @@ -424,7 +375,7 @@ } - // unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; - // if(irq_interval <= 0) irq_interval=1; - unsigned int irq_interval=2; // this is not the HW IRQ interval + max_packet_size = page_size; + unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; + if(irq_interval <= 0) irq_interval=1; // the SP specifies how many packets to ISO-buffer Index: /trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp =================================================================== --- /trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (revision 796) +++ /trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (revision 797) @@ -211,20 +211,19 @@ transmit_at_cycle, cycles_until_transmit, presentation_time, (unsigned int)TICKS_TO_CYCLES(presentation_time) ); - debugShowBackLogLines(200); - flushDebugOutput(); - // however, if we can send this sufficiently before the presentation - // time, it could be harmless. - // NOTE: dangerous since the device has no way of reporting that it didn't get - // this packet on time. - if(cycles_until_presentation >= min_cycles_before_presentation) - { - // we are not that late and can still try to transmit the packet - m_dbc += fillDataPacketHeader(packet, length, m_last_timestamp); - return (fc < (signed)(2*m_syt_interval) ? eCRV_Defer : eCRV_Packet); - } - else // definitely too late - { + //debugShowBackLogLines(200); +// // however, if we can send this sufficiently before the presentation +// // time, it could be harmless. +// // NOTE: dangerous since the device has no way of reporting that it didn't get +// // this packet on time. +// if(cycles_until_presentation >= min_cycles_before_presentation) +// { +// // we are not that late and can still try to transmit the packet +// m_dbc += fillDataPacketHeader(packet, length, m_last_timestamp); +// return (fc < (signed)(2*m_syt_interval) ? eCRV_Defer : eCRV_Packet); +// } +// else // definitely too late +// { return eCRV_XRun; - } +// } } else if(cycles_until_transmit <= max_cycles_to_transmit_early) Index: /trunk/libffado/src/libstreaming/StreamProcessorManager.cpp =================================================================== --- /trunk/libffado/src/libstreaming/StreamProcessorManager.cpp (revision 796) +++ /trunk/libffado/src/libstreaming/StreamProcessorManager.cpp (revision 797) @@ -712,7 +712,9 @@ // check if xruns occurred on the Iso side. // also check if xruns will occur should we transfer() now +#if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY #ifdef DEBUG int waited = 0; #endif +#endif bool ready_for_transfer = false; bool ready; @@ -735,4 +737,5 @@ xrun_occurred |= (*it)->xrunOccurred(); } +#if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY if (!ready_for_transfer) { @@ -751,6 +754,8 @@ #endif } +#endif } // we are either ready or an xrun occurred +#if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY // in order to avoid a runaway value of the sync delay, we gradually decrease // it. It will be increased by a 'too early' event (cfr some lines higher) @@ -765,4 +770,5 @@ } #endif +#endif // this is to notify the client of the delay that we introduced by waiting Index: /trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp =================================================================== --- /trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp (revision 796) +++ /trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp (revision 797) @@ -127,5 +127,5 @@ packets_to_prebuffer); - // only queue a part (70%) of the theoretical max in order not to have too much 'not ready' cycles + // only queue a part of the theoretical max in order not to have too much 'not ready' cycles packets_to_prebuffer = (packets_to_prebuffer * MAX_ISO_XMIT_BUFFER_FILL_PCT * 1000) / 100000; debugOutput(DEBUG_LEVEL_VERBOSE, " reduce to %d%%: %u\n", @@ -490,5 +490,4 @@ int cycle_diff = diffCycles(cycle, now_cycles); - #ifdef DEBUG if(cycle_diff < 0 && (m_state == ePS_Running || m_state == ePS_DryRunning)) { debugWarning("Requesting packet for cycle %04d which is in the past (now=%04dcy)\n", @@ -498,7 +497,16 @@ // flushDebugOutput(); // assert(0); - } - } - #endif + debugWarning("generatePacketData xrun\n"); + m_in_xrun = true; + debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to data xrun\n"); + m_next_state = ePS_WaitingForStreamDisable; + // execute the requested change + if (!updateState()) { // we are allowed to change the state directly + debugError("Could not update state!\n"); + return RAW1394_ISO_ERROR; + } + goto send_empty_packet; + } + } // store the previous timestamp @@ -604,5 +612,4 @@ m_in_xrun = true; debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to header xrun\n"); - m_cycle_to_switch_state = cycle+1; // switch in the next cycle m_next_state = ePS_WaitingForStreamDisable; // execute the requested change Index: /trunk/libffado/config.h.in =================================================================== --- /trunk/libffado/config.h.in (revision 796) +++ /trunk/libffado/config.h.in (revision 797) @@ -36,6 +36,6 @@ #define SHAREDIR "$sharedir" -#define MINIMUM_INTERRUPTS_PER_PERIOD 4U -#define MAX_ISO_XMIT_BUFFER_FILL_PCT 70 +#define MINIMUM_INTERRUPTS_PER_PERIOD 2U +#define MAX_ISO_XMIT_BUFFER_FILL_PCT 50 #define ISOHANDLER_PER_HANDLER_THREAD 0 @@ -58,4 +58,5 @@ #define STREAMPROCESSORMANAGER_NB_ALIGN_TRIES 40 +#define STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 0 // FIXME: note that it will probably be better to use a DLL bandwidth that is