native_audio 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/assets/include/GL/glew.h +26427 -0
- data/assets/include/GLES2/gl2.h +656 -0
- data/assets/include/GLES2/gl2ext.h +3949 -0
- data/assets/include/GLES2/gl2ext_angle.h +701 -0
- data/assets/include/GLES2/gl2platform.h +27 -0
- data/assets/include/GLES3/gl3.h +1192 -0
- data/assets/include/GLES3/gl31.h +1507 -0
- data/assets/include/GLES3/gl32.h +1808 -0
- data/assets/include/GLES3/gl3platform.h +27 -0
- data/assets/include/KHR/khrplatform.h +290 -0
- data/assets/include/SDL2/SDL.h +233 -0
- data/assets/include/SDL2/SDL_assert.h +326 -0
- data/assets/include/SDL2/SDL_atomic.h +415 -0
- data/assets/include/SDL2/SDL_audio.h +1500 -0
- data/assets/include/SDL2/SDL_bits.h +126 -0
- data/assets/include/SDL2/SDL_blendmode.h +198 -0
- data/assets/include/SDL2/SDL_clipboard.h +141 -0
- data/assets/include/SDL2/SDL_config.h +61 -0
- data/assets/include/SDL2/SDL_config_android.h +194 -0
- data/assets/include/SDL2/SDL_config_emscripten.h +218 -0
- data/assets/include/SDL2/SDL_config_iphoneos.h +217 -0
- data/assets/include/SDL2/SDL_config_macosx.h +277 -0
- data/assets/include/SDL2/SDL_config_minimal.h +95 -0
- data/assets/include/SDL2/SDL_config_ngage.h +89 -0
- data/assets/include/SDL2/SDL_config_os2.h +207 -0
- data/assets/include/SDL2/SDL_config_pandora.h +141 -0
- data/assets/include/SDL2/SDL_config_windows.h +331 -0
- data/assets/include/SDL2/SDL_config_wingdk.h +253 -0
- data/assets/include/SDL2/SDL_config_winrt.h +220 -0
- data/assets/include/SDL2/SDL_config_xbox.h +235 -0
- data/assets/include/SDL2/SDL_copying.h +20 -0
- data/assets/include/SDL2/SDL_cpuinfo.h +594 -0
- data/assets/include/SDL2/SDL_egl.h +2352 -0
- data/assets/include/SDL2/SDL_endian.h +348 -0
- data/assets/include/SDL2/SDL_error.h +163 -0
- data/assets/include/SDL2/SDL_events.h +1166 -0
- data/assets/include/SDL2/SDL_filesystem.h +149 -0
- data/assets/include/SDL2/SDL_gamecontroller.h +1074 -0
- data/assets/include/SDL2/SDL_gesture.h +117 -0
- data/assets/include/SDL2/SDL_guid.h +100 -0
- data/assets/include/SDL2/SDL_haptic.h +1341 -0
- data/assets/include/SDL2/SDL_hidapi.h +451 -0
- data/assets/include/SDL2/SDL_hints.h +2569 -0
- data/assets/include/SDL2/SDL_image.h +2173 -0
- data/assets/include/SDL2/SDL_joystick.h +1066 -0
- data/assets/include/SDL2/SDL_keyboard.h +353 -0
- data/assets/include/SDL2/SDL_keycode.h +358 -0
- data/assets/include/SDL2/SDL_loadso.h +115 -0
- data/assets/include/SDL2/SDL_locale.h +103 -0
- data/assets/include/SDL2/SDL_log.h +404 -0
- data/assets/include/SDL2/SDL_main.h +275 -0
- data/assets/include/SDL2/SDL_messagebox.h +193 -0
- data/assets/include/SDL2/SDL_metal.h +113 -0
- data/assets/include/SDL2/SDL_misc.h +79 -0
- data/assets/include/SDL2/SDL_mixer.h +2784 -0
- data/assets/include/SDL2/SDL_mouse.h +465 -0
- data/assets/include/SDL2/SDL_mutex.h +471 -0
- data/assets/include/SDL2/SDL_name.h +33 -0
- data/assets/include/SDL2/SDL_opengl.h +2132 -0
- data/assets/include/SDL2/SDL_opengl_glext.h +13209 -0
- data/assets/include/SDL2/SDL_opengles.h +39 -0
- data/assets/include/SDL2/SDL_opengles2.h +52 -0
- data/assets/include/SDL2/SDL_opengles2_gl2.h +656 -0
- data/assets/include/SDL2/SDL_opengles2_gl2ext.h +4033 -0
- data/assets/include/SDL2/SDL_opengles2_gl2platform.h +27 -0
- data/assets/include/SDL2/SDL_opengles2_khrplatform.h +311 -0
- data/assets/include/SDL2/SDL_pixels.h +644 -0
- data/assets/include/SDL2/SDL_platform.h +261 -0
- data/assets/include/SDL2/SDL_power.h +88 -0
- data/assets/include/SDL2/SDL_quit.h +58 -0
- data/assets/include/SDL2/SDL_rect.h +376 -0
- data/assets/include/SDL2/SDL_render.h +1919 -0
- data/assets/include/SDL2/SDL_revision.h +6 -0
- data/assets/include/SDL2/SDL_rwops.h +841 -0
- data/assets/include/SDL2/SDL_scancode.h +438 -0
- data/assets/include/SDL2/SDL_sensor.h +322 -0
- data/assets/include/SDL2/SDL_shape.h +155 -0
- data/assets/include/SDL2/SDL_stdinc.h +830 -0
- data/assets/include/SDL2/SDL_surface.h +997 -0
- data/assets/include/SDL2/SDL_system.h +623 -0
- data/assets/include/SDL2/SDL_syswm.h +386 -0
- data/assets/include/SDL2/SDL_test.h +69 -0
- data/assets/include/SDL2/SDL_test_assert.h +105 -0
- data/assets/include/SDL2/SDL_test_common.h +236 -0
- data/assets/include/SDL2/SDL_test_compare.h +69 -0
- data/assets/include/SDL2/SDL_test_crc32.h +124 -0
- data/assets/include/SDL2/SDL_test_font.h +168 -0
- data/assets/include/SDL2/SDL_test_fuzzer.h +386 -0
- data/assets/include/SDL2/SDL_test_harness.h +134 -0
- data/assets/include/SDL2/SDL_test_images.h +78 -0
- data/assets/include/SDL2/SDL_test_log.h +67 -0
- data/assets/include/SDL2/SDL_test_md5.h +129 -0
- data/assets/include/SDL2/SDL_test_memory.h +63 -0
- data/assets/include/SDL2/SDL_test_random.h +115 -0
- data/assets/include/SDL2/SDL_thread.h +464 -0
- data/assets/include/SDL2/SDL_timer.h +222 -0
- data/assets/include/SDL2/SDL_touch.h +150 -0
- data/assets/include/SDL2/SDL_ttf.h +2316 -0
- data/assets/include/SDL2/SDL_types.h +29 -0
- data/assets/include/SDL2/SDL_version.h +204 -0
- data/assets/include/SDL2/SDL_video.h +2150 -0
- data/assets/include/SDL2/SDL_vulkan.h +215 -0
- data/assets/include/SDL2/begin_code.h +187 -0
- data/assets/include/SDL2/close_code.h +40 -0
- data/assets/macos/universal/lib/libFLAC.a +0 -0
- data/assets/macos/universal/lib/libSDL2.a +0 -0
- data/assets/macos/universal/lib/libSDL2_image.a +0 -0
- data/assets/macos/universal/lib/libSDL2_mixer.a +0 -0
- data/assets/macos/universal/lib/libSDL2_ttf.a +0 -0
- data/assets/macos/universal/lib/libmodplug.a +0 -0
- data/assets/macos/universal/lib/libmpg123.a +0 -0
- data/assets/macos/universal/lib/libogg.a +0 -0
- data/assets/macos/universal/lib/libvorbis.a +0 -0
- data/assets/macos/universal/lib/libvorbisfile.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libFLAC.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_mixer.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libglew32.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmodplug.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmpg123.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libogg.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopus.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopusfile.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libsndfile.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libssp.a +1 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libstdc++.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbis.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbisfile.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libz.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libzstd.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libglew32.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libssp.a +1 -0
- data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libzstd.a +0 -0
- data/ext/Makefile +270 -0
- data/ext/audio.c +80 -0
- data/ext/audio.o +0 -0
- data/ext/extconf.h +3 -0
- data/ext/extconf.rb +177 -0
- data/ext/mkmf.log +7 -0
- data/lib/audio.bundle +0 -0
- data/lib/native_audio.rb +50 -0
- metadata +198 -0
@@ -0,0 +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: */
|
@@ -0,0 +1,33 @@
|
|
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 SDLname_h_
|
23
|
+
#define SDLname_h_
|
24
|
+
|
25
|
+
#if defined(__STDC__) || defined(__cplusplus)
|
26
|
+
#define NeedFunctionPrototypes 1
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#define SDL_NAME(X) SDL_##X
|
30
|
+
|
31
|
+
#endif /* SDLname_h_ */
|
32
|
+
|
33
|
+
/* vi: set ts=4 sw=4 expandtab: */
|