native_audio 0.3.0 → 0.4.0

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 (138) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -0
  3. data/README.md +87 -0
  4. data/ext/audio/audio.c +321 -47
  5. data/ext/audio/extconf.rb +12 -110
  6. data/ext/audio/miniaudio.h +95844 -0
  7. data/lib/dummy_audio.rb +49 -0
  8. data/lib/native_audio.rb +22 -7
  9. metadata +7 -132
  10. data/assets/include/SDL2/SDL.h +0 -233
  11. data/assets/include/SDL2/SDL_assert.h +0 -326
  12. data/assets/include/SDL2/SDL_atomic.h +0 -415
  13. data/assets/include/SDL2/SDL_audio.h +0 -1500
  14. data/assets/include/SDL2/SDL_bits.h +0 -126
  15. data/assets/include/SDL2/SDL_blendmode.h +0 -198
  16. data/assets/include/SDL2/SDL_clipboard.h +0 -141
  17. data/assets/include/SDL2/SDL_config.h +0 -61
  18. data/assets/include/SDL2/SDL_config_android.h +0 -194
  19. data/assets/include/SDL2/SDL_config_emscripten.h +0 -218
  20. data/assets/include/SDL2/SDL_config_iphoneos.h +0 -217
  21. data/assets/include/SDL2/SDL_config_macosx.h +0 -277
  22. data/assets/include/SDL2/SDL_config_minimal.h +0 -95
  23. data/assets/include/SDL2/SDL_config_ngage.h +0 -89
  24. data/assets/include/SDL2/SDL_config_os2.h +0 -207
  25. data/assets/include/SDL2/SDL_config_pandora.h +0 -141
  26. data/assets/include/SDL2/SDL_config_windows.h +0 -331
  27. data/assets/include/SDL2/SDL_config_wingdk.h +0 -253
  28. data/assets/include/SDL2/SDL_config_winrt.h +0 -220
  29. data/assets/include/SDL2/SDL_config_xbox.h +0 -235
  30. data/assets/include/SDL2/SDL_copying.h +0 -20
  31. data/assets/include/SDL2/SDL_cpuinfo.h +0 -594
  32. data/assets/include/SDL2/SDL_egl.h +0 -2352
  33. data/assets/include/SDL2/SDL_endian.h +0 -348
  34. data/assets/include/SDL2/SDL_error.h +0 -163
  35. data/assets/include/SDL2/SDL_events.h +0 -1166
  36. data/assets/include/SDL2/SDL_filesystem.h +0 -149
  37. data/assets/include/SDL2/SDL_gamecontroller.h +0 -1074
  38. data/assets/include/SDL2/SDL_gesture.h +0 -117
  39. data/assets/include/SDL2/SDL_guid.h +0 -100
  40. data/assets/include/SDL2/SDL_haptic.h +0 -1341
  41. data/assets/include/SDL2/SDL_hidapi.h +0 -451
  42. data/assets/include/SDL2/SDL_hints.h +0 -2569
  43. data/assets/include/SDL2/SDL_image.h +0 -2173
  44. data/assets/include/SDL2/SDL_joystick.h +0 -1066
  45. data/assets/include/SDL2/SDL_keyboard.h +0 -353
  46. data/assets/include/SDL2/SDL_keycode.h +0 -358
  47. data/assets/include/SDL2/SDL_loadso.h +0 -115
  48. data/assets/include/SDL2/SDL_locale.h +0 -103
  49. data/assets/include/SDL2/SDL_log.h +0 -404
  50. data/assets/include/SDL2/SDL_main.h +0 -275
  51. data/assets/include/SDL2/SDL_messagebox.h +0 -193
  52. data/assets/include/SDL2/SDL_metal.h +0 -113
  53. data/assets/include/SDL2/SDL_misc.h +0 -79
  54. data/assets/include/SDL2/SDL_mixer.h +0 -2784
  55. data/assets/include/SDL2/SDL_mouse.h +0 -465
  56. data/assets/include/SDL2/SDL_mutex.h +0 -471
  57. data/assets/include/SDL2/SDL_name.h +0 -33
  58. data/assets/include/SDL2/SDL_opengl.h +0 -2132
  59. data/assets/include/SDL2/SDL_opengl_glext.h +0 -13209
  60. data/assets/include/SDL2/SDL_opengles.h +0 -39
  61. data/assets/include/SDL2/SDL_opengles2.h +0 -52
  62. data/assets/include/SDL2/SDL_opengles2_gl2.h +0 -656
  63. data/assets/include/SDL2/SDL_opengles2_gl2ext.h +0 -4033
  64. data/assets/include/SDL2/SDL_opengles2_gl2platform.h +0 -27
  65. data/assets/include/SDL2/SDL_opengles2_khrplatform.h +0 -311
  66. data/assets/include/SDL2/SDL_pixels.h +0 -644
  67. data/assets/include/SDL2/SDL_platform.h +0 -261
  68. data/assets/include/SDL2/SDL_power.h +0 -88
  69. data/assets/include/SDL2/SDL_quit.h +0 -58
  70. data/assets/include/SDL2/SDL_rect.h +0 -376
  71. data/assets/include/SDL2/SDL_render.h +0 -1919
  72. data/assets/include/SDL2/SDL_revision.h +0 -6
  73. data/assets/include/SDL2/SDL_rwops.h +0 -841
  74. data/assets/include/SDL2/SDL_scancode.h +0 -438
  75. data/assets/include/SDL2/SDL_sensor.h +0 -322
  76. data/assets/include/SDL2/SDL_shape.h +0 -155
  77. data/assets/include/SDL2/SDL_stdinc.h +0 -830
  78. data/assets/include/SDL2/SDL_surface.h +0 -997
  79. data/assets/include/SDL2/SDL_system.h +0 -623
  80. data/assets/include/SDL2/SDL_syswm.h +0 -386
  81. data/assets/include/SDL2/SDL_test.h +0 -69
  82. data/assets/include/SDL2/SDL_test_assert.h +0 -105
  83. data/assets/include/SDL2/SDL_test_common.h +0 -236
  84. data/assets/include/SDL2/SDL_test_compare.h +0 -69
  85. data/assets/include/SDL2/SDL_test_crc32.h +0 -124
  86. data/assets/include/SDL2/SDL_test_font.h +0 -168
  87. data/assets/include/SDL2/SDL_test_fuzzer.h +0 -386
  88. data/assets/include/SDL2/SDL_test_harness.h +0 -134
  89. data/assets/include/SDL2/SDL_test_images.h +0 -78
  90. data/assets/include/SDL2/SDL_test_log.h +0 -67
  91. data/assets/include/SDL2/SDL_test_md5.h +0 -129
  92. data/assets/include/SDL2/SDL_test_memory.h +0 -63
  93. data/assets/include/SDL2/SDL_test_random.h +0 -115
  94. data/assets/include/SDL2/SDL_thread.h +0 -464
  95. data/assets/include/SDL2/SDL_timer.h +0 -222
  96. data/assets/include/SDL2/SDL_touch.h +0 -150
  97. data/assets/include/SDL2/SDL_ttf.h +0 -2316
  98. data/assets/include/SDL2/SDL_types.h +0 -29
  99. data/assets/include/SDL2/SDL_version.h +0 -204
  100. data/assets/include/SDL2/SDL_video.h +0 -2150
  101. data/assets/include/SDL2/SDL_vulkan.h +0 -215
  102. data/assets/include/SDL2/begin_code.h +0 -187
  103. data/assets/include/SDL2/close_code.h +0 -40
  104. data/assets/macos/universal/lib/libFLAC.a +0 -0
  105. data/assets/macos/universal/lib/libSDL2.a +0 -0
  106. data/assets/macos/universal/lib/libSDL2_mixer.a +0 -0
  107. data/assets/macos/universal/lib/libmodplug.a +0 -0
  108. data/assets/macos/universal/lib/libmpg123.a +0 -0
  109. data/assets/macos/universal/lib/libogg.a +0 -0
  110. data/assets/macos/universal/lib/libvorbis.a +0 -0
  111. data/assets/macos/universal/lib/libvorbisfile.a +0 -0
  112. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libFLAC.a +0 -0
  113. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2.a +0 -0
  114. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_mixer.a +0 -0
  115. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmodplug.a +0 -0
  116. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmpg123.a +0 -0
  117. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libogg.a +0 -0
  118. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopus.a +0 -0
  119. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopusfile.a +0 -0
  120. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libsndfile.a +0 -0
  121. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libstdc++.a +0 -0
  122. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbis.a +0 -0
  123. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbisfile.a +0 -0
  124. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libz.a +0 -0
  125. data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
  126. data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
  127. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
  128. data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
  129. data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
  130. data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
  131. data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
  132. data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
  133. data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
  134. data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
  135. data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
  136. data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
  137. data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
  138. data/ext/audio/extconf.h +0 -3
@@ -1,464 +0,0 @@
1
- /*
2
- Simple DirectMedia Layer
3
- Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
4
-
5
- This software is provided 'as-is', without any express or implied
6
- warranty. In no event will the authors be held liable for any damages
7
- arising from the use of this software.
8
-
9
- Permission is granted to anyone to use this software for any purpose,
10
- including commercial applications, and to alter it and redistribute it
11
- freely, subject to the following restrictions:
12
-
13
- 1. The origin of this software must not be misrepresented; you must not
14
- claim that you wrote the original software. If you use this software
15
- in a product, an acknowledgment in the product documentation would be
16
- appreciated but is not required.
17
- 2. Altered source versions must be plainly marked as such, and must not be
18
- misrepresented as being the original software.
19
- 3. This notice may not be removed or altered from any source distribution.
20
- */
21
-
22
- #ifndef SDL_thread_h_
23
- #define SDL_thread_h_
24
-
25
- /**
26
- * \file SDL_thread.h
27
- *
28
- * Header for the SDL thread management routines.
29
- */
30
-
31
- #include "SDL_stdinc.h"
32
- #include "SDL_error.h"
33
-
34
- /* Thread synchronization primitives */
35
- #include "SDL_atomic.h"
36
- #include "SDL_mutex.h"
37
-
38
- #if defined(__WIN32__) || defined(__GDK__)
39
- #include <process.h> /* _beginthreadex() and _endthreadex() */
40
- #endif
41
- #if defined(__OS2__) /* for _beginthread() and _endthread() */
42
- #ifndef __EMX__
43
- #include <process.h>
44
- #else
45
- #include <stdlib.h>
46
- #endif
47
- #endif
48
-
49
- #include "begin_code.h"
50
- /* Set up for C function definitions, even when using C++ */
51
- #ifdef __cplusplus
52
- extern "C" {
53
- #endif
54
-
55
- /* The SDL thread structure, defined in SDL_thread.c */
56
- struct SDL_Thread;
57
- typedef struct SDL_Thread SDL_Thread;
58
-
59
- /* The SDL thread ID */
60
- typedef unsigned long SDL_threadID;
61
-
62
- /* Thread local storage ID, 0 is the invalid ID */
63
- typedef unsigned int SDL_TLSID;
64
-
65
- /**
66
- * The SDL thread priority.
67
- *
68
- * SDL will make system changes as necessary in order to apply the thread priority.
69
- * Code which attempts to control thread state related to priority should be aware
70
- * that calling SDL_SetThreadPriority may alter such state.
71
- * SDL_HINT_THREAD_PRIORITY_POLICY can be used to control aspects of this behavior.
72
- *
73
- * \note On many systems you require special privileges to set high or time critical priority.
74
- */
75
- typedef enum {
76
- SDL_THREAD_PRIORITY_LOW,
77
- SDL_THREAD_PRIORITY_NORMAL,
78
- SDL_THREAD_PRIORITY_HIGH,
79
- SDL_THREAD_PRIORITY_TIME_CRITICAL
80
- } SDL_ThreadPriority;
81
-
82
- /**
83
- * The function passed to SDL_CreateThread().
84
- *
85
- * \param data what was passed as `data` to SDL_CreateThread()
86
- * \returns a value that can be reported through SDL_WaitThread().
87
- */
88
- typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
89
-
90
-
91
- #if defined(__WIN32__) || defined(__GDK__)
92
- /**
93
- * \file SDL_thread.h
94
- *
95
- * We compile SDL into a DLL. This means, that it's the DLL which
96
- * creates a new thread for the calling process with the SDL_CreateThread()
97
- * API. There is a problem with this, that only the RTL of the SDL2.DLL will
98
- * be initialized for those threads, and not the RTL of the calling
99
- * application!
100
- *
101
- * To solve this, we make a little hack here.
102
- *
103
- * We'll always use the caller's _beginthread() and _endthread() APIs to
104
- * start a new thread. This way, if it's the SDL2.DLL which uses this API,
105
- * then the RTL of SDL2.DLL will be used to create the new thread, and if it's
106
- * the application, then the RTL of the application will be used.
107
- *
108
- * So, in short:
109
- * Always use the _beginthread() and _endthread() of the calling runtime
110
- * library!
111
- */
112
- #define SDL_PASSED_BEGINTHREAD_ENDTHREAD
113
-
114
- typedef uintptr_t (__cdecl * pfnSDL_CurrentBeginThread)
115
- (void *, unsigned, unsigned (__stdcall *func)(void *),
116
- void * /*arg*/, unsigned, unsigned * /* threadID */);
117
- typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
118
-
119
- #ifndef SDL_beginthread
120
- #define SDL_beginthread _beginthreadex
121
- #endif
122
- #ifndef SDL_endthread
123
- #define SDL_endthread _endthreadex
124
- #endif
125
-
126
- extern DECLSPEC SDL_Thread *SDLCALL
127
- SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
128
- pfnSDL_CurrentBeginThread pfnBeginThread,
129
- pfnSDL_CurrentEndThread pfnEndThread);
130
-
131
- extern DECLSPEC SDL_Thread *SDLCALL
132
- SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn,
133
- const char *name, const size_t stacksize, void *data,
134
- pfnSDL_CurrentBeginThread pfnBeginThread,
135
- pfnSDL_CurrentEndThread pfnEndThread);
136
-
137
-
138
- #if defined(SDL_CreateThread) && SDL_DYNAMIC_API
139
- #undef SDL_CreateThread
140
- #define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
141
- #undef SDL_CreateThreadWithStackSize
142
- #define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
143
- #else
144
- #define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
145
- #define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)SDL_endthread)
146
- #endif
147
-
148
- #elif defined(__OS2__)
149
- /*
150
- * just like the windows case above: We compile SDL2
151
- * into a dll with Watcom's runtime statically linked.
152
- */
153
- #define SDL_PASSED_BEGINTHREAD_ENDTHREAD
154
-
155
- typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void * /*arg*/);
156
- typedef void (*pfnSDL_CurrentEndThread)(void);
157
-
158
- #ifndef SDL_beginthread
159
- #define SDL_beginthread _beginthread
160
- #endif
161
- #ifndef SDL_endthread
162
- #define SDL_endthread _endthread
163
- #endif
164
-
165
- extern DECLSPEC SDL_Thread *SDLCALL
166
- SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
167
- pfnSDL_CurrentBeginThread pfnBeginThread,
168
- pfnSDL_CurrentEndThread pfnEndThread);
169
- extern DECLSPEC SDL_Thread *SDLCALL
170
- SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data,
171
- pfnSDL_CurrentBeginThread pfnBeginThread,
172
- pfnSDL_CurrentEndThread pfnEndThread);
173
-
174
- #if defined(SDL_CreateThread) && SDL_DYNAMIC_API
175
- #undef SDL_CreateThread
176
- #define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
177
- #undef SDL_CreateThreadWithStackSize
178
- #define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
179
- #else
180
- #define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
181
- #define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
182
- #endif
183
-
184
- #else
185
-
186
- /**
187
- * Create a new thread with a default stack size.
188
- *
189
- * This is equivalent to calling:
190
- *
191
- * ```c
192
- * SDL_CreateThreadWithStackSize(fn, name, 0, data);
193
- * ```
194
- *
195
- * \param fn the SDL_ThreadFunction function to call in the new thread
196
- * \param name the name of the thread
197
- * \param data a pointer that is passed to `fn`
198
- * \returns an opaque pointer to the new thread object on success, NULL if the
199
- * new thread could not be created; call SDL_GetError() for more
200
- * information.
201
- *
202
- * \since This function is available since SDL 2.0.0.
203
- *
204
- * \sa SDL_CreateThreadWithStackSize
205
- * \sa SDL_WaitThread
206
- */
207
- extern DECLSPEC SDL_Thread *SDLCALL
208
- SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
209
-
210
- /**
211
- * Create a new thread with a specific stack size.
212
- *
213
- * SDL makes an attempt to report `name` to the system, so that debuggers can
214
- * display it. Not all platforms support this.
215
- *
216
- * Thread naming is a little complicated: Most systems have very small limits
217
- * for the string length (Haiku has 32 bytes, Linux currently has 16, Visual
218
- * C++ 6.0 has _nine_!), and possibly other arbitrary rules. You'll have to
219
- * see what happens with your system's debugger. The name should be UTF-8 (but
220
- * using the naming limits of C identifiers is a better bet). There are no
221
- * requirements for thread naming conventions, so long as the string is
222
- * null-terminated UTF-8, but these guidelines are helpful in choosing a name:
223
- *
224
- * https://stackoverflow.com/questions/149932/naming-conventions-for-threads
225
- *
226
- * If a system imposes requirements, SDL will try to munge the string for it
227
- * (truncate, etc), but the original string contents will be available from
228
- * SDL_GetThreadName().
229
- *
230
- * The size (in bytes) of the new stack can be specified. Zero means "use the
231
- * system default" which might be wildly different between platforms. x86
232
- * Linux generally defaults to eight megabytes, an embedded device might be a
233
- * few kilobytes instead. You generally need to specify a stack that is a
234
- * multiple of the system's page size (in many cases, this is 4 kilobytes, but
235
- * check your system documentation).
236
- *
237
- * In SDL 2.1, stack size will be folded into the original SDL_CreateThread
238
- * function, but for backwards compatibility, this is currently a separate
239
- * function.
240
- *
241
- * \param fn the SDL_ThreadFunction function to call in the new thread
242
- * \param name the name of the thread
243
- * \param stacksize the size, in bytes, to allocate for the new thread stack.
244
- * \param data a pointer that is passed to `fn`
245
- * \returns an opaque pointer to the new thread object on success, NULL if the
246
- * new thread could not be created; call SDL_GetError() for more
247
- * information.
248
- *
249
- * \since This function is available since SDL 2.0.9.
250
- *
251
- * \sa SDL_WaitThread
252
- */
253
- extern DECLSPEC SDL_Thread *SDLCALL
254
- SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data);
255
-
256
- #endif
257
-
258
- /**
259
- * Get the thread name as it was specified in SDL_CreateThread().
260
- *
261
- * This is internal memory, not to be freed by the caller, and remains valid
262
- * until the specified thread is cleaned up by SDL_WaitThread().
263
- *
264
- * \param thread the thread to query
265
- * \returns a pointer to a UTF-8 string that names the specified thread, or
266
- * NULL if it doesn't have a name.
267
- *
268
- * \since This function is available since SDL 2.0.0.
269
- *
270
- * \sa SDL_CreateThread
271
- */
272
- extern DECLSPEC const char *SDLCALL SDL_GetThreadName(SDL_Thread *thread);
273
-
274
- /**
275
- * Get the thread identifier for the current thread.
276
- *
277
- * This thread identifier is as reported by the underlying operating system.
278
- * If SDL is running on a platform that does not support threads the return
279
- * value will always be zero.
280
- *
281
- * This function also returns a valid thread ID when called from the main
282
- * thread.
283
- *
284
- * \returns the ID of the current thread.
285
- *
286
- * \since This function is available since SDL 2.0.0.
287
- *
288
- * \sa SDL_GetThreadID
289
- */
290
- extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void);
291
-
292
- /**
293
- * Get the thread identifier for the specified thread.
294
- *
295
- * This thread identifier is as reported by the underlying operating system.
296
- * If SDL is running on a platform that does not support threads the return
297
- * value will always be zero.
298
- *
299
- * \param thread the thread to query
300
- * \returns the ID of the specified thread, or the ID of the current thread if
301
- * `thread` is NULL.
302
- *
303
- * \since This function is available since SDL 2.0.0.
304
- *
305
- * \sa SDL_ThreadID
306
- */
307
- extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread);
308
-
309
- /**
310
- * Set the priority for the current thread.
311
- *
312
- * Note that some platforms will not let you alter the priority (or at least,
313
- * promote the thread to a higher priority) at all, and some require you to be
314
- * an administrator account. Be prepared for this to fail.
315
- *
316
- * \param priority the SDL_ThreadPriority to set
317
- * \returns 0 on success or a negative error code on failure; call
318
- * SDL_GetError() for more information.
319
- *
320
- * \since This function is available since SDL 2.0.0.
321
- */
322
- extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority);
323
-
324
- /**
325
- * Wait for a thread to finish.
326
- *
327
- * Threads that haven't been detached will remain (as a "zombie") until this
328
- * function cleans them up. Not doing so is a resource leak.
329
- *
330
- * Once a thread has been cleaned up through this function, the SDL_Thread
331
- * that references it becomes invalid and should not be referenced again. As
332
- * such, only one thread may call SDL_WaitThread() on another.
333
- *
334
- * The return code for the thread function is placed in the area pointed to by
335
- * `status`, if `status` is not NULL.
336
- *
337
- * You may not wait on a thread that has been used in a call to
338
- * SDL_DetachThread(). Use either that function or this one, but not both, or
339
- * behavior is undefined.
340
- *
341
- * It is safe to pass a NULL thread to this function; it is a no-op.
342
- *
343
- * Note that the thread pointer is freed by this function and is not valid
344
- * afterward.
345
- *
346
- * \param thread the SDL_Thread pointer that was returned from the
347
- * SDL_CreateThread() call that started this thread
348
- * \param status pointer to an integer that will receive the value returned
349
- * from the thread function by its 'return', or NULL to not
350
- * receive such value back.
351
- *
352
- * \since This function is available since SDL 2.0.0.
353
- *
354
- * \sa SDL_CreateThread
355
- * \sa SDL_DetachThread
356
- */
357
- extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status);
358
-
359
- /**
360
- * Let a thread clean up on exit without intervention.
361
- *
362
- * A thread may be "detached" to signify that it should not remain until
363
- * another thread has called SDL_WaitThread() on it. Detaching a thread is
364
- * useful for long-running threads that nothing needs to synchronize with or
365
- * further manage. When a detached thread is done, it simply goes away.
366
- *
367
- * There is no way to recover the return code of a detached thread. If you
368
- * need this, don't detach the thread and instead use SDL_WaitThread().
369
- *
370
- * Once a thread is detached, you should usually assume the SDL_Thread isn't
371
- * safe to reference again, as it will become invalid immediately upon the
372
- * detached thread's exit, instead of remaining until someone has called
373
- * SDL_WaitThread() to finally clean it up. As such, don't detach the same
374
- * thread more than once.
375
- *
376
- * If a thread has already exited when passed to SDL_DetachThread(), it will
377
- * stop waiting for a call to SDL_WaitThread() and clean up immediately. It is
378
- * not safe to detach a thread that might be used with SDL_WaitThread().
379
- *
380
- * You may not call SDL_WaitThread() on a thread that has been detached. Use
381
- * either that function or this one, but not both, or behavior is undefined.
382
- *
383
- * It is safe to pass NULL to this function; it is a no-op.
384
- *
385
- * \param thread the SDL_Thread pointer that was returned from the
386
- * SDL_CreateThread() call that started this thread
387
- *
388
- * \since This function is available since SDL 2.0.2.
389
- *
390
- * \sa SDL_CreateThread
391
- * \sa SDL_WaitThread
392
- */
393
- extern DECLSPEC void SDLCALL SDL_DetachThread(SDL_Thread * thread);
394
-
395
- /**
396
- * Create a piece of thread-local storage.
397
- *
398
- * This creates an identifier that is globally visible to all threads but
399
- * refers to data that is thread-specific.
400
- *
401
- * \returns the newly created thread local storage identifier or 0 on error.
402
- *
403
- * \since This function is available since SDL 2.0.0.
404
- *
405
- * \sa SDL_TLSGet
406
- * \sa SDL_TLSSet
407
- */
408
- extern DECLSPEC SDL_TLSID SDLCALL SDL_TLSCreate(void);
409
-
410
- /**
411
- * Get the current thread's value associated with a thread local storage ID.
412
- *
413
- * \param id the thread local storage ID
414
- * \returns the value associated with the ID for the current thread or NULL if
415
- * no value has been set; call SDL_GetError() for more information.
416
- *
417
- * \since This function is available since SDL 2.0.0.
418
- *
419
- * \sa SDL_TLSCreate
420
- * \sa SDL_TLSSet
421
- */
422
- extern DECLSPEC void * SDLCALL SDL_TLSGet(SDL_TLSID id);
423
-
424
- /**
425
- * Set the current thread's value associated with a thread local storage ID.
426
- *
427
- * The function prototype for `destructor` is:
428
- *
429
- * ```c
430
- * void destructor(void *value)
431
- * ```
432
- *
433
- * where its parameter `value` is what was passed as `value` to SDL_TLSSet().
434
- *
435
- * \param id the thread local storage ID
436
- * \param value the value to associate with the ID for the current thread
437
- * \param destructor a function called when the thread exits, to free the
438
- * value
439
- * \returns 0 on success or a negative error code on failure; call
440
- * SDL_GetError() for more information.
441
- *
442
- * \since This function is available since SDL 2.0.0.
443
- *
444
- * \sa SDL_TLSCreate
445
- * \sa SDL_TLSGet
446
- */
447
- extern DECLSPEC int SDLCALL SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void*));
448
-
449
- /**
450
- * Cleanup all TLS data for this thread.
451
- *
452
- * \since This function is available since SDL 2.0.16.
453
- */
454
- extern DECLSPEC void SDLCALL SDL_TLSCleanup(void);
455
-
456
- /* Ends C function definitions when using C++ */
457
- #ifdef __cplusplus
458
- }
459
- #endif
460
- #include "close_code.h"
461
-
462
- #endif /* SDL_thread_h_ */
463
-
464
- /* vi: set ts=4 sw=4 expandtab: */
@@ -1,222 +0,0 @@
1
- /*
2
- Simple DirectMedia Layer
3
- Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
4
-
5
- This software is provided 'as-is', without any express or implied
6
- warranty. In no event will the authors be held liable for any damages
7
- arising from the use of this software.
8
-
9
- Permission is granted to anyone to use this software for any purpose,
10
- including commercial applications, and to alter it and redistribute it
11
- freely, subject to the following restrictions:
12
-
13
- 1. The origin of this software must not be misrepresented; you must not
14
- claim that you wrote the original software. If you use this software
15
- in a product, an acknowledgment in the product documentation would be
16
- appreciated but is not required.
17
- 2. Altered source versions must be plainly marked as such, and must not be
18
- misrepresented as being the original software.
19
- 3. This notice may not be removed or altered from any source distribution.
20
- */
21
-
22
- #ifndef SDL_timer_h_
23
- #define SDL_timer_h_
24
-
25
- /**
26
- * \file SDL_timer.h
27
- *
28
- * Header for the SDL time management routines.
29
- */
30
-
31
- #include "SDL_stdinc.h"
32
- #include "SDL_error.h"
33
-
34
- #include "begin_code.h"
35
- /* Set up for C function definitions, even when using C++ */
36
- #ifdef __cplusplus
37
- extern "C" {
38
- #endif
39
-
40
- /**
41
- * Get the number of milliseconds since SDL library initialization.
42
- *
43
- * This value wraps if the program runs for more than ~49 days.
44
- *
45
- * This function is not recommended as of SDL 2.0.18; use SDL_GetTicks64()
46
- * instead, where the value doesn't wrap every ~49 days. There are places in
47
- * SDL where we provide a 32-bit timestamp that can not change without
48
- * breaking binary compatibility, though, so this function isn't officially
49
- * deprecated.
50
- *
51
- * \returns an unsigned 32-bit value representing the number of milliseconds
52
- * since the SDL library initialized.
53
- *
54
- * \since This function is available since SDL 2.0.0.
55
- *
56
- * \sa SDL_TICKS_PASSED
57
- */
58
- extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void);
59
-
60
- /**
61
- * Get the number of milliseconds since SDL library initialization.
62
- *
63
- * Note that you should not use the SDL_TICKS_PASSED macro with values
64
- * returned by this function, as that macro does clever math to compensate for
65
- * the 32-bit overflow every ~49 days that SDL_GetTicks() suffers from. 64-bit
66
- * values from this function can be safely compared directly.
67
- *
68
- * For example, if you want to wait 100 ms, you could do this:
69
- *
70
- * ```c
71
- * const Uint64 timeout = SDL_GetTicks64() + 100;
72
- * while (SDL_GetTicks64() < timeout) {
73
- * // ... do work until timeout has elapsed
74
- * }
75
- * ```
76
- *
77
- * \returns an unsigned 64-bit value representing the number of milliseconds
78
- * since the SDL library initialized.
79
- *
80
- * \since This function is available since SDL 2.0.18.
81
- */
82
- extern DECLSPEC Uint64 SDLCALL SDL_GetTicks64(void);
83
-
84
- /**
85
- * Compare 32-bit SDL ticks values, and return true if `A` has passed `B`.
86
- *
87
- * This should be used with results from SDL_GetTicks(), as this macro
88
- * attempts to deal with the 32-bit counter wrapping back to zero every ~49
89
- * days, but should _not_ be used with SDL_GetTicks64(), which does not have
90
- * that problem.
91
- *
92
- * For example, with SDL_GetTicks(), if you want to wait 100 ms, you could
93
- * do this:
94
- *
95
- * ```c
96
- * const Uint32 timeout = SDL_GetTicks() + 100;
97
- * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) {
98
- * // ... do work until timeout has elapsed
99
- * }
100
- * ```
101
- *
102
- * Note that this does not handle tick differences greater
103
- * than 2^31 so take care when using the above kind of code
104
- * with large timeout delays (tens of days).
105
- */
106
- #define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0)
107
-
108
- /**
109
- * Get the current value of the high resolution counter.
110
- *
111
- * This function is typically used for profiling.
112
- *
113
- * The counter values are only meaningful relative to each other. Differences
114
- * between values can be converted to times by using
115
- * SDL_GetPerformanceFrequency().
116
- *
117
- * \returns the current counter value.
118
- *
119
- * \since This function is available since SDL 2.0.0.
120
- *
121
- * \sa SDL_GetPerformanceFrequency
122
- */
123
- extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void);
124
-
125
- /**
126
- * Get the count per second of the high resolution counter.
127
- *
128
- * \returns a platform-specific count per second.
129
- *
130
- * \since This function is available since SDL 2.0.0.
131
- *
132
- * \sa SDL_GetPerformanceCounter
133
- */
134
- extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void);
135
-
136
- /**
137
- * Wait a specified number of milliseconds before returning.
138
- *
139
- * This function waits a specified number of milliseconds before returning. It
140
- * waits at least the specified time, but possibly longer due to OS
141
- * scheduling.
142
- *
143
- * \param ms the number of milliseconds to delay
144
- *
145
- * \since This function is available since SDL 2.0.0.
146
- */
147
- extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
148
-
149
- /**
150
- * Function prototype for the timer callback function.
151
- *
152
- * The callback function is passed the current timer interval and returns
153
- * the next timer interval. If the returned value is the same as the one
154
- * passed in, the periodic alarm continues, otherwise a new alarm is
155
- * scheduled. If the callback returns 0, the periodic alarm is cancelled.
156
- */
157
- typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param);
158
-
159
- /**
160
- * Definition of the timer ID type.
161
- */
162
- typedef int SDL_TimerID;
163
-
164
- /**
165
- * Call a callback function at a future time.
166
- *
167
- * If you use this function, you must pass `SDL_INIT_TIMER` to SDL_Init().
168
- *
169
- * The callback function is passed the current timer interval and the user
170
- * supplied parameter from the SDL_AddTimer() call and should return the next
171
- * timer interval. If the value returned from the callback is 0, the timer is
172
- * canceled.
173
- *
174
- * The callback is run on a separate thread.
175
- *
176
- * Timers take into account the amount of time it took to execute the
177
- * callback. For example, if the callback took 250 ms to execute and returned
178
- * 1000 (ms), the timer would only wait another 750 ms before its next
179
- * iteration.
180
- *
181
- * Timing may be inexact due to OS scheduling. Be sure to note the current
182
- * time with SDL_GetTicks() or SDL_GetPerformanceCounter() in case your
183
- * callback needs to adjust for variances.
184
- *
185
- * \param interval the timer delay, in milliseconds, passed to `callback`
186
- * \param callback the SDL_TimerCallback function to call when the specified
187
- * `interval` elapses
188
- * \param param a pointer that is passed to `callback`
189
- * \returns a timer ID or 0 if an error occurs; call SDL_GetError() for more
190
- * information.
191
- *
192
- * \since This function is available since SDL 2.0.0.
193
- *
194
- * \sa SDL_RemoveTimer
195
- */
196
- extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval,
197
- SDL_TimerCallback callback,
198
- void *param);
199
-
200
- /**
201
- * Remove a timer created with SDL_AddTimer().
202
- *
203
- * \param id the ID of the timer to remove
204
- * \returns SDL_TRUE if the timer is removed or SDL_FALSE if the timer wasn't
205
- * found.
206
- *
207
- * \since This function is available since SDL 2.0.0.
208
- *
209
- * \sa SDL_AddTimer
210
- */
211
- extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id);
212
-
213
-
214
- /* Ends C function definitions when using C++ */
215
- #ifdef __cplusplus
216
- }
217
- #endif
218
- #include "close_code.h"
219
-
220
- #endif /* SDL_timer_h_ */
221
-
222
- /* vi: set ts=4 sw=4 expandtab: */