- Timestamp:
- 06/23/12 07:03:54 (9 years ago)
- Files:
-
- trunk/libffado/src/bebob/bebob_dl_mgr.cpp (modified) (1 diff)
- trunk/libffado/src/debugmodule/debugmodule.cpp (modified) (2 diffs)
- trunk/libffado/src/libieee1394/ieee1394service.cpp (modified) (3 diffs)
- trunk/libffado/src/libieee1394/IsoHandlerManager.cpp (modified) (1 diff)
- trunk/libffado/src/libstreaming/StreamProcessorManager.cpp (modified) (1 diff)
- trunk/libffado/src/libutil/PosixMessageQueue.cpp (modified) (4 diffs)
- trunk/libffado/src/libutil/SystemTimeSource.cpp (modified) (5 diffs)
- trunk/libffado/src/libutil/SystemTimeSource.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/bebob/bebob_dl_mgr.cpp
r2019 r2171 575 575 struct timespec timeout; 576 576 int retcode; 577 clock_gettime(CLOCK_REALTIME,&timeout);577 Util::SystemTimeSource::clockGettime(&timeout); 578 578 do { 579 579 printf("."); trunk/libffado/src/debugmodule/debugmodule.cpp
r1999 r2171 27 27 #include <stdarg.h> 28 28 #include "libutil/ByteSwap.h" 29 #include "libutil/Time.h" 29 30 30 31 #include <iostream> … … 180 181 // add a timing timestamp 181 182 struct timespec ts; 182 clock_gettime(CLOCK_MONOTONIC,&ts);183 Util::SystemTimeSource::clockGettime(&ts); 183 184 uint64_t ts_usec=(uint64_t)(ts.tv_sec * 1000000LL + ts.tv_nsec / 1000LL); 184 185 trunk/libffado/src/libieee1394/ieee1394service.cpp
r2167 r2171 2 2 * Copyright (C) 2005-2008 by Daniel Wagner 3 3 * Copyright (C) 2005-2008 by Pieter Palmers 4 * Copyright (C) 2012 by Jonathan Woithe 4 5 * 5 6 * This file is part of FFADO … … 351 352 if (raw1394_read_cycle_timer_and_clock != NULL) { 352 353 err = raw1394_read_cycle_timer_and_clock(m_util_handle, &cycle_timer, &local_time, CLOCK_MONOTONIC_RAW); 353 if (!err )354 if (!err && Util::SystemTimeSource::setSource(CLOCK_MONOTONIC_RAW)==true) 354 355 m_have_read_ctr_and_clock = true; 355 356 } 356 357 357 if (m_have_read_ctr_and_clock) 358 debugOutput(DEBUG_LEVEL_VERBOSE, "This system supports the raw1394_read_cycle_timer_and_clock call, using it.\n"); 359 else { 358 if (m_have_read_ctr_and_clock) { 359 debugOutput(DEBUG_LEVEL_VERBOSE, "This system supports the raw1394_read_cycle_timer_and_clock call and the\n"); 360 debugOutput(DEBUG_LEVEL_VERBOSE, "CLOCK_MONOTONIC_RAW clock source; using them.\n"); 361 } else { 360 362 debugOutput(DEBUG_LEVEL_VERBOSE, "This system supports the raw1394_read_cycle_timer call, using it.\n"); 361 debugOutput(DEBUG_LEVEL_NORMAL, "The raw1394_read_cycle_timer_and_clock call is not available.\n"); 363 debugOutput(DEBUG_LEVEL_NORMAL, "The raw1394_read_cycle_timer_and_clock call and/or the CLOCK_MONOTONIC_RAW\n"); 364 debugOutput(DEBUG_LEVEL_NORMAL, "clock source is not available.\n"); 362 365 debugOutput(DEBUG_LEVEL_NORMAL, "Fallback to raw1394_read_cycle_timer.\n"); 363 366 debugOutput(DEBUG_LEVEL_NORMAL, "FFADO may be susceptible to NTP-induced clock discontinuities.\n"); 364 debugOutput(DEBUG_LEVEL_NORMAL, "Upgrade libraw1394 to version 2.1.0 or later if this is an issue.\n"); 367 debugOutput(DEBUG_LEVEL_NORMAL, "If this is an issue, upgrade libraw1394 to version 2.1.0 or later and/or\n"); 368 debugOutput(DEBUG_LEVEL_NORMAL, "kernel 2.6.28 or later.\n"); 365 369 } 366 370 } … … 538 542 if (m_have_read_ctr_and_clock) { 539 543 int err; 540 err = raw1394_read_cycle_timer_and_clock(m_util_handle, cycle_timer, local_time, CLOCK_MONOTONIC_RAW); 544 err = raw1394_read_cycle_timer_and_clock(m_util_handle, cycle_timer, local_time, 545 Util::SystemTimeSource::getSource()); 541 546 if(err) { 542 547 debugWarning("raw1394_read_cycle_timer_and_clock: %s\n", strerror(err)); trunk/libffado/src/libieee1394/IsoHandlerManager.cpp
r2076 r2171 398 398 int result; 399 399 400 if ( clock_gettime(CLOCK_REALTIME,&ts) == -1) {400 if (Util::SystemTimeSource::clockGettime(&ts) == -1) { 401 401 debugError("clock_gettime failed\n"); 402 402 return eAR_Error; trunk/libffado/src/libstreaming/StreamProcessorManager.cpp
r2107 r2171 164 164 if (m_activity_wait_timeout_nsec >= 0) { 165 165 166 if ( clock_gettime(CLOCK_REALTIME,&ts) == -1) {166 if (Util::SystemTimeSource::clockGettime(&ts) == -1) { 167 167 debugError("clock_gettime failed\n"); 168 168 return eAR_Error; trunk/libffado/src/libutil/PosixMessageQueue.cpp
r1255 r2171 26 26 #include "Functors.h" 27 27 #include "PosixMutex.h" 28 #include "Time.h" 28 29 29 30 #include <errno.h> … … 197 198 while(countMessages()) { 198 199 struct timespec timeout; 199 clock_gettime(CLOCK_REALTIME,&timeout);200 Util::SystemTimeSource::clockGettime(&timeout); 200 201 timeout.tv_sec += m_timeout.tv_sec; 201 202 timeout.tv_nsec += m_timeout.tv_nsec; … … 247 248 248 249 struct timespec timeout; 249 clock_gettime(CLOCK_REALTIME,&timeout);250 Util::SystemTimeSource::clockGettime(&timeout); 250 251 timeout.tv_sec += m_timeout.tv_sec; 251 252 timeout.tv_nsec += m_timeout.tv_nsec; … … 293 294 294 295 struct timespec timeout; 295 clock_gettime(CLOCK_REALTIME,&timeout);296 Util::SystemTimeSource::clockGettime(&timeout); 296 297 timeout.tv_sec += m_timeout.tv_sec; 297 298 timeout.tv_nsec += m_timeout.tv_nsec; trunk/libffado/src/libutil/SystemTimeSource.cpp
r1763 r2171 1 1 /* 2 2 * Copyright (C) 2005-2008 by Pieter Palmers 3 * Copytight (C) 2012 by Jonathan Woithe 3 4 * 4 5 * This file is part of FFADO … … 37 38 namespace Util { 38 39 40 static clockid_t clock_id = CLOCK_REALTIME; 41 42 bool 43 SystemTimeSource::setSource(clockid_t id) 44 { 45 struct timespec tp; 46 // Determine at runtime whether the kernel has support for the 47 // requested clock source. 48 if (clock_gettime(id, &tp) == 0) { 49 clock_id = id; 50 return true; 51 } 52 return false; 53 } 54 55 clockid_t 56 SystemTimeSource::getSource(void) 57 { 58 return clock_id; 59 } 60 61 int 62 SystemTimeSource::clockGettime(struct timespec *tp) 63 { 64 return clock_gettime(clock_id, tp); 65 } 66 39 67 void 40 68 SystemTimeSource::SleepUsecRelative(ffado_microsecs_t usecs) … … 44 72 ts.tv_sec = usecs / (1000000LL); 45 73 ts.tv_nsec = (usecs % (1000000LL)) * 1000LL; 46 clock_nanosleep( CLOCK_REALTIME, 0, &ts, NULL);74 clock_nanosleep(clock_id, 0, &ts, NULL); 47 75 } 48 76 … … 57 85 "clock_nanosleep until %"PRId64" sec, %"PRId64" nanosec\n", 58 86 (int64_t)ts.tv_sec, (int64_t)ts.tv_nsec); 59 int err = clock_nanosleep( CLOCK_REALTIME, TIMER_ABSTIME, &ts, NULL);87 int err = clock_nanosleep(clock_id, TIMER_ABSTIME, &ts, NULL); 60 88 if(err) { 61 89 // maybe signal occurred, but we're going to ignore that … … 95 123 { 96 124 struct timespec ts; 97 clock_gettime( CLOCK_REALTIME, &ts);125 clock_gettime(clock_id, &ts); 98 126 return (ffado_microsecs_t)(ts.tv_sec * 1000000LL + ts.tv_nsec / 1000LL); 99 127 } trunk/libffado/src/libutil/SystemTimeSource.h
r1568 r2171 1 1 /* 2 2 * Copyright (C) 2005-2008 by Pieter Palmers 3 * Copyright (C) 2012 by Jonathan Woithe 3 4 * 4 5 * This file is part of FFADO … … 31 32 typedef uint64_t ffado_microsecs_t; 32 33 34 // Ensure this is defined even for kernels/glib versions which don't include 35 // it. This allows compile-time testing for the feature. 36 #ifndef CLOCK_MONOTONIC_RAW 37 #define CLOCK_MONOTONIC_RAW 4 38 #endif 39 33 40 namespace Util { 34 41 … … 40 47 41 48 public: 49 static bool setSource(clockid_t id); 50 static clockid_t getSource(void); 51 static int clockGettime(struct timespec *tp); 52 42 53 static ffado_microsecs_t getCurrentTime(); 43 54 static ffado_microsecs_t getCurrentTimeAsUsecs();