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.1KB

  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 "internal.h"
  28. #include "engine.h"
  29. #include <jack/jack.h>
  30. #include <sysdeps/time.h>
  31. #include "local.h"
  32. const char*
  33. jack_clock_source_name (jack_timer_type_t src)
  34. {
  35. switch (src) {
  36. case JACK_TIMER_HPET:
  37. return "hpet";
  38. case JACK_TIMER_SYSTEM_CLOCK:
  39. #if HAVE_CLOCK_GETTIME
  40. return "system clock via clock_gettime";
  41. #else
  42. return "system clock via gettimeofday";
  43. #endif
  44. }
  45. /* what is wrong with gcc ? */
  46. return "unknown";
  47. }
  48. #if HAVE_CLOCK_GETTIME
  49. jack_time_t
  50. jack_get_microseconds_from_system (void)
  51. {
  52. jack_time_t jackTime;
  53. struct timespec time;
  54. clock_gettime (CLOCK_MONOTONIC, &time);
  55. jackTime = (jack_time_t)time.tv_sec * 1e6 +
  56. (jack_time_t)time.tv_nsec / 1e3;
  57. return jackTime;
  58. }
  59. #else
  60. jack_time_t
  61. jack_get_microseconds_from_system (void)
  62. {
  63. jack_time_t jackTime;
  64. struct timeval tv;
  65. gettimeofday (&tv, NULL);
  66. jackTime = (jack_time_t)tv.tv_sec * 1000000 + (jack_time_t)tv.tv_usec;
  67. return jackTime;
  68. }
  69. #endif /* HAVE_CLOCK_GETTIME */
  70. /* everything below here should be system-dependent */
  71. #include <sysdeps/time.c>