- Timestamp:
- 02/06/07 23:59:56 (17 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/streaming-rework/src/libstreaming/StreamProcessor.cpp
r386 r390 31 31 #include "StreamProcessor.h" 32 32 #include "StreamProcessorManager.h" 33 #include "cycletimer.h" 33 34 34 35 #include <assert.h> … … 50 51 , m_disabled(true) 51 52 , m_is_disabled(true) 53 , m_cycle_to_enable_at(0) 52 54 , m_framecounter(0) 53 55 , m_SyncSource(NULL) … … 211 213 } 212 214 215 uint64_t StreamProcessor::getTimeNow() { 216 return m_handler->getCycleTimerTicks(); 217 } 218 219 213 220 bool StreamProcessor::isRunning() { 214 221 return m_running; 215 222 } 216 223 217 bool StreamProcessor::enable() { 218 int cnt=0; 224 bool StreamProcessor::enable(uint64_t time_to_enable_at) { 225 // FIXME: time_to_enable_at will be in 'time' not cycles 226 m_cycle_to_enable_at=time_to_enable_at; 219 227 220 228 if(!m_running) { 221 229 debugWarning("The StreamProcessor is not running yet, enable() might not be a good idea.\n"); 222 230 } 223 231 232 #ifdef DEBUG 233 uint64_t now_cycles=TICKS_TO_CYCLES(m_handler->getCycleTimerTicks()); 234 const int64_t max=(int64_t)(TICKS_PER_SECOND/2); 235 236 int64_t diff=m_cycle_to_enable_at-now_cycles; 237 238 if (diff > max) { 239 diff-=TICKS_PER_SECOND; 240 } else if (diff < -max) { 241 diff+=TICKS_PER_SECOND; 242 } 243 244 if (diff<0) { 245 debugWarning("Request to enable streamprocessor %d cycles ago.\n",diff); 246 } 247 #endif 248 224 249 m_disabled=false; 225 250 226 // now wait until it is effectively enabled227 // time-out at 100ms228 while(m_is_disabled && cnt++ < 1000) {229 usleep(100);230 }231 232 // check if the operation timed out233 if(cnt==1000) {234 debugWarning("Timeout when enabling StreamProcessor (%p)\n",this);235 return false;236 }237 238 251 return true; 239 252 } 240 253 241 254 bool StreamProcessor::disable() { 242 int cnt=0;243 255 244 256 m_disabled=true; 245 246 // now wait until it is effectively disabled 247 // time-out at 248 while(!m_is_disabled && cnt++ < 1000) { 249 usleep(100); 250 } 251 252 // check if the operation timed out (100ms) 253 if(cnt==1000) { 254 debugWarning("Timeout when disabling StreamProcessor (%p)\n",this); 255 return false; 256 } 257 257 258 258 return true; 259 259