mirror of
https://github.com/libsdl-org/SDL.git
synced 2024-11-26 21:33:26 +08:00
Use SDL_bool instead an int return code in the SDL API
Most SDL functions used to indicate success or failure using an int return code. These functions have been changed to return SDL_bool. Here is a coccinelle patch to change code that previously compared the return value to 0 and changes it to a boolean test: @ bool_return_type @ identifier func =~ "^(SDL_AddEventWatch|SDL_AddHintCallback|SDL_AddSurfaceAlternateImage|SDL_AddVulkanRenderSemaphores|SDL_BindAudioStream|SDL_BindAudioStreams|SDL_BlitSurface|SDL_BlitSurface9Grid|SDL_BlitSurfaceScaled|SDL_BlitSurfaceTiled|SDL_BlitSurfaceTiledWithScale|SDL_BlitSurfaceUnchecked|SDL_BlitSurfaceUncheckedScaled|SDL_CaptureMouse|SDL_ClearAudioStream|SDL_ClearClipboardData|SDL_ClearComposition|SDL_ClearError|SDL_ClearProperty|SDL_ClearSurface|SDL_CloseIO|SDL_CloseStorage|SDL_ConvertAudioSamples|SDL_ConvertEventToRenderCoordinates|SDL_ConvertPixels|SDL_ConvertPixelsAndColorspace|SDL_CopyFile|SDL_CopyProperties|SDL_CopyStorageFile|SDL_CreateDirectory|SDL_CreateStorageDirectory|SDL_CreateWindowAndRenderer|SDL_DateTimeToTime|SDL_DestroyWindowSurface|SDL_DetachVirtualJoystick|SDL_DisableScreenSaver|SDL_EnableScreenSaver|SDL_EnumerateDirectory|SDL_EnumerateProperties|SDL_EnumerateStorageDirectory|SDL_FillSurfaceRect|SDL_FillSurfaceRects|SDL_FlashWindow|SDL_FlipSurface|SDL_FlushAudioStream|SDL_FlushRenderer|SDL_GL_DestroyContext|SDL_GL_GetAttribute|SDL_GL_GetSwapInterval|SDL_GL_LoadLibrary|SDL_GL_MakeCurrent|SDL_GL_SetAttribute|SDL_GL_SetSwapInterval|SDL_GL_SwapWindow|SDL_GetAudioDeviceFormat|SDL_GetAudioStreamFormat|SDL_GetCameraFormat|SDL_GetClosestFullscreenDisplayMode|SDL_GetCurrentRenderOutputSize|SDL_GetCurrentTime|SDL_GetDXGIOutputInfo|SDL_GetDateTimeLocalePreferences|SDL_GetDisplayBounds|SDL_GetDisplayUsableBounds|SDL_GetGDKDefaultUser|SDL_GetGDKTaskQueue|SDL_GetGamepadSensorData|SDL_GetGamepadTouchpadFinger|SDL_GetHapticEffectStatus|SDL_GetJoystickBall|SDL_GetMasksForPixelFormat|SDL_GetPathInfo|SDL_GetRectUnion|SDL_GetRectUnionFloat|SDL_GetRenderClipRect|SDL_GetRenderColorScale|SDL_GetRenderDrawBlendMode|SDL_GetRenderDrawColor|SDL_GetRenderDrawColorFloat|SDL_GetRenderLogicalPresentation|SDL_GetRenderLogicalPresentationRect|SDL_GetRenderOutputSize|SDL_GetRenderSafeArea|SDL_GetRenderScale|SDL_GetRenderVSync|SDL_GetRenderViewport|SDL_GetSensorData|SDL_GetStorageFileSize|SDL_GetStoragePathInfo|SDL_GetSurfaceAlphaMod|SDL_GetSurfaceBlendMode|SDL_GetSurfaceClipRect|SDL_GetSurfaceColorKey|SDL_GetSurfaceColorMod|SDL_GetTextInputArea|SDL_GetTextureAlphaMod|SDL_GetTextureAlphaModFloat|SDL_GetTextureBlendMode|SDL_GetTextureColorMod|SDL_GetTextureColorModFloat|SDL_GetTextureScaleMode|SDL_GetTextureSize|SDL_GetWindowAspectRatio|SDL_GetWindowBordersSize|SDL_GetWindowMaximumSize|SDL_GetWindowMinimumSize|SDL_GetWindowPosition|SDL_GetWindowRelativeMouseMode|SDL_GetWindowSafeArea|SDL_GetWindowSize|SDL_GetWindowSizeInPixels|SDL_GetWindowSurfaceVSync|SDL_HideCursor|SDL_HideWindow|SDL_Init|SDL_InitHapticRumble|SDL_InitSubSystem|SDL_LoadWAV|SDL_LoadWAV_IO|SDL_LockAudioStream|SDL_LockProperties|SDL_LockSurface|SDL_LockTexture|SDL_LockTextureToSurface|SDL_MaximizeWindow|SDL_MinimizeWindow|SDL_MixAudio|SDL_OpenURL|SDL_OutOfMemory|SDL_PauseAudioDevice|SDL_PauseAudioStreamDevice|SDL_PauseHaptic|SDL_PlayHapticRumble|SDL_PremultiplyAlpha|SDL_PremultiplySurfaceAlpha|SDL_PushEvent|SDL_PutAudioStreamData|SDL_RaiseWindow|SDL_ReadStorageFile|SDL_ReadSurfacePixel|SDL_ReadSurfacePixelFloat|SDL_RegisterApp|SDL_ReloadGamepadMappings|SDL_RemovePath|SDL_RemoveStoragePath|SDL_RemoveTimer|SDL_RenamePath|SDL_RenameStoragePath|SDL_RenderClear|SDL_RenderCoordinatesFromWindow|SDL_RenderCoordinatesToWindow|SDL_RenderFillRect|SDL_RenderFillRects|SDL_RenderGeometry|SDL_RenderGeometryRaw|SDL_RenderLine|SDL_RenderLines|SDL_RenderPoint|SDL_RenderPoints|SDL_RenderPresent|SDL_RenderRect|SDL_RenderRects|SDL_RenderTexture|SDL_RenderTexture9Grid|SDL_RenderTextureRotated|SDL_RenderTextureTiled|SDL_RequestAndroidPermission|SDL_RestoreWindow|SDL_ResumeAudioDevice|SDL_ResumeAudioStreamDevice|SDL_ResumeHaptic|SDL_RumbleGamepad|SDL_RumbleGamepadTriggers|SDL_RumbleJoystick|SDL_RumbleJoystickTriggers|SDL_RunHapticEffect|SDL_SaveBMP|SDL_SaveBMP_IO|SDL_SendAndroidMessage|SDL_SendGamepadEffect|SDL_SendJoystickEffect|SDL_SendJoystickVirtualSensorData|SDL_SetAppMetadata|SDL_SetAppMetadataProperty|SDL_SetAudioDeviceGain|SDL_SetAudioPostmixCallback|SDL_SetAudioStreamFormat|SDL_SetAudioStreamFrequencyRatio|SDL_SetAudioStreamGain|SDL_SetAudioStreamGetCallback|SDL_SetAudioStreamInputChannelMap|SDL_SetAudioStreamOutputChannelMap|SDL_SetAudioStreamPutCallback|SDL_SetBooleanProperty|SDL_SetClipboardData|SDL_SetClipboardText|SDL_SetCursor|SDL_SetFloatProperty|SDL_SetGamepadLED|SDL_SetGamepadMapping|SDL_SetGamepadPlayerIndex|SDL_SetGamepadSensorEnabled|SDL_SetHapticAutocenter|SDL_SetHapticGain|SDL_SetJoystickLED|SDL_SetJoystickPlayerIndex|SDL_SetJoystickVirtualAxis|SDL_SetJoystickVirtualBall|SDL_SetJoystickVirtualButton|SDL_SetJoystickVirtualHat|SDL_SetJoystickVirtualTouchpad|SDL_SetLinuxThreadPriority|SDL_SetLinuxThreadPriorityAndPolicy|SDL_SetLogPriorityPrefix|SDL_SetMemoryFunctions|SDL_SetNumberProperty|SDL_SetPaletteColors|SDL_SetPointerProperty|SDL_SetPointerPropertyWithCleanup|SDL_SetPrimarySelectionText|SDL_SetRenderClipRect|SDL_SetRenderColorScale|SDL_SetRenderDrawBlendMode|SDL_SetRenderDrawColor|SDL_SetRenderDrawColorFloat|SDL_SetRenderLogicalPresentation|SDL_SetRenderScale|SDL_SetRenderTarget|SDL_SetRenderVSync|SDL_SetRenderViewport|SDL_SetScancodeName|SDL_SetStringProperty|SDL_SetSurfaceAlphaMod|SDL_SetSurfaceBlendMode|SDL_SetSurfaceColorKey|SDL_SetSurfaceColorMod|SDL_SetSurfaceColorspace|SDL_SetSurfacePalette|SDL_SetSurfaceRLE|SDL_SetTLS|SDL_SetTextInputArea|SDL_SetTextureAlphaMod|SDL_SetTextureAlphaModFloat|SDL_SetTextureBlendMode|SDL_SetTextureColorMod|SDL_SetTextureColorModFloat|SDL_SetTextureScaleMode|SDL_SetThreadPriority|SDL_SetWindowAlwaysOnTop|SDL_SetWindowAspectRatio|SDL_SetWindowBordered|SDL_SetWindowFocusable|SDL_SetWindowFullscreen|SDL_SetWindowFullscreenMode|SDL_SetWindowHitTest|SDL_SetWindowIcon|SDL_SetWindowKeyboardGrab|SDL_SetWindowMaximumSize|SDL_SetWindowMinimumSize|SDL_SetWindowModalFor|SDL_SetWindowMouseGrab|SDL_SetWindowMouseRect|SDL_SetWindowOpacity|SDL_SetWindowPosition|SDL_SetWindowRelativeMouseMode|SDL_SetWindowResizable|SDL_SetWindowShape|SDL_SetWindowSize|SDL_SetWindowSurfaceVSync|SDL_SetWindowTitle|SDL_SetiOSAnimationCallback|SDL_ShowAndroidToast|SDL_ShowCursor|SDL_ShowMessageBox|SDL_ShowSimpleMessageBox|SDL_ShowWindow|SDL_ShowWindowSystemMenu|SDL_StartTextInput|SDL_StartTextInputWithProperties|SDL_StopHapticEffect|SDL_StopHapticEffects|SDL_StopHapticRumble|SDL_StopTextInput|SDL_SyncWindow|SDL_TimeToDateTime|SDL_TryLockMutex|SDL_TryLockRWLockForReading|SDL_TryLockRWLockForWriting|SDL_TryWaitSemaphore|SDL_UnlockAudioStream|SDL_UpdateHapticEffect|SDL_UpdateNVTexture|SDL_UpdateTexture|SDL_UpdateWindowSurface|SDL_UpdateWindowSurfaceRects|SDL_UpdateYUVTexture|SDL_Vulkan_CreateSurface|SDL_Vulkan_LoadLibrary|SDL_WaitConditionTimeout|SDL_WaitSemaphoreTimeout|SDL_WarpMouseGlobal|SDL_WriteStorageFile|SDL_WriteSurfacePixel|SDL_WriteSurfacePixelFloat)$"; @@ ( func( ... ) - == 0 | - func( + !func( ... ) - < 0 | - func( + !func( ... ) - != 0 | - func( + !func( ... ) - == -1 )
This commit is contained in:
parent
d9a5ed75b9
commit
9ff3446f03
@ -197,7 +197,7 @@ LoadSprite(const char *file)
|
||||
if (!sprites[i]) {
|
||||
return -1;
|
||||
}
|
||||
if (SDL_SetTextureBlendMode(sprites[i], blendMode) < 0) {
|
||||
if (!SDL_SetTextureBlendMode(sprites[i], blendMode)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s\n", SDL_GetError());
|
||||
SDL_DestroyTexture(sprites[i]);
|
||||
return -1;
|
||||
@ -425,7 +425,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Load the wave file into memory */
|
||||
if (SDL_LoadWAV(soundname, &wave.spec, &wave.sound, &wave.soundlen) == -1) {
|
||||
if (!SDL_LoadWAV(soundname, &wave.spec, &wave.sound, &wave.soundlen)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", soundname, SDL_GetError());
|
||||
quit(1);
|
||||
}
|
||||
|
@ -10,13 +10,13 @@
|
||||
int main(int argc, char *argv[]) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
if (SDL_Init(SDL_INIT_EVENTS | SDL_INIT_VIDEO) < 0) {
|
||||
if (!SDL_Init(SDL_INIT_EVENTS | SDL_INIT_VIDEO)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init failed (%s)", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Hello World",
|
||||
"!! Your SDL project successfully runs on Android !!", NULL) < 0) {
|
||||
if (!SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Hello World",
|
||||
"!! Your SDL project successfully runs on Android !!", NULL)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_ShowSimpleMessageBox failed (%s)", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
@ -1473,11 +1473,11 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
if (SDLControllerManager.isDeviceSDLJoystick(deviceId)) {
|
||||
// Note that we process events with specific key codes here
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
if (SDLControllerManager.onNativePadDown(deviceId, keyCode) == 0) {
|
||||
if (SDLControllerManager.onNativePadDown(deviceId, keyCode)) {
|
||||
return true;
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
if (SDLControllerManager.onNativePadUp(deviceId, keyCode) == 0) {
|
||||
if (SDLControllerManager.onNativePadUp(deviceId, keyCode)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1951,7 +1951,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static int openURL(String url)
|
||||
public static boolean openURL(String url)
|
||||
{
|
||||
try {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
@ -1967,18 +1967,18 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
|
||||
mSingleton.startActivity(i);
|
||||
} catch (Exception ex) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static int showToast(String message, int duration, int gravity, int xOffset, int yOffset)
|
||||
public static boolean showToast(String message, int duration, int gravity, int xOffset, int yOffset)
|
||||
{
|
||||
if(null == mSingleton) {
|
||||
return - 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
@ -2013,9 +2013,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
}
|
||||
mSingleton.runOnUiThread(new OneShotTask(message, duration, gravity, xOffset, yOffset));
|
||||
} catch(Exception ex) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,15 +22,15 @@ public class SDLControllerManager
|
||||
|
||||
public static native int nativeSetupJNI();
|
||||
|
||||
public static native int nativeAddJoystick(int device_id, String name, String desc,
|
||||
int vendor_id, int product_id,
|
||||
int button_mask,
|
||||
int naxes, int axis_mask, int nhats, boolean can_rumble);
|
||||
public static native int nativeRemoveJoystick(int device_id);
|
||||
public static native int nativeAddHaptic(int device_id, String name);
|
||||
public static native int nativeRemoveHaptic(int device_id);
|
||||
public static native int onNativePadDown(int device_id, int keycode);
|
||||
public static native int onNativePadUp(int device_id, int keycode);
|
||||
public static native void nativeAddJoystick(int device_id, String name, String desc,
|
||||
int vendor_id, int product_id,
|
||||
int button_mask,
|
||||
int naxes, int axis_mask, int nhats, boolean can_rumble);
|
||||
public static native void nativeRemoveJoystick(int device_id);
|
||||
public static native void nativeAddHaptic(int device_id, String name);
|
||||
public static native void nativeRemoveHaptic(int device_id);
|
||||
public static native boolean onNativePadDown(int device_id, int keycode);
|
||||
public static native boolean onNativePadUp(int device_id, int keycode);
|
||||
public static native void onNativeJoy(int device_id, int axis,
|
||||
float value);
|
||||
public static native void onNativeHat(int device_id, int hat_id,
|
||||
|
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@
|
||||
|
||||
import SDL3
|
||||
|
||||
guard SDL_Init(Uint32(SDL_INIT_VIDEO)) == 0 else {
|
||||
guard SDL_Init(SDL_INIT_VIDEO) != 0 else {
|
||||
fatalError("SDL_Init error: \(String(cString: SDL_GetError()))")
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_SetMainReady();
|
||||
if (SDL_Init(0) < 0) {
|
||||
if (!SDL_Init(0)) {
|
||||
SDL_Log("Could not initialize SDL: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_Window *window = NULL;
|
||||
SDL_Surface *screenSurface = NULL;
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
SDL_Log("Could not initialize SDL: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ int MYLIBRARY_EXPORT mylibrary_work(void);
|
||||
|
||||
int mylibrary_init(void) {
|
||||
SDL_SetMainReady();
|
||||
if (SDL_Init(0) < 0) {
|
||||
if (!SDL_Init(0)) {
|
||||
SDL_Log("Could not initialize SDL: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ int main(int argc, char *argv[]) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
SDL_Log("SDL_Init failed (%s)", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
@ -393,7 +393,7 @@ int main(int argc, char *argv[]) {
|
||||
SDL_Window *window = NULL;
|
||||
SDL_Renderer *renderer = NULL;
|
||||
|
||||
if (SDL_CreateWindowAndRenderer("SDL issue", 640, 480, 0, &window, &renderer) < 0) {
|
||||
if (!SDL_CreateWindowAndRenderer("SDL issue", 640, 480, 0, &window, &renderer)) {
|
||||
SDL_Log("SDL_CreateWindowAndRenderer failed (%s)", SDL_GetError());
|
||||
SDL_Quit();
|
||||
return 1;
|
||||
|
@ -35,7 +35,7 @@ SDL now has, internally, a table of function pointers. So, this is what SDL_Init
|
||||
now looks like:
|
||||
|
||||
```c
|
||||
Uint32 SDL_Init(Uint32 flags)
|
||||
SDL_bool SDL_Init(SDL_InitFlags flags)
|
||||
{
|
||||
return jump_table.SDL_Init(flags);
|
||||
}
|
||||
@ -49,7 +49,7 @@ SDL_Init() that you've been calling all this time. But at startup, it looks more
|
||||
like this:
|
||||
|
||||
```c
|
||||
Uint32 SDL_Init_DEFAULT(Uint32 flags)
|
||||
SDL_bool SDL_Init_DEFAULT(SDL_InitFlags flags)
|
||||
{
|
||||
SDL_InitDynamicAPI();
|
||||
return jump_table.SDL_Init(flags);
|
||||
|
@ -225,7 +225,7 @@ Game Center
|
||||
|
||||
Game Center integration might require that you break up your main loop in order to yield control back to the system. In other words, instead of running an endless main loop, you run each frame in a callback function, using:
|
||||
|
||||
int SDL_SetiOSAnimationCallback(SDL_Window * window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam);
|
||||
SDL_bool SDL_SetiOSAnimationCallback(SDL_Window * window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam);
|
||||
|
||||
This will set up the given function to be called back on the animation callback, and then you have to return from main() to let the Cocoa event loop run.
|
||||
|
||||
|
@ -54,6 +54,7 @@ NSApplicationDelegate implementation:
|
||||
{
|
||||
if (SDL_GetEventState(SDL_EVENT_QUIT) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
SDL_zero(event);
|
||||
event.type = SDL_EVENT_QUIT;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
@ -65,9 +66,10 @@ NSApplicationDelegate implementation:
|
||||
{
|
||||
if (SDL_GetEventState(SDL_EVENT_DROP_FILE) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
SDL_zero(event);
|
||||
event.type = SDL_EVENT_DROP_FILE;
|
||||
event.drop.file = SDL_strdup([filename UTF8String]);
|
||||
return (SDL_PushEvent(&event) > 0);
|
||||
return SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
return NO;
|
||||
|
@ -6,6 +6,36 @@ Details on API changes are organized by SDL 2.0 header below.
|
||||
|
||||
The file with your main() function should include <SDL3/SDL_main.h>, as that is no longer included in SDL.h.
|
||||
|
||||
Functions that previously returned a negative error code now return SDL_bool.
|
||||
|
||||
Code that used to look like this:
|
||||
```c
|
||||
if (SDL_Function() < 0 || SDL_Function() == -1) {
|
||||
/* Failure... */
|
||||
}
|
||||
```
|
||||
or
|
||||
```c
|
||||
if (SDL_Function() == 0) {
|
||||
/* Success... */
|
||||
}
|
||||
```
|
||||
or
|
||||
```c
|
||||
if (!SDL_Function()) {
|
||||
/* Success... */
|
||||
}
|
||||
```
|
||||
should be changed to:
|
||||
```c
|
||||
if (SDL_Function()) {
|
||||
/* Success... */
|
||||
} else {
|
||||
/* Failure... */
|
||||
}
|
||||
```
|
||||
This only applies to camel case functions, e.g. `SDL_[A-Z]*`. Lower case functions like SDL_strcmp() and SDL_memcmp() are unchanged, matching their C runtime counterpart.
|
||||
|
||||
Many functions and symbols have been renamed. We have provided a handy Python script [rename_symbols.py](https://github.com/libsdl-org/SDL/blob/main/build-scripts/rename_symbols.py) to rename SDL2 functions to their SDL3 counterparts:
|
||||
```sh
|
||||
rename_symbols.py --all-symbols source_code_path
|
||||
@ -152,7 +182,7 @@ Rather than iterating over audio devices using a device index, there are new fun
|
||||
|
||||
```c
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_AUDIO) == 0) {
|
||||
if (SDL_InitSubSystem(SDL_INIT_AUDIO)) {
|
||||
int i, num_devices;
|
||||
SDL_AudioDeviceID *devices = SDL_GetAudioPlaybackDevices(&num_devices);
|
||||
if (devices) {
|
||||
@ -191,7 +221,7 @@ SDL_FreeWAV has been removed and calls can be replaced with SDL_free.
|
||||
|
||||
SDL_LoadWAV() is a proper function now and no longer a macro (but offers the same functionality otherwise).
|
||||
|
||||
SDL_LoadWAV_IO() and SDL_LoadWAV() return an int now: zero on success, -1 on error, like most of SDL. They no longer return a pointer to an SDL_AudioSpec.
|
||||
SDL_LoadWAV_IO() and SDL_LoadWAV() return an SDL_bool now, like most of SDL. They no longer return a pointer to an SDL_AudioSpec.
|
||||
|
||||
SDL_AudioCVT interface has been removed, the SDL_AudioStream interface (for audio supplied in pieces) or the new SDL_ConvertAudioSamples() function (for converting a complete audio buffer in one call) can be used instead.
|
||||
|
||||
@ -211,7 +241,7 @@ should be changed to:
|
||||
int dst_len = 0;
|
||||
const SDL_AudioSpec src_spec = { src_format, src_channels, src_rate };
|
||||
const SDL_AudioSpec dst_spec = { dst_format, dst_channels, dst_rate };
|
||||
if (SDL_ConvertAudioSamples(&src_spec, src_data, src_len, &dst_spec, &dst_data, &dst_len) < 0) {
|
||||
if (!SDL_ConvertAudioSamples(&src_spec, src_data, src_len, &dst_spec, &dst_data, &dst_len)) {
|
||||
/* error */
|
||||
}
|
||||
do_something(dst_data, dst_len);
|
||||
@ -375,7 +405,7 @@ The iscapture field of SDL_AudioDeviceEvent has been renamed recording.
|
||||
|
||||
SDL_QUERY, SDL_IGNORE, SDL_ENABLE, and SDL_DISABLE have been removed. You can use the functions SDL_SetEventEnabled() and SDL_EventEnabled() to set and query event processing state.
|
||||
|
||||
SDL_AddEventWatch() now returns -1 if it fails because it ran out of memory and couldn't add the event watch callback.
|
||||
SDL_AddEventWatch() now returns SDL_FALSE_ if it fails because it ran out of memory and couldn't add the event watch callback.
|
||||
|
||||
SDL_RegisterEvents() now returns 0 if it couldn't allocate any user events.
|
||||
|
||||
@ -702,7 +732,7 @@ Gamepads with simple rumble capability no longer show up in the SDL haptics inte
|
||||
Rather than iterating over haptic devices using device index, there is a new function SDL_GetHaptics() to get the current list of haptic devices, and new functions to get information about haptic devices from their instance ID:
|
||||
```c
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_HAPTIC) == 0) {
|
||||
if (SDL_InitSubSystem(SDL_INIT_HAPTIC)) {
|
||||
int i, num_haptics;
|
||||
SDL_HapticID *haptics = SDL_GetHaptics(&num_haptics);
|
||||
if (haptics) {
|
||||
@ -717,7 +747,7 @@ Rather than iterating over haptic devices using device index, there is a new fun
|
||||
}
|
||||
```
|
||||
|
||||
SDL_HapticEffectSupported(), SDL_HapticRumbleSupported(), and SDL_IsJoystickHaptic() now return SDL_bool instead of an optional negative error code.
|
||||
SDL_GetHapticEffectStatus() now returns SDL_bool instead of an int result. You should call SDL_GetHapticFeatures() to make sure effect status is supported before calling this function.
|
||||
|
||||
The following functions have been renamed:
|
||||
* SDL_HapticClose() => SDL_CloseHaptic()
|
||||
@ -753,12 +783,8 @@ The following functions have been removed:
|
||||
|
||||
## SDL_hints.h
|
||||
|
||||
SDL_AddHintCallback() now returns a standard int result instead of void, returning 0 if the function succeeds or a negative error code if there was an error.
|
||||
|
||||
Calling SDL_GetHint() with the name of the hint being changed from within a hint callback will now return the new value rather than the old value. The old value is still passed as a parameter to the hint callback.
|
||||
|
||||
SDL_SetHint, SDL_SetHintWithPriority, and SDL_ResetHint now return int (-1 on error, 0 on success) instead of SDL_bool (SDL_FALSE on error, SDL_TRUE on success).
|
||||
|
||||
The environment variables SDL_VIDEODRIVER and SDL_AUDIODRIVER have been renamed to SDL_VIDEO_DRIVER and SDL_AUDIO_DRIVER.
|
||||
|
||||
The environment variables SDL_VIDEO_X11_WMCLASS and SDL_VIDEO_WAYLAND_WMCLASS have been removed and replaced by either using the appindentifier param to SDL_SetAppMetadata() or setting SDL_PROP_APP_METADATA_IDENTIFIER_STRING with SDL_SetAppMetadataProperty()
|
||||
@ -861,7 +887,7 @@ SDL_JoystickID has changed from Sint32 to Uint32, with an invalid ID being 0.
|
||||
Rather than iterating over joysticks using device index, there is a new function SDL_GetJoysticks() to get the current list of joysticks, and new functions to get information about joysticks from their instance ID:
|
||||
```c
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == 0) {
|
||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK)) {
|
||||
int i, num_joysticks;
|
||||
SDL_JoystickID *joysticks = SDL_GetJoysticks(&num_joysticks);
|
||||
if (joysticks) {
|
||||
@ -1128,7 +1154,11 @@ The following symbols have been renamed:
|
||||
|
||||
SDL_MUTEX_MAXWAIT has been removed; it suggested there was a maximum timeout one could outlive, instead of an infinite wait. Instead, pass a -1 to functions that accepted this symbol.
|
||||
|
||||
SDL_LockMutex and SDL_UnlockMutex now return void; if the mutex is valid (including being a NULL pointer, which returns immediately), these functions never fail. If the mutex is invalid or the caller does something illegal, like unlock another thread's mutex, this is considered undefined behavior.
|
||||
SDL_MUTEX_TIMEDOUT has been removed, the wait functions return SDL_TRUE if the operation succeeded or SDL_FALSE if they timed out.
|
||||
|
||||
SDL_LockMutex(), SDL_UnlockMutex(), SDL_WaitSemaphore(), SDL_SignalSemaphore(), SDL_WaitCondition(), SDL_SignalCondition(), and SDL_BroadcastCondition() now return void; if the object is valid (including being a NULL pointer, which returns immediately), these functions never fail. If the object is invalid or the caller does something illegal, like unlock another thread's mutex, this is considered undefined behavior.
|
||||
|
||||
SDL_TryWaitSemaphore(), SDL_WaitSemaphoreTimeout(), and SDL_WaitConditionTimeout() now return SDL_TRUE if the operation succeeded or SDL_FALSE if they timed out.
|
||||
|
||||
The following functions have been renamed:
|
||||
* SDL_CondBroadcast() => SDL_BroadcastCondition()
|
||||
@ -1174,8 +1204,6 @@ should be changed to:
|
||||
pixel = SDL_MapSurfaceRGBA(surface, r, g, b, a);
|
||||
```
|
||||
|
||||
SDL_GetMasksForPixelFormat() now returns the standard int error code.
|
||||
|
||||
SDL_CalculateGammaRamp has been removed, because SDL_SetWindowGammaRamp has been removed as well due to poor support in modern operating systems (see [SDL_video.h](#sdl_videoh)).
|
||||
|
||||
The following functions have been renamed:
|
||||
@ -1472,17 +1500,20 @@ static Sint64 SDLCALL stdio_seek(void *userdata, Sint64 offset, int whence)
|
||||
stdiowhence = SEEK_END;
|
||||
break;
|
||||
default:
|
||||
return SDL_SetError("Unknown value for 'whence'");
|
||||
SDL_SetError("Unknown value for 'whence'");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fseek(fp, (fseek_off_t)offset, stdiowhence) == 0) {
|
||||
const Sint64 pos = ftell(fp);
|
||||
if (pos < 0) {
|
||||
return SDL_SetError("Couldn't get stream offset");
|
||||
SDL_SetError("Couldn't get stream offset");
|
||||
return -1;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
return SDL_Error(SDL_EFSEEK);
|
||||
SDL_SetError("Couldn't seek in stream");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static size_t SDLCALL stdio_read(void *userdata, void *ptr, size_t size, SDL_IOStatus *status)
|
||||
@ -1490,7 +1521,7 @@ static size_t SDLCALL stdio_read(void *userdata, void *ptr, size_t size, SDL_IOS
|
||||
FILE *fp = ((IOStreamStdioFPData *) userdata)->fp;
|
||||
const size_t bytes = fread(ptr, 1, size, fp);
|
||||
if (bytes == 0 && ferror(fp)) {
|
||||
SDL_Error(SDL_EFREAD);
|
||||
SDL_SetError("Couldn't read stream");
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
@ -1500,18 +1531,19 @@ static size_t SDLCALL stdio_write(void *userdata, const void *ptr, size_t size,
|
||||
FILE *fp = ((IOStreamStdioFPData *) userdata)->fp;
|
||||
const size_t bytes = fwrite(ptr, 1, size, fp);
|
||||
if (bytes == 0 && ferror(fp)) {
|
||||
SDL_Error(SDL_EFWRITE);
|
||||
SDL_SetError("Couldn't write stream");
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
static int SDLCALL stdio_close(void *userdata)
|
||||
static SDL_bool SDLCALL stdio_close(void *userdata)
|
||||
{
|
||||
IOStreamStdioData *rwopsdata = (IOStreamStdioData *) userdata;
|
||||
int status = 0;
|
||||
SDL_bool status = SDL_TRUE;
|
||||
if (rwopsdata->autoclose) {
|
||||
if (fclose(rwopsdata->fp) != 0) {
|
||||
status = SDL_Error(SDL_EFWRITE);
|
||||
SDL_SetError("Couldn't close stream");
|
||||
status = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
@ -1614,7 +1646,7 @@ SDL_SensorID has changed from Sint32 to Uint32, with an invalid ID being 0.
|
||||
Rather than iterating over sensors using device index, there is a new function SDL_GetSensors() to get the current list of sensors, and new functions to get information about sensors from their instance ID:
|
||||
```c
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_SENSOR) == 0) {
|
||||
if (SDL_InitSubSystem(SDL_INIT_SENSOR)) {
|
||||
int i, num_sensors;
|
||||
SDL_SensorID *sensors = SDL_GetSensors(&num_sensors);
|
||||
if (sensors) {
|
||||
@ -1805,8 +1837,6 @@ SDL_RequestAndroidPermission is no longer a blocking call; the caller now provid
|
||||
|
||||
SDL_iPhoneSetAnimationCallback() and SDL_iPhoneSetEventPump() have been renamed to SDL_SetiOSAnimationCallback() and SDL_SetiOSEventPump(), respectively. SDL2 has had macros to provide this new name with the old symbol since the introduction of the iPad, but now the correctly-named symbol is the only option.
|
||||
|
||||
SDL_GetDXGIOutputInfo() now returns the standard int error code.
|
||||
|
||||
The following functions have been removed:
|
||||
* SDL_RenderGetD3D11Device() - replaced with the "SDL.renderer.d3d11.device" property
|
||||
* SDL_RenderGetD3D12Device() - replaced with the "SDL.renderer.d3d12.device" property
|
||||
@ -1982,8 +2012,6 @@ The callback passed to SDL_AddTimer() has changed parameters to:
|
||||
Uint32 SDLCALL TimerCallback(void *userdata, SDL_TimerID timerID, Uint32 interval);
|
||||
````
|
||||
|
||||
SDL_RemoveTimer() now returns the standard int error code.
|
||||
|
||||
## SDL_touch.h
|
||||
|
||||
SDL_GetTouchName is replaced with SDL_GetTouchDeviceName(), which takes an SDL_TouchID instead of an index.
|
||||
@ -2023,7 +2051,7 @@ SDL_VideoInit() and SDL_VideoQuit() have been removed. Instead you can call SDL_
|
||||
Rather than iterating over displays using display index, there is a new function SDL_GetDisplays() to get the current list of displays, and functions which used to take a display index now take SDL_DisplayID, with an invalid ID being 0.
|
||||
```c
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) == 0) {
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO)) {
|
||||
int i, num_displays = 0;
|
||||
SDL_DisplayID *displays = SDL_GetDisplays(&num_displays);
|
||||
if (displays) {
|
||||
@ -2097,11 +2125,9 @@ Removed SDL_GL_CONTEXT_EGL from OpenGL configuration attributes. You can instead
|
||||
|
||||
SDL_GL_GetProcAddress() and SDL_EGL_GetProcAddress() now return `SDL_FunctionPointer` instead of `void *`, and should be cast to the appropriate function type. You can define SDL_FUNCTION_POINTER_IS_VOID_POINTER in your project to restore the previous behavior.
|
||||
|
||||
SDL_GL_SwapWindow() returns 0 if the function succeeds or a negative error code if there was an error.
|
||||
SDL_GL_DeleteContext() has been renamed to SDL_GL_DestroyContext to match SDL naming conventions (and glX/EGL!).
|
||||
|
||||
SDL_GL_DeleteContext() has been renamed to SDL_GL_DestroyContext to match SDL naming conventions (and glX!). It also now returns 0 if the function succeeds or a negative error code if there was an error (it returned void in SDL2).
|
||||
|
||||
SDL_GL_GetSwapInterval() takes the interval as an output parameter and returns 0 if the function succeeds or a negative error code if there was an error.
|
||||
SDL_GL_GetSwapInterval() takes the interval as an output parameter and returns SDL_TRUE if the function succeeds or SDL_FALSE if there was an error.
|
||||
|
||||
SDL_GL_GetDrawableSize() has been removed. SDL_GetWindowSizeInPixels() can be used in its place.
|
||||
|
||||
@ -2188,8 +2214,6 @@ SDL_Vulkan_GetInstanceExtensions() no longer takes a window parameter, and no lo
|
||||
|
||||
SDL_Vulkan_GetVkGetInstanceProcAddr() now returns `SDL_FunctionPointer` instead of `void *`, and should be cast to PFN_vkGetInstanceProcAddr.
|
||||
|
||||
SDL_Vulkan_CreateSurface() now returns an int (0=success, -1=error) instead of an SDL_bool (true=success, false=error).
|
||||
|
||||
SDL_Vulkan_CreateSurface() now takes a VkAllocationCallbacks pointer as its third parameter. If you don't have an allocator to supply, pass a NULL here to use the system default allocator (SDL2 always used the system default allocator here).
|
||||
|
||||
SDL_Vulkan_GetDrawableSize() has been removed. SDL_GetWindowSizeInPixels() can be used in its place.
|
||||
|
@ -298,9 +298,9 @@ int main(int argc, char **argv)
|
||||
SDL_Event evt;
|
||||
SDL_bool keep_going = SDL_TRUE;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
return 1;
|
||||
} else if (SDL_CreateWindowAndRenderer("Hello SDL", 0, 0, SDL_WINDOW_FULLSCREEN, &window, &renderer) != 0) {
|
||||
} else if (!SDL_CreateWindowAndRenderer("Hello SDL", 0, 0, SDL_WINDOW_FULLSCREEN, &window, &renderer)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -21,13 +21,13 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
{
|
||||
SDL_AudioSpec spec;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) == -1) {
|
||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
/* we don't _need_ a window for audio-only things but it's good policy to have one. */
|
||||
if (SDL_CreateWindowAndRenderer("examples/audio/simple-playback", 640, 480, 0, &window, &renderer) == -1) {
|
||||
if (!SDL_CreateWindowAndRenderer("examples/audio/simple-playback", 640, 480, 0, &window, &renderer)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
@ -53,13 +53,13 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
{
|
||||
SDL_AudioSpec spec;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) == -1) {
|
||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
/* we don't _need_ a window for audio-only things but it's good policy to have one. */
|
||||
if (SDL_CreateWindowAndRenderer("examples/audio/simple-playback-callback", 640, 480, 0, &window, &renderer) == -1) {
|
||||
if (!SDL_CreateWindowAndRenderer("examples/audio/simple-playback-callback", 640, 480, 0, &window, &renderer)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
@ -31,20 +31,20 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
SDL_AudioSpec spec;
|
||||
char *wav_path = NULL;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) == -1) {
|
||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
/* we don't _need_ a window for audio-only things but it's good policy to have one. */
|
||||
if (SDL_CreateWindowAndRenderer("examples/audio/load-wav", 640, 480, 0, &window, &renderer) == -1) {
|
||||
if (!SDL_CreateWindowAndRenderer("examples/audio/load-wav", 640, 480, 0, &window, &renderer)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
/* Load the .wav file from wherever the app is being run from. */
|
||||
SDL_asprintf(&wav_path, "%ssample.wav", SDL_GetBasePath()); /* allocate a string of the full file path */
|
||||
if (SDL_LoadWAV(wav_path, &spec, &wav_data, &wav_data_len) == -1) {
|
||||
if (!SDL_LoadWAV(wav_path, &spec, &wav_data, &wav_data_len)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't load .wav file!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
@ -26,12 +26,12 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
SDL_CameraID *devices = NULL;
|
||||
int devcount = 0;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_CAMERA) == -1) {
|
||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_CAMERA)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
if (SDL_CreateWindowAndRenderer("examples/camera/read-and-draw", 640, 480, 0, &window, &renderer) == -1) {
|
||||
if (!SDL_CreateWindowAndRenderer("examples/camera/read-and-draw", 640, 480, 0, &window, &renderer)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
@ -26,17 +26,11 @@ typedef struct
|
||||
|
||||
static Uint32 sdl_timer_callback_(void *payload, SDL_TimerID timer_id, Uint32 interval)
|
||||
{
|
||||
SDL_Event e;
|
||||
SDL_UserEvent ue;
|
||||
/* NOTE: snake_step is not called here directly for multithreaded concerns. */
|
||||
(void)payload;
|
||||
ue.type = SDL_EVENT_USER;
|
||||
ue.code = 0;
|
||||
ue.data1 = NULL;
|
||||
ue.data2 = NULL;
|
||||
e.type = SDL_EVENT_USER;
|
||||
e.user = ue;
|
||||
SDL_PushEvent(&e);
|
||||
SDL_Event event;
|
||||
SDL_zero(event);
|
||||
event.type = SDL_EVENT_USER;
|
||||
SDL_PushEvent(&event);
|
||||
return interval;
|
||||
}
|
||||
|
||||
@ -113,14 +107,14 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
|
||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER)) {
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
SDL_SetHint("SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR", "0");
|
||||
AppState *as = malloc(sizeof(AppState));
|
||||
*appstate = as;
|
||||
as->step_timer = 0;
|
||||
if (SDL_CreateWindowAndRenderer("examples/game/snake", SDL_WINDOW_WIDTH, SDL_WINDOW_HEIGHT, 0, &as->window, &as->renderer) == -1) {
|
||||
if (!SDL_CreateWindowAndRenderer("examples/game/snake", SDL_WINDOW_WIDTH, SDL_WINDOW_HEIGHT, 0, &as->window, &as->renderer)) {
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
snake_initialize(&as->snake_ctx, SDL_rand);
|
||||
|
@ -23,12 +23,12 @@ static float previous_touch_y = -1.0f;
|
||||
/* This function runs once at startup. */
|
||||
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
{
|
||||
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
if (SDL_CreateWindowAndRenderer("examples/pen/drawing-lines", 640, 480, 0, &window, &renderer) == -1) {
|
||||
if (!SDL_CreateWindowAndRenderer("examples/pen/drawing-lines", 640, 480, 0, &window, &renderer)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
@ -25,12 +25,12 @@ static int fade_direction = 1;
|
||||
/* This function runs once at startup. */
|
||||
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
{
|
||||
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
if (SDL_CreateWindowAndRenderer("examples/renderer/clear", 640, 480, 0, &window, &renderer) == -1) {
|
||||
if (!SDL_CreateWindowAndRenderer("examples/renderer/clear", 640, 480, 0, &window, &renderer)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
if (SDL_CreateWindowAndRenderer("examples/renderer/primitives", 640, 480, 0, &window, &renderer) == -1) {
|
||||
if (!SDL_CreateWindowAndRenderer("examples/renderer/primitives", 640, 480, 0, &window, &renderer)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
@ -16,12 +16,12 @@ static SDL_Renderer *renderer = NULL;
|
||||
/* This function runs once at startup. */
|
||||
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
{
|
||||
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
if (SDL_CreateWindowAndRenderer("examples/CATEGORY/NAME", 640, 480, 0, &window, &renderer) == -1) {
|
||||
if (!SDL_CreateWindowAndRenderer("examples/CATEGORY/NAME", 640, 480, 0, &window, &renderer)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
@ -531,14 +531,14 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetAudioDeviceName(SDL_AudioDeviceI
|
||||
* \param spec on return, will be filled with device details.
|
||||
* \param sample_frames pointer to store device buffer size, in sample frames.
|
||||
* Can be NULL.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetAudioDeviceFormat(SDL_AudioDeviceID devid, SDL_AudioSpec *spec, int *sample_frames);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetAudioDeviceFormat(SDL_AudioDeviceID devid, SDL_AudioSpec *spec, int *sample_frames);
|
||||
|
||||
/**
|
||||
* Get the current channel map of an audio device.
|
||||
@ -658,7 +658,7 @@ extern SDL_DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(SDL_AudioDevic
|
||||
* created through SDL_OpenAudioDevice() can be.
|
||||
*
|
||||
* \param dev a device opened by SDL_OpenAudioDevice().
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -668,7 +668,7 @@ extern SDL_DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(SDL_AudioDevic
|
||||
* \sa SDL_ResumeAudioDevice
|
||||
* \sa SDL_AudioDevicePaused
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev);
|
||||
|
||||
/**
|
||||
* Use this function to unpause audio playback on a specified device.
|
||||
@ -686,7 +686,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev);
|
||||
* created through SDL_OpenAudioDevice() can be.
|
||||
*
|
||||
* \param dev a device opened by SDL_OpenAudioDevice().
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -696,7 +696,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev);
|
||||
* \sa SDL_AudioDevicePaused
|
||||
* \sa SDL_PauseAudioDevice
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ResumeAudioDevice(SDL_AudioDeviceID dev);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ResumeAudioDevice(SDL_AudioDeviceID dev);
|
||||
|
||||
/**
|
||||
* Use this function to query if an audio device is paused.
|
||||
@ -766,7 +766,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetAudioDeviceGain(SDL_AudioDeviceID devid
|
||||
*
|
||||
* \param devid the audio device on which to change gain.
|
||||
* \param gain the gain. 1.0f is no change, 0.0f is silence.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, as it holds
|
||||
@ -776,7 +776,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetAudioDeviceGain(SDL_AudioDeviceID devid
|
||||
*
|
||||
* \sa SDL_GetAudioDeviceGain
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetAudioDeviceGain(SDL_AudioDeviceID devid, float gain);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetAudioDeviceGain(SDL_AudioDeviceID devid, float gain);
|
||||
|
||||
/**
|
||||
* Close a previously-opened audio device.
|
||||
@ -823,7 +823,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID devid);
|
||||
* \param devid an audio device to bind a stream to.
|
||||
* \param streams an array of audio streams to bind.
|
||||
* \param num_streams number streams listed in the `streams` array.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -834,7 +834,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID devid);
|
||||
* \sa SDL_UnbindAudioStream
|
||||
* \sa SDL_GetAudioStreamDevice
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int num_streams);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int num_streams);
|
||||
|
||||
/**
|
||||
* Bind a single audio stream to an audio device.
|
||||
@ -844,7 +844,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BindAudioStreams(SDL_AudioDeviceID devid, SD
|
||||
*
|
||||
* \param devid an audio device to bind a stream to.
|
||||
* \param stream an audio stream to bind to a device.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -855,7 +855,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BindAudioStreams(SDL_AudioDeviceID devid, SD
|
||||
* \sa SDL_UnbindAudioStream
|
||||
* \sa SDL_GetAudioStreamDevice
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_BindAudioStream(SDL_AudioDeviceID devid, SDL_AudioStream *stream);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_BindAudioStream(SDL_AudioDeviceID devid, SDL_AudioStream *stream);
|
||||
|
||||
/**
|
||||
* Unbind a list of audio streams from their audio devices.
|
||||
@ -952,7 +952,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetAudioStreamProperties(SDL_Au
|
||||
* \param stream the SDL_AudioStream to query.
|
||||
* \param src_spec where to store the input audio format; ignored if NULL.
|
||||
* \param dst_spec where to store the output audio format; ignored if NULL.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, as it holds
|
||||
@ -962,9 +962,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetAudioStreamProperties(SDL_Au
|
||||
*
|
||||
* \sa SDL_SetAudioStreamFormat
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamFormat(SDL_AudioStream *stream,
|
||||
SDL_AudioSpec *src_spec,
|
||||
SDL_AudioSpec *dst_spec);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetAudioStreamFormat(SDL_AudioStream *stream, SDL_AudioSpec *src_spec, SDL_AudioSpec *dst_spec);
|
||||
|
||||
/**
|
||||
* Change the input and output formats of an audio stream.
|
||||
@ -984,7 +982,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamFormat(SDL_AudioStream *stream
|
||||
* changed.
|
||||
* \param dst_spec the new format of the audio output; if NULL, it is not
|
||||
* changed.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, as it holds
|
||||
@ -995,9 +993,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamFormat(SDL_AudioStream *stream
|
||||
* \sa SDL_GetAudioStreamFormat
|
||||
* \sa SDL_SetAudioStreamFrequencyRatio
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamFormat(SDL_AudioStream *stream,
|
||||
const SDL_AudioSpec *src_spec,
|
||||
const SDL_AudioSpec *dst_spec);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetAudioStreamFormat(SDL_AudioStream *stream, const SDL_AudioSpec *src_spec, const SDL_AudioSpec *dst_spec);
|
||||
|
||||
/**
|
||||
* Get the frequency ratio of an audio stream.
|
||||
@ -1030,7 +1026,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetAudioStreamFrequencyRatio(SDL_AudioStre
|
||||
* \param stream the stream the frequency ratio is being changed.
|
||||
* \param ratio the frequency ratio. 1.0 is normal speed. Must be between 0.01
|
||||
* and 100.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, as it holds
|
||||
@ -1041,7 +1037,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetAudioStreamFrequencyRatio(SDL_AudioStre
|
||||
* \sa SDL_GetAudioStreamFrequencyRatio
|
||||
* \sa SDL_SetAudioStreamFormat
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamFrequencyRatio(SDL_AudioStream *stream, float ratio);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetAudioStreamFrequencyRatio(SDL_AudioStream *stream, float ratio);
|
||||
|
||||
/**
|
||||
* Get the gain of an audio stream.
|
||||
@ -1077,7 +1073,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetAudioStreamGain(SDL_AudioStream *stream
|
||||
*
|
||||
* \param stream the stream on which the gain is being changed.
|
||||
* \param gain the gain. 1.0f is no change, 0.0f is silence.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, as it holds
|
||||
@ -1087,7 +1083,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetAudioStreamGain(SDL_AudioStream *stream
|
||||
*
|
||||
* \sa SDL_GetAudioStreamGain
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamGain(SDL_AudioStream *stream, float gain);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetAudioStreamGain(SDL_AudioStream *stream, float gain);
|
||||
|
||||
/**
|
||||
* Get the current input channel map of an audio stream.
|
||||
@ -1174,7 +1170,7 @@ extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioStreamOutputChannelMap(SDL_AudioSt
|
||||
* \param stream the SDL_AudioStream to change.
|
||||
* \param chmap the new channel map, NULL to reset to default.
|
||||
* \param count The number of channels in the map.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, as it holds
|
||||
@ -1186,7 +1182,7 @@ extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioStreamOutputChannelMap(SDL_AudioSt
|
||||
*
|
||||
* \sa SDL_SetAudioStreamInputChannelMap
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamInputChannelMap(SDL_AudioStream *stream, const int *chmap, int count);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetAudioStreamInputChannelMap(SDL_AudioStream *stream, const int *chmap, int count);
|
||||
|
||||
/**
|
||||
* Set the current output channel map of an audio stream.
|
||||
@ -1221,7 +1217,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamInputChannelMap(SDL_AudioStrea
|
||||
* \param stream the SDL_AudioStream to change.
|
||||
* \param chmap the new channel map, NULL to reset to default.
|
||||
* \param count The number of channels in the map.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, as it holds
|
||||
@ -1233,7 +1229,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamInputChannelMap(SDL_AudioStrea
|
||||
*
|
||||
* \sa SDL_SetAudioStreamInputChannelMap
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamOutputChannelMap(SDL_AudioStream *stream, const int *chmap, int count);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetAudioStreamOutputChannelMap(SDL_AudioStream *stream, const int *chmap, int count);
|
||||
|
||||
/**
|
||||
* Add data to the stream.
|
||||
@ -1249,7 +1245,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamOutputChannelMap(SDL_AudioStre
|
||||
* \param stream the stream the audio data is being added to.
|
||||
* \param buf a pointer to the audio data to add.
|
||||
* \param len the number of bytes to write to the stream.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, but if the
|
||||
@ -1263,7 +1259,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamOutputChannelMap(SDL_AudioStre
|
||||
* \sa SDL_GetAudioStreamData
|
||||
* \sa SDL_GetAudioStreamQueued
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len);
|
||||
|
||||
/**
|
||||
* Get converted/resampled data from the stream.
|
||||
@ -1280,7 +1276,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_PutAudioStreamData(SDL_AudioStream *stream,
|
||||
* \param stream the stream the audio is being requested from.
|
||||
* \param buf a buffer to fill with audio data.
|
||||
* \param len the maximum number of bytes to fill.
|
||||
* \returns the number of bytes read from the stream or a negative error code
|
||||
* \returns the number of bytes read from the stream or -1
|
||||
* on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, but if the
|
||||
@ -1309,8 +1305,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamData(SDL_AudioStream *stream,
|
||||
* clamped.
|
||||
*
|
||||
* \param stream the audio stream to query.
|
||||
* \returns the number of converted/resampled bytes available or a negative
|
||||
* error code on failure; call SDL_GetError() for more information.
|
||||
* \returns the number of converted/resampled bytes available or -1 on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
@ -1342,7 +1337,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamAvailable(SDL_AudioStream *str
|
||||
* clamped.
|
||||
*
|
||||
* \param stream the audio stream to query.
|
||||
* \returns the number of bytes queued or a negative error code on failure;
|
||||
* \returns the number of bytes queued or -1 on failure;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -1364,7 +1359,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamQueued(SDL_AudioStream *stream
|
||||
* input, so the complete output becomes available.
|
||||
*
|
||||
* \param stream the audio stream to flush.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -1373,7 +1368,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamQueued(SDL_AudioStream *stream
|
||||
*
|
||||
* \sa SDL_PutAudioStreamData
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_FlushAudioStream(SDL_AudioStream *stream);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_FlushAudioStream(SDL_AudioStream *stream);
|
||||
|
||||
/**
|
||||
* Clear any pending data in the stream.
|
||||
@ -1382,7 +1377,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_FlushAudioStream(SDL_AudioStream *stream);
|
||||
* stream until more is added.
|
||||
*
|
||||
* \param stream the audio stream to clear.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -1394,7 +1389,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_FlushAudioStream(SDL_AudioStream *stream);
|
||||
* \sa SDL_GetAudioStreamQueued
|
||||
* \sa SDL_PutAudioStreamData
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ClearAudioStream(SDL_AudioStream *stream);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ClearAudioStream(SDL_AudioStream *stream);
|
||||
|
||||
/**
|
||||
* Use this function to pause audio playback on the audio device associated
|
||||
@ -1409,7 +1404,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_ClearAudioStream(SDL_AudioStream *stream);
|
||||
* loading, etc.
|
||||
*
|
||||
* \param stream the audio stream associated with the audio device to pause.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -1418,7 +1413,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_ClearAudioStream(SDL_AudioStream *stream);
|
||||
*
|
||||
* \sa SDL_ResumeAudioStreamDevice
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_PauseAudioStreamDevice(SDL_AudioStream *stream);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_PauseAudioStreamDevice(SDL_AudioStream *stream);
|
||||
|
||||
/**
|
||||
* Use this function to unpause audio playback on the audio device associated
|
||||
@ -1429,7 +1424,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_PauseAudioStreamDevice(SDL_AudioStream *stre
|
||||
* to progress again, and audio can be generated.
|
||||
*
|
||||
* \param stream the audio stream associated with the audio device to resume.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -1438,7 +1433,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_PauseAudioStreamDevice(SDL_AudioStream *stre
|
||||
*
|
||||
* \sa SDL_PauseAudioStreamDevice
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ResumeAudioStreamDevice(SDL_AudioStream *stream);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ResumeAudioStreamDevice(SDL_AudioStream *stream);
|
||||
|
||||
/**
|
||||
* Lock an audio stream for serialized access.
|
||||
@ -1457,7 +1452,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_ResumeAudioStreamDevice(SDL_AudioStream *str
|
||||
* all the same attributes (recursive locks are allowed, etc).
|
||||
*
|
||||
* \param stream the audio stream to lock.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -1466,7 +1461,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_ResumeAudioStreamDevice(SDL_AudioStream *str
|
||||
*
|
||||
* \sa SDL_UnlockAudioStream
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_LockAudioStream(SDL_AudioStream *stream);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_LockAudioStream(SDL_AudioStream *stream);
|
||||
|
||||
|
||||
/**
|
||||
@ -1475,7 +1470,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_LockAudioStream(SDL_AudioStream *stream);
|
||||
* This unlocks an audio stream after a call to SDL_LockAudioStream.
|
||||
*
|
||||
* \param stream the audio stream to unlock.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety You should only call this from the same thread that
|
||||
@ -1485,7 +1480,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_LockAudioStream(SDL_AudioStream *stream);
|
||||
*
|
||||
* \sa SDL_LockAudioStream
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_UnlockAudioStream(SDL_AudioStream *stream);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_UnlockAudioStream(SDL_AudioStream *stream);
|
||||
|
||||
/**
|
||||
* A callback that fires when data passes through an SDL_AudioStream.
|
||||
@ -1564,7 +1559,7 @@ typedef void (SDLCALL *SDL_AudioStreamCallback)(void *userdata, SDL_AudioStream
|
||||
* stream.
|
||||
* \param userdata an opaque pointer provided to the callback for its own
|
||||
* personal use.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information. This only fails if `stream`
|
||||
* is NULL.
|
||||
*
|
||||
@ -1574,7 +1569,7 @@ typedef void (SDLCALL *SDL_AudioStreamCallback)(void *userdata, SDL_AudioStream
|
||||
*
|
||||
* \sa SDL_SetAudioStreamPutCallback
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamGetCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetAudioStreamGetCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata);
|
||||
|
||||
/**
|
||||
* Set a callback that runs when data is added to an audio stream.
|
||||
@ -1614,7 +1609,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamGetCallback(SDL_AudioStream *s
|
||||
* stream.
|
||||
* \param userdata an opaque pointer provided to the callback for its own
|
||||
* personal use.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information. This only fails if `stream`
|
||||
* is NULL.
|
||||
*
|
||||
@ -1624,7 +1619,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamGetCallback(SDL_AudioStream *s
|
||||
*
|
||||
* \sa SDL_SetAudioStreamGetCallback
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamPutCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetAudioStreamPutCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata);
|
||||
|
||||
|
||||
/**
|
||||
@ -1793,14 +1788,14 @@ typedef void (SDLCALL *SDL_AudioPostmixCallback)(void *userdata, const SDL_Audio
|
||||
* \param devid the ID of an opened audio device.
|
||||
* \param callback a callback function to be called. Can be NULL.
|
||||
* \param userdata app-controlled pointer passed to callback. Can be NULL.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallback callback, void *userdata);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallback callback, void *userdata);
|
||||
|
||||
|
||||
/**
|
||||
@ -1863,11 +1858,11 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetAudioPostmixCallback(SDL_AudioDeviceID de
|
||||
* function.
|
||||
* \param audio_len a pointer filled with the length of the audio data buffer
|
||||
* in bytes.
|
||||
* \returns 0 on success. `audio_buf` will be filled with a pointer to an
|
||||
* \returns SDL_TRUE on success. `audio_buf` will be filled with a pointer to an
|
||||
* allocated buffer containing the audio data, and `audio_len` is
|
||||
* filled with the length of that audio buffer in bytes.
|
||||
*
|
||||
* This function returns -1 if the .WAV file cannot be opened, uses
|
||||
* This function returns SDL_FALSE if the .WAV file cannot be opened, uses
|
||||
* an unknown data format, or is corrupt; call SDL_GetError() for
|
||||
* more information.
|
||||
*
|
||||
@ -1881,9 +1876,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetAudioPostmixCallback(SDL_AudioDeviceID de
|
||||
* \sa SDL_free
|
||||
* \sa SDL_LoadWAV
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_LoadWAV_IO(SDL_IOStream * src, SDL_bool closeio,
|
||||
SDL_AudioSpec * spec, Uint8 ** audio_buf,
|
||||
Uint32 * audio_len);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_LoadWAV_IO(SDL_IOStream *src, SDL_bool closeio, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
|
||||
|
||||
/**
|
||||
* Loads a WAV from a file path.
|
||||
@ -1891,7 +1884,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_LoadWAV_IO(SDL_IOStream * src, SDL_bool clos
|
||||
* This is a convenience function that is effectively the same as:
|
||||
*
|
||||
* ```c
|
||||
* SDL_LoadWAV_IO(SDL_IOFromFile(path, "rb"), 1, spec, audio_buf, audio_len);
|
||||
* SDL_LoadWAV_IO(SDL_IOFromFile(path, "rb"), SDL_TRUE, spec, audio_buf, audio_len);
|
||||
* ```
|
||||
*
|
||||
* \param path the file path of the WAV file to open.
|
||||
@ -1901,11 +1894,11 @@ extern SDL_DECLSPEC int SDLCALL SDL_LoadWAV_IO(SDL_IOStream * src, SDL_bool clos
|
||||
* function.
|
||||
* \param audio_len a pointer filled with the length of the audio data buffer
|
||||
* in bytes.
|
||||
* \returns 0 on success. `audio_buf` will be filled with a pointer to an
|
||||
* \returns SDL_TRUE on success. `audio_buf` will be filled with a pointer to an
|
||||
* allocated buffer containing the audio data, and `audio_len` is
|
||||
* filled with the length of that audio buffer in bytes.
|
||||
*
|
||||
* This function returns -1 if the .WAV file cannot be opened, uses
|
||||
* This function returns SDL_FALSE if the .WAV file cannot be opened, uses
|
||||
* an unknown data format, or is corrupt; call SDL_GetError() for
|
||||
* more information.
|
||||
*
|
||||
@ -1919,8 +1912,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_LoadWAV_IO(SDL_IOStream * src, SDL_bool clos
|
||||
* \sa SDL_free
|
||||
* \sa SDL_LoadWAV_IO
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_LoadWAV(const char *path, SDL_AudioSpec * spec,
|
||||
Uint8 ** audio_buf, Uint32 * audio_len);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_LoadWAV(const char *path, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
|
||||
|
||||
/**
|
||||
* Mix audio data in a specified format.
|
||||
@ -1949,17 +1941,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_LoadWAV(const char *path, SDL_AudioSpec * sp
|
||||
* \param len the length of the audio buffer in bytes.
|
||||
* \param volume ranges from 0.0 - 1.0, and should be set to 1.0 for full
|
||||
* audio volume.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_MixAudio(Uint8 * dst,
|
||||
const Uint8 * src,
|
||||
SDL_AudioFormat format,
|
||||
Uint32 len, float volume);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format, Uint32 len, float volume);
|
||||
|
||||
/**
|
||||
* Convert some audio data of one format to another format.
|
||||
@ -1982,19 +1971,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_MixAudio(Uint8 * dst,
|
||||
* which should be freed with SDL_free(). On error, it will be
|
||||
* NULL.
|
||||
* \param dst_len will be filled with the len of dst_data.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ConvertAudioSamples(const SDL_AudioSpec *src_spec,
|
||||
const Uint8 *src_data,
|
||||
int src_len,
|
||||
const SDL_AudioSpec *dst_spec,
|
||||
Uint8 **dst_data,
|
||||
int *dst_len);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ConvertAudioSamples(const SDL_AudioSpec *src_spec, const Uint8 *src_data, int src_len, const SDL_AudioSpec *dst_spec, Uint8 **dst_data, int *dst_len);
|
||||
|
||||
/**
|
||||
* Get the human readable name of an audio format.
|
||||
|
@ -366,14 +366,14 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetCameraProperties(SDL_Camera
|
||||
* be converting to this format behind the scenes.
|
||||
*
|
||||
* If the system is waiting for the user to approve access to the camera, as
|
||||
* some platforms require, this will return -1, but this isn't necessarily a
|
||||
* some platforms require, this will return SDL_FALSE, but this isn't necessarily a
|
||||
* fatal error; you should either wait for an SDL_EVENT_CAMERA_DEVICE_APPROVED
|
||||
* (or SDL_EVENT_CAMERA_DEVICE_DENIED) event, or poll SDL_IsCameraApproved()
|
||||
* occasionally until it returns non-zero.
|
||||
*
|
||||
* \param camera opened camera device.
|
||||
* \param spec the SDL_CameraSpec to be initialized by this function.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -382,7 +382,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetCameraProperties(SDL_Camera
|
||||
*
|
||||
* \sa SDL_OpenCamera
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec);
|
||||
|
||||
/**
|
||||
* Acquire a frame.
|
||||
@ -446,8 +446,6 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_AcquireCameraFrame(SDL_Camera *cam
|
||||
*
|
||||
* \param camera opened camera device.
|
||||
* \param frame the video frame surface to release.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
@ -455,7 +453,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_AcquireCameraFrame(SDL_Camera *cam
|
||||
*
|
||||
* \sa SDL_AcquireCameraFrame
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ReleaseCameraFrame(SDL_Camera *camera, SDL_Surface *frame);
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_ReleaseCameraFrame(SDL_Camera *camera, SDL_Surface *frame);
|
||||
|
||||
/**
|
||||
* Use this function to shut down camera processing and close the camera
|
||||
|
@ -46,7 +46,7 @@ extern "C" {
|
||||
* Put UTF-8 text into the clipboard.
|
||||
*
|
||||
* \param text the text to store in the clipboard.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -54,7 +54,7 @@ extern "C" {
|
||||
* \sa SDL_GetClipboardText
|
||||
* \sa SDL_HasClipboardText
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetClipboardText(const char *text);
|
||||
|
||||
/**
|
||||
* Get UTF-8 text from the clipboard.
|
||||
@ -89,7 +89,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void);
|
||||
* Put UTF-8 text into the primary selection.
|
||||
*
|
||||
* \param text the text to store in the primary selection.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -97,7 +97,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void);
|
||||
* \sa SDL_GetPrimarySelectionText
|
||||
* \sa SDL_HasPrimarySelectionText
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetPrimarySelectionText(const char *text);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetPrimarySelectionText(const char *text);
|
||||
|
||||
/**
|
||||
* Get UTF-8 text from the primary selection.
|
||||
@ -185,7 +185,7 @@ typedef void (SDLCALL *SDL_ClipboardCleanupCallback)(void *userdata);
|
||||
* \param userdata an opaque pointer that will be forwarded to the callbacks.
|
||||
* \param mime_types a list of mime-types that are being offered.
|
||||
* \param num_mime_types the number of mime-types in the mime_types list.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -194,19 +194,19 @@ typedef void (SDLCALL *SDL_ClipboardCleanupCallback)(void *userdata);
|
||||
* \sa SDL_GetClipboardData
|
||||
* \sa SDL_HasClipboardData
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetClipboardData(SDL_ClipboardDataCallback callback, SDL_ClipboardCleanupCallback cleanup, void *userdata, const char **mime_types, size_t num_mime_types);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetClipboardData(SDL_ClipboardDataCallback callback, SDL_ClipboardCleanupCallback cleanup, void *userdata, const char **mime_types, size_t num_mime_types);
|
||||
|
||||
/**
|
||||
* Clear the clipboard data.
|
||||
*
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetClipboardData
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ClearClipboardData(void);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ClearClipboardData(void);
|
||||
|
||||
/**
|
||||
* Get the data from clipboard for a given mime type.
|
||||
|
@ -56,25 +56,25 @@ extern "C" {
|
||||
* \param fmt a printf()-style message format string.
|
||||
* \param ... additional parameters matching % tokens in the `fmt` string, if
|
||||
* any.
|
||||
* \returns -1.
|
||||
* \returns SDL_FALSE.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_ClearError
|
||||
* \sa SDL_GetError
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
|
||||
|
||||
/**
|
||||
* Set an error indicating that memory allocation failed.
|
||||
*
|
||||
* This function does not do any memory allocation.
|
||||
*
|
||||
* \returns -1.
|
||||
* \returns SDL_FALSE.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_OutOfMemory(void);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_OutOfMemory(void);
|
||||
|
||||
/**
|
||||
* Retrieve a message about the last error that occurred on the current
|
||||
@ -114,14 +114,14 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetError(void);
|
||||
/**
|
||||
* Clear any previous error message for this thread.
|
||||
*
|
||||
* \returns 0.
|
||||
* \returns SDL_TRUE.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetError
|
||||
* \sa SDL_SetError
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ClearError(void);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ClearError(void);
|
||||
|
||||
/**
|
||||
* \name Internal error functions
|
||||
|
@ -1039,7 +1039,7 @@ typedef enum SDL_EventAction
|
||||
* SDL_EVENT_FIRST is a safe choice.
|
||||
* \param maxType maximum value of the event type to be considered;
|
||||
* SDL_EVENT_LAST is a safe choice.
|
||||
* \returns the number of events actually stored or a negative error code on
|
||||
* \returns the number of events actually stored or -1 on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1254,8 +1254,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WaitEventTimeout(SDL_Event *event, Sint
|
||||
* its own custom event types.
|
||||
*
|
||||
* \param event the SDL_Event to be added to the queue.
|
||||
* \returns 1 on success, 0 if the event was filtered, or a negative error
|
||||
* code on failure; call SDL_GetError() for more information. A
|
||||
* \returns SDL_TRUE on success, SDL_FALSE if the event was filtered or on failure; call SDL_GetError() for more information. A
|
||||
* common reason for error is the event queue being full.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1264,7 +1263,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WaitEventTimeout(SDL_Event *event, Sint
|
||||
* \sa SDL_PollEvent
|
||||
* \sa SDL_RegisterEvents
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_PushEvent(SDL_Event *event);
|
||||
|
||||
/**
|
||||
* A function pointer used for callbacks that watch the event queue.
|
||||
@ -1372,7 +1371,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter *filter,
|
||||
*
|
||||
* \param filter an SDL_EventFilter function to call when an event happens.
|
||||
* \param userdata a pointer that is passed to `filter`.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -1382,7 +1381,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter *filter,
|
||||
* \sa SDL_DelEventWatch
|
||||
* \sa SDL_SetEventFilter
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, void *userdata);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, void *userdata);
|
||||
|
||||
/**
|
||||
* Remove an event watch callback added with SDL_AddEventWatch().
|
||||
|
@ -266,12 +266,12 @@ typedef Uint32 SDL_GlobFlags;
|
||||
* Create a directory.
|
||||
*
|
||||
* \param path the path of the directory to create.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_CreateDirectory(const char *path);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_CreateDirectory(const char *path);
|
||||
|
||||
/* Callback for directory enumeration. Return 1 to keep enumerating,
|
||||
0 to stop enumerating (no error), -1 to stop enumerating and
|
||||
@ -289,47 +289,47 @@ typedef int (SDLCALL *SDL_EnumerateDirectoryCallback)(void *userdata, const char
|
||||
* \param path the path of the directory to enumerate.
|
||||
* \param callback a function that is called for each entry in the directory.
|
||||
* \param userdata a pointer that is passed to `callback`.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata);
|
||||
|
||||
/**
|
||||
* Remove a file or an empty directory.
|
||||
*
|
||||
* \param path the path of the directory to enumerate.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_RemovePath(const char *path);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RemovePath(const char *path);
|
||||
|
||||
/**
|
||||
* Rename a file or directory.
|
||||
*
|
||||
* \param oldpath the old path.
|
||||
* \param newpath the new path.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_RenamePath(const char *oldpath, const char *newpath);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RenamePath(const char *oldpath, const char *newpath);
|
||||
|
||||
/**
|
||||
* Copy a file.
|
||||
*
|
||||
* \param oldpath the old path.
|
||||
* \param newpath the new path.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_CopyFile(const char *oldpath, const char *newpath);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_CopyFile(const char *oldpath, const char *newpath);
|
||||
|
||||
/**
|
||||
* Get information about a filesystem path.
|
||||
@ -337,12 +337,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_CopyFile(const char *oldpath, const char *ne
|
||||
* \param path the path to query.
|
||||
* \param info a pointer filled in with information about the path, or NULL to
|
||||
* check for the existence of a file.
|
||||
* \returns 0 on success or a negative error code if the file doesn't exist,
|
||||
* \returns SDL_TRUE on success or SDL_FALSE if the file doesn't exist,
|
||||
* or another failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetPathInfo(const char *path, SDL_PathInfo *info);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetPathInfo(const char *path, SDL_PathInfo *info);
|
||||
|
||||
/**
|
||||
* Enumerate a directory tree, filtered by pattern, and return a list.
|
||||
|
@ -379,12 +379,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file)
|
||||
*
|
||||
* This will generate gamepad events as needed if device mappings change.
|
||||
*
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ReloadGamepadMappings(void);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ReloadGamepadMappings(void);
|
||||
|
||||
/**
|
||||
* Get the current gamepad mappings.
|
||||
@ -442,7 +442,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad);
|
||||
* \param instance_id the joystick instance ID.
|
||||
* \param mapping the mapping to use for this device, or NULL to clear the
|
||||
* mapping.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -450,7 +450,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad);
|
||||
* \sa SDL_AddGamepadMapping
|
||||
* \sa SDL_GetGamepadMapping
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping);
|
||||
|
||||
/**
|
||||
* Return whether a gamepad is currently connected.
|
||||
@ -813,14 +813,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad);
|
||||
* \param gamepad the gamepad object to adjust.
|
||||
* \param player_index player index to assign to this gamepad, or -1 to clear
|
||||
* the player index and turn off player LEDs.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetGamepadPlayerIndex
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index);
|
||||
|
||||
/**
|
||||
* Get the USB vendor ID of an opened gamepad, if available.
|
||||
@ -1257,14 +1257,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *ga
|
||||
* \param y filled with y position, normalized 0 to 1, with the origin in the
|
||||
* upper left.
|
||||
* \param pressure filled with pressure value.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetNumGamepadTouchpadFingers
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
|
||||
|
||||
/**
|
||||
* Return whether a gamepad has a particular sensor.
|
||||
@ -1287,7 +1287,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad,
|
||||
* \param gamepad the gamepad to update.
|
||||
* \param type the type of sensor to enable/disable.
|
||||
* \param enabled whether data reporting should be enabled.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1295,7 +1295,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad,
|
||||
* \sa SDL_GamepadHasSensor
|
||||
* \sa SDL_GamepadSensorEnabled
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, SDL_bool enabled);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, SDL_bool enabled);
|
||||
|
||||
/**
|
||||
* Query whether sensor data reporting is enabled for a gamepad.
|
||||
@ -1331,12 +1331,12 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *game
|
||||
* \param type the type of sensor to query.
|
||||
* \param data a pointer filled with the current sensor state.
|
||||
* \param num_values the number of values to write to data.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values);
|
||||
|
||||
/**
|
||||
* Start a rumble effect on a gamepad.
|
||||
@ -1353,11 +1353,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, S
|
||||
* \param high_frequency_rumble the intensity of the high frequency (right)
|
||||
* rumble motor, from 0 to 0xFFFF.
|
||||
* \param duration_ms the duration of the rumble effect, in milliseconds.
|
||||
* \returns 0, or -1 if rumble isn't supported on this gamepad.
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
|
||||
|
||||
/**
|
||||
* Start a rumble effect in the gamepad's triggers.
|
||||
@ -1378,14 +1379,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 l
|
||||
* \param right_rumble the intensity of the right trigger rumble motor, from 0
|
||||
* to 0xFFFF.
|
||||
* \param duration_ms the duration of the rumble effect, in milliseconds.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_RumbleGamepad
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
|
||||
|
||||
/**
|
||||
* Update a gamepad's LED color.
|
||||
@ -1400,12 +1401,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad,
|
||||
* \param red the intensity of the red LED.
|
||||
* \param green the intensity of the green LED.
|
||||
* \param blue the intensity of the blue LED.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue);
|
||||
|
||||
/**
|
||||
* Send a gamepad specific effect packet.
|
||||
@ -1413,12 +1414,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 re
|
||||
* \param gamepad the gamepad to affect.
|
||||
* \param data the data to send to the gamepad.
|
||||
* \param size the size of the data to send to the gamepad.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size);
|
||||
|
||||
/**
|
||||
* Close a gamepad previously opened with SDL_OpenGamepad().
|
||||
|
@ -48,15 +48,15 @@
|
||||
* SDL_free(haptics);
|
||||
* }
|
||||
* if (haptic == NULL)
|
||||
* return -1;
|
||||
* return;
|
||||
*
|
||||
* // Initialize simple rumble
|
||||
* if (SDL_InitHapticRumble(haptic) != 0)
|
||||
* return -1;
|
||||
* if (!SDL_InitHapticRumble(haptic))
|
||||
* return;
|
||||
*
|
||||
* // Play effect at 50% strength for 2 seconds
|
||||
* if (SDL_PlayHapticRumble(haptic, 0.5, 2000) != 0)
|
||||
* return -1;
|
||||
* if (!SDL_PlayHapticRumble(haptic, 0.5, 2000))
|
||||
* return;
|
||||
* SDL_Delay(2000);
|
||||
*
|
||||
* // Clean up
|
||||
@ -66,7 +66,7 @@
|
||||
* Complete example:
|
||||
*
|
||||
* ```c
|
||||
* int test_haptic(SDL_Joystick *joystick)
|
||||
* SDL_bool test_haptic(SDL_Joystick *joystick)
|
||||
* {
|
||||
* SDL_Haptic *haptic;
|
||||
* SDL_HapticEffect effect;
|
||||
@ -74,12 +74,12 @@
|
||||
*
|
||||
* // Open the device
|
||||
* haptic = SDL_OpenHapticFromJoystick(joystick);
|
||||
* if (haptic == NULL) return -1; // Most likely joystick isn't haptic
|
||||
* if (haptic == NULL) return SDL_FALSE; // Most likely joystick isn't haptic
|
||||
*
|
||||
* // See if it can do sine waves
|
||||
* if ((SDL_GetHapticFeatures(haptic) & SDL_HAPTIC_SINE)==0) {
|
||||
* SDL_CloseHaptic(haptic); // No sine effect
|
||||
* return -1;
|
||||
* return SDL_FALSE;
|
||||
* }
|
||||
*
|
||||
* // Create the effect
|
||||
@ -106,7 +106,7 @@
|
||||
* // Close the device
|
||||
* SDL_CloseHaptic(haptic);
|
||||
*
|
||||
* return 0; // Success
|
||||
* return SDL_TRUE; // Success
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
@ -1116,7 +1116,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetMaxHapticEffects(SDL_Haptic *haptic);
|
||||
*
|
||||
* \param haptic the SDL_Haptic device to query maximum playing effects.
|
||||
* \returns the number of effects the haptic device can play at the same time
|
||||
* or a negative error code on failure; call SDL_GetError() for more
|
||||
* or -1 on failure; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1147,7 +1147,7 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetHapticFeatures(SDL_Haptic *haptic);
|
||||
* SDL_HapticDirection effect.
|
||||
*
|
||||
* \param haptic the SDL_Haptic device to query.
|
||||
* \returns the number of axes on success or a negative error code on failure;
|
||||
* \returns the number of axes on success or -1 on failure;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1174,7 +1174,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HapticEffectSupported(SDL_Haptic *hapti
|
||||
* \param haptic an SDL_Haptic device to create the effect on.
|
||||
* \param effect an SDL_HapticEffect structure containing the properties of
|
||||
* the effect to create.
|
||||
* \returns the ID of the effect on success or a negative error code on
|
||||
* \returns the ID of the effect on success or -1 on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1197,7 +1197,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_CreateHapticEffect(SDL_Haptic *haptic, const
|
||||
* \param effect the identifier of the effect to update.
|
||||
* \param data an SDL_HapticEffect structure containing the new effect
|
||||
* properties to use.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1205,7 +1205,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_CreateHapticEffect(SDL_Haptic *haptic, const
|
||||
* \sa SDL_CreateHapticEffect
|
||||
* \sa SDL_RunHapticEffect
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_UpdateHapticEffect(SDL_Haptic *haptic, int effect, const SDL_HapticEffect *data);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_UpdateHapticEffect(SDL_Haptic *haptic, int effect, const SDL_HapticEffect *data);
|
||||
|
||||
/**
|
||||
* Run the haptic effect on its associated haptic device.
|
||||
@ -1220,7 +1220,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_UpdateHapticEffect(SDL_Haptic *haptic, int e
|
||||
* \param effect the ID of the haptic effect to run.
|
||||
* \param iterations the number of iterations to run the effect; use
|
||||
* `SDL_HAPTIC_INFINITY` to repeat forever.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1229,14 +1229,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_UpdateHapticEffect(SDL_Haptic *haptic, int e
|
||||
* \sa SDL_StopHapticEffect
|
||||
* \sa SDL_StopHapticEffects
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_RunHapticEffect(SDL_Haptic *haptic, int effect, Uint32 iterations);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RunHapticEffect(SDL_Haptic *haptic, int effect, Uint32 iterations);
|
||||
|
||||
/**
|
||||
* Stop the haptic effect on its associated haptic device.
|
||||
*
|
||||
* \param haptic the SDL_Haptic device to stop the effect on.
|
||||
* \param effect the ID of the haptic effect to stop.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1244,7 +1244,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_RunHapticEffect(SDL_Haptic *haptic, int effe
|
||||
* \sa SDL_RunHapticEffect
|
||||
* \sa SDL_StopHapticEffects
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_StopHapticEffect(SDL_Haptic *haptic, int effect);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_StopHapticEffect(SDL_Haptic *haptic, int effect);
|
||||
|
||||
/**
|
||||
* Destroy a haptic effect on the device.
|
||||
@ -1268,12 +1268,13 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroyHapticEffect(SDL_Haptic *haptic, int
|
||||
*
|
||||
* \param haptic the SDL_Haptic device to query for the effect status on.
|
||||
* \param effect the ID of the haptic effect to query its status.
|
||||
* \returns 0 if it isn't playing, 1 if it is playing, or a negative error
|
||||
* code on failure; call SDL_GetError() for more information.
|
||||
* \returns SDL_TRUE if it is playing, SDL_FALSE if it isn't playing or haptic status isn't supported.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetHapticFeatures
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetHapticEffectStatus(SDL_Haptic *haptic, int effect);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetHapticEffectStatus(SDL_Haptic *haptic, int effect);
|
||||
|
||||
/**
|
||||
* Set the global gain of the specified haptic device.
|
||||
@ -1288,14 +1289,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetHapticEffectStatus(SDL_Haptic *haptic, in
|
||||
* \param haptic the SDL_Haptic device to set the gain on.
|
||||
* \param gain value to set the gain to, should be between 0 and 100 (0 -
|
||||
* 100).
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetHapticFeatures
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetHapticGain(SDL_Haptic *haptic, int gain);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetHapticGain(SDL_Haptic *haptic, int gain);
|
||||
|
||||
/**
|
||||
* Set the global autocenter of the device.
|
||||
@ -1307,14 +1308,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetHapticGain(SDL_Haptic *haptic, int gain);
|
||||
*
|
||||
* \param haptic the SDL_Haptic device to set autocentering on.
|
||||
* \param autocenter value to set autocenter to (0-100).
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetHapticFeatures
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetHapticAutocenter(SDL_Haptic *haptic, int autocenter);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetHapticAutocenter(SDL_Haptic *haptic, int autocenter);
|
||||
|
||||
/**
|
||||
* Pause a haptic device.
|
||||
@ -1326,14 +1327,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetHapticAutocenter(SDL_Haptic *haptic, int
|
||||
* can cause all sorts of weird errors.
|
||||
*
|
||||
* \param haptic the SDL_Haptic device to pause.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_ResumeHaptic
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_PauseHaptic(SDL_Haptic *haptic);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_PauseHaptic(SDL_Haptic *haptic);
|
||||
|
||||
/**
|
||||
* Resume a haptic device.
|
||||
@ -1341,20 +1342,20 @@ extern SDL_DECLSPEC int SDLCALL SDL_PauseHaptic(SDL_Haptic *haptic);
|
||||
* Call to unpause after SDL_PauseHaptic().
|
||||
*
|
||||
* \param haptic the SDL_Haptic device to unpause.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_PauseHaptic
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ResumeHaptic(SDL_Haptic *haptic);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ResumeHaptic(SDL_Haptic *haptic);
|
||||
|
||||
/**
|
||||
* Stop all the currently playing effects on a haptic device.
|
||||
*
|
||||
* \param haptic the SDL_Haptic device to stop.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1362,7 +1363,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_ResumeHaptic(SDL_Haptic *haptic);
|
||||
* \sa SDL_RunHapticEffect
|
||||
* \sa SDL_StopHapticEffects
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_StopHapticEffects(SDL_Haptic *haptic);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_StopHapticEffects(SDL_Haptic *haptic);
|
||||
|
||||
/**
|
||||
* Check whether rumble is supported on a haptic device.
|
||||
@ -1380,7 +1381,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HapticRumbleSupported(SDL_Haptic *hapti
|
||||
* Initialize a haptic device for simple rumble playback.
|
||||
*
|
||||
* \param haptic the haptic device to initialize for simple rumble playback.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1389,7 +1390,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HapticRumbleSupported(SDL_Haptic *hapti
|
||||
* \sa SDL_StopHapticRumble
|
||||
* \sa SDL_HapticRumbleSupported
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_InitHapticRumble(SDL_Haptic *haptic);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_InitHapticRumble(SDL_Haptic *haptic);
|
||||
|
||||
/**
|
||||
* Run a simple rumble effect on a haptic device.
|
||||
@ -1397,7 +1398,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_InitHapticRumble(SDL_Haptic *haptic);
|
||||
* \param haptic the haptic device to play the rumble effect on.
|
||||
* \param strength strength of the rumble to play as a 0-1 float value.
|
||||
* \param length length of the rumble to play in milliseconds.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1405,20 +1406,20 @@ extern SDL_DECLSPEC int SDLCALL SDL_InitHapticRumble(SDL_Haptic *haptic);
|
||||
* \sa SDL_InitHapticRumble
|
||||
* \sa SDL_StopHapticRumble
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_PlayHapticRumble(SDL_Haptic *haptic, float strength, Uint32 length);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_PlayHapticRumble(SDL_Haptic *haptic, float strength, Uint32 length);
|
||||
|
||||
/**
|
||||
* Stop the simple rumble on a haptic device.
|
||||
*
|
||||
* \param haptic the haptic device to stop the rumble effect on.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_PlayHapticRumble
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_StopHapticRumble(SDL_Haptic *haptic);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_StopHapticRumble(SDL_Haptic *haptic);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
@ -4168,7 +4168,7 @@ typedef enum SDL_HintPriority
|
||||
* \param name the hint to set.
|
||||
* \param value the value of the hint variable.
|
||||
* \param priority the SDL_HintPriority level for the hint.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -4179,9 +4179,7 @@ typedef enum SDL_HintPriority
|
||||
* \sa SDL_ResetHint
|
||||
* \sa SDL_SetHint
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetHintWithPriority(const char *name,
|
||||
const char *value,
|
||||
SDL_HintPriority priority);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPriority priority);
|
||||
|
||||
/**
|
||||
* Set a hint with normal priority.
|
||||
@ -4192,7 +4190,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetHintWithPriority(const char *name,
|
||||
*
|
||||
* \param name the hint to set.
|
||||
* \param value the value of the hint variable.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -4203,7 +4201,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetHintWithPriority(const char *name,
|
||||
* \sa SDL_ResetHint
|
||||
* \sa SDL_SetHintWithPriority
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetHint(const char *name, const char *value);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name, const char *value);
|
||||
|
||||
/**
|
||||
* Reset a hint to the default value.
|
||||
@ -4213,7 +4211,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetHint(const char *name, const char *value)
|
||||
* change.
|
||||
*
|
||||
* \param name the hint to set.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -4223,7 +4221,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetHint(const char *name, const char *value)
|
||||
* \sa SDL_SetHint
|
||||
* \sa SDL_ResetHints
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ResetHint(const char *name);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ResetHint(const char *name);
|
||||
|
||||
/**
|
||||
* Reset all hints to the default values.
|
||||
@ -4308,7 +4306,7 @@ typedef void (SDLCALL *SDL_HintCallback)(void *userdata, const char *name, const
|
||||
* \param callback An SDL_HintCallback function that will be called when the
|
||||
* hint value changes.
|
||||
* \param userdata a pointer to pass to the callback function.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -4317,9 +4315,7 @@ typedef void (SDLCALL *SDL_HintCallback)(void *userdata, const char *name, const
|
||||
*
|
||||
* \sa SDL_DelHintCallback
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_AddHintCallback(const char *name,
|
||||
SDL_HintCallback callback,
|
||||
void *userdata);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata);
|
||||
|
||||
/**
|
||||
* Remove a function watching a particular hint.
|
||||
|
@ -143,7 +143,7 @@ typedef void (SDLCALL *SDL_AppQuit_func)(void *appstate);
|
||||
* SDL_SetAppMetadataProperty().
|
||||
*
|
||||
* \param flags subsystem initialization flags.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -155,7 +155,7 @@ typedef void (SDLCALL *SDL_AppQuit_func)(void *appstate);
|
||||
* \sa SDL_SetMainReady
|
||||
* \sa SDL_WasInit
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_Init(SDL_InitFlags flags);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_Init(SDL_InitFlags flags);
|
||||
|
||||
/**
|
||||
* Compatibility function to initialize the SDL library.
|
||||
@ -163,7 +163,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_Init(SDL_InitFlags flags);
|
||||
* This function and SDL_Init() are interchangeable.
|
||||
*
|
||||
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -172,7 +172,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_Init(SDL_InitFlags flags);
|
||||
* \sa SDL_Quit
|
||||
* \sa SDL_QuitSubSystem
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_InitSubSystem(SDL_InitFlags flags);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_InitSubSystem(SDL_InitFlags flags);
|
||||
|
||||
/**
|
||||
* Shut down specific SDL subsystems.
|
||||
@ -248,7 +248,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_Quit(void);
|
||||
* hash, or whatever makes sense).
|
||||
* \param appidentifier A unique string in reverse-domain format that
|
||||
* identifies this app ("com.example.mygame2").
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -257,7 +257,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_Quit(void);
|
||||
*
|
||||
* \sa SDL_SetAppMetadataProperty
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetAppMetadata(const char *appname, const char *appversion, const char *appidentifier);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetAppMetadata(const char *appname, const char *appversion, const char *appidentifier);
|
||||
|
||||
/**
|
||||
* Specify metadata about your app through a set of properties.
|
||||
@ -310,7 +310,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetAppMetadata(const char *appname, const ch
|
||||
*
|
||||
* \param name the name of the metadata property to set.
|
||||
* \param value the value of the property, or NULL to remove that property.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -320,7 +320,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetAppMetadata(const char *appname, const ch
|
||||
* \sa SDL_GetAppMetadataProperty
|
||||
* \sa SDL_SetAppMetadata
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetAppMetadataProperty(const char *name, const char *value);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetAppMetadataProperty(const char *name, const char *value);
|
||||
|
||||
#define SDL_PROP_APP_METADATA_NAME_STRING "SDL.app.metadata.name"
|
||||
#define SDL_PROP_APP_METADATA_VERSION_STRING "SDL.app.metadata.version"
|
||||
|
@ -132,9 +132,10 @@ typedef struct SDL_IOStreamInterface
|
||||
* The SDL_IOStream is still destroyed even if this fails, so clean up anything
|
||||
* even if flushing to disk returns an error.
|
||||
*
|
||||
* \return 0 if successful or -1 on write error when flushing data.
|
||||
* \return SDL_TRUE if successful or SDL_FALSE on write error when flushing data.
|
||||
*/
|
||||
int (SDLCALL *close)(void *userdata);
|
||||
SDL_bool (SDLCALL *close)(void *userdata);
|
||||
|
||||
} SDL_IOStreamInterface;
|
||||
|
||||
|
||||
@ -371,21 +372,21 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_OpenIO(const SDL_IOStreamInterfac
|
||||
*
|
||||
* SDL_CloseIO() closes and cleans up the SDL_IOStream stream. It releases any
|
||||
* resources used by the stream and frees the SDL_IOStream itself. This
|
||||
* returns 0 on success, or -1 if the stream failed to flush to its output
|
||||
* returns SDL_TRUE on success, or SDL_FALSE if the stream failed to flush to its output
|
||||
* (e.g. to disk).
|
||||
*
|
||||
* Note that if this fails to flush the stream to disk, this function reports
|
||||
* an error, but the SDL_IOStream is still invalid once this function returns.
|
||||
*
|
||||
* \param context SDL_IOStream structure to close.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_OpenIO
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_CloseIO(SDL_IOStream *context);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_CloseIO(SDL_IOStream *context);
|
||||
|
||||
/**
|
||||
* Get the properties associated with an SDL_IOStream.
|
||||
|
@ -446,11 +446,11 @@ typedef struct SDL_VirtualJoystickDesc
|
||||
void *userdata; /**< User data pointer passed to callbacks */
|
||||
void (SDLCALL *Update)(void *userdata); /**< Called when the joystick state should be updated */
|
||||
void (SDLCALL *SetPlayerIndex)(void *userdata, int player_index); /**< Called when the player index is set */
|
||||
int (SDLCALL *Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); /**< Implements SDL_RumbleJoystick() */
|
||||
int (SDLCALL *RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble); /**< Implements SDL_RumbleJoystickTriggers() */
|
||||
int (SDLCALL *SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue); /**< Implements SDL_SetJoystickLED() */
|
||||
int (SDLCALL *SendEffect)(void *userdata, const void *data, int size); /**< Implements SDL_SendJoystickEffect() */
|
||||
int (SDLCALL *SetSensorsEnabled)(void *userdata, SDL_bool enabled); /**< Implements SDL_SetGamepadSensorEnabled() */
|
||||
SDL_bool (SDLCALL *Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); /**< Implements SDL_RumbleJoystick() */
|
||||
SDL_bool (SDLCALL *RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble); /**< Implements SDL_RumbleJoystickTriggers() */
|
||||
SDL_bool (SDLCALL *SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue); /**< Implements SDL_SetJoystickLED() */
|
||||
SDL_bool (SDLCALL *SendEffect)(void *userdata, const void *data, int size); /**< Implements SDL_SendJoystickEffect() */
|
||||
SDL_bool (SDLCALL *SetSensorsEnabled)(void *userdata, SDL_bool enabled); /**< Implements SDL_SetGamepadSensorEnabled() */
|
||||
} SDL_VirtualJoystickDesc;
|
||||
|
||||
/**
|
||||
@ -471,14 +471,14 @@ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystick(const SDL_V
|
||||
*
|
||||
* \param instance_id the joystick instance ID, previously returned from
|
||||
* SDL_AttachVirtualJoystick().
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_AttachVirtualJoystick
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_DetachVirtualJoystick(SDL_JoystickID instance_id);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_DetachVirtualJoystick(SDL_JoystickID instance_id);
|
||||
|
||||
/**
|
||||
* Query whether or not a joystick is virtual.
|
||||
@ -506,12 +506,12 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_IsJoystickVirtual(SDL_JoystickID instan
|
||||
* \param joystick the virtual joystick on which to set state.
|
||||
* \param axis the index of the axis on the virtual joystick to update.
|
||||
* \param value the new value for the specified axis.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetJoystickVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value);
|
||||
|
||||
/**
|
||||
* Generate ball motion on an opened virtual joystick.
|
||||
@ -526,12 +526,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickVirtualAxis(SDL_Joystick *joystic
|
||||
* \param ball the index of the ball on the virtual joystick to update.
|
||||
* \param xrel the relative motion on the X axis.
|
||||
* \param yrel the relative motion on the Y axis.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickVirtualBall(SDL_Joystick *joystick, int ball, Sint16 xrel, Sint16 yrel);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetJoystickVirtualBall(SDL_Joystick *joystick, int ball, Sint16 xrel, Sint16 yrel);
|
||||
|
||||
/**
|
||||
* Set the state of a button on an opened virtual joystick.
|
||||
@ -545,12 +545,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickVirtualBall(SDL_Joystick *joystic
|
||||
* \param joystick the virtual joystick on which to set state.
|
||||
* \param button the index of the button on the virtual joystick to update.
|
||||
* \param value the new value for the specified button.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickVirtualButton(SDL_Joystick *joystick, int button, Uint8 value);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetJoystickVirtualButton(SDL_Joystick *joystick, int button, Uint8 value);
|
||||
|
||||
/**
|
||||
* Set the state of a hat on an opened virtual joystick.
|
||||
@ -564,12 +564,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickVirtualButton(SDL_Joystick *joyst
|
||||
* \param joystick the virtual joystick on which to set state.
|
||||
* \param hat the index of the hat on the virtual joystick to update.
|
||||
* \param value the new value for the specified hat.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value);
|
||||
|
||||
/**
|
||||
* Set touchpad finger state on an opened virtual joystick.
|
||||
@ -591,12 +591,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystick
|
||||
* \param y the y coordinate of the finger on the touchpad, normalized 0 to 1,
|
||||
* with the origin in the upper left.
|
||||
* \param pressure the pressure of the finger.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickVirtualTouchpad(SDL_Joystick *joystick, int touchpad, int finger, Uint8 state, float x, float y, float pressure);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetJoystickVirtualTouchpad(SDL_Joystick *joystick, int touchpad, int finger, Uint8 state, float x, float y, float pressure);
|
||||
|
||||
/**
|
||||
* Send a sensor update for an opened virtual joystick.
|
||||
@ -613,12 +613,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickVirtualTouchpad(SDL_Joystick *joy
|
||||
* the sensor reading.
|
||||
* \param data the data associated with the sensor reading.
|
||||
* \param num_values the number of values pointed to by `data`.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SendJoystickVirtualSensorData(SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SendJoystickVirtualSensorData(SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values);
|
||||
|
||||
/**
|
||||
* Get the properties associated with a joystick.
|
||||
@ -697,14 +697,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndex(SDL_Joystick *joystic
|
||||
* \param joystick the SDL_Joystick obtained from SDL_OpenJoystick().
|
||||
* \param player_index player index to assign to this joystick, or -1 to clear
|
||||
* the player index and turn off player LEDs.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetJoystickPlayerIndex
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index);
|
||||
|
||||
/**
|
||||
* Get the implementation-dependent GUID for the joystick.
|
||||
@ -852,8 +852,8 @@ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetJoystickID(SDL_Joystick *joyst
|
||||
* device and platform.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information.
|
||||
* \returns the number of axis controls/number of axes on success or a
|
||||
* negative error code on failure; call SDL_GetError() for more
|
||||
* \returns the number of axis controls/number of axes on success or -1
|
||||
* on failure; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -874,7 +874,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickAxes(SDL_Joystick *joystick);
|
||||
* Most joysticks do not have trackballs.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information.
|
||||
* \returns the number of trackballs on success or a negative error code on
|
||||
* \returns the number of trackballs on success or -1 on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -890,7 +890,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickBalls(SDL_Joystick *joystick);
|
||||
* Get the number of POV hats on a joystick.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information.
|
||||
* \returns the number of POV hats on success or a negative error code on
|
||||
* \returns the number of POV hats on success or -1 on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -906,7 +906,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickHats(SDL_Joystick *joystick);
|
||||
* Get the number of buttons on a joystick.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information.
|
||||
* \returns the number of buttons on success or a negative error code on
|
||||
* \returns the number of buttons on success or -1 on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1012,14 +1012,14 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystic
|
||||
* \param ball the ball index to query; ball indices start at index 0.
|
||||
* \param dx stores the difference in the x axis position since the last poll.
|
||||
* \param dy stores the difference in the y axis position since the last poll.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetNumJoystickBalls
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
|
||||
|
||||
/**
|
||||
* Get the current state of a POV hat on a joystick.
|
||||
@ -1075,11 +1075,11 @@ extern SDL_DECLSPEC Uint8 SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick,
|
||||
* \param high_frequency_rumble the intensity of the high frequency (right)
|
||||
* rumble motor, from 0 to 0xFFFF.
|
||||
* \param duration_ms the duration of the rumble effect, in milliseconds.
|
||||
* \returns 0, or -1 if rumble isn't supported on this joystick.
|
||||
* \returns SDL_TRUE, or SDL_FALSE if rumble isn't supported on this joystick.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
|
||||
|
||||
/**
|
||||
* Start a rumble effect in the joystick's triggers.
|
||||
@ -1101,14 +1101,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint1
|
||||
* \param right_rumble the intensity of the right trigger rumble motor, from 0
|
||||
* to 0xFFFF.
|
||||
* \param duration_ms the duration of the rumble effect, in milliseconds.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_RumbleJoystick
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
|
||||
|
||||
/**
|
||||
* Update a joystick's LED color.
|
||||
@ -1123,12 +1123,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joystic
|
||||
* \param red the intensity of the red LED.
|
||||
* \param green the intensity of the green LED.
|
||||
* \param blue the intensity of the blue LED.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
|
||||
|
||||
/**
|
||||
* Send a joystick specific effect packet.
|
||||
@ -1136,12 +1136,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8
|
||||
* \param joystick the joystick to affect.
|
||||
* \param data the data to send to the joystick.
|
||||
* \param size the size of the data to send to the joystick.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, const void *data, int size);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, const void *data, int size);
|
||||
|
||||
/**
|
||||
* Close a joystick previously opened with SDL_OpenJoystick().
|
||||
|
@ -231,14 +231,14 @@ extern SDL_DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key,
|
||||
* \param name the name to use for the scancode, encoded as UTF-8. The string
|
||||
* is not copied, so the pointer given to this function must stay
|
||||
* valid while SDL is being used.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetScancodeName
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetScancodeName(SDL_Scancode scancode, const char *name);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetScancodeName(SDL_Scancode scancode, const char *name);
|
||||
|
||||
/**
|
||||
* Get a human-readable name for a scancode.
|
||||
@ -322,7 +322,7 @@ extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name);
|
||||
* On some platforms using this function shows the screen keyboard.
|
||||
*
|
||||
* \param window the window to enable text input.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -332,7 +332,7 @@ extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name);
|
||||
* \sa SDL_StopTextInput
|
||||
* \sa SDL_TextInputActive
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_StartTextInput(SDL_Window *window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_StartTextInput(SDL_Window *window);
|
||||
|
||||
/**
|
||||
* Text input type.
|
||||
@ -414,7 +414,7 @@ typedef enum SDL_Capitalization
|
||||
*
|
||||
* \param window the window to enable text input.
|
||||
* \param props the properties to use.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -424,7 +424,7 @@ typedef enum SDL_Capitalization
|
||||
* \sa SDL_StopTextInput
|
||||
* \sa SDL_TextInputActive
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_StartTextInputWithProperties(SDL_Window *window, SDL_PropertiesID props);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_StartTextInputWithProperties(SDL_Window *window, SDL_PropertiesID props);
|
||||
|
||||
#define SDL_PROP_TEXTINPUT_TYPE_NUMBER "SDL.textinput.type"
|
||||
#define SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER "SDL.textinput.capitalization"
|
||||
@ -451,20 +451,20 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_TextInputActive(SDL_Window *window);
|
||||
* it.
|
||||
*
|
||||
* \param window the window to disable text input.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_StartTextInput
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_StopTextInput(SDL_Window *window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_StopTextInput(SDL_Window *window);
|
||||
|
||||
/**
|
||||
* Dismiss the composition window/IME without disabling the subsystem.
|
||||
*
|
||||
* \param window the window to affect.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -472,7 +472,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_StopTextInput(SDL_Window *window);
|
||||
* \sa SDL_StartTextInput
|
||||
* \sa SDL_StopTextInput
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ClearComposition(SDL_Window *window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ClearComposition(SDL_Window *window);
|
||||
|
||||
/**
|
||||
* Set the area used to type Unicode text input.
|
||||
@ -485,7 +485,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_ClearComposition(SDL_Window *window);
|
||||
* coordinates, or NULL to clear it.
|
||||
* \param cursor the offset of the current cursor location relative to
|
||||
* `rect->x`, in window coordinates.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -493,7 +493,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_ClearComposition(SDL_Window *window);
|
||||
* \sa SDL_GetTextInputArea
|
||||
* \sa SDL_StartTextInput
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetTextInputArea(SDL_Window *window, const SDL_Rect *rect, int cursor);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetTextInputArea(SDL_Window *window, const SDL_Rect *rect, int cursor);
|
||||
|
||||
/**
|
||||
* Get the area used to type Unicode text input.
|
||||
@ -505,14 +505,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetTextInputArea(SDL_Window *window, const S
|
||||
* may be NULL.
|
||||
* \param cursor a pointer to the offset of the current cursor location
|
||||
* relative to `rect->x`, may be NULL.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetTextInputArea
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetTextInputArea(SDL_Window *window, SDL_Rect *rect, int *cursor);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetTextInputArea(SDL_Window *window, SDL_Rect *rect, int *cursor);
|
||||
|
||||
/**
|
||||
* Check whether the platform has screen keyboard support.
|
||||
|
@ -191,7 +191,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_ResetLogPriorities(void);
|
||||
* \param priority the SDL_LogPriority to modify.
|
||||
* \param prefix the prefix to use for that log priority, or NULL to use no
|
||||
* prefix.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -199,7 +199,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_ResetLogPriorities(void);
|
||||
* \sa SDL_SetLogPriorities
|
||||
* \sa SDL_SetLogPriority
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetLogPriorityPrefix(SDL_LogPriority priority, const char *prefix);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetLogPriorityPrefix(SDL_LogPriority priority, const char *prefix);
|
||||
|
||||
/**
|
||||
* Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.
|
||||
|
@ -478,7 +478,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetMainReady(void);
|
||||
* literally have to be `main`.
|
||||
* \param reserved should be NULL (reserved for future use, will probably be
|
||||
* platform-specific then).
|
||||
* \returns the return value from mainFunction: 0 on success, -1 on failure;
|
||||
* \returns the return value from mainFunction: 0 on success, otherwise failure;
|
||||
* SDL_GetError() might have more information on the failure.
|
||||
*
|
||||
* \threadsafety Generally this is called once, near startup, from the
|
||||
@ -537,12 +537,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_EnterAppMainCallbacks(int argc, char *argv[]
|
||||
* what is specified here.
|
||||
* \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL
|
||||
* will use `GetModuleHandle(NULL)` instead.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst);
|
||||
|
||||
/**
|
||||
* Deregister the win32 window class from an SDL_RegisterApp call.
|
||||
|
@ -154,14 +154,14 @@ typedef struct SDL_MessageBoxData
|
||||
* other options.
|
||||
* \param buttonid the pointer to which user id of hit button should be
|
||||
* copied.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_ShowSimpleMessageBox
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
|
||||
|
||||
/**
|
||||
* Display a simple modal message box.
|
||||
@ -196,14 +196,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *mes
|
||||
* \param title uTF-8 title text.
|
||||
* \param message uTF-8 message text.
|
||||
* \param window the parent window, or NULL for no parent.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_ShowMessageBox
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, const char *title, const char *message, SDL_Window *window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, const char *title, const char *message, SDL_Window *window);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
|
@ -62,12 +62,12 @@ extern "C" {
|
||||
*
|
||||
* \param url a valid URL/URI to open. Use `file:///full/path/to/file` for
|
||||
* local files, if supported.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_OpenURL(const char *url);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_OpenURL(const char *url);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
@ -295,14 +295,14 @@ extern SDL_DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
|
||||
*
|
||||
* \param x the x coordinate.
|
||||
* \param y the y coordinate.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_WarpMouseInWindow
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_WarpMouseGlobal(float x, float y);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WarpMouseGlobal(float x, float y);
|
||||
|
||||
/**
|
||||
* Set relative mouse mode for a window.
|
||||
@ -316,14 +316,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_WarpMouseGlobal(float x, float y);
|
||||
*
|
||||
* \param window the window to change.
|
||||
* \param enabled SDL_TRUE to enable relative mode, SDL_FALSE to disable.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetWindowRelativeMouseMode
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowRelativeMouseMode(SDL_Window *window, SDL_bool enabled);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowRelativeMouseMode(SDL_Window *window, SDL_bool enabled);
|
||||
|
||||
/**
|
||||
* Query whether relative mouse mode is enabled for a window.
|
||||
@ -375,14 +375,14 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetWindowRelativeMouseMode(SDL_Window *
|
||||
* `SDL_HINT_MOUSE_AUTO_CAPTURE` hint to zero.
|
||||
*
|
||||
* \param enabled SDL_TRUE to enable capturing, SDL_FALSE to disable.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetGlobalMouseState
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_CaptureMouse(SDL_bool enabled);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_CaptureMouse(SDL_bool enabled);
|
||||
|
||||
/**
|
||||
* Create a cursor using the specified bitmap data and mask (in MSB format).
|
||||
@ -483,14 +483,14 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor
|
||||
* this is desired for any reason.
|
||||
*
|
||||
* \param cursor a cursor to make active.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetCursor
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetCursor(SDL_Cursor *cursor);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetCursor(SDL_Cursor *cursor);
|
||||
|
||||
/**
|
||||
* Get the active cursor.
|
||||
@ -538,7 +538,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroyCursor(SDL_Cursor *cursor);
|
||||
/**
|
||||
* Show the cursor.
|
||||
*
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -546,12 +546,12 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroyCursor(SDL_Cursor *cursor);
|
||||
* \sa SDL_CursorVisible
|
||||
* \sa SDL_HideCursor
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ShowCursor(void);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ShowCursor(void);
|
||||
|
||||
/**
|
||||
* Hide the cursor.
|
||||
*
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -559,7 +559,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_ShowCursor(void);
|
||||
* \sa SDL_CursorVisible
|
||||
* \sa SDL_ShowCursor
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_HideCursor(void);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HideCursor(void);
|
||||
|
||||
/**
|
||||
* Return whether the cursor is currently being shown.
|
||||
|
@ -115,16 +115,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Synchronization functions return this value if they time out.
|
||||
*
|
||||
* Not all functions _can_ time out; some will block indefinitely.
|
||||
*
|
||||
* \since This macro is available since SDL 3.0.0.
|
||||
*/
|
||||
#define SDL_MUTEX_TIMEDOUT 1
|
||||
|
||||
|
||||
/**
|
||||
* \name Mutex functions
|
||||
*/
|
||||
@ -194,25 +184,22 @@ extern SDL_DECLSPEC void SDLCALL SDL_LockMutex(SDL_Mutex *mutex) SDL_ACQUIRE(mut
|
||||
* Try to lock a mutex without blocking.
|
||||
*
|
||||
* This works just like SDL_LockMutex(), but if the mutex is not available,
|
||||
* this function returns `SDL_MUTEX_TIMEDOUT` immediately.
|
||||
* this function returns SDL_FALSE immediately.
|
||||
*
|
||||
* This technique is useful if you need exclusive access to a resource but
|
||||
* don't want to wait for it, and will return to it to try again later.
|
||||
*
|
||||
* This function does not fail; if mutex is NULL, it will return 0 immediately
|
||||
* having locked nothing. If the mutex is valid, this function will always
|
||||
* either lock the mutex and return 0, or return SDL_MUTEX_TIMEOUT and lock
|
||||
* nothing.
|
||||
*
|
||||
* This function returns SDL_TRUE if passed a NULL mutex.
|
||||
*
|
||||
* \param mutex the mutex to try to lock.
|
||||
* \returns 0 or `SDL_MUTEX_TIMEDOUT`.
|
||||
* \returns SDL_TRUE on success, SDL_FALSE if the mutex would block.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_LockMutex
|
||||
* \sa SDL_UnlockMutex
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_Mutex *mutex) SDL_TRY_ACQUIRE(0, mutex);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_TryLockMutex(SDL_Mutex *mutex) SDL_TRY_ACQUIRE(0, mutex);
|
||||
|
||||
/**
|
||||
* Unlock the mutex.
|
||||
@ -278,19 +265,6 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_Mutex *mutex);
|
||||
*/
|
||||
typedef struct SDL_RWLock SDL_RWLock;
|
||||
|
||||
/*
|
||||
* Synchronization functions return this value if they time out.
|
||||
*
|
||||
* Not all functions _can_ time out; some will block indefinitely.
|
||||
*
|
||||
* This symbol is just for clarity when dealing with SDL_RWLock
|
||||
* functions; its value is equivalent to SDL_MUTEX_TIMEOUT.
|
||||
*
|
||||
* \since This macro is available since SDL 3.0.0.
|
||||
*/
|
||||
#define SDL_RWLOCK_TIMEDOUT SDL_MUTEX_TIMEDOUT
|
||||
|
||||
|
||||
/**
|
||||
* Create a new read/write lock.
|
||||
*
|
||||
@ -405,7 +379,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SD
|
||||
* Try to lock a read/write lock _for reading_ without blocking.
|
||||
*
|
||||
* This works just like SDL_LockRWLockForReading(), but if the rwlock is not
|
||||
* available, then this function returns `SDL_RWLOCK_TIMEDOUT` immediately.
|
||||
* available, then this function returns SDL_FALSE immediately.
|
||||
*
|
||||
* This technique is useful if you need access to a resource but don't want to
|
||||
* wait for it, and will return to it to try again later.
|
||||
@ -413,13 +387,10 @@ extern SDL_DECLSPEC void SDLCALL SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SD
|
||||
* Trying to lock for read-only access can succeed if other threads are
|
||||
* holding read-only locks, as this won't prevent access.
|
||||
*
|
||||
* This function does not fail; if rwlock is NULL, it will return 0
|
||||
* immediately having locked nothing. If rwlock is valid, this function will
|
||||
* always either lock the rwlock and return 0, or return SDL_RWLOCK_TIMEOUT
|
||||
* and lock nothing.
|
||||
*
|
||||
* This function returns SDL_TRUE if passed a NULL rwlock.
|
||||
*
|
||||
* \param rwlock the rwlock to try to lock.
|
||||
* \returns 0 or `SDL_RWLOCK_TIMEDOUT`.
|
||||
* \returns SDL_TRUE on success, SDL_FALSE if the lock would block.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
@ -427,13 +398,13 @@ extern SDL_DECLSPEC void SDLCALL SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SD
|
||||
* \sa SDL_TryLockRWLockForWriting
|
||||
* \sa SDL_UnlockRWLock
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE_SHARED(0, rwlock);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE_SHARED(0, rwlock);
|
||||
|
||||
/**
|
||||
* Try to lock a read/write lock _for writing_ without blocking.
|
||||
*
|
||||
* This works just like SDL_LockRWLockForWriting(), but if the rwlock is not
|
||||
* available, this function returns `SDL_RWLOCK_TIMEDOUT` immediately.
|
||||
* available, then this function returns SDL_FALSE immediately.
|
||||
*
|
||||
* This technique is useful if you need exclusive access to a resource but
|
||||
* don't want to wait for it, and will return to it to try again later.
|
||||
@ -446,13 +417,10 @@ extern SDL_DECLSPEC int SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock)
|
||||
* read-only lock. Doing so results in undefined behavior. Unlock the
|
||||
* read-only lock before requesting a write lock.
|
||||
*
|
||||
* This function does not fail; if rwlock is NULL, it will return 0
|
||||
* immediately having locked nothing. If rwlock is valid, this function will
|
||||
* always either lock the rwlock and return 0, or return SDL_RWLOCK_TIMEOUT
|
||||
* and lock nothing.
|
||||
*
|
||||
* This function returns SDL_TRUE if passed a NULL rwlock.
|
||||
*
|
||||
* \param rwlock the rwlock to try to lock.
|
||||
* \returns 0 or `SDL_RWLOCK_TIMEDOUT`.
|
||||
* \returns SDL_TRUE on success, SDL_FALSE if the lock would block.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
@ -460,7 +428,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock)
|
||||
* \sa SDL_TryLockRWLockForReading
|
||||
* \sa SDL_UnlockRWLock
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE(0, rwlock);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE(0, rwlock);
|
||||
|
||||
/**
|
||||
* Unlock the read/write lock.
|
||||
@ -569,17 +537,13 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_Semaphore *sem);
|
||||
/**
|
||||
* Wait until a semaphore has a positive value and then decrements it.
|
||||
*
|
||||
* This function suspends the calling thread until either the semaphore
|
||||
* pointed to by `sem` has a positive value or the call is interrupted by a
|
||||
* signal or error. If the call is successful it will atomically decrement the
|
||||
* semaphore value.
|
||||
* This function suspends the calling thread until the semaphore
|
||||
* pointed to by `sem` has a positive value, and then atomically decrement the semaphore value.
|
||||
*
|
||||
* This function is the equivalent of calling SDL_WaitSemaphoreTimeout() with
|
||||
* a time length of -1.
|
||||
*
|
||||
* \param sem the semaphore wait on.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
@ -587,7 +551,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_Semaphore *sem);
|
||||
* \sa SDL_TryWaitSemaphore
|
||||
* \sa SDL_WaitSemaphoreTimeout
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_WaitSemaphore(SDL_Semaphore *sem);
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_WaitSemaphore(SDL_Semaphore *sem);
|
||||
|
||||
/**
|
||||
* See if a semaphore has a positive value and decrement it if it does.
|
||||
@ -595,12 +559,11 @@ extern SDL_DECLSPEC int SDLCALL SDL_WaitSemaphore(SDL_Semaphore *sem);
|
||||
* This function checks to see if the semaphore pointed to by `sem` has a
|
||||
* positive value and atomically decrements the semaphore value if it does. If
|
||||
* the semaphore doesn't have a positive value, the function immediately
|
||||
* returns SDL_MUTEX_TIMEDOUT.
|
||||
* returns SDL_FALSE.
|
||||
*
|
||||
* \param sem the semaphore to wait on.
|
||||
* \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait would
|
||||
* block, or a negative error code on failure; call SDL_GetError()
|
||||
* for more information.
|
||||
* \returns SDL_TRUE if the wait succeeds, SDL_FALSE if the wait would
|
||||
* block.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
@ -608,21 +571,18 @@ extern SDL_DECLSPEC int SDLCALL SDL_WaitSemaphore(SDL_Semaphore *sem);
|
||||
* \sa SDL_WaitSemaphore
|
||||
* \sa SDL_WaitSemaphoreTimeout
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_TryWaitSemaphore(SDL_Semaphore *sem);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_TryWaitSemaphore(SDL_Semaphore *sem);
|
||||
|
||||
/**
|
||||
* Wait until a semaphore has a positive value and then decrements it.
|
||||
*
|
||||
* This function suspends the calling thread until either the semaphore
|
||||
* pointed to by `sem` has a positive value, the call is interrupted by a
|
||||
* signal or error, or the specified time has elapsed. If the call is
|
||||
* pointed to by `sem` has a positive value or the specified time has elapsed. If the call is
|
||||
* successful it will atomically decrement the semaphore value.
|
||||
*
|
||||
* \param sem the semaphore to wait on.
|
||||
* \param timeoutMS the length of the timeout, in milliseconds.
|
||||
* \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait does not
|
||||
* succeed in the allotted time, or a negative error code on failure;
|
||||
* call SDL_GetError() for more information.
|
||||
* \param timeoutMS the length of the timeout, in milliseconds, or -1 to wait indefinitely.
|
||||
* \returns SDL_TRUE if the wait succeeds or SDL_FALSE if the wait times out.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
@ -630,14 +590,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_TryWaitSemaphore(SDL_Semaphore *sem);
|
||||
* \sa SDL_TryWaitSemaphore
|
||||
* \sa SDL_WaitSemaphore
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_WaitSemaphoreTimeout(SDL_Semaphore *sem, Sint32 timeoutMS);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WaitSemaphoreTimeout(SDL_Semaphore *sem, Sint32 timeoutMS);
|
||||
|
||||
/**
|
||||
* Atomically increment a semaphore's value and wake waiting threads.
|
||||
*
|
||||
* \param sem the semaphore to increment.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
@ -645,7 +603,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_WaitSemaphoreTimeout(SDL_Semaphore *sem, Sin
|
||||
* \sa SDL_WaitSemaphore
|
||||
* \sa SDL_WaitSemaphoreTimeout
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SignalSemaphore(SDL_Semaphore *sem);
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_SignalSemaphore(SDL_Semaphore *sem);
|
||||
|
||||
/**
|
||||
* Get the current value of a semaphore.
|
||||
@ -711,8 +669,6 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroyCondition(SDL_Condition *cond);
|
||||
* Restart one of the threads that are waiting on the condition variable.
|
||||
*
|
||||
* \param cond the condition variable to signal.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
@ -722,14 +678,12 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroyCondition(SDL_Condition *cond);
|
||||
* \sa SDL_WaitCondition
|
||||
* \sa SDL_WaitConditionTimeout
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SignalCondition(SDL_Condition *cond);
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_SignalCondition(SDL_Condition *cond);
|
||||
|
||||
/**
|
||||
* Restart all threads that are waiting on the condition variable.
|
||||
*
|
||||
* \param cond the condition variable to signal.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
@ -739,7 +693,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SignalCondition(SDL_Condition *cond);
|
||||
* \sa SDL_WaitCondition
|
||||
* \sa SDL_WaitConditionTimeout
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_BroadcastCondition(SDL_Condition *cond);
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_BroadcastCondition(SDL_Condition *cond);
|
||||
|
||||
/**
|
||||
* Wait until a condition variable is signaled.
|
||||
@ -758,8 +712,6 @@ extern SDL_DECLSPEC int SDLCALL SDL_BroadcastCondition(SDL_Condition *cond);
|
||||
*
|
||||
* \param cond the condition variable to wait on.
|
||||
* \param mutex the mutex used to coordinate thread access.
|
||||
* \returns 0 when it is signaled or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
@ -769,7 +721,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BroadcastCondition(SDL_Condition *cond);
|
||||
* \sa SDL_SignalCondition
|
||||
* \sa SDL_WaitConditionTimeout
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_WaitCondition(SDL_Condition *cond, SDL_Mutex *mutex);
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_WaitCondition(SDL_Condition *cond, SDL_Mutex *mutex);
|
||||
|
||||
/**
|
||||
* Wait until a condition variable is signaled or a certain time has passed.
|
||||
@ -788,9 +740,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_WaitCondition(SDL_Condition *cond, SDL_Mutex
|
||||
* \param mutex the mutex used to coordinate thread access.
|
||||
* \param timeoutMS the maximum time to wait, in milliseconds, or -1 to wait
|
||||
* indefinitely.
|
||||
* \returns 0 if the condition variable is signaled, `SDL_MUTEX_TIMEDOUT` if
|
||||
* the condition is not signaled in the allotted time, or a negative
|
||||
* error code on failure; call SDL_GetError() for more information.
|
||||
* \returns SDL_TRUE if the condition variable is signaled, SDL_FALSE if
|
||||
* the condition is not signaled in the allotted time.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
@ -800,7 +751,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_WaitCondition(SDL_Condition *cond, SDL_Mutex
|
||||
* \sa SDL_SignalCondition
|
||||
* \sa SDL_WaitCondition
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_WaitConditionTimeout(SDL_Condition *cond,
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WaitConditionTimeout(SDL_Condition *cond,
|
||||
SDL_Mutex *mutex, Sint32 timeoutMS);
|
||||
|
||||
/* @} *//* Condition variable functions */
|
||||
|
@ -742,7 +742,7 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetPixelFormatName(SDL_PixelFormat
|
||||
* \param Gmask a pointer filled in with the green mask for the format.
|
||||
* \param Bmask a pointer filled in with the blue mask for the format.
|
||||
* \param Amask a pointer filled in with the alpha mask for the format.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -751,7 +751,7 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetPixelFormatName(SDL_PixelFormat
|
||||
*
|
||||
* \sa SDL_GetPixelFormatForMasks
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask);
|
||||
|
||||
/**
|
||||
* Convert a bpp value and RGBA masks to an enumerated pixel format.
|
||||
@ -819,7 +819,7 @@ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreatePalette(int ncolors);
|
||||
* \param colors an array of SDL_Color structures to copy into the palette.
|
||||
* \param firstcolor the index of the first palette entry to modify.
|
||||
* \param ncolors the number of entries to modify.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, as long as
|
||||
@ -827,7 +827,7 @@ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreatePalette(int ncolors);
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors);
|
||||
|
||||
/**
|
||||
* Free a palette created with SDL_CreatePalette().
|
||||
|
@ -116,14 +116,14 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_CreateProperties(void);
|
||||
*
|
||||
* \param src the properties to copy.
|
||||
* \param dst the destination properties.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst);
|
||||
|
||||
/**
|
||||
* Lock a group of properties.
|
||||
@ -138,7 +138,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_CopyProperties(SDL_PropertiesID src, SDL_Pro
|
||||
* thread.
|
||||
*
|
||||
* \param props the properties to lock.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -147,7 +147,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_CopyProperties(SDL_PropertiesID src, SDL_Pro
|
||||
*
|
||||
* \sa SDL_UnlockProperties
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_LockProperties(SDL_PropertiesID props);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_LockProperties(SDL_PropertiesID props);
|
||||
|
||||
/**
|
||||
* Unlock a group of properties.
|
||||
@ -204,7 +204,7 @@ typedef void (SDLCALL *SDL_CleanupPropertyCallback)(void *userdata, void *value)
|
||||
* \param cleanup the function to call when this property is deleted, or NULL
|
||||
* if no cleanup is necessary.
|
||||
* \param userdata a pointer that is passed to the cleanup function.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -215,7 +215,7 @@ typedef void (SDLCALL *SDL_CleanupPropertyCallback)(void *userdata, void *value)
|
||||
* \sa SDL_SetPointerProperty
|
||||
* \sa SDL_CleanupPropertyCallback
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetPointerPropertyWithCleanup(SDL_PropertiesID props, const char *name, void *value, SDL_CleanupPropertyCallback cleanup, void *userdata);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetPointerPropertyWithCleanup(SDL_PropertiesID props, const char *name, void *value, SDL_CleanupPropertyCallback cleanup, void *userdata);
|
||||
|
||||
/**
|
||||
* Set a pointer property in a group of properties.
|
||||
@ -223,7 +223,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetPointerPropertyWithCleanup(SDL_Properties
|
||||
* \param props the properties to modify.
|
||||
* \param name the name of the property to modify.
|
||||
* \param value the new value of the property, or NULL to delete the property.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -238,7 +238,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetPointerPropertyWithCleanup(SDL_Properties
|
||||
* \sa SDL_SetPointerPropertyWithCleanup
|
||||
* \sa SDL_SetStringProperty
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetPointerProperty(SDL_PropertiesID props, const char *name, void *value);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetPointerProperty(SDL_PropertiesID props, const char *name, void *value);
|
||||
|
||||
/**
|
||||
* Set a string property in a group of properties.
|
||||
@ -249,7 +249,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetPointerProperty(SDL_PropertiesID props, c
|
||||
* \param props the properties to modify.
|
||||
* \param name the name of the property to modify.
|
||||
* \param value the new value of the property, or NULL to delete the property.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -258,7 +258,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetPointerProperty(SDL_PropertiesID props, c
|
||||
*
|
||||
* \sa SDL_GetStringProperty
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetStringProperty(SDL_PropertiesID props, const char *name, const char *value);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetStringProperty(SDL_PropertiesID props, const char *name, const char *value);
|
||||
|
||||
/**
|
||||
* Set an integer property in a group of properties.
|
||||
@ -266,7 +266,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetStringProperty(SDL_PropertiesID props, co
|
||||
* \param props the properties to modify.
|
||||
* \param name the name of the property to modify.
|
||||
* \param value the new value of the property.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -275,7 +275,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetStringProperty(SDL_PropertiesID props, co
|
||||
*
|
||||
* \sa SDL_GetNumberProperty
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetNumberProperty(SDL_PropertiesID props, const char *name, Sint64 value);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetNumberProperty(SDL_PropertiesID props, const char *name, Sint64 value);
|
||||
|
||||
/**
|
||||
* Set a floating point property in a group of properties.
|
||||
@ -283,7 +283,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetNumberProperty(SDL_PropertiesID props, co
|
||||
* \param props the properties to modify.
|
||||
* \param name the name of the property to modify.
|
||||
* \param value the new value of the property.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -292,7 +292,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetNumberProperty(SDL_PropertiesID props, co
|
||||
*
|
||||
* \sa SDL_GetFloatProperty
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetFloatProperty(SDL_PropertiesID props, const char *name, float value);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetFloatProperty(SDL_PropertiesID props, const char *name, float value);
|
||||
|
||||
/**
|
||||
* Set a boolean property in a group of properties.
|
||||
@ -300,7 +300,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetFloatProperty(SDL_PropertiesID props, con
|
||||
* \param props the properties to modify.
|
||||
* \param name the name of the property to modify.
|
||||
* \param value the new value of the property.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -309,7 +309,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetFloatProperty(SDL_PropertiesID props, con
|
||||
*
|
||||
* \sa SDL_GetBooleanProperty
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetBooleanProperty(SDL_PropertiesID props, const char *name, SDL_bool value);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetBooleanProperty(SDL_PropertiesID props, const char *name, SDL_bool value);
|
||||
|
||||
/**
|
||||
* Return whether a property exists in a group of properties.
|
||||
@ -470,14 +470,14 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetBooleanProperty(SDL_PropertiesID pro
|
||||
*
|
||||
* \param props the properties to modify.
|
||||
* \param name the name of the property to clear.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ClearProperty(SDL_PropertiesID props, const char *name);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ClearProperty(SDL_PropertiesID props, const char *name);
|
||||
|
||||
/**
|
||||
* A callback used to enumerate all the properties in a group of properties.
|
||||
@ -507,14 +507,14 @@ typedef void (SDLCALL *SDL_EnumeratePropertiesCallback)(void *userdata, SDL_Prop
|
||||
* \param props the properties to query.
|
||||
* \param callback the function to call for each property.
|
||||
* \param userdata a pointer that is passed to `callback`.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_EnumerateProperties(SDL_PropertiesID props, SDL_EnumeratePropertiesCallback callback, void *userdata);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_EnumerateProperties(SDL_PropertiesID props, SDL_EnumeratePropertiesCallback callback, void *userdata);
|
||||
|
||||
/**
|
||||
* Destroy a group of properties.
|
||||
|
@ -221,8 +221,7 @@ SDL_FORCE_INLINE SDL_bool SDL_RectsEqual(const SDL_Rect *a, const SDL_Rect *b)
|
||||
*
|
||||
* \sa SDL_GetRectIntersection
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasRectIntersection(const SDL_Rect * A,
|
||||
const SDL_Rect * B);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasRectIntersection(const SDL_Rect *A, const SDL_Rect *B);
|
||||
|
||||
/**
|
||||
* Calculate the intersection of two rectangles.
|
||||
@ -239,9 +238,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasRectIntersection(const SDL_Rect * A,
|
||||
*
|
||||
* \sa SDL_HasRectIntersection
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectIntersection(const SDL_Rect * A,
|
||||
const SDL_Rect * B,
|
||||
SDL_Rect * result);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectIntersection(const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result);
|
||||
|
||||
/**
|
||||
* Calculate the union of two rectangles.
|
||||
@ -250,14 +247,12 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectIntersection(const SDL_Rect * A,
|
||||
* \param B an SDL_Rect structure representing the second rectangle.
|
||||
* \param result an SDL_Rect structure filled in with the union of rectangles
|
||||
* `A` and `B`.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetRectUnion(const SDL_Rect * A,
|
||||
const SDL_Rect * B,
|
||||
SDL_Rect * result);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectUnion(const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result);
|
||||
|
||||
/**
|
||||
* Calculate a minimal rectangle enclosing a set of points.
|
||||
@ -276,10 +271,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetRectUnion(const SDL_Rect * A,
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectEnclosingPoints(const SDL_Point * points,
|
||||
int count,
|
||||
const SDL_Rect * clip,
|
||||
SDL_Rect * result);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectEnclosingPoints(const SDL_Point *points, int count, const SDL_Rect *clip, SDL_Rect *result);
|
||||
|
||||
/**
|
||||
* Calculate the intersection of a rectangle and line segment.
|
||||
@ -299,10 +291,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectEnclosingPoints(const SDL_Point
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectAndLineIntersection(const SDL_Rect *
|
||||
rect, int *X1,
|
||||
int *Y1, int *X2,
|
||||
int *Y2);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectAndLineIntersection(const SDL_Rect *rect, int *X1, int *Y1, int *X2, int *Y2);
|
||||
|
||||
|
||||
/* SDL_FRect versions... */
|
||||
@ -435,8 +424,7 @@ SDL_FORCE_INLINE SDL_bool SDL_RectsEqualFloat(const SDL_FRect *a, const SDL_FRec
|
||||
*
|
||||
* \sa SDL_GetRectIntersection
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasRectIntersectionFloat(const SDL_FRect * A,
|
||||
const SDL_FRect * B);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasRectIntersectionFloat(const SDL_FRect *A, const SDL_FRect *B);
|
||||
|
||||
/**
|
||||
* Calculate the intersection of two rectangles with float precision.
|
||||
@ -453,9 +441,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasRectIntersectionFloat(const SDL_FRec
|
||||
*
|
||||
* \sa SDL_HasRectIntersectionFloat
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectIntersectionFloat(const SDL_FRect * A,
|
||||
const SDL_FRect * B,
|
||||
SDL_FRect * result);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectIntersectionFloat(const SDL_FRect *A, const SDL_FRect *B, SDL_FRect *result);
|
||||
|
||||
/**
|
||||
* Calculate the union of two rectangles with float precision.
|
||||
@ -464,14 +450,12 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectIntersectionFloat(const SDL_FRec
|
||||
* \param B an SDL_FRect structure representing the second rectangle.
|
||||
* \param result an SDL_FRect structure filled in with the union of rectangles
|
||||
* `A` and `B`.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetRectUnionFloat(const SDL_FRect * A,
|
||||
const SDL_FRect * B,
|
||||
SDL_FRect * result);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectUnionFloat(const SDL_FRect *A, const SDL_FRect *B, SDL_FRect *result);
|
||||
|
||||
/**
|
||||
* Calculate a minimal rectangle enclosing a set of points with float
|
||||
@ -491,10 +475,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetRectUnionFloat(const SDL_FRect * A,
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectEnclosingPointsFloat(const SDL_FPoint * points,
|
||||
int count,
|
||||
const SDL_FRect * clip,
|
||||
SDL_FRect * result);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectEnclosingPointsFloat(const SDL_FPoint *points, int count, const SDL_FRect *clip, SDL_FRect *result);
|
||||
|
||||
/**
|
||||
* Calculate the intersection of a rectangle and line segment with float
|
||||
@ -515,10 +496,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectEnclosingPointsFloat(const SDL_F
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectAndLineIntersectionFloat(const SDL_FRect *
|
||||
rect, float *X1,
|
||||
float *Y1, float *X2,
|
||||
float *Y2);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRectAndLineIntersectionFloat(const SDL_FRect *rect, float *X1, float *Y1, float *X2, float *Y2);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -277,12 +277,12 @@ extern SDL_DECLSPEC SDL_SensorID SDLCALL SDL_GetSensorID(SDL_Sensor *sensor);
|
||||
* \param sensor the SDL_Sensor object to query.
|
||||
* \param data a pointer filled with the current sensor state.
|
||||
* \param num_values the number of values to write to data.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetSensorData(SDL_Sensor *sensor, float *data, int num_values);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetSensorData(SDL_Sensor *sensor, float *data, int num_values);
|
||||
|
||||
/**
|
||||
* Close a sensor previously opened with SDL_OpenSensor().
|
||||
|
@ -595,7 +595,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_
|
||||
* \param calloc_func custom calloc function.
|
||||
* \param realloc_func custom realloc function.
|
||||
* \param free_func custom free function.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, but one
|
||||
@ -607,10 +607,10 @@ extern SDL_DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_
|
||||
* \sa SDL_GetMemoryFunctions
|
||||
* \sa SDL_GetOriginalMemoryFunctions
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
|
||||
SDL_calloc_func calloc_func,
|
||||
SDL_realloc_func realloc_func,
|
||||
SDL_free_func free_func);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
|
||||
SDL_calloc_func calloc_func,
|
||||
SDL_realloc_func realloc_func,
|
||||
SDL_free_func free_func);
|
||||
|
||||
/**
|
||||
* Allocate memory aligned to a specific value.
|
||||
|
@ -57,34 +57,34 @@ extern "C" {
|
||||
typedef struct SDL_StorageInterface
|
||||
{
|
||||
/* Called when the storage is closed */
|
||||
int (SDLCALL *close)(void *userdata);
|
||||
SDL_bool (SDLCALL *close)(void *userdata);
|
||||
|
||||
/* Optional, returns whether the storage is currently ready for access */
|
||||
SDL_bool (SDLCALL *ready)(void *userdata);
|
||||
|
||||
/* Enumerate a directory, optional for write-only storage */
|
||||
int (SDLCALL *enumerate)(void *userdata, const char *path, SDL_EnumerateDirectoryCallback callback, void *callback_userdata);
|
||||
SDL_bool (SDLCALL *enumerate)(void *userdata, const char *path, SDL_EnumerateDirectoryCallback callback, void *callback_userdata);
|
||||
|
||||
/* Get path information, optional for write-only storage */
|
||||
int (SDLCALL *info)(void *userdata, const char *path, SDL_PathInfo *info);
|
||||
SDL_bool (SDLCALL *info)(void *userdata, const char *path, SDL_PathInfo *info);
|
||||
|
||||
/* Read a file from storage, optional for write-only storage */
|
||||
int (SDLCALL *read_file)(void *userdata, const char *path, void *destination, Uint64 length);
|
||||
SDL_bool (SDLCALL *read_file)(void *userdata, const char *path, void *destination, Uint64 length);
|
||||
|
||||
/* Write a file to storage, optional for read-only storage */
|
||||
int (SDLCALL *write_file)(void *userdata, const char *path, const void *source, Uint64 length);
|
||||
SDL_bool (SDLCALL *write_file)(void *userdata, const char *path, const void *source, Uint64 length);
|
||||
|
||||
/* Create a directory, optional for read-only storage */
|
||||
int (SDLCALL *mkdir)(void *userdata, const char *path);
|
||||
SDL_bool (SDLCALL *mkdir)(void *userdata, const char *path);
|
||||
|
||||
/* Remove a file or empty directory, optional for read-only storage */
|
||||
int (SDLCALL *remove)(void *userdata, const char *path);
|
||||
SDL_bool (SDLCALL *remove)(void *userdata, const char *path);
|
||||
|
||||
/* Rename a path, optional for read-only storage */
|
||||
int (SDLCALL *rename)(void *userdata, const char *oldpath, const char *newpath);
|
||||
SDL_bool (SDLCALL *rename)(void *userdata, const char *oldpath, const char *newpath);
|
||||
|
||||
/* Copy a file, optional for read-only storage */
|
||||
int (SDLCALL *copy)(void *userdata, const char *oldpath, const char *newpath);
|
||||
SDL_bool (SDLCALL *copy)(void *userdata, const char *oldpath, const char *newpath);
|
||||
|
||||
/* Get the space remaining, optional for read-only storage */
|
||||
Uint64 (SDLCALL *space_remaining)(void *userdata);
|
||||
@ -196,7 +196,7 @@ extern SDL_DECLSPEC SDL_Storage * SDLCALL SDL_OpenStorage(const SDL_StorageInter
|
||||
* Closes and frees a storage container.
|
||||
*
|
||||
* \param storage a storage container to close.
|
||||
* \returns 0 if the container was freed with no errors, a negative value
|
||||
* \returns SDL_TRUE if the container was freed with no errors, SDL_FALSE
|
||||
* otherwise; call SDL_GetError() for more information. Even if the
|
||||
* function returns an error, the container data will be freed; the
|
||||
* error is only for informational purposes.
|
||||
@ -208,7 +208,7 @@ extern SDL_DECLSPEC SDL_Storage * SDLCALL SDL_OpenStorage(const SDL_StorageInter
|
||||
* \sa SDL_OpenTitleStorage
|
||||
* \sa SDL_OpenUserStorage
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_CloseStorage(SDL_Storage *storage);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_CloseStorage(SDL_Storage *storage);
|
||||
|
||||
/**
|
||||
* Checks if the storage container is ready to use.
|
||||
@ -230,7 +230,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_StorageReady(SDL_Storage *storage);
|
||||
* \param storage a storage container to query.
|
||||
* \param path the relative path of the file to query.
|
||||
* \param length a pointer to be filled with the file's length.
|
||||
* \returns 0 if the file could be queried or a negative error code on
|
||||
* \returns SDL_TRUE if the file could be queried or SDL_FALSE on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -238,7 +238,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_StorageReady(SDL_Storage *storage);
|
||||
* \sa SDL_ReadStorageFile
|
||||
* \sa SDL_StorageReady
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetStorageFileSize(SDL_Storage *storage, const char *path, Uint64 *length);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetStorageFileSize(SDL_Storage *storage, const char *path, Uint64 *length);
|
||||
|
||||
/**
|
||||
* Synchronously read a file from a storage container into a client-provided
|
||||
@ -248,7 +248,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetStorageFileSize(SDL_Storage *storage, con
|
||||
* \param path the relative path of the file to read.
|
||||
* \param destination a client-provided buffer to read the file into.
|
||||
* \param length the length of the destination buffer.
|
||||
* \returns 0 if the file was read or a negative error code on failure; call
|
||||
* \returns SDL_TRUE if the file was read or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -257,7 +257,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetStorageFileSize(SDL_Storage *storage, con
|
||||
* \sa SDL_StorageReady
|
||||
* \sa SDL_WriteStorageFile
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ReadStorageFile(SDL_Storage *storage, const char *path, void *destination, Uint64 length);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ReadStorageFile(SDL_Storage *storage, const char *path, void *destination, Uint64 length);
|
||||
|
||||
/**
|
||||
* Synchronously write a file from client memory into a storage container.
|
||||
@ -266,7 +266,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_ReadStorageFile(SDL_Storage *storage, const
|
||||
* \param path the relative path of the file to write.
|
||||
* \param source a client-provided buffer to write from.
|
||||
* \param length the length of the source buffer.
|
||||
* \returns 0 if the file was written or a negative error code on failure;
|
||||
* \returns SDL_TRUE if the file was written or SDL_FALSE on failure;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -275,21 +275,21 @@ extern SDL_DECLSPEC int SDLCALL SDL_ReadStorageFile(SDL_Storage *storage, const
|
||||
* \sa SDL_ReadStorageFile
|
||||
* \sa SDL_StorageReady
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_WriteStorageFile(SDL_Storage *storage, const char *path, const void *source, Uint64 length);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WriteStorageFile(SDL_Storage *storage, const char *path, const void *source, Uint64 length);
|
||||
|
||||
/**
|
||||
* Create a directory in a writable storage container.
|
||||
*
|
||||
* \param storage a storage container.
|
||||
* \param path the path of the directory to create.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_StorageReady
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_CreateStorageDirectory(SDL_Storage *storage, const char *path);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_CreateStorageDirectory(SDL_Storage *storage, const char *path);
|
||||
|
||||
/**
|
||||
* Enumerate a directory in a storage container through a callback function.
|
||||
@ -302,28 +302,28 @@ extern SDL_DECLSPEC int SDLCALL SDL_CreateStorageDirectory(SDL_Storage *storage,
|
||||
* \param path the path of the directory to enumerate.
|
||||
* \param callback a function that is called for each entry in the directory.
|
||||
* \param userdata a pointer that is passed to `callback`.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_StorageReady
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_EnumerateStorageDirectory(SDL_Storage *storage, const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_EnumerateStorageDirectory(SDL_Storage *storage, const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata);
|
||||
|
||||
/**
|
||||
* Remove a file or an empty directory in a writable storage container.
|
||||
*
|
||||
* \param storage a storage container.
|
||||
* \param path the path of the directory to enumerate.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_StorageReady
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_RemoveStoragePath(SDL_Storage *storage, const char *path);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RemoveStoragePath(SDL_Storage *storage, const char *path);
|
||||
|
||||
/**
|
||||
* Rename a file or directory in a writable storage container.
|
||||
@ -331,14 +331,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_RemoveStoragePath(SDL_Storage *storage, cons
|
||||
* \param storage a storage container.
|
||||
* \param oldpath the old path.
|
||||
* \param newpath the new path.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_StorageReady
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_RenameStoragePath(SDL_Storage *storage, const char *oldpath, const char *newpath);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RenameStoragePath(SDL_Storage *storage, const char *oldpath, const char *newpath);
|
||||
|
||||
/**
|
||||
* Copy a file in a writable storage container.
|
||||
@ -346,14 +346,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_RenameStoragePath(SDL_Storage *storage, cons
|
||||
* \param storage a storage container.
|
||||
* \param oldpath the old path.
|
||||
* \param newpath the new path.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_StorageReady
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_CopyStorageFile(SDL_Storage *storage, const char *oldpath, const char *newpath);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_CopyStorageFile(SDL_Storage *storage, const char *oldpath, const char *newpath);
|
||||
|
||||
/**
|
||||
* Get information about a filesystem path in a storage container.
|
||||
@ -362,14 +362,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_CopyStorageFile(SDL_Storage *storage, const
|
||||
* \param path the path to query.
|
||||
* \param info a pointer filled in with information about the path, or NULL to
|
||||
* check for the existence of a file.
|
||||
* \returns 0 on success or a negative error code if the file doesn't exist,
|
||||
* \returns SDL_TRUE on success or SDL_FALSE if the file doesn't exist,
|
||||
* or another failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_StorageReady
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetStoragePathInfo(SDL_Storage *storage, const char *path, SDL_PathInfo *info);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetStoragePathInfo(SDL_Storage *storage, const char *path, SDL_PathInfo *info);
|
||||
|
||||
/**
|
||||
* Queries the remaining space in a storage container.
|
||||
|
@ -224,14 +224,14 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSurfaceProperties(SDL_Surfac
|
||||
* \param surface the SDL_Surface structure to update.
|
||||
* \param colorspace an SDL_ColorSpace value describing the surface
|
||||
* colorspace.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetSurfaceColorspace
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceColorspace(SDL_Surface *surface, SDL_Colorspace colorspace);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetSurfaceColorspace(SDL_Surface *surface, SDL_Colorspace colorspace);
|
||||
|
||||
/**
|
||||
* Get the colorspace used by a surface.
|
||||
@ -285,7 +285,7 @@ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreateSurfacePalette(SDL_Surface *
|
||||
*
|
||||
* \param surface the SDL_Surface structure to update.
|
||||
* \param palette the SDL_Palette structure to use.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -293,7 +293,7 @@ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreateSurfacePalette(SDL_Surface *
|
||||
* \sa SDL_CreatePalette
|
||||
* \sa SDL_GetSurfacePalette
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette);
|
||||
|
||||
/**
|
||||
* Get the palette used by a surface.
|
||||
@ -322,8 +322,8 @@ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetSurfacePalette(SDL_Surface *sur
|
||||
* \param surface the SDL_Surface structure to update.
|
||||
* \param image a pointer to an alternate SDL_Surface to associate with this
|
||||
* surface.
|
||||
* \returns SDL_TRUE if alternate versions are available or SDL_TRUE
|
||||
* otherwise.
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
@ -331,7 +331,7 @@ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetSurfacePalette(SDL_Surface *sur
|
||||
* \sa SDL_GetSurfaceImages
|
||||
* \sa SDL_SurfaceHasAlternateImages
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_AddSurfaceAlternateImage(SDL_Surface *surface, SDL_Surface *image);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_AddSurfaceAlternateImage(SDL_Surface *surface, SDL_Surface *image);
|
||||
|
||||
/**
|
||||
* Return whether a surface has alternate versions available.
|
||||
@ -402,7 +402,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_RemoveSurfaceAlternateImages(SDL_Surface *s
|
||||
* format of the surface will not change.
|
||||
*
|
||||
* \param surface the SDL_Surface structure to be locked.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -410,7 +410,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_RemoveSurfaceAlternateImages(SDL_Surface *s
|
||||
* \sa SDL_MUSTLOCK
|
||||
* \sa SDL_UnlockSurface
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_LockSurface(SDL_Surface *surface);
|
||||
|
||||
/**
|
||||
* Release a surface after directly accessing the pixels.
|
||||
@ -474,7 +474,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP(const char *file);
|
||||
* \param dst a data stream to save to.
|
||||
* \param closeio if SDL_TRUE, calls SDL_CloseIO() on `dst` before returning,
|
||||
* even in the case of an error.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -482,7 +482,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP(const char *file);
|
||||
* \sa SDL_LoadBMP_IO
|
||||
* \sa SDL_SaveBMP
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio);
|
||||
|
||||
/**
|
||||
* Save a surface to a file.
|
||||
@ -495,7 +495,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStrea
|
||||
*
|
||||
* \param surface the SDL_Surface structure containing the image to be saved.
|
||||
* \param file a file to save to.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -503,7 +503,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStrea
|
||||
* \sa SDL_LoadBMP
|
||||
* \sa SDL_SaveBMP_IO
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *file);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *file);
|
||||
|
||||
/**
|
||||
* Set the RLE acceleration hint for a surface.
|
||||
@ -514,7 +514,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *fi
|
||||
* \param surface the SDL_Surface structure to optimize.
|
||||
* \param enabled SDL_TRUE to enable RLE acceleration, SDL_FALSE to disable
|
||||
* it.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -523,7 +523,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *fi
|
||||
* \sa SDL_LockSurface
|
||||
* \sa SDL_UnlockSurface
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, SDL_bool enabled);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, SDL_bool enabled);
|
||||
|
||||
/**
|
||||
* Returns whether the surface is RLE enabled.
|
||||
@ -553,7 +553,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SurfaceHasRLE(SDL_Surface *surface);
|
||||
* \param enabled SDL_TRUE to enable color key, SDL_FALSE to disable color
|
||||
* key.
|
||||
* \param key the transparent pixel.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -562,7 +562,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SurfaceHasRLE(SDL_Surface *surface);
|
||||
* \sa SDL_SetSurfaceRLE
|
||||
* \sa SDL_SurfaceHasColorKey
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceColorKey(SDL_Surface *surface, SDL_bool enabled, Uint32 key);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetSurfaceColorKey(SDL_Surface *surface, SDL_bool enabled, Uint32 key);
|
||||
|
||||
/**
|
||||
* Returns whether the surface has a color key.
|
||||
@ -589,7 +589,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SurfaceHasColorKey(SDL_Surface *surface
|
||||
*
|
||||
* \param surface the SDL_Surface structure to query.
|
||||
* \param key a pointer filled in with the transparent pixel.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -597,7 +597,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SurfaceHasColorKey(SDL_Surface *surface
|
||||
* \sa SDL_SetSurfaceColorKey
|
||||
* \sa SDL_SurfaceHasColorKey
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key);
|
||||
|
||||
/**
|
||||
* Set an additional color value multiplied into blit operations.
|
||||
@ -612,7 +612,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface, Uin
|
||||
* \param r the red color value multiplied into blit operations.
|
||||
* \param g the green color value multiplied into blit operations.
|
||||
* \param b the blue color value multiplied into blit operations.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -620,7 +620,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface, Uin
|
||||
* \sa SDL_GetSurfaceColorMod
|
||||
* \sa SDL_SetSurfaceAlphaMod
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b);
|
||||
|
||||
|
||||
/**
|
||||
@ -630,7 +630,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Uin
|
||||
* \param r a pointer filled in with the current red color value.
|
||||
* \param g a pointer filled in with the current green color value.
|
||||
* \param b a pointer filled in with the current blue color value.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -638,7 +638,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Uin
|
||||
* \sa SDL_GetSurfaceAlphaMod
|
||||
* \sa SDL_SetSurfaceColorMod
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b);
|
||||
|
||||
/**
|
||||
* Set an additional alpha value used in blit operations.
|
||||
@ -650,7 +650,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uin
|
||||
*
|
||||
* \param surface the SDL_Surface structure to update.
|
||||
* \param alpha the alpha value multiplied into blit operations.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -658,14 +658,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uin
|
||||
* \sa SDL_GetSurfaceAlphaMod
|
||||
* \sa SDL_SetSurfaceColorMod
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha);
|
||||
|
||||
/**
|
||||
* Get the additional alpha value used in blit operations.
|
||||
*
|
||||
* \param surface the SDL_Surface structure to query.
|
||||
* \param alpha a pointer filled in with the current alpha value.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -673,7 +673,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uin
|
||||
* \sa SDL_GetSurfaceColorMod
|
||||
* \sa SDL_SetSurfaceAlphaMod
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha);
|
||||
|
||||
/**
|
||||
* Set the blend mode used for blit operations.
|
||||
@ -684,28 +684,28 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uin
|
||||
*
|
||||
* \param surface the SDL_Surface structure to update.
|
||||
* \param blendMode the SDL_BlendMode to use for blit blending.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetSurfaceBlendMode
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode);
|
||||
|
||||
/**
|
||||
* Get the blend mode used for blit operations.
|
||||
*
|
||||
* \param surface the SDL_Surface structure to query.
|
||||
* \param blendMode a pointer filled in with the current SDL_BlendMode.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetSurfaceBlendMode
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode);
|
||||
|
||||
/**
|
||||
* Set the clipping rectangle for a surface.
|
||||
@ -738,26 +738,26 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetSurfaceClipRect(SDL_Surface *surface
|
||||
* clipped.
|
||||
* \param rect an SDL_Rect structure filled in with the clipping rectangle for
|
||||
* the surface.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetSurfaceClipRect
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceClipRect(SDL_Surface *surface, SDL_Rect *rect);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetSurfaceClipRect(SDL_Surface *surface, SDL_Rect *rect);
|
||||
|
||||
/**
|
||||
* Flip a surface vertically or horizontally.
|
||||
*
|
||||
* \param surface the surface to flip.
|
||||
* \param flip the direction to flip.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMode flip);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMode flip);
|
||||
|
||||
/**
|
||||
* Creates a new surface identical to the existing surface.
|
||||
@ -860,14 +860,14 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurfaceAndColorspace(SDL_Su
|
||||
* \param dst_format an SDL_PixelFormat value of the `dst` pixels format.
|
||||
* \param dst a pointer to be filled in with new pixel data.
|
||||
* \param dst_pitch the pitch of the destination pixels, in bytes.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_FALSE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_ConvertPixelsAndColorspace
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ConvertPixels(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch);
|
||||
|
||||
/**
|
||||
* Copy a block of pixels of one format and colorspace to another format and
|
||||
@ -889,14 +889,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, SDL_Pix
|
||||
* properties, or 0.
|
||||
* \param dst a pointer to be filled in with new pixel data.
|
||||
* \param dst_pitch the pitch of the destination pixels, in bytes.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_FALSE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_ConvertPixels
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ConvertPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ConvertPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
|
||||
|
||||
/**
|
||||
* Premultiply the alpha on a block of pixels.
|
||||
@ -913,12 +913,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_ConvertPixelsAndColorspace(int width, int he
|
||||
* \param dst_pitch the pitch of the destination pixels, in bytes.
|
||||
* \param linear SDL_TRUE to convert from sRGB to linear space for the alpha
|
||||
* multiplication, SDL_FALSE to do multiplication in sRGB space.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_PremultiplyAlpha(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch, SDL_bool linear);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_PremultiplyAlpha(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch, SDL_bool linear);
|
||||
|
||||
/**
|
||||
* Premultiply the alpha in a surface.
|
||||
@ -928,12 +928,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_PremultiplyAlpha(int width, int height, SDL_
|
||||
* \param surface the surface to modify.
|
||||
* \param linear SDL_TRUE to convert from sRGB to linear space for the alpha
|
||||
* multiplication, SDL_FALSE to do multiplication in sRGB space.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_PremultiplySurfaceAlpha(SDL_Surface *surface, SDL_bool linear);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_PremultiplySurfaceAlpha(SDL_Surface *surface, SDL_bool linear);
|
||||
|
||||
/**
|
||||
* Clear a surface with a specific color, with floating point precision.
|
||||
@ -948,12 +948,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_PremultiplySurfaceAlpha(SDL_Surface *surface
|
||||
* \param g the green component of the pixel, normally in the range 0-1.
|
||||
* \param b the blue component of the pixel, normally in the range 0-1.
|
||||
* \param a the alpha component of the pixel, normally in the range 0-1.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ClearSurface(SDL_Surface *surface, float r, float g, float b, float a);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ClearSurface(SDL_Surface *surface, float r, float g, float b, float a);
|
||||
|
||||
/**
|
||||
* Perform a fast fill of a rectangle with a specific color.
|
||||
@ -971,14 +971,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_ClearSurface(SDL_Surface *surface, float r,
|
||||
* \param rect the SDL_Rect structure representing the rectangle to fill, or
|
||||
* NULL to fill the entire surface.
|
||||
* \param color the color to fill with.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_FillSurfaceRects
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color);
|
||||
|
||||
/**
|
||||
* Perform a fast fill of a set of rectangles with a specific color.
|
||||
@ -996,14 +996,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_
|
||||
* \param rects an array of SDL_Rects representing the rectangles to fill.
|
||||
* \param count the number of rectangles in the array.
|
||||
* \param color the color to fill with.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_FillSurfaceRect
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color);
|
||||
|
||||
/**
|
||||
* Performs a fast blit from the source surface to the destination surface.
|
||||
@ -1067,7 +1067,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_FillSurfaceRects(SDL_Surface *dst, const SDL
|
||||
* height are ignored, and are copied from `srcrect`. If you
|
||||
* want a specific width and height, you should use
|
||||
* SDL_BlitSurfaceScaled().
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety The same destination surface should not be used from two
|
||||
@ -1078,7 +1078,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_FillSurfaceRects(SDL_Surface *dst, const SDL
|
||||
*
|
||||
* \sa SDL_BlitSurfaceScaled
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||
|
||||
/**
|
||||
* Perform low-level surface blitting only.
|
||||
@ -1092,7 +1092,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect
|
||||
* \param dst the SDL_Surface structure that is the blit target.
|
||||
* \param dstrect the SDL_Rect structure representing the target rectangle in
|
||||
* the destination surface, may not be NULL.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety The same destination surface should not be used from two
|
||||
@ -1103,7 +1103,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect
|
||||
*
|
||||
* \sa SDL_BlitSurface
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceUnchecked(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_BlitSurfaceUnchecked(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||
|
||||
/**
|
||||
* Perform a scaled blit to a destination surface, which may be of a different
|
||||
@ -1117,7 +1117,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceUnchecked(SDL_Surface *src, const
|
||||
* the destination surface, or NULL to fill the entire
|
||||
* destination surface.
|
||||
* \param scaleMode the SDL_ScaleMode to be used.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety The same destination surface should not be used from two
|
||||
@ -1128,7 +1128,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceUnchecked(SDL_Surface *src, const
|
||||
*
|
||||
* \sa SDL_BlitSurface
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
|
||||
|
||||
/**
|
||||
* Perform low-level surface scaled blitting only.
|
||||
@ -1143,7 +1143,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SD
|
||||
* \param dstrect the SDL_Rect structure representing the target rectangle in
|
||||
* the destination surface, may not be NULL.
|
||||
* \param scaleMode the SDL_ScaleMode to be used.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety The same destination surface should not be used from two
|
||||
@ -1154,7 +1154,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SD
|
||||
*
|
||||
* \sa SDL_BlitSurfaceScaled
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
|
||||
|
||||
/**
|
||||
* Perform a tiled blit to a destination surface, which may be of a different
|
||||
@ -1169,7 +1169,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src,
|
||||
* \param dst the SDL_Surface structure that is the blit target.
|
||||
* \param dstrect the SDL_Rect structure representing the target rectangle in
|
||||
* the destination surface, or NULL to fill the entire surface.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety The same destination surface should not be used from two
|
||||
@ -1180,7 +1180,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src,
|
||||
*
|
||||
* \sa SDL_BlitSurface
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||
|
||||
/**
|
||||
* Perform a scaled and tiled blit to a destination surface, which may be of a
|
||||
@ -1199,7 +1199,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL
|
||||
* \param dst the SDL_Surface structure that is the blit target.
|
||||
* \param dstrect the SDL_Rect structure representing the target rectangle in
|
||||
* the destination surface, or NULL to fill the entire surface.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety The same destination surface should not be used from two
|
||||
@ -1210,7 +1210,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL
|
||||
*
|
||||
* \sa SDL_BlitSurface
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||
|
||||
/**
|
||||
* Perform a scaled blit using the 9-grid algorithm to a destination surface,
|
||||
@ -1236,7 +1236,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceTiledWithScale(SDL_Surface *src,
|
||||
* \param dst the SDL_Surface structure that is the blit target.
|
||||
* \param dstrect the SDL_Rect structure representing the target rectangle in
|
||||
* the destination surface, or NULL to fill the entire surface.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety The same destination surface should not be used from two
|
||||
@ -1247,7 +1247,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceTiledWithScale(SDL_Surface *src,
|
||||
*
|
||||
* \sa SDL_BlitSurface
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||
|
||||
/**
|
||||
* Map an RGB triple to an opaque pixel value for a surface.
|
||||
@ -1330,12 +1330,12 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGBA(SDL_Surface *surface, Uint
|
||||
* ignore this channel.
|
||||
* \param a a pointer filled in with the alpha channel, 0-255, or NULL to
|
||||
* ignore this channel.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
|
||||
|
||||
/**
|
||||
* Retrieves a single pixel from a surface.
|
||||
@ -1354,12 +1354,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_ReadSurfacePixel(SDL_Surface *surface, int x
|
||||
* 0-1, or NULL to ignore this channel.
|
||||
* \param a a pointer filled in with the alpha channel, normally in the range
|
||||
* 0-1, or NULL to ignore this channel.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ReadSurfacePixelFloat(SDL_Surface *surface, int x, int y, float *r, float *g, float *b, float *a);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ReadSurfacePixelFloat(SDL_Surface *surface, int x, int y, float *r, float *g, float *b, float *a);
|
||||
|
||||
/**
|
||||
* Writes a single pixel to a surface.
|
||||
@ -1377,12 +1377,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_ReadSurfacePixelFloat(SDL_Surface *surface,
|
||||
* \param g the green channel value, 0-255.
|
||||
* \param b the blue channel value, 0-255.
|
||||
* \param a the alpha channel value, 0-255.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_WriteSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WriteSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/**
|
||||
* Writes a single pixel to a surface.
|
||||
@ -1397,12 +1397,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_WriteSurfacePixel(SDL_Surface *surface, int
|
||||
* \param g the green channel value, normally in the range 0-1.
|
||||
* \param b the blue channel value, normally in the range 0-1.
|
||||
* \param a the alpha channel value, normally in the range 0-1.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_WriteSurfacePixelFloat(SDL_Surface *surface, int x, int y, float r, float g, float b, float a);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WriteSurfacePixelFloat(SDL_Surface *surface, int x, int y, float r, float g, float b, float a);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
@ -101,7 +101,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHoo
|
||||
* controls on which monitor a full screen application will appear.
|
||||
*
|
||||
* \param displayID the instance of the display to query.
|
||||
* \returns the D3D9 adapter index on success or a negative error code on
|
||||
* \returns the D3D9 adapter index on success or -1 on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -122,12 +122,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetDirect3D9AdapterIndex(SDL_DisplayID displ
|
||||
* \param displayID the instance of the display to query.
|
||||
* \param adapterIndex a pointer to be filled in with the adapter index.
|
||||
* \param outputIndex a pointer to be filled in with the output index.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetDXGIOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetDXGIOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex);
|
||||
|
||||
#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */
|
||||
|
||||
@ -162,12 +162,12 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetX11EventHook(SDL_X11EventHook callback,
|
||||
*
|
||||
* \param threadID the Unix thread ID to change priority of.
|
||||
* \param priority the new, Unix-specific, priority value.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetLinuxThreadPriority(Sint64 threadID, int priority);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetLinuxThreadPriority(Sint64 threadID, int priority);
|
||||
|
||||
/**
|
||||
* Sets the priority (not nice level) and scheduling policy for a thread.
|
||||
@ -178,12 +178,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetLinuxThreadPriority(Sint64 threadID, int
|
||||
* \param sdlPriority the new SDL_ThreadPriority value.
|
||||
* \param schedPolicy the new scheduling policy (SCHED_FIFO, SCHED_RR,
|
||||
* SCHED_OTHER, etc...).
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy);
|
||||
|
||||
#endif /* SDL_PLATFORM_LINUX */
|
||||
|
||||
@ -240,14 +240,14 @@ typedef void (SDLCALL *SDL_iOSAnimationCallback)(void *userdata);
|
||||
* called.
|
||||
* \param callback the function to call for every frame.
|
||||
* \param callbackParam a pointer that is passed to `callback`.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetiOSEventPump
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetiOSAnimationCallback(SDL_Window *window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetiOSAnimationCallback(SDL_Window *window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam);
|
||||
|
||||
/**
|
||||
* Use this function to enable or disable the SDL event pump on Apple iOS.
|
||||
@ -503,7 +503,7 @@ typedef void (SDLCALL *SDL_RequestAndroidPermissionCallback)(void *userdata, con
|
||||
* \param permission the permission to request.
|
||||
* \param cb the callback to trigger when the request has a response.
|
||||
* \param userdata an app-controlled pointer that is passed to the callback.
|
||||
* \returns zero if the request was submitted, -1 if there was an error
|
||||
* \returns SDL_TRUE if the request was submitted, SDL_FALSE if there was an error
|
||||
* submitting. The result of the request is only ever reported
|
||||
* through the callback, not this return value.
|
||||
*
|
||||
@ -511,7 +511,7 @@ typedef void (SDLCALL *SDL_RequestAndroidPermissionCallback)(void *userdata, con
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata);
|
||||
|
||||
/**
|
||||
* Shows an Android toast notification.
|
||||
@ -532,14 +532,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_RequestAndroidPermission(const char *permiss
|
||||
* \param gravity where the notification should appear on the screen.
|
||||
* \param xoffset set this parameter only when gravity >=0.
|
||||
* \param yoffset set this parameter only when gravity >=0.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xoffset, int yoffset);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xoffset, int yoffset);
|
||||
|
||||
/**
|
||||
* Send a user command to SDLActivity.
|
||||
@ -548,14 +548,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_ShowAndroidToast(const char *message, int du
|
||||
*
|
||||
* \param command user command that must be greater or equal to 0x8000.
|
||||
* \param param user parameter.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SendAndroidMessage(Uint32 command, int param);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SendAndroidMessage(Uint32 command, int param);
|
||||
|
||||
#endif /* SDL_PLATFORM_ANDROID */
|
||||
|
||||
@ -794,12 +794,12 @@ typedef struct XUser *XUserHandle;
|
||||
* leak.
|
||||
*
|
||||
* \param outTaskQueue a pointer to be filled in with task queue handle.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue);
|
||||
|
||||
/**
|
||||
* Gets a reference to the default user handle for GDK.
|
||||
@ -809,12 +809,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQue
|
||||
*
|
||||
* \param outUserHandle a pointer to be filled in with the default user
|
||||
* handle.
|
||||
* \returns 0 if success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE if success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetGDKDefaultUser(XUserHandle *outUserHandle);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetGDKDefaultUser(XUserHandle *outUserHandle);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -50,9 +50,9 @@ extern int FONT_CHARACTER_SIZE;
|
||||
* \param y The Y coordinate of the upper left corner of the character.
|
||||
* \param c The character to draw.
|
||||
*
|
||||
* \returns 0 on success, -1 on failure.
|
||||
* \returns SDL_TRUE on success, SDL_FALSE on failure.
|
||||
*/
|
||||
int SDLTest_DrawCharacter(SDL_Renderer *renderer, float x, float y, Uint32 c);
|
||||
SDL_bool SDLTest_DrawCharacter(SDL_Renderer *renderer, float x, float y, Uint32 c);
|
||||
|
||||
/*
|
||||
* Draw a UTF-8 string in the currently set font.
|
||||
@ -64,9 +64,9 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, float x, float y, Uint32 c);
|
||||
* \param y The Y coordinate of the upper left corner of the string.
|
||||
* \param s The string to draw.
|
||||
*
|
||||
* \returns 0 on success, -1 on failure.
|
||||
* \returns SDL_TRUE on success, SDL_FALSE on failure.
|
||||
*/
|
||||
int SDLTest_DrawString(SDL_Renderer *renderer, float x, float y, const char *s);
|
||||
SDL_bool SDLTest_DrawString(SDL_Renderer *renderer, float x, float y, const char *s);
|
||||
|
||||
/*
|
||||
* Data used for multi-line text output
|
||||
|
@ -381,12 +381,12 @@ extern SDL_DECLSPEC SDL_ThreadID SDLCALL SDL_GetThreadID(SDL_Thread *thread);
|
||||
* an administrator account. Be prepared for this to fail.
|
||||
*
|
||||
* \param priority the SDL_ThreadPriority to set.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority);
|
||||
|
||||
/**
|
||||
* Wait for a thread to finish.
|
||||
@ -504,7 +504,7 @@ typedef void (SDLCALL *SDL_TLSDestructorCallback)(void *value);
|
||||
* \param value the value to associate with the ID for the current thread.
|
||||
* \param destructor a function called when the thread exits, to free the
|
||||
* value, may be NULL.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
@ -513,7 +513,7 @@ typedef void (SDLCALL *SDL_TLSDestructorCallback)(void *value);
|
||||
*
|
||||
* \sa SDL_GetTLS
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetTLS(SDL_TLSID *id, const void *value, SDL_TLSDestructorCallback destructor);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetTLS(SDL_TLSID *id, const void *value, SDL_TLSDestructorCallback destructor);
|
||||
|
||||
/**
|
||||
* Cleanup all TLS data for this thread.
|
||||
|
@ -95,24 +95,24 @@ typedef enum SDL_TimeFormat
|
||||
* format, may be NULL.
|
||||
* \param timeFormat a pointer to the SDL_TimeFormat to hold the returned time
|
||||
* format, may be NULL.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetDateTimeLocalePreferences(SDL_DateFormat *dateFormat, SDL_TimeFormat *timeFormat);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetDateTimeLocalePreferences(SDL_DateFormat *dateFormat, SDL_TimeFormat *timeFormat);
|
||||
|
||||
/**
|
||||
* Gets the current value of the system realtime clock in nanoseconds since
|
||||
* Jan 1, 1970 in Universal Coordinated Time (UTC).
|
||||
*
|
||||
* \param ticks the SDL_Time to hold the returned tick count.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetCurrentTime(SDL_Time *ticks);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetCurrentTime(SDL_Time *ticks);
|
||||
|
||||
/**
|
||||
* Converts an SDL_Time in nanoseconds since the epoch to a calendar time in
|
||||
@ -123,12 +123,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetCurrentTime(SDL_Time *ticks);
|
||||
* \param localTime the resulting SDL_DateTime will be expressed in local time
|
||||
* if true, otherwise it will be in Universal Coordinated
|
||||
* Time (UTC).
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime);
|
||||
|
||||
/**
|
||||
* Converts a calendar time to an SDL_Time in nanoseconds since the epoch.
|
||||
@ -138,12 +138,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime
|
||||
*
|
||||
* \param dt the source SDL_DateTime.
|
||||
* \param ticks the resulting SDL_Time.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_DateTimeToTime(const SDL_DateTime *dt, SDL_Time *ticks);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_DateTimeToTime(const SDL_DateTime *dt, SDL_Time *ticks);
|
||||
|
||||
/**
|
||||
* Converts an SDL time into a Windows FILETIME (100-nanosecond intervals
|
||||
@ -181,7 +181,7 @@ extern SDL_DECLSPEC SDL_Time SDLCALL SDL_TimeFromWindows(Uint32 dwLowDateTime, U
|
||||
*
|
||||
* \param year the year.
|
||||
* \param month the month [1-12].
|
||||
* \returns the number of days in the requested month or a negative error code
|
||||
* \returns the number of days in the requested month or -1
|
||||
* on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -194,8 +194,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetDaysInMonth(int year, int month);
|
||||
* \param year the year component of the date.
|
||||
* \param month the month component of the date.
|
||||
* \param day the day component of the date.
|
||||
* \returns the day of year [0-365] if the date is valid or a negative error
|
||||
* code on failure; call SDL_GetError() for more information.
|
||||
* \returns the day of year [0-365] if the date is valid or -1
|
||||
* on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
@ -207,8 +207,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetDayOfYear(int year, int month, int day);
|
||||
* \param year the year component of the date.
|
||||
* \param month the month component of the date.
|
||||
* \param day the day component of the date.
|
||||
* \returns a value between 0 and 6 (0 being Sunday) if the date is valid or a
|
||||
* negative error code on failure; call SDL_GetError() for more
|
||||
* \returns a value between 0 and 6 (0 being Sunday) if the date is valid or -1
|
||||
* on failure; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
|
@ -263,14 +263,14 @@ extern SDL_DECLSPEC SDL_TimerID SDLCALL SDL_AddTimerNS(Uint64 interval, SDL_NSTi
|
||||
* Remove a timer created with SDL_AddTimer().
|
||||
*
|
||||
* \param id the ID of the timer to remove.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_AddTimer
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_RemoveTimer(SDL_TimerID id);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
|
@ -348,8 +348,7 @@ typedef enum SDL_GLContextResetNotification
|
||||
/**
|
||||
* Get the number of video drivers compiled into SDL.
|
||||
*
|
||||
* \returns a number >= 1 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
* \returns the number of built in video drivers.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
@ -476,7 +475,7 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetDisplayName(SDL_DisplayID displa
|
||||
*
|
||||
* \param displayID the instance ID of the display to query.
|
||||
* \param rect the SDL_Rect structure filled in with the display bounds.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -484,7 +483,7 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetDisplayName(SDL_DisplayID displa
|
||||
* \sa SDL_GetDisplayUsableBounds
|
||||
* \sa SDL_GetDisplays
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect);
|
||||
|
||||
/**
|
||||
* Get the usable desktop area represented by a display, in screen
|
||||
@ -500,7 +499,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetDisplayBounds(SDL_DisplayID displayID, SD
|
||||
*
|
||||
* \param displayID the instance ID of the display to query.
|
||||
* \param rect the SDL_Rect structure filled in with the display bounds.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -508,7 +507,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetDisplayBounds(SDL_DisplayID displayID, SD
|
||||
* \sa SDL_GetDisplayBounds
|
||||
* \sa SDL_GetDisplays
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect);
|
||||
|
||||
/**
|
||||
* Get the orientation of a display when it is unrotated.
|
||||
@ -599,7 +598,7 @@ extern SDL_DECLSPEC SDL_DisplayMode ** SDLCALL SDL_GetFullscreenDisplayModes(SDL
|
||||
* the search.
|
||||
* \param mode a pointer filled in with the closest display mode equal to or
|
||||
* larger than the desired mode.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -607,7 +606,7 @@ extern SDL_DECLSPEC SDL_DisplayMode ** SDLCALL SDL_GetFullscreenDisplayModes(SDL
|
||||
* \sa SDL_GetDisplays
|
||||
* \sa SDL_GetFullscreenDisplayModes
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, SDL_bool include_high_density_modes, SDL_DisplayMode *mode);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, SDL_bool include_high_density_modes, SDL_DisplayMode *mode);
|
||||
|
||||
/**
|
||||
* Get information about the desktop's display mode.
|
||||
@ -752,7 +751,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetWindowDisplayScale(SDL_Window *window);
|
||||
* borderless fullscreen desktop mode, or one of the fullscreen
|
||||
* modes returned by SDL_GetFullscreenDisplayModes() to set an
|
||||
* exclusive fullscreen mode.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -761,7 +760,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetWindowDisplayScale(SDL_Window *window);
|
||||
* \sa SDL_SetWindowFullscreen
|
||||
* \sa SDL_SyncWindow
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode);
|
||||
|
||||
/**
|
||||
* Query the display mode to use when a window is visible at fullscreen.
|
||||
@ -1328,14 +1327,14 @@ extern SDL_DECLSPEC SDL_WindowFlags SDLCALL SDL_GetWindowFlags(SDL_Window *windo
|
||||
*
|
||||
* \param window the window to change.
|
||||
* \param title the desired window title in UTF-8 format.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetWindowTitle
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowTitle(SDL_Window *window, const char *title);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowTitle(SDL_Window *window, const char *title);
|
||||
|
||||
/**
|
||||
* Get the title of a window.
|
||||
@ -1365,12 +1364,12 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetWindowTitle(SDL_Window *window);
|
||||
*
|
||||
* \param window the window to change.
|
||||
* \param icon an SDL_Surface structure containing the icon for the window.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon);
|
||||
|
||||
/**
|
||||
* Request that the window's position be set.
|
||||
@ -1402,7 +1401,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surfac
|
||||
* `SDL_WINDOWPOS_UNDEFINED`.
|
||||
* \param y the y coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or
|
||||
* `SDL_WINDOWPOS_UNDEFINED`.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1410,7 +1409,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surfac
|
||||
* \sa SDL_GetWindowPosition
|
||||
* \sa SDL_SyncWindow
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y);
|
||||
|
||||
/**
|
||||
* Get the position of a window.
|
||||
@ -1426,14 +1425,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x,
|
||||
* NULL.
|
||||
* \param y a pointer filled in with the y position of the window, may be
|
||||
* NULL.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetWindowPosition
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y);
|
||||
|
||||
/**
|
||||
* Request that the size of a window's client area be set.
|
||||
@ -1460,7 +1459,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x
|
||||
* \param window the window to change.
|
||||
* \param w the width of the window, must be > 0.
|
||||
* \param h the height of the window, must be > 0.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1469,7 +1468,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x
|
||||
* \sa SDL_SetWindowFullscreenMode
|
||||
* \sa SDL_SyncWindow
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h);
|
||||
|
||||
/**
|
||||
* Get the size of a window's client area.
|
||||
@ -1481,7 +1480,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int
|
||||
* \param window the window to query the width and height from.
|
||||
* \param w a pointer filled in with the width of the window, may be NULL.
|
||||
* \param h a pointer filled in with the height of the window, may be NULL.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1490,7 +1489,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int
|
||||
* \sa SDL_GetWindowSizeInPixels
|
||||
* \sa SDL_SetWindowSize
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
|
||||
|
||||
/**
|
||||
* Get the safe area for this window.
|
||||
@ -1505,12 +1504,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, in
|
||||
* \param window the window to query.
|
||||
* \param rect a pointer filled in with the client area that is safe for
|
||||
* interactive content.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSafeArea(SDL_Window *window, SDL_Rect *rect);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetWindowSafeArea(SDL_Window *window, SDL_Rect *rect);
|
||||
|
||||
/**
|
||||
* Request that the aspect ratio of a window's client area be set.
|
||||
@ -1541,7 +1540,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSafeArea(SDL_Window *window, SDL_Re
|
||||
* limit.
|
||||
* \param max_aspect the maximum aspect ratio of the window, or 0.0f for no
|
||||
* limit.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1549,7 +1548,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSafeArea(SDL_Window *window, SDL_Re
|
||||
* \sa SDL_GetWindowAspectRatio
|
||||
* \sa SDL_SyncWindow
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowAspectRatio(SDL_Window *window, float min_aspect, float max_aspect);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowAspectRatio(SDL_Window *window, float min_aspect, float max_aspect);
|
||||
|
||||
/**
|
||||
* Get the size of a window's client area.
|
||||
@ -1559,14 +1558,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowAspectRatio(SDL_Window *window, flo
|
||||
* window, may be NULL.
|
||||
* \param max_aspect a pointer filled in with the maximum aspect ratio of the
|
||||
* window, may be NULL.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetWindowAspectRatio
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetWindowAspectRatio(SDL_Window *window, float *min_aspect, float *max_aspect);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetWindowAspectRatio(SDL_Window *window, float *min_aspect, float *max_aspect);
|
||||
|
||||
/**
|
||||
* Get the size of a window's borders (decorations) around the client area.
|
||||
@ -1593,14 +1592,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowAspectRatio(SDL_Window *window, flo
|
||||
* border; NULL is permitted.
|
||||
* \param right pointer to variable for storing the size of the right border;
|
||||
* NULL is permitted.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetWindowSize
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right);
|
||||
|
||||
/**
|
||||
* Get the size of a window's client area, in pixels.
|
||||
@ -1610,7 +1609,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int
|
||||
* NULL.
|
||||
* \param h a pointer to variable for storing the height in pixels, may be
|
||||
* NULL.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1618,7 +1617,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int
|
||||
* \sa SDL_CreateWindow
|
||||
* \sa SDL_GetWindowSize
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h);
|
||||
|
||||
/**
|
||||
* Set the minimum size of a window's client area.
|
||||
@ -1626,7 +1625,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, in
|
||||
* \param window the window to change.
|
||||
* \param min_w the minimum width of the window, or 0 for no limit.
|
||||
* \param min_h the minimum height of the window, or 0 for no limit.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1634,7 +1633,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, in
|
||||
* \sa SDL_GetWindowMinimumSize
|
||||
* \sa SDL_SetWindowMaximumSize
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h);
|
||||
|
||||
/**
|
||||
* Get the minimum size of a window's client area.
|
||||
@ -1644,7 +1643,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int
|
||||
* NULL.
|
||||
* \param h a pointer filled in with the minimum height of the window, may be
|
||||
* NULL.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1652,7 +1651,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int
|
||||
* \sa SDL_GetWindowMaximumSize
|
||||
* \sa SDL_SetWindowMinimumSize
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h);
|
||||
|
||||
/**
|
||||
* Set the maximum size of a window's client area.
|
||||
@ -1660,7 +1659,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int
|
||||
* \param window the window to change.
|
||||
* \param max_w the maximum width of the window, or 0 for no limit.
|
||||
* \param max_h the maximum height of the window, or 0 for no limit.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1668,7 +1667,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int
|
||||
* \sa SDL_GetWindowMaximumSize
|
||||
* \sa SDL_SetWindowMinimumSize
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h);
|
||||
|
||||
/**
|
||||
* Get the maximum size of a window's client area.
|
||||
@ -1678,7 +1677,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int
|
||||
* NULL.
|
||||
* \param h a pointer filled in with the maximum height of the window, may be
|
||||
* NULL.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1686,7 +1685,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int
|
||||
* \sa SDL_GetWindowMinimumSize
|
||||
* \sa SDL_SetWindowMaximumSize
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h);
|
||||
|
||||
/**
|
||||
* Set the border state of a window.
|
||||
@ -1699,14 +1698,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int
|
||||
*
|
||||
* \param window the window of which to change the border state.
|
||||
* \param bordered SDL_FALSE to remove border, SDL_TRUE to add border.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetWindowFlags
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered);
|
||||
|
||||
/**
|
||||
* Set the user-resizable state of a window.
|
||||
@ -1719,14 +1718,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowBordered(SDL_Window *window, SDL_bo
|
||||
*
|
||||
* \param window the window of which to change the resizable state.
|
||||
* \param resizable SDL_TRUE to allow resizing, SDL_FALSE to disallow.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetWindowFlags
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable);
|
||||
|
||||
/**
|
||||
* Set the window to always be above the others.
|
||||
@ -1737,20 +1736,20 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowResizable(SDL_Window *window, SDL_b
|
||||
* \param window the window of which to change the always on top state.
|
||||
* \param on_top SDL_TRUE to set the window always on top, SDL_FALSE to
|
||||
* disable.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetWindowFlags
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top);
|
||||
|
||||
/**
|
||||
* Show a window.
|
||||
*
|
||||
* \param window the window to show.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1758,20 +1757,20 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL
|
||||
* \sa SDL_HideWindow
|
||||
* \sa SDL_RaiseWindow
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ShowWindow(SDL_Window *window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ShowWindow(SDL_Window *window);
|
||||
|
||||
/**
|
||||
* Hide a window.
|
||||
*
|
||||
* \param window the window to hide.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_ShowWindow
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_HideWindow(SDL_Window *window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HideWindow(SDL_Window *window);
|
||||
|
||||
/**
|
||||
* Request that a window be raised above other windows and gain the input
|
||||
@ -1784,12 +1783,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_HideWindow(SDL_Window *window);
|
||||
* the window will have the SDL_WINDOW_INPUT_FOCUS flag set.
|
||||
*
|
||||
* \param window the window to raise.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_RaiseWindow(SDL_Window *window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RaiseWindow(SDL_Window *window);
|
||||
|
||||
/**
|
||||
* Request that the window be made as large as possible.
|
||||
@ -1812,7 +1811,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_RaiseWindow(SDL_Window *window);
|
||||
* and Wayland window managers may vary.
|
||||
*
|
||||
* \param window the window to maximize.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1821,7 +1820,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_RaiseWindow(SDL_Window *window);
|
||||
* \sa SDL_RestoreWindow
|
||||
* \sa SDL_SyncWindow
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_MaximizeWindow(SDL_Window *window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_MaximizeWindow(SDL_Window *window);
|
||||
|
||||
/**
|
||||
* Request that the window be minimized to an iconic representation.
|
||||
@ -1836,7 +1835,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_MaximizeWindow(SDL_Window *window);
|
||||
* deny the state change.
|
||||
*
|
||||
* \param window the window to minimize.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1845,7 +1844,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_MaximizeWindow(SDL_Window *window);
|
||||
* \sa SDL_RestoreWindow
|
||||
* \sa SDL_SyncWindow
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_MinimizeWindow(SDL_Window *window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_MinimizeWindow(SDL_Window *window);
|
||||
|
||||
/**
|
||||
* Request that the size and position of a minimized or maximized window be
|
||||
@ -1861,7 +1860,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_MinimizeWindow(SDL_Window *window);
|
||||
* deny the state change.
|
||||
*
|
||||
* \param window the window to restore.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1870,7 +1869,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_MinimizeWindow(SDL_Window *window);
|
||||
* \sa SDL_MinimizeWindow
|
||||
* \sa SDL_SyncWindow
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_RestoreWindow(SDL_Window *window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RestoreWindow(SDL_Window *window);
|
||||
|
||||
/**
|
||||
* Request that the window's fullscreen state be changed.
|
||||
@ -1891,7 +1890,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_RestoreWindow(SDL_Window *window);
|
||||
* \param window the window to change.
|
||||
* \param fullscreen SDL_TRUE for fullscreen mode, SDL_FALSE for windowed
|
||||
* mode.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -1900,7 +1899,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_RestoreWindow(SDL_Window *window);
|
||||
* \sa SDL_SetWindowFullscreenMode
|
||||
* \sa SDL_SyncWindow
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window *window, SDL_bool fullscreen);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowFullscreen(SDL_Window *window, SDL_bool fullscreen);
|
||||
|
||||
/**
|
||||
* Block until any pending window state is finalized.
|
||||
@ -1916,9 +1915,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window *window, SDL_
|
||||
*
|
||||
* \param window the window for which to wait for the pending state to be
|
||||
* applied.
|
||||
* \returns 0 on success, a positive value if the operation timed out before
|
||||
* the window was in the requested state, or a negative error code on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
* \returns SDL_TRUE on success or SDL_FALSE if the operation timed out before
|
||||
* the window was in the requested state.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
@ -1930,7 +1928,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window *window, SDL_
|
||||
* \sa SDL_RestoreWindow
|
||||
* \sa SDL_HINT_VIDEO_SYNC_WINDOW_OPERATIONS
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SyncWindow(SDL_Window *window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SyncWindow(SDL_Window *window);
|
||||
|
||||
/**
|
||||
* Return whether the window has a surface associated with it.
|
||||
@ -1987,14 +1985,14 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window *windo
|
||||
*
|
||||
* \param window the window.
|
||||
* \param vsync the vertical refresh sync interval.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetWindowSurfaceVSync
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowSurfaceVSync(SDL_Window *window, int vsync);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowSurfaceVSync(SDL_Window *window, int vsync);
|
||||
|
||||
#define SDL_WINDOW_SURFACE_VSYNC_DISABLED 0
|
||||
#define SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE (-1)
|
||||
@ -2005,14 +2003,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowSurfaceVSync(SDL_Window *window, in
|
||||
* \param window the window to query.
|
||||
* \param vsync an int filled with the current vertical refresh sync interval.
|
||||
* See SDL_SetWindowSurfaceVSync() for the meaning of the value.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetWindowSurfaceVSync
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSurfaceVSync(SDL_Window *window, int *vsync);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetWindowSurfaceVSync(SDL_Window *window, int *vsync);
|
||||
|
||||
/**
|
||||
* Copy the window surface to the screen.
|
||||
@ -2023,7 +2021,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSurfaceVSync(SDL_Window *window, in
|
||||
* This function is equivalent to the SDL 1.2 API SDL_Flip().
|
||||
*
|
||||
* \param window the window to update.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -2031,7 +2029,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSurfaceVSync(SDL_Window *window, in
|
||||
* \sa SDL_GetWindowSurface
|
||||
* \sa SDL_UpdateWindowSurfaceRects
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window *window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_UpdateWindowSurface(SDL_Window *window);
|
||||
|
||||
/**
|
||||
* Copy areas of the window surface to the screen.
|
||||
@ -2050,7 +2048,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window *window);
|
||||
* \param rects an array of SDL_Rect structures representing areas of the
|
||||
* surface to copy, in pixels.
|
||||
* \param numrects the number of rectangles.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -2058,13 +2056,13 @@ extern SDL_DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window *window);
|
||||
* \sa SDL_GetWindowSurface
|
||||
* \sa SDL_UpdateWindowSurface
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, int numrects);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, int numrects);
|
||||
|
||||
/**
|
||||
* Destroy the surface associated with the window.
|
||||
*
|
||||
* \param window the window to update.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -2072,7 +2070,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window *window,
|
||||
* \sa SDL_GetWindowSurface
|
||||
* \sa SDL_WindowHasSurface
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_DestroyWindowSurface(SDL_Window *window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_DestroyWindowSurface(SDL_Window *window);
|
||||
|
||||
/**
|
||||
* Set a window's keyboard grab mode.
|
||||
@ -2095,7 +2093,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_DestroyWindowSurface(SDL_Window *window);
|
||||
*
|
||||
* \param window the window for which the keyboard grab mode should be set.
|
||||
* \param grabbed this is SDL_TRUE to grab keyboard, and SDL_FALSE to release.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -2103,7 +2101,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_DestroyWindowSurface(SDL_Window *window);
|
||||
* \sa SDL_GetWindowKeyboardGrab
|
||||
* \sa SDL_SetWindowMouseGrab
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed);
|
||||
|
||||
/**
|
||||
* Set a window's mouse grab mode.
|
||||
@ -2112,7 +2110,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SD
|
||||
*
|
||||
* \param window the window for which the mouse grab mode should be set.
|
||||
* \param grabbed this is SDL_TRUE to grab mouse, and SDL_FALSE to release.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -2120,7 +2118,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SD
|
||||
* \sa SDL_GetWindowMouseGrab
|
||||
* \sa SDL_SetWindowKeyboardGrab
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed);
|
||||
|
||||
/**
|
||||
* Get a window's keyboard grab mode.
|
||||
@ -2167,7 +2165,7 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void);
|
||||
* \param window the window that will be associated with the barrier.
|
||||
* \param rect a rectangle area in window-relative coordinates. If NULL the
|
||||
* barrier for the specified window will be destroyed.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -2175,7 +2173,7 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void);
|
||||
* \sa SDL_GetWindowMouseRect
|
||||
* \sa SDL_SetWindowMouseGrab
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect);
|
||||
|
||||
/**
|
||||
* Get the mouse confinement rectangle of a window.
|
||||
@ -2200,14 +2198,14 @@ extern SDL_DECLSPEC const SDL_Rect * SDLCALL SDL_GetWindowMouseRect(SDL_Window *
|
||||
*
|
||||
* \param window the window which will be made transparent or opaque.
|
||||
* \param opacity the opacity value (0.0f - transparent, 1.0f - opaque).
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetWindowOpacity
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowOpacity(SDL_Window *window, float opacity);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowOpacity(SDL_Window *window, float opacity);
|
||||
|
||||
/**
|
||||
* Get the opacity of a window.
|
||||
@ -2216,8 +2214,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowOpacity(SDL_Window *window, float o
|
||||
* as 1.0f without error.
|
||||
*
|
||||
* \param window the window to get the current opacity value from.
|
||||
* \returns the opacity, (0.0f - transparent, 1.0f - opaque), or a negative
|
||||
* error code on failure; call SDL_GetError() for more information.
|
||||
* \returns the opacity, (0.0f - transparent, 1.0f - opaque), or -1.0f on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
@ -2237,12 +2234,12 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetWindowOpacity(SDL_Window *window);
|
||||
*
|
||||
* \param modal_window the window that should be set modal.
|
||||
* \param parent_window the parent window for the modal window.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window);
|
||||
|
||||
/**
|
||||
* Set whether the window may have input focus.
|
||||
@ -2250,12 +2247,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window *modal_window,
|
||||
* \param window the window to set focusable state.
|
||||
* \param focusable SDL_TRUE to allow input focus, SDL_FALSE to not allow
|
||||
* input focus.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowFocusable(SDL_Window *window, SDL_bool focusable);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowFocusable(SDL_Window *window, SDL_bool focusable);
|
||||
|
||||
|
||||
/**
|
||||
@ -2274,12 +2271,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowFocusable(SDL_Window *window, SDL_b
|
||||
* the client area.
|
||||
* \param y the y coordinate of the menu, relative to the origin (top-left) of
|
||||
* the client area.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ShowWindowSystemMenu(SDL_Window *window, int x, int y);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ShowWindowSystemMenu(SDL_Window *window, int x, int y);
|
||||
|
||||
/**
|
||||
* Possible return values from the SDL_HitTest callback.
|
||||
@ -2337,7 +2334,7 @@ typedef SDL_HitTestResult (SDLCALL *SDL_HitTest)(SDL_Window *win,
|
||||
* Specifying NULL for a callback disables hit-testing. Hit-testing is
|
||||
* disabled by default.
|
||||
*
|
||||
* Platforms that don't support this functionality will return -1
|
||||
* Platforms that don't support this functionality will return SDL_FALSE
|
||||
* unconditionally, even if you're attempting to disable hit-testing.
|
||||
*
|
||||
* Your callback may fire at any time, and its firing does not indicate any
|
||||
@ -2351,12 +2348,12 @@ typedef SDL_HitTestResult (SDLCALL *SDL_HitTest)(SDL_Window *win,
|
||||
* \param window the window to set hit-testing on.
|
||||
* \param callback the function to call when doing a hit-test.
|
||||
* \param callback_data an app-defined void pointer passed to **callback**.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *callback_data);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *callback_data);
|
||||
|
||||
/**
|
||||
* Set the shape of a transparent window.
|
||||
@ -2375,24 +2372,24 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowHitTest(SDL_Window *window, SDL_Hit
|
||||
* \param window the window.
|
||||
* \param shape the surface representing the shape of the window, or NULL to
|
||||
* remove any current shape.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape);
|
||||
|
||||
/**
|
||||
* Request a window to demand attention from the user.
|
||||
*
|
||||
* \param window the window to be flashed.
|
||||
* \param operation the operation to perform.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation);
|
||||
|
||||
/**
|
||||
* Destroy a window.
|
||||
@ -2431,7 +2428,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ScreenSaverEnabled(void);
|
||||
/**
|
||||
* Allow the screen to be blanked by a screen saver.
|
||||
*
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -2439,7 +2436,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ScreenSaverEnabled(void);
|
||||
* \sa SDL_DisableScreenSaver
|
||||
* \sa SDL_ScreenSaverEnabled
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_EnableScreenSaver(void);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_EnableScreenSaver(void);
|
||||
|
||||
/**
|
||||
* Prevent the screen from being blanked by a screen saver.
|
||||
@ -2450,7 +2447,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_EnableScreenSaver(void);
|
||||
* The screensaver is disabled by default, but this may by changed by
|
||||
* SDL_HINT_VIDEO_ALLOW_SCREENSAVER.
|
||||
*
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -2458,7 +2455,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_EnableScreenSaver(void);
|
||||
* \sa SDL_EnableScreenSaver
|
||||
* \sa SDL_ScreenSaverEnabled
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_DisableScreenSaver(void);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_DisableScreenSaver(void);
|
||||
|
||||
|
||||
/**
|
||||
@ -2478,7 +2475,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_DisableScreenSaver(void);
|
||||
*
|
||||
* \param path the platform dependent OpenGL library name, or NULL to open the
|
||||
* default OpenGL library.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -2486,7 +2483,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_DisableScreenSaver(void);
|
||||
* \sa SDL_GL_GetProcAddress
|
||||
* \sa SDL_GL_UnloadLibrary
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GL_LoadLibrary(const char *path);
|
||||
|
||||
/**
|
||||
* Get an OpenGL function by name.
|
||||
@ -2609,7 +2606,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void);
|
||||
* \param attr an SDL_GLattr enum value specifying the OpenGL attribute to
|
||||
* set.
|
||||
* \param value the desired value for the attribute.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -2617,7 +2614,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void);
|
||||
* \sa SDL_GL_GetAttribute
|
||||
* \sa SDL_GL_ResetAttributes
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
|
||||
|
||||
/**
|
||||
* Get the actual value for an attribute from the current context.
|
||||
@ -2625,7 +2622,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
|
||||
* \param attr an SDL_GLattr enum value specifying the OpenGL attribute to
|
||||
* get.
|
||||
* \param value a pointer filled in with the current value of `attr`.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -2633,7 +2630,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
|
||||
* \sa SDL_GL_ResetAttributes
|
||||
* \sa SDL_GL_SetAttribute
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
|
||||
|
||||
/**
|
||||
* Create an OpenGL context for an OpenGL window, and make it current.
|
||||
@ -2664,14 +2661,14 @@ extern SDL_DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *windo
|
||||
*
|
||||
* \param window the window to associate with the context.
|
||||
* \param context the OpenGL context to associate with the window.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GL_CreateContext
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context);
|
||||
|
||||
/**
|
||||
* Get the currently active OpenGL window.
|
||||
@ -2760,7 +2757,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_EGL_SetAttributeCallbacks(SDL_EGLAttribArra
|
||||
* the vertical retrace for a given frame, it swaps buffers immediately, which
|
||||
* might be less jarring for the user during occasional framerate drops. If an
|
||||
* application requests adaptive vsync and the system does not support it,
|
||||
* this function will fail and return -1. In such a case, you should probably
|
||||
* this function will fail and return SDL_FALSE. In such a case, you should probably
|
||||
* retry the call with 1 for the interval.
|
||||
*
|
||||
* Adaptive vsync is implemented for some glX drivers with
|
||||
@ -2772,14 +2769,14 @@ extern SDL_DECLSPEC void SDLCALL SDL_EGL_SetAttributeCallbacks(SDL_EGLAttribArra
|
||||
*
|
||||
* \param interval 0 for immediate updates, 1 for updates synchronized with
|
||||
* the vertical retrace, -1 for adaptive vsync.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GL_GetSwapInterval
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GL_SetSwapInterval(int interval);
|
||||
|
||||
/**
|
||||
* Get the swap interval for the current OpenGL context.
|
||||
@ -2791,14 +2788,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval);
|
||||
* synchronization, 1 if the buffer swap is synchronized with
|
||||
* the vertical retrace, and -1 if late swaps happen
|
||||
* immediately instead of waiting for the next retrace.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GL_SetSwapInterval
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(int *interval);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GL_GetSwapInterval(int *interval);
|
||||
|
||||
/**
|
||||
* Update a window with OpenGL rendering.
|
||||
@ -2811,25 +2808,25 @@ extern SDL_DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(int *interval);
|
||||
* extra.
|
||||
*
|
||||
* \param window the window to change.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GL_SwapWindow(SDL_Window *window);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GL_SwapWindow(SDL_Window *window);
|
||||
|
||||
/**
|
||||
* Delete an OpenGL context.
|
||||
*
|
||||
* \param context the OpenGL context to be deleted.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GL_CreateContext
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GL_DestroyContext(SDL_GLContext context);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GL_DestroyContext(SDL_GLContext context);
|
||||
|
||||
/* @} *//* OpenGL support functions */
|
||||
|
||||
|
@ -95,7 +95,7 @@ struct VkAllocationCallbacks;
|
||||
* library version.
|
||||
*
|
||||
* \param path the platform dependent Vulkan loader library name or NULL.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -103,7 +103,7 @@ struct VkAllocationCallbacks;
|
||||
* \sa SDL_Vulkan_GetVkGetInstanceProcAddr
|
||||
* \sa SDL_Vulkan_UnloadLibrary
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_Vulkan_LoadLibrary(const char *path);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_Vulkan_LoadLibrary(const char *path);
|
||||
|
||||
/**
|
||||
* Get the address of the `vkGetInstanceProcAddr` function.
|
||||
@ -175,7 +175,7 @@ extern SDL_DECLSPEC char const * const * SDLCALL SDL_Vulkan_GetInstanceExtension
|
||||
* allocator that creates the surface. Can be NULL.
|
||||
* \param surface a pointer to a VkSurfaceKHR handle to output the newly
|
||||
* created surface.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
@ -183,10 +183,10 @@ extern SDL_DECLSPEC char const * const * SDLCALL SDL_Vulkan_GetInstanceExtension
|
||||
* \sa SDL_Vulkan_GetInstanceExtensions
|
||||
* \sa SDL_Vulkan_DestroySurface
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_Vulkan_CreateSurface(SDL_Window *window,
|
||||
VkInstance instance,
|
||||
const struct VkAllocationCallbacks *allocator,
|
||||
VkSurfaceKHR* surface);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_Vulkan_CreateSurface(SDL_Window *window,
|
||||
VkInstance instance,
|
||||
const struct VkAllocationCallbacks *allocator,
|
||||
VkSurfaceKHR* surface);
|
||||
|
||||
/**
|
||||
* Destroy the Vulkan rendering surface of a window.
|
||||
|
38
src/SDL.c
38
src/SDL.c
@ -59,8 +59,8 @@
|
||||
// Initialization/Cleanup routines
|
||||
#include "timer/SDL_timer_c.h"
|
||||
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
||||
extern int SDL_HelperWindowCreate(void);
|
||||
extern int SDL_HelperWindowDestroy(void);
|
||||
extern bool SDL_HelperWindowCreate(void);
|
||||
extern void SDL_HelperWindowDestroy(void);
|
||||
#endif
|
||||
|
||||
#ifdef SDL_BUILD_MAJOR_VERSION
|
||||
@ -109,12 +109,12 @@ SDL_NORETURN void SDL_ExitProcess(int exitcode)
|
||||
|
||||
// App metadata
|
||||
|
||||
int SDL_SetAppMetadata(const char *appname, const char *appversion, const char *appidentifier)
|
||||
SDL_bool SDL_SetAppMetadata(const char *appname, const char *appversion, const char *appidentifier)
|
||||
{
|
||||
SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_NAME_STRING, appname);
|
||||
SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_VERSION_STRING, appversion);
|
||||
SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_IDENTIFIER_STRING, appidentifier);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SDL_ValidMetadataProperty(const char *name)
|
||||
@ -135,7 +135,7 @@ static bool SDL_ValidMetadataProperty(const char *name)
|
||||
return false;
|
||||
}
|
||||
|
||||
int SDL_SetAppMetadataProperty(const char *name, const char *value)
|
||||
SDL_bool SDL_SetAppMetadataProperty(const char *name, const char *value)
|
||||
{
|
||||
if (!SDL_ValidMetadataProperty(name)) {
|
||||
return SDL_InvalidParamError("name");
|
||||
@ -238,7 +238,7 @@ static bool SDL_InitOrIncrementSubsystem(Uint32 subsystem)
|
||||
++SDL_SubsystemRefCount[subsystem_index];
|
||||
return true;
|
||||
}
|
||||
return SDL_InitSubSystem(subsystem) == 0;
|
||||
return SDL_InitSubSystem(subsystem);
|
||||
}
|
||||
|
||||
void SDL_SetMainReady(void)
|
||||
@ -268,7 +268,7 @@ static void SDL_QuitMainThread(void)
|
||||
SDL_QuitTLSData();
|
||||
}
|
||||
|
||||
int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
SDL_bool SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
{
|
||||
Uint32 flags_initialized = 0;
|
||||
|
||||
@ -284,7 +284,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
||||
if (flags & (SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK)) {
|
||||
if (SDL_HelperWindowCreate() < 0) {
|
||||
if (!SDL_HelperWindowCreate()) {
|
||||
goto quit_and_error;
|
||||
}
|
||||
}
|
||||
@ -294,7 +294,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
if (flags & SDL_INIT_EVENTS) {
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_EVENTS)) {
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_EVENTS);
|
||||
if (SDL_InitEvents() < 0) {
|
||||
if (!SDL_InitEvents()) {
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_EVENTS);
|
||||
goto quit_and_error;
|
||||
}
|
||||
@ -308,7 +308,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
if (flags & SDL_INIT_TIMER) {
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_TIMER)) {
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_TIMER);
|
||||
if (SDL_InitTimers() < 0) {
|
||||
if (!SDL_InitTimers()) {
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_TIMER);
|
||||
goto quit_and_error;
|
||||
}
|
||||
@ -328,7 +328,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
}
|
||||
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_VIDEO);
|
||||
if (SDL_VideoInit(NULL) < 0) {
|
||||
if (!SDL_VideoInit(NULL)) {
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_VIDEO);
|
||||
goto quit_and_error;
|
||||
}
|
||||
@ -352,7 +352,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
}
|
||||
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_AUDIO);
|
||||
if (SDL_InitAudio(NULL) < 0) {
|
||||
if (!SDL_InitAudio(NULL)) {
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_AUDIO);
|
||||
goto quit_and_error;
|
||||
}
|
||||
@ -376,7 +376,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
}
|
||||
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_JOYSTICK);
|
||||
if (SDL_InitJoysticks() < 0) {
|
||||
if (!SDL_InitJoysticks()) {
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_JOYSTICK);
|
||||
goto quit_and_error;
|
||||
}
|
||||
@ -399,7 +399,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
}
|
||||
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_GAMEPAD);
|
||||
if (SDL_InitGamepads() < 0) {
|
||||
if (!SDL_InitGamepads()) {
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_GAMEPAD);
|
||||
goto quit_and_error;
|
||||
}
|
||||
@ -418,7 +418,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
#ifndef SDL_HAPTIC_DISABLED
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_HAPTIC)) {
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_HAPTIC);
|
||||
if (SDL_InitHaptics() < 0) {
|
||||
if (!SDL_InitHaptics()) {
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_HAPTIC);
|
||||
goto quit_and_error;
|
||||
}
|
||||
@ -437,7 +437,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
#ifndef SDL_SENSOR_DISABLED
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_SENSOR)) {
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_SENSOR);
|
||||
if (SDL_InitSensors() < 0) {
|
||||
if (!SDL_InitSensors()) {
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_SENSOR);
|
||||
goto quit_and_error;
|
||||
}
|
||||
@ -461,7 +461,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
}
|
||||
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_CAMERA);
|
||||
if (SDL_CameraInit(NULL) < 0) {
|
||||
if (!SDL_CameraInit(NULL)) {
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_CAMERA);
|
||||
goto quit_and_error;
|
||||
}
|
||||
@ -481,10 +481,10 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
|
||||
quit_and_error:
|
||||
SDL_QuitSubSystem(flags_initialized);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
int SDL_Init(SDL_InitFlags flags)
|
||||
SDL_bool SDL_Init(SDL_InitFlags flags)
|
||||
{
|
||||
return SDL_InitSubSystem(flags);
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
|
||||
messagebox.numbuttons = SDL_arraysize(buttons);
|
||||
messagebox.buttons = buttons;
|
||||
|
||||
if (SDL_ShowMessageBox(&messagebox, &selected) == 0) {
|
||||
if (SDL_ShowMessageBox(&messagebox, &selected)) {
|
||||
if (selected == -1) {
|
||||
state = SDL_ASSERTION_IGNORE;
|
||||
} else {
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "SDL_error_c.h"
|
||||
|
||||
int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||
SDL_bool SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||
{
|
||||
// Ignore call if invalid format pointer was passed
|
||||
if (fmt) {
|
||||
@ -56,7 +56,7 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *SDL_GetError(void)
|
||||
@ -77,23 +77,23 @@ const char *SDL_GetError(void)
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_ClearError(void)
|
||||
SDL_bool SDL_ClearError(void)
|
||||
{
|
||||
SDL_error *error = SDL_GetErrBuf(false);
|
||||
|
||||
if (error) {
|
||||
error->error = SDL_ErrorCodeNone;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_OutOfMemory(void)
|
||||
SDL_bool SDL_OutOfMemory(void)
|
||||
{
|
||||
SDL_error *error = SDL_GetErrBuf(true);
|
||||
|
||||
if (error) {
|
||||
error->error = SDL_ErrorCodeOutOfMemory;
|
||||
}
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ static void SDLCALL CleanupHintProperty(void *userdata, void *value)
|
||||
SDL_free(hint);
|
||||
}
|
||||
|
||||
int SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPriority priority)
|
||||
SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPriority priority)
|
||||
{
|
||||
if (!name || !*name) {
|
||||
return SDL_InvalidParamError("name");
|
||||
@ -79,10 +79,10 @@ int SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPriorit
|
||||
|
||||
const SDL_PropertiesID hints = GetHintProperties(true);
|
||||
if (!hints) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
int retval = -1;
|
||||
bool result = false;
|
||||
|
||||
SDL_LockProperties(hints);
|
||||
|
||||
@ -103,7 +103,7 @@ int SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPriorit
|
||||
SDL_free(old_value);
|
||||
}
|
||||
hint->priority = priority;
|
||||
retval = 0;
|
||||
result = true;
|
||||
}
|
||||
} else { // Couldn't find the hint? Add a new one.
|
||||
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
|
||||
@ -111,16 +111,16 @@ int SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPriorit
|
||||
hint->value = value ? SDL_strdup(value) : NULL;
|
||||
hint->priority = priority;
|
||||
hint->callbacks = NULL;
|
||||
retval = (SDL_SetPointerPropertyWithCleanup(hints, name, hint, CleanupHintProperty, NULL) != -1);
|
||||
result = SDL_SetPointerPropertyWithCleanup(hints, name, hint, CleanupHintProperty, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_UnlockProperties(hints);
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
int SDL_ResetHint(const char *name)
|
||||
SDL_bool SDL_ResetHint(const char *name)
|
||||
{
|
||||
if (!name || !*name) {
|
||||
return SDL_InvalidParamError("name");
|
||||
@ -130,10 +130,10 @@ int SDL_ResetHint(const char *name)
|
||||
|
||||
const SDL_PropertiesID hints = GetHintProperties(false);
|
||||
if (!hints) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
int retval = -1;
|
||||
bool result = false;
|
||||
|
||||
SDL_LockProperties(hints);
|
||||
|
||||
@ -150,12 +150,12 @@ int SDL_ResetHint(const char *name)
|
||||
SDL_free(hint->value);
|
||||
hint->value = NULL;
|
||||
hint->priority = SDL_HINT_DEFAULT;
|
||||
retval = 0;
|
||||
result = true;
|
||||
}
|
||||
|
||||
SDL_UnlockProperties(hints);
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void SDLCALL ResetHintsCallback(void *userdata, SDL_PropertiesID hints, const char *name)
|
||||
@ -185,7 +185,7 @@ void SDL_ResetHints(void)
|
||||
SDL_EnumerateProperties(GetHintProperties(false), ResetHintsCallback, NULL);
|
||||
}
|
||||
|
||||
int SDL_SetHint(const char *name, const char *value)
|
||||
SDL_bool SDL_SetHint(const char *name, const char *value)
|
||||
{
|
||||
return SDL_SetHintWithPriority(name, value, SDL_HINT_NORMAL);
|
||||
}
|
||||
@ -196,7 +196,7 @@ const char *SDL_GetHint(const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *retval = SDL_getenv(name);
|
||||
const char *result = SDL_getenv(name);
|
||||
|
||||
const SDL_PropertiesID hints = GetHintProperties(false);
|
||||
if (hints) {
|
||||
@ -204,15 +204,15 @@ const char *SDL_GetHint(const char *name)
|
||||
|
||||
SDL_Hint *hint = SDL_GetPointerProperty(hints, name, NULL);
|
||||
if (hint) {
|
||||
if (!retval || hint->priority == SDL_HINT_OVERRIDE) {
|
||||
retval = SDL_GetPersistentString(hint->value);
|
||||
if (!result || hint->priority == SDL_HINT_OVERRIDE) {
|
||||
result = SDL_GetPersistentString(hint->value);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_UnlockProperties(hints);
|
||||
}
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
int SDL_GetStringInteger(const char *value, int default_value)
|
||||
@ -249,7 +249,7 @@ SDL_bool SDL_GetHintBoolean(const char *name, SDL_bool default_value)
|
||||
return SDL_GetStringBoolean(hint, default_value);
|
||||
}
|
||||
|
||||
int SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
|
||||
SDL_bool SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
|
||||
{
|
||||
if (!name || !*name) {
|
||||
return SDL_InvalidParamError("name");
|
||||
@ -259,17 +259,17 @@ int SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userd
|
||||
|
||||
const SDL_PropertiesID hints = GetHintProperties(true);
|
||||
if (!hints) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_HintWatch *entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry));
|
||||
if (!entry) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
entry->callback = callback;
|
||||
entry->userdata = userdata;
|
||||
|
||||
int retval = -1;
|
||||
bool result = false;
|
||||
|
||||
SDL_LockProperties(hints);
|
||||
|
||||
@ -277,18 +277,18 @@ int SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userd
|
||||
|
||||
SDL_Hint *hint = SDL_GetPointerProperty(hints, name, NULL);
|
||||
if (hint) {
|
||||
retval = 0;
|
||||
result = true;
|
||||
} else { // Need to add a hint entry for this watcher
|
||||
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
|
||||
if (!hint) {
|
||||
SDL_free(entry);
|
||||
SDL_UnlockProperties(hints);
|
||||
return -1;
|
||||
return false;
|
||||
} else {
|
||||
hint->value = NULL;
|
||||
hint->priority = SDL_HINT_DEFAULT;
|
||||
hint->callbacks = NULL;
|
||||
retval = SDL_SetPointerPropertyWithCleanup(hints, name, hint, CleanupHintProperty, NULL);
|
||||
result = SDL_SetPointerPropertyWithCleanup(hints, name, hint, CleanupHintProperty, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ int SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userd
|
||||
|
||||
SDL_UnlockProperties(hints);
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
void SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
|
||||
|
@ -302,8 +302,8 @@ extern void SDL_InitMainThread(void);
|
||||
/* The internal implementations of these functions have up to nanosecond precision.
|
||||
We can expose these functions as part of the API if we want to later.
|
||||
*/
|
||||
extern int SDLCALL SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS);
|
||||
extern int SDLCALL SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS);
|
||||
extern SDL_bool SDLCALL SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS);
|
||||
extern SDL_bool SDLCALL SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS);
|
||||
extern SDL_bool SDLCALL SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS);
|
||||
|
||||
// Ends C function definitions when using C++
|
||||
|
@ -23,18 +23,18 @@
|
||||
#include "./SDL_list.h"
|
||||
|
||||
// Push
|
||||
int SDL_ListAdd(SDL_ListNode **head, void *ent)
|
||||
bool SDL_ListAdd(SDL_ListNode **head, void *ent)
|
||||
{
|
||||
SDL_ListNode *node = (SDL_ListNode *)SDL_malloc(sizeof(*node));
|
||||
|
||||
if (!node) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
node->entry = ent;
|
||||
node->next = *head;
|
||||
*head = node;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Pop from end as a FIFO (if add with SDL_ListAdd)
|
||||
|
@ -28,7 +28,7 @@ typedef struct SDL_ListNode
|
||||
struct SDL_ListNode *next;
|
||||
} SDL_ListNode;
|
||||
|
||||
int SDL_ListAdd(SDL_ListNode **head, void *ent);
|
||||
bool SDL_ListAdd(SDL_ListNode **head, void *ent);
|
||||
void SDL_ListPop(SDL_ListNode **head, void **ent);
|
||||
void SDL_ListRemove(SDL_ListNode **head, void *ent);
|
||||
void SDL_ListClear(SDL_ListNode **head);
|
||||
|
@ -338,7 +338,7 @@ static const char *SDL_GetLogPriorityPrefix(SDL_LogPriority priority)
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_SetLogPriorityPrefix(SDL_LogPriority priority, const char *prefix)
|
||||
SDL_bool SDL_SetLogPriorityPrefix(SDL_LogPriority priority, const char *prefix)
|
||||
{
|
||||
if (priority < SDL_LOG_PRIORITY_VERBOSE || priority >= SDL_NUM_LOG_PRIORITIES) {
|
||||
return SDL_InvalidParamError("priority");
|
||||
@ -349,11 +349,11 @@ int SDL_SetLogPriorityPrefix(SDL_LogPriority priority, const char *prefix)
|
||||
} else {
|
||||
prefix = SDL_GetPersistentString(prefix);
|
||||
if (!prefix) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
SDL_priority_prefixes[priority] = prefix;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||
|
@ -97,21 +97,21 @@ static void SDL_FreeProperties(const void *key, const void *value, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_InitProperties(void)
|
||||
bool SDL_InitProperties(void)
|
||||
{
|
||||
if (!SDL_properties_lock) {
|
||||
SDL_properties_lock = SDL_CreateMutex();
|
||||
if (!SDL_properties_lock) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!SDL_properties) {
|
||||
SDL_properties = SDL_CreateHashTable(NULL, 16, SDL_HashID, SDL_KeyMatchID, SDL_FreeProperties, false);
|
||||
if (!SDL_properties) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDL_QuitProperties(void)
|
||||
@ -144,7 +144,7 @@ SDL_PropertiesID SDL_CreateProperties(void)
|
||||
SDL_Properties *properties = NULL;
|
||||
bool inserted = false;
|
||||
|
||||
if (!SDL_properties && SDL_InitProperties() < 0) {
|
||||
if (!SDL_properties && !SDL_InitProperties()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ SDL_PropertiesID SDL_CreateProperties(void)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (SDL_InitProperties() < 0) {
|
||||
if (!SDL_InitProperties()) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -186,11 +186,11 @@ error:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst)
|
||||
SDL_bool SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst)
|
||||
{
|
||||
SDL_Properties *src_properties = NULL;
|
||||
SDL_Properties *dst_properties = NULL;
|
||||
int result = 0;
|
||||
bool result = true;
|
||||
|
||||
if (!src) {
|
||||
return SDL_InvalidParamError("src");
|
||||
@ -233,13 +233,13 @@ int SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst)
|
||||
|
||||
dst_name = SDL_strdup(src_name);
|
||||
if (!dst_name) {
|
||||
result = -1;
|
||||
result = false;
|
||||
continue;
|
||||
}
|
||||
dst_property = (SDL_Property *)SDL_malloc(sizeof(*dst_property));
|
||||
if (!dst_property) {
|
||||
SDL_free(dst_name);
|
||||
result = -1;
|
||||
result = false;
|
||||
continue;
|
||||
}
|
||||
SDL_copyp(dst_property, src_property);
|
||||
@ -248,7 +248,7 @@ int SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst)
|
||||
}
|
||||
if (!SDL_InsertIntoHashTable(dst_properties->props, dst_name, dst_property)) {
|
||||
SDL_FreePropertyWithCleanup(dst_name, dst_property, NULL, false);
|
||||
result = -1;
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -258,7 +258,7 @@ int SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst)
|
||||
return result;
|
||||
}
|
||||
|
||||
int SDL_LockProperties(SDL_PropertiesID props)
|
||||
SDL_bool SDL_LockProperties(SDL_PropertiesID props)
|
||||
{
|
||||
SDL_Properties *properties = NULL;
|
||||
|
||||
@ -275,7 +275,7 @@ int SDL_LockProperties(SDL_PropertiesID props)
|
||||
}
|
||||
|
||||
SDL_LockMutex(properties->lock);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDL_UnlockProperties(SDL_PropertiesID props)
|
||||
@ -297,10 +297,10 @@ void SDL_UnlockProperties(SDL_PropertiesID props)
|
||||
SDL_UnlockMutex(properties->lock);
|
||||
}
|
||||
|
||||
static int SDL_PrivateSetProperty(SDL_PropertiesID props, const char *name, SDL_Property *property)
|
||||
static SDL_bool SDL_PrivateSetProperty(SDL_PropertiesID props, const char *name, SDL_Property *property)
|
||||
{
|
||||
SDL_Properties *properties = NULL;
|
||||
int result = 0;
|
||||
bool result = true;
|
||||
|
||||
if (!props) {
|
||||
SDL_FreePropertyWithCleanup(NULL, property, NULL, true);
|
||||
@ -327,7 +327,7 @@ static int SDL_PrivateSetProperty(SDL_PropertiesID props, const char *name, SDL_
|
||||
char *key = SDL_strdup(name);
|
||||
if (!SDL_InsertIntoHashTable(properties->props, key, property)) {
|
||||
SDL_FreePropertyWithCleanup(key, property, NULL, true);
|
||||
result = -1;
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -336,7 +336,7 @@ static int SDL_PrivateSetProperty(SDL_PropertiesID props, const char *name, SDL_
|
||||
return result;
|
||||
}
|
||||
|
||||
int SDL_SetPointerPropertyWithCleanup(SDL_PropertiesID props, const char *name, void *value, SDL_CleanupPropertyCallback cleanup, void *userdata)
|
||||
SDL_bool SDL_SetPointerPropertyWithCleanup(SDL_PropertiesID props, const char *name, void *value, SDL_CleanupPropertyCallback cleanup, void *userdata)
|
||||
{
|
||||
SDL_Property *property;
|
||||
|
||||
@ -353,7 +353,7 @@ int SDL_SetPointerPropertyWithCleanup(SDL_PropertiesID props, const char *name,
|
||||
cleanup(userdata, value);
|
||||
}
|
||||
SDL_FreePropertyWithCleanup(NULL, property, NULL, false);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
property->type = SDL_PROPERTY_TYPE_POINTER;
|
||||
property->value.pointer_value = value;
|
||||
@ -362,7 +362,7 @@ int SDL_SetPointerPropertyWithCleanup(SDL_PropertiesID props, const char *name,
|
||||
return SDL_PrivateSetProperty(props, name, property);
|
||||
}
|
||||
|
||||
int SDL_SetPointerProperty(SDL_PropertiesID props, const char *name, void *value)
|
||||
SDL_bool SDL_SetPointerProperty(SDL_PropertiesID props, const char *name, void *value)
|
||||
{
|
||||
SDL_Property *property;
|
||||
|
||||
@ -372,7 +372,7 @@ int SDL_SetPointerProperty(SDL_PropertiesID props, const char *name, void *value
|
||||
|
||||
property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
|
||||
if (!property) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
property->type = SDL_PROPERTY_TYPE_POINTER;
|
||||
property->value.pointer_value = value;
|
||||
@ -384,7 +384,7 @@ static void SDLCALL CleanupFreeableProperty(void *userdata, void *value)
|
||||
SDL_free(value);
|
||||
}
|
||||
|
||||
int SDL_SetFreeableProperty(SDL_PropertiesID props, const char *name, void *value)
|
||||
bool SDL_SetFreeableProperty(SDL_PropertiesID props, const char *name, void *value)
|
||||
{
|
||||
return SDL_SetPointerPropertyWithCleanup(props, name, value, CleanupFreeableProperty, NULL);
|
||||
}
|
||||
@ -396,12 +396,12 @@ static void SDLCALL CleanupSurface(void *userdata, void *value)
|
||||
SDL_DestroySurface(surface);
|
||||
}
|
||||
|
||||
int SDL_SetSurfaceProperty(SDL_PropertiesID props, const char *name, SDL_Surface *surface)
|
||||
bool SDL_SetSurfaceProperty(SDL_PropertiesID props, const char *name, SDL_Surface *surface)
|
||||
{
|
||||
return SDL_SetPointerPropertyWithCleanup(props, name, surface, CleanupSurface, NULL);
|
||||
}
|
||||
|
||||
int SDL_SetStringProperty(SDL_PropertiesID props, const char *name, const char *value)
|
||||
SDL_bool SDL_SetStringProperty(SDL_PropertiesID props, const char *name, const char *value)
|
||||
{
|
||||
SDL_Property *property;
|
||||
|
||||
@ -411,44 +411,44 @@ int SDL_SetStringProperty(SDL_PropertiesID props, const char *name, const char *
|
||||
|
||||
property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
|
||||
if (!property) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
property->type = SDL_PROPERTY_TYPE_STRING;
|
||||
property->value.string_value = SDL_strdup(value);
|
||||
if (!property->value.string_value) {
|
||||
SDL_free(property);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
return SDL_PrivateSetProperty(props, name, property);
|
||||
}
|
||||
|
||||
int SDL_SetNumberProperty(SDL_PropertiesID props, const char *name, Sint64 value)
|
||||
SDL_bool SDL_SetNumberProperty(SDL_PropertiesID props, const char *name, Sint64 value)
|
||||
{
|
||||
SDL_Property *property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
|
||||
if (!property) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
property->type = SDL_PROPERTY_TYPE_NUMBER;
|
||||
property->value.number_value = value;
|
||||
return SDL_PrivateSetProperty(props, name, property);
|
||||
}
|
||||
|
||||
int SDL_SetFloatProperty(SDL_PropertiesID props, const char *name, float value)
|
||||
SDL_bool SDL_SetFloatProperty(SDL_PropertiesID props, const char *name, float value)
|
||||
{
|
||||
SDL_Property *property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
|
||||
if (!property) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
property->type = SDL_PROPERTY_TYPE_FLOAT;
|
||||
property->value.float_value = value;
|
||||
return SDL_PrivateSetProperty(props, name, property);
|
||||
}
|
||||
|
||||
int SDL_SetBooleanProperty(SDL_PropertiesID props, const char *name, SDL_bool value)
|
||||
SDL_bool SDL_SetBooleanProperty(SDL_PropertiesID props, const char *name, SDL_bool value)
|
||||
{
|
||||
SDL_Property *property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
|
||||
if (!property) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
property->type = SDL_PROPERTY_TYPE_BOOLEAN;
|
||||
property->value.boolean_value = value ? true : false;
|
||||
@ -732,12 +732,12 @@ SDL_bool SDL_GetBooleanProperty(SDL_PropertiesID props, const char *name, SDL_bo
|
||||
return value;
|
||||
}
|
||||
|
||||
int SDL_ClearProperty(SDL_PropertiesID props, const char *name)
|
||||
SDL_bool SDL_ClearProperty(SDL_PropertiesID props, const char *name)
|
||||
{
|
||||
return SDL_PrivateSetProperty(props, name, NULL);
|
||||
}
|
||||
|
||||
int SDL_EnumerateProperties(SDL_PropertiesID props, SDL_EnumeratePropertiesCallback callback, void *userdata)
|
||||
SDL_bool SDL_EnumerateProperties(SDL_PropertiesID props, SDL_EnumeratePropertiesCallback callback, void *userdata)
|
||||
{
|
||||
SDL_Properties *properties = NULL;
|
||||
|
||||
@ -768,7 +768,7 @@ int SDL_EnumerateProperties(SDL_PropertiesID props, SDL_EnumeratePropertiesCallb
|
||||
}
|
||||
SDL_UnlockMutex(properties->lock);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void SDLCALL SDL_DumpPropertiesCallback(void *userdata, SDL_PropertiesID props, const char *name)
|
||||
@ -798,7 +798,7 @@ static void SDLCALL SDL_DumpPropertiesCallback(void *userdata, SDL_PropertiesID
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_DumpProperties(SDL_PropertiesID props)
|
||||
bool SDL_DumpProperties(SDL_PropertiesID props)
|
||||
{
|
||||
return SDL_EnumerateProperties(props, SDL_DumpPropertiesCallback, NULL);
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
extern int SDL_InitProperties(void);
|
||||
extern int SDL_SetFreeableProperty(SDL_PropertiesID props, const char *name, void *value);
|
||||
extern int SDL_SetSurfaceProperty(SDL_PropertiesID props, const char *name, SDL_Surface *surface);
|
||||
extern int SDL_DumpProperties(SDL_PropertiesID props);
|
||||
extern bool SDL_InitProperties(void);
|
||||
extern bool SDL_SetFreeableProperty(SDL_PropertiesID props, const char *name, void *value);
|
||||
extern bool SDL_SetSurfaceProperty(SDL_PropertiesID props, const char *name, SDL_Surface *surface);
|
||||
extern bool SDL_DumpProperties(SDL_PropertiesID props);
|
||||
extern void SDL_QuitProperties(void);
|
||||
|
@ -53,6 +53,14 @@ int SDL_powerof2(int x)
|
||||
return value;
|
||||
}
|
||||
|
||||
Uint32 SDL_CalculateGCD(Uint32 a, Uint32 b)
|
||||
{
|
||||
if (b == 0) {
|
||||
return a;
|
||||
}
|
||||
return SDL_CalculateGCD(b, (a % b));
|
||||
}
|
||||
|
||||
// Algorithm adapted with thanks from John Cook's blog post:
|
||||
// http://www.johndcook.com/blog/2010/10/20/best-rational-approximation
|
||||
void SDL_CalculateFraction(float x, int *numerator, int *denominator)
|
||||
@ -92,6 +100,14 @@ void SDL_CalculateFraction(float x, int *numerator, int *denominator)
|
||||
}
|
||||
}
|
||||
|
||||
bool SDL_startswith(const char *string, const char *prefix)
|
||||
{
|
||||
if (SDL_strncmp(string, prefix, SDL_strlen(prefix)) == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SDL_endswith(const char *string, const char *suffix)
|
||||
{
|
||||
size_t string_length = string ? SDL_strlen(string) : 0;
|
||||
@ -352,8 +368,8 @@ const char *SDL_GetPersistentString(const char *string)
|
||||
SDL_SetTLS(&SDL_string_storage, strings, SDL_FreePersistentStrings);
|
||||
}
|
||||
|
||||
const char *retval;
|
||||
if (!SDL_FindInHashTable(strings, string, (const void **)&retval)) {
|
||||
const char *result;
|
||||
if (!SDL_FindInHashTable(strings, string, (const void **)&result)) {
|
||||
char *new_string = SDL_strdup(string);
|
||||
if (!new_string) {
|
||||
return NULL;
|
||||
@ -361,7 +377,7 @@ const char *SDL_GetPersistentString(const char *string)
|
||||
|
||||
// If the hash table insert fails, at least we can return the string we allocated
|
||||
SDL_InsertIntoHashTable(strings, new_string, new_string);
|
||||
retval = new_string;
|
||||
result = new_string;
|
||||
}
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
@ -28,8 +28,10 @@
|
||||
// Return the smallest power of 2 greater than or equal to 'x'
|
||||
extern int SDL_powerof2(int x);
|
||||
|
||||
extern Uint32 SDL_CalculateGCD(Uint32 a, Uint32 b);
|
||||
extern void SDL_CalculateFraction(float x, int *numerator, int *denominator);
|
||||
|
||||
extern bool SDL_startswith(const char *string, const char *prefix);
|
||||
extern bool SDL_endswith(const char *string, const char *suffix);
|
||||
|
||||
/** Convert URI to a local filename, stripping the "file://"
|
||||
|
@ -136,16 +136,16 @@ SDL_bool SDL_AtomicCompareAndSwap(SDL_AtomicInt *a, int oldval, int newval)
|
||||
#elif defined(SDL_PLATFORM_SOLARIS)
|
||||
return ((int)atomic_cas_uint((volatile uint_t *)&a->value, (uint_t)oldval, (uint_t)newval) == oldval);
|
||||
#elif defined(EMULATE_CAS)
|
||||
bool retval = false;
|
||||
bool result = false;
|
||||
|
||||
enterLock(a);
|
||||
if (a->value == oldval) {
|
||||
a->value = newval;
|
||||
retval = true;
|
||||
result = true;
|
||||
}
|
||||
leaveLock(a);
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
#else
|
||||
#error Please define your platform.
|
||||
#endif
|
||||
@ -166,16 +166,16 @@ SDL_bool SDL_AtomicCompareAndSwapPointer(void **a, void *oldval, void *newval)
|
||||
#elif defined(SDL_PLATFORM_SOLARIS)
|
||||
return (atomic_cas_ptr(a, oldval, newval) == oldval);
|
||||
#elif defined(EMULATE_CAS)
|
||||
bool retval = false;
|
||||
bool result = false;
|
||||
|
||||
enterLock(a);
|
||||
if (*a == oldval) {
|
||||
*a = newval;
|
||||
retval = true;
|
||||
result = true;
|
||||
}
|
||||
leaveLock(a);
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
#else
|
||||
#error Please define your platform.
|
||||
#endif
|
||||
|
@ -278,18 +278,18 @@ bool SDL_AudioSpecsEqual(const SDL_AudioSpec *a, const SDL_AudioSpec *b, const i
|
||||
|
||||
// These get used when a device is disconnected or fails, so audiostreams don't overflow with data that isn't being
|
||||
// consumed and apps relying on audio callbacks don't stop making progress.
|
||||
static int ZombieWaitDevice(SDL_AudioDevice *device)
|
||||
static bool ZombieWaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
if (!SDL_AtomicGet(&device->shutdown)) {
|
||||
const int frames = device->buffer_size / SDL_AUDIO_FRAMESIZE(device->spec);
|
||||
SDL_Delay((frames * 1000) / device->spec.freq);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int ZombiePlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
static bool ZombiePlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
{
|
||||
return 0; // no-op, just throw the audio away.
|
||||
return true; // no-op, just throw the audio away.
|
||||
}
|
||||
|
||||
static Uint8 *ZombieGetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
@ -770,9 +770,9 @@ void SDL_AudioDeviceDisconnected(SDL_AudioDevice *device)
|
||||
// stubs for audio drivers that don't need a specific entry point...
|
||||
|
||||
static void SDL_AudioThreadDeinit_Default(SDL_AudioDevice *device) { /* no-op. */ }
|
||||
static int SDL_AudioWaitDevice_Default(SDL_AudioDevice *device) { return 0; /* no-op. */ }
|
||||
static int SDL_AudioPlayDevice_Default(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size) { return 0; /* no-op. */ }
|
||||
static int SDL_AudioWaitRecordingDevice_Default(SDL_AudioDevice *device) { return 0; /* no-op. */ }
|
||||
static bool SDL_AudioWaitDevice_Default(SDL_AudioDevice *device) { return true; /* no-op. */ }
|
||||
static bool SDL_AudioPlayDevice_Default(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size) { return true; /* no-op. */ }
|
||||
static bool SDL_AudioWaitRecordingDevice_Default(SDL_AudioDevice *device) { return true; /* no-op. */ }
|
||||
static void SDL_AudioFlushRecording_Default(SDL_AudioDevice *device) { /* no-op. */ }
|
||||
static void SDL_AudioCloseDevice_Default(SDL_AudioDevice *device) { /* no-op. */ }
|
||||
static void SDL_AudioDeinitializeStart_Default(void) { /* no-op. */ }
|
||||
@ -804,10 +804,11 @@ static Uint8 *SDL_AudioGetDeviceBuf_Default(SDL_AudioDevice *device, int *buffer
|
||||
|
||||
static int SDL_AudioRecordDevice_Default(SDL_AudioDevice *device, void *buffer, int buflen)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int SDL_AudioOpenDevice_Default(SDL_AudioDevice *device)
|
||||
static bool SDL_AudioOpenDevice_Default(SDL_AudioDevice *device)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
@ -836,7 +837,7 @@ static void CompleteAudioEntryPoints(void)
|
||||
static SDL_AudioDevice *GetFirstAddedAudioDevice(const bool recording)
|
||||
{
|
||||
SDL_AudioDeviceID highest = (SDL_AudioDeviceID) SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK; // According to AssignAudioDeviceInstanceId, nothing can have a value this large.
|
||||
SDL_AudioDevice *retval = NULL;
|
||||
SDL_AudioDevice *result = NULL;
|
||||
|
||||
// (Device IDs increase as new devices are added, so the first device added has the lowest SDL_AudioDeviceID value.)
|
||||
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
||||
@ -852,12 +853,12 @@ static SDL_AudioDevice *GetFirstAddedAudioDevice(const bool recording)
|
||||
const bool isphysical = (devid & (1 << 1));
|
||||
if (isphysical && (devid_recording == recording) && (devid < highest)) {
|
||||
highest = devid;
|
||||
retval = (SDL_AudioDevice *) value;
|
||||
result = (SDL_AudioDevice *) value;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static Uint32 HashAudioDeviceID(const void *key, void *data)
|
||||
@ -878,7 +879,7 @@ static void NukeAudioDeviceHashItem(const void *key, const void *value, void *da
|
||||
}
|
||||
|
||||
// !!! FIXME: the video subsystem does SDL_VideoInit, not SDL_InitVideo. Make this match.
|
||||
int SDL_InitAudio(const char *driver_name)
|
||||
bool SDL_InitAudio(const char *driver_name)
|
||||
{
|
||||
if (SDL_GetCurrentAudioDriver()) {
|
||||
SDL_QuitAudio(); // shutdown driver if already running.
|
||||
@ -892,13 +893,13 @@ int SDL_InitAudio(const char *driver_name)
|
||||
|
||||
SDL_RWLock *device_hash_lock = SDL_CreateRWLock(); // create this early, so if it fails we don't have to tear down the whole audio subsystem.
|
||||
if (!device_hash_lock) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_HashTable *device_hash = SDL_CreateHashTable(NULL, 8, HashAudioDeviceID, MatchAudioDeviceID, NukeAudioDeviceHashItem, false);
|
||||
if (!device_hash) {
|
||||
SDL_DestroyRWLock(device_hash_lock);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Select the proper audio driver
|
||||
@ -916,7 +917,7 @@ int SDL_InitAudio(const char *driver_name)
|
||||
if (!driver_name_copy) {
|
||||
SDL_DestroyRWLock(device_hash_lock);
|
||||
SDL_DestroyHashTable(device_hash);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
while (driver_attempt && *driver_attempt != 0 && !initialized) {
|
||||
@ -984,7 +985,7 @@ int SDL_InitAudio(const char *driver_name)
|
||||
SDL_DestroyRWLock(device_hash_lock);
|
||||
SDL_DestroyHashTable(device_hash);
|
||||
SDL_zero(current_audio);
|
||||
return -1; // No driver was available, so fail.
|
||||
return false; // No driver was available, so fail.
|
||||
}
|
||||
|
||||
CompleteAudioEntryPoints();
|
||||
@ -1013,7 +1014,7 @@ int SDL_InitAudio(const char *driver_name)
|
||||
RefPhysicalAudioDevice(default_recording); // extra ref on default devices.
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDL_QuitAudio(void)
|
||||
@ -1073,7 +1074,7 @@ void SDL_AudioThreadFinalize(SDL_AudioDevice *device)
|
||||
|
||||
static void MixFloat32Audio(float *dst, const float *src, const int buffer_size)
|
||||
{
|
||||
if (SDL_MixAudio((Uint8 *) dst, (const Uint8 *) src, SDL_AUDIO_F32, buffer_size, 1.0f) < 0) {
|
||||
if (!SDL_MixAudio((Uint8 *) dst, (const Uint8 *) src, SDL_AUDIO_F32, buffer_size, 1.0f)) {
|
||||
SDL_assert(!"This shouldn't happen.");
|
||||
}
|
||||
}
|
||||
@ -1182,7 +1183,7 @@ bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
|
||||
}
|
||||
|
||||
// PlayDevice SHOULD NOT BLOCK, as we are holding a lock right now. Block in WaitDevice instead!
|
||||
if (device->PlayDevice(device, device_buffer, buffer_size) < 0) {
|
||||
if (!device->PlayDevice(device, device_buffer, buffer_size)) {
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
@ -1216,7 +1217,7 @@ static int SDLCALL PlaybackAudioThread(void *devicep) // thread entry point
|
||||
SDL_PlaybackAudioThreadSetup(device);
|
||||
|
||||
do {
|
||||
if (device->WaitDevice(device) < 0) {
|
||||
if (!device->WaitDevice(device)) {
|
||||
SDL_AudioDeviceDisconnected(device); // doh. (but don't break out of the loop, just be a zombie for now!)
|
||||
}
|
||||
} while (SDL_PlaybackAudioThreadIterate(device));
|
||||
@ -1288,7 +1289,7 @@ bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device)
|
||||
for iterating here because the binding linked list can only change while the device lock is held.
|
||||
(we _do_ lock the stream during binding/unbinding to make sure that two threads can't try to bind
|
||||
the same stream to different devices at the same time, though.) */
|
||||
if (SDL_PutAudioStreamData(stream, output_buffer, br) < 0) {
|
||||
if (!SDL_PutAudioStreamData(stream, output_buffer, br)) {
|
||||
// oh crud, we probably ran out of memory. This is possibly an overreaction to kill the audio device, but it's likely the whole thing is going down in a moment anyhow.
|
||||
failed = true;
|
||||
break;
|
||||
@ -1323,7 +1324,7 @@ static int SDLCALL RecordingAudioThread(void *devicep) // thread entry point
|
||||
SDL_RecordingAudioThreadSetup(device);
|
||||
|
||||
do {
|
||||
if (device->WaitRecordingDevice(device) < 0) {
|
||||
if (!device->WaitRecordingDevice(device)) {
|
||||
SDL_AudioDeviceDisconnected(device); // doh. (but don't break out of the loop, just be a zombie for now!)
|
||||
}
|
||||
} while (SDL_RecordingAudioThreadIterate(device));
|
||||
@ -1335,15 +1336,15 @@ static int SDLCALL RecordingAudioThread(void *devicep) // thread entry point
|
||||
|
||||
static SDL_AudioDeviceID *GetAudioDevices(int *count, bool recording)
|
||||
{
|
||||
SDL_AudioDeviceID *retval = NULL;
|
||||
SDL_AudioDeviceID *result = NULL;
|
||||
int num_devices = 0;
|
||||
|
||||
if (SDL_GetCurrentAudioDriver()) {
|
||||
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
||||
{
|
||||
num_devices = SDL_AtomicGet(recording ? ¤t_audio.recording_device_count : ¤t_audio.playback_device_count);
|
||||
retval = (SDL_AudioDeviceID *) SDL_malloc((num_devices + 1) * sizeof (SDL_AudioDeviceID));
|
||||
if (retval) {
|
||||
result = (SDL_AudioDeviceID *) SDL_malloc((num_devices + 1) * sizeof (SDL_AudioDeviceID));
|
||||
if (result) {
|
||||
int devs_seen = 0;
|
||||
const void *key;
|
||||
const void *value;
|
||||
@ -1356,12 +1357,12 @@ static SDL_AudioDeviceID *GetAudioDevices(int *count, bool recording)
|
||||
const bool isphysical = (devid & (1<<1));
|
||||
if (isphysical && (devid_recording == recording)) {
|
||||
SDL_assert(devs_seen < num_devices);
|
||||
retval[devs_seen++] = devid;
|
||||
result[devs_seen++] = devid;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_assert(devs_seen == num_devices);
|
||||
retval[devs_seen] = 0; // null-terminated.
|
||||
result[devs_seen] = 0; // null-terminated.
|
||||
}
|
||||
}
|
||||
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
||||
@ -1370,13 +1371,13 @@ static SDL_AudioDeviceID *GetAudioDevices(int *count, bool recording)
|
||||
}
|
||||
|
||||
if (count) {
|
||||
if (retval) {
|
||||
if (result) {
|
||||
*count = num_devices;
|
||||
} else {
|
||||
*count = 0;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
SDL_AudioDeviceID *SDL_GetAudioPlaybackDevices(int *count)
|
||||
@ -1432,44 +1433,44 @@ SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByHandle(void *handle)
|
||||
|
||||
const char *SDL_GetAudioDeviceName(SDL_AudioDeviceID devid)
|
||||
{
|
||||
const char *retval = NULL;
|
||||
const char *result = NULL;
|
||||
SDL_AudioDevice *device = ObtainPhysicalAudioDevice(devid);
|
||||
if (device) {
|
||||
retval = SDL_GetPersistentString(device->name);
|
||||
result = SDL_GetPersistentString(device->name);
|
||||
}
|
||||
ReleaseAudioDevice(device);
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
int SDL_GetAudioDeviceFormat(SDL_AudioDeviceID devid, SDL_AudioSpec *spec, int *sample_frames)
|
||||
SDL_bool SDL_GetAudioDeviceFormat(SDL_AudioDeviceID devid, SDL_AudioSpec *spec, int *sample_frames)
|
||||
{
|
||||
if (!spec) {
|
||||
return SDL_InvalidParamError("spec");
|
||||
}
|
||||
|
||||
int retval = -1;
|
||||
bool result = false;
|
||||
SDL_AudioDevice *device = ObtainPhysicalAudioDeviceDefaultAllowed(devid);
|
||||
if (device) {
|
||||
SDL_copyp(spec, &device->spec);
|
||||
if (sample_frames) {
|
||||
*sample_frames = device->sample_frames;
|
||||
}
|
||||
retval = 0;
|
||||
result = true;
|
||||
}
|
||||
ReleaseAudioDevice(device);
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
int *SDL_GetAudioDeviceChannelMap(SDL_AudioDeviceID devid, int *count)
|
||||
{
|
||||
int *retval = NULL;
|
||||
int *result = NULL;
|
||||
int channels = 0;
|
||||
SDL_AudioDevice *device = ObtainPhysicalAudioDeviceDefaultAllowed(devid);
|
||||
if (device) {
|
||||
channels = device->spec.channels;
|
||||
retval = SDL_ChannelMapDup(device->chmap, channels);
|
||||
result = SDL_ChannelMapDup(device->chmap, channels);
|
||||
}
|
||||
ReleaseAudioDevice(device);
|
||||
|
||||
@ -1477,7 +1478,7 @@ int *SDL_GetAudioDeviceChannelMap(SDL_AudioDeviceID devid, int *count)
|
||||
*count = channels;
|
||||
}
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -1620,17 +1621,17 @@ char *SDL_GetAudioThreadName(SDL_AudioDevice *device, char *buf, size_t buflen)
|
||||
|
||||
|
||||
// this expects the device lock to be held.
|
||||
static int OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec *inspec)
|
||||
static bool OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec *inspec)
|
||||
{
|
||||
SerializePhysicalDeviceClose(device); // make sure another thread that's closing didn't release the lock to let the device thread join...
|
||||
|
||||
if (device->currently_opened) {
|
||||
return 0; // we're already good.
|
||||
return true; // we're already good.
|
||||
}
|
||||
|
||||
// Just pretend to open a zombie device. It can still collect logical devices on a default device under the assumption they will all migrate when the default device is officially changed.
|
||||
if (SDL_AtomicGet(&device->zombie)) {
|
||||
return 0; // Braaaaaaaaains.
|
||||
return true; // Braaaaaaaaains.
|
||||
}
|
||||
|
||||
// These start with the backend's implementation, but we might swap them out with zombie versions later.
|
||||
@ -1656,9 +1657,9 @@ static int OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec
|
||||
SDL_UpdatedAudioDeviceFormat(device); // start this off sane.
|
||||
|
||||
device->currently_opened = true; // mark this true even if impl.OpenDevice fails, so we know to clean up.
|
||||
if (current_audio.impl.OpenDevice(device) < 0) {
|
||||
if (!current_audio.impl.OpenDevice(device)) {
|
||||
ClosePhysicalAudioDevice(device); // clean up anything the backend left half-initialized.
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_UpdatedAudioDeviceFormat(device); // in case the backend changed things and forgot to call this.
|
||||
@ -1667,14 +1668,14 @@ static int OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec
|
||||
device->work_buffer = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size);
|
||||
if (!device->work_buffer) {
|
||||
ClosePhysicalAudioDevice(device);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (device->spec.format != SDL_AUDIO_F32) {
|
||||
device->mix_buffer = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size);
|
||||
if (!device->mix_buffer) {
|
||||
ClosePhysicalAudioDevice(device);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1690,7 +1691,7 @@ static int OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSpec *spec)
|
||||
@ -1714,7 +1715,7 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
|
||||
}
|
||||
}
|
||||
|
||||
SDL_AudioDeviceID retval = 0;
|
||||
SDL_AudioDeviceID result = 0;
|
||||
|
||||
if (device) {
|
||||
SDL_LogicalAudioDevice *logdev = NULL;
|
||||
@ -1723,12 +1724,12 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
|
||||
SDL_SetError("Device was already lost and can't accept new opens");
|
||||
} else if ((logdev = (SDL_LogicalAudioDevice *) SDL_calloc(1, sizeof (SDL_LogicalAudioDevice))) == NULL) {
|
||||
// SDL_calloc already called SDL_OutOfMemory
|
||||
} else if (OpenPhysicalAudioDevice(device, spec) < 0) { // if this is the first thing using this physical device, open at the OS level if necessary...
|
||||
} else if (!OpenPhysicalAudioDevice(device, spec)) { // if this is the first thing using this physical device, open at the OS level if necessary...
|
||||
SDL_free(logdev);
|
||||
} else {
|
||||
RefPhysicalAudioDevice(device); // unref'd on successful SDL_CloseAudioDevice
|
||||
SDL_AtomicSet(&logdev->paused, 0);
|
||||
retval = logdev->instance_id = AssignAudioDeviceInstanceId(device->recording, /*islogical=*/true);
|
||||
result = logdev->instance_id = AssignAudioDeviceInstanceId(device->recording, /*islogical=*/true);
|
||||
logdev->physical_device = device;
|
||||
logdev->gain = 1.0f;
|
||||
logdev->opened_as_default = wants_default;
|
||||
@ -1741,21 +1742,21 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
|
||||
}
|
||||
ReleaseAudioDevice(device);
|
||||
|
||||
if (retval) {
|
||||
if (result) {
|
||||
SDL_LockRWLockForWriting(current_audio.device_hash_lock);
|
||||
const bool inserted = SDL_InsertIntoHashTable(current_audio.device_hash, (const void *) (uintptr_t) retval, logdev);
|
||||
const bool inserted = SDL_InsertIntoHashTable(current_audio.device_hash, (const void *) (uintptr_t) result, logdev);
|
||||
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
||||
if (!inserted) {
|
||||
SDL_CloseAudioDevice(retval);
|
||||
retval = 0;
|
||||
SDL_CloseAudioDevice(result);
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static int SetLogicalAudioDevicePauseState(SDL_AudioDeviceID devid, int value)
|
||||
static bool SetLogicalAudioDevicePauseState(SDL_AudioDeviceID devid, int value)
|
||||
{
|
||||
SDL_AudioDevice *device = NULL;
|
||||
SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(devid, &device);
|
||||
@ -1763,15 +1764,15 @@ static int SetLogicalAudioDevicePauseState(SDL_AudioDeviceID devid, int value)
|
||||
SDL_AtomicSet(&logdev->paused, value);
|
||||
}
|
||||
ReleaseAudioDevice(device);
|
||||
return logdev ? 0 : -1; // ObtainLogicalAudioDevice will have set an error.
|
||||
return logdev ? true : false; // ObtainLogicalAudioDevice will have set an error.
|
||||
}
|
||||
|
||||
int SDL_PauseAudioDevice(SDL_AudioDeviceID devid)
|
||||
SDL_bool SDL_PauseAudioDevice(SDL_AudioDeviceID devid)
|
||||
{
|
||||
return SetLogicalAudioDevicePauseState(devid, 1);
|
||||
}
|
||||
|
||||
int SDLCALL SDL_ResumeAudioDevice(SDL_AudioDeviceID devid)
|
||||
SDL_bool SDLCALL SDL_ResumeAudioDevice(SDL_AudioDeviceID devid)
|
||||
{
|
||||
return SetLogicalAudioDevicePauseState(devid, 0);
|
||||
}
|
||||
@ -1780,24 +1781,24 @@ SDL_bool SDL_AudioDevicePaused(SDL_AudioDeviceID devid)
|
||||
{
|
||||
SDL_AudioDevice *device = NULL;
|
||||
SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(devid, &device);
|
||||
bool retval = false;
|
||||
bool result = false;
|
||||
if (logdev && SDL_AtomicGet(&logdev->paused)) {
|
||||
retval = true;
|
||||
result = true;
|
||||
}
|
||||
ReleaseAudioDevice(device);
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
float SDL_GetAudioDeviceGain(SDL_AudioDeviceID devid)
|
||||
{
|
||||
SDL_AudioDevice *device = NULL;
|
||||
SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(devid, &device);
|
||||
const float retval = logdev ? logdev->gain : -1.0f;
|
||||
const float result = logdev ? logdev->gain : -1.0f;
|
||||
ReleaseAudioDevice(device);
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
int SDL_SetAudioDeviceGain(SDL_AudioDeviceID devid, float gain)
|
||||
SDL_bool SDL_SetAudioDeviceGain(SDL_AudioDeviceID devid, float gain)
|
||||
{
|
||||
if (gain < 0.0f) {
|
||||
return SDL_InvalidParamError("gain");
|
||||
@ -1805,7 +1806,7 @@ int SDL_SetAudioDeviceGain(SDL_AudioDeviceID devid, float gain)
|
||||
|
||||
SDL_AudioDevice *device = NULL;
|
||||
SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(devid, &device);
|
||||
int retval = -1;
|
||||
bool result = false;
|
||||
if (logdev) {
|
||||
logdev->gain = gain;
|
||||
if (device->recording) {
|
||||
@ -1820,26 +1821,26 @@ int SDL_SetAudioDeviceGain(SDL_AudioDeviceID devid, float gain)
|
||||
}
|
||||
|
||||
UpdateAudioStreamFormatsPhysical(device);
|
||||
retval = 0;
|
||||
result = true;
|
||||
}
|
||||
ReleaseAudioDevice(device);
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
int SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallback callback, void *userdata)
|
||||
SDL_bool SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallback callback, void *userdata)
|
||||
{
|
||||
SDL_AudioDevice *device = NULL;
|
||||
SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(devid, &device);
|
||||
int retval = 0;
|
||||
bool result = true;
|
||||
if (logdev) {
|
||||
if (callback && !device->postmix_buffer) {
|
||||
device->postmix_buffer = (float *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size);
|
||||
if (!device->postmix_buffer) {
|
||||
retval = -1;
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (retval == 0) {
|
||||
if (result) {
|
||||
logdev->postmix = callback;
|
||||
logdev->postmix_userdata = userdata;
|
||||
|
||||
@ -1858,18 +1859,18 @@ int SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallbac
|
||||
UpdateAudioStreamFormatsPhysical(device);
|
||||
}
|
||||
ReleaseAudioDevice(device);
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int num_streams)
|
||||
SDL_bool SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int num_streams)
|
||||
{
|
||||
const bool islogical = !(devid & (1<<1));
|
||||
SDL_AudioDevice *device = NULL;
|
||||
SDL_LogicalAudioDevice *logdev = NULL;
|
||||
int retval = 0;
|
||||
bool result = true;
|
||||
|
||||
if (num_streams == 0) {
|
||||
return 0; // nothing to do
|
||||
return true; // nothing to do
|
||||
} else if (num_streams < 0) {
|
||||
return SDL_InvalidParamError("num_streams");
|
||||
} else if (!streams) {
|
||||
@ -1880,9 +1881,9 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
|
||||
|
||||
logdev = ObtainLogicalAudioDevice(devid, &device);
|
||||
if (!logdev) {
|
||||
retval = -1; // ObtainLogicalAudioDevice set the error string.
|
||||
result = false; // ObtainLogicalAudioDevice set the error string.
|
||||
} else if (logdev->simplified) {
|
||||
retval = SDL_SetError("Cannot change stream bindings on device opened with SDL_OpenAudioDeviceStream");
|
||||
result = SDL_SetError("Cannot change stream bindings on device opened with SDL_OpenAudioDeviceStream");
|
||||
} else {
|
||||
|
||||
// !!! FIXME: We'll set the device's side's format below, but maybe we should refuse to bind a stream if the app's side doesn't have a format set yet.
|
||||
@ -1896,18 +1897,18 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
|
||||
SDL_AudioStream *stream = streams[i];
|
||||
if (!stream) {
|
||||
SDL_SetError("Stream #%d is NULL", i);
|
||||
retval = -1; // to pacify the static analyzer, that doesn't realize SDL_SetError() always returns -1.
|
||||
result = false; // to pacify the static analyzer, that doesn't realize SDL_SetError() always returns SDL_FALSE.
|
||||
} else {
|
||||
SDL_LockMutex(stream->lock);
|
||||
SDL_assert((stream->bound_device == NULL) == ((stream->prev_binding == NULL) || (stream->next_binding == NULL)));
|
||||
if (stream->bound_device) {
|
||||
retval = SDL_SetError("Stream #%d is already bound to a device", i);
|
||||
result = SDL_SetError("Stream #%d is already bound to a device", i);
|
||||
} else if (stream->simplified) { // You can get here if you closed the device instead of destroying the stream.
|
||||
retval = SDL_SetError("Cannot change binding on a stream created with SDL_OpenAudioDeviceStream");
|
||||
result = SDL_SetError("Cannot change binding on a stream created with SDL_OpenAudioDeviceStream");
|
||||
}
|
||||
}
|
||||
|
||||
if (retval != 0) {
|
||||
if (!result) {
|
||||
int j;
|
||||
for (j = 0; j < i; j++) {
|
||||
SDL_UnlockMutex(streams[j]->lock);
|
||||
@ -1920,7 +1921,7 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
|
||||
}
|
||||
}
|
||||
|
||||
if (retval == 0) {
|
||||
if (result) {
|
||||
// Now that everything is verified, chain everything together.
|
||||
const bool recording = device->recording;
|
||||
for (int i = 0; i < num_streams; i++) {
|
||||
@ -1951,10 +1952,10 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
|
||||
|
||||
ReleaseAudioDevice(device);
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
int SDL_BindAudioStream(SDL_AudioDeviceID devid, SDL_AudioStream *stream)
|
||||
SDL_bool SDL_BindAudioStream(SDL_AudioDeviceID devid, SDL_AudioStream *stream)
|
||||
{
|
||||
return SDL_BindAudioStreams(devid, &stream, 1);
|
||||
}
|
||||
@ -2034,7 +2035,7 @@ void SDL_UnbindAudioStream(SDL_AudioStream *stream)
|
||||
|
||||
SDL_AudioDeviceID SDL_GetAudioStreamDevice(SDL_AudioStream *stream)
|
||||
{
|
||||
SDL_AudioDeviceID retval = 0;
|
||||
SDL_AudioDeviceID result = 0;
|
||||
|
||||
if (!stream) {
|
||||
SDL_InvalidParamError("stream");
|
||||
@ -2043,13 +2044,13 @@ SDL_AudioDeviceID SDL_GetAudioStreamDevice(SDL_AudioStream *stream)
|
||||
|
||||
SDL_LockMutex(stream->lock);
|
||||
if (stream->bound_device) {
|
||||
retval = stream->bound_device->instance_id;
|
||||
result = stream->bound_device->instance_id;
|
||||
} else {
|
||||
SDL_SetError("Audio stream not bound to an audio device");
|
||||
}
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_AudioSpec *spec, SDL_AudioStreamCallback callback, void *userdata)
|
||||
@ -2097,13 +2098,13 @@ SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_Au
|
||||
UpdateAudioStreamFormatsPhysical(device);
|
||||
|
||||
if (callback) {
|
||||
int rc;
|
||||
bool rc;
|
||||
if (recording) {
|
||||
rc = SDL_SetAudioStreamPutCallback(stream, callback, userdata);
|
||||
} else {
|
||||
rc = SDL_SetAudioStreamGetCallback(stream, callback, userdata);
|
||||
}
|
||||
SDL_assert(rc == 0); // should only fail if stream==NULL atm.
|
||||
SDL_assert(rc); // should only fail if stream==NULL atm.
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2119,21 +2120,21 @@ SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_Au
|
||||
return stream;
|
||||
}
|
||||
|
||||
int SDL_PauseAudioStreamDevice(SDL_AudioStream *stream)
|
||||
SDL_bool SDL_PauseAudioStreamDevice(SDL_AudioStream *stream)
|
||||
{
|
||||
SDL_AudioDeviceID devid = SDL_GetAudioStreamDevice(stream);
|
||||
if (!devid) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return SDL_PauseAudioDevice(devid);
|
||||
}
|
||||
|
||||
int SDL_ResumeAudioStreamDevice(SDL_AudioStream *stream)
|
||||
SDL_bool SDL_ResumeAudioStreamDevice(SDL_AudioStream *stream)
|
||||
{
|
||||
SDL_AudioDeviceID devid = SDL_GetAudioStreamDevice(stream);
|
||||
if (!devid) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return SDL_ResumeAudioDevice(devid);
|
||||
@ -2267,7 +2268,7 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device)
|
||||
|
||||
if (needs_migration) {
|
||||
// New default physical device not been opened yet? Open at the OS level...
|
||||
if (OpenPhysicalAudioDevice(new_default_device, &spec) < 0) {
|
||||
if (!OpenPhysicalAudioDevice(new_default_device, &spec)) {
|
||||
needs_migration = false; // uhoh, just leave everything on the old default, nothing to be done.
|
||||
}
|
||||
}
|
||||
@ -2350,13 +2351,13 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device)
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL_AudioSpec *newspec, int new_sample_frames)
|
||||
bool SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL_AudioSpec *newspec, int new_sample_frames)
|
||||
{
|
||||
const int orig_work_buffer_size = device->work_buffer_size;
|
||||
|
||||
// we don't currently have any place where channel maps change from under you, but we can check that if necessary later.
|
||||
if (SDL_AudioSpecsEqual(&device->spec, newspec, NULL, NULL) && (new_sample_frames == device->sample_frames)) {
|
||||
return 0; // we're already in that format.
|
||||
return true; // we're already in that format.
|
||||
}
|
||||
|
||||
SDL_copyp(&device->spec, newspec);
|
||||
@ -2432,15 +2433,18 @@ int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL
|
||||
}
|
||||
}
|
||||
|
||||
return kill_device ? -1 : 0;
|
||||
if (kill_device) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_AudioDeviceFormatChanged(SDL_AudioDevice *device, const SDL_AudioSpec *newspec, int new_sample_frames)
|
||||
bool SDL_AudioDeviceFormatChanged(SDL_AudioDevice *device, const SDL_AudioSpec *newspec, int new_sample_frames)
|
||||
{
|
||||
ObtainPhysicalAudioDeviceObj(device);
|
||||
const int retval = SDL_AudioDeviceFormatChangedAlreadyLocked(device, newspec, new_sample_frames);
|
||||
const bool result = SDL_AudioDeviceFormatChangedAlreadyLocked(device, newspec, new_sample_frames);
|
||||
ReleaseAudioDevice(device);
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
// This is an internal function, so SDL_PumpEvents() can check for pending audio device events.
|
||||
|
@ -377,14 +377,14 @@ static Sint64 GetAudioStreamResampleRate(SDL_AudioStream* stream, int src_freq,
|
||||
return resample_rate;
|
||||
}
|
||||
|
||||
static int UpdateAudioStreamInputSpec(SDL_AudioStream *stream, const SDL_AudioSpec *spec, const int *chmap)
|
||||
static bool UpdateAudioStreamInputSpec(SDL_AudioStream *stream, const SDL_AudioSpec *spec, const int *chmap)
|
||||
{
|
||||
if (SDL_AudioSpecsEqual(&stream->input_spec, spec, stream->input_chmap, chmap)) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SDL_ResetAudioQueueHistory(stream->queue, SDL_GetResamplerHistoryFrames()) < 0) {
|
||||
return -1;
|
||||
if (!SDL_ResetAudioQueueHistory(stream->queue, SDL_GetResamplerHistoryFrames())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!chmap) {
|
||||
@ -397,7 +397,7 @@ static int UpdateAudioStreamInputSpec(SDL_AudioStream *stream, const SDL_AudioSp
|
||||
|
||||
SDL_copyp(&stream->input_spec, spec);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_AudioStream *SDL_CreateAudioStream(const SDL_AudioSpec *src_spec, const SDL_AudioSpec *dst_spec)
|
||||
@ -405,35 +405,35 @@ SDL_AudioStream *SDL_CreateAudioStream(const SDL_AudioSpec *src_spec, const SDL_
|
||||
SDL_ChooseAudioConverters();
|
||||
SDL_SetupAudioResampler();
|
||||
|
||||
SDL_AudioStream *retval = (SDL_AudioStream *)SDL_calloc(1, sizeof(SDL_AudioStream));
|
||||
if (!retval) {
|
||||
SDL_AudioStream *result = (SDL_AudioStream *)SDL_calloc(1, sizeof(SDL_AudioStream));
|
||||
if (!result) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
retval->freq_ratio = 1.0f;
|
||||
retval->gain = 1.0f;
|
||||
retval->queue = SDL_CreateAudioQueue(8192);
|
||||
result->freq_ratio = 1.0f;
|
||||
result->gain = 1.0f;
|
||||
result->queue = SDL_CreateAudioQueue(8192);
|
||||
|
||||
if (!retval->queue) {
|
||||
SDL_free(retval);
|
||||
if (!result->queue) {
|
||||
SDL_free(result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
retval->lock = SDL_CreateMutex();
|
||||
if (!retval->lock) {
|
||||
SDL_free(retval->queue);
|
||||
SDL_free(retval);
|
||||
result->lock = SDL_CreateMutex();
|
||||
if (!result->lock) {
|
||||
SDL_free(result->queue);
|
||||
SDL_free(result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
OnAudioStreamCreated(retval);
|
||||
OnAudioStreamCreated(result);
|
||||
|
||||
if (SDL_SetAudioStreamFormat(retval, src_spec, dst_spec) < 0) {
|
||||
SDL_DestroyAudioStream(retval);
|
||||
if (!SDL_SetAudioStreamFormat(result, src_spec, dst_spec)) {
|
||||
SDL_DestroyAudioStream(result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
SDL_PropertiesID SDL_GetAudioStreamProperties(SDL_AudioStream *stream)
|
||||
@ -448,7 +448,7 @@ SDL_PropertiesID SDL_GetAudioStreamProperties(SDL_AudioStream *stream)
|
||||
return stream->props;
|
||||
}
|
||||
|
||||
int SDL_SetAudioStreamGetCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata)
|
||||
SDL_bool SDL_SetAudioStreamGetCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata)
|
||||
{
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
@ -457,10 +457,10 @@ int SDL_SetAudioStreamGetCallback(SDL_AudioStream *stream, SDL_AudioStreamCallba
|
||||
stream->get_callback = callback;
|
||||
stream->get_callback_userdata = userdata;
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_SetAudioStreamPutCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata)
|
||||
SDL_bool SDL_SetAudioStreamPutCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata)
|
||||
{
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
@ -469,28 +469,28 @@ int SDL_SetAudioStreamPutCallback(SDL_AudioStream *stream, SDL_AudioStreamCallba
|
||||
stream->put_callback = callback;
|
||||
stream->put_callback_userdata = userdata;
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_LockAudioStream(SDL_AudioStream *stream)
|
||||
SDL_bool SDL_LockAudioStream(SDL_AudioStream *stream)
|
||||
{
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
}
|
||||
SDL_LockMutex(stream->lock);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_UnlockAudioStream(SDL_AudioStream *stream)
|
||||
SDL_bool SDL_UnlockAudioStream(SDL_AudioStream *stream)
|
||||
{
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
}
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_GetAudioStreamFormat(SDL_AudioStream *stream, SDL_AudioSpec *src_spec, SDL_AudioSpec *dst_spec)
|
||||
SDL_bool SDL_GetAudioStreamFormat(SDL_AudioStream *stream, SDL_AudioSpec *src_spec, SDL_AudioSpec *dst_spec)
|
||||
{
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
@ -511,10 +511,10 @@ int SDL_GetAudioStreamFormat(SDL_AudioStream *stream, SDL_AudioSpec *src_spec, S
|
||||
return SDL_SetError("Stream has no destination format");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_SetAudioStreamFormat(SDL_AudioStream *stream, const SDL_AudioSpec *src_spec, const SDL_AudioSpec *dst_spec)
|
||||
SDL_bool SDL_SetAudioStreamFormat(SDL_AudioStream *stream, const SDL_AudioSpec *src_spec, const SDL_AudioSpec *dst_spec)
|
||||
{
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
@ -581,27 +581,27 @@ int SDL_SetAudioStreamFormat(SDL_AudioStream *stream, const SDL_AudioSpec *src_s
|
||||
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SetAudioStreamChannelMap(SDL_AudioStream *stream, const SDL_AudioSpec *spec, int **stream_chmap, const int *chmap, int channels, int isinput)
|
||||
bool SetAudioStreamChannelMap(SDL_AudioStream *stream, const SDL_AudioSpec *spec, int **stream_chmap, const int *chmap, int channels, int isinput)
|
||||
{
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
}
|
||||
|
||||
int retval = 0;
|
||||
bool result = true;
|
||||
|
||||
SDL_LockMutex(stream->lock);
|
||||
|
||||
if (channels != spec->channels) {
|
||||
retval = SDL_SetError("Wrong number of channels");
|
||||
result = SDL_SetError("Wrong number of channels");
|
||||
} else if (!*stream_chmap && !chmap) {
|
||||
// already at default, we're good.
|
||||
} else if (*stream_chmap && chmap && (SDL_memcmp(*stream_chmap, chmap, sizeof (*chmap) * channels) == 0)) {
|
||||
// already have this map, don't allocate/copy it again.
|
||||
} else if (SDL_ChannelMapIsBogus(chmap, channels)) {
|
||||
retval = SDL_SetError("Invalid channel mapping");
|
||||
result = SDL_SetError("Invalid channel mapping");
|
||||
} else if ((isinput != -1) && stream->bound_device && (!!isinput == !!stream->bound_device->physical_device->recording)) {
|
||||
// quietly refuse to change the format of the end currently bound to a device.
|
||||
} else {
|
||||
@ -611,7 +611,7 @@ int SetAudioStreamChannelMap(SDL_AudioStream *stream, const SDL_AudioSpec *spec,
|
||||
if (chmap) {
|
||||
int *dupmap = SDL_ChannelMapDup(chmap, channels);
|
||||
if (!dupmap) {
|
||||
retval = SDL_SetError("Invalid channel mapping");
|
||||
result = SDL_SetError("Invalid channel mapping");
|
||||
} else {
|
||||
SDL_free(*stream_chmap);
|
||||
*stream_chmap = dupmap;
|
||||
@ -623,27 +623,27 @@ int SetAudioStreamChannelMap(SDL_AudioStream *stream, const SDL_AudioSpec *spec,
|
||||
}
|
||||
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
int SDL_SetAudioStreamInputChannelMap(SDL_AudioStream *stream, const int *chmap, int channels)
|
||||
SDL_bool SDL_SetAudioStreamInputChannelMap(SDL_AudioStream *stream, const int *chmap, int channels)
|
||||
{
|
||||
return SetAudioStreamChannelMap(stream, &stream->src_spec, &stream->src_chmap, chmap, channels, true);
|
||||
}
|
||||
|
||||
int SDL_SetAudioStreamOutputChannelMap(SDL_AudioStream *stream, const int *chmap, int channels)
|
||||
SDL_bool SDL_SetAudioStreamOutputChannelMap(SDL_AudioStream *stream, const int *chmap, int channels)
|
||||
{
|
||||
return SetAudioStreamChannelMap(stream, &stream->dst_spec, &stream->dst_chmap, chmap, channels, false);
|
||||
}
|
||||
|
||||
int *SDL_GetAudioStreamInputChannelMap(SDL_AudioStream *stream, int *count)
|
||||
{
|
||||
int *retval = NULL;
|
||||
int *result = NULL;
|
||||
int channels = 0;
|
||||
if (stream) {
|
||||
SDL_LockMutex(stream->lock);
|
||||
channels = stream->src_spec.channels;
|
||||
retval = SDL_ChannelMapDup(stream->src_chmap, channels);
|
||||
result = SDL_ChannelMapDup(stream->src_chmap, channels);
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
}
|
||||
|
||||
@ -651,17 +651,17 @@ int *SDL_GetAudioStreamInputChannelMap(SDL_AudioStream *stream, int *count)
|
||||
*count = channels;
|
||||
}
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
int *SDL_GetAudioStreamOutputChannelMap(SDL_AudioStream *stream, int *count)
|
||||
{
|
||||
int *retval = NULL;
|
||||
int *result = NULL;
|
||||
int channels = 0;
|
||||
if (stream) {
|
||||
SDL_LockMutex(stream->lock);
|
||||
channels = stream->dst_spec.channels;
|
||||
retval = SDL_ChannelMapDup(stream->dst_chmap, channels);
|
||||
result = SDL_ChannelMapDup(stream->dst_chmap, channels);
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
}
|
||||
|
||||
@ -669,7 +669,7 @@ int *SDL_GetAudioStreamOutputChannelMap(SDL_AudioStream *stream, int *count)
|
||||
*count = channels;
|
||||
}
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
float SDL_GetAudioStreamFrequencyRatio(SDL_AudioStream *stream)
|
||||
@ -686,7 +686,7 @@ float SDL_GetAudioStreamFrequencyRatio(SDL_AudioStream *stream)
|
||||
return freq_ratio;
|
||||
}
|
||||
|
||||
int SDL_SetAudioStreamFrequencyRatio(SDL_AudioStream *stream, float freq_ratio)
|
||||
SDL_bool SDL_SetAudioStreamFrequencyRatio(SDL_AudioStream *stream, float freq_ratio)
|
||||
{
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
@ -706,7 +706,7 @@ int SDL_SetAudioStreamFrequencyRatio(SDL_AudioStream *stream, float freq_ratio)
|
||||
stream->freq_ratio = freq_ratio;
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
float SDL_GetAudioStreamGain(SDL_AudioStream *stream)
|
||||
@ -723,7 +723,7 @@ float SDL_GetAudioStreamGain(SDL_AudioStream *stream)
|
||||
return gain;
|
||||
}
|
||||
|
||||
int SDL_SetAudioStreamGain(SDL_AudioStream *stream, float gain)
|
||||
SDL_bool SDL_SetAudioStreamGain(SDL_AudioStream *stream, float gain)
|
||||
{
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
@ -735,10 +735,10 @@ int SDL_SetAudioStreamGain(SDL_AudioStream *stream, float gain)
|
||||
stream->gain = gain;
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int CheckAudioStreamIsFullySetup(SDL_AudioStream *stream)
|
||||
static bool CheckAudioStreamIsFullySetup(SDL_AudioStream *stream)
|
||||
{
|
||||
if (stream->src_spec.format == 0) {
|
||||
return SDL_SetError("Stream has no source format");
|
||||
@ -746,10 +746,10 @@ static int CheckAudioStreamIsFullySetup(SDL_AudioStream *stream)
|
||||
return SDL_SetError("Stream has no destination format");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PutAudioStreamBuffer(SDL_AudioStream *stream, const void *buf, int len, SDL_ReleaseAudioBufferCallback callback, void* userdata)
|
||||
static bool PutAudioStreamBuffer(SDL_AudioStream *stream, const void *buf, int len, SDL_ReleaseAudioBufferCallback callback, void* userdata)
|
||||
{
|
||||
#if DEBUG_AUDIOSTREAM
|
||||
SDL_Log("AUDIOSTREAM: wants to put %d bytes", len);
|
||||
@ -757,9 +757,9 @@ static int PutAudioStreamBuffer(SDL_AudioStream *stream, const void *buf, int le
|
||||
|
||||
SDL_LockMutex(stream->lock);
|
||||
|
||||
if (CheckAudioStreamIsFullySetup(stream) != 0) {
|
||||
if (!CheckAudioStreamIsFullySetup(stream)) {
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((len % SDL_AUDIO_FRAMESIZE(stream->src_spec)) != 0) {
|
||||
@ -774,21 +774,21 @@ static int PutAudioStreamBuffer(SDL_AudioStream *stream, const void *buf, int le
|
||||
|
||||
if (!track) {
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const int prev_available = stream->put_callback ? SDL_GetAudioStreamAvailable(stream) : 0;
|
||||
|
||||
int retval = 0;
|
||||
bool result = true;
|
||||
|
||||
if (track) {
|
||||
SDL_AddTrackToAudioQueue(stream->queue, track);
|
||||
} else {
|
||||
retval = SDL_WriteToAudioQueue(stream->queue, &stream->src_spec, stream->src_chmap, (const Uint8 *)buf, len);
|
||||
result = SDL_WriteToAudioQueue(stream->queue, &stream->src_spec, stream->src_chmap, (const Uint8 *)buf, len);
|
||||
}
|
||||
|
||||
if (retval == 0) {
|
||||
if (result) {
|
||||
if (stream->put_callback) {
|
||||
const int newavail = SDL_GetAudioStreamAvailable(stream) - prev_available;
|
||||
stream->put_callback(stream->put_callback_userdata, stream, newavail, newavail);
|
||||
@ -797,7 +797,7 @@ static int PutAudioStreamBuffer(SDL_AudioStream *stream, const void *buf, int le
|
||||
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void SDLCALL FreeAllocatedAudioBuffer(void *userdata, const void *buf, int len)
|
||||
@ -805,7 +805,7 @@ static void SDLCALL FreeAllocatedAudioBuffer(void *userdata, const void *buf, in
|
||||
SDL_free((void*) buf);
|
||||
}
|
||||
|
||||
int SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len)
|
||||
SDL_bool SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len)
|
||||
{
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
@ -814,7 +814,7 @@ int SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len)
|
||||
} else if (len < 0) {
|
||||
return SDL_InvalidParamError("len");
|
||||
} else if (len == 0) {
|
||||
return 0; // nothing to do.
|
||||
return true; // nothing to do.
|
||||
}
|
||||
|
||||
// When copying in large amounts of data, try and do as much work as possible
|
||||
@ -822,28 +822,26 @@ int SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len)
|
||||
const int large_input_thresh = 64 * 1024;
|
||||
|
||||
if (len >= large_input_thresh) {
|
||||
void* data = SDL_malloc(len);
|
||||
void *data = SDL_malloc(len);
|
||||
|
||||
if (!data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_memcpy(data, buf, len);
|
||||
buf = data;
|
||||
|
||||
int ret = PutAudioStreamBuffer(stream, buf, len, FreeAllocatedAudioBuffer, NULL);
|
||||
|
||||
if (ret < 0) {
|
||||
bool ret = PutAudioStreamBuffer(stream, buf, len, FreeAllocatedAudioBuffer, NULL);
|
||||
if (!ret) {
|
||||
SDL_free(data);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return PutAudioStreamBuffer(stream, buf, len, NULL, NULL);
|
||||
}
|
||||
|
||||
int SDL_FlushAudioStream(SDL_AudioStream *stream)
|
||||
SDL_bool SDL_FlushAudioStream(SDL_AudioStream *stream)
|
||||
{
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
@ -853,7 +851,7 @@ int SDL_FlushAudioStream(SDL_AudioStream *stream)
|
||||
SDL_FlushAudioQueue(stream->queue);
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* this does not save the previous contents of stream->work_buffer. It's a work buffer!!
|
||||
@ -970,7 +968,7 @@ static Sint64 GetAudioStreamHead(SDL_AudioStream* stream, SDL_AudioSpec* out_spe
|
||||
|
||||
// You must hold stream->lock and validate your parameters before calling this!
|
||||
// Enough input data MUST be available!
|
||||
static int GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int output_frames, float gain)
|
||||
static bool GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int output_frames, float gain)
|
||||
{
|
||||
const SDL_AudioSpec* src_spec = &stream->input_spec;
|
||||
const SDL_AudioSpec* dst_spec = &stream->dst_spec;
|
||||
@ -1000,15 +998,15 @@ static int GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int ou
|
||||
work_buffer = EnsureAudioStreamWorkBufferSize(stream, output_frames * max_frame_size);
|
||||
|
||||
if (!work_buffer) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_ReadFromAudioQueue(stream->queue, buf, dst_format, dst_channels, dst_map, 0, output_frames, 0, work_buffer, gain) != buf) {
|
||||
if (SDL_ReadFromAudioQueue(stream->queue, (Uint8 *)buf, dst_format, dst_channels, dst_map, 0, output_frames, 0, work_buffer, gain) != buf) {
|
||||
return SDL_SetError("Not enough data in queue");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Time to do some resampling!
|
||||
@ -1066,7 +1064,7 @@ static int GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int ou
|
||||
Uint8* work_buffer = EnsureAudioStreamWorkBufferSize(stream, work_buffer_capacity);
|
||||
|
||||
if (!work_buffer) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// adjust gain either before resampling or after, depending on which point has less
|
||||
@ -1096,7 +1094,7 @@ static int GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int ou
|
||||
// Convert to the final format, if necessary (src channel map is NULL because SDL_ReadFromAudioQueue already handled this).
|
||||
ConvertAudio(output_frames, resample_buffer, resample_format, resample_channels, NULL, buf, dst_format, dst_channels, dst_map, work_buffer, postresample_gain);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// get converted/resampled data from the stream
|
||||
@ -1109,18 +1107,21 @@ int SDL_GetAudioStreamDataAdjustGain(SDL_AudioStream *stream, void *voidbuf, int
|
||||
#endif
|
||||
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
SDL_InvalidParamError("stream");
|
||||
return -1;
|
||||
} else if (!buf) {
|
||||
return SDL_InvalidParamError("buf");
|
||||
SDL_InvalidParamError("buf");
|
||||
return -1;
|
||||
} else if (len < 0) {
|
||||
return SDL_InvalidParamError("len");
|
||||
SDL_InvalidParamError("len");
|
||||
return -1;
|
||||
} else if (len == 0) {
|
||||
return 0; // nothing to do.
|
||||
}
|
||||
|
||||
SDL_LockMutex(stream->lock);
|
||||
|
||||
if (CheckAudioStreamIsFullySetup(stream) != 0) {
|
||||
if (!CheckAudioStreamIsFullySetup(stream)) {
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
return -1;
|
||||
}
|
||||
@ -1176,7 +1177,7 @@ int SDL_GetAudioStreamDataAdjustGain(SDL_AudioStream *stream, void *voidbuf, int
|
||||
break;
|
||||
}
|
||||
|
||||
if (UpdateAudioStreamInputSpec(stream, &input_spec, input_chmap) != 0) {
|
||||
if (!UpdateAudioStreamInputSpec(stream, &input_spec, input_chmap)) {
|
||||
total = total ? total : -1;
|
||||
break;
|
||||
}
|
||||
@ -1187,7 +1188,7 @@ int SDL_GetAudioStreamDataAdjustGain(SDL_AudioStream *stream, void *voidbuf, int
|
||||
output_frames = SDL_min(output_frames, chunk_size);
|
||||
output_frames = (int) SDL_min(output_frames, available_frames);
|
||||
|
||||
if (GetAudioStreamDataInternal(stream, &buf[total], output_frames, gain) != 0) {
|
||||
if (!GetAudioStreamDataInternal(stream, &buf[total], output_frames, gain)) {
|
||||
total = total ? total : -1;
|
||||
break;
|
||||
}
|
||||
@ -1213,12 +1214,13 @@ int SDL_GetAudioStreamData(SDL_AudioStream *stream, void *voidbuf, int len)
|
||||
int SDL_GetAudioStreamAvailable(SDL_AudioStream *stream)
|
||||
{
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
SDL_InvalidParamError("stream");
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_LockMutex(stream->lock);
|
||||
|
||||
if (CheckAudioStreamIsFullySetup(stream) != 0) {
|
||||
if (!CheckAudioStreamIsFullySetup(stream)) {
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
return 0;
|
||||
}
|
||||
@ -1238,7 +1240,8 @@ int SDL_GetAudioStreamAvailable(SDL_AudioStream *stream)
|
||||
int SDL_GetAudioStreamQueued(SDL_AudioStream *stream)
|
||||
{
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
SDL_InvalidParamError("stream");
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_LockMutex(stream->lock);
|
||||
@ -1251,7 +1254,7 @@ int SDL_GetAudioStreamQueued(SDL_AudioStream *stream)
|
||||
return (int) SDL_min(total, SDL_INT_MAX);
|
||||
}
|
||||
|
||||
int SDL_ClearAudioStream(SDL_AudioStream *stream)
|
||||
SDL_bool SDL_ClearAudioStream(SDL_AudioStream *stream)
|
||||
{
|
||||
if (!stream) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
@ -1265,7 +1268,7 @@ int SDL_ClearAudioStream(SDL_AudioStream *stream)
|
||||
stream->resample_offset = 0;
|
||||
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDL_DestroyAudioStream(SDL_AudioStream *stream)
|
||||
@ -1300,8 +1303,7 @@ static void SDLCALL DontFreeThisAudioBuffer(void *userdata, const void *buf, int
|
||||
// We don't own the buffer, but know it will outlive the stream
|
||||
}
|
||||
|
||||
int SDL_ConvertAudioSamples(const SDL_AudioSpec *src_spec, const Uint8 *src_data, int src_len,
|
||||
const SDL_AudioSpec *dst_spec, Uint8 **dst_data, int *dst_len)
|
||||
SDL_bool SDL_ConvertAudioSamples(const SDL_AudioSpec *src_spec, const Uint8 *src_data, int src_len, const SDL_AudioSpec *dst_spec, Uint8 **dst_data, int *dst_len)
|
||||
{
|
||||
if (dst_data) {
|
||||
*dst_data = NULL;
|
||||
@ -1321,30 +1323,31 @@ int SDL_ConvertAudioSamples(const SDL_AudioSpec *src_spec, const Uint8 *src_data
|
||||
return SDL_InvalidParamError("dst_len");
|
||||
}
|
||||
|
||||
int retval = -1;
|
||||
bool result = false;
|
||||
Uint8 *dst = NULL;
|
||||
int dstlen = 0;
|
||||
|
||||
SDL_AudioStream *stream = SDL_CreateAudioStream(src_spec, dst_spec);
|
||||
if (stream) {
|
||||
if ((PutAudioStreamBuffer(stream, src_data, src_len, DontFreeThisAudioBuffer, NULL) == 0) && (SDL_FlushAudioStream(stream) == 0)) {
|
||||
if (PutAudioStreamBuffer(stream, src_data, src_len, DontFreeThisAudioBuffer, NULL) &&
|
||||
SDL_FlushAudioStream(stream)) {
|
||||
dstlen = SDL_GetAudioStreamAvailable(stream);
|
||||
if (dstlen >= 0) {
|
||||
dst = (Uint8 *)SDL_malloc(dstlen);
|
||||
if (dst) {
|
||||
retval = (SDL_GetAudioStreamData(stream, dst, dstlen) == dstlen) ? 0 : -1;
|
||||
result = (SDL_GetAudioStreamData(stream, dst, dstlen) == dstlen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (retval < 0) {
|
||||
SDL_free(dst);
|
||||
} else {
|
||||
if (result) {
|
||||
*dst_data = dst;
|
||||
*dst_len = dstlen;
|
||||
} else {
|
||||
SDL_free(dst);
|
||||
}
|
||||
|
||||
SDL_DestroyAudioStream(stream);
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
@ -121,13 +121,13 @@ static void InitMemoryPool(SDL_MemoryPool *pool, size_t block_size, size_t max_f
|
||||
}
|
||||
|
||||
// Allocates a number of blocks and adds them to the pool
|
||||
static int ReserveMemoryPoolBlocks(SDL_MemoryPool *pool, size_t num_blocks)
|
||||
static bool ReserveMemoryPoolBlocks(SDL_MemoryPool *pool, size_t num_blocks)
|
||||
{
|
||||
for (; num_blocks; --num_blocks) {
|
||||
void *block = AllocNewMemoryPoolBlock(pool);
|
||||
|
||||
if (block == NULL) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
*(void **)block = pool->free_blocks;
|
||||
@ -135,7 +135,7 @@ static int ReserveMemoryPoolBlocks(SDL_MemoryPool *pool, size_t num_blocks)
|
||||
++pool->num_free;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDL_DestroyAudioQueue(SDL_AudioQueue *queue)
|
||||
@ -160,7 +160,7 @@ SDL_AudioQueue *SDL_CreateAudioQueue(size_t chunk_size)
|
||||
InitMemoryPool(&queue->track_pool, sizeof(SDL_AudioTrack), 8);
|
||||
InitMemoryPool(&queue->chunk_pool, chunk_size, 4);
|
||||
|
||||
if (ReserveMemoryPoolBlocks(&queue->track_pool, 2) != 0) {
|
||||
if (!ReserveMemoryPoolBlocks(&queue->track_pool, 2)) {
|
||||
SDL_DestroyAudioQueue(queue);
|
||||
return NULL;
|
||||
}
|
||||
@ -318,10 +318,10 @@ static size_t WriteToAudioTrack(SDL_AudioTrack *track, const Uint8 *data, size_t
|
||||
return len;
|
||||
}
|
||||
|
||||
int SDL_WriteToAudioQueue(SDL_AudioQueue *queue, const SDL_AudioSpec *spec, const int *chmap, const Uint8 *data, size_t len)
|
||||
bool SDL_WriteToAudioQueue(SDL_AudioQueue *queue, const SDL_AudioSpec *spec, const int *chmap, const Uint8 *data, size_t len)
|
||||
{
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_AudioTrack *track = queue->tail;
|
||||
@ -335,7 +335,7 @@ int SDL_WriteToAudioQueue(SDL_AudioQueue *queue, const SDL_AudioSpec *spec, cons
|
||||
track = CreateChunkedAudioTrack(queue, spec, chmap);
|
||||
|
||||
if (!track) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
queue->head = track;
|
||||
@ -354,7 +354,7 @@ int SDL_WriteToAudioQueue(SDL_AudioQueue *queue, const SDL_AudioSpec *spec, cons
|
||||
SDL_AudioTrack *new_track = CreateChunkedAudioTrack(queue, spec, chmap);
|
||||
|
||||
if (!new_track) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
track->next = new_track;
|
||||
@ -362,7 +362,7 @@ int SDL_WriteToAudioQueue(SDL_AudioQueue *queue, const SDL_AudioSpec *spec, cons
|
||||
track = new_track;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void *SDL_BeginAudioQueueIter(SDL_AudioQueue *queue)
|
||||
@ -624,12 +624,12 @@ size_t SDL_GetAudioQueueQueued(SDL_AudioQueue *queue)
|
||||
return total;
|
||||
}
|
||||
|
||||
int SDL_ResetAudioQueueHistory(SDL_AudioQueue *queue, int num_frames)
|
||||
bool SDL_ResetAudioQueueHistory(SDL_AudioQueue *queue, int num_frames)
|
||||
{
|
||||
SDL_AudioTrack *track = queue->head;
|
||||
|
||||
if (!track) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t length = num_frames * SDL_AUDIO_FRAMESIZE(track->spec);
|
||||
@ -638,7 +638,7 @@ int SDL_ResetAudioQueueHistory(SDL_AudioQueue *queue, int num_frames)
|
||||
if (queue->history_capacity < length) {
|
||||
history_buffer = SDL_aligned_alloc(SDL_GetSIMDAlignment(), length);
|
||||
if (!history_buffer) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
SDL_aligned_free(queue->history_buffer);
|
||||
queue->history_buffer = history_buffer;
|
||||
@ -648,5 +648,5 @@ int SDL_ResetAudioQueueHistory(SDL_AudioQueue *queue, int num_frames)
|
||||
queue->history_length = length;
|
||||
SDL_memset(history_buffer, SDL_GetSilenceValueForFormat(track->spec.format), length);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
@ -25,55 +25,55 @@
|
||||
|
||||
// Internal functions used by SDL_AudioStream for queueing audio.
|
||||
|
||||
typedef void(SDLCALL *SDL_ReleaseAudioBufferCallback)(void *userdata, const void *buffer, int buflen);
|
||||
typedef void (SDLCALL *SDL_ReleaseAudioBufferCallback)(void *userdata, const void *buffer, int buflen);
|
||||
|
||||
typedef struct SDL_AudioQueue SDL_AudioQueue;
|
||||
typedef struct SDL_AudioTrack SDL_AudioTrack;
|
||||
|
||||
// Create a new audio queue
|
||||
SDL_AudioQueue *SDL_CreateAudioQueue(size_t chunk_size);
|
||||
extern SDL_AudioQueue *SDL_CreateAudioQueue(size_t chunk_size);
|
||||
|
||||
// Destroy an audio queue
|
||||
void SDL_DestroyAudioQueue(SDL_AudioQueue *queue);
|
||||
extern void SDL_DestroyAudioQueue(SDL_AudioQueue *queue);
|
||||
|
||||
// Completely clear the queue
|
||||
void SDL_ClearAudioQueue(SDL_AudioQueue *queue);
|
||||
extern void SDL_ClearAudioQueue(SDL_AudioQueue *queue);
|
||||
|
||||
// Mark the last track as flushed
|
||||
void SDL_FlushAudioQueue(SDL_AudioQueue *queue);
|
||||
extern void SDL_FlushAudioQueue(SDL_AudioQueue *queue);
|
||||
|
||||
// Pop the current head track
|
||||
// REQUIRES: The head track must exist, and must have been flushed
|
||||
void SDL_PopAudioQueueHead(SDL_AudioQueue *queue);
|
||||
extern void SDL_PopAudioQueueHead(SDL_AudioQueue *queue);
|
||||
|
||||
// Write data to the end of queue
|
||||
// REQUIRES: If the spec has changed, the last track must have been flushed
|
||||
int SDL_WriteToAudioQueue(SDL_AudioQueue *queue, const SDL_AudioSpec *spec, const int *chmap, const Uint8 *data, size_t len);
|
||||
extern bool SDL_WriteToAudioQueue(SDL_AudioQueue *queue, const SDL_AudioSpec *spec, const int *chmap, const Uint8 *data, size_t len);
|
||||
|
||||
// Create a track where the input data is owned by the caller
|
||||
SDL_AudioTrack *SDL_CreateAudioTrack(SDL_AudioQueue *queue,
|
||||
const SDL_AudioSpec *spec, const int *chmap, Uint8 *data, size_t len, size_t capacity,
|
||||
SDL_ReleaseAudioBufferCallback callback, void *userdata);
|
||||
extern SDL_AudioTrack *SDL_CreateAudioTrack(SDL_AudioQueue *queue,
|
||||
const SDL_AudioSpec *spec, const int *chmap, Uint8 *data, size_t len, size_t capacity,
|
||||
SDL_ReleaseAudioBufferCallback callback, void *userdata);
|
||||
|
||||
// Add a track to the end of the queue
|
||||
// REQUIRES: `track != NULL`
|
||||
void SDL_AddTrackToAudioQueue(SDL_AudioQueue *queue, SDL_AudioTrack *track);
|
||||
extern void SDL_AddTrackToAudioQueue(SDL_AudioQueue *queue, SDL_AudioTrack *track);
|
||||
|
||||
// Iterate over the tracks in the queue
|
||||
void *SDL_BeginAudioQueueIter(SDL_AudioQueue *queue);
|
||||
extern void *SDL_BeginAudioQueueIter(SDL_AudioQueue *queue);
|
||||
|
||||
// Query and update the track iterator
|
||||
// REQUIRES: `*inout_iter != NULL` (a valid iterator)
|
||||
size_t SDL_NextAudioQueueIter(SDL_AudioQueue *queue, void **inout_iter, SDL_AudioSpec *out_spec, int **out_chmap, bool *out_flushed);
|
||||
extern size_t SDL_NextAudioQueueIter(SDL_AudioQueue *queue, void **inout_iter, SDL_AudioSpec *out_spec, int **out_chmap, bool *out_flushed);
|
||||
|
||||
const Uint8 *SDL_ReadFromAudioQueue(SDL_AudioQueue *queue,
|
||||
Uint8 *dst, SDL_AudioFormat dst_format, int dst_channels, const int *dst_map,
|
||||
int past_frames, int present_frames, int future_frames,
|
||||
Uint8 *scratch, float gain);
|
||||
extern const Uint8 *SDL_ReadFromAudioQueue(SDL_AudioQueue *queue,
|
||||
Uint8 *dst, SDL_AudioFormat dst_format, int dst_channels, const int *dst_map,
|
||||
int past_frames, int present_frames, int future_frames,
|
||||
Uint8 *scratch, float gain);
|
||||
|
||||
// Get the total number of bytes currently queued
|
||||
size_t SDL_GetAudioQueueQueued(SDL_AudioQueue *queue);
|
||||
extern size_t SDL_GetAudioQueueQueued(SDL_AudioQueue *queue);
|
||||
|
||||
int SDL_ResetAudioQueueHistory(SDL_AudioQueue *queue, int num_frames);
|
||||
extern bool SDL_ResetAudioQueueHistory(SDL_AudioQueue *queue, int num_frames);
|
||||
|
||||
#endif // SDL_audioqueue_h_
|
||||
|
@ -613,24 +613,24 @@ int SDL_GetResamplerPaddingFrames(Sint64 resample_rate)
|
||||
}
|
||||
|
||||
// These are not general purpose. They do not check for all possible underflow/overflow
|
||||
SDL_FORCE_INLINE Sint64 ResamplerAdd(Sint64 a, Sint64 b, Sint64 *ret)
|
||||
SDL_FORCE_INLINE bool ResamplerAdd(Sint64 a, Sint64 b, Sint64 *ret)
|
||||
{
|
||||
if ((b > 0) && (a > SDL_MAX_SINT64 - b)) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
*ret = a + b;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_FORCE_INLINE Sint64 ResamplerMul(Sint64 a, Sint64 b, Sint64 *ret)
|
||||
SDL_FORCE_INLINE bool ResamplerMul(Sint64 a, Sint64 b, Sint64 *ret)
|
||||
{
|
||||
if ((b > 0) && (a > SDL_MAX_SINT64 / b)) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
*ret = a * b;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
Sint64 SDL_GetResamplerInputFrames(Sint64 output_frames, Sint64 resample_rate, Sint64 resample_offset)
|
||||
@ -639,8 +639,8 @@ Sint64 SDL_GetResamplerInputFrames(Sint64 output_frames, Sint64 resample_rate, S
|
||||
// ((((output_frames - 1) * resample_rate) + resample_offset) >> 32) + 1
|
||||
|
||||
Sint64 output_offset;
|
||||
if (ResamplerMul(output_frames, resample_rate, &output_offset) ||
|
||||
ResamplerAdd(output_offset, -resample_rate + resample_offset + 0x100000000, &output_offset)) {
|
||||
if (!ResamplerMul(output_frames, resample_rate, &output_offset) ||
|
||||
!ResamplerAdd(output_offset, -resample_rate + resample_offset + 0x100000000, &output_offset)) {
|
||||
output_offset = SDL_MAX_SINT64;
|
||||
}
|
||||
|
||||
@ -656,8 +656,8 @@ Sint64 SDL_GetResamplerOutputFrames(Sint64 input_frames, Sint64 resample_rate, S
|
||||
|
||||
// input_offset = (input_frames << 32) - resample_offset;
|
||||
Sint64 input_offset;
|
||||
if (ResamplerMul(input_frames, 0x100000000, &input_offset) ||
|
||||
ResamplerAdd(input_offset, -resample_offset, &input_offset)) {
|
||||
if (!ResamplerMul(input_frames, 0x100000000, &input_offset) ||
|
||||
!ResamplerAdd(input_offset, -resample_offset, &input_offset)) {
|
||||
input_offset = SDL_MAX_SINT64;
|
||||
}
|
||||
|
||||
|
@ -86,13 +86,12 @@ static const Uint8 mix8[] = {
|
||||
// !!! FIXME: Add fast-path for volume = 1
|
||||
// !!! FIXME: Use larger scales for 16-bit/32-bit integers
|
||||
|
||||
int SDL_MixAudio(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format,
|
||||
Uint32 len, float fvolume)
|
||||
SDL_bool SDL_MixAudio(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format, Uint32 len, float fvolume)
|
||||
{
|
||||
int volume = (int)SDL_roundf(fvolume * MIX_MAXVOLUME);
|
||||
|
||||
if (volume == 0) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
@ -287,5 +286,5 @@ int SDL_MixAudio(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format,
|
||||
return SDL_SetError("SDL_MixAudio(): unknown audio format");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ typedef struct SDL_AudioDevice SDL_AudioDevice;
|
||||
typedef struct SDL_LogicalAudioDevice SDL_LogicalAudioDevice;
|
||||
|
||||
// Used by src/SDL.c to initialize a particular audio driver.
|
||||
extern int SDL_InitAudio(const char *driver_name);
|
||||
extern bool SDL_InitAudio(const char *driver_name);
|
||||
|
||||
// Used by src/SDL.c to shut down previously-initialized audio.
|
||||
extern void SDL_QuitAudio(void);
|
||||
@ -79,10 +79,10 @@ extern void SDL_AudioDeviceDisconnected(SDL_AudioDevice *device);
|
||||
extern void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device);
|
||||
|
||||
// Backends should call this if a device's format is changing (opened or not); SDL will update state and carry on with the new format.
|
||||
extern int SDL_AudioDeviceFormatChanged(SDL_AudioDevice *device, const SDL_AudioSpec *newspec, int new_sample_frames);
|
||||
extern bool SDL_AudioDeviceFormatChanged(SDL_AudioDevice *device, const SDL_AudioSpec *newspec, int new_sample_frames);
|
||||
|
||||
// Same as above, but assume the device is already locked.
|
||||
extern int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL_AudioSpec *newspec, int new_sample_frames);
|
||||
extern bool SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL_AudioSpec *newspec, int new_sample_frames);
|
||||
|
||||
// Find the SDL_AudioDevice associated with the handle supplied to SDL_AddAudioDevice. NULL if not found. DOES NOT LOCK THE DEVICE.
|
||||
extern SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByHandle(void *handle);
|
||||
@ -138,19 +138,19 @@ extern void OnAudioStreamDestroy(SDL_AudioStream *stream);
|
||||
extern int SDL_GetAudioStreamDataAdjustGain(SDL_AudioStream *stream, void *voidbuf, int len, float extra_gain);
|
||||
|
||||
// This is the bulk of `SDL_SetAudioStream*putChannelMap`'s work, but it lets you skip the check about changing the device end of a stream if isinput==-1.
|
||||
extern int SetAudioStreamChannelMap(SDL_AudioStream *stream, const SDL_AudioSpec *spec, int **stream_chmap, const int *chmap, int channels, int isinput);
|
||||
extern bool SetAudioStreamChannelMap(SDL_AudioStream *stream, const SDL_AudioSpec *spec, int **stream_chmap, const int *chmap, int channels, int isinput);
|
||||
|
||||
|
||||
typedef struct SDL_AudioDriverImpl
|
||||
{
|
||||
void (*DetectDevices)(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording);
|
||||
int (*OpenDevice)(SDL_AudioDevice *device);
|
||||
bool (*OpenDevice)(SDL_AudioDevice *device);
|
||||
void (*ThreadInit)(SDL_AudioDevice *device); // Called by audio thread at start
|
||||
void (*ThreadDeinit)(SDL_AudioDevice *device); // Called by audio thread at end
|
||||
int (*WaitDevice)(SDL_AudioDevice *device);
|
||||
int (*PlayDevice)(SDL_AudioDevice *device, const Uint8 *buffer, int buflen); // buffer and buflen are always from GetDeviceBuf, passed here for convenience.
|
||||
bool (*WaitDevice)(SDL_AudioDevice *device);
|
||||
bool (*PlayDevice)(SDL_AudioDevice *device, const Uint8 *buffer, int buflen); // buffer and buflen are always from GetDeviceBuf, passed here for convenience.
|
||||
Uint8 *(*GetDeviceBuf)(SDL_AudioDevice *device, int *buffer_size);
|
||||
int (*WaitRecordingDevice)(SDL_AudioDevice *device);
|
||||
bool (*WaitRecordingDevice)(SDL_AudioDevice *device);
|
||||
int (*RecordDevice)(SDL_AudioDevice *device, void *buffer, int buflen);
|
||||
void (*FlushRecording)(SDL_AudioDevice *device);
|
||||
void (*CloseDevice)(SDL_AudioDevice *device);
|
||||
@ -282,10 +282,10 @@ struct SDL_AudioDevice
|
||||
SDL_AtomicInt refcount;
|
||||
|
||||
// These are, initially, set from current_audio, but we might swap them out with Zombie versions on disconnect/failure.
|
||||
int (*WaitDevice)(SDL_AudioDevice *device);
|
||||
int (*PlayDevice)(SDL_AudioDevice *device, const Uint8 *buffer, int buflen);
|
||||
bool (*WaitDevice)(SDL_AudioDevice *device);
|
||||
bool (*PlayDevice)(SDL_AudioDevice *device, const Uint8 *buffer, int buflen);
|
||||
Uint8 *(*GetDeviceBuf)(SDL_AudioDevice *device, int *buffer_size);
|
||||
int (*WaitRecordingDevice)(SDL_AudioDevice *device);
|
||||
bool (*WaitRecordingDevice)(SDL_AudioDevice *device);
|
||||
int (*RecordDevice)(SDL_AudioDevice *device, void *buffer, int buflen);
|
||||
void (*FlushRecording)(SDL_AudioDevice *device);
|
||||
|
||||
|
@ -324,7 +324,8 @@ static Sint64 WaveAdjustToFactValue(WaveFile *file, Sint64 sampleframes)
|
||||
{
|
||||
if (file->fact.status == 2) {
|
||||
if (file->facthint == FactStrict && sampleframes < file->fact.samplelength) {
|
||||
return SDL_SetError("Invalid number of sample frames in WAVE fact chunk (too many)");
|
||||
SDL_SetError("Invalid number of sample frames in WAVE fact chunk (too many)");
|
||||
return -1;
|
||||
} else if (sampleframes > file->fact.samplelength) {
|
||||
return file->fact.samplelength;
|
||||
}
|
||||
@ -333,7 +334,7 @@ static Sint64 WaveAdjustToFactValue(WaveFile *file, Sint64 sampleframes)
|
||||
return sampleframes;
|
||||
}
|
||||
|
||||
static int MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
|
||||
static bool MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
|
||||
{
|
||||
WaveFormat *format = &file->format;
|
||||
const size_t blockheadersize = (size_t)file->format.channels * 7;
|
||||
@ -366,13 +367,13 @@ static int MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
|
||||
|
||||
file->sampleframes = WaveAdjustToFactValue(file, file->sampleframes);
|
||||
if (file->sampleframes < 0) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int MS_ADPCM_Init(WaveFile *file, size_t datalength)
|
||||
static bool MS_ADPCM_Init(WaveFile *file, size_t datalength)
|
||||
{
|
||||
WaveFormat *format = &file->format;
|
||||
WaveChunk *chunk = &file->chunk;
|
||||
@ -440,7 +441,7 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength)
|
||||
coeffdata = (MS_ADPCM_CoeffData *)SDL_malloc(sizeof(MS_ADPCM_CoeffData) + coeffcount * 4);
|
||||
file->decoderdata = coeffdata; // Freed in cleanup.
|
||||
if (!coeffdata) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
coeffdata->coeff = &coeffdata->aligndummy;
|
||||
coeffdata->coeffcount = (Uint16)coeffcount;
|
||||
@ -483,11 +484,11 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength)
|
||||
return SDL_SetError("Invalid number of samples per MS ADPCM block (wSamplesPerBlock)");
|
||||
}
|
||||
|
||||
if (MS_ADPCM_CalculateSampleFrames(file, datalength) < 0) {
|
||||
return -1;
|
||||
if (!MS_ADPCM_CalculateSampleFrames(file, datalength)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Sint16 MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sample1, Sint32 sample2, Uint8 nybble)
|
||||
@ -526,7 +527,7 @@ static Sint16 MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sampl
|
||||
return (Sint16)new_sample;
|
||||
}
|
||||
|
||||
static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||
static bool MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||
{
|
||||
Uint8 coeffindex;
|
||||
const Uint32 channels = state->channels;
|
||||
@ -578,7 +579,7 @@ static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||
// Header provided two sample frames.
|
||||
state->framesleft -= 2;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Decodes the data of the MS ADPCM block. Decoding will stop if a block is too
|
||||
@ -586,7 +587,7 @@ static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||
* will always contain full sample frames (same sample count for each channel).
|
||||
* Incomplete sample frames are discarded.
|
||||
*/
|
||||
static int MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
|
||||
static bool MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
|
||||
{
|
||||
Uint16 nybble = 0;
|
||||
Sint16 sample1, sample2;
|
||||
@ -613,7 +614,7 @@ static int MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
|
||||
} else {
|
||||
// Out of input data. Drop the incomplete frame and return.
|
||||
state->output.pos = outpos - c;
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Load previous samples which may come from the block header.
|
||||
@ -630,12 +631,12 @@ static int MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
|
||||
|
||||
state->output.pos = outpos;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
static bool MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
int result;
|
||||
bool result;
|
||||
size_t bytesleft, outputsize;
|
||||
WaveChunk *chunk = &file->chunk;
|
||||
ADPCM_DecoderState state;
|
||||
@ -646,8 +647,8 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
|
||||
if (chunk->size != chunk->length) {
|
||||
// Could not read everything. Recalculate number of sample frames.
|
||||
if (MS_ADPCM_CalculateSampleFrames(file, chunk->size) < 0) {
|
||||
return -1;
|
||||
if (!MS_ADPCM_CalculateSampleFrames(file, chunk->size)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -655,7 +656,7 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
if (file->sampleframes == 0) {
|
||||
*audio_buf = NULL;
|
||||
*audio_len = 0;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
state.blocksize = file->format.blockalign;
|
||||
@ -683,7 +684,7 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
state.output.size = outputsize / sizeof(Sint16);
|
||||
state.output.data = (Sint16 *)SDL_calloc(1, outputsize);
|
||||
if (!state.output.data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
state.cstate = cstate;
|
||||
@ -703,14 +704,14 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
|
||||
// Initialize decoder with the values from the block header.
|
||||
result = MS_ADPCM_DecodeBlockHeader(&state);
|
||||
if (result < 0) {
|
||||
if (!result) {
|
||||
SDL_free(state.output.data);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Decode the block data. It stores the samples directly in the output.
|
||||
result = MS_ADPCM_DecodeBlockData(&state);
|
||||
if (result < 0) {
|
||||
if (!result) {
|
||||
// Unexpected end. Stop decoding and return partial data if necessary.
|
||||
if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) {
|
||||
SDL_free(state.output.data);
|
||||
@ -729,10 +730,10 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
*audio_buf = (Uint8 *)state.output.data;
|
||||
*audio_len = (Uint32)outputsize;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
|
||||
static bool IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
|
||||
{
|
||||
WaveFormat *format = &file->format;
|
||||
const size_t blockheadersize = (size_t)format->channels * 4;
|
||||
@ -779,13 +780,13 @@ static int IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
|
||||
|
||||
file->sampleframes = WaveAdjustToFactValue(file, file->sampleframes);
|
||||
if (file->sampleframes < 0) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int IMA_ADPCM_Init(WaveFile *file, size_t datalength)
|
||||
static bool IMA_ADPCM_Init(WaveFile *file, size_t datalength)
|
||||
{
|
||||
WaveFormat *format = &file->format;
|
||||
WaveChunk *chunk = &file->chunk;
|
||||
@ -843,11 +844,11 @@ static int IMA_ADPCM_Init(WaveFile *file, size_t datalength)
|
||||
return SDL_SetError("Invalid number of samples per IMA ADPCM block (wSamplesPerBlock)");
|
||||
}
|
||||
|
||||
if (IMA_ADPCM_CalculateSampleFrames(file, datalength) < 0) {
|
||||
return -1;
|
||||
if (!IMA_ADPCM_CalculateSampleFrames(file, datalength)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Sint16 IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 nybble)
|
||||
@ -919,7 +920,7 @@ static Sint16 IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 ny
|
||||
return (Sint16)sample;
|
||||
}
|
||||
|
||||
static int IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||
static bool IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||
{
|
||||
Sint16 step;
|
||||
Uint32 c;
|
||||
@ -950,7 +951,7 @@ static int IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||
// Header provided one sample frame.
|
||||
state->framesleft--;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Decodes the data of the IMA ADPCM block. Decoding will stop if a block is too
|
||||
@ -958,14 +959,14 @@ static int IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||
* contains full sample frames (same sample count for each channel).
|
||||
* Incomplete sample frames are discarded.
|
||||
*/
|
||||
static int IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
|
||||
static bool IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
|
||||
{
|
||||
size_t i;
|
||||
int retval = 0;
|
||||
const Uint32 channels = state->channels;
|
||||
const size_t subblockframesize = (size_t)channels * 4;
|
||||
Uint64 bytesrequired;
|
||||
Uint32 c;
|
||||
bool result = true;
|
||||
|
||||
size_t blockpos = state->block.pos;
|
||||
size_t blocksize = state->block.size;
|
||||
@ -988,7 +989,7 @@ static int IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
|
||||
blockframesleft += (Sint64)(remainingbytes % 4) * 2;
|
||||
}
|
||||
// Signal the truncation.
|
||||
retval = -1;
|
||||
result = false;
|
||||
}
|
||||
|
||||
/* Each channel has their nibbles packed into 32-bit blocks. These blocks
|
||||
@ -1024,12 +1025,12 @@ static int IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
|
||||
state->block.pos = blockpos;
|
||||
state->output.pos = outpos;
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
static bool IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
int result;
|
||||
bool result;
|
||||
size_t bytesleft, outputsize;
|
||||
WaveChunk *chunk = &file->chunk;
|
||||
ADPCM_DecoderState state;
|
||||
@ -1037,8 +1038,8 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
|
||||
|
||||
if (chunk->size != chunk->length) {
|
||||
// Could not read everything. Recalculate number of sample frames.
|
||||
if (IMA_ADPCM_CalculateSampleFrames(file, chunk->size) < 0) {
|
||||
return -1;
|
||||
if (!IMA_ADPCM_CalculateSampleFrames(file, chunk->size)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1046,7 +1047,7 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
|
||||
if (file->sampleframes == 0) {
|
||||
*audio_buf = NULL;
|
||||
*audio_len = 0;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_zero(state);
|
||||
@ -1074,13 +1075,13 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
|
||||
state.output.size = outputsize / sizeof(Sint16);
|
||||
state.output.data = (Sint16 *)SDL_malloc(outputsize);
|
||||
if (!state.output.data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cstate = (Sint8 *)SDL_calloc(state.channels, sizeof(Sint8));
|
||||
if (!cstate) {
|
||||
SDL_free(state.output.data);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
state.cstate = cstate;
|
||||
|
||||
@ -1100,12 +1101,12 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
|
||||
|
||||
// Initialize decoder with the values from the block header.
|
||||
result = IMA_ADPCM_DecodeBlockHeader(&state);
|
||||
if (result == 0) {
|
||||
if (result) {
|
||||
// Decode the block data. It stores the samples directly in the output.
|
||||
result = IMA_ADPCM_DecodeBlockData(&state);
|
||||
}
|
||||
|
||||
if (result < 0) {
|
||||
if (!result) {
|
||||
// Unexpected end. Stop decoding and return partial data if necessary.
|
||||
if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) {
|
||||
SDL_free(state.output.data);
|
||||
@ -1127,10 +1128,10 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
|
||||
|
||||
SDL_free(cstate);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int LAW_Init(WaveFile *file, size_t datalength)
|
||||
static bool LAW_Init(WaveFile *file, size_t datalength)
|
||||
{
|
||||
WaveFormat *format = &file->format;
|
||||
|
||||
@ -1152,13 +1153,13 @@ static int LAW_Init(WaveFile *file, size_t datalength)
|
||||
|
||||
file->sampleframes = WaveAdjustToFactValue(file, datalength / format->blockalign);
|
||||
if (file->sampleframes < 0) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
static bool LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
#ifdef SDL_WAVE_LAW_LUT
|
||||
const Sint16 alaw_lut[256] = {
|
||||
@ -1208,7 +1209,7 @@ static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
if (chunk->length != chunk->size) {
|
||||
file->sampleframes = WaveAdjustToFactValue(file, chunk->size / format->blockalign);
|
||||
if (file->sampleframes < 0) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1216,7 +1217,7 @@ static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
if (file->sampleframes == 0) {
|
||||
*audio_buf = NULL;
|
||||
*audio_len = 0;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
sample_count = (size_t)file->sampleframes;
|
||||
@ -1234,7 +1235,7 @@ static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
// 1 to avoid allocating zero bytes, to keep static analysis happy.
|
||||
src = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
|
||||
if (!src) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
chunk->data = NULL;
|
||||
chunk->size = 0;
|
||||
@ -1297,10 +1298,10 @@ static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
*audio_buf = src;
|
||||
*audio_len = (Uint32)expanded_len;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PCM_Init(WaveFile *file, size_t datalength)
|
||||
static bool PCM_Init(WaveFile *file, size_t datalength)
|
||||
{
|
||||
WaveFormat *format = &file->format;
|
||||
|
||||
@ -1337,13 +1338,13 @@ static int PCM_Init(WaveFile *file, size_t datalength)
|
||||
|
||||
file->sampleframes = WaveAdjustToFactValue(file, datalength / format->blockalign);
|
||||
if (file->sampleframes < 0) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
static bool PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
WaveFormat *format = &file->format;
|
||||
WaveChunk *chunk = &file->chunk;
|
||||
@ -1365,7 +1366,7 @@ static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *
|
||||
// 1 to avoid allocating zero bytes, to keep static analysis happy.
|
||||
ptr = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
|
||||
if (!ptr) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// This pointer is now invalid.
|
||||
@ -1391,10 +1392,10 @@ static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *
|
||||
ptr[o * 4 + 3] = b[3];
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
static bool PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
WaveFormat *format = &file->format;
|
||||
WaveChunk *chunk = &file->chunk;
|
||||
@ -1403,7 +1404,7 @@ static int PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
if (chunk->length != chunk->size) {
|
||||
file->sampleframes = WaveAdjustToFactValue(file, chunk->size / format->blockalign);
|
||||
if (file->sampleframes < 0) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1411,7 +1412,7 @@ static int PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
if (file->sampleframes == 0) {
|
||||
*audio_buf = NULL;
|
||||
*audio_len = 0;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// 24-bit samples get shifted to 32 bits.
|
||||
@ -1433,7 +1434,7 @@ static int PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
chunk->data = NULL;
|
||||
chunk->size = 0;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static WaveRiffSizeHint WaveGetRiffSizeHint(void)
|
||||
@ -1598,7 +1599,7 @@ static Uint16 WaveGetFormatGUIDEncoding(WaveFormat *format)
|
||||
return UNKNOWN_CODE;
|
||||
}
|
||||
|
||||
static int WaveReadFormat(WaveFile *file)
|
||||
static bool WaveReadFormat(WaveFile *file)
|
||||
{
|
||||
WaveChunk *chunk = &file->chunk;
|
||||
WaveFormat *format = &file->format;
|
||||
@ -1611,7 +1612,7 @@ static int WaveReadFormat(WaveFile *file)
|
||||
}
|
||||
fmtsrc = SDL_IOFromConstMem(chunk->data, (int)chunk->size);
|
||||
if (!fmtsrc) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SDL_ReadU16LE(fmtsrc, &format->formattag) ||
|
||||
@ -1619,14 +1620,14 @@ static int WaveReadFormat(WaveFile *file)
|
||||
!SDL_ReadU32LE(fmtsrc, &format->frequency) ||
|
||||
!SDL_ReadU32LE(fmtsrc, &format->byterate) ||
|
||||
!SDL_ReadU16LE(fmtsrc, &format->blockalign)) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
format->encoding = format->formattag;
|
||||
|
||||
// This is PCM specific in the first version of the specification.
|
||||
if (fmtlen >= 16) {
|
||||
if (!SDL_ReadU16LE(fmtsrc, &format->bitspersample)) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
} else if (format->encoding == PCM_CODE) {
|
||||
SDL_CloseIO(fmtsrc);
|
||||
@ -1636,7 +1637,7 @@ static int WaveReadFormat(WaveFile *file)
|
||||
// The earlier versions also don't have this field.
|
||||
if (fmtlen >= 18) {
|
||||
if (!SDL_ReadU16LE(fmtsrc, &format->extsize)) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1663,10 +1664,10 @@ static int WaveReadFormat(WaveFile *file)
|
||||
|
||||
SDL_CloseIO(fmtsrc);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int WaveCheckFormat(WaveFile *file, size_t datalength)
|
||||
static bool WaveCheckFormat(WaveFile *file, size_t datalength)
|
||||
{
|
||||
WaveFormat *format = &file->format;
|
||||
|
||||
@ -1731,24 +1732,24 @@ static int WaveCheckFormat(WaveFile *file, size_t datalength)
|
||||
switch (format->encoding) {
|
||||
case PCM_CODE:
|
||||
case IEEE_FLOAT_CODE:
|
||||
if (PCM_Init(file, datalength) < 0) {
|
||||
return -1;
|
||||
if (!PCM_Init(file, datalength)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case ALAW_CODE:
|
||||
case MULAW_CODE:
|
||||
if (LAW_Init(file, datalength) < 0) {
|
||||
return -1;
|
||||
if (!LAW_Init(file, datalength)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case MS_ADPCM_CODE:
|
||||
if (MS_ADPCM_Init(file, datalength) < 0) {
|
||||
return -1;
|
||||
if (!MS_ADPCM_Init(file, datalength)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case IMA_ADPCM_CODE:
|
||||
if (IMA_ADPCM_Init(file, datalength) < 0) {
|
||||
return -1;
|
||||
if (!IMA_ADPCM_Init(file, datalength)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case MPEG_CODE:
|
||||
@ -1766,10 +1767,10 @@ static int WaveCheckFormat(WaveFile *file, size_t datalength)
|
||||
return SDL_SetError("Unknown WAVE format tag: 0x%04x", (unsigned int)format->encoding);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
static bool WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
int result;
|
||||
Uint32 chunkcount = 0;
|
||||
@ -1965,10 +1966,10 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
return SDL_SetError("Invalid WAVE fmt chunk length (too small)");
|
||||
} else if (chunk->size < 14) {
|
||||
return SDL_SetError("Could not read data of WAVE fmt chunk");
|
||||
} else if (WaveReadFormat(file) < 0) {
|
||||
return -1;
|
||||
} else if (WaveCheckFormat(file, (size_t)datachunk.length) < 0) {
|
||||
return -1;
|
||||
} else if (!WaveReadFormat(file)) {
|
||||
return false;
|
||||
} else if (!WaveCheckFormat(file, (size_t)datachunk.length)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef SDL_WAVE_DEBUG_LOG_FORMAT
|
||||
@ -1986,7 +1987,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
if (chunk->length > 0) {
|
||||
result = WaveReadChunkData(src, chunk);
|
||||
if (result < 0) {
|
||||
return -1;
|
||||
return false;
|
||||
} else if (result == -2) {
|
||||
return SDL_SetError("Could not seek data of WAVE data chunk");
|
||||
}
|
||||
@ -2004,24 +2005,24 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
switch (format->encoding) {
|
||||
case PCM_CODE:
|
||||
case IEEE_FLOAT_CODE:
|
||||
if (PCM_Decode(file, audio_buf, audio_len) < 0) {
|
||||
return -1;
|
||||
if (!PCM_Decode(file, audio_buf, audio_len)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case ALAW_CODE:
|
||||
case MULAW_CODE:
|
||||
if (LAW_Decode(file, audio_buf, audio_len) < 0) {
|
||||
return -1;
|
||||
if (!LAW_Decode(file, audio_buf, audio_len)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case MS_ADPCM_CODE:
|
||||
if (MS_ADPCM_Decode(file, audio_buf, audio_len) < 0) {
|
||||
return -1;
|
||||
if (!MS_ADPCM_Decode(file, audio_buf, audio_len)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case IMA_ADPCM_CODE:
|
||||
if (IMA_ADPCM_Decode(file, audio_buf, audio_len) < 0) {
|
||||
return -1;
|
||||
if (!IMA_ADPCM_Decode(file, audio_buf, audio_len)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -2072,12 +2073,12 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
chunk->position = lastchunkpos;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_LoadWAV_IO(SDL_IOStream *src, SDL_bool closeio, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
SDL_bool SDL_LoadWAV_IO(SDL_IOStream *src, SDL_bool closeio, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
int result = -1;
|
||||
bool result = false;
|
||||
WaveFile file;
|
||||
|
||||
if (spec) {
|
||||
@ -2110,7 +2111,7 @@ int SDL_LoadWAV_IO(SDL_IOStream *src, SDL_bool closeio, SDL_AudioSpec *spec, Uin
|
||||
file.facthint = WaveGetFactChunkHint();
|
||||
|
||||
result = WaveLoad(src, &file, spec, audio_buf, audio_len);
|
||||
if (result < 0) {
|
||||
if (!result) {
|
||||
SDL_free(*audio_buf);
|
||||
audio_buf = NULL;
|
||||
audio_len = 0;
|
||||
@ -2129,7 +2130,7 @@ done:
|
||||
return result;
|
||||
}
|
||||
|
||||
int SDL_LoadWAV(const char *path, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
SDL_bool SDL_LoadWAV(const char *path, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
return SDL_LoadWAV_IO(SDL_IOFromFile(path, "rb"), 1, spec, audio_buf, audio_len);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ typedef struct AAUDIO_Data
|
||||
} AAUDIO_Data;
|
||||
static AAUDIO_Data ctx;
|
||||
|
||||
static int AAUDIO_LoadFunctions(AAUDIO_Data *data)
|
||||
static bool AAUDIO_LoadFunctions(AAUDIO_Data *data)
|
||||
{
|
||||
#define SDL_PROC(ret, func, params) \
|
||||
do { \
|
||||
@ -72,7 +72,7 @@ static int AAUDIO_LoadFunctions(AAUDIO_Data *data)
|
||||
} \
|
||||
} while (0);
|
||||
#include "SDL_aaudiofuncs.h"
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -162,26 +162,21 @@ static Uint8 *AAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *bufsize)
|
||||
return &hidden->mixbuf[offset];
|
||||
}
|
||||
|
||||
static int AAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool AAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
// this semaphore won't fire when the app is in the background (AAUDIO_PauseDevices was called).
|
||||
const int rc = SDL_WaitSemaphoreTimeout(device->hidden->semaphore, 100);
|
||||
if (rc == -1) { // uh, what?
|
||||
return -1;
|
||||
} else if (rc == 0) {
|
||||
return 0; // semaphore was signaled, let's go!
|
||||
} else {
|
||||
SDL_assert(rc == SDL_MUTEX_TIMEDOUT);
|
||||
if (SDL_WaitSemaphoreTimeout(device->hidden->semaphore, 100)) {
|
||||
return true; // semaphore was signaled, let's go!
|
||||
}
|
||||
// Still waiting on the semaphore (or the system), check other things then wait again.
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int BuildAAudioStream(SDL_AudioDevice *device);
|
||||
static bool BuildAAudioStream(SDL_AudioDevice *device);
|
||||
|
||||
static int RecoverAAudioDevice(SDL_AudioDevice *device)
|
||||
static bool RecoverAAudioDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
struct SDL_PrivateAudioData *hidden = device->hidden;
|
||||
|
||||
@ -200,8 +195,8 @@ static int RecoverAAudioDevice(SDL_AudioDevice *device)
|
||||
SDL_AudioSpec prevspec;
|
||||
SDL_copyp(&prevspec, &device->spec);
|
||||
|
||||
if (BuildAAudioStream(device) < 0) {
|
||||
return -1; // oh well, we tried.
|
||||
if (!BuildAAudioStream(device)) {
|
||||
return false; // oh well, we tried.
|
||||
}
|
||||
|
||||
// we don't know the new device spec until we open the new device, so we saved off the old one and force it back
|
||||
@ -212,14 +207,14 @@ static int RecoverAAudioDevice(SDL_AudioDevice *device)
|
||||
|
||||
device->sample_frames = prev_sample_frames;
|
||||
SDL_copyp(&device->spec, &prevspec);
|
||||
if (SDL_AudioDeviceFormatChangedAlreadyLocked(device, &newspec, new_sample_frames) < 0) {
|
||||
return -1; // ugh
|
||||
if (!SDL_AudioDeviceFormatChangedAlreadyLocked(device, &newspec, new_sample_frames)) {
|
||||
return false; // ugh
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static int AAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
static bool AAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
{
|
||||
struct SDL_PrivateAudioData *hidden = device->hidden;
|
||||
|
||||
@ -228,14 +223,14 @@ static int AAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int b
|
||||
if (err) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "aaudio: Audio device triggered error %d (%s)", (int) err, ctx.AAudio_convertResultToText(err));
|
||||
|
||||
if (RecoverAAudioDevice(device) < 0) {
|
||||
return -1; // oh well, we went down hard.
|
||||
if (!RecoverAAudioDevice(device)) {
|
||||
return false; // oh well, we went down hard.
|
||||
}
|
||||
} else {
|
||||
SDL_MemoryBarrierRelease();
|
||||
hidden->processed_bytes += buflen;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int AAUDIO_RecordDevice(SDL_AudioDevice *device, void *buffer, int buflen)
|
||||
@ -279,7 +274,7 @@ static void AAUDIO_CloseDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
static int BuildAAudioStream(SDL_AudioDevice *device)
|
||||
static bool BuildAAudioStream(SDL_AudioDevice *device)
|
||||
{
|
||||
struct SDL_PrivateAudioData *hidden = device->hidden;
|
||||
const bool recording = device->recording;
|
||||
@ -365,7 +360,7 @@ static int BuildAAudioStream(SDL_AudioDevice *device)
|
||||
hidden->mixbuf_bytes = (hidden->num_buffers * device->buffer_size);
|
||||
hidden->mixbuf = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), hidden->mixbuf_bytes);
|
||||
if (!hidden->mixbuf) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
hidden->processed_bytes = 0;
|
||||
hidden->callback_bytes = 0;
|
||||
@ -373,7 +368,7 @@ static int BuildAAudioStream(SDL_AudioDevice *device)
|
||||
hidden->semaphore = SDL_CreateSemaphore(recording ? 0 : hidden->num_buffers);
|
||||
if (!hidden->semaphore) {
|
||||
LOGI("SDL Failed SDL_CreateSemaphore %s recording:%d", SDL_GetError(), recording);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGI("AAudio Actually opened %u hz %u bit chan %u %s samples %u, buffers %d",
|
||||
@ -388,7 +383,7 @@ static int BuildAAudioStream(SDL_AudioDevice *device)
|
||||
|
||||
LOGI("SDL AAudioStream_requestStart OK");
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// !!! FIXME: make this non-blocking!
|
||||
@ -397,7 +392,7 @@ static void SDLCALL RequestAndroidPermissionBlockingCallback(void *userdata, con
|
||||
SDL_AtomicSet((SDL_AtomicInt *) userdata, granted ? 1 : -1);
|
||||
}
|
||||
|
||||
static int AAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool AAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
#if ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES
|
||||
SDL_assert(device->handle); // AAUDIO_UNSPECIFIED is zero, so legit devices should all be non-zero.
|
||||
@ -409,8 +404,8 @@ static int AAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
// !!! FIXME: make this non-blocking!
|
||||
SDL_AtomicInt permission_response;
|
||||
SDL_AtomicSet(&permission_response, 0);
|
||||
if (SDL_RequestAndroidPermission("android.permission.RECORD_AUDIO", RequestAndroidPermissionBlockingCallback, &permission_response) == -1) {
|
||||
return -1;
|
||||
if (!SDL_RequestAndroidPermission("android.permission.RECORD_AUDIO", RequestAndroidPermissionBlockingCallback, &permission_response)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (SDL_AtomicGet(&permission_response) == 0) {
|
||||
@ -425,7 +420,7 @@ static int AAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
|
||||
device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return BuildAAudioStream(device);
|
||||
@ -519,7 +514,7 @@ static bool AAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AAUDIO_LoadFunctions(&ctx) < 0) {
|
||||
if (!AAUDIO_LoadFunctions(&ctx)) {
|
||||
SDL_UnloadObject(ctx.handle);
|
||||
SDL_zero(ctx);
|
||||
return false;
|
||||
|
@ -93,26 +93,26 @@ static int (*ALSA_snd_pcm_chmap_print)(const snd_pcm_chmap_t *map, size_t maxlen
|
||||
static const char *alsa_library = SDL_AUDIO_DRIVER_ALSA_DYNAMIC;
|
||||
static void *alsa_handle = NULL;
|
||||
|
||||
static int load_alsa_sym(const char *fn, void **addr)
|
||||
static bool load_alsa_sym(const char *fn, void **addr)
|
||||
{
|
||||
*addr = SDL_LoadFunction(alsa_handle, fn);
|
||||
if (!*addr) {
|
||||
// Don't call SDL_SetError(): SDL_LoadFunction already did.
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// cast funcs to char* first, to please GCC's strict aliasing rules.
|
||||
#define SDL_ALSA_SYM(x) \
|
||||
if (!load_alsa_sym(#x, (void **)(char *)&ALSA_##x)) \
|
||||
return -1
|
||||
return false
|
||||
#else
|
||||
#define SDL_ALSA_SYM(x) ALSA_##x = x
|
||||
#endif
|
||||
|
||||
static int load_alsa_syms(void)
|
||||
static bool load_alsa_syms(void)
|
||||
{
|
||||
SDL_ALSA_SYM(snd_pcm_open);
|
||||
SDL_ALSA_SYM(snd_pcm_close);
|
||||
@ -156,7 +156,7 @@ static int load_alsa_syms(void)
|
||||
SDL_ALSA_SYM(snd_pcm_chmap_print);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#undef SDL_ALSA_SYM
|
||||
@ -171,17 +171,17 @@ static void UnloadALSALibrary(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int LoadALSALibrary(void)
|
||||
static bool LoadALSALibrary(void)
|
||||
{
|
||||
int retval = 0;
|
||||
bool retval = true;
|
||||
if (!alsa_handle) {
|
||||
alsa_handle = SDL_LoadObject(alsa_library);
|
||||
if (!alsa_handle) {
|
||||
retval = -1;
|
||||
retval = false;
|
||||
// Don't call SDL_SetError(): SDL_LoadObject already did.
|
||||
} else {
|
||||
retval = load_alsa_syms();
|
||||
if (retval < 0) {
|
||||
if (!retval) {
|
||||
UnloadALSALibrary();
|
||||
}
|
||||
}
|
||||
@ -195,10 +195,10 @@ static void UnloadALSALibrary(void)
|
||||
{
|
||||
}
|
||||
|
||||
static int LoadALSALibrary(void)
|
||||
static bool LoadALSALibrary(void)
|
||||
{
|
||||
load_alsa_syms();
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // SDL_AUDIO_DRIVER_ALSA_DYNAMIC
|
||||
@ -260,7 +260,7 @@ static const int swizzle_alsa_channels_8[8] = { 0, 1, 6, 7, 2, 3, 4, 5 };
|
||||
|
||||
|
||||
// This function waits until it is possible to write a full sound buffer
|
||||
static int ALSA_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool ALSA_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
const int fulldelay = (int) ((((Uint64) device->sample_frames) * 1000) / device->spec.freq);
|
||||
const int delay = SDL_max(fulldelay, 10);
|
||||
@ -272,7 +272,7 @@ static int ALSA_WaitDevice(SDL_AudioDevice *device)
|
||||
if (status < 0) {
|
||||
// Hmm, not much we can do - abort
|
||||
SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "ALSA: snd_pcm_wait failed (unrecoverable): %s", ALSA_snd_strerror(rc));
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -284,10 +284,10 @@ static int ALSA_WaitDevice(SDL_AudioDevice *device)
|
||||
// Timed out! Make sure we aren't shutting down and then wait again.
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int ALSA_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
static bool ALSA_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
{
|
||||
SDL_assert(buffer == device->hidden->mixbuf);
|
||||
Uint8 *sample_buf = (Uint8 *) buffer; // !!! FIXME: deal with this without casting away constness
|
||||
@ -304,7 +304,7 @@ static int ALSA_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buf
|
||||
if (status < 0) {
|
||||
// Hmm, not much we can do - abort
|
||||
SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "ALSA write failed (unrecoverable): %s", ALSA_snd_strerror(rc));
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -313,7 +313,7 @@ static int ALSA_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buf
|
||||
frames_left -= rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Uint8 *ALSA_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
@ -434,7 +434,7 @@ static int ALSA_set_buffer_size(SDL_AudioDevice *device, snd_pcm_hw_params_t *pa
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ALSA_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool ALSA_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
const bool recording = device->recording;
|
||||
int status = 0;
|
||||
@ -442,7 +442,7 @@ static int ALSA_OpenDevice(SDL_AudioDevice *device)
|
||||
// Initialize all variables that we clean on shutdown
|
||||
device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Open the audio device
|
||||
@ -559,7 +559,7 @@ static int ALSA_OpenDevice(SDL_AudioDevice *device)
|
||||
if (swizmap) {
|
||||
device->chmap = SDL_ChannelMapDup(swizmap, channels);
|
||||
if (!device->chmap) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -606,7 +606,7 @@ static int ALSA_OpenDevice(SDL_AudioDevice *device)
|
||||
if (!recording) {
|
||||
device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size);
|
||||
if (!device->hidden->mixbuf) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size);
|
||||
}
|
||||
@ -619,7 +619,7 @@ static int ALSA_OpenDevice(SDL_AudioDevice *device)
|
||||
|
||||
ALSA_snd_pcm_start(pcm_handle);
|
||||
|
||||
return 0; // We're ready to rock and roll. :-)
|
||||
return true; // We're ready to rock and roll. :-)
|
||||
}
|
||||
|
||||
static void add_device(const bool recording, const char *name, void *hint, ALSA_Device **pSeen)
|
||||
@ -889,7 +889,7 @@ static void ALSA_Deinitialize(void)
|
||||
|
||||
static bool ALSA_Init(SDL_AudioDriverImpl *impl)
|
||||
{
|
||||
if (LoadALSALibrary() < 0) {
|
||||
if (!LoadALSALibrary()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -548,7 +548,7 @@ static bool UpdateAudioSession(SDL_AudioDevice *device, bool open, bool allow_pl
|
||||
#endif
|
||||
|
||||
|
||||
static int COREAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
|
||||
static bool COREAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
|
||||
{
|
||||
AudioQueueBufferRef current_buffer = device->hidden->current_buffer;
|
||||
SDL_assert(current_buffer != NULL); // should have been called from PlaybackBufferReadyCallback
|
||||
@ -556,7 +556,7 @@ static int COREAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, in
|
||||
current_buffer->mAudioDataByteSize = current_buffer->mAudioDataBytesCapacity;
|
||||
device->hidden->current_buffer = NULL;
|
||||
AudioQueueEnqueueBuffer(device->hidden->audioQueue, current_buffer, 0, NULL);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Uint8 *COREAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
@ -660,7 +660,7 @@ static void COREAUDIO_CloseDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
|
||||
#ifdef MACOSX_COREAUDIO
|
||||
static int PrepareDevice(SDL_AudioDevice *device)
|
||||
static bool PrepareDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
SDL_assert(device->handle != NULL); // this meant "system default" in SDL2, but doesn't anymore
|
||||
|
||||
@ -696,10 +696,10 @@ static int PrepareDevice(SDL_AudioDevice *device)
|
||||
|
||||
device->hidden->deviceID = devid;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int AssignDeviceToAudioQueue(SDL_AudioDevice *device)
|
||||
static bool AssignDeviceToAudioQueue(SDL_AudioDevice *device)
|
||||
{
|
||||
const AudioObjectPropertyAddress prop = {
|
||||
kAudioDevicePropertyDeviceUID,
|
||||
@ -715,11 +715,11 @@ static int AssignDeviceToAudioQueue(SDL_AudioDevice *device)
|
||||
result = AudioQueueSetProperty(device->hidden->audioQueue, kAudioQueueProperty_CurrentDevice, &devuid, devuidsize);
|
||||
CFRelease(devuid); // Release devuid; we're done with it and AudioQueueSetProperty should have retained if it wants to keep it.
|
||||
CHECK_RESULT("AudioQueueSetProperty (kAudioQueueProperty_CurrentDevice)");
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int PrepareAudioQueue(SDL_AudioDevice *device)
|
||||
static bool PrepareAudioQueue(SDL_AudioDevice *device)
|
||||
{
|
||||
const AudioStreamBasicDescription *strdesc = &device->hidden->strdesc;
|
||||
const bool recording = device->recording;
|
||||
@ -736,8 +736,8 @@ static int PrepareAudioQueue(SDL_AudioDevice *device)
|
||||
}
|
||||
|
||||
#ifdef MACOSX_COREAUDIO
|
||||
if (AssignDeviceToAudioQueue(device) < 0) {
|
||||
return -1;
|
||||
if (!AssignDeviceToAudioQueue(device)) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -796,7 +796,7 @@ static int PrepareAudioQueue(SDL_AudioDevice *device)
|
||||
device->hidden->numAudioBuffers = numAudioBuffers;
|
||||
device->hidden->audioBuffer = SDL_calloc(numAudioBuffers, sizeof(AudioQueueBufferRef));
|
||||
if (device->hidden->audioBuffer == NULL) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
#if DEBUG_COREAUDIO
|
||||
@ -816,7 +816,7 @@ static int PrepareAudioQueue(SDL_AudioDevice *device)
|
||||
result = AudioQueueStart(device->hidden->audioQueue, NULL);
|
||||
CHECK_RESULT("AudioQueueStart");
|
||||
|
||||
return 0; // We're running!
|
||||
return true; // We're running!
|
||||
}
|
||||
|
||||
static int AudioQueueThreadEntry(void *arg)
|
||||
@ -829,7 +829,7 @@ static int AudioQueueThreadEntry(void *arg)
|
||||
SDL_PlaybackAudioThreadSetup(device);
|
||||
}
|
||||
|
||||
if (PrepareAudioQueue(device) < 0) {
|
||||
if (!PrepareAudioQueue(device)) {
|
||||
device->hidden->thread_error = SDL_strdup(SDL_GetError());
|
||||
SDL_SignalSemaphore(device->hidden->ready_semaphore);
|
||||
return 0;
|
||||
@ -855,17 +855,17 @@ static int AudioQueueThreadEntry(void *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int COREAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool COREAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
// Initialize all variables that we clean on shutdown
|
||||
device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (device->hidden == NULL) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef MACOSX_COREAUDIO
|
||||
if (!UpdateAudioSession(device, true, true)) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Stop CoreAudio from doing expensive audio rate conversion
|
||||
@ -935,22 +935,22 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
strdesc->mBytesPerPacket = strdesc->mBytesPerFrame * strdesc->mFramesPerPacket;
|
||||
|
||||
#ifdef MACOSX_COREAUDIO
|
||||
if (PrepareDevice(device) < 0) {
|
||||
return -1;
|
||||
if (!PrepareDevice(device)) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// This has to init in a new thread so it can get its own CFRunLoop. :/
|
||||
device->hidden->ready_semaphore = SDL_CreateSemaphore(0);
|
||||
if (!device->hidden->ready_semaphore) {
|
||||
return -1; // oh well.
|
||||
return false; // oh well.
|
||||
}
|
||||
|
||||
char threadname[64];
|
||||
SDL_GetAudioThreadName(device, threadname, sizeof(threadname));
|
||||
device->hidden->thread = SDL_CreateThread(AudioQueueThreadEntry, threadname, device);
|
||||
if (!device->hidden->thread) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_WaitSemaphore(device->hidden->ready_semaphore);
|
||||
@ -963,7 +963,7 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
return SDL_SetError("%s", device->hidden->thread_error);
|
||||
}
|
||||
|
||||
return (device->hidden->thread != NULL) ? 0 : -1;
|
||||
return (device->hidden->thread != NULL);
|
||||
}
|
||||
|
||||
static void COREAUDIO_DeinitializeStart(void)
|
||||
|
@ -72,9 +72,9 @@ static void DSOUND_Unload(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int DSOUND_Load(void)
|
||||
static bool DSOUND_Load(void)
|
||||
{
|
||||
int loaded = 0;
|
||||
bool loaded = false;
|
||||
|
||||
DSOUND_Unload();
|
||||
|
||||
@ -87,9 +87,9 @@ static int DSOUND_Load(void)
|
||||
{ \
|
||||
p##f = (fn##f)SDL_LoadFunction(DSoundDLL, #f); \
|
||||
if (!p##f) \
|
||||
loaded = 0; \
|
||||
loaded = false; \
|
||||
}
|
||||
loaded = 1; // will reset if necessary.
|
||||
loaded = true; // will reset if necessary.
|
||||
DSOUNDLOAD(DirectSoundCreate8);
|
||||
DSOUNDLOAD(DirectSoundEnumerateW);
|
||||
DSOUNDLOAD(DirectSoundCaptureCreate8);
|
||||
@ -109,7 +109,7 @@ static int DSOUND_Load(void)
|
||||
return loaded;
|
||||
}
|
||||
|
||||
static int SetDSerror(const char *function, int code)
|
||||
static bool SetDSerror(const char *function, int code)
|
||||
{
|
||||
const char *error;
|
||||
|
||||
@ -229,7 +229,7 @@ static void DSOUND_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDe
|
||||
|
||||
}
|
||||
|
||||
static int DSOUND_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool DSOUND_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
/* Semi-busy wait, since we have no way of getting play notification
|
||||
on a primary mixing buffer located in hardware (DirectX 5.0)
|
||||
@ -255,23 +255,23 @@ static int DSOUND_WaitDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
|
||||
if ((result != DS_OK) && (result != DSERR_BUFFERLOST)) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_Delay(1); // not ready yet; sleep a bit.
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int DSOUND_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
static bool DSOUND_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
{
|
||||
// Unlock the buffer, allowing it to play
|
||||
SDL_assert(buflen == device->buffer_size);
|
||||
if (IDirectSoundBuffer_Unlock(device->hidden->mixbuf, (LPVOID) buffer, buflen, NULL, 0) != DS_OK) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Uint8 *DSOUND_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
@ -333,20 +333,20 @@ static Uint8 *DSOUND_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
return device->hidden->locked_buf;
|
||||
}
|
||||
|
||||
static int DSOUND_WaitRecordingDevice(SDL_AudioDevice *device)
|
||||
static bool DSOUND_WaitRecordingDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
struct SDL_PrivateAudioData *h = device->hidden;
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
DWORD junk, cursor;
|
||||
if (IDirectSoundCaptureBuffer_GetCurrentPosition(h->capturebuf, &junk, &cursor) != DS_OK) {
|
||||
return -1;
|
||||
return false;
|
||||
} else if ((cursor / device->buffer_size) != h->lastchunk) {
|
||||
break;
|
||||
}
|
||||
SDL_Delay(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int DSOUND_RecordDevice(SDL_AudioDevice *device, void *buffer, int buflen)
|
||||
@ -411,7 +411,7 @@ static void DSOUND_CloseDevice(SDL_AudioDevice *device)
|
||||
number of audio chunks available in the created buffer. This is for
|
||||
playback devices, not recording.
|
||||
*/
|
||||
static int CreateSecondary(SDL_AudioDevice *device, const DWORD bufsize, WAVEFORMATEX *wfmt)
|
||||
static bool CreateSecondary(SDL_AudioDevice *device, const DWORD bufsize, WAVEFORMATEX *wfmt)
|
||||
{
|
||||
LPDIRECTSOUND sndObj = device->hidden->sound;
|
||||
LPDIRECTSOUNDBUFFER *sndbuf = &device->hidden->mixbuf;
|
||||
@ -445,14 +445,14 @@ static int CreateSecondary(SDL_AudioDevice *device, const DWORD bufsize, WAVEFOR
|
||||
(LPVOID)pvAudioPtr2, dwAudioBytes2);
|
||||
}
|
||||
|
||||
return 0; // We're ready to go
|
||||
return true; // We're ready to go
|
||||
}
|
||||
|
||||
/* This function tries to create a capture buffer, and returns the
|
||||
number of audio chunks available in the created buffer. This is for
|
||||
recording devices, not playback.
|
||||
*/
|
||||
static int CreateCaptureBuffer(SDL_AudioDevice *device, const DWORD bufsize, WAVEFORMATEX *wfmt)
|
||||
static bool CreateCaptureBuffer(SDL_AudioDevice *device, const DWORD bufsize, WAVEFORMATEX *wfmt)
|
||||
{
|
||||
LPDIRECTSOUNDCAPTURE capture = device->hidden->capture;
|
||||
LPDIRECTSOUNDCAPTUREBUFFER *capturebuf = &device->hidden->capturebuf;
|
||||
@ -488,15 +488,15 @@ static int CreateCaptureBuffer(SDL_AudioDevice *device, const DWORD bufsize, WAV
|
||||
device->hidden->lastchunk = cursor / device->buffer_size;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int DSOUND_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool DSOUND_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
// Initialize all variables that we clean on shutdown
|
||||
device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Open the audio device
|
||||
@ -603,8 +603,8 @@ static int DSOUND_OpenDevice(SDL_AudioDevice *device)
|
||||
wfmt.Format.nBlockAlign = wfmt.Format.nChannels * (wfmt.Format.wBitsPerSample / 8);
|
||||
wfmt.Format.nAvgBytesPerSec = wfmt.Format.nSamplesPerSec * wfmt.Format.nBlockAlign;
|
||||
|
||||
const int rc = device->recording ? CreateCaptureBuffer(device, bufsize, (WAVEFORMATEX *)&wfmt) : CreateSecondary(device, bufsize, (WAVEFORMATEX *)&wfmt);
|
||||
if (rc == 0) {
|
||||
const bool rc = device->recording ? CreateCaptureBuffer(device, bufsize, (WAVEFORMATEX *)&wfmt) : CreateSecondary(device, bufsize, (WAVEFORMATEX *)&wfmt);
|
||||
if (rc) {
|
||||
device->hidden->num_buffers = numchunks;
|
||||
break;
|
||||
}
|
||||
@ -618,14 +618,14 @@ static int DSOUND_OpenDevice(SDL_AudioDevice *device)
|
||||
|
||||
if (!test_format) {
|
||||
if (tried_format) {
|
||||
return -1; // CreateSecondary() should have called SDL_SetError().
|
||||
return false; // CreateSecondary() should have called SDL_SetError().
|
||||
}
|
||||
return SDL_SetError("%s: Unsupported audio format", "directsound");
|
||||
}
|
||||
|
||||
// Playback buffers will auto-start playing in DSOUND_WaitDevice()
|
||||
|
||||
return 0; // good to go.
|
||||
return true; // good to go.
|
||||
}
|
||||
|
||||
static void DSOUND_DeinitializeStart(void)
|
||||
@ -652,7 +652,7 @@ static bool DSOUND_Init(SDL_AudioDriverImpl *impl)
|
||||
}
|
||||
|
||||
#ifdef HAVE_MMDEVICEAPI_H
|
||||
SupportsIMMDevice = !(SDL_IMMDevice_Init(NULL) < 0);
|
||||
SupportsIMMDevice = SDL_IMMDevice_Init(NULL);
|
||||
#endif
|
||||
|
||||
impl->DetectDevices = DSOUND_DetectDevices;
|
||||
|
@ -30,22 +30,22 @@
|
||||
#define DISKDEFAULT_OUTFILE "sdlaudio.raw"
|
||||
#define DISKDEFAULT_INFILE "sdlaudio-in.raw"
|
||||
|
||||
static int DISKAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool DISKAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
SDL_Delay(device->hidden->io_delay);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int DISKAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
|
||||
static bool DISKAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
|
||||
{
|
||||
const int written = (int)SDL_WriteIO(device->hidden->io, buffer, (size_t)buffer_size);
|
||||
if (written != buffer_size) { // If we couldn't write, assume fatal error for now
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG_AUDIO
|
||||
SDL_Log("DISKAUDIO: Wrote %d bytes of audio data", (int) written);
|
||||
#endif
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Uint8 *DISKAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
@ -100,14 +100,14 @@ static const char *get_filename(const bool recording)
|
||||
return devname;
|
||||
}
|
||||
|
||||
static int DISKAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool DISKAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
bool recording = device->recording;
|
||||
const char *fname = get_filename(recording);
|
||||
|
||||
device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
device->hidden->io_delay = ((device->sample_frames * 1000) / device->spec.freq);
|
||||
@ -123,14 +123,14 @@ static int DISKAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
// Open the "audio device"
|
||||
device->hidden->io = SDL_IOFromFile(fname, recording ? "rb" : "wb");
|
||||
if (!device->hidden->io) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Allocate mixing buffer
|
||||
if (!recording) {
|
||||
device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size);
|
||||
if (!device->hidden->mixbuf) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size);
|
||||
}
|
||||
@ -138,7 +138,7 @@ static int DISKAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_AUDIO, "You are using the SDL disk i/o audio driver!");
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_AUDIO, " %s file [%s].\n", recording ? "Reading from" : "Writing to", fname);
|
||||
|
||||
return 0; // We're ready to rock and roll. :-)
|
||||
return true; // We're ready to rock and roll. :-)
|
||||
}
|
||||
|
||||
static void DISKAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
||||
|
@ -55,7 +55,7 @@ static void DSP_CloseDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
static int DSP_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool DSP_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
// Make sure fragment size stays a power of 2, or OSS fails.
|
||||
// (I don't know which of these are actually legal values, though...)
|
||||
@ -70,7 +70,7 @@ static int DSP_OpenDevice(SDL_AudioDevice *device)
|
||||
// Initialize all variables that we clean on shutdown
|
||||
device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Open the audio device; we hardcode the device path in `device->name` for lack of better info, so use that.
|
||||
@ -191,15 +191,15 @@ static int DSP_OpenDevice(SDL_AudioDevice *device)
|
||||
if (!device->recording) {
|
||||
device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size);
|
||||
if (!device->hidden->mixbuf) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size);
|
||||
}
|
||||
|
||||
return 0; // We're ready to rock and roll. :-)
|
||||
return true; // We're ready to rock and roll. :-)
|
||||
}
|
||||
|
||||
static int DSP_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool DSP_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
const unsigned long ioctlreq = device->recording ? SNDCTL_DSP_GETISPACE : SNDCTL_DSP_GETOSPACE;
|
||||
struct SDL_PrivateAudioData *h = device->hidden;
|
||||
@ -213,7 +213,7 @@ static int DSP_WaitDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
// Hmm, not much we can do - abort
|
||||
fprintf(stderr, "dsp WaitDevice ioctl failed (unrecoverable): %s\n", strerror(errno));
|
||||
return -1;
|
||||
return false;
|
||||
} else if (info.bytes < device->buffer_size) {
|
||||
SDL_Delay(10);
|
||||
} else {
|
||||
@ -221,20 +221,20 @@ static int DSP_WaitDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int DSP_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
static bool DSP_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
{
|
||||
struct SDL_PrivateAudioData *h = device->hidden;
|
||||
if (write(h->audio_fd, buffer, buflen) == -1) {
|
||||
perror("Audio write");
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Wrote %d bytes of audio data\n", h->mixlen);
|
||||
#endif
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Uint8 *DSP_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
|
@ -29,23 +29,23 @@
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
static int DUMMYAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool DUMMYAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
SDL_Delay(device->hidden->io_delay);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int DUMMYAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool DUMMYAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!device->recording) {
|
||||
device->hidden->mixbuf = (Uint8 *) SDL_malloc(device->buffer_size);
|
||||
if (!device->hidden->mixbuf) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ static int DUMMYAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
}, device->recording ? 1 : 0, device->sample_frames, device->spec.freq, device->recording ? SDL_RecordingAudioThreadIterate : SDL_PlaybackAudioThreadIterate, device);
|
||||
#endif
|
||||
|
||||
return 0; // we're good; don't change reported device format.
|
||||
return true; // we're good; don't change reported device format.
|
||||
}
|
||||
|
||||
static void DUMMYAUDIO_CloseDevice(SDL_AudioDevice *device)
|
||||
|
@ -36,7 +36,7 @@ static Uint8 *EMSCRIPTENAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_
|
||||
return device->hidden->mixbuf;
|
||||
}
|
||||
|
||||
static int EMSCRIPTENAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
|
||||
static bool EMSCRIPTENAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
|
||||
{
|
||||
const int framelen = SDL_AUDIO_FRAMESIZE(device->spec);
|
||||
MAIN_THREAD_EM_ASM({
|
||||
@ -53,7 +53,7 @@ static int EMSCRIPTENAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buff
|
||||
}
|
||||
}
|
||||
}, buffer, buffer_size / framelen);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -138,12 +138,12 @@ static void EMSCRIPTENAUDIO_CloseDevice(SDL_AudioDevice *device)
|
||||
|
||||
EM_JS_DEPS(sdlaudio, "$autoResumeAudioContext,$dynCall");
|
||||
|
||||
static int EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
// based on parts of library_sdl.js
|
||||
|
||||
// create context
|
||||
const int result = MAIN_THREAD_EM_ASM_INT({
|
||||
const bool result = MAIN_THREAD_EM_ASM_INT({
|
||||
if (typeof(Module['SDL3']) === 'undefined') {
|
||||
Module['SDL3'] = {};
|
||||
}
|
||||
@ -166,10 +166,10 @@ static int EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
}
|
||||
}
|
||||
return SDL3.audioContext === undefined ? -1 : 0;
|
||||
return (SDL3.audioContext !== undefined);
|
||||
}, device->recording);
|
||||
|
||||
if (result < 0) {
|
||||
if (!result) {
|
||||
return SDL_SetError("Web Audio API is not available!");
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
// Initialize all variables that we clean on shutdown
|
||||
device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// limit to native freq
|
||||
@ -189,7 +189,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
if (!device->recording) {
|
||||
device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size);
|
||||
if (!device->hidden->mixbuf) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size);
|
||||
}
|
||||
@ -294,7 +294,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
}, device->spec.channels, device->sample_frames, SDL_PlaybackAudioThreadIterate, device);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||
|
@ -45,14 +45,14 @@ static Uint8 *HAIKUAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
return device->hidden->current_buffer;
|
||||
}
|
||||
|
||||
static int HAIKUAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
|
||||
static bool HAIKUAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
|
||||
{
|
||||
// We already wrote our output right into the BSoundPlayer's callback's stream. Just clean up our stuff.
|
||||
SDL_assert(device->hidden->current_buffer != NULL);
|
||||
SDL_assert(device->hidden->current_buffer_len > 0);
|
||||
device->hidden->current_buffer = NULL;
|
||||
device->hidden->current_buffer_len = 0;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// The Haiku callback for handling the audio buffer
|
||||
@ -102,12 +102,12 @@ static inline void UnmaskSignals(sigset_t * omask)
|
||||
}
|
||||
|
||||
|
||||
static int HAIKUAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool HAIKUAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
// Initialize all variables that we clean on shutdown
|
||||
device->hidden = new SDL_PrivateAudioData;
|
||||
if (device->hidden == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
if (!device->hidden) {
|
||||
return false;
|
||||
}
|
||||
SDL_zerop(device->hidden);
|
||||
|
||||
@ -186,7 +186,7 @@ static int HAIKUAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
return SDL_SetError("Unable to start Haiku audio");
|
||||
}
|
||||
|
||||
return 0; // We're running!
|
||||
return true; // We're running!
|
||||
}
|
||||
|
||||
static void HAIKUAUDIO_Deinitialize(void)
|
||||
@ -196,7 +196,7 @@ static void HAIKUAUDIO_Deinitialize(void)
|
||||
|
||||
static bool HAIKUAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||
{
|
||||
if (SDL_InitBeApp() < 0) {
|
||||
if (!SDL_InitBeApp()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ static int (*JACK_jack_set_process_callback)(jack_client_t *, JackProcessCallbac
|
||||
static int (*JACK_jack_set_sample_rate_callback)(jack_client_t *, JackSampleRateCallback, void *);
|
||||
static int (*JACK_jack_set_buffer_size_callback)(jack_client_t *, JackBufferSizeCallback, void *);
|
||||
|
||||
static int load_jack_syms(void);
|
||||
static bool load_jack_syms(void);
|
||||
|
||||
#ifdef SDL_AUDIO_DRIVER_JACK_DYNAMIC
|
||||
|
||||
@ -54,21 +54,21 @@ static const char *jack_library = SDL_AUDIO_DRIVER_JACK_DYNAMIC;
|
||||
static void *jack_handle = NULL;
|
||||
|
||||
// !!! FIXME: this is copy/pasted in several places now
|
||||
static int load_jack_sym(const char *fn, void **addr)
|
||||
static bool load_jack_sym(const char *fn, void **addr)
|
||||
{
|
||||
*addr = SDL_LoadFunction(jack_handle, fn);
|
||||
if (!*addr) {
|
||||
// Don't call SDL_SetError(): SDL_LoadFunction already did.
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// cast funcs to char* first, to please GCC's strict aliasing rules.
|
||||
#define SDL_JACK_SYM(x) \
|
||||
if (!load_jack_sym(#x, (void **)(char *)&JACK_##x)) \
|
||||
return -1
|
||||
return false
|
||||
|
||||
static void UnloadJackLibrary(void)
|
||||
{
|
||||
@ -78,22 +78,22 @@ static void UnloadJackLibrary(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int LoadJackLibrary(void)
|
||||
static bool LoadJackLibrary(void)
|
||||
{
|
||||
int retval = 0;
|
||||
bool result = true;
|
||||
if (!jack_handle) {
|
||||
jack_handle = SDL_LoadObject(jack_library);
|
||||
if (!jack_handle) {
|
||||
retval = -1;
|
||||
result = false;
|
||||
// Don't call SDL_SetError(): SDL_LoadObject already did.
|
||||
} else {
|
||||
retval = load_jack_syms();
|
||||
if (retval < 0) {
|
||||
result = load_jack_syms();
|
||||
if (!result) {
|
||||
UnloadJackLibrary();
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
#else
|
||||
@ -104,15 +104,15 @@ static void UnloadJackLibrary(void)
|
||||
{
|
||||
}
|
||||
|
||||
static int LoadJackLibrary(void)
|
||||
static bool LoadJackLibrary(void)
|
||||
{
|
||||
load_jack_syms();
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // SDL_AUDIO_DRIVER_JACK_DYNAMIC
|
||||
|
||||
static int load_jack_syms(void)
|
||||
static bool load_jack_syms(void)
|
||||
{
|
||||
SDL_JACK_SYM(jack_client_open);
|
||||
SDL_JACK_SYM(jack_client_close);
|
||||
@ -134,7 +134,7 @@ static int load_jack_syms(void)
|
||||
SDL_JACK_SYM(jack_set_sample_rate_callback);
|
||||
SDL_JACK_SYM(jack_set_buffer_size_callback);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void jackShutdownCallback(void *arg) // JACK went away; device is lost.
|
||||
@ -149,7 +149,7 @@ static int jackSampleRateCallback(jack_nframes_t nframes, void *arg)
|
||||
SDL_AudioSpec newspec;
|
||||
SDL_copyp(&newspec, &device->spec);
|
||||
newspec.freq = (int) nframes;
|
||||
if (SDL_AudioDeviceFormatChanged(device, &newspec, device->sample_frames) < 0) {
|
||||
if (!SDL_AudioDeviceFormatChanged(device, &newspec, device->sample_frames)) {
|
||||
SDL_AudioDeviceDisconnected(device);
|
||||
}
|
||||
return 0;
|
||||
@ -161,7 +161,7 @@ static int jackBufferSizeCallback(jack_nframes_t nframes, void *arg)
|
||||
SDL_AudioDevice *device = (SDL_AudioDevice *) arg;
|
||||
SDL_AudioSpec newspec;
|
||||
SDL_copyp(&newspec, &device->spec);
|
||||
if (SDL_AudioDeviceFormatChanged(device, &newspec, (int) nframes) < 0) {
|
||||
if (!SDL_AudioDeviceFormatChanged(device, &newspec, (int) nframes)) {
|
||||
SDL_AudioDeviceDisconnected(device);
|
||||
}
|
||||
return 0;
|
||||
@ -174,7 +174,7 @@ static int jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int JACK_PlayDevice(SDL_AudioDevice *device, const Uint8 *ui8buffer, int buflen)
|
||||
static bool JACK_PlayDevice(SDL_AudioDevice *device, const Uint8 *ui8buffer, int buflen)
|
||||
{
|
||||
const float *buffer = (float *) ui8buffer;
|
||||
jack_port_t **ports = device->hidden->sdlports;
|
||||
@ -193,7 +193,7 @@ static int JACK_PlayDevice(SDL_AudioDevice *device, const Uint8 *ui8buffer, int
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Uint8 *JACK_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
@ -267,7 +267,7 @@ static const char *GetJackAppName(void)
|
||||
return SDL_GetAppMetadataProperty(SDL_PROP_APP_METADATA_NAME_STRING);
|
||||
}
|
||||
|
||||
static int JACK_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool JACK_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
/* Note that JACK uses "output" for recording devices (they output audio
|
||||
data to us) and "input" for playback (we input audio data to them).
|
||||
@ -289,7 +289,7 @@ static int JACK_OpenDevice(SDL_AudioDevice *device)
|
||||
// Initialize all variables that we clean on shutdown
|
||||
device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
client = JACK_jack_client_open(GetJackAppName(), JackNoStartServer, &status, NULL);
|
||||
@ -335,7 +335,7 @@ static int JACK_OpenDevice(SDL_AudioDevice *device)
|
||||
device->hidden->iobuffer = (float *)SDL_calloc(1, device->buffer_size);
|
||||
if (!device->hidden->iobuffer) {
|
||||
SDL_free(audio_ports);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,7 +343,7 @@ static int JACK_OpenDevice(SDL_AudioDevice *device)
|
||||
device->hidden->sdlports = (jack_port_t **)SDL_calloc(channels, sizeof(jack_port_t *));
|
||||
if (!device->hidden->sdlports) {
|
||||
SDL_free(audio_ports);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < channels; i++) {
|
||||
@ -390,7 +390,7 @@ static int JACK_OpenDevice(SDL_AudioDevice *device)
|
||||
SDL_free(audio_ports);
|
||||
|
||||
// We're ready to rock and roll. :-)
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void JACK_Deinitialize(void)
|
||||
@ -400,7 +400,7 @@ static void JACK_Deinitialize(void)
|
||||
|
||||
static bool JACK_Init(SDL_AudioDriverImpl *impl)
|
||||
{
|
||||
if (LoadJackLibrary() < 0) {
|
||||
if (!LoadJackLibrary()) {
|
||||
return false;
|
||||
} else {
|
||||
// Make sure a JACK server is running and available.
|
||||
@ -408,8 +408,7 @@ static bool JACK_Init(SDL_AudioDriverImpl *impl)
|
||||
jack_client_t *client = JACK_jack_client_open("SDL", JackNoStartServer, &status, NULL);
|
||||
if (!client) {
|
||||
UnloadJackLibrary();
|
||||
SDL_SetError("Can't open JACK client");
|
||||
return false;
|
||||
return SDL_SetError("Can't open JACK client");
|
||||
}
|
||||
JACK_jack_client_close(client);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ static void AudioFrameFinished(void *vdevice)
|
||||
contextUnlock(device);
|
||||
}
|
||||
|
||||
static int N3DSAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool N3DSAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
Result ndsp_init_res;
|
||||
Uint8 *data_vaddr;
|
||||
@ -84,18 +84,17 @@ static int N3DSAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
|
||||
device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialise the DSP service
|
||||
ndsp_init_res = ndspInit();
|
||||
if (R_FAILED(ndsp_init_res)) {
|
||||
if ((R_SUMMARY(ndsp_init_res) == RS_NOTFOUND) && (R_MODULE(ndsp_init_res) == RM_DSP)) {
|
||||
SDL_SetError("DSP init failed: dspfirm.cdc missing!");
|
||||
return SDL_SetError("DSP init failed: dspfirm.cdc missing!");
|
||||
} else {
|
||||
SDL_SetError("DSP init failed. Error code: 0x%lX", ndsp_init_res);
|
||||
return SDL_SetError("DSP init failed. Error code: 0x%lX", ndsp_init_res);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Initialise internal state
|
||||
@ -135,7 +134,7 @@ static int N3DSAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
|
||||
device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size);
|
||||
if (!device->hidden->mixbuf) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size);
|
||||
@ -174,10 +173,10 @@ static int N3DSAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
ndspSetCallback(AudioFrameFinished, device);
|
||||
dspHook(&dsp_hook, N3DSAUD_DspHook);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int N3DSAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
static bool N3DSAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
{
|
||||
contextLock(device);
|
||||
|
||||
@ -186,7 +185,7 @@ static int N3DSAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, in
|
||||
if (device->hidden->isCancelled ||
|
||||
device->hidden->waveBuf[nextbuf].status != NDSP_WBUF_FREE) {
|
||||
contextUnlock(device);
|
||||
return 0; // !!! FIXME: is this a fatal error? If so, this should return -1.
|
||||
return true; // !!! FIXME: is this a fatal error? If so, this should return false.
|
||||
}
|
||||
|
||||
device->hidden->nextbuf = (nextbuf + 1) % NUM_BUFFERS;
|
||||
@ -198,10 +197,10 @@ static int N3DSAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, in
|
||||
|
||||
ndspChnWaveBufAdd(0, &device->hidden->waveBuf[nextbuf]);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int N3DSAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool N3DSAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
contextLock(device);
|
||||
while (!device->hidden->isCancelled && !SDL_AtomicGet(&device->shutdown) &&
|
||||
@ -209,7 +208,7 @@ static int N3DSAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
CondVar_Wait(&device->hidden->cv, &device->hidden->lock);
|
||||
}
|
||||
contextUnlock(device);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Uint8 *N3DSAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
|
@ -114,7 +114,7 @@ static void NETBSDAUDIO_Status(SDL_AudioDevice *device)
|
||||
#endif // DEBUG_AUDIO
|
||||
}
|
||||
|
||||
static int NETBSDAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool NETBSDAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
const bool recording = device->recording;
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
@ -126,7 +126,7 @@ static int NETBSDAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
// Hmm, not much we can do - abort
|
||||
fprintf(stderr, "netbsdaudio WaitDevice ioctl failed (unrecoverable): %s\n", strerror(errno));
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
const size_t remain = (size_t)((recording ? info.record.seek : info.play.seek) * SDL_AUDIO_BYTESIZE(device->spec.format));
|
||||
if (!recording && (remain >= device->buffer_size)) {
|
||||
@ -138,21 +138,21 @@ static int NETBSDAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int NETBSDAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
static bool NETBSDAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
{
|
||||
struct SDL_PrivateAudioData *h = device->hidden;
|
||||
const int written = write(h->audio_fd, buffer, buflen);
|
||||
if (written != buflen) { // Treat even partial writes as fatal errors.
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Wrote %d bytes of audio data\n", written);
|
||||
#endif
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Uint8 *NETBSDAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
@ -206,7 +206,7 @@ static void NETBSDAUDIO_CloseDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
static int NETBSDAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool NETBSDAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
const bool recording = device->recording;
|
||||
int encoding = AUDIO_ENCODING_NONE;
|
||||
@ -216,7 +216,7 @@ static int NETBSDAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
// Initialize all variables that we clean on shutdown
|
||||
device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Open the audio device; we hardcode the device path in `device->name` for lack of better info, so use that.
|
||||
@ -294,14 +294,14 @@ static int NETBSDAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
device->hidden->mixlen = device->buffer_size;
|
||||
device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->hidden->mixlen);
|
||||
if (!device->hidden->mixbuf) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size);
|
||||
}
|
||||
|
||||
NETBSDAUDIO_Status(device);
|
||||
|
||||
return 0; // We're ready to rock and roll. :-)
|
||||
return true; // We're ready to rock and roll. :-)
|
||||
}
|
||||
|
||||
static bool NETBSDAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||
|
@ -135,7 +135,7 @@ static void OPENSLES_DestroyEngine(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int OPENSLES_CreateEngine(void)
|
||||
static bool OPENSLES_CreateEngine(void)
|
||||
{
|
||||
const SLInterfaceID ids[1] = { SL_IID_VOLUME };
|
||||
const SLboolean req[1] = { SL_BOOLEAN_FALSE };
|
||||
@ -181,11 +181,11 @@ static int OPENSLES_CreateEngine(void)
|
||||
LOGE("RealizeOutputMix failed: %d", result);
|
||||
goto error;
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
error:
|
||||
OPENSLES_DestroyEngine();
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// this callback handler is called every time a buffer finishes recording
|
||||
@ -234,7 +234,7 @@ static void SDLCALL RequestAndroidPermissionBlockingCallback(void *userdata, con
|
||||
SDL_AtomicSet((SDL_AtomicInt *) userdata, granted ? 1 : -1);
|
||||
}
|
||||
|
||||
static int OPENSLES_CreatePCMRecorder(SDL_AudioDevice *device)
|
||||
static bool OPENSLES_CreatePCMRecorder(SDL_AudioDevice *device)
|
||||
{
|
||||
struct SDL_PrivateAudioData *audiodata = device->hidden;
|
||||
SLDataFormat_PCM format_pcm;
|
||||
@ -251,8 +251,8 @@ static int OPENSLES_CreatePCMRecorder(SDL_AudioDevice *device)
|
||||
{
|
||||
SDL_AtomicInt permission_response;
|
||||
SDL_AtomicSet(&permission_response, 0);
|
||||
if (SDL_RequestAndroidPermission("android.permission.RECORD_AUDIO", RequestAndroidPermissionBlockingCallback, &permission_response) == -1) {
|
||||
return -1;
|
||||
if (!SDL_RequestAndroidPermission("android.permission.RECORD_AUDIO", RequestAndroidPermissionBlockingCallback, &permission_response)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (SDL_AtomicGet(&permission_response) == 0) {
|
||||
@ -378,7 +378,7 @@ static int OPENSLES_CreatePCMRecorder(SDL_AudioDevice *device)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
|
||||
failed:
|
||||
return SDL_SetError("Open device failed!");
|
||||
@ -424,7 +424,7 @@ static void OPENSLES_DestroyPCMPlayer(SDL_AudioDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
static int OPENSLES_CreatePCMPlayer(SDL_AudioDevice *device)
|
||||
static bool OPENSLES_CreatePCMPlayer(SDL_AudioDevice *device)
|
||||
{
|
||||
/* If we want to add floating point audio support (requires API level 21)
|
||||
it can be done as described here:
|
||||
@ -609,27 +609,27 @@ static int OPENSLES_CreatePCMPlayer(SDL_AudioDevice *device)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
|
||||
failed:
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int OPENSLES_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool OPENSLES_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (device->recording) {
|
||||
LOGI("OPENSLES_OpenDevice() for recording");
|
||||
return OPENSLES_CreatePCMRecorder(device);
|
||||
} else {
|
||||
int ret;
|
||||
bool ret;
|
||||
LOGI("OPENSLES_OpenDevice() for playback");
|
||||
ret = OPENSLES_CreatePCMPlayer(device);
|
||||
if (ret < 0) {
|
||||
if (!ret) {
|
||||
// Another attempt to open the device with a lower frequency
|
||||
if (device->spec.freq > 48000) {
|
||||
OPENSLES_DestroyPCMPlayer(device);
|
||||
@ -638,15 +638,15 @@ static int OPENSLES_OpenDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
if (!ret) {
|
||||
return SDL_SetError("Open device failed!");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int OPENSLES_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool OPENSLES_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
struct SDL_PrivateAudioData *audiodata = device->hidden;
|
||||
|
||||
@ -654,20 +654,15 @@ static int OPENSLES_WaitDevice(SDL_AudioDevice *device)
|
||||
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
// this semaphore won't fire when the app is in the background (OPENSLES_PauseDevices was called).
|
||||
const int rc = SDL_WaitSemaphoreTimeout(audiodata->playsem, 100);
|
||||
if (rc == -1) { // uh, what?
|
||||
return -1;
|
||||
} else if (rc == 0) {
|
||||
return 0; // semaphore was signaled, let's go!
|
||||
} else {
|
||||
SDL_assert(rc == SDL_MUTEX_TIMEDOUT);
|
||||
if (SDL_WaitSemaphoreTimeout(audiodata->playsem, 100)) {
|
||||
return true; // semaphore was signaled, let's go!
|
||||
}
|
||||
// Still waiting on the semaphore (or the system), check other things then wait again.
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int OPENSLES_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
static bool OPENSLES_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
{
|
||||
struct SDL_PrivateAudioData *audiodata = device->hidden;
|
||||
|
||||
@ -687,7 +682,7 @@ static int OPENSLES_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int
|
||||
SDL_SignalSemaphore(audiodata->playsem);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// n playn sem
|
||||
|
@ -94,26 +94,25 @@ static int (*PIPEWIRE_pw_properties_setf)(struct pw_properties *, const char *,
|
||||
static const char *pipewire_library = SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC;
|
||||
static void *pipewire_handle = NULL;
|
||||
|
||||
static int pipewire_dlsym(const char *fn, void **addr)
|
||||
static bool pipewire_dlsym(const char *fn, void **addr)
|
||||
{
|
||||
*addr = SDL_LoadFunction(pipewire_handle, fn);
|
||||
if (!*addr) {
|
||||
// Don't call SDL_SetError(): SDL_LoadFunction already did.
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
#define SDL_PIPEWIRE_SYM(x) \
|
||||
if (!pipewire_dlsym(#x, (void **)(char *)&PIPEWIRE_##x)) { \
|
||||
return -1; \
|
||||
}
|
||||
if (!pipewire_dlsym(#x, (void **)(char *)&PIPEWIRE_##x)) \
|
||||
return false
|
||||
|
||||
static int load_pipewire_library(void)
|
||||
static bool load_pipewire_library(void)
|
||||
{
|
||||
pipewire_handle = SDL_LoadObject(pipewire_library);
|
||||
return pipewire_handle ? 0 : -1;
|
||||
return pipewire_handle ? true : false;
|
||||
}
|
||||
|
||||
static void unload_pipewire_library(void)
|
||||
@ -128,9 +127,9 @@ static void unload_pipewire_library(void)
|
||||
|
||||
#define SDL_PIPEWIRE_SYM(x) PIPEWIRE_##x = x
|
||||
|
||||
static int load_pipewire_library(void)
|
||||
static bool load_pipewire_library(void)
|
||||
{
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void unload_pipewire_library(void)
|
||||
@ -140,7 +139,7 @@ static void unload_pipewire_library(void)
|
||||
|
||||
#endif // SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC
|
||||
|
||||
static int load_pipewire_syms(void)
|
||||
static bool load_pipewire_syms(void)
|
||||
{
|
||||
SDL_PIPEWIRE_SYM(pw_get_library_version);
|
||||
SDL_PIPEWIRE_SYM(pw_init);
|
||||
@ -176,19 +175,19 @@ static int load_pipewire_syms(void)
|
||||
SDL_PIPEWIRE_SYM(pw_properties_set);
|
||||
SDL_PIPEWIRE_SYM(pw_properties_setf);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int init_pipewire_library(void)
|
||||
static bool init_pipewire_library(void)
|
||||
{
|
||||
if (!load_pipewire_library()) {
|
||||
if (!load_pipewire_syms()) {
|
||||
if (load_pipewire_library()) {
|
||||
if (load_pipewire_syms()) {
|
||||
PIPEWIRE_pw_init(NULL, NULL);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void deinit_pipewire_library(void)
|
||||
@ -705,7 +704,7 @@ static const struct pw_registry_events registry_events = { PW_VERSION_REGISTRY_E
|
||||
.global_remove = registry_event_remove_callback };
|
||||
|
||||
// The hotplug thread
|
||||
static int hotplug_loop_init(void)
|
||||
static bool hotplug_loop_init(void)
|
||||
{
|
||||
int res;
|
||||
|
||||
@ -745,7 +744,7 @@ static int hotplug_loop_init(void)
|
||||
return SDL_SetError("Pipewire: Failed to start hotplug detection loop");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void hotplug_loop_destroy(void)
|
||||
@ -896,6 +895,9 @@ static void initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info
|
||||
case SDL_AUDIO_F32BE:
|
||||
info->format = SPA_AUDIO_FORMAT_F32_BE;
|
||||
break;
|
||||
default:
|
||||
info->format = SPA_AUDIO_FORMAT_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -920,7 +922,7 @@ static Uint8 *PIPEWIRE_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
return (Uint8 *) spa_buf->datas[0].data;
|
||||
}
|
||||
|
||||
static int PIPEWIRE_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
|
||||
static bool PIPEWIRE_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
|
||||
{
|
||||
struct pw_stream *stream = device->hidden->stream;
|
||||
struct pw_buffer *pw_buf = device->hidden->pw_buf;
|
||||
@ -932,7 +934,7 @@ static int PIPEWIRE_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int
|
||||
PIPEWIRE_pw_stream_queue_buffer(stream, pw_buf);
|
||||
device->hidden->pw_buf = NULL;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void output_callback(void *data)
|
||||
@ -1022,7 +1024,7 @@ static const struct pw_stream_events stream_input_events = { PW_VERSION_STREAM_E
|
||||
.add_buffer = stream_add_buffer_callback,
|
||||
.process = input_callback };
|
||||
|
||||
static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool PIPEWIRE_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
/*
|
||||
* NOTE: The PW_STREAM_FLAG_RT_PROCESS flag can be set to call the stream
|
||||
@ -1083,7 +1085,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device)
|
||||
priv = SDL_calloc(1, sizeof(struct SDL_PrivateAudioData));
|
||||
device->hidden = priv;
|
||||
if (!priv) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Size of a single audio frame in bytes
|
||||
@ -1172,7 +1174,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device)
|
||||
return SDL_SetError("Pipewire: Stream error: %s", error);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void PIPEWIRE_CloseDevice(SDL_AudioDevice *device)
|
||||
@ -1221,14 +1223,13 @@ static void PIPEWIRE_Deinitialize(void)
|
||||
static bool PipewireInitialize(SDL_AudioDriverImpl *impl)
|
||||
{
|
||||
if (!pipewire_initialized) {
|
||||
|
||||
if (init_pipewire_library() < 0) {
|
||||
if (!init_pipewire_library()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pipewire_initialized = true;
|
||||
|
||||
if (hotplug_loop_init() < 0) {
|
||||
if (!hotplug_loop_init()) {
|
||||
PIPEWIRE_Deinitialize();
|
||||
return false;
|
||||
}
|
||||
|
@ -27,11 +27,11 @@
|
||||
#include <audsrv.h>
|
||||
#include <ps2_audio_driver.h>
|
||||
|
||||
static int PS2AUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool PS2AUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// These are the native supported audio PS2 configs
|
||||
@ -82,19 +82,19 @@ static int PS2AUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
device->hidden->mixbufs[i] = &device->hidden->rawbuf[i * device->buffer_size];
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PS2AUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
static bool PS2AUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
{
|
||||
// this returns number of bytes accepted or a negative error. We assume anything other than buflen is a fatal error.
|
||||
return (audsrv_play_audio((char *)buffer, buflen) != buflen) ? -1 : 0;
|
||||
return (audsrv_play_audio((char *)buffer, buflen) == buflen);
|
||||
}
|
||||
|
||||
static int PS2AUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool PS2AUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
audsrv_wait_audio(device->buffer_size);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Uint8 *PS2AUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
|
@ -38,11 +38,11 @@ static bool isBasicAudioConfig(const SDL_AudioSpec *spec)
|
||||
return spec->freq == 44100;
|
||||
}
|
||||
|
||||
static int PSPAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool PSPAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// device only natively supports S16LSB
|
||||
@ -102,10 +102,10 @@ static int PSPAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
device->hidden->mixbufs[i] = &device->hidden->rawbuf[i * device->buffer_size];
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PSPAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
static bool PSPAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
{
|
||||
int rc;
|
||||
if (!isBasicAudioConfig(&device->spec)) {
|
||||
@ -114,12 +114,12 @@ static int PSPAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int
|
||||
} else {
|
||||
rc = sceAudioOutputPannedBlocking(device->hidden->channel, PSP_AUDIO_VOLUME_MAX, PSP_AUDIO_VOLUME_MAX, (void *) buffer);
|
||||
}
|
||||
return (rc == 0) ? 0 : -1;
|
||||
return (rc == 0);
|
||||
}
|
||||
|
||||
static int PSPAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool PSPAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
return 0; // Because we block when sending audio, there's no need for this function to do anything.
|
||||
return true; // Because we block when sending audio, there's no need for this function to do anything.
|
||||
}
|
||||
|
||||
static Uint8 *PSPAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
|
@ -129,28 +129,28 @@ static void (*PULSEAUDIO_pa_stream_set_write_callback)(pa_stream *, pa_stream_re
|
||||
static void (*PULSEAUDIO_pa_stream_set_read_callback)(pa_stream *, pa_stream_request_cb_t, void *);
|
||||
static pa_operation *(*PULSEAUDIO_pa_context_get_server_info)(pa_context *, pa_server_info_cb_t, void *);
|
||||
|
||||
static int load_pulseaudio_syms(void);
|
||||
static bool load_pulseaudio_syms(void);
|
||||
|
||||
#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
|
||||
|
||||
static const char *pulseaudio_library = SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC;
|
||||
static void *pulseaudio_handle = NULL;
|
||||
|
||||
static int load_pulseaudio_sym(const char *fn, void **addr)
|
||||
static bool load_pulseaudio_sym(const char *fn, void **addr)
|
||||
{
|
||||
*addr = SDL_LoadFunction(pulseaudio_handle, fn);
|
||||
if (!*addr) {
|
||||
// Don't call SDL_SetError(): SDL_LoadFunction already did.
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// cast funcs to char* first, to please GCC's strict aliasing rules.
|
||||
#define SDL_PULSEAUDIO_SYM(x) \
|
||||
if (!load_pulseaudio_sym(#x, (void **)(char *)&PULSEAUDIO_##x)) \
|
||||
return -1
|
||||
return -1
|
||||
|
||||
static void UnloadPulseAudioLibrary(void)
|
||||
{
|
||||
@ -160,22 +160,22 @@ static void UnloadPulseAudioLibrary(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int LoadPulseAudioLibrary(void)
|
||||
static bool LoadPulseAudioLibrary(void)
|
||||
{
|
||||
int retval = 0;
|
||||
bool result = true;
|
||||
if (!pulseaudio_handle) {
|
||||
pulseaudio_handle = SDL_LoadObject(pulseaudio_library);
|
||||
if (!pulseaudio_handle) {
|
||||
retval = -1;
|
||||
result = false;
|
||||
// Don't call SDL_SetError(): SDL_LoadObject already did.
|
||||
} else {
|
||||
retval = load_pulseaudio_syms();
|
||||
if (retval < 0) {
|
||||
result = load_pulseaudio_syms();
|
||||
if (!result) {
|
||||
UnloadPulseAudioLibrary();
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
#else
|
||||
@ -186,15 +186,15 @@ static void UnloadPulseAudioLibrary(void)
|
||||
{
|
||||
}
|
||||
|
||||
static int LoadPulseAudioLibrary(void)
|
||||
static bool LoadPulseAudioLibrary(void)
|
||||
{
|
||||
load_pulseaudio_syms();
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
|
||||
|
||||
static int load_pulseaudio_syms(void)
|
||||
static bool load_pulseaudio_syms(void)
|
||||
{
|
||||
SDL_PULSEAUDIO_SYM(pa_get_library_version);
|
||||
SDL_PULSEAUDIO_SYM(pa_threaded_mainloop_new);
|
||||
@ -261,7 +261,7 @@ static int load_pulseaudio_syms(void)
|
||||
PULSEAUDIO_pa_threaded_mainloop_set_name = NULL;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static const char *getAppName(void)
|
||||
@ -316,7 +316,7 @@ static void PulseContextStateChangeCallback(pa_context *context, void *userdata)
|
||||
PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); // just signal any waiting code, it can look up the details.
|
||||
}
|
||||
|
||||
static int ConnectToPulseServer(void)
|
||||
static bool ConnectToPulseServer(void)
|
||||
{
|
||||
pa_mainloop_api *mainloop_api = NULL;
|
||||
pa_proplist *proplist = NULL;
|
||||
@ -384,12 +384,12 @@ static int ConnectToPulseServer(void)
|
||||
|
||||
PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop);
|
||||
|
||||
return 0; // connected and ready!
|
||||
return true; // connected and ready!
|
||||
|
||||
failed:
|
||||
PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop);
|
||||
DisconnectFromPulseServer();
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void WriteCallback(pa_stream *p, size_t nbytes, void *userdata)
|
||||
@ -401,10 +401,10 @@ static void WriteCallback(pa_stream *p, size_t nbytes, void *userdata)
|
||||
}
|
||||
|
||||
// This function waits until it is possible to write a full sound buffer
|
||||
static int PULSEAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool PULSEAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
struct SDL_PrivateAudioData *h = device->hidden;
|
||||
int retval = 0;
|
||||
bool result = true;
|
||||
|
||||
//SDL_Log("PULSEAUDIO PLAYDEVICE START! mixlen=%d", available);
|
||||
|
||||
@ -416,17 +416,17 @@ static int PULSEAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
|
||||
if ((PULSEAUDIO_pa_context_get_state(pulseaudio_context) != PA_CONTEXT_READY) || (PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY)) {
|
||||
//SDL_Log("PULSEAUDIO DEVICE FAILURE IN WAITDEVICE!");
|
||||
retval = -1;
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop);
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static int PULSEAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
|
||||
static bool PULSEAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
|
||||
{
|
||||
struct SDL_PrivateAudioData *h = device->hidden;
|
||||
|
||||
@ -439,14 +439,14 @@ static int PULSEAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, i
|
||||
PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop);
|
||||
|
||||
if (rc < 0) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
//SDL_Log("PULSEAUDIO FEED! nbytes=%d", buffer_size);
|
||||
h->bytes_requested -= buffer_size;
|
||||
|
||||
//SDL_Log("PULSEAUDIO PLAYDEVICE END! written=%d", written);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Uint8 *PULSEAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
@ -471,15 +471,15 @@ static void ReadCallback(pa_stream *p, size_t nbytes, void *userdata)
|
||||
PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); // the recording code queries what it needs, we just need to signal to end any wait
|
||||
}
|
||||
|
||||
static int PULSEAUDIO_WaitRecordingDevice(SDL_AudioDevice *device)
|
||||
static bool PULSEAUDIO_WaitRecordingDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
struct SDL_PrivateAudioData *h = device->hidden;
|
||||
|
||||
if (h->recordingbuf) {
|
||||
return 0; // there's still data available to read.
|
||||
return true; // there's still data available to read.
|
||||
}
|
||||
|
||||
int retval = 0;
|
||||
bool result = true;
|
||||
|
||||
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
|
||||
|
||||
@ -487,7 +487,7 @@ static int PULSEAUDIO_WaitRecordingDevice(SDL_AudioDevice *device)
|
||||
PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop);
|
||||
if ((PULSEAUDIO_pa_context_get_state(pulseaudio_context) != PA_CONTEXT_READY) || (PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY)) {
|
||||
//SDL_Log("PULSEAUDIO DEVICE FAILURE IN WAITRECORDINGDEVICE!");
|
||||
retval = -1;
|
||||
result = false;
|
||||
break;
|
||||
} else if (PULSEAUDIO_pa_stream_readable_size(h->stream) > 0) {
|
||||
// a new fragment is available!
|
||||
@ -509,7 +509,7 @@ static int PULSEAUDIO_WaitRecordingDevice(SDL_AudioDevice *device)
|
||||
|
||||
PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop);
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static int PULSEAUDIO_RecordDevice(SDL_AudioDevice *device, void *buffer, int buflen)
|
||||
@ -591,7 +591,7 @@ static void PulseStreamStateChangeCallback(pa_stream *stream, void *userdata)
|
||||
PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); // just signal any waiting code, it can look up the details.
|
||||
}
|
||||
|
||||
static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
const bool recording = device->recording;
|
||||
struct SDL_PrivateAudioData *h = NULL;
|
||||
@ -602,7 +602,7 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
pa_channel_map pacmap;
|
||||
pa_stream_flags_t flags = 0;
|
||||
int format = PA_SAMPLE_INVALID;
|
||||
int retval = 0;
|
||||
bool result = true;
|
||||
|
||||
SDL_assert(pulseaudio_threaded_mainloop != NULL);
|
||||
SDL_assert(pulseaudio_context != NULL);
|
||||
@ -610,7 +610,7 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
// Initialize all variables that we clean on shutdown
|
||||
h = device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try for a closest match on audio format
|
||||
@ -659,7 +659,7 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
if (!recording) {
|
||||
h->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size);
|
||||
if (!h->mixbuf) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
SDL_memset(h->mixbuf, device->silence_value, device->buffer_size);
|
||||
}
|
||||
@ -690,7 +690,7 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
);
|
||||
|
||||
if (!h->stream) {
|
||||
retval = SDL_SetError("Could not set up PulseAudio stream");
|
||||
result = SDL_SetError("Could not set up PulseAudio stream");
|
||||
} else {
|
||||
int rc;
|
||||
|
||||
@ -709,7 +709,7 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
|
||||
if (rc < 0) {
|
||||
retval = SDL_SetError("Could not connect PulseAudio stream");
|
||||
result = SDL_SetError("Could not connect PulseAudio stream");
|
||||
} else {
|
||||
int state = PULSEAUDIO_pa_stream_get_state(h->stream);
|
||||
while (PA_STREAM_IS_GOOD(state) && (state != PA_STREAM_READY)) {
|
||||
@ -718,11 +718,11 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
|
||||
if (!PA_STREAM_IS_GOOD(state)) {
|
||||
retval = SDL_SetError("Could not connect PulseAudio stream");
|
||||
result = SDL_SetError("Could not connect PulseAudio stream");
|
||||
} else {
|
||||
const pa_buffer_attr *actual_bufattr = PULSEAUDIO_pa_stream_get_buffer_attr(h->stream);
|
||||
if (!actual_bufattr) {
|
||||
retval = SDL_SetError("Could not determine connected PulseAudio stream's buffer attributes");
|
||||
result = SDL_SetError("Could not determine connected PulseAudio stream's buffer attributes");
|
||||
} else {
|
||||
device->buffer_size = (int) recording ? actual_bufattr->tlength : actual_bufattr->fragsize;
|
||||
device->sample_frames = device->buffer_size / SDL_AUDIO_FRAMESIZE(device->spec);
|
||||
@ -734,7 +734,7 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop);
|
||||
|
||||
// We're (hopefully) ready to rock and roll. :-)
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
// device handles are device index + 1, cast to void*, so we never pass a NULL.
|
||||
@ -994,9 +994,9 @@ static void PULSEAUDIO_Deinitialize(void)
|
||||
|
||||
static bool PULSEAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||
{
|
||||
if (LoadPulseAudioLibrary() < 0) {
|
||||
if (!LoadPulseAudioLibrary()) {
|
||||
return false;
|
||||
} else if (ConnectToPulseServer() < 0) {
|
||||
} else if (!ConnectToPulseServer()) {
|
||||
UnloadPulseAudioLibrary();
|
||||
return false;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@
|
||||
|
||||
#define QSA_MAX_NAME_LENGTH 81+16 // Hardcoded in QSA, can't be changed
|
||||
|
||||
static int QSA_SetError(const char *fn, int status)
|
||||
static bool QSA_SetError(const char *fn, int status)
|
||||
{
|
||||
return SDL_SetError("QSA: %s() failed: %s", fn, snd_strerror(status));
|
||||
}
|
||||
@ -86,7 +86,7 @@ static void QSA_InitAudioParams(snd_pcm_channel_params_t * cpars)
|
||||
}
|
||||
|
||||
// This function waits until it is possible to write a full sound buffer
|
||||
static int QSA_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool QSA_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
// Setup timeout for playing one fragment equal to 2 seconds
|
||||
// If timeout occurred than something wrong with hardware or driver
|
||||
@ -98,7 +98,7 @@ static int QSA_WaitDevice(SDL_AudioDevice *device)
|
||||
switch (result) {
|
||||
case -1:
|
||||
SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "QSA: SDL_IOReady() failed: %s", strerror(errno));
|
||||
return -1;
|
||||
return false;
|
||||
case 0:
|
||||
device->hidden->timeout_on_wait = true; // !!! FIXME: Should we just disconnect the device in this case?
|
||||
break;
|
||||
@ -107,13 +107,13 @@ static int QSA_WaitDevice(SDL_AudioDevice *device)
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int QSA_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
static bool QSA_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
{
|
||||
if (SDL_AtomicGet(&device->shutdown) || !device->hidden) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int towrite = buflen;
|
||||
@ -125,7 +125,7 @@ static int QSA_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int bufl
|
||||
// Check if samples playback got stuck somewhere in hardware or in the audio device driver
|
||||
if ((errno == EAGAIN) && (bw == 0)) {
|
||||
if (device->hidden->timeout_on_wait) {
|
||||
return 0; // oh well, try again next time. !!! FIXME: Should we just disconnect the device in this case?
|
||||
return true; // oh well, try again next time. !!! FIXME: Should we just disconnect the device in this case?
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,17 +145,17 @@ static int QSA_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int bufl
|
||||
int status = snd_pcm_plugin_status(device->hidden->audio_handle, &cstatus);
|
||||
if (status < 0) {
|
||||
QSA_SetError("snd_pcm_plugin_status", status);
|
||||
return -1;
|
||||
return false;
|
||||
} else if ((cstatus.status == SND_PCM_STATUS_UNDERRUN) || (cstatus.status == SND_PCM_STATUS_READY)) {
|
||||
status = snd_pcm_plugin_prepare(device->hidden->audio_handle, device->recording ? SND_PCM_CHANNEL_CAPTURE : SND_PCM_CHANNEL_PLAYBACK);
|
||||
if (status < 0) {
|
||||
QSA_SetError("snd_pcm_plugin_prepare", status);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// we wrote all remaining data
|
||||
@ -165,7 +165,7 @@ static int QSA_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int bufl
|
||||
}
|
||||
|
||||
// If we couldn't write, assume fatal error for now
|
||||
return (towrite != 0) ? -1 : 0;
|
||||
return (towrite == 0);
|
||||
}
|
||||
|
||||
static Uint8 *QSA_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
@ -190,7 +190,7 @@ static void QSA_CloseDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
static int QSA_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool QSA_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
if (device->recording) {
|
||||
return SDL_SetError("SDL recording support isn't available on QNX atm"); // !!! FIXME: most of this code has support for recording devices, but there's no RecordDevice, etc functions. Fill them in!
|
||||
@ -206,7 +206,7 @@ static int QSA_OpenDevice(SDL_AudioDevice *device)
|
||||
// Initialize all variables that we clean on shutdown
|
||||
device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, (sizeof (struct SDL_PrivateAudioData)));
|
||||
if (device->hidden == NULL) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialize channel transfer parameters to default
|
||||
@ -275,7 +275,7 @@ static int QSA_OpenDevice(SDL_AudioDevice *device)
|
||||
|
||||
device->hidden->pcm_buf = (Uint8 *) SDL_malloc(device->buffer_size);
|
||||
if (device->hidden->pcm_buf == NULL) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
SDL_memset(device->hidden->pcm_buf, device->silence_value, device->buffer_size);
|
||||
|
||||
@ -291,7 +291,7 @@ static int QSA_OpenDevice(SDL_AudioDevice *device)
|
||||
return QSA_SetError("snd_pcm_plugin_prepare", status);
|
||||
}
|
||||
|
||||
return 0; // We're really ready to rock and roll. :-)
|
||||
return true; // We're really ready to rock and roll. :-)
|
||||
}
|
||||
|
||||
static SDL_AudioFormat QnxFormatToSDLFormat(const int32_t qnxfmt)
|
||||
|
@ -68,25 +68,25 @@ static void (*SNDIO_sio_initpar)(struct sio_par *);
|
||||
static const char *sndio_library = SDL_AUDIO_DRIVER_SNDIO_DYNAMIC;
|
||||
static void *sndio_handle = NULL;
|
||||
|
||||
static int load_sndio_sym(const char *fn, void **addr)
|
||||
static bool load_sndio_sym(const char *fn, void **addr)
|
||||
{
|
||||
*addr = SDL_LoadFunction(sndio_handle, fn);
|
||||
if (!*addr) {
|
||||
return 0; // Don't call SDL_SetError(): SDL_LoadFunction already did.
|
||||
return false; // Don't call SDL_SetError(): SDL_LoadFunction already did.
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// cast funcs to char* first, to please GCC's strict aliasing rules.
|
||||
#define SDL_SNDIO_SYM(x) \
|
||||
if (!load_sndio_sym(#x, (void **)(char *)&SNDIO_##x)) \
|
||||
return -1
|
||||
return false
|
||||
#else
|
||||
#define SDL_SNDIO_SYM(x) SNDIO_##x = x
|
||||
#endif
|
||||
|
||||
static int load_sndio_syms(void)
|
||||
static bool load_sndio_syms(void)
|
||||
{
|
||||
SDL_SNDIO_SYM(sio_open);
|
||||
SDL_SNDIO_SYM(sio_close);
|
||||
@ -101,7 +101,7 @@ static int load_sndio_syms(void)
|
||||
SDL_SNDIO_SYM(sio_revents);
|
||||
SDL_SNDIO_SYM(sio_eof);
|
||||
SDL_SNDIO_SYM(sio_initpar);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#undef SDL_SNDIO_SYM
|
||||
@ -116,21 +116,21 @@ static void UnloadSNDIOLibrary(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int LoadSNDIOLibrary(void)
|
||||
static bool LoadSNDIOLibrary(void)
|
||||
{
|
||||
int retval = 0;
|
||||
bool result = true;
|
||||
if (!sndio_handle) {
|
||||
sndio_handle = SDL_LoadObject(sndio_library);
|
||||
if (!sndio_handle) {
|
||||
retval = -1; // Don't call SDL_SetError(): SDL_LoadObject already did.
|
||||
result = false; // Don't call SDL_SetError(): SDL_LoadObject already did.
|
||||
} else {
|
||||
retval = load_sndio_syms();
|
||||
if (retval < 0) {
|
||||
result = load_sndio_syms();
|
||||
if (!result) {
|
||||
UnloadSNDIOLibrary();
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
#else
|
||||
@ -139,26 +139,26 @@ static void UnloadSNDIOLibrary(void)
|
||||
{
|
||||
}
|
||||
|
||||
static int LoadSNDIOLibrary(void)
|
||||
static bool LoadSNDIOLibrary(void)
|
||||
{
|
||||
load_sndio_syms();
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // SDL_AUDIO_DRIVER_SNDIO_DYNAMIC
|
||||
|
||||
static int SNDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool SNDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
const bool recording = device->recording;
|
||||
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
if (SNDIO_sio_eof(device->hidden->dev)) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
const int nfds = SNDIO_sio_pollfd(device->hidden->dev, device->hidden->pfd, recording ? POLLIN : POLLOUT);
|
||||
if (nfds <= 0 || poll(device->hidden->pfd, nfds, 10) < 0) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
const int revents = SNDIO_sio_revents(device->hidden->dev, device->hidden->pfd);
|
||||
@ -167,24 +167,24 @@ static int SNDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
} else if (!recording && (revents & POLLOUT)) {
|
||||
break;
|
||||
} else if (revents & POLLHUP) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SNDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
static bool SNDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
{
|
||||
// !!! FIXME: this should be non-blocking so we can check device->shutdown.
|
||||
// this is set to blocking, because we _have_ to send the entire buffer down, but hopefully WaitDevice took most of the delay time.
|
||||
if (SNDIO_sio_write(device->hidden->dev, buffer, buflen) != buflen) {
|
||||
return -1; // If we couldn't write, assume fatal error for now
|
||||
return false; // If we couldn't write, assume fatal error for now
|
||||
}
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Wrote %d bytes of audio data\n", written);
|
||||
#endif
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SNDIO_RecordDevice(SDL_AudioDevice *device, void *buffer, int buflen)
|
||||
@ -224,11 +224,11 @@ static void SNDIO_CloseDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
static int SNDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool SNDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Recording devices must be non-blocking for SNDIO_FlushRecording
|
||||
@ -240,7 +240,7 @@ static int SNDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
|
||||
device->hidden->pfd = SDL_malloc(sizeof(struct pollfd) * SNDIO_sio_nfds(device->hidden->dev));
|
||||
if (!device->hidden->pfd) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
struct sio_par par;
|
||||
@ -305,7 +305,7 @@ static int SNDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
// Allocate mixing buffer
|
||||
device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size);
|
||||
if (!device->hidden->mixbuf) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size);
|
||||
|
||||
@ -313,7 +313,7 @@ static int SNDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
return SDL_SetError("sio_start() failed");
|
||||
}
|
||||
|
||||
return 0; // We're ready to rock and roll. :-)
|
||||
return true; // We're ready to rock and roll. :-)
|
||||
}
|
||||
|
||||
static void SNDIO_Deinitialize(void)
|
||||
@ -329,7 +329,7 @@ static void SNDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDev
|
||||
|
||||
static bool SNDIO_Init(SDL_AudioDriverImpl *impl)
|
||||
{
|
||||
if (LoadSNDIOLibrary() < 0) {
|
||||
if (!LoadSNDIOLibrary()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
#define SCE_AUDIO_SAMPLE_ALIGN(s) (((s) + 63) & ~63)
|
||||
#define SCE_AUDIO_MAX_VOLUME 0x8000
|
||||
|
||||
static int VITAAUD_OpenRecordingDevice(SDL_AudioDevice *device)
|
||||
static bool VITAAUD_OpenRecordingDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
device->spec.freq = 16000;
|
||||
device->spec.channels = 1;
|
||||
@ -51,10 +51,10 @@ static int VITAAUD_OpenRecordingDevice(SDL_AudioDevice *device)
|
||||
return SDL_SetError("Couldn't open audio in port: %x", device->hidden->port);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VITAAUD_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool VITAAUD_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
int format, mixlen, i, port = SCE_AUDIO_OUT_PORT_TYPE_MAIN;
|
||||
int vols[2] = { SCE_AUDIO_MAX_VOLUME, SCE_AUDIO_MAX_VOLUME };
|
||||
@ -64,7 +64,7 @@ static int VITAAUD_OpenDevice(SDL_AudioDevice *device)
|
||||
device->hidden = (struct SDL_PrivateAudioData *)
|
||||
SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
closefmts = SDL_ClosestAudioFormats(device->spec.format);
|
||||
@ -125,29 +125,29 @@ static int VITAAUD_OpenDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
|
||||
device->hidden->next_buffer = 0;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VITAAUD_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
|
||||
static bool VITAAUD_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
|
||||
{
|
||||
return (sceAudioOutOutput(device->hidden->port, buffer) == 0) ? 0 : -1;
|
||||
return (sceAudioOutOutput(device->hidden->port, buffer) == 0);
|
||||
}
|
||||
|
||||
// This function waits until it is possible to write a full sound buffer
|
||||
static int VITAAUD_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool VITAAUD_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
// !!! FIXME: we might just need to sleep roughly as long as playback buffers take to process, based on sample rate, etc.
|
||||
while (!SDL_AtomicGet(&device->shutdown) && (sceAudioOutGetRestSample(device->hidden->port) >= device->buffer_size)) {
|
||||
SDL_Delay(1);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Uint8 *VITAAUD_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
{
|
||||
Uint8 *retval = device->hidden->mixbufs[device->hidden->next_buffer];
|
||||
Uint8 *result = device->hidden->mixbufs[device->hidden->next_buffer];
|
||||
device->hidden->next_buffer = (device->hidden->next_buffer + 1) % NUM_BUFFERS;
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void VITAAUD_CloseDevice(SDL_AudioDevice *device)
|
||||
@ -171,7 +171,7 @@ static void VITAAUD_CloseDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
static int VITAAUD_WaitRecordingDevice(SDL_AudioDevice *device)
|
||||
static bool VITAAUD_WaitRecordingDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
// there's only a blocking call to obtain more data, so we'll just sleep as
|
||||
// long as a buffer would run.
|
||||
@ -179,7 +179,7 @@ static int VITAAUD_WaitRecordingDevice(SDL_AudioDevice *device)
|
||||
while (!SDL_AtomicGet(&device->shutdown) && (SDL_GetTicks() < endticks)) {
|
||||
SDL_Delay(1);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VITAAUD_RecordDevice(SDL_AudioDevice *device, void *buffer, int buflen)
|
||||
@ -188,7 +188,8 @@ static int VITAAUD_RecordDevice(SDL_AudioDevice *device, void *buffer, int bufle
|
||||
SDL_assert(buflen == device->buffer_size);
|
||||
ret = sceAudioInInput(device->hidden->port, buffer);
|
||||
if (ret < 0) {
|
||||
return SDL_SetError("Failed to record from device: %x", ret);
|
||||
SDL_SetError("Failed to record from device: %x", ret);
|
||||
return -1;
|
||||
}
|
||||
return device->buffer_size;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ typedef struct ManagementThreadPendingTask
|
||||
{
|
||||
ManagementThreadTask fn;
|
||||
void *userdata;
|
||||
int result;
|
||||
bool result;
|
||||
SDL_Semaphore *task_complete_sem;
|
||||
char *errorstr;
|
||||
struct ManagementThreadPendingTask *next;
|
||||
@ -93,12 +93,12 @@ static void ManagementThreadMainloop(void)
|
||||
SDL_UnlockMutex(ManagementThreadLock); // told to shut down and out of tasks, let go of the lock and return.
|
||||
}
|
||||
|
||||
int WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, int *wait_on_result)
|
||||
bool WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, bool *wait_on_result)
|
||||
{
|
||||
// We want to block for a result, but we are already running from the management thread! Just run the task now so we don't deadlock.
|
||||
if ((wait_on_result) && (SDL_GetCurrentThreadID() == SDL_GetThreadID(ManagementThread))) {
|
||||
*wait_on_result = task(userdata);
|
||||
return 0; // completed!
|
||||
return true; // completed!
|
||||
}
|
||||
|
||||
if (SDL_AtomicGet(&ManagementThreadShutdown)) {
|
||||
@ -107,7 +107,7 @@ int WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, in
|
||||
|
||||
ManagementThreadPendingTask *pending = (ManagementThreadPendingTask *)SDL_calloc(1, sizeof(ManagementThreadPendingTask));
|
||||
if (!pending) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
pending->fn = task;
|
||||
@ -117,7 +117,7 @@ int WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, in
|
||||
pending->task_complete_sem = SDL_CreateSemaphore(0);
|
||||
if (!pending->task_complete_sem) {
|
||||
SDL_free(pending);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,19 +152,19 @@ int WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, in
|
||||
SDL_free(pending);
|
||||
}
|
||||
|
||||
return 0; // successfully added (and possibly executed)!
|
||||
return true; // successfully added (and possibly executed)!
|
||||
}
|
||||
|
||||
static int ManagementThreadPrepare(void)
|
||||
static bool ManagementThreadPrepare(void)
|
||||
{
|
||||
if (WASAPI_PlatformInit() < 0) {
|
||||
return -1;
|
||||
if (!WASAPI_PlatformInit()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ManagementThreadLock = SDL_CreateMutex();
|
||||
if (!ManagementThreadLock) {
|
||||
WASAPI_PlatformDeinit();
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
ManagementThreadCondition = SDL_CreateCondition();
|
||||
@ -172,10 +172,10 @@ static int ManagementThreadPrepare(void)
|
||||
SDL_DestroyMutex(ManagementThreadLock);
|
||||
ManagementThreadLock = NULL;
|
||||
WASAPI_PlatformDeinit();
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
@ -188,7 +188,7 @@ static int ManagementThreadEntry(void *userdata)
|
||||
{
|
||||
ManagementThreadEntryData *data = (ManagementThreadEntryData *)userdata;
|
||||
|
||||
if (ManagementThreadPrepare() < 0) {
|
||||
if (!ManagementThreadPrepare()) {
|
||||
data->errorstr = SDL_strdup(SDL_GetError());
|
||||
SDL_SignalSemaphore(data->ready_sem); // unblock calling thread.
|
||||
return 0;
|
||||
@ -201,20 +201,20 @@ static int ManagementThreadEntry(void *userdata)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int InitManagementThread(void)
|
||||
static bool InitManagementThread(void)
|
||||
{
|
||||
ManagementThreadEntryData mgmtdata;
|
||||
SDL_zero(mgmtdata);
|
||||
mgmtdata.ready_sem = SDL_CreateSemaphore(0);
|
||||
if (!mgmtdata.ready_sem) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_AtomicSetPtr((void **) &ManagementThreadPendingTasks, NULL);
|
||||
SDL_AtomicSet(&ManagementThreadShutdown, 0);
|
||||
ManagementThread = SDL_CreateThreadWithStackSize(ManagementThreadEntry, "SDLWASAPIMgmt", 256 * 1024, &mgmtdata); // !!! FIXME: maybe even smaller stack size?
|
||||
if (!ManagementThread) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_WaitSemaphore(mgmtdata.ready_sem);
|
||||
@ -225,10 +225,10 @@ static int InitManagementThread(void)
|
||||
ManagementThread = NULL;
|
||||
SDL_SetError("%s", mgmtdata.errorstr);
|
||||
SDL_free(mgmtdata.errorstr);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void DeinitManagementThread(void)
|
||||
@ -257,16 +257,16 @@ typedef struct
|
||||
SDL_AudioDevice **default_recording;
|
||||
} mgmtthrtask_DetectDevicesData;
|
||||
|
||||
static int mgmtthrtask_DetectDevices(void *userdata)
|
||||
static bool mgmtthrtask_DetectDevices(void *userdata)
|
||||
{
|
||||
mgmtthrtask_DetectDevicesData *data = (mgmtthrtask_DetectDevicesData *)userdata;
|
||||
WASAPI_EnumerateEndpoints(data->default_playback, data->default_recording);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void WASAPI_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
||||
{
|
||||
int rc;
|
||||
bool rc;
|
||||
// this blocks because it needs to finish before the audio subsystem inits
|
||||
mgmtthrtask_DetectDevicesData data;
|
||||
data.default_playback = default_playback;
|
||||
@ -274,15 +274,15 @@ static void WASAPI_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDe
|
||||
WASAPI_ProxyToManagementThread(mgmtthrtask_DetectDevices, &data, &rc);
|
||||
}
|
||||
|
||||
static int mgmtthrtask_DisconnectDevice(void *userdata)
|
||||
static bool mgmtthrtask_DisconnectDevice(void *userdata)
|
||||
{
|
||||
SDL_AudioDeviceDisconnected((SDL_AudioDevice *)userdata);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void WASAPI_DisconnectDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
int rc; // block on this; don't disconnect while holding the device lock!
|
||||
bool rc; // block on this; don't disconnect while holding the device lock!
|
||||
WASAPI_ProxyToManagementThread(mgmtthrtask_DisconnectDevice, device, &rc);
|
||||
}
|
||||
|
||||
@ -299,42 +299,42 @@ static bool WasapiFailed(SDL_AudioDevice *device, const HRESULT err)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int mgmtthrtask_StopAndReleaseClient(void *userdata)
|
||||
static bool mgmtthrtask_StopAndReleaseClient(void *userdata)
|
||||
{
|
||||
IAudioClient *client = (IAudioClient *) userdata;
|
||||
IAudioClient_Stop(client);
|
||||
IAudioClient_Release(client);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int mgmtthrtask_ReleaseCaptureClient(void *userdata)
|
||||
static bool mgmtthrtask_ReleaseCaptureClient(void *userdata)
|
||||
{
|
||||
IAudioCaptureClient_Release((IAudioCaptureClient *)userdata);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int mgmtthrtask_ReleaseRenderClient(void *userdata)
|
||||
static bool mgmtthrtask_ReleaseRenderClient(void *userdata)
|
||||
{
|
||||
IAudioRenderClient_Release((IAudioRenderClient *)userdata);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int mgmtthrtask_CoTaskMemFree(void *userdata)
|
||||
static bool mgmtthrtask_CoTaskMemFree(void *userdata)
|
||||
{
|
||||
CoTaskMemFree(userdata);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int mgmtthrtask_PlatformDeleteActivationHandler(void *userdata)
|
||||
static bool mgmtthrtask_PlatformDeleteActivationHandler(void *userdata)
|
||||
{
|
||||
WASAPI_PlatformDeleteActivationHandler(userdata);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int mgmtthrtask_CloseHandle(void *userdata)
|
||||
static bool mgmtthrtask_CloseHandle(void *userdata)
|
||||
{
|
||||
CloseHandle((HANDLE) userdata);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void ResetWasapiDevice(SDL_AudioDevice *device)
|
||||
@ -383,17 +383,17 @@ static void ResetWasapiDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
static int mgmtthrtask_ActivateDevice(void *userdata)
|
||||
static bool mgmtthrtask_ActivateDevice(void *userdata)
|
||||
{
|
||||
return WASAPI_ActivateDevice((SDL_AudioDevice *)userdata);
|
||||
}
|
||||
|
||||
static int ActivateWasapiDevice(SDL_AudioDevice *device)
|
||||
static bool ActivateWasapiDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
// this blocks because we're either being notified from a background thread or we're running during device open,
|
||||
// both of which won't deadlock vs the device thread.
|
||||
int rc = -1;
|
||||
return ((WASAPI_ProxyToManagementThread(mgmtthrtask_ActivateDevice, device, &rc) < 0) || (rc < 0)) ? -1 : 0;
|
||||
bool rc = false;
|
||||
return (WASAPI_ProxyToManagementThread(mgmtthrtask_ActivateDevice, device, &rc) && rc);
|
||||
}
|
||||
|
||||
// do not call when holding the device lock!
|
||||
@ -402,7 +402,7 @@ static bool RecoverWasapiDevice(SDL_AudioDevice *device)
|
||||
ResetWasapiDevice(device); // dump the lost device's handles.
|
||||
|
||||
// This handles a non-default device that simply had its format changed in the Windows Control Panel.
|
||||
if (ActivateWasapiDevice(device) < 0) {
|
||||
if (!ActivateWasapiDevice(device)) {
|
||||
WASAPI_DisconnectDevice(device);
|
||||
return false;
|
||||
}
|
||||
@ -452,16 +452,16 @@ static Uint8 *WASAPI_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
return (Uint8 *)buffer;
|
||||
}
|
||||
|
||||
static int WASAPI_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
static bool WASAPI_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
{
|
||||
if (device->hidden->render) { // definitely activated?
|
||||
// WasapiFailed() will mark the device for reacquisition or removal elsewhere.
|
||||
WasapiFailed(device, IAudioRenderClient_ReleaseBuffer(device->hidden->render, device->sample_frames, 0));
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int WASAPI_WaitDevice(SDL_AudioDevice *device)
|
||||
static bool WASAPI_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
// WaitDevice does not hold the device lock, so check for recovery/disconnect details here.
|
||||
while (RecoverWasapiIfLost(device) && device->hidden->client && device->hidden->event) {
|
||||
@ -483,7 +483,7 @@ static int WASAPI_WaitDevice(SDL_AudioDevice *device)
|
||||
default:
|
||||
//SDL_Log("WASAPI FAILED EVENT!");
|
||||
IAudioClient_Stop(device->hidden->client);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
DWORD waitResult = WaitForSingleObjectEx(device->hidden->event, 200, FALSE);
|
||||
@ -498,12 +498,12 @@ static int WASAPI_WaitDevice(SDL_AudioDevice *device)
|
||||
} else if (waitResult != WAIT_TIMEOUT) {
|
||||
//SDL_Log("WASAPI FAILED EVENT!");*/
|
||||
IAudioClient_Stop(device->hidden->client);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int WASAPI_RecordDevice(SDL_AudioDevice *device, void *buffer, int buflen)
|
||||
@ -572,7 +572,7 @@ static void WASAPI_CloseDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
static int mgmtthrtask_PrepDevice(void *userdata)
|
||||
static bool mgmtthrtask_PrepDevice(void *userdata)
|
||||
{
|
||||
SDL_AudioDevice *device = (SDL_AudioDevice *)userdata;
|
||||
|
||||
@ -719,8 +719,8 @@ static int mgmtthrtask_PrepDevice(void *userdata)
|
||||
}
|
||||
|
||||
// Update the fragment size as size in bytes
|
||||
if (SDL_AudioDeviceFormatChangedAlreadyLocked(device, &newspec, new_sample_frames) < 0) {
|
||||
return -1;
|
||||
if (!SDL_AudioDeviceFormatChangedAlreadyLocked(device, &newspec, new_sample_frames)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
device->hidden->framesize = SDL_AUDIO_FRAMESIZE(device->spec);
|
||||
@ -755,24 +755,24 @@ static int mgmtthrtask_PrepDevice(void *userdata)
|
||||
}
|
||||
}
|
||||
|
||||
return 0; // good to go.
|
||||
return true; // good to go.
|
||||
}
|
||||
|
||||
// This is called once a device is activated, possibly asynchronously.
|
||||
int WASAPI_PrepDevice(SDL_AudioDevice *device)
|
||||
bool WASAPI_PrepDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
int rc = 0;
|
||||
return (WASAPI_ProxyToManagementThread(mgmtthrtask_PrepDevice, device, &rc) < 0) ? -1 : rc;
|
||||
bool rc = true;
|
||||
return (WASAPI_ProxyToManagementThread(mgmtthrtask_PrepDevice, device, &rc) && rc);
|
||||
}
|
||||
|
||||
static int WASAPI_OpenDevice(SDL_AudioDevice *device)
|
||||
static bool WASAPI_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
// Initialize all variables that we clean on shutdown
|
||||
device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
|
||||
if (!device->hidden) {
|
||||
return -1;
|
||||
} else if (ActivateWasapiDevice(device) < 0) {
|
||||
return -1; // already set error.
|
||||
return false;
|
||||
} else if (!ActivateWasapiDevice(device)) {
|
||||
return false; // already set error.
|
||||
}
|
||||
|
||||
/* Ready, but possibly waiting for async device activation.
|
||||
@ -780,7 +780,7 @@ static int WASAPI_OpenDevice(SDL_AudioDevice *device)
|
||||
devices and ignore data on playback devices. Upon activation, we'll make
|
||||
sure any bound audio streams are adjusted for the final device format. */
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void WASAPI_ThreadInit(SDL_AudioDevice *device)
|
||||
@ -793,27 +793,27 @@ static void WASAPI_ThreadDeinit(SDL_AudioDevice *device)
|
||||
WASAPI_PlatformThreadDeinit(device);
|
||||
}
|
||||
|
||||
static int mgmtthrtask_FreeDeviceHandle(void *userdata)
|
||||
static bool mgmtthrtask_FreeDeviceHandle(void *userdata)
|
||||
{
|
||||
WASAPI_PlatformFreeDeviceHandle((SDL_AudioDevice *)userdata);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void WASAPI_FreeDeviceHandle(SDL_AudioDevice *device)
|
||||
{
|
||||
int rc;
|
||||
bool rc;
|
||||
WASAPI_ProxyToManagementThread(mgmtthrtask_FreeDeviceHandle, device, &rc);
|
||||
}
|
||||
|
||||
static int mgmtthrtask_DeinitializeStart(void *userdata)
|
||||
static bool mgmtthrtask_DeinitializeStart(void *userdata)
|
||||
{
|
||||
WASAPI_PlatformDeinitializeStart();
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void WASAPI_DeinitializeStart(void)
|
||||
{
|
||||
int rc;
|
||||
bool rc;
|
||||
WASAPI_ProxyToManagementThread(mgmtthrtask_DeinitializeStart, NULL, &rc);
|
||||
}
|
||||
|
||||
@ -824,7 +824,7 @@ static void WASAPI_Deinitialize(void)
|
||||
|
||||
static bool WASAPI_Init(SDL_AudioDriverImpl *impl)
|
||||
{
|
||||
if (InitManagementThread() < 0) {
|
||||
if (!InitManagementThread()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user