Changeset 401
- Timestamp:
- 02/17/07 08:37:50 (17 years ago)
- Files:
-
- branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp (modified) (4 diffs)
- branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.h (modified) (4 diffs)
- branches/streaming-rework/src/libstreaming/StreamProcessor.cpp (modified) (3 diffs)
- branches/streaming-rework/src/libstreaming/StreamProcessor.h (modified) (5 diffs)
- branches/streaming-rework/src/libutil/TimestampedBuffer.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp
r399 r401 361 361 return RAW1394_ISO_ERROR; 362 362 363 }364 365 int64_t AmdtpTransmitStreamProcessor::getTimeUntilNextPeriodUsecs() {366 uint64_t time_at_period=getTimeAtPeriod();367 368 uint64_t cycle_timer=m_handler->getCycleTimerTicks();369 370 // calculate the time until the next period371 int64_t until_next=substractTicks(time_at_period,cycle_timer);372 373 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> TAP=%11llu, CTR=%11llu, UTN=%11lld\n",374 time_at_period, cycle_timer, until_next375 );376 377 // now convert to usecs378 // don't use the mapping function because it only works379 // for absolute times, not the relative time we are380 // using here (which can also be negative).381 return (int64_t)(((float)until_next) / TICKS_PER_USEC);382 }383 384 uint64_t AmdtpTransmitStreamProcessor::getTimeAtPeriodUsecs() {385 // then we should convert this into usecs386 return (uint64_t)((float)getTimeAtPeriod() * TICKS_PER_USEC);387 }388 389 uint64_t AmdtpTransmitStreamProcessor::getTimeAtPeriod() {390 uint64_t next_period_boundary=m_data_buffer->getTimestampFromTail((m_nb_buffers-1) * m_period);391 392 #ifdef DEBUG393 uint64_t ts,fc;394 m_data_buffer->getBufferTailTimestamp(&ts,&fc);395 396 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD=%11lld, LTS=%11llu, FC=%5u, TPF=%f\n",397 next_period_boundary, ts, fc, m_ticks_per_frame398 );399 #endif400 401 return next_period_boundary;402 363 } 403 364 … … 699 660 } 700 661 701 bool AmdtpTransmitStreamProcessor::canClientTransferFrames(unsigned int nbframes) {702 // there has to be enough space to put the frames in703 return m_ringbuffer_size_frames - m_data_buffer->getFrameCounter() > nbframes;704 }705 706 662 bool AmdtpTransmitStreamProcessor::putFrames(unsigned int nbframes, int64_t ts) { 707 663 m_PeriodStat.mark(m_data_buffer->getBufferFill()); … … 1099 1055 1100 1056 return retval; 1101 }1102 1103 int64_t AmdtpReceiveStreamProcessor::getTimeUntilNextPeriodUsecs() {1104 uint64_t time_at_period=getTimeAtPeriod();1105 1106 uint64_t cycle_timer=m_handler->getCycleTimerTicks();1107 1108 // calculate the time until the next period1109 int64_t until_next=substractTicks(time_at_period,cycle_timer);1110 1111 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> TAP=%11llu, CTR=%11llu, UTN=%11lld\n",1112 time_at_period, cycle_timer, until_next1113 );1114 1115 // now convert to usecs1116 // don't use the mapping function because it only works1117 // for absolute times, not the relative time we are1118 // using here (which can also be negative).1119 return (int64_t)(((float)until_next) / TICKS_PER_USEC);1120 }1121 1122 uint64_t AmdtpReceiveStreamProcessor::getTimeAtPeriodUsecs() {1123 // then we should convert this into usecs1124 return (uint64_t)((float)getTimeAtPeriod()*TICKS_PER_USEC);1125 }1126 1127 uint64_t AmdtpReceiveStreamProcessor::getTimeAtPeriod() {1128 uint64_t next_period_boundary=m_data_buffer->getTimestampFromHead(m_period);1129 1130 #ifdef DEBUG1131 uint64_t ts,fc;1132 m_data_buffer->getBufferTailTimestamp(&ts,&fc);1133 1134 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD=%11lld, LTS=%11llu, FC=%5u, TPF=%f\n",1135 next_period_boundary, ts, fc, m_ticks_per_frame1136 );1137 #endif1138 1139 return next_period_boundary;1140 1057 } 1141 1058 … … 1355 1272 } 1356 1273 1357 bool AmdtpReceiveStreamProcessor::canClientTransferFrames(unsigned int nbframes) {1358 return m_data_buffer->getFrameCounter() >= (int) nbframes;1359 }1360 1361 1274 bool AmdtpReceiveStreamProcessor::getFrames(unsigned int nbframes) { 1362 1275 branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.h
r399 r401 95 95 bool prepareForEnable(uint64_t time_to_enable_at); 96 96 97 bool canClientTransferFrames(unsigned int nbframes);98 97 bool putFrames(unsigned int nbframes, int64_t ts); ///< transfer the buffer contents from the client 99 98 … … 109 108 unsigned int getMaxPacketSize() {return 4 * (2 + m_syt_interval * m_dimension);}; 110 109 111 int64_t getTimeUntilNextPeriodUsecs();112 113 uint64_t getTimeAtPeriodUsecs();114 uint64_t getTimeAtPeriod();115 110 int getMinimalSyncDelay(); 116 111 … … 183 178 bool prepareForStart(); 184 179 185 bool canClientTransferFrames(unsigned int nbframes);186 180 bool getFrames(unsigned int nbframes); ///< transfer the buffer contents to the client 187 181 … … 199 193 void dumpInfo(); 200 194 201 int64_t getTimeUntilNextPeriodUsecs();202 203 uint64_t getTimeAtPeriodUsecs();204 uint64_t getTimeAtPeriod();205 195 int getMinimalSyncDelay(); 206 196 branches/streaming-rework/src/libstreaming/StreamProcessor.cpp
r399 r401 232 232 } 233 233 234 int64_t StreamProcessor::getTimeUntilNextPeriodUsecs() { 235 uint64_t time_at_period=getTimeAtPeriod(); 236 237 uint64_t cycle_timer=m_handler->getCycleTimerTicks(); 238 239 // calculate the time until the next period 240 int64_t until_next=substractTicks(time_at_period,cycle_timer); 241 242 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> TAP=%11llu, CTR=%11llu, UTN=%11lld\n", 243 time_at_period, cycle_timer, until_next 244 ); 245 246 // now convert to usecs 247 // don't use the mapping function because it only works 248 // for absolute times, not the relative time we are 249 // using here (which can also be negative). 250 return (int64_t)(((float)until_next) / TICKS_PER_USEC); 251 } 252 253 uint64_t StreamProcessor::getTimeAtPeriodUsecs() { 254 return (uint64_t)((float)getTimeAtPeriod() * TICKS_PER_USEC); 255 } 256 234 257 /** 235 258 * Resets the xrun counter, in a atomic way. This … … 262 285 } 263 286 287 uint64_t ReceiveStreamProcessor::getTimeAtPeriod() { 288 uint64_t next_period_boundary=m_data_buffer->getTimestampFromHead(m_period); 289 290 #ifdef DEBUG 291 uint64_t ts,fc; 292 m_data_buffer->getBufferTailTimestamp(&ts,&fc); 293 294 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD=%11lld, LTS=%11llu, FC=%5u, TPF=%f\n", 295 next_period_boundary, ts, fc, m_ticks_per_frame 296 ); 297 #endif 298 299 return next_period_boundary; 300 } 301 302 bool ReceiveStreamProcessor::canClientTransferFrames(unsigned int nbframes) { 303 return m_data_buffer->getFrameCounter() >= (int) nbframes; 304 } 264 305 265 306 TransmitStreamProcessor::TransmitStreamProcessor( int port, int framerate) … … 278 319 } 279 320 280 } 321 uint64_t TransmitStreamProcessor::getTimeAtPeriod() { 322 uint64_t next_period_boundary=m_data_buffer->getTimestampFromTail((m_nb_buffers-1) * m_period); 323 324 #ifdef DEBUG 325 uint64_t ts,fc; 326 m_data_buffer->getBufferTailTimestamp(&ts,&fc); 327 328 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD=%11lld, LTS=%11llu, FC=%5u, TPF=%f\n", 329 next_period_boundary, ts, fc, m_ticks_per_frame 330 ); 331 #endif 332 333 return next_period_boundary; 334 } 335 336 bool TransmitStreamProcessor::canClientTransferFrames(unsigned int nbframes) { 337 // there has to be enough space to put the frames in 338 return m_data_buffer->getBufferSize() - m_data_buffer->getFrameCounter() > nbframes; 339 } 340 341 342 } branches/streaming-rework/src/libstreaming/StreamProcessor.h
r399 r401 151 151 * false if it can't 152 152 */ 153 virtual bool canClientTransferFrames(unsigned int nframes) {return true;};153 virtual bool canClientTransferFrames(unsigned int nframes) = 0; 154 154 155 155 /** … … 164 164 * \return the time in usecs 165 165 */ 166 virtual int64_t getTimeUntilNextPeriodUsecs() = 0;166 int64_t getTimeUntilNextPeriodUsecs(); 167 167 /** 168 168 * \brief return the time of the next period boundary (in microseconds) … … 176 176 * \return the time in usecs 177 177 */ 178 virtual uint64_t getTimeAtPeriodUsecs() = 0;178 uint64_t getTimeAtPeriodUsecs(); 179 179 180 180 /** … … 251 251 virtual void setVerboseLevel(int l); 252 252 253 uint64_t getTimeAtPeriod(); 254 bool canClientTransferFrames(unsigned int nframes); 255 253 256 protected: 254 257 bool processWriteBlock(char *data, unsigned int nevents, unsigned int offset) {return true;}; … … 283 286 virtual void setVerboseLevel(int l); 284 287 288 uint64_t getTimeAtPeriod(); 289 bool canClientTransferFrames(unsigned int nframes); 290 285 291 protected: 286 292 bool processReadBlock(char *data, unsigned int nevents, unsigned int offset) {return true;}; branches/streaming-rework/src/libutil/TimestampedBuffer.h
r397 r401 100 100 bool setEventsPerFrame(unsigned int s); 101 101 bool setBufferSize(unsigned int s); 102 unsigned int getBufferSize() {return m_buffer_size;}; 102 103 103 104 bool setWrapValue(uint64_t w);