Index: /trunk/libffado/src/libieee1394/IsoHandlerManager.cpp =================================================================== --- /trunk/libffado/src/libieee1394/IsoHandlerManager.cpp (revision 784) +++ /trunk/libffado/src/libieee1394/IsoHandlerManager.cpp (revision 791) @@ -368,7 +368,8 @@ } - unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; - if(irq_interval <= 0) irq_interval=1; - + //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, // but it has a minimal value in order for libraw to operate correctly (300) @@ -423,6 +424,7 @@ } - unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; - if(irq_interval <= 0) irq_interval=1; + // 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 SP specifies how many packets to ISO-buffer Index: /trunk/libffado/src/libieee1394/IsoHandler.cpp =================================================================== --- /trunk/libffado/src/libieee1394/IsoHandler.cpp (revision 790) +++ /trunk/libffado/src/libieee1394/IsoHandler.cpp (revision 791) @@ -214,5 +214,5 @@ } debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "(%c %p) poll took %lldus, iterate took %lldus\n", - (this->getType()==eHT_Receive?'R':'X'), this, + (getType()==eHT_Receive?'R':'X'), this, poll_exit-poll_enter, iter_exit-iter_enter); #else @@ -220,5 +220,5 @@ // so poll'ing is not really necessary bool result = iterate(); - usleep(125); + //usleep(125); return result; #endif @@ -228,4 +228,5 @@ bool IsoHandler::iterate() { + flush(); if(raw1394_loop_iterate(m_handle)) { debugOutput( DEBUG_LEVEL_VERBOSE, Index: /trunk/libffado/src/libstreaming/StreamProcessorManager.cpp =================================================================== --- /trunk/libffado/src/libstreaming/StreamProcessorManager.cpp (revision 790) +++ /trunk/libffado/src/libstreaming/StreamProcessorManager.cpp (revision 791) @@ -465,5 +465,8 @@ while(nb_sync_runs) { debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " check (%d)...\n", nb_sync_runs); - waitForPeriod(); + if(!waitForPeriod()) { + debugWarning("xrun while aligning streams...\n"); + return false; + }; i = 0; @@ -541,7 +544,9 @@ it != m_ReceiveProcessors.end(); ++it ) { - if(!(*it)->scheduleStopRunning(-1)) { - debugError("%p->scheduleStopRunning(-1) failed\n", *it); - return false; + if((*it)->isRunning()) { + if(!(*it)->scheduleStopRunning(-1)) { + debugError("%p->scheduleStopRunning(-1) failed\n", *it); + return false; + } } } @@ -549,7 +554,9 @@ it != m_TransmitProcessors.end(); ++it ) { - if(!(*it)->scheduleStopRunning(-1)) { - debugError("%p->scheduleStopRunning(-1) failed\n", *it); - return false; + if((*it)->isRunning()) { + if(!(*it)->scheduleStopRunning(-1)) { + debugError("%p->scheduleStopRunning(-1) failed\n", *it); + return false; + } } } @@ -754,5 +761,7 @@ m_SyncSource->setSyncDelay(d); d = m_SyncSource->getSyncDelay(); - debugOutput(DEBUG_LEVEL_VERBOSE, "Increased the Sync delay to: %d\n", d); + debugOutput(DEBUG_LEVEL_VERBOSE, "Increased the Sync delay to: %d ticks (%f frames, %f cy)\n", + d, ((float)d)/m_SyncSource->getTicksPerFrame(), + ((float)d)/((float)TICKS_PER_CYCLE)); #ifdef DEBUG Index: /trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp =================================================================== --- /trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp (revision 783) +++ /trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp (revision 791) @@ -117,5 +117,5 @@ // only queue a part (80%) of the theoretical max in order not to have too much 'not ready' cycles - packets_to_prebuffer = (packets_to_prebuffer * 8000) / 10000; + packets_to_prebuffer = (packets_to_prebuffer * 7000) / 10000; return packets_to_prebuffer; @@ -620,8 +620,9 @@ } } -// return RAW1394_ISO_AGAIN; - generateSilentPacketHeader(data, length, tag, sy, cycle, dropped_cycles, max_length); - generateSilentPacketData(data, length, tag, sy, cycle, dropped_cycles, max_length); - return RAW1394_ISO_DEFER; + usleep(125); // only when using thread-per-handler + return RAW1394_ISO_AGAIN; +// generateSilentPacketHeader(data, length, tag, sy, cycle, dropped_cycles, max_length); +// generateSilentPacketData(data, length, tag, sy, cycle, dropped_cycles, max_length); +// return RAW1394_ISO_DEFER; } else { debugError("Invalid return value: %d\n", result); @@ -1284,6 +1285,10 @@ } break; + case ePS_WaitingForStreamEnable: // when xrunning at startup + result &= m_data_buffer->clearBuffer(); + m_data_buffer->setTransparent(true); + break; case ePS_WaitingForStreamDisable: - result &= m_data_buffer->clearBuffer(); // FIXME: don't like the reset() name + result &= m_data_buffer->clearBuffer(); m_data_buffer->setTransparent(true); break; Index: /trunk/libffado/src/ffado.cpp =================================================================== --- /trunk/libffado/src/ffado.cpp (revision 750) +++ /trunk/libffado/src/ffado.cpp (revision 791) @@ -245,4 +245,5 @@ return dev->options.period_size; } else { + debugWarning("XRUN"); xruns++; return -1; Index: /trunk/libffado/SConstruct =================================================================== --- /trunk/libffado/SConstruct (revision 781) +++ /trunk/libffado/SConstruct (revision 791) @@ -319,5 +319,5 @@ env['PACKAGE'] = "libffado" -env['VERSION'] = "1.999.10" +env['VERSION'] = "1.999.11" env['LIBVERSION'] = "1.0.0"