Changeset 1027
- Timestamp:
- 04/25/08 07:04:52 (16 years ago)
- Files:
-
- trunk/libffado/src/libieee1394/CycleTimerHelper.cpp (modified) (3 diffs)
- trunk/libffado/src/libieee1394/CycleTimerHelper.h (modified) (1 diff)
- trunk/libffado/src/libieee1394/ieee1394service.cpp (modified) (4 diffs)
- trunk/libffado/src/libieee1394/ieee1394service.h (modified) (2 diffs)
- trunk/libffado/src/libieee1394/IsoHandlerManager.cpp (modified) (1 diff)
- trunk/libffado/src/libutil/SystemTimeSource.cpp (modified) (1 diff)
- trunk/libffado/src/libutil/SystemTimeSource.h (modified) (2 diffs)
- trunk/libffado/src/libutil/TimeSource.cpp (deleted)
- trunk/libffado/src/libutil/TimeSource.h (deleted)
- trunk/libffado/src/libutil/Watchdog.cpp (modified) (2 diffs)
- trunk/libffado/src/SConscript (modified) (1 diff)
- trunk/libffado/tests/test-bufferops.cpp (modified) (6 diffs)
- trunk/libffado/tests/test-watchdog.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/libieee1394/CycleTimerHelper.cpp
r1016 r1027 187 187 #if IEEE1394SERVICE_USE_CYCLETIMER_DLL 188 188 debugOutput( DEBUG_LEVEL_VERBOSE, "requesting DLL re-init...\n" ); 189 m_TimeSource.SleepUsecRelative(1000); // some time to settle189 Util::SystemTimeSource::SleepUsecRelative(1000); // some time to settle 190 190 m_high_bw_updates = UPDATES_WITH_HIGH_BANDWIDTH; 191 191 if(!initDLL()) { … … 343 343 // wait for the next update period 344 344 #if DEBUG_EXTREME_ENABLE 345 ffado_microsecs_t now = m_TimeSource.getCurrentTimeAsUsecs();345 ffado_microsecs_t now = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 346 346 int sleep_time = m_sleep_until - now; 347 347 debugOutputExtreme( DEBUG_LEVEL_VERY_VERBOSE, "(%p) Sleep until %lld/%f (now: %lld, diff=%d) ...\n", 348 348 this, m_sleep_until, m_next_time_usecs, now, sleep_time); 349 349 #endif 350 m_TimeSource.SleepUsecAbsolute(m_sleep_until);350 Util::SystemTimeSource::SleepUsecAbsolute(m_sleep_until); 351 351 debugOutputExtreme( DEBUG_LEVEL_VERY_VERBOSE, " (%p) back...\n", this); 352 352 } … … 389 389 390 390 // // simulate a random scheduling delay between (0-10ms) 391 // ffado_microsecs_t tmp = m_TimeSource.SleepUsecRandom(10000);391 // ffado_microsecs_t tmp = Util::SystemTimeSource::SleepUsecRandom(10000); 392 392 // debugOutput( DEBUG_LEVEL_VERBOSE, " (%p) random sleep of %llu usecs...\n", this, tmp); 393 393 trunk/libffado/src/libieee1394/CycleTimerHelper.h
r980 r1027 116 116 117 117 Ieee1394Service &m_Parent; 118 Util::SystemTimeSource m_TimeSource;119 118 // parameters 120 119 uint32_t m_ticks_per_update; trunk/libffado/src/libieee1394/ieee1394service.cpp
r1008 r1027 56 56 , m_pCTRHelper ( new CycleTimerHelper( *this, IEEE1394SERVICE_CYCLETIMER_DLL_UPDATE_INTERVAL_USEC ) ) 57 57 , m_have_new_ctr_read ( false ) 58 , m_pTimeSource ( new Util::SystemTimeSource() )59 58 , m_pWatchdog ( new Util::Watchdog() ) 60 59 { … … 83 82 prio + IEEE1394SERVICE_CYCLETIMER_HELPER_PRIO_INCREASE ) ) 84 83 , m_have_new_ctr_read ( false ) 85 , m_pTimeSource ( new Util::SystemTimeSource() )86 84 , m_pWatchdog ( new Util::Watchdog() ) 87 85 { … … 116 114 } 117 115 118 delete m_pTimeSource;119 116 delete m_pWatchdog; 120 117 if ( m_handle ) { … … 391 388 uint64_t 392 389 Ieee1394Service::getCurrentTimeAsUsecs() { 393 if(m_pTimeSource) { 394 return m_pTimeSource->getCurrentTimeAsUsecs(); 395 } else { 396 debugError("No timesource!\n"); 397 return 0; 398 } 390 return Util::SystemTimeSource::getCurrentTimeAsUsecs(); 399 391 } 400 392 trunk/libffado/src/libieee1394/ieee1394service.h
r940 r1027 44 44 45 45 namespace Util { 46 class TimeSource;47 46 class Watchdog; 48 47 } … … 331 330 bool m_have_new_ctr_read; 332 331 333 // the time source334 Util::TimeSource* m_pTimeSource;335 336 332 // the RT watchdog 337 333 Util::Watchdog* m_pWatchdog; trunk/libffado/src/libieee1394/IsoHandlerManager.cpp
r1005 r1027 145 145 146 146 #ifdef DEBUG 147 uint64_t now = m_manager.get1394Service().getCurrentTimeAsUsecs();147 uint64_t now = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 148 148 int diff = now - m_last_loop_entry; 149 149 if(diff < 100) { trunk/libffado/src/libutil/SystemTimeSource.cpp
r1026 r1027 34 34 35 35 namespace Util { 36 37 IMPL_DEBUG_MODULE( SystemTimeSource, SystemTimeSource, DEBUG_LEVEL_NORMAL );38 39 SystemTimeSource::SystemTimeSource()40 {41 }42 43 SystemTimeSource::~SystemTimeSource()44 {45 }46 36 47 37 void trunk/libffado/src/libutil/SystemTimeSource.h
r1015 r1027 26 26 27 27 #include "../debugmodule/debugmodule.h" 28 #include "TimeSource.h" 28 29 typedef uint64_t ffado_microsecs_t; 29 30 30 31 namespace Util { 31 32 32 33 class SystemTimeSource 33 : public Util::TimeSource34 34 { 35 private: // don't allow objects to be created 36 SystemTimeSource() {}; 37 virtual ~SystemTimeSource() {}; 35 38 36 39 public: 37 38 SystemTimeSource(); 39 virtual ~SystemTimeSource(); 40 41 // implement the TimeSource interface 42 ffado_microsecs_t getCurrentTime(); 43 ffado_microsecs_t getCurrentTimeAsUsecs(); 44 inline ffado_microsecs_t unWrapTime(ffado_microsecs_t t) {return t;}; 45 inline ffado_microsecs_t wrapTime(ffado_microsecs_t t) {return t;}; 40 static ffado_microsecs_t getCurrentTime(); 41 static ffado_microsecs_t getCurrentTimeAsUsecs(); 46 42 47 43 static void SleepUsecRelative(ffado_microsecs_t usecs); … … 49 45 50 46 /** 51 * @brief sleeps for a random amoun d tousecs47 * @brief sleeps for a random amount of usecs 52 48 * @param max_usec max usecs 53 49 * @return number of usecs slept 54 50 */ 55 51 static ffado_microsecs_t SleepUsecRandom(ffado_microsecs_t max_usec); 56 protected:57 DECLARE_DEBUG_MODULE;58 59 52 }; 60 53 trunk/libffado/src/libutil/Watchdog.cpp
r980 r1027 72 72 73 73 #ifdef DEBUG 74 uint64_t now = SystemTimeSource().getCurrentTimeAsUsecs();74 uint64_t now = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 75 75 int diff = now - m_last_loop_entry; 76 76 if(diff < 100) { … … 121 121 122 122 #ifdef DEBUG 123 uint64_t now = SystemTimeSource().getCurrentTimeAsUsecs();123 uint64_t now = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 124 124 int diff = now - m_last_loop_entry; 125 125 if(diff < 100) { trunk/libffado/src/SConscript
r992 r1027 81 81 libutil/StreamStatistics.cpp \ 82 82 libutil/SystemTimeSource.cpp \ 83 libutil/TimeSource.cpp \84 83 libutil/TimestampedBuffer.cpp \ 85 84 libutil/Watchdog.cpp \ trunk/libffado/tests/test-bufferops.cpp
r864 r1027 42 42 int i=0; 43 43 44 Util::SystemTimeSource time;45 44 ffado_microsecs_t start; 46 45 ffado_microsecs_t elapsed; … … 84 83 } 85 84 86 start = time.getCurrentTimeAsUsecs();85 start = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 87 86 byteSwapToBus(buffer_1, nb_quadlets); 88 elapsed = time.getCurrentTimeAsUsecs() - start;87 elapsed = Util::SystemTimeSource::getCurrentTimeAsUsecs() - start; 89 88 printMessage( " took %lluusec...\n", elapsed); 90 89 … … 116 115 int i=0; 117 116 118 Util::SystemTimeSource time;119 117 ffado_microsecs_t start; 120 118 ffado_microsecs_t elapsed; … … 153 151 } 154 152 155 start = time.getCurrentTimeAsUsecs();153 start = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 156 154 convertFromInt24AndLabelAsMBLA(buffer_1, nb_quadlets); 157 elapsed = time.getCurrentTimeAsUsecs() - start;155 elapsed = Util::SystemTimeSource::getCurrentTimeAsUsecs() - start; 158 156 printMessage( " took %lluusec...\n", elapsed); 159 157 } … … 186 184 int i=0; 187 185 188 Util::SystemTimeSource time;189 186 ffado_microsecs_t start; 190 187 ffado_microsecs_t elapsed; … … 236 233 } 237 234 238 start = time.getCurrentTimeAsUsecs();235 start = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 239 236 convertFromFloatAndLabelAsMBLA(buffer_1, nb_quadlets); 240 elapsed = time.getCurrentTimeAsUsecs() - start;237 elapsed = Util::SystemTimeSource::getCurrentTimeAsUsecs() - start; 241 238 printMessage( " took %lluusec...\n", elapsed); 242 239 } trunk/libffado/tests/test-watchdog.cpp
r939 r1027 43 43 using namespace Util; 44 44 45 SystemTimeSource timesource;46 45 DECLARE_GLOBAL_DEBUG_MODULE; 47 46 … … 57 56 bool Execute() { 58 57 debugOutput(DEBUG_LEVEL_VERBOSE, "execute\n"); 59 ffado_microsecs_t start = timesource.getCurrentTimeAsUsecs();58 ffado_microsecs_t start = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 60 59 ffado_microsecs_t stop_at = start + m_time; 61 60 int cnt; 62 61 int dummyvar = 0; 63 while( timesource.getCurrentTimeAsUsecs() < stop_at) {62 while(Util::SystemTimeSource::getCurrentTimeAsUsecs() < stop_at) { 64 63 cnt=1000; 65 64 while(cnt--) { dummyvar++; } … … 67 66 68 67 // ensure that dummyvar doesn't get optimized away 69 bool always_true = (dummyvar + timesource.getCurrentTimeAsUsecs() != 0);68 bool always_true = (dummyvar + Util::SystemTimeSource::getCurrentTimeAsUsecs() != 0); 70 69 71 70 bool stop = (m_nb_hangs == 0); … … 73 72 74 73 // we sleep for 100ms after a 'hang' 75 timesource.SleepUsecRelative(1000*100);74 Util::SystemTimeSource::SleepUsecRelative(1000*100); 76 75 77 76 // we want the thread to exit after m_nb_hangs 'hangs' … … 183 182 // start the watchdog 184 183 w->start(); 185 timesource.SleepUsecRelative(1000*1000*1);184 Util::SystemTimeSource::SleepUsecRelative(1000*1000*1); 186 185 187 186 // start the first thread, should be harmless since it's hang time is too low 188 187 thread1->Start(); 189 timesource.SleepUsecRelative(1000*1000*1);188 Util::SystemTimeSource::SleepUsecRelative(1000*1000*1); 190 189 191 190 // start the second thread, should be rescheduled since it hangs too long … … 193 192 194 193 // wait for a while 195 timesource.SleepUsecRelative(1000*1000*5);194 Util::SystemTimeSource::SleepUsecRelative(1000*1000*5); 196 195 197 196