@ciphore/radiocli 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/CHANGELOG.md +147 -2
  2. package/CONTRIBUTING.md +46 -6
  3. package/README.md +108 -209
  4. package/SECURITY.md +23 -1
  5. package/dist/agent/alarm-service.js +10 -7
  6. package/dist/agent/cli.js +16 -1
  7. package/dist/agent/command-schema.js +47 -0
  8. package/dist/agent/headless-host.js +234 -67
  9. package/dist/agent/launcher.js +7 -67
  10. package/dist/agent/mcp-install.js +15 -15
  11. package/dist/agent/mcp-server.js +10 -5
  12. package/dist/agent/service.js +74 -39
  13. package/dist/agent/session.js +227 -53
  14. package/dist/agent/tui-session.js +213 -0
  15. package/dist/alarms/active-session.js +9 -12
  16. package/dist/alarms/cli.js +19 -3
  17. package/dist/alarms/guard.js +79 -36
  18. package/dist/alarms/inhibitor.js +27 -22
  19. package/dist/alarms/occurrence-cache.js +25 -0
  20. package/dist/alarms/power-guard-store.js +2 -10
  21. package/dist/alarms/runner.js +140 -45
  22. package/dist/alarms/schedule.js +37 -2
  23. package/dist/alarms/scheduler.js +202 -52
  24. package/dist/alarms/setup-verification.js +1 -2
  25. package/dist/alarms/system-volume-linux.js +160 -0
  26. package/dist/alarms/system-volume-ownership.js +335 -0
  27. package/dist/alarms/system-volume.js +188 -26
  28. package/dist/alarms/terminal-launcher.js +76 -136
  29. package/dist/alarms/tui-presence.js +2 -4
  30. package/dist/cli/arguments.js +212 -0
  31. package/dist/cli/completion.js +44 -0
  32. package/dist/cli/doctor.js +156 -0
  33. package/dist/cli/interactive.js +79 -0
  34. package/dist/cli/listener.js +227 -0
  35. package/dist/cli/output.js +121 -0
  36. package/dist/cli/render-tui.js +34 -0
  37. package/dist/cli.js +198 -154
  38. package/dist/platform/capabilities.js +60 -0
  39. package/dist/platform/desktop-media.js +61 -0
  40. package/dist/platform/desktop.js +36 -0
  41. package/dist/platform/diagnostics.js +273 -0
  42. package/dist/{player/command.js → platform/executables.js} +43 -9
  43. package/dist/platform/ipc.js +14 -0
  44. package/dist/platform/json-worker.js +111 -0
  45. package/dist/platform/launch-command.js +138 -0
  46. package/dist/platform/loopback.js +44 -0
  47. package/dist/platform/mpris.js +356 -0
  48. package/dist/platform/network.js +380 -0
  49. package/dist/platform/omarchy.js +147 -0
  50. package/dist/platform/packages.js +222 -0
  51. package/dist/platform/paths.js +40 -0
  52. package/dist/platform/runtime.js +67 -0
  53. package/dist/platform/shell.js +24 -0
  54. package/dist/platform/storage.js +48 -0
  55. package/dist/platform/support.js +214 -0
  56. package/dist/platform/terminal.js +63 -0
  57. package/dist/platform/terminals.js +223 -0
  58. package/dist/player/airplay-discovery.js +145 -60
  59. package/dist/player/airplay-policy.js +15 -0
  60. package/dist/player/airplay-process.js +63 -0
  61. package/dist/player/airplay-readiness.js +42 -0
  62. package/dist/player/airplay-sender-health.js +49 -49
  63. package/dist/player/airplay-sender-package.js +5 -0
  64. package/dist/player/airplay-sender-patch.js +102 -4
  65. package/dist/player/airplay-setup.js +51 -0
  66. package/dist/player/airplay-worker.js +97 -41
  67. package/dist/player/backend-install.js +17 -95
  68. package/dist/player/command-diagnostics.js +2 -2
  69. package/dist/player/ffmpeg-input.js +37 -0
  70. package/dist/player/mpv-desktop-media.js +194 -0
  71. package/dist/player/mpv-ipc-client.js +52 -2
  72. package/dist/player/player-controller.js +569 -82
  73. package/dist/player/radio-engine.js +282 -0
  74. package/dist/playlists/playlist.js +18 -16
  75. package/dist/providers/cache.js +293 -99
  76. package/dist/providers/discovery-session.js +111 -0
  77. package/dist/providers/provider-manager.js +106 -28
  78. package/dist/providers/radio-browser.js +418 -89
  79. package/dist/providers/radio-garden.js +18 -23
  80. package/dist/setup-playback.js +152 -0
  81. package/dist/setup.js +163 -168
  82. package/dist/storage/file-lock.js +113 -0
  83. package/dist/storage/read-settings.js +33 -0
  84. package/dist/storage/replace-file.js +20 -0
  85. package/dist/storage/repository.js +247 -0
  86. package/dist/storage/station-identity.js +21 -0
  87. package/dist/storage/station-schema.js +27 -0
  88. package/dist/storage/store.js +333 -107
  89. package/dist/streams/import-stream.js +163 -0
  90. package/dist/ui/AdaptiveContent.js +49 -32
  91. package/dist/ui/App.js +822 -481
  92. package/dist/ui/AppContent.js +5 -5
  93. package/dist/ui/airplay-settings.js +12 -5
  94. package/dist/ui/app-state.js +8 -1
  95. package/dist/ui/ascii.js +11 -2
  96. package/dist/ui/bidi-ranges.js +45 -0
  97. package/dist/ui/components/AdaptiveMarquee.js +20 -10
  98. package/dist/ui/components/Logo.js +5 -2
  99. package/dist/ui/components/Menu.js +2 -2
  100. package/dist/ui/components/ScreenHeader.js +1 -1
  101. package/dist/ui/components/StationList.js +6 -4
  102. package/dist/ui/components/TopTabs.js +1 -1
  103. package/dist/ui/display-context.js +8 -11
  104. package/dist/ui/format.js +37 -4
  105. package/dist/ui/help-content.js +9 -6
  106. package/dist/ui/layout.js +5 -2
  107. package/dist/ui/page-footer.js +3 -3
  108. package/dist/ui/rtl-output.js +137 -0
  109. package/dist/ui/screen-items.js +12 -6
  110. package/dist/ui/screen-meta.js +1 -1
  111. package/dist/ui/screens/AirPlayCodeScreen.js +6 -2
  112. package/dist/ui/screens/AirPlaySettingsScreen.js +10 -6
  113. package/dist/ui/screens/AlarmsScreen.js +5 -2
  114. package/dist/ui/screens/ExploreScreen.js +2 -1
  115. package/dist/ui/screens/HelpScreen.js +8 -4
  116. package/dist/ui/screens/HomeScreen.js +5 -1
  117. package/dist/ui/screens/MapScreen.js +1 -1
  118. package/dist/ui/screens/NowPlayingScreen.js +4 -4
  119. package/dist/ui/screens/SearchScreen.js +3 -1
  120. package/dist/ui/screens/SettingsScreen.js +28 -21
  121. package/dist/ui/screens/StatsScreen.js +3 -1
  122. package/dist/ui/system-actions.js +80 -52
  123. package/dist/ui/terminal-renderer.js +16 -0
  124. package/dist/ui/text-direction.js +9 -0
  125. package/dist/ui/use-alarm-tui.js +57 -42
  126. package/dist/ui/use-app-input.js +84 -30
  127. package/dist/ui/use-command-executor.js +50 -19
  128. package/dist/ui/visualizers/gallop.js +1 -1
  129. package/dist/ui/visualizers/receiver-style-registry.js +2 -1
  130. package/dist/update-check.js +10 -18
  131. package/docs/THIRD_PARTY_NOTICES.md +6 -4
  132. package/package.json +34 -11
  133. package/scripts/build-airplay-native.mjs +22 -0
  134. package/vendor/node-airtunes2/LICENSE +208 -0
  135. package/vendor/node-airtunes2/RADIOCLI_PATCH.md +29 -0
  136. package/vendor/node-airtunes2/README.md +225 -0
  137. package/vendor/node-airtunes2/UPSTREAM.json +50 -0
  138. package/vendor/node-airtunes2/binding.gyp +41 -0
  139. package/vendor/node-airtunes2/lib/ap2_test.js +4 -0
  140. package/vendor/node-airtunes2/lib/atv.js +307 -0
  141. package/vendor/node-airtunes2/lib/atvAuthenticator.js +136 -0
  142. package/vendor/node-airtunes2/lib/audio_out.js +69 -0
  143. package/vendor/node-airtunes2/lib/circular_buffer.js +133 -0
  144. package/vendor/node-airtunes2/lib/config.js +26 -0
  145. package/vendor/node-airtunes2/lib/device_airtunes.js +532 -0
  146. package/vendor/node-airtunes2/lib/devices.js +266 -0
  147. package/vendor/node-airtunes2/lib/ed25519.js +26 -0
  148. package/vendor/node-airtunes2/lib/homekit/credentials.js +86 -0
  149. package/vendor/node-airtunes2/lib/homekit/encryption.js +69 -0
  150. package/vendor/node-airtunes2/lib/homekit/number.js +44 -0
  151. package/vendor/node-airtunes2/lib/homekit/tlv.js +95 -0
  152. package/vendor/node-airtunes2/lib/http.js +189 -0
  153. package/vendor/node-airtunes2/lib/index.d.ts +141 -0
  154. package/vendor/node-airtunes2/lib/index.js +127 -0
  155. package/vendor/node-airtunes2/lib/ntp.js +37 -0
  156. package/vendor/node-airtunes2/lib/num_util.js +21 -0
  157. package/vendor/node-airtunes2/lib/packet_pool.js +43 -0
  158. package/vendor/node-airtunes2/lib/rtsp.js +1807 -0
  159. package/vendor/node-airtunes2/lib/srp.js +158 -0
  160. package/vendor/node-airtunes2/lib/udp_servers.js +214 -0
  161. package/vendor/node-airtunes2/lib/util.js +12 -0
  162. package/vendor/node-airtunes2/package.json +31 -0
  163. package/vendor/node-airtunes2/src/CADebugMacros.h +257 -0
  164. package/vendor/node-airtunes2/src/CAHostTimeBase.cpp +105 -0
  165. package/vendor/node-airtunes2/src/CAHostTimeBase.h +224 -0
  166. package/vendor/node-airtunes2/src/aes_utils.c +864 -0
  167. package/vendor/node-airtunes2/src/aes_utils.h +24 -0
  168. package/vendor/node-airtunes2/src/base64.c +136 -0
  169. package/vendor/node-airtunes2/src/base64.h +42 -0
  170. package/vendor/node-airtunes2/src/bindings.cc +29 -0
  171. package/vendor/node-airtunes2/src/codec.cc +170 -0
  172. package/vendor/node-airtunes2/src/coreaudio.cc +332 -0
@@ -0,0 +1,105 @@
1
+ /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved.
2
+
3
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
4
+ ("Apple") in consideration of your agreement to the following terms, and your
5
+ use, installation, modification or redistribution of this Apple software
6
+ constitutes acceptance of these terms. If you do not agree with these terms,
7
+ please do not use, install, modify or redistribute this Apple software.
8
+
9
+ In consideration of your agreement to abide by the following terms, and subject
10
+ to these terms, Apple grants you a personal, non-exclusive license, under Apple�s
11
+ copyrights in this original Apple software (the "Apple Software"), to use,
12
+ reproduce, modify and redistribute the Apple Software, with or without
13
+ modifications, in source and/or binary forms; provided that if you redistribute
14
+ the Apple Software in its entirety and without modifications, you must retain
15
+ this notice and the following text and disclaimers in all such redistributions of
16
+ the Apple Software. Neither the name, trademarks, service marks or logos of
17
+ Apple Computer, Inc. may be used to endorse or promote products derived from the
18
+ Apple Software without specific prior written permission from Apple. Except as
19
+ expressly stated in this notice, no other rights or licenses, express or implied,
20
+ are granted by Apple herein, including but not limited to any patent rights that
21
+ may be infringed by your derivative works or by other works in which the Apple
22
+ Software may be incorporated.
23
+
24
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
25
+ WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
26
+ WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27
+ PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
28
+ COMBINATION WITH YOUR PRODUCTS.
29
+
30
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
31
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33
+ ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
34
+ OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
35
+ (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
36
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
+ */
38
+ /*=============================================================================
39
+ CAHostTimeBase.cp
40
+
41
+ =============================================================================*/
42
+
43
+ //=============================================================================
44
+ // Includes
45
+ //=============================================================================
46
+
47
+ #include "CAHostTimeBase.h"
48
+
49
+ Float64 CAHostTimeBase::sFrequency = 0;
50
+ UInt32 CAHostTimeBase::sMinDelta = 0;
51
+ UInt32 CAHostTimeBase::sToNanosNumerator = 0;
52
+ UInt32 CAHostTimeBase::sToNanosDenominator = 0;
53
+ UInt32 CAHostTimeBase::sFromNanosNumerator = 0;
54
+ UInt32 CAHostTimeBase::sFromNanosDenominator = 0;
55
+ bool CAHostTimeBase::sUseMicroseconds = false;
56
+ bool CAHostTimeBase::sIsInited = false;
57
+ #if Track_Host_TimeBase
58
+ UInt64 CAHostTimeBase::sLastTime = 0;
59
+ #endif
60
+
61
+ //=============================================================================
62
+ // CAHostTimeBase
63
+ //
64
+ // This class provides platform independent access to the host's time base.
65
+ //=============================================================================
66
+
67
+ void CAHostTimeBase::Initialize()
68
+ {
69
+ // get the info about Absolute time
70
+ #if TARGET_OS_MAC
71
+ struct mach_timebase_info theTimeBaseInfo;
72
+ mach_timebase_info(&theTimeBaseInfo);
73
+ sMinDelta = 1;
74
+ sToNanosNumerator = theTimeBaseInfo.numer;
75
+ sToNanosDenominator = theTimeBaseInfo.denom;
76
+ sFromNanosNumerator = sToNanosDenominator;
77
+ sFromNanosDenominator = sToNanosNumerator;
78
+
79
+ // the frequency of that clock is: (sToNanosDenominator / sToNanosNumerator) * 10^9
80
+ sFrequency = static_cast<Float64>(sToNanosDenominator) / static_cast<Float64>(sToNanosNumerator);
81
+ sFrequency *= 1000000000.0;
82
+ #elif TARGET_OS_WIN32
83
+ LARGE_INTEGER theFrequency;
84
+ QueryPerformanceFrequency(&theFrequency);
85
+ sMinDelta = 1;
86
+ sToNanosNumerator = 1000000000ULL;
87
+ sToNanosDenominator = *((UInt64*)&theFrequency);
88
+ sFromNanosNumerator = sToNanosDenominator;
89
+ sFromNanosDenominator = sToNanosNumerator;
90
+ sFrequency = static_cast<Float64>(*((UInt64*)&theFrequency));
91
+ #endif
92
+
93
+
94
+ #if Log_Host_Time_Base_Parameters
95
+ DebugMessage( "Host Time Base Parameters");
96
+ DebugMessageN1(" Minimum Delta: %lu", sMinDelta);
97
+ DebugMessageN1(" Frequency: %f", sFrequency);
98
+ DebugMessageN1(" To Nanos Numerator: %lu", sToNanosNumerator);
99
+ DebugMessageN1(" To Nanos Denominator: %lu", sToNanosDenominator);
100
+ DebugMessageN1(" From Nanos Numerator: %lu", sFromNanosNumerator);
101
+ DebugMessageN1(" From Nanos Denominator: %lu", sFromNanosDenominator);
102
+ #endif
103
+
104
+ sIsInited = true;
105
+ }
@@ -0,0 +1,224 @@
1
+ /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved.
2
+
3
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
4
+ ("Apple") in consideration of your agreement to the following terms, and your
5
+ use, installation, modification or redistribution of this Apple software
6
+ constitutes acceptance of these terms. If you do not agree with these terms,
7
+ please do not use, install, modify or redistribute this Apple software.
8
+
9
+ In consideration of your agreement to abide by the following terms, and subject
10
+ to these terms, Apple grants you a personal, non-exclusive license, under Apple�s
11
+ copyrights in this original Apple software (the "Apple Software"), to use,
12
+ reproduce, modify and redistribute the Apple Software, with or without
13
+ modifications, in source and/or binary forms; provided that if you redistribute
14
+ the Apple Software in its entirety and without modifications, you must retain
15
+ this notice and the following text and disclaimers in all such redistributions of
16
+ the Apple Software. Neither the name, trademarks, service marks or logos of
17
+ Apple Computer, Inc. may be used to endorse or promote products derived from the
18
+ Apple Software without specific prior written permission from Apple. Except as
19
+ expressly stated in this notice, no other rights or licenses, express or implied,
20
+ are granted by Apple herein, including but not limited to any patent rights that
21
+ may be infringed by your derivative works or by other works in which the Apple
22
+ Software may be incorporated.
23
+
24
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
25
+ WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
26
+ WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27
+ PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
28
+ COMBINATION WITH YOUR PRODUCTS.
29
+
30
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
31
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33
+ ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
34
+ OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
35
+ (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
36
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
+ */
38
+ /*=============================================================================
39
+ CAHostTimeBase.h
40
+
41
+ =============================================================================*/
42
+ #if !defined(__CAHostTimeBase_h__)
43
+ #define __CAHostTimeBase_h__
44
+
45
+ //=============================================================================
46
+ // Includes
47
+ //=============================================================================
48
+
49
+ #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
50
+ #include <CoreAudio/CoreAudioTypes.h>
51
+ #else
52
+ #include <CoreAudioTypes.h>
53
+ #endif
54
+
55
+ #if TARGET_OS_MAC
56
+ #include <mach/mach_time.h>
57
+ #elif TARGET_OS_WIN32
58
+ #include <windows.h>
59
+ #else
60
+ #error Unsupported operating system
61
+ #endif
62
+
63
+ #include "CADebugMacros.h"
64
+
65
+ //=============================================================================
66
+ // CAHostTimeBase
67
+ //
68
+ // This class provides platform independent access to the host's time base.
69
+ //=============================================================================
70
+
71
+ #if CoreAudio_Debug
72
+ // #define Log_Host_Time_Base_Parameters 1
73
+ // #define Track_Host_TimeBase 1
74
+ #endif
75
+
76
+ class CAHostTimeBase
77
+ {
78
+
79
+ public:
80
+ static UInt64 ConvertToNanos(UInt64 inHostTime);
81
+ static UInt64 ConvertFromNanos(UInt64 inNanos);
82
+
83
+ static UInt64 GetTheCurrentTime();
84
+ #if TARGET_OS_MAC
85
+ static UInt64 GetCurrentTime() { return GetTheCurrentTime(); }
86
+ #endif
87
+ static UInt64 GetCurrentTimeInNanos();
88
+
89
+ static Float64 GetFrequency() { if(!sIsInited) { Initialize(); } return sFrequency; }
90
+ static UInt32 GetMinimumDelta() { if(!sIsInited) { Initialize(); } return sMinDelta; }
91
+
92
+ static UInt64 AbsoluteHostDeltaToNanos(UInt64 inStartTime, UInt64 inEndTime);
93
+ static SInt64 HostDeltaToNanos(UInt64 inStartTime, UInt64 inEndTime);
94
+
95
+ private:
96
+ static void Initialize();
97
+
98
+ static bool sIsInited;
99
+
100
+ static Float64 sFrequency;
101
+ static UInt32 sMinDelta;
102
+ static UInt32 sToNanosNumerator;
103
+ static UInt32 sToNanosDenominator;
104
+ static UInt32 sFromNanosNumerator;
105
+ static UInt32 sFromNanosDenominator;
106
+ static bool sUseMicroseconds;
107
+ #if Track_Host_TimeBase
108
+ static UInt64 sLastTime;
109
+ #endif
110
+ };
111
+
112
+ inline UInt64 CAHostTimeBase::GetTheCurrentTime()
113
+ {
114
+ UInt64 theTime = 0;
115
+
116
+ #if TARGET_OS_MAC
117
+ theTime = mach_absolute_time();
118
+ #elif TARGET_OS_WIN32
119
+ LARGE_INTEGER theValue;
120
+ QueryPerformanceCounter(&theValue);
121
+ theTime = *((UInt64*)&theValue);
122
+ #endif
123
+
124
+ #if Track_Host_TimeBase
125
+ if(sLastTime != 0)
126
+ {
127
+ if(theTime <= sLastTime)
128
+ {
129
+ DebugMessageN2("CAHostTimeBase::GetTheCurrentTime: the current time is earlier than the last time, now: %qd, then: %qd", theTime, sLastTime);
130
+ }
131
+ sLastTime = theTime;
132
+ }
133
+ else
134
+ {
135
+ sLastTime = theTime;
136
+ }
137
+ #endif
138
+
139
+ return theTime;
140
+ }
141
+
142
+ inline UInt64 CAHostTimeBase::ConvertToNanos(UInt64 inHostTime)
143
+ {
144
+ if(!sIsInited)
145
+ {
146
+ Initialize();
147
+ }
148
+
149
+ Float64 theNumerator = static_cast<Float64>(sToNanosNumerator);
150
+ Float64 theDenominator = static_cast<Float64>(sToNanosDenominator);
151
+ Float64 theHostTime = static_cast<Float64>(inHostTime);
152
+
153
+ Float64 thePartialAnswer = theHostTime / theDenominator;
154
+ Float64 theFloatAnswer = thePartialAnswer * theNumerator;
155
+ UInt64 theAnswer = static_cast<UInt64>(theFloatAnswer);
156
+
157
+ //Assert(!((theNumerator > theDenominator) && (theAnswer < inHostTime)), "CAHostTimeBase::ConvertToNanos: The conversion wrapped");
158
+ //Assert(!((theDenominator > theNumerator) && (theAnswer > inHostTime)), "CAHostTimeBase::ConvertToNanos: The conversion wrapped");
159
+
160
+ return theAnswer;
161
+ }
162
+
163
+ inline UInt64 CAHostTimeBase::ConvertFromNanos(UInt64 inNanos)
164
+ {
165
+ if(!sIsInited)
166
+ {
167
+ Initialize();
168
+ }
169
+
170
+ Float64 theNumerator = static_cast<Float64>(sToNanosNumerator);
171
+ Float64 theDenominator = static_cast<Float64>(sToNanosDenominator);
172
+ Float64 theNanos = static_cast<Float64>(inNanos);
173
+
174
+ Float64 thePartialAnswer = theNanos / theNumerator;
175
+ Float64 theFloatAnswer = thePartialAnswer * theDenominator;
176
+ UInt64 theAnswer = static_cast<UInt64>(theFloatAnswer);
177
+
178
+ //Assert(!((theDenominator > theNumerator) && (theAnswer < inNanos)), "CAHostTimeBase::ConvertToNanos: The conversion wrapped");
179
+ //Assert(!((theNumerator > theDenominator) && (theAnswer > inNanos)), "CAHostTimeBase::ConvertToNanos: The conversion wrapped");
180
+
181
+ return theAnswer;
182
+ }
183
+
184
+
185
+ inline UInt64 CAHostTimeBase::GetCurrentTimeInNanos()
186
+ {
187
+ return ConvertToNanos(GetTheCurrentTime());
188
+ }
189
+
190
+ inline UInt64 CAHostTimeBase::AbsoluteHostDeltaToNanos(UInt64 inStartTime, UInt64 inEndTime)
191
+ {
192
+ UInt64 theAnswer;
193
+
194
+ if(inStartTime <= inEndTime)
195
+ {
196
+ theAnswer = inEndTime - inStartTime;
197
+ }
198
+ else
199
+ {
200
+ theAnswer = inStartTime - inEndTime;
201
+ }
202
+
203
+ return ConvertToNanos(theAnswer);
204
+ }
205
+
206
+ inline SInt64 CAHostTimeBase::HostDeltaToNanos(UInt64 inStartTime, UInt64 inEndTime)
207
+ {
208
+ SInt64 theAnswer;
209
+ SInt64 theSign = 1;
210
+
211
+ if(inStartTime <= inEndTime)
212
+ {
213
+ theAnswer = inEndTime - inStartTime;
214
+ }
215
+ else
216
+ {
217
+ theAnswer = inStartTime - inEndTime;
218
+ theSign = -1;
219
+ }
220
+
221
+ return theSign * ConvertToNanos(theAnswer);
222
+ }
223
+
224
+ #endif