- Timestamp:
- 11/04/07 09:19:44 (16 years ago)
- Files:
-
- branches/ppalmers-streaming/src/debugmodule/debugmodule.cpp (modified) (2 diffs)
- branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpStreamProcessor.cpp (modified) (23 diffs)
- branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpStreamProcessor.h (modified) (6 diffs)
- branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.cpp (modified) (3 diffs)
- branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.h (modified) (2 diffs)
- branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.cpp (modified) (17 diffs)
- branches/ppalmers-streaming/src/libstreaming/util/cycletimer.h (modified) (2 diffs)
- branches/ppalmers-streaming/src/libstreaming/util/IsoHandlerManager.cpp (modified) (2 diffs)
- branches/ppalmers-streaming/src/libutil/StreamStatistics.cpp (modified) (4 diffs)
- branches/ppalmers-streaming/src/libutil/StreamStatistics.h (modified) (3 diffs)
- branches/ppalmers-streaming/src/libutil/TimestampedBuffer.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/ppalmers-streaming/src/debugmodule/debugmodule.cpp
r698 r707 428 428 for (unsigned int i=0; i<BACKLOG_MB_BUFFERS;i++) { 429 429 unsigned int idx=(i+bl_mb_inbuffer)%BACKLOG_MB_BUFFERS; 430 fputs("BL: ", stderr); 430 431 fputs(bl_mb_buffers[idx], stderr); 431 432 } 432 fprintf(stderr, " \n");433 fprintf(stderr, "BL: \n"); 433 434 434 435 fprintf(stderr, "=====================================================\n"); … … 454 455 if (lines_to_skip-- < 0) { 455 456 unsigned int idx=(i+bl_mb_inbuffer)%BACKLOG_MB_BUFFERS; 457 fputs("BL: ", stderr); 456 458 fputs(bl_mb_buffers[idx], stderr); 457 459 } 458 460 } 459 fprintf(stderr, " \n");461 fprintf(stderr, "BL: \n"); 460 462 461 463 fprintf(stderr, "=====================================================\n"); branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpStreamProcessor.cpp
r705 r707 31 31 32 32 // in ticks 33 #define TRANSMIT_TRANSFER_DELAY 9000U 34 // the number of cycles to send a packet in advance of it's timestamp 35 #define TRANSMIT_ADVANCE_CYCLES 4U 33 // as per AMDTP2.1: 34 // 354.17us + 125us @ 24.576ticks/usec = 11776.08192 ticks 35 #define DEFAULT_TRANSFER_DELAY (11776U) 36 37 #define TRANSMIT_TRANSFER_DELAY DEFAULT_TRANSFER_DELAY 36 38 37 39 namespace Streaming { 38 39 IMPL_DEBUG_MODULE( AmdtpTransmitStreamProcessor, AmdtpTransmitStreamProcessor, DEBUG_LEVEL_VERBOSE );40 IMPL_DEBUG_MODULE( AmdtpReceiveStreamProcessor, AmdtpReceiveStreamProcessor, DEBUG_LEVEL_VERBOSE );41 42 40 43 41 /* transmit */ … … 45 43 : TransmitStreamProcessor(port, framerate), m_dimension(dimension) 46 44 , m_last_timestamp(0), m_dbc(0), m_ringbuffer_size_frames(0) 47 { 48 49 } 50 51 AmdtpTransmitStreamProcessor::~AmdtpTransmitStreamProcessor() { 52 53 } 45 {} 54 46 55 47 /** … … 66 58 return false; 67 59 } 68 69 60 return true; 70 }71 72 void AmdtpTransmitStreamProcessor::setVerboseLevel(int l) {73 setDebugLevel(l);74 TransmitStreamProcessor::setVerboseLevel(l);75 61 } 76 62 … … 79 65 unsigned char *tag, unsigned char *sy, 80 66 int cycle, unsigned int dropped, unsigned int max_length) { 81 82 67 struct iec61883_packet *packet = (struct iec61883_packet *) data; 83 68 84 69 if (cycle<0) { 85 70 debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE,"Xmit handler for cycle %d, (running=%d)\n", 86 71 cycle, m_running); 87 88 72 *tag = 0; 89 73 *sy = 0; 90 74 *length=0; 91 75 return RAW1394_ISO_OK; 92 93 } 94 76 } 77 95 78 debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE,"Xmit handler for cycle %d, (running=%d)\n", 96 79 cycle, m_running); 97 80 98 81 m_last_cycle=cycle; 99 82 … … 139 122 cycle, now_cycles); 140 123 } 124 125 // keep track of the lag 126 m_PacketStat.mark(cycle_diff); 141 127 #endif 142 128 … … 150 136 } 151 137 152 uint64_t ts_head;153 138 signed int fc; 154 139 uint64_t presentation_time; … … 156 141 int cycles_until_presentation; 157 142 158 const int min_cycles_beforehand = 2; // FIXME: should become a define 159 const int max_cycles_beforehand = 15; // FIXME: should become a define 143 uint64_t transmit_at_time; 144 unsigned int transmit_at_cycle; 145 int cycles_until_transmit; 146 147 // FIXME: should become a define 148 // the absolute minimum number of cycles we want to transmit 149 // a packet ahead of the presentation time. The nominal time 150 // the packet is transmitted ahead of the presentation time is 151 // given by TRANSMIT_TRANSFER_DELAY (in ticks), but in case we 152 // are too late for that, this constant defines how late we can 153 // be. 154 const int min_cycles_before_presentation = 1; 155 // FIXME: should become a define 156 // the absolute maximum number of cycles we want to transmit 157 // a packet ahead of the ideal transmit time. The nominal time 158 // the packet is transmitted ahead of the presentation time is 159 // given by TRANSMIT_TRANSFER_DELAY (in ticks), but we can send 160 // packets early if we want to. (not completely according to spec) 161 const int max_cycles_to_transmit_early = 1; 160 162 161 163 if( !m_running || !m_data_buffer->isEnabled() ) { … … 174 176 ffado_timestamp_t ts_head_tmp; 175 177 m_data_buffer->getBufferHeadTimestamp(&ts_head_tmp, &fc); // thread safe 176 ts_head=(uint64_t)ts_head_tmp; 177 178 // first calculate the presentation time of the samples 179 presentation_time = addTicks(ts_head, TRANSMIT_TRANSFER_DELAY); 178 179 // the timestamp gives us the time at which we want the sample block 180 // to be output by the device 181 presentation_time=(uint64_t)ts_head_tmp; 182 183 // now we calculate the time when we have to transmit the sample block 184 transmit_at_time = substractTicks(presentation_time, TRANSMIT_TRANSFER_DELAY); 180 185 181 186 // calculate the cycle this block should be presented in … … 184 189 presentation_cycle = (unsigned int)(TICKS_TO_CYCLES( presentation_time )); 185 190 191 // calculate the cycle this block should be transmitted in 192 transmit_at_cycle = (unsigned int)(TICKS_TO_CYCLES( transmit_at_time )); 193 186 194 // we can check whether this cycle is within the 'window' we have 187 195 // to send this packet. 188 196 // first calculate the number of cycles left before presentation time 189 197 cycles_until_presentation = diffCycles( presentation_cycle, cycle ); 198 199 // we can check whether this cycle is within the 'window' we have 200 // to send this packet. 201 // first calculate the number of cycles left before presentation time 202 cycles_until_transmit = diffCycles( transmit_at_cycle, cycle ); 190 203 191 204 // two different options: … … 196 209 // => determine whether we have to send them in this packet 197 210 if (fc < (signed int)m_syt_interval) { 211 m_PacketStat.signal(0); 198 212 // not enough frames in the buffer, 199 213 debugOutput(DEBUG_LEVEL_VERBOSE, 200 "Insufficient frames: CY=%04u, PTC=%04u, CUP=%04d\n",201 cycle, presentation_cycle, cycles_until_presentation);214 "Insufficient frames: N=%02d, CY=%04u, TC=%04u, CUT=%04d\n", 215 fc, cycle, transmit_at_cycle, cycles_until_transmit); 202 216 // we can still postpone the queueing of the packets 203 217 // if we are far enough ahead of the presentation time 204 if( cycles_until_presentation <= min_cycles_beforehand ) { 205 // we have an invalid timestamp or we are too late 218 if( cycles_until_presentation <= min_cycles_before_presentation ) { 219 m_PacketStat.signal(1); 220 // we are too late 206 221 // meaning that we in some sort of xrun state 207 222 // signal xrun situation ??HERE?? 208 223 m_xruns++; 224 // we send an empty packet on this cycle 225 goto send_empty_packet; // UGLY but effective 209 226 } else { 227 m_PacketStat.signal(2); 210 228 // there is still time left to send the packet 229 // we want the system to give this packet another go 230 // goto try_packet_again; // UGLY but effective 231 // unfortunatly the try_again doesn't work very well, 232 // so we'll have to either usleep(one cycle) and goto try_block_of_frames 233 234 // or just fill this with an empty packet 235 // if we have to do this too often, the presentation time will 236 // get too close and we're in trouble 237 goto send_empty_packet; // UGLY but effective 211 238 } 212 // in any case we send an empty packet on this cycle213 goto send_empty_packet; // UGLY but effective214 239 } else { 240 m_PacketStat.signal(3); 215 241 // there are enough frames, so check the time they are intended for 216 242 // all frames have a certain 'time window' in which they can be sent … … 229 255 // get next block of frames and repeat 230 256 231 if (cycles_until_presentation <= min_cycles_beforehand) { 257 if (cycles_until_transmit <= max_cycles_to_transmit_early) { 258 m_PacketStat.signal(4); 259 // it's time send the packet 260 goto send_packet; // UGLY but effective 261 } else if (cycles_until_transmit < 0) { 232 262 // we are too late 233 263 debugOutput(DEBUG_LEVEL_VERBOSE, 234 "Too late: CY=%04u, PTC=%04u, CUP=%04d, TSP=%011llu (%04u)\n",264 "Too late: CY=%04u, TC=%04u, CUT=%04d, TSP=%011llu (%04u)\n", 235 265 cycle, 236 presentation_cycle, cycles_until_presentation,266 transmit_at_cycle, cycles_until_transmit, 237 267 presentation_time, (unsigned int)TICKS_TO_CYCLES(presentation_time)); 238 // remove the samples 239 m_data_buffer->dropFrames(m_syt_interval); 240 241 // signal some xrun situation ??HERE?? 242 m_xruns++; 243 244 // try a new block of frames 245 goto try_block_of_frames; // UGLY but effective 246 } else if (cycles_until_presentation >= max_cycles_beforehand) { 268 269 // however, if we can send this sufficiently before the presentation 270 // time, it could be harmless. 271 // NOTE: dangerous since the device has no way of reporting that it didn't get 272 // this packet on time. 273 if ( cycles_until_presentation <= min_cycles_before_presentation ) { 274 m_PacketStat.signal(5); 275 // we are not that late and can still try to transmit the packet 276 goto send_packet; // UGLY but effective 277 } else { // definitely too late 278 m_PacketStat.signal(6); 279 // remove the samples 280 m_data_buffer->dropFrames(m_syt_interval); 281 // signal some xrun situation ??HERE?? 282 m_xruns++; 283 // try a new block of frames 284 goto try_block_of_frames; // UGLY but effective 285 } 286 } else { 287 m_PacketStat.signal(7); 247 288 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, 248 "Too early: CY=%04u, PTC=%04u, CUP=%04d, TSP=%011llu (%04u)\n",289 "Too early: CY=%04u, TC=%04u, CUT=%04d, TST=%011llu (%04u), TSP=%011llu (%04u)\n", 249 290 cycle, 250 presentation_cycle, cycles_until_presentation, 291 transmit_at_cycle, cycles_until_transmit, 292 transmit_at_time, (unsigned int)TICKS_TO_CYCLES(transmit_at_time), 251 293 presentation_time, (unsigned int)TICKS_TO_CYCLES(presentation_time)); 294 #ifdef DEBUG 295 if (cycles_until_transmit > max_cycles_to_transmit_early + 1) { 296 debugOutput(DEBUG_LEVEL_VERBOSE, 297 "Way too early: CY=%04u, TC=%04u, CUT=%04d, TST=%011llu (%04u), TSP=%011llu (%04u)\n", 298 cycle, 299 transmit_at_cycle, cycles_until_transmit, 300 transmit_at_time, (unsigned int)TICKS_TO_CYCLES(transmit_at_time), 301 presentation_time, (unsigned int)TICKS_TO_CYCLES(presentation_time)); 302 } 303 #endif 252 304 // we are too early, send only an empty packet 253 305 goto send_empty_packet; // UGLY but effective 254 } else {255 // send the packet256 goto send_packet; // UGLY but effective257 306 } 258 307 } 259 260 debug Error("Should never reach this code!\n");308 309 debugFatal("Should never reach this code!\n"); 261 310 return RAW1394_ISO_ERROR; 262 311 263 312 send_empty_packet: 264 313 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT NONE: CY=%04u, TSP=%011llu (%04u)\n", … … 279 328 } 280 329 281 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT DATA: CY=%04u, TS H=%011llu (%04u), TSP=%011llu (%04u)\n",330 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT DATA: CY=%04u, TST=%011llu (%04u), TSP=%011llu (%04u)\n", 282 331 cycle, 283 t s_head, (unsigned int)TICKS_TO_CYCLES(ts_head),332 transmit_at_time, (unsigned int)TICKS_TO_CYCLES(transmit_at_time), 284 333 presentation_time, (unsigned int)TICKS_TO_CYCLES(presentation_time)); 285 334 286 335 return RAW1394_ISO_OK; 287 336 } 337 338 // the ISO AGAIN does not work very well... 339 // try_packet_again: 340 // 341 // debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT RETRY: CY=%04u, TSP=%011llu (%04u)\n", 342 // cycle, 343 // presentation_time, (unsigned int)TICKS_TO_CYCLES(presentation_time)); 344 // return RAW1394_ISO_AGAIN; 345 288 346 // else: 289 debug Error("This is impossible, since we checked the buffer size before!\n");347 debugFatal("This is impossible, since we checked the buffer size before!\n"); 290 348 return RAW1394_ISO_ERROR; 291 349 } … … 549 607 550 608 bool AmdtpTransmitStreamProcessor::prepareForStart() { 551 552 609 return true; 553 610 } … … 589 646 bool AmdtpTransmitStreamProcessor::putFrames(unsigned int nbframes, int64_t ts) { 590 647 m_PeriodStat.mark(m_data_buffer->getBufferFill()); 591 592 648 debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, "AmdtpTransmitStreamProcessor::putFrames(%d, %llu)\n", nbframes, ts); 593 649 … … 601 657 602 658 bool AmdtpTransmitStreamProcessor::putFramesDry(unsigned int nbframes, int64_t ts) { 659 m_PeriodStat.mark(m_data_buffer->getBufferFill()); 603 660 debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, "AmdtpTransmitStreamProcessor::putFramesDry(%d, %llu)\n", nbframes, ts); 604 661 … … 844 901 845 902 AmdtpReceiveStreamProcessor::AmdtpReceiveStreamProcessor(int port, int framerate, int dimension) 846 : ReceiveStreamProcessor(port, framerate), m_dimension(dimension), m_last_timestamp(0), m_last_timestamp2(0) { 847 848 } 849 850 AmdtpReceiveStreamProcessor::~AmdtpReceiveStreamProcessor() { 851 852 } 903 : ReceiveStreamProcessor(port, framerate), m_dimension(dimension), m_last_timestamp(0), m_last_timestamp2(0) 904 {} 853 905 854 906 bool AmdtpReceiveStreamProcessor::init() { … … 861 913 return false; 862 914 } 863 864 915 return true; 865 916 } … … 882 933 883 934 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"ch%2u: CY=%4u, SYT=%08X (%4ucy + %04uticks) (running=%d)\n", 884 channel, cycle, ntohs(packet->syt),935 channel, cycle, ntohs(packet->syt), 885 936 CYCLE_TIMER_GET_CYCLES(ntohs(packet->syt)), CYCLE_TIMER_GET_OFFSET(ntohs(packet->syt)), 886 937 m_running); … … 934 985 #ifdef DEBUG_OFF 935 986 if((cycle % 1000) == 0) { 987 uint32_t now=m_handler->getCycleTimer(); 936 988 uint32_t syt = (uint32_t)ntohs(packet->syt); 937 uint32_t now=m_handler->getCycleTimer();938 989 uint32_t now_ticks=CYCLE_TIMER_TO_TICKS(now); 939 990 … … 952 1003 #endif 953 1004 1005 #ifdef DEBUG 1006 // keep track of the lag 1007 uint32_t now=m_handler->getCycleTimer(); 1008 int32_t diff = diffCycles( cycle, ((int)CYCLE_TIMER_GET_CYCLES(now)) ); 1009 m_PacketStat.mark(diff); 1010 #endif 1011 954 1012 //=> process the packet 955 1013 // add the data payload to the ringbuffer … … 987 1045 void AmdtpReceiveStreamProcessor::dumpInfo() { 988 1046 StreamProcessor::dumpInfo(); 989 }990 991 void AmdtpReceiveStreamProcessor::setVerboseLevel(int l) {992 setDebugLevel(l);993 ReceiveStreamProcessor::setVerboseLevel(l);994 1047 } 995 1048 … … 1170 1223 1171 1224 bool AmdtpReceiveStreamProcessor::getFrames(unsigned int nbframes, int64_t ts) { 1225 m_PeriodStat.mark(m_data_buffer->getBufferFill()); 1172 1226 1173 1227 // ask the buffer to process nbframes of frames … … 1180 1234 1181 1235 bool AmdtpReceiveStreamProcessor::getFramesDry(unsigned int nbframes, int64_t ts) { 1236 m_PeriodStat.mark(m_data_buffer->getBufferFill()); 1182 1237 int frames_to_ditch=(int)(nbframes); 1183 1238 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "stream (%p): dry run %d frames (@ ts=%lld)\n", branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpStreamProcessor.h
r705 r707 79 79 */ 80 80 AmdtpTransmitStreamProcessor(int port, int framerate, int dimension); 81 82 virtual ~AmdtpTransmitStreamProcessor(); 81 virtual ~AmdtpTransmitStreamProcessor() {}; 83 82 84 83 enum raw1394_iso_disposition … … 111 110 112 111 int getMinimalSyncDelay(); 113 114 void setVerboseLevel(int l);115 112 116 113 protected: … … 150 147 151 148 unsigned int m_ringbuffer_size_frames; 152 153 DECLARE_DEBUG_MODULE;154 155 149 }; 156 150 /*! … … 174 168 */ 175 169 AmdtpReceiveStreamProcessor(int port, int framerate, int dimension); 176 177 virtual ~AmdtpReceiveStreamProcessor(); 170 virtual ~AmdtpReceiveStreamProcessor() {}; 178 171 179 172 enum raw1394_iso_disposition putPacket(unsigned char *data, unsigned int length, … … 207 200 int getMinimalSyncDelay(); 208 201 209 void setVerboseLevel(int l);210 211 202 protected: 212 203 … … 224 215 uint64_t m_last_timestamp2; /// last timestamp (in ticks) 225 216 uint64_t m_last_timestamp_at_period_ticks; 226 227 DECLARE_DEBUG_MODULE;228 229 217 }; 230 218 branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.cpp
r706 r707 84 84 m_PeriodStat.dumpInfo(); 85 85 m_PacketStat.dumpInfo(); 86 m_WakeupStat.dumpInfo(); 87 86 // m_WakeupStat.dumpInfo(); 88 87 } 89 88 … … 293 292 IsoStream::setVerboseLevel(l); 294 293 PortManager::setVerboseLevel(l); 295 296 294 } 297 295 … … 334 332 335 333 bool TransmitStreamProcessor::canClientTransferFrames(unsigned int nbframes) { 334 bool can_transfer; 336 335 // there has to be enough space to put the frames in 337 return m_data_buffer->getBufferSize() - m_data_buffer->getFrameCounter() > nbframes; 338 } 339 340 341 } 336 can_transfer = m_data_buffer->getBufferSize() - m_data_buffer->getFrameCounter() > nbframes; 337 // or the buffer is transparent 338 can_transfer |= m_data_buffer->isTransparent(); 339 return can_transfer; 340 } 341 342 343 } branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.h
r706 r707 111 111 Util::TimestampedBuffer *m_data_buffer; 112 112 113 StreamStatistics m_PacketStat; 114 StreamStatistics m_PeriodStat; 115 116 StreamStatistics m_WakeupStat; 117 113 118 protected: // SPM related 114 119 void setManager(StreamProcessorManager *manager) {m_manager=manager;}; … … 130 135 unsigned int m_cycle_to_enable_at; 131 136 132 StreamStatistics m_PacketStat;133 StreamStatistics m_PeriodStat;134 135 StreamStatistics m_WakeupStat;136 137 137 138 branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.cpp
r705 r707 41 41 namespace Streaming { 42 42 43 IMPL_DEBUG_MODULE( StreamProcessorManager, StreamProcessorManager, DEBUG_LEVEL_ NORMAL);43 IMPL_DEBUG_MODULE( StreamProcessorManager, StreamProcessorManager, DEBUG_LEVEL_VERBOSE ); 44 44 45 45 StreamProcessorManager::StreamProcessorManager(unsigned int period, unsigned int nb_buffers) … … 391 391 } 392 392 393 debugOutput( DEBUG_LEVEL_VERBOSE, " sync at TS=%011llu...\n", m_time_of_transfer); 393 debugOutput( DEBUG_LEVEL_VERBOSE, " sync at TS=%011llu (%03us %04uc %04ut)...\n", 394 m_time_of_transfer, 395 (unsigned int)TICKS_TO_SECS(m_time_of_transfer), 396 (unsigned int)TICKS_TO_CYCLES(m_time_of_transfer), 397 (unsigned int)TICKS_TO_OFFSET(m_time_of_transfer)); 394 398 // FIXME: xruns can screw up the framecounter accounting. do something more sane here 395 399 resetXrunCounters(); … … 450 454 while(nb_dryrun_cycles--) { 451 455 waitForPeriod(); 456 m_TransmitProcessors.at(0)->m_PacketStat.dumpInfo(); 452 457 no_xrun = dryRun(); // dry run both receive and xmit 453 458 454 if ( no_xrun) {459 if (!no_xrun) { 455 460 debugOutput( DEBUG_LEVEL_VERBOSE, " This dry-run was not xrun free...\n" ); 456 461 resetXrunCounters(); … … 826 831 debugOutput( DEBUG_LEVEL_VERBOSE, "Handling Xrun ...\n"); 827 832 833 dumpInfo(); 834 828 835 /* 829 836 * Reset means: … … 892 899 } 893 900 901 if(xrun_occurred) break; 902 894 903 // check if we were waked up too soon 895 904 time_till_next_period=m_SyncSource->getTimeUntilNextPeriodSignalUsecs(); … … 941 950 942 951 // if this is true, a xrun will occur 943 xrun_occurred |= !((*it)->canClientTransferFrames(m_period)) ;952 xrun_occurred |= !((*it)->canClientTransferFrames(m_period)) && (*it)->isEnabled(); 944 953 945 954 #ifdef DEBUG … … 948 957 (*it)->dumpInfo(); 949 958 } 950 if (!((*it)->canClientTransferFrames(m_period)) ) {959 if (!((*it)->canClientTransferFrames(m_period)) && (*it)->isEnabled()) { 951 960 debugWarning("Xrun on RECV SP %p due to buffer xrun\n",*it); 952 961 (*it)->dumpInfo(); … … 962 971 963 972 // if this is true, a xrun will occur 964 xrun_occurred |= !((*it)->canClientTransferFrames(m_period)) ;973 xrun_occurred |= !((*it)->canClientTransferFrames(m_period)) && (*it)->isEnabled(); 965 974 966 975 #ifdef DEBUG … … 968 977 debugWarning("Xrun on XMIT SP %p due to ISO xrun\n",*it); 969 978 } 970 if (!((*it)->canClientTransferFrames(m_period)) ) {979 if (!((*it)->canClientTransferFrames(m_period)) && (*it)->isEnabled()) { 971 980 debugWarning("Xrun on XMIT SP %p due to buffer xrun\n",*it); 972 981 } … … 990 999 991 1000 debugOutput( DEBUG_LEVEL_VERBOSE, "Transferring period...\n"); 992 993 if (!transfer(StreamProcessor::E_Receive)) return false; 994 if (!transfer(StreamProcessor::E_Transmit)) return false; 995 996 return true; 1001 bool retval=true; 1002 retval &= dryRun(StreamProcessor::E_Receive); 1003 retval &= dryRun(StreamProcessor::E_Transmit); 1004 return retval; 997 1005 } 998 1006 … … 1008 1016 bool StreamProcessorManager::transfer(enum StreamProcessor::EProcessorType t) { 1009 1017 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Transferring period...\n"); 1010 1018 bool retval = true; 1011 1019 // a static cast could make sure that there is no performance 1012 1020 // penalty for the virtual functions (to be checked) 1013 1021 if (t==StreamProcessor::E_Receive) { 1014 1015 1022 // determine the time at which we want reception to start 1016 1023 float rate=m_SyncSource->getTicksPerFrame(); … … 1035 1042 debugOutput(DEBUG_LEVEL_VERBOSE,"could not getFrames(%u, %11llu) from stream processor (%p)\n", 1036 1043 m_period, m_time_of_transfer,*it); 1037 return false; // buffer underrun 1038 } 1039 1044 retval &= false; // buffer underrun 1045 } 1040 1046 } 1041 1047 } else { … … 1055 1061 debugOutput(DEBUG_LEVEL_VERBOSE, "could not putFrames(%u,%llu) to stream processor (%p)\n", 1056 1062 m_period, transmit_timestamp, *it); 1057 return false; // buffer overrun 1058 } 1059 1060 } 1061 } 1062 1063 return true; 1063 retval &= false; // buffer underrun 1064 } 1065 1066 } 1067 } 1068 return retval; 1064 1069 } 1065 1070 … … 1075 1080 bool StreamProcessorManager::dryRun() { 1076 1081 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Dry-running period...\n"); 1077 if (!dryRun(StreamProcessor::E_Receive)) return false; 1078 if (!dryRun(StreamProcessor::E_Transmit)) return false; 1079 return true; 1082 bool retval=true; 1083 retval &= dryRun(StreamProcessor::E_Receive); 1084 retval &= dryRun(StreamProcessor::E_Transmit); 1085 return retval; 1080 1086 } 1081 1087 … … 1090 1096 1091 1097 bool StreamProcessorManager::dryRun(enum StreamProcessor::EProcessorType t) { 1092 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " Transferring period...\n");1093 1098 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Dry-running period...\n"); 1099 bool retval = true; 1094 1100 // a static cast could make sure that there is no performance 1095 1101 // penalty for the virtual functions (to be checked) 1096 1102 if (t==StreamProcessor::E_Receive) { 1097 1098 1103 // determine the time at which we want reception to start 1099 1104 float rate=m_SyncSource->getTicksPerFrame(); … … 1118 1123 debugOutput(DEBUG_LEVEL_VERBOSE,"could not getFrames(%u, %11llu) from stream processor (%p)\n", 1119 1124 m_period, m_time_of_transfer,*it); 1120 returnfalse; // buffer underrun1125 retval &= false; // buffer underrun 1121 1126 } 1122 1127 … … 1138 1143 debugOutput(DEBUG_LEVEL_VERBOSE, "could not putFrames(%u,%llu) to stream processor (%p)\n", 1139 1144 m_period, transmit_timestamp, *it); 1140 return false; // buffer overrun 1141 } 1142 1143 } 1144 } 1145 1146 return true; 1145 retval &= false; // buffer underrun 1146 } 1147 1148 } 1149 } 1150 return retval; 1147 1151 } 1148 1152 branches/ppalmers-streaming/src/libstreaming/util/cycletimer.h
r705 r707 156 156 return x; 157 157 158 } 159 160 /** 161 * @brief Computes a difference between cycles 162 * 163 * This function computes a difference between cycles 164 * such that it respects wrapping (at 8000 cycles). 165 * 166 * See diffTicks 167 * 168 * @param x First cycle value 169 * @param y Second cycle value 170 * @return the difference x-y, unwrapped 171 */ 172 static inline int diffCycles(unsigned int x, unsigned int y) { 173 int diff = x - y; 174 175 // the maximal difference we allow (64secs) 176 const int max=CYCLES_PER_SECOND/2; 177 178 if(diff > max) { 179 diff -= CYCLES_PER_SECOND; 180 } else if (diff < -max) { 181 diff += CYCLES_PER_SECOND; 182 } 183 184 return diff; 158 185 } 159 186 … … 406 433 } 407 434 408 /**409 * @brief Computes a difference between cycles410 *411 * This function computes a difference between cycles412 * such that it respects wrapping (at 8000 cycles).413 *414 * See diffTicks415 *416 * @param x First cycle value417 * @param y Second cycle value418 * @return the difference x-y, unwrapped419 */420 static inline int diffCycles(unsigned int x, unsigned int y) {421 int diff = x - y;422 423 // the maximal difference we allow (64secs)424 const int max=CYCLES_PER_SECOND/2;425 426 if(diff > max) {427 diff -= CYCLES_PER_SECOND;428 } else if (diff < -max) {429 diff += CYCLES_PER_SECOND;430 }431 432 return diff;433 }434 435 435 #endif // __CYCLETIMER_H__ branches/ppalmers-streaming/src/libstreaming/util/IsoHandlerManager.cpp
r705 r707 30 30 #include <assert.h> 31 31 32 #define MINIMUM_INTERRUPTS_PER_PERIOD 2U32 #define MINIMUM_INTERRUPTS_PER_PERIOD 4U 33 33 #define PACKETS_PER_INTERRUPT 4U 34 34 … … 450 450 // event buffers 451 451 452 // FIXME: latency spoiler 452 453 // every irq_interval packets an interrupt will occur. that is when 453 454 // buffers get transfered, meaning that we should have at least some branches/ppalmers-streaming/src/libutil/StreamStatistics.cpp
r445 r707 26 26 27 27 namespace Streaming { 28 IMPL_DEBUG_MODULE( StreamStatistics, StreamStatistics, DEBUG_LEVEL_VERBOSE ); 28 29 29 30 StreamStatistics::StreamStatistics() … … 35 36 , m_sum(0) 36 37 { 37 38 } 39 40 41 StreamStatistics::~StreamStatistics() 42 { 38 reset(); 43 39 } 44 40 … … 51 47 } 52 48 49 void StreamStatistics::signal(unsigned int val) { 50 if (val <= MAX_SIGNAL_VALUE) { 51 m_signalled[val]++; 52 } 53 } 54 53 55 void StreamStatistics::dumpInfo() { 54 printf("--- Stats for %s: min=%ld avg=%f max=%ld cnt=%ld sum=%ld\n",m_name.c_str(), 55 m_min,m_average,m_max,m_count,m_sum); 56 debugOutputShort( DEBUG_LEVEL_VERBOSE, 57 "--- Stats for %s: min=%ld avg=%f max=%ld cnt=%ld sum=%ld\n", 58 m_name.c_str(), m_min, m_average, m_max, m_count, m_sum); 59 debugOutputShort( DEBUG_LEVEL_VERBOSE, " Signal stats\n"); 60 for (unsigned int i=0;i <= MAX_SIGNAL_VALUE; i++) { 61 debugOutputShort(DEBUG_LEVEL_VERBOSE, 62 " Stats for %3u: %8u\n", 63 i, m_signalled[i]); 64 } 56 65 } 57 66 … … 62 71 m_max=0; 63 72 m_sum=0; 73 74 for (unsigned int i=0;i <= MAX_SIGNAL_VALUE; i++) { 75 m_signalled[i]=0; 76 } 64 77 } 65 78 branches/ppalmers-streaming/src/libutil/StreamStatistics.h
r445 r707 27 27 #include <string> 28 28 29 #include "debugmodule/debugmodule.h" 30 31 #define MAX_SIGNAL_VALUE 7 29 32 namespace Streaming { 30 33 … … 33 36 StreamStatistics(); 34 37 35 ~StreamStatistics() ;38 ~StreamStatistics() {}; 36 39 37 40 void setName(std::string n) {m_name=n;}; … … 50 53 long m_sum; 51 54 55 // some tools to do run statistics 56 // will keep a histogram of the number of times a certain value 57 // is added. 58 void signal(unsigned int val); 59 60 unsigned int m_signalled[MAX_SIGNAL_VALUE+1]; 61 52 62 private: 53 63 DECLARE_DEBUG_MODULE; 54 64 }; 55 65 branches/ppalmers-streaming/src/libutil/TimestampedBuffer.cpp
r705 r707 501 501 502 502 if(vec[0].len==0) { // this indicates a full event buffer 503 debugError("Event buffer overrun in buffer %p\n",this); 504 break; 503 debugError("Event buffer overrun in buffer %p, fill: %u, bytes2write: %u \n", 504 this, ffado_ringbuffer_read_space(m_event_buffer), bytes2write); 505 debugShowBackLog(); 506 return false; 505 507 } 506 508