jack1 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.2KB

  1. /* -*- mode: c; c-file-style: "bsd"; -*- */
  2. /*
  3. Copyright (C) 2001-2003 Paul Davis
  4. Copyright (C) 2005 Jussi Laako
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as published by
  7. the Free Software Foundation; either version 2.1 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16. */
  17. #include <config.h>
  18. #include <errno.h>
  19. #include <fcntl.h>
  20. #include <stdio.h>
  21. #ifdef HAVE_STDINT_H
  22. #include <stdint.h>
  23. #endif
  24. #include <string.h>
  25. #include <sys/types.h>
  26. #include <sys/mman.h>
  27. #include <jack/internal.h>
  28. #include <jack/jack.h>
  29. #include <jack/engine.h>
  30. #include <sysdeps/time.h>
  31. #include <sysdeps/cycles.h>
  32. #include "local.h"
  33. const char*
  34. jack_clock_source_name (jack_timer_type_t src)
  35. {
  36. switch (src) {
  37. case JACK_TIMER_CYCLE_COUNTER:
  38. return "cycle counter";
  39. case JACK_TIMER_HPET:
  40. return "hpet";
  41. case JACK_TIMER_SYSTEM_CLOCK:
  42. #ifdef HAVE_CLOCK_GETTIME
  43. return "system clock via clock_gettime";
  44. #else
  45. return "system clock via gettimeofday";
  46. #endif
  47. }
  48. /* what is wrong with gcc ? */
  49. return "unknown";
  50. }
  51. #ifndef HAVE_CLOCK_GETTIME
  52. jack_time_t
  53. jack_get_microseconds_from_system (void) {
  54. jack_time_t jackTime;
  55. struct timeval tv;
  56. gettimeofday (&tv, NULL);
  57. jackTime = (jack_time_t) tv.tv_sec * 1000000 + (jack_time_t) tv.tv_usec;
  58. return jackTime;
  59. }
  60. #else
  61. jack_time_t
  62. jack_get_microseconds_from_system (void) {
  63. jack_time_t jackTime;
  64. struct timespec time;
  65. clock_gettime(CLOCK_MONOTONIC, &time);
  66. jackTime = (jack_time_t) time.tv_sec * 1e6 +
  67. (jack_time_t) time.tv_nsec / 1e3;
  68. return jackTime;
  69. }
  70. #endif /* HAVE_CLOCK_GETTIME */
  71. /* everything below here should be system-dependent */
  72. #include <sysdeps/time.c>