Index: branches/streaming-rework/src/libstreaming/MotuPort.h =================================================================== --- branches/streaming-rework/src/libstreaming/MotuPort.h (revision 404) +++ branches/streaming-rework/src/libstreaming/MotuPort.h (revision 407) @@ -26,7 +26,4 @@ * */ - -#ifdef ENABLE_MOTU - #ifndef __FREEBOB_MOTUPORT__ #define __FREEBOB_MOTUPORT__ @@ -121,4 +118,2 @@ #endif /* __FREEBOB_MOTUPORT__ */ -#endif //#ifdef ENABLE_MOTU - Index: branches/streaming-rework/src/libstreaming/MotuStreamProcessor.cpp =================================================================== --- branches/streaming-rework/src/libstreaming/MotuStreamProcessor.cpp (revision 402) +++ branches/streaming-rework/src/libstreaming/MotuStreamProcessor.cpp (revision 407) @@ -27,7 +27,4 @@ * */ - -#ifdef ENABLE_MOTU - #include "MotuStreamProcessor.h" #include "Port.h" @@ -1398,3 +1395,2 @@ } // end of namespace FreebobStreaming -#endif Index: branches/streaming-rework/src/libstreaming/MotuPortInfo.cpp =================================================================== --- branches/streaming-rework/src/libstreaming/MotuPortInfo.cpp (revision 404) +++ branches/streaming-rework/src/libstreaming/MotuPortInfo.cpp (revision 407) @@ -26,7 +26,4 @@ * */ - -#ifdef ENABLE_MOTU - #include "MotuPortInfo.h" #include @@ -36,4 +33,2 @@ } // end of namespace FreebobStreaming - -#endif //#ifdef ENABLE_MOTU Index: branches/streaming-rework/src/libstreaming/MotuStreamProcessor.h =================================================================== --- branches/streaming-rework/src/libstreaming/MotuStreamProcessor.h (revision 402) +++ branches/streaming-rework/src/libstreaming/MotuStreamProcessor.h (revision 407) @@ -35,6 +35,4 @@ #include "../libutil/DelayLockedLoop.h" - -#ifdef ENABLE_MOTU namespace FreebobStreaming { @@ -181,6 +179,4 @@ } // end of namespace FreebobStreaming -#endif /* ENABLE_MOTU */ - #endif /* __FREEBOB_MOTUSTREAMPROCESSOR__ */ Index: branches/streaming-rework/src/libstreaming/MotuPortInfo.h =================================================================== --- branches/streaming-rework/src/libstreaming/MotuPortInfo.h (revision 404) +++ branches/streaming-rework/src/libstreaming/MotuPortInfo.h (revision 407) @@ -26,6 +26,4 @@ * */ -#ifdef ENABLE_MOTU - #ifndef __FREEBOB_MOTUPORTINFO__ #define __FREEBOB_MOTUPORTINFO__ @@ -92,5 +90,2 @@ #endif /* __FREEBOB_MOTUPORTINFO__ */ - -#endif //#ifdef ENABLE_MOTU - Index: branches/streaming-rework/src/libstreaming/AmdtpPort.cpp =================================================================== --- branches/streaming-rework/src/libstreaming/AmdtpPort.cpp (revision 404) +++ branches/streaming-rework/src/libstreaming/AmdtpPort.cpp (revision 407) @@ -26,24 +26,4 @@ * */ -#ifdef ENABLE_BEBOB - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_DICE - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_BOUNCE - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_AMDTP_SP - #include "AmdtpPort.h" #include @@ -52,4 +32,2 @@ } // end of namespace FreebobStreaming - -#endif // #ifdef ENABLE_AMDTP_SP Index: branches/streaming-rework/src/libstreaming/AmdtpPort.h =================================================================== --- branches/streaming-rework/src/libstreaming/AmdtpPort.h (revision 404) +++ branches/streaming-rework/src/libstreaming/AmdtpPort.h (revision 407) @@ -26,24 +26,4 @@ * */ -#ifdef ENABLE_BEBOB - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_DICE - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_BOUNCE - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_AMDTP_SP - #ifndef __FREEBOB_AMDTPPORT__ #define __FREEBOB_AMDTPPORT__ @@ -119,4 +99,2 @@ #endif /* __FREEBOB_AMDTPPORT__ */ - -#endif // #ifdef ENABLE_AMDTP_SP Index: branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp =================================================================== --- branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp (revision 404) +++ branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp (revision 407) @@ -26,25 +26,4 @@ * */ - -#ifdef ENABLE_BEBOB - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_DICE - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_BOUNCE - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_AMDTP_SP - #include "AmdtpStreamProcessor.h" #include "Port.h" @@ -57,5 +36,5 @@ // in ticks -#define TRANSMIT_TRANSFER_DELAY 6000U +#define TRANSMIT_TRANSFER_DELAY 9000U // the number of cycles to send a packet in advance of it's timestamp #define TRANSMIT_ADVANCE_CYCLES 1U @@ -190,5 +169,5 @@ ts_head = addTicks(ts_head, sync_lag_cycles * TICKS_PER_CYCLE); - m_data_buffer->setBufferTailTimestamp(ts_head); + m_data_buffer->setBufferHeadTimestamp(ts_head); #ifdef DEBUG @@ -213,6 +192,4 @@ // the base timestamp is the one of the next sample in the buffer m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe - - int64_t timestamp = ts_head; // we send a packet some cycles in advance, to avoid the @@ -236,144 +213,117 @@ // time until the packet is to be sent (if > 0: send packet) - int64_t until_next=substractTicks(timestamp, cycle_timer + ticks_to_advance); - -#ifdef DEBUG - if(!m_is_disabled) { - uint32_t timestamp_u=timestamp; - uint32_t syt = addTicks(timestamp_u, TRANSMIT_TRANSFER_DELAY); - - debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "T: TS=%011llu, NOW=%011llu, CYN=%04d, CYT=%04d\n", - timestamp, cycle_timer, now_cycles, cycle - ); - debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " UTN=%11lld\n", - until_next - ); - debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " CY_NOW=%04d, CY_TARGET=%04d, CY_DIFF=%04d, CY_SYT=%04d\n", - now_cycles, cycle, cycle_diff, TICKS_TO_CYCLES(syt) - ); - } -#endif - - #ifdef DEBUG_OFF - if((cycle % 1000) == 0) { - uint32_t timestamp_u=timestamp; - uint32_t syt = TICKS_TO_SYT(addTicks(timestamp_u, TRANSMIT_TRANSFER_DELAY)); - uint32_t now=m_handler->getCycleTimer(); - uint32_t now_ticks=CYCLE_TIMER_TO_TICKS(now); + int64_t until_next=substractTicks(ts_head, cycle_timer + ticks_to_advance); + + // if until_next < 0 we should send a filled packet + // otherwise we should send a NO-DATA packet + if((until_next<0) && (m_running)) { + // add the transmit transfer delay to construct the playout time (=SYT timestamp) + uint64_t ts_packet=addTicks(ts_head, TRANSMIT_TRANSFER_DELAY); + + // if we are disabled, send a silent packet + // and advance the buffer head timestamp + if(m_is_disabled) { + + transmitSilenceBlock((char *)(data+8), m_syt_interval, 0); + m_dbc += fillDataPacketHeader(packet, length, ts_packet); + + debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT SYNC: CY=%04u TSH=%011llu TSP=%011llu\n", + cycle, ts_head, ts_packet); + + // update the base timestamp + uint32_t ts_step=(uint32_t)((float)(m_syt_interval) + *m_SyncSource->m_data_buffer->getRate()); + + // the next buffer head timestamp + ts_head=addTicks(ts_head,ts_step); + m_data_buffer->setBufferHeadTimestamp(ts_head); + + // defer to make sure we get to be enabled asap + return RAW1394_ISO_DEFER; + + } else { // enabled & packet due, read from the buffer + if (m_data_buffer->readFrames(m_syt_interval, (char *)(data + 8))) { + m_dbc += fillDataPacketHeader(packet, length, ts_packet); + + // process all ports that should be handled on a per-packet base + // this is MIDI for AMDTP (due to the need of DBC) + if (!encodePacketPorts((quadlet_t *)(data+8), m_syt_interval, packet->dbc)) { + debugWarning("Problem encoding Packet Ports\n"); + } + + debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT: CY=%04u TSH=%011llu TSP=%011llu\n", + cycle, ts_head, ts_packet); + + return RAW1394_ISO_OK; + + } else if (now_cycles0) || m_is_disabled || !m_running) { - // no-data packets have syt=0xFFFF - // and have the usual amount of events as dummy data (?) - packet->fdf = IEC61883_FDF_NODATA; - packet->syt = 0xffff; - - // FIXME: either make this a setting or choose - bool send_payload=true; - if(send_payload) { - // the dbc is incremented even with no data packets - m_dbc += m_syt_interval; - - // this means no-data packets with payload (DICE doesn't like that) - *length = 2*sizeof(quadlet_t) + m_syt_interval * m_dimension * sizeof(quadlet_t); - } else { - // dbc is not incremented - - // this means no-data packets without payload - *length = 2*sizeof(quadlet_t); - } - + } else { // no packet due, send no-data packet + m_dbc += fillNoDataPacketHeader(packet, length); return RAW1394_ISO_DEFER; } - // construct the packet - - // add the transmit transfer delay to construct the playout time (=SYT timestamp) - uint64_t ts=addTicks(timestamp, TRANSMIT_TRANSFER_DELAY); - - unsigned int nevents = m_syt_interval; - if (m_data_buffer->readFrames(nevents, (char *)(data + 8))) { - - m_dbc += m_syt_interval; - - packet->fdf = m_fdf; - - // convert the timestamp to SYT format - uint16_t timestamp_SYT = TICKS_TO_SYT(ts); - packet->syt = ntohs(timestamp_SYT); - - *length = nevents*sizeof(quadlet_t)*m_dimension + 8; - - // process all ports that should be handled on a per-packet base - // this is MIDI for AMDTP (due to the need of DBC) - if (!encodePacketPorts((quadlet_t *)(data+8), nevents, packet->dbc)) { - debugWarning("Problem encoding Packet Ports\n"); - } - - debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT: CY=%04u TS=%011llu TSS=%011llu\n", - cycle, timestamp, ts); - - return RAW1394_ISO_OK; - - } else if (now_cyclesfdf = m_fdf; + + // convert the timestamp to SYT format + uint16_t timestamp_SYT = TICKS_TO_SYT(ts); + packet->syt = ntohs(timestamp_SYT); + + *length = m_syt_interval*sizeof(quadlet_t)*m_dimension + 8; + + return m_syt_interval; +} + +unsigned int AmdtpTransmitStreamProcessor::fillNoDataPacketHeader( + struct iec61883_packet *packet, unsigned int* length) { + + // no-data packets have syt=0xFFFF + // and have the usual amount of events as dummy data (?) + packet->fdf = IEC61883_FDF_NODATA; + packet->syt = 0xffff; + + // FIXME: either make this a setting or choose + bool send_payload=true; + if(send_payload) { + // this means no-data packets with payload (DICE doesn't like that) + *length = 2*sizeof(quadlet_t) + m_syt_interval * m_dimension * sizeof(quadlet_t); + return m_syt_interval; + } else { + // dbc is not incremented + // this means no-data packets without payload + *length = 2*sizeof(quadlet_t); + return 0; + } } @@ -937,5 +887,5 @@ debugWarning("Dropped %d packets on cycle %d\n",dropped, cycle); } -#endif + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"ch%2u: CY=%4u, SYT=%08X (%4ucy + %04uticks) (running=%d, disabled=%d,%d)\n", @@ -944,4 +894,14 @@ m_running,m_disabled,m_is_disabled); + debugOutput(DEBUG_LEVEL_VERY_VERBOSE, + "RCV: CH = %d, FDF = %X. SYT = %6d, DBS = %3d, DBC = %3d, FMT = %3d, LEN = %4d\n", + channel, packet->fdf, + packet->syt, + packet->dbs, + packet->dbc, + packet->fmt, + length); + +#endif // check our enable status if (!m_disabled && m_is_disabled) { @@ -1077,5 +1037,5 @@ // ISO buffering int AmdtpReceiveStreamProcessor::getMinimalSyncDelay() { - return (int)(m_handler->getWakeupInterval() * m_syt_interval * m_ticks_per_frame); + return ((int)(m_handler->getWakeupInterval() * m_syt_interval * m_ticks_per_frame)+10000); } @@ -1441,4 +1401,2 @@ } // end of namespace FreebobStreaming - -#endif // #ifdef ENABLE_AMDTP_SP Index: branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.h =================================================================== --- branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.h (revision 404) +++ branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.h (revision 407) @@ -26,24 +26,4 @@ * */ -#ifdef ENABLE_BEBOB - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_DICE - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_BOUNCE - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_AMDTP_SP - #ifndef __FREEBOB_AMDTPSTREAMPROCESSOR__ #define __FREEBOB_AMDTPSTREAMPROCESSOR__ @@ -141,4 +121,8 @@ bool prefill(); + unsigned int fillNoDataPacketHeader(struct iec61883_packet *packet, unsigned int* length); + unsigned int fillDataPacketHeader(struct iec61883_packet *packet, unsigned int* length, uint32_t ts); + + bool transferSilence(unsigned int size); @@ -235,4 +219,2 @@ #endif /* __FREEBOB_AMDTPSTREAMPROCESSOR__ */ -#endif // #ifdef ENABLE_AMDTP_SP - Index: branches/streaming-rework/src/libstreaming/AmdtpPortInfo.cpp =================================================================== --- branches/streaming-rework/src/libstreaming/AmdtpPortInfo.cpp (revision 404) +++ branches/streaming-rework/src/libstreaming/AmdtpPortInfo.cpp (revision 407) @@ -26,25 +26,4 @@ * */ - -#ifdef ENABLE_BEBOB - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_DICE - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_BOUNCE - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_AMDTP_SP - #include "AmdtpPortInfo.h" #include @@ -55,4 +34,2 @@ } // end of namespace FreebobStreaming - -#endif // #ifdef ENABLE_AMDTP_SP Index: branches/streaming-rework/src/libstreaming/StreamProcessorManager.cpp =================================================================== --- branches/streaming-rework/src/libstreaming/StreamProcessorManager.cpp (revision 399) +++ branches/streaming-rework/src/libstreaming/StreamProcessorManager.cpp (revision 407) @@ -155,4 +155,6 @@ bool StreamProcessorManager::setSyncSource(StreamProcessor *s) { + debugOutput( DEBUG_LEVEL_VERBOSE, "Setting sync source to (%p)\n", s); + m_SyncSource=s; return true; @@ -411,5 +413,5 @@ debugOutput( DEBUG_LEVEL_VERBOSE, "Starting IsoHandlers...\n"); - if (!m_isoManager->startHandlers(0)) { + if (!m_isoManager->startHandlers(-1)) { debugFatal("Could not start handlers...\n"); return false; Index: branches/streaming-rework/src/libstreaming/MotuPort.cpp =================================================================== --- branches/streaming-rework/src/libstreaming/MotuPort.cpp (revision 404) +++ branches/streaming-rework/src/libstreaming/MotuPort.cpp (revision 407) @@ -27,6 +27,4 @@ */ -#ifdef ENABLE_MOTU - #include "MotuPort.h" #include @@ -35,4 +33,2 @@ } // end of namespace FreebobStreaming - -#endif //#ifdef ENABLE_MOTU Index: branches/streaming-rework/src/libstreaming/AmdtpPortInfo.h =================================================================== --- branches/streaming-rework/src/libstreaming/AmdtpPortInfo.h (revision 404) +++ branches/streaming-rework/src/libstreaming/AmdtpPortInfo.h (revision 407) @@ -26,25 +26,4 @@ * */ - -#ifdef ENABLE_BEBOB - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_DICE - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_BOUNCE - #ifndef ENABLE_AMDTP_SP - #define ENABLE_AMDTP_SP - #endif -#endif - -#ifdef ENABLE_AMDTP_SP - #ifndef __FREEBOB_AMDTPPORTINFO__ #define __FREEBOB_AMDTPPORTINFO__ @@ -107,4 +86,2 @@ #endif /* __FREEBOB_AMDTPPORTINFO__ */ - -#endif // #ifdef ENABLE_AMDTP_SP Index: branches/streaming-rework/src/libstreaming/StreamProcessor.cpp =================================================================== --- branches/streaming-rework/src/libstreaming/StreamProcessor.cpp (revision 401) +++ branches/streaming-rework/src/libstreaming/StreamProcessor.cpp (revision 407) @@ -80,6 +80,6 @@ debugOutputShort( DEBUG_LEVEL_NORMAL, " Device framerate : Sync: %f, Buffer %f\n", - 24576000.0*m_SyncSource->m_data_buffer->getRate(), - 24576000.0*m_data_buffer->getRate() + 24576000.0/m_SyncSource->m_data_buffer->getRate(), + 24576000.0/m_data_buffer->getRate() ); @@ -197,6 +197,6 @@ #ifdef DEBUG - uint64_t now_cycles=TICKS_TO_CYCLES(m_handler->getCycleTimerTicks()); - const int64_t max=(int64_t)(TICKS_PER_SECOND/2); + uint64_t now_cycles=CYCLE_TIMER_GET_CYCLES(m_handler->getCycleTimer()); + const int64_t max=(int64_t)(CYCLES_PER_SECOND/2); int64_t diff=(int64_t)m_cycle_to_enable_at-(int64_t)now_cycles;