HostTime.pas 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. {==================================================================================================
  2. File: CoreAudio/HostTime.h
  3. Contains: Routines for accessing the host's time base
  4. Version: Technology: Mac OS X
  5. Release: Mac OS X
  6. Copyright: (c) 1985-2005 by Apple Computer, Inc., all rights reserved.
  7. ==================================================================================================}
  8. { Pascal Translation: Gale R Paeper, <[email protected]>, 2006 }
  9. {
  10. Modified for use with Free Pascal
  11. Version 200
  12. Please report any bugs to <[email protected]>
  13. }
  14. {$mode macpas}
  15. {$packenum 1}
  16. {$macro on}
  17. {$inline on}
  18. {$CALLING MWPASCAL}
  19. unit HostTime;
  20. interface
  21. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  22. {$setc GAP_INTERFACES_VERSION := $0200}
  23. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  24. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  25. {$endc}
  26. {$ifc defined CPUPOWERPC and defined CPUI386}
  27. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  28. {$endc}
  29. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  30. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  31. {$endc}
  32. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  33. {$setc __ppc__ := 1}
  34. {$elsec}
  35. {$setc __ppc__ := 0}
  36. {$endc}
  37. {$ifc not defined __i386__ and defined CPUI386}
  38. {$setc __i386__ := 1}
  39. {$elsec}
  40. {$setc __i386__ := 0}
  41. {$endc}
  42. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  43. {$error Conflicting definitions for __ppc__ and __i386__}
  44. {$endc}
  45. {$ifc defined __ppc__ and __ppc__}
  46. {$setc TARGET_CPU_PPC := TRUE}
  47. {$setc TARGET_CPU_X86 := FALSE}
  48. {$elifc defined __i386__ and __i386__}
  49. {$setc TARGET_CPU_PPC := FALSE}
  50. {$setc TARGET_CPU_X86 := TRUE}
  51. {$elsec}
  52. {$error Neither __ppc__ nor __i386__ is defined.}
  53. {$endc}
  54. {$setc TARGET_CPU_PPC_64 := FALSE}
  55. {$ifc defined FPC_BIG_ENDIAN}
  56. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  57. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  58. {$elifc defined FPC_LITTLE_ENDIAN}
  59. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  60. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  61. {$elsec}
  62. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  63. {$endc}
  64. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  65. {$setc CALL_NOT_IN_CARBON := FALSE}
  66. {$setc OLDROUTINENAMES := FALSE}
  67. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  68. {$setc OPAQUE_UPP_TYPES := TRUE}
  69. {$setc OTCARBONAPPLICATION := TRUE}
  70. {$setc OTKERNEL := FALSE}
  71. {$setc PM_USE_SESSION_APIS := TRUE}
  72. {$setc TARGET_API_MAC_CARBON := TRUE}
  73. {$setc TARGET_API_MAC_OS8 := FALSE}
  74. {$setc TARGET_API_MAC_OSX := TRUE}
  75. {$setc TARGET_CARBON := TRUE}
  76. {$setc TARGET_CPU_68K := FALSE}
  77. {$setc TARGET_CPU_MIPS := FALSE}
  78. {$setc TARGET_CPU_SPARC := FALSE}
  79. {$setc TARGET_OS_MAC := TRUE}
  80. {$setc TARGET_OS_UNIX := FALSE}
  81. {$setc TARGET_OS_WIN32 := FALSE}
  82. {$setc TARGET_RT_MAC_68881 := FALSE}
  83. {$setc TARGET_RT_MAC_CFM := FALSE}
  84. {$setc TARGET_RT_MAC_MACHO := TRUE}
  85. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  86. {$setc TYPE_BOOL := FALSE}
  87. {$setc TYPE_EXTENDED := FALSE}
  88. {$setc TYPE_LONGLONG := TRUE}
  89. uses MacTypes,CoreAudioTypes;
  90. {$ALIGN POWER}
  91. //==================================================================================================
  92. //#pragma mark Theory of Operation
  93. {!
  94. @header HostTime
  95. This collection of functions provides access to the host's time base. It also provides
  96. discriptive information about the time base and translations to and from nanoseconds.
  97. }
  98. {!
  99. @functiongroup HostTime
  100. }
  101. {!
  102. @function AudioGetCurrentHostTime
  103. @abstract Gets the current host time.
  104. @result A UInt64 containing the current host time.
  105. }
  106. function AudioGetCurrentHostTime: UInt64; external name '_AudioGetCurrentHostTime';
  107. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  108. {!
  109. @function AudioGetHostClockFrequency
  110. @abstract Gets the number of ticks per second in the host time base.
  111. @result A Float64 containing the number of ticks per second in the host time base.
  112. }
  113. function AudioGetHostClockFrequency: Float64; external name '_AudioGetHostClockFrequency';
  114. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  115. {!
  116. @function AudioGetHostClockMinimumTimeDelta
  117. @abstract Gets the smallest number of ticks that two succeeding values will ever differ.
  118. by.
  119. @result A UInt32 containing the smallest number of ticks that two succeeding values will
  120. ever differ.
  121. }
  122. function AudioGetHostClockMinimumTimeDelta: UInt32; external name '_AudioGetHostClockMinimumTimeDelta';
  123. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  124. {!
  125. @function AudioConvertHostTimeToNanos
  126. @abstract Convert the given host time into a time in nanoseconds.
  127. @param inHostTime
  128. A UInt64 containing the host time to convert.
  129. @result A UInt64 containining the converted host time.
  130. }
  131. function AudioConvertHostTimeToNanos( inHostTime: UInt64 ): UInt64; external name '_AudioConvertHostTimeToNanos';
  132. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  133. {!
  134. @function AudioConvertNanosToHostTime
  135. @abstract Convert the given nanosecond time into a host time.
  136. @param inNanos
  137. A UInt64 containing the nanosecond time to convert.
  138. @result A UInt64 containining the converted nanosecond time.
  139. }
  140. function AudioConvertNanosToHostTime( inNanos: UInt64 ): UInt64; external name '_AudioConvertNanosToHostTime';
  141. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  142. end.