native_audio 0.1.0 → 0.2.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 (147) hide show
  1. checksums.yaml +4 -4
  2. data/assets/include/GL/glew.h +26427 -26427
  3. data/assets/include/GLES2/gl2.h +656 -656
  4. data/assets/include/GLES2/gl2ext.h +3949 -3949
  5. data/assets/include/GLES2/gl2ext_angle.h +701 -701
  6. data/assets/include/GLES2/gl2platform.h +27 -27
  7. data/assets/include/GLES3/gl3.h +1192 -1192
  8. data/assets/include/GLES3/gl31.h +1507 -1507
  9. data/assets/include/GLES3/gl32.h +1808 -1808
  10. data/assets/include/GLES3/gl3platform.h +27 -27
  11. data/assets/include/KHR/khrplatform.h +290 -290
  12. data/assets/include/SDL2/SDL.h +233 -233
  13. data/assets/include/SDL2/SDL_assert.h +326 -326
  14. data/assets/include/SDL2/SDL_atomic.h +415 -415
  15. data/assets/include/SDL2/SDL_audio.h +1500 -1500
  16. data/assets/include/SDL2/SDL_bits.h +126 -126
  17. data/assets/include/SDL2/SDL_blendmode.h +198 -198
  18. data/assets/include/SDL2/SDL_clipboard.h +141 -141
  19. data/assets/include/SDL2/SDL_config.h +61 -61
  20. data/assets/include/SDL2/SDL_config_android.h +194 -194
  21. data/assets/include/SDL2/SDL_config_emscripten.h +218 -218
  22. data/assets/include/SDL2/SDL_config_iphoneos.h +217 -217
  23. data/assets/include/SDL2/SDL_config_macosx.h +277 -277
  24. data/assets/include/SDL2/SDL_config_minimal.h +95 -95
  25. data/assets/include/SDL2/SDL_config_ngage.h +89 -89
  26. data/assets/include/SDL2/SDL_config_os2.h +207 -207
  27. data/assets/include/SDL2/SDL_config_pandora.h +141 -141
  28. data/assets/include/SDL2/SDL_config_windows.h +331 -331
  29. data/assets/include/SDL2/SDL_config_wingdk.h +253 -253
  30. data/assets/include/SDL2/SDL_config_winrt.h +220 -220
  31. data/assets/include/SDL2/SDL_config_xbox.h +235 -235
  32. data/assets/include/SDL2/SDL_copying.h +20 -20
  33. data/assets/include/SDL2/SDL_cpuinfo.h +594 -594
  34. data/assets/include/SDL2/SDL_egl.h +2352 -2352
  35. data/assets/include/SDL2/SDL_endian.h +348 -348
  36. data/assets/include/SDL2/SDL_error.h +163 -163
  37. data/assets/include/SDL2/SDL_events.h +1166 -1166
  38. data/assets/include/SDL2/SDL_filesystem.h +149 -149
  39. data/assets/include/SDL2/SDL_gamecontroller.h +1074 -1074
  40. data/assets/include/SDL2/SDL_gesture.h +117 -117
  41. data/assets/include/SDL2/SDL_guid.h +100 -100
  42. data/assets/include/SDL2/SDL_haptic.h +1341 -1341
  43. data/assets/include/SDL2/SDL_hidapi.h +451 -451
  44. data/assets/include/SDL2/SDL_hints.h +2569 -2569
  45. data/assets/include/SDL2/SDL_image.h +2173 -2173
  46. data/assets/include/SDL2/SDL_joystick.h +1066 -1066
  47. data/assets/include/SDL2/SDL_keyboard.h +353 -353
  48. data/assets/include/SDL2/SDL_keycode.h +358 -358
  49. data/assets/include/SDL2/SDL_loadso.h +115 -115
  50. data/assets/include/SDL2/SDL_locale.h +103 -103
  51. data/assets/include/SDL2/SDL_log.h +404 -404
  52. data/assets/include/SDL2/SDL_main.h +275 -275
  53. data/assets/include/SDL2/SDL_messagebox.h +193 -193
  54. data/assets/include/SDL2/SDL_metal.h +113 -113
  55. data/assets/include/SDL2/SDL_misc.h +79 -79
  56. data/assets/include/SDL2/SDL_mixer.h +2784 -2784
  57. data/assets/include/SDL2/SDL_mouse.h +465 -465
  58. data/assets/include/SDL2/SDL_mutex.h +471 -471
  59. data/assets/include/SDL2/SDL_name.h +33 -33
  60. data/assets/include/SDL2/SDL_opengl.h +2132 -2132
  61. data/assets/include/SDL2/SDL_opengl_glext.h +13209 -13209
  62. data/assets/include/SDL2/SDL_opengles.h +39 -39
  63. data/assets/include/SDL2/SDL_opengles2.h +52 -52
  64. data/assets/include/SDL2/SDL_opengles2_gl2.h +656 -656
  65. data/assets/include/SDL2/SDL_opengles2_gl2ext.h +4033 -4033
  66. data/assets/include/SDL2/SDL_opengles2_gl2platform.h +27 -27
  67. data/assets/include/SDL2/SDL_opengles2_khrplatform.h +311 -311
  68. data/assets/include/SDL2/SDL_pixels.h +644 -644
  69. data/assets/include/SDL2/SDL_platform.h +261 -261
  70. data/assets/include/SDL2/SDL_power.h +88 -88
  71. data/assets/include/SDL2/SDL_quit.h +58 -58
  72. data/assets/include/SDL2/SDL_rect.h +376 -376
  73. data/assets/include/SDL2/SDL_render.h +1919 -1919
  74. data/assets/include/SDL2/SDL_revision.h +6 -6
  75. data/assets/include/SDL2/SDL_rwops.h +841 -841
  76. data/assets/include/SDL2/SDL_scancode.h +438 -438
  77. data/assets/include/SDL2/SDL_sensor.h +322 -322
  78. data/assets/include/SDL2/SDL_shape.h +155 -155
  79. data/assets/include/SDL2/SDL_stdinc.h +830 -830
  80. data/assets/include/SDL2/SDL_surface.h +997 -997
  81. data/assets/include/SDL2/SDL_system.h +623 -623
  82. data/assets/include/SDL2/SDL_syswm.h +386 -386
  83. data/assets/include/SDL2/SDL_test.h +69 -69
  84. data/assets/include/SDL2/SDL_test_assert.h +105 -105
  85. data/assets/include/SDL2/SDL_test_common.h +236 -236
  86. data/assets/include/SDL2/SDL_test_compare.h +69 -69
  87. data/assets/include/SDL2/SDL_test_crc32.h +124 -124
  88. data/assets/include/SDL2/SDL_test_font.h +168 -168
  89. data/assets/include/SDL2/SDL_test_fuzzer.h +386 -386
  90. data/assets/include/SDL2/SDL_test_harness.h +134 -134
  91. data/assets/include/SDL2/SDL_test_images.h +78 -78
  92. data/assets/include/SDL2/SDL_test_log.h +67 -67
  93. data/assets/include/SDL2/SDL_test_md5.h +129 -129
  94. data/assets/include/SDL2/SDL_test_memory.h +63 -63
  95. data/assets/include/SDL2/SDL_test_random.h +115 -115
  96. data/assets/include/SDL2/SDL_thread.h +464 -464
  97. data/assets/include/SDL2/SDL_timer.h +222 -222
  98. data/assets/include/SDL2/SDL_touch.h +150 -150
  99. data/assets/include/SDL2/SDL_ttf.h +2316 -2316
  100. data/assets/include/SDL2/SDL_types.h +29 -29
  101. data/assets/include/SDL2/SDL_version.h +204 -204
  102. data/assets/include/SDL2/SDL_video.h +2150 -2150
  103. data/assets/include/SDL2/SDL_vulkan.h +215 -215
  104. data/assets/include/SDL2/begin_code.h +187 -187
  105. data/assets/include/SDL2/close_code.h +40 -40
  106. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libFLAC.a +0 -0
  107. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2.a +0 -0
  108. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_mixer.a +0 -0
  109. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libglew32.a +0 -0
  110. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmodplug.a +0 -0
  111. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmpg123.a +0 -0
  112. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libogg.a +0 -0
  113. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopus.a +0 -0
  114. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopusfile.a +0 -0
  115. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libsndfile.a +0 -0
  116. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libssp.a +1 -1
  117. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libstdc++.a +0 -0
  118. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbis.a +0 -0
  119. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbisfile.a +0 -0
  120. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libz.a +0 -0
  121. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libzstd.a +0 -0
  122. data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
  123. data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
  124. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
  125. data/assets/windows/mingw-w64-x86_64/lib/libglew32.a +0 -0
  126. data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
  127. data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
  128. data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
  129. data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
  130. data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
  131. data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
  132. data/assets/windows/mingw-w64-x86_64/lib/libssp.a +1 -1
  133. data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
  134. data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
  135. data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
  136. data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
  137. data/assets/windows/mingw-w64-x86_64/lib/libzstd.a +0 -0
  138. data/ext/audio.c +80 -80
  139. data/ext/extconf.h +3 -3
  140. data/ext/extconf.rb +173 -177
  141. data/lib/audio.bundle +0 -0
  142. data/lib/audio.so +0 -0
  143. data/lib/native_audio.rb +50 -50
  144. metadata +4 -9
  145. data/ext/Makefile +0 -270
  146. data/ext/audio.o +0 -0
  147. data/ext/mkmf.log +0 -7
@@ -1,471 +1,471 @@
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_mutex_h_
23
- #define SDL_mutex_h_
24
-
25
- /**
26
- * \file SDL_mutex.h
27
- *
28
- * Functions to provide thread synchronization primitives.
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
- * Synchronization functions which can time out return this value
42
- * if they time out.
43
- */
44
- #define SDL_MUTEX_TIMEDOUT 1
45
-
46
- /**
47
- * This is the timeout value which corresponds to never time out.
48
- */
49
- #define SDL_MUTEX_MAXWAIT (~(Uint32)0)
50
-
51
-
52
- /**
53
- * \name Mutex functions
54
- */
55
- /* @{ */
56
-
57
- /* The SDL mutex structure, defined in SDL_sysmutex.c */
58
- struct SDL_mutex;
59
- typedef struct SDL_mutex SDL_mutex;
60
-
61
- /**
62
- * Create a new mutex.
63
- *
64
- * All newly-created mutexes begin in the _unlocked_ state.
65
- *
66
- * Calls to SDL_LockMutex() will not return while the mutex is locked by
67
- * another thread. See SDL_TryLockMutex() to attempt to lock without blocking.
68
- *
69
- * SDL mutexes are reentrant.
70
- *
71
- * \returns the initialized and unlocked mutex or NULL on failure; call
72
- * SDL_GetError() for more information.
73
- *
74
- * \since This function is available since SDL 2.0.0.
75
- *
76
- * \sa SDL_DestroyMutex
77
- * \sa SDL_LockMutex
78
- * \sa SDL_TryLockMutex
79
- * \sa SDL_UnlockMutex
80
- */
81
- extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void);
82
-
83
- /**
84
- * Lock the mutex.
85
- *
86
- * This will block until the mutex is available, which is to say it is in the
87
- * unlocked state and the OS has chosen the caller as the next thread to lock
88
- * it. Of all threads waiting to lock the mutex, only one may do so at a time.
89
- *
90
- * It is legal for the owning thread to lock an already-locked mutex. It must
91
- * unlock it the same number of times before it is actually made available for
92
- * other threads in the system (this is known as a "recursive mutex").
93
- *
94
- * \param mutex the mutex to lock
95
- * \return 0, or -1 on error.
96
- *
97
- * \since This function is available since SDL 2.0.0.
98
- */
99
- extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex);
100
- #define SDL_mutexP(m) SDL_LockMutex(m)
101
-
102
- /**
103
- * Try to lock a mutex without blocking.
104
- *
105
- * This works just like SDL_LockMutex(), but if the mutex is not available,
106
- * this function returns `SDL_MUTEX_TIMEOUT` immediately.
107
- *
108
- * This technique is useful if you need exclusive access to a resource but
109
- * don't want to wait for it, and will return to it to try again later.
110
- *
111
- * \param mutex the mutex to try to lock
112
- * \returns 0, `SDL_MUTEX_TIMEDOUT`, or -1 on error; call SDL_GetError() for
113
- * more information.
114
- *
115
- * \since This function is available since SDL 2.0.0.
116
- *
117
- * \sa SDL_CreateMutex
118
- * \sa SDL_DestroyMutex
119
- * \sa SDL_LockMutex
120
- * \sa SDL_UnlockMutex
121
- */
122
- extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex);
123
-
124
- /**
125
- * Unlock the mutex.
126
- *
127
- * It is legal for the owning thread to lock an already-locked mutex. It must
128
- * unlock it the same number of times before it is actually made available for
129
- * other threads in the system (this is known as a "recursive mutex").
130
- *
131
- * It is an error to unlock a mutex that has not been locked by the current
132
- * thread, and doing so results in undefined behavior.
133
- *
134
- * It is also an error to unlock a mutex that isn't locked at all.
135
- *
136
- * \param mutex the mutex to unlock.
137
- * \returns 0, or -1 on error.
138
- *
139
- * \since This function is available since SDL 2.0.0.
140
- */
141
- extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex);
142
- #define SDL_mutexV(m) SDL_UnlockMutex(m)
143
-
144
- /**
145
- * Destroy a mutex created with SDL_CreateMutex().
146
- *
147
- * This function must be called on any mutex that is no longer needed. Failure
148
- * to destroy a mutex will result in a system memory or resource leak. While
149
- * it is safe to destroy a mutex that is _unlocked_, it is not safe to attempt
150
- * to destroy a locked mutex, and may result in undefined behavior depending
151
- * on the platform.
152
- *
153
- * \param mutex the mutex to destroy
154
- *
155
- * \since This function is available since SDL 2.0.0.
156
- *
157
- * \sa SDL_CreateMutex
158
- * \sa SDL_LockMutex
159
- * \sa SDL_TryLockMutex
160
- * \sa SDL_UnlockMutex
161
- */
162
- extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex);
163
-
164
- /* @} *//* Mutex functions */
165
-
166
-
167
- /**
168
- * \name Semaphore functions
169
- */
170
- /* @{ */
171
-
172
- /* The SDL semaphore structure, defined in SDL_syssem.c */
173
- struct SDL_semaphore;
174
- typedef struct SDL_semaphore SDL_sem;
175
-
176
- /**
177
- * Create a semaphore.
178
- *
179
- * This function creates a new semaphore and initializes it with the value
180
- * `initial_value`. Each wait operation on the semaphore will atomically
181
- * decrement the semaphore value and potentially block if the semaphore value
182
- * is 0. Each post operation will atomically increment the semaphore value and
183
- * wake waiting threads and allow them to retry the wait operation.
184
- *
185
- * \param initial_value the starting value of the semaphore
186
- * \returns a new semaphore or NULL on failure; call SDL_GetError() for more
187
- * information.
188
- *
189
- * \since This function is available since SDL 2.0.0.
190
- *
191
- * \sa SDL_DestroySemaphore
192
- * \sa SDL_SemPost
193
- * \sa SDL_SemTryWait
194
- * \sa SDL_SemValue
195
- * \sa SDL_SemWait
196
- * \sa SDL_SemWaitTimeout
197
- */
198
- extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
199
-
200
- /**
201
- * Destroy a semaphore.
202
- *
203
- * It is not safe to destroy a semaphore if there are threads currently
204
- * waiting on it.
205
- *
206
- * \param sem the semaphore to destroy
207
- *
208
- * \since This function is available since SDL 2.0.0.
209
- *
210
- * \sa SDL_CreateSemaphore
211
- * \sa SDL_SemPost
212
- * \sa SDL_SemTryWait
213
- * \sa SDL_SemValue
214
- * \sa SDL_SemWait
215
- * \sa SDL_SemWaitTimeout
216
- */
217
- extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem);
218
-
219
- /**
220
- * Wait until a semaphore has a positive value and then decrements it.
221
- *
222
- * This function suspends the calling thread until either the semaphore
223
- * pointed to by `sem` has a positive value or the call is interrupted by a
224
- * signal or error. If the call is successful it will atomically decrement the
225
- * semaphore value.
226
- *
227
- * This function is the equivalent of calling SDL_SemWaitTimeout() with a time
228
- * length of `SDL_MUTEX_MAXWAIT`.
229
- *
230
- * \param sem the semaphore wait on
231
- * \returns 0 on success or a negative error code on failure; call
232
- * SDL_GetError() for more information.
233
- *
234
- * \since This function is available since SDL 2.0.0.
235
- *
236
- * \sa SDL_CreateSemaphore
237
- * \sa SDL_DestroySemaphore
238
- * \sa SDL_SemPost
239
- * \sa SDL_SemTryWait
240
- * \sa SDL_SemValue
241
- * \sa SDL_SemWait
242
- * \sa SDL_SemWaitTimeout
243
- */
244
- extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem);
245
-
246
- /**
247
- * See if a semaphore has a positive value and decrement it if it does.
248
- *
249
- * This function checks to see if the semaphore pointed to by `sem` has a
250
- * positive value and atomically decrements the semaphore value if it does. If
251
- * the semaphore doesn't have a positive value, the function immediately
252
- * returns SDL_MUTEX_TIMEDOUT.
253
- *
254
- * \param sem the semaphore to wait on
255
- * \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait would
256
- * block, or a negative error code on failure; call SDL_GetError()
257
- * for more information.
258
- *
259
- * \since This function is available since SDL 2.0.0.
260
- *
261
- * \sa SDL_CreateSemaphore
262
- * \sa SDL_DestroySemaphore
263
- * \sa SDL_SemPost
264
- * \sa SDL_SemValue
265
- * \sa SDL_SemWait
266
- * \sa SDL_SemWaitTimeout
267
- */
268
- extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
269
-
270
- /**
271
- * Wait until a semaphore has a positive value and then decrements it.
272
- *
273
- * This function suspends the calling thread until either the semaphore
274
- * pointed to by `sem` has a positive value, the call is interrupted by a
275
- * signal or error, or the specified time has elapsed. If the call is
276
- * successful it will atomically decrement the semaphore value.
277
- *
278
- * \param sem the semaphore to wait on
279
- * \param ms the length of the timeout, in milliseconds
280
- * \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait does not
281
- * succeed in the allotted time, or a negative error code on failure;
282
- * call SDL_GetError() for more information.
283
- *
284
- * \since This function is available since SDL 2.0.0.
285
- *
286
- * \sa SDL_CreateSemaphore
287
- * \sa SDL_DestroySemaphore
288
- * \sa SDL_SemPost
289
- * \sa SDL_SemTryWait
290
- * \sa SDL_SemValue
291
- * \sa SDL_SemWait
292
- */
293
- extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms);
294
-
295
- /**
296
- * Atomically increment a semaphore's value and wake waiting threads.
297
- *
298
- * \param sem the semaphore to increment
299
- * \returns 0 on success or a negative error code on failure; call
300
- * SDL_GetError() for more information.
301
- *
302
- * \since This function is available since SDL 2.0.0.
303
- *
304
- * \sa SDL_CreateSemaphore
305
- * \sa SDL_DestroySemaphore
306
- * \sa SDL_SemTryWait
307
- * \sa SDL_SemValue
308
- * \sa SDL_SemWait
309
- * \sa SDL_SemWaitTimeout
310
- */
311
- extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem);
312
-
313
- /**
314
- * Get the current value of a semaphore.
315
- *
316
- * \param sem the semaphore to query
317
- * \returns the current value of the semaphore.
318
- *
319
- * \since This function is available since SDL 2.0.0.
320
- *
321
- * \sa SDL_CreateSemaphore
322
- */
323
- extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem);
324
-
325
- /* @} *//* Semaphore functions */
326
-
327
-
328
- /**
329
- * \name Condition variable functions
330
- */
331
- /* @{ */
332
-
333
- /* The SDL condition variable structure, defined in SDL_syscond.c */
334
- struct SDL_cond;
335
- typedef struct SDL_cond SDL_cond;
336
-
337
- /**
338
- * Create a condition variable.
339
- *
340
- * \returns a new condition variable or NULL on failure; call SDL_GetError()
341
- * for more information.
342
- *
343
- * \since This function is available since SDL 2.0.0.
344
- *
345
- * \sa SDL_CondBroadcast
346
- * \sa SDL_CondSignal
347
- * \sa SDL_CondWait
348
- * \sa SDL_CondWaitTimeout
349
- * \sa SDL_DestroyCond
350
- */
351
- extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void);
352
-
353
- /**
354
- * Destroy a condition variable.
355
- *
356
- * \param cond the condition variable to destroy
357
- *
358
- * \since This function is available since SDL 2.0.0.
359
- *
360
- * \sa SDL_CondBroadcast
361
- * \sa SDL_CondSignal
362
- * \sa SDL_CondWait
363
- * \sa SDL_CondWaitTimeout
364
- * \sa SDL_CreateCond
365
- */
366
- extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond);
367
-
368
- /**
369
- * Restart one of the threads that are waiting on the condition variable.
370
- *
371
- * \param cond the condition variable to signal
372
- * \returns 0 on success or a negative error code on failure; call
373
- * SDL_GetError() for more information.
374
- *
375
- * \since This function is available since SDL 2.0.0.
376
- *
377
- * \sa SDL_CondBroadcast
378
- * \sa SDL_CondWait
379
- * \sa SDL_CondWaitTimeout
380
- * \sa SDL_CreateCond
381
- * \sa SDL_DestroyCond
382
- */
383
- extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond);
384
-
385
- /**
386
- * Restart all threads that are waiting on the condition variable.
387
- *
388
- * \param cond the condition variable to signal
389
- * \returns 0 on success or a negative error code on failure; call
390
- * SDL_GetError() for more information.
391
- *
392
- * \since This function is available since SDL 2.0.0.
393
- *
394
- * \sa SDL_CondSignal
395
- * \sa SDL_CondWait
396
- * \sa SDL_CondWaitTimeout
397
- * \sa SDL_CreateCond
398
- * \sa SDL_DestroyCond
399
- */
400
- extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond);
401
-
402
- /**
403
- * Wait until a condition variable is signaled.
404
- *
405
- * This function unlocks the specified `mutex` and waits for another thread to
406
- * call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable
407
- * `cond`. Once the condition variable is signaled, the mutex is re-locked and
408
- * the function returns.
409
- *
410
- * The mutex must be locked before calling this function.
411
- *
412
- * This function is the equivalent of calling SDL_CondWaitTimeout() with a
413
- * time length of `SDL_MUTEX_MAXWAIT`.
414
- *
415
- * \param cond the condition variable to wait on
416
- * \param mutex the mutex used to coordinate thread access
417
- * \returns 0 when it is signaled or a negative error code on failure; call
418
- * SDL_GetError() for more information.
419
- *
420
- * \since This function is available since SDL 2.0.0.
421
- *
422
- * \sa SDL_CondBroadcast
423
- * \sa SDL_CondSignal
424
- * \sa SDL_CondWaitTimeout
425
- * \sa SDL_CreateCond
426
- * \sa SDL_DestroyCond
427
- */
428
- extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex);
429
-
430
- /**
431
- * Wait until a condition variable is signaled or a certain time has passed.
432
- *
433
- * This function unlocks the specified `mutex` and waits for another thread to
434
- * call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable
435
- * `cond`, or for the specified time to elapse. Once the condition variable is
436
- * signaled or the time elapsed, the mutex is re-locked and the function
437
- * returns.
438
- *
439
- * The mutex must be locked before calling this function.
440
- *
441
- * \param cond the condition variable to wait on
442
- * \param mutex the mutex used to coordinate thread access
443
- * \param ms the maximum time to wait, in milliseconds, or `SDL_MUTEX_MAXWAIT`
444
- * to wait indefinitely
445
- * \returns 0 if the condition variable is signaled, `SDL_MUTEX_TIMEDOUT` if
446
- * the condition is not signaled in the allotted time, or a negative
447
- * error code on failure; call SDL_GetError() for more information.
448
- *
449
- * \since This function is available since SDL 2.0.0.
450
- *
451
- * \sa SDL_CondBroadcast
452
- * \sa SDL_CondSignal
453
- * \sa SDL_CondWait
454
- * \sa SDL_CreateCond
455
- * \sa SDL_DestroyCond
456
- */
457
- extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond,
458
- SDL_mutex * mutex, Uint32 ms);
459
-
460
- /* @} *//* Condition variable functions */
461
-
462
-
463
- /* Ends C function definitions when using C++ */
464
- #ifdef __cplusplus
465
- }
466
- #endif
467
- #include "close_code.h"
468
-
469
- #endif /* SDL_mutex_h_ */
470
-
471
- /* vi: set ts=4 sw=4 expandtab: */
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_mutex_h_
23
+ #define SDL_mutex_h_
24
+
25
+ /**
26
+ * \file SDL_mutex.h
27
+ *
28
+ * Functions to provide thread synchronization primitives.
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
+ * Synchronization functions which can time out return this value
42
+ * if they time out.
43
+ */
44
+ #define SDL_MUTEX_TIMEDOUT 1
45
+
46
+ /**
47
+ * This is the timeout value which corresponds to never time out.
48
+ */
49
+ #define SDL_MUTEX_MAXWAIT (~(Uint32)0)
50
+
51
+
52
+ /**
53
+ * \name Mutex functions
54
+ */
55
+ /* @{ */
56
+
57
+ /* The SDL mutex structure, defined in SDL_sysmutex.c */
58
+ struct SDL_mutex;
59
+ typedef struct SDL_mutex SDL_mutex;
60
+
61
+ /**
62
+ * Create a new mutex.
63
+ *
64
+ * All newly-created mutexes begin in the _unlocked_ state.
65
+ *
66
+ * Calls to SDL_LockMutex() will not return while the mutex is locked by
67
+ * another thread. See SDL_TryLockMutex() to attempt to lock without blocking.
68
+ *
69
+ * SDL mutexes are reentrant.
70
+ *
71
+ * \returns the initialized and unlocked mutex or NULL on failure; call
72
+ * SDL_GetError() for more information.
73
+ *
74
+ * \since This function is available since SDL 2.0.0.
75
+ *
76
+ * \sa SDL_DestroyMutex
77
+ * \sa SDL_LockMutex
78
+ * \sa SDL_TryLockMutex
79
+ * \sa SDL_UnlockMutex
80
+ */
81
+ extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void);
82
+
83
+ /**
84
+ * Lock the mutex.
85
+ *
86
+ * This will block until the mutex is available, which is to say it is in the
87
+ * unlocked state and the OS has chosen the caller as the next thread to lock
88
+ * it. Of all threads waiting to lock the mutex, only one may do so at a time.
89
+ *
90
+ * It is legal for the owning thread to lock an already-locked mutex. It must
91
+ * unlock it the same number of times before it is actually made available for
92
+ * other threads in the system (this is known as a "recursive mutex").
93
+ *
94
+ * \param mutex the mutex to lock
95
+ * \return 0, or -1 on error.
96
+ *
97
+ * \since This function is available since SDL 2.0.0.
98
+ */
99
+ extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex);
100
+ #define SDL_mutexP(m) SDL_LockMutex(m)
101
+
102
+ /**
103
+ * Try to lock a mutex without blocking.
104
+ *
105
+ * This works just like SDL_LockMutex(), but if the mutex is not available,
106
+ * this function returns `SDL_MUTEX_TIMEOUT` immediately.
107
+ *
108
+ * This technique is useful if you need exclusive access to a resource but
109
+ * don't want to wait for it, and will return to it to try again later.
110
+ *
111
+ * \param mutex the mutex to try to lock
112
+ * \returns 0, `SDL_MUTEX_TIMEDOUT`, or -1 on error; call SDL_GetError() for
113
+ * more information.
114
+ *
115
+ * \since This function is available since SDL 2.0.0.
116
+ *
117
+ * \sa SDL_CreateMutex
118
+ * \sa SDL_DestroyMutex
119
+ * \sa SDL_LockMutex
120
+ * \sa SDL_UnlockMutex
121
+ */
122
+ extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex);
123
+
124
+ /**
125
+ * Unlock the mutex.
126
+ *
127
+ * It is legal for the owning thread to lock an already-locked mutex. It must
128
+ * unlock it the same number of times before it is actually made available for
129
+ * other threads in the system (this is known as a "recursive mutex").
130
+ *
131
+ * It is an error to unlock a mutex that has not been locked by the current
132
+ * thread, and doing so results in undefined behavior.
133
+ *
134
+ * It is also an error to unlock a mutex that isn't locked at all.
135
+ *
136
+ * \param mutex the mutex to unlock.
137
+ * \returns 0, or -1 on error.
138
+ *
139
+ * \since This function is available since SDL 2.0.0.
140
+ */
141
+ extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex);
142
+ #define SDL_mutexV(m) SDL_UnlockMutex(m)
143
+
144
+ /**
145
+ * Destroy a mutex created with SDL_CreateMutex().
146
+ *
147
+ * This function must be called on any mutex that is no longer needed. Failure
148
+ * to destroy a mutex will result in a system memory or resource leak. While
149
+ * it is safe to destroy a mutex that is _unlocked_, it is not safe to attempt
150
+ * to destroy a locked mutex, and may result in undefined behavior depending
151
+ * on the platform.
152
+ *
153
+ * \param mutex the mutex to destroy
154
+ *
155
+ * \since This function is available since SDL 2.0.0.
156
+ *
157
+ * \sa SDL_CreateMutex
158
+ * \sa SDL_LockMutex
159
+ * \sa SDL_TryLockMutex
160
+ * \sa SDL_UnlockMutex
161
+ */
162
+ extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex);
163
+
164
+ /* @} *//* Mutex functions */
165
+
166
+
167
+ /**
168
+ * \name Semaphore functions
169
+ */
170
+ /* @{ */
171
+
172
+ /* The SDL semaphore structure, defined in SDL_syssem.c */
173
+ struct SDL_semaphore;
174
+ typedef struct SDL_semaphore SDL_sem;
175
+
176
+ /**
177
+ * Create a semaphore.
178
+ *
179
+ * This function creates a new semaphore and initializes it with the value
180
+ * `initial_value`. Each wait operation on the semaphore will atomically
181
+ * decrement the semaphore value and potentially block if the semaphore value
182
+ * is 0. Each post operation will atomically increment the semaphore value and
183
+ * wake waiting threads and allow them to retry the wait operation.
184
+ *
185
+ * \param initial_value the starting value of the semaphore
186
+ * \returns a new semaphore or NULL on failure; call SDL_GetError() for more
187
+ * information.
188
+ *
189
+ * \since This function is available since SDL 2.0.0.
190
+ *
191
+ * \sa SDL_DestroySemaphore
192
+ * \sa SDL_SemPost
193
+ * \sa SDL_SemTryWait
194
+ * \sa SDL_SemValue
195
+ * \sa SDL_SemWait
196
+ * \sa SDL_SemWaitTimeout
197
+ */
198
+ extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
199
+
200
+ /**
201
+ * Destroy a semaphore.
202
+ *
203
+ * It is not safe to destroy a semaphore if there are threads currently
204
+ * waiting on it.
205
+ *
206
+ * \param sem the semaphore to destroy
207
+ *
208
+ * \since This function is available since SDL 2.0.0.
209
+ *
210
+ * \sa SDL_CreateSemaphore
211
+ * \sa SDL_SemPost
212
+ * \sa SDL_SemTryWait
213
+ * \sa SDL_SemValue
214
+ * \sa SDL_SemWait
215
+ * \sa SDL_SemWaitTimeout
216
+ */
217
+ extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem);
218
+
219
+ /**
220
+ * Wait until a semaphore has a positive value and then decrements it.
221
+ *
222
+ * This function suspends the calling thread until either the semaphore
223
+ * pointed to by `sem` has a positive value or the call is interrupted by a
224
+ * signal or error. If the call is successful it will atomically decrement the
225
+ * semaphore value.
226
+ *
227
+ * This function is the equivalent of calling SDL_SemWaitTimeout() with a time
228
+ * length of `SDL_MUTEX_MAXWAIT`.
229
+ *
230
+ * \param sem the semaphore wait on
231
+ * \returns 0 on success or a negative error code on failure; call
232
+ * SDL_GetError() for more information.
233
+ *
234
+ * \since This function is available since SDL 2.0.0.
235
+ *
236
+ * \sa SDL_CreateSemaphore
237
+ * \sa SDL_DestroySemaphore
238
+ * \sa SDL_SemPost
239
+ * \sa SDL_SemTryWait
240
+ * \sa SDL_SemValue
241
+ * \sa SDL_SemWait
242
+ * \sa SDL_SemWaitTimeout
243
+ */
244
+ extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem);
245
+
246
+ /**
247
+ * See if a semaphore has a positive value and decrement it if it does.
248
+ *
249
+ * This function checks to see if the semaphore pointed to by `sem` has a
250
+ * positive value and atomically decrements the semaphore value if it does. If
251
+ * the semaphore doesn't have a positive value, the function immediately
252
+ * returns SDL_MUTEX_TIMEDOUT.
253
+ *
254
+ * \param sem the semaphore to wait on
255
+ * \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait would
256
+ * block, or a negative error code on failure; call SDL_GetError()
257
+ * for more information.
258
+ *
259
+ * \since This function is available since SDL 2.0.0.
260
+ *
261
+ * \sa SDL_CreateSemaphore
262
+ * \sa SDL_DestroySemaphore
263
+ * \sa SDL_SemPost
264
+ * \sa SDL_SemValue
265
+ * \sa SDL_SemWait
266
+ * \sa SDL_SemWaitTimeout
267
+ */
268
+ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
269
+
270
+ /**
271
+ * Wait until a semaphore has a positive value and then decrements it.
272
+ *
273
+ * This function suspends the calling thread until either the semaphore
274
+ * pointed to by `sem` has a positive value, the call is interrupted by a
275
+ * signal or error, or the specified time has elapsed. If the call is
276
+ * successful it will atomically decrement the semaphore value.
277
+ *
278
+ * \param sem the semaphore to wait on
279
+ * \param ms the length of the timeout, in milliseconds
280
+ * \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait does not
281
+ * succeed in the allotted time, or a negative error code on failure;
282
+ * call SDL_GetError() for more information.
283
+ *
284
+ * \since This function is available since SDL 2.0.0.
285
+ *
286
+ * \sa SDL_CreateSemaphore
287
+ * \sa SDL_DestroySemaphore
288
+ * \sa SDL_SemPost
289
+ * \sa SDL_SemTryWait
290
+ * \sa SDL_SemValue
291
+ * \sa SDL_SemWait
292
+ */
293
+ extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms);
294
+
295
+ /**
296
+ * Atomically increment a semaphore's value and wake waiting threads.
297
+ *
298
+ * \param sem the semaphore to increment
299
+ * \returns 0 on success or a negative error code on failure; call
300
+ * SDL_GetError() for more information.
301
+ *
302
+ * \since This function is available since SDL 2.0.0.
303
+ *
304
+ * \sa SDL_CreateSemaphore
305
+ * \sa SDL_DestroySemaphore
306
+ * \sa SDL_SemTryWait
307
+ * \sa SDL_SemValue
308
+ * \sa SDL_SemWait
309
+ * \sa SDL_SemWaitTimeout
310
+ */
311
+ extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem);
312
+
313
+ /**
314
+ * Get the current value of a semaphore.
315
+ *
316
+ * \param sem the semaphore to query
317
+ * \returns the current value of the semaphore.
318
+ *
319
+ * \since This function is available since SDL 2.0.0.
320
+ *
321
+ * \sa SDL_CreateSemaphore
322
+ */
323
+ extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem);
324
+
325
+ /* @} *//* Semaphore functions */
326
+
327
+
328
+ /**
329
+ * \name Condition variable functions
330
+ */
331
+ /* @{ */
332
+
333
+ /* The SDL condition variable structure, defined in SDL_syscond.c */
334
+ struct SDL_cond;
335
+ typedef struct SDL_cond SDL_cond;
336
+
337
+ /**
338
+ * Create a condition variable.
339
+ *
340
+ * \returns a new condition variable or NULL on failure; call SDL_GetError()
341
+ * for more information.
342
+ *
343
+ * \since This function is available since SDL 2.0.0.
344
+ *
345
+ * \sa SDL_CondBroadcast
346
+ * \sa SDL_CondSignal
347
+ * \sa SDL_CondWait
348
+ * \sa SDL_CondWaitTimeout
349
+ * \sa SDL_DestroyCond
350
+ */
351
+ extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void);
352
+
353
+ /**
354
+ * Destroy a condition variable.
355
+ *
356
+ * \param cond the condition variable to destroy
357
+ *
358
+ * \since This function is available since SDL 2.0.0.
359
+ *
360
+ * \sa SDL_CondBroadcast
361
+ * \sa SDL_CondSignal
362
+ * \sa SDL_CondWait
363
+ * \sa SDL_CondWaitTimeout
364
+ * \sa SDL_CreateCond
365
+ */
366
+ extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond);
367
+
368
+ /**
369
+ * Restart one of the threads that are waiting on the condition variable.
370
+ *
371
+ * \param cond the condition variable to signal
372
+ * \returns 0 on success or a negative error code on failure; call
373
+ * SDL_GetError() for more information.
374
+ *
375
+ * \since This function is available since SDL 2.0.0.
376
+ *
377
+ * \sa SDL_CondBroadcast
378
+ * \sa SDL_CondWait
379
+ * \sa SDL_CondWaitTimeout
380
+ * \sa SDL_CreateCond
381
+ * \sa SDL_DestroyCond
382
+ */
383
+ extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond);
384
+
385
+ /**
386
+ * Restart all threads that are waiting on the condition variable.
387
+ *
388
+ * \param cond the condition variable to signal
389
+ * \returns 0 on success or a negative error code on failure; call
390
+ * SDL_GetError() for more information.
391
+ *
392
+ * \since This function is available since SDL 2.0.0.
393
+ *
394
+ * \sa SDL_CondSignal
395
+ * \sa SDL_CondWait
396
+ * \sa SDL_CondWaitTimeout
397
+ * \sa SDL_CreateCond
398
+ * \sa SDL_DestroyCond
399
+ */
400
+ extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond);
401
+
402
+ /**
403
+ * Wait until a condition variable is signaled.
404
+ *
405
+ * This function unlocks the specified `mutex` and waits for another thread to
406
+ * call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable
407
+ * `cond`. Once the condition variable is signaled, the mutex is re-locked and
408
+ * the function returns.
409
+ *
410
+ * The mutex must be locked before calling this function.
411
+ *
412
+ * This function is the equivalent of calling SDL_CondWaitTimeout() with a
413
+ * time length of `SDL_MUTEX_MAXWAIT`.
414
+ *
415
+ * \param cond the condition variable to wait on
416
+ * \param mutex the mutex used to coordinate thread access
417
+ * \returns 0 when it is signaled or a negative error code on failure; call
418
+ * SDL_GetError() for more information.
419
+ *
420
+ * \since This function is available since SDL 2.0.0.
421
+ *
422
+ * \sa SDL_CondBroadcast
423
+ * \sa SDL_CondSignal
424
+ * \sa SDL_CondWaitTimeout
425
+ * \sa SDL_CreateCond
426
+ * \sa SDL_DestroyCond
427
+ */
428
+ extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex);
429
+
430
+ /**
431
+ * Wait until a condition variable is signaled or a certain time has passed.
432
+ *
433
+ * This function unlocks the specified `mutex` and waits for another thread to
434
+ * call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable
435
+ * `cond`, or for the specified time to elapse. Once the condition variable is
436
+ * signaled or the time elapsed, the mutex is re-locked and the function
437
+ * returns.
438
+ *
439
+ * The mutex must be locked before calling this function.
440
+ *
441
+ * \param cond the condition variable to wait on
442
+ * \param mutex the mutex used to coordinate thread access
443
+ * \param ms the maximum time to wait, in milliseconds, or `SDL_MUTEX_MAXWAIT`
444
+ * to wait indefinitely
445
+ * \returns 0 if the condition variable is signaled, `SDL_MUTEX_TIMEDOUT` if
446
+ * the condition is not signaled in the allotted time, or a negative
447
+ * error code on failure; call SDL_GetError() for more information.
448
+ *
449
+ * \since This function is available since SDL 2.0.0.
450
+ *
451
+ * \sa SDL_CondBroadcast
452
+ * \sa SDL_CondSignal
453
+ * \sa SDL_CondWait
454
+ * \sa SDL_CreateCond
455
+ * \sa SDL_DestroyCond
456
+ */
457
+ extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond,
458
+ SDL_mutex * mutex, Uint32 ms);
459
+
460
+ /* @} *//* Condition variable functions */
461
+
462
+
463
+ /* Ends C function definitions when using C++ */
464
+ #ifdef __cplusplus
465
+ }
466
+ #endif
467
+ #include "close_code.h"
468
+
469
+ #endif /* SDL_mutex_h_ */
470
+
471
+ /* vi: set ts=4 sw=4 expandtab: */