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:
Sam Lantinga
2024-08-22 17:33:49 -07:00
parent d9a5ed75b9
commit 9ff3446f03
726 changed files with 11062 additions and 11472 deletions

View File

@@ -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);
}

View File

@@ -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 {

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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++

View File

@@ -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)

View File

@@ -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);

View File

@@ -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, ...)

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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://"

View 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

View File

@@ -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 ? &current_audio.recording_device_count : &current_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.

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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_

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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;

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -46,21 +46,21 @@ struct SDL_PrivateAudioData
};
// win32 and winrt implementations call into these.
int WASAPI_PrepDevice(SDL_AudioDevice *device);
bool WASAPI_PrepDevice(SDL_AudioDevice *device);
void WASAPI_DisconnectDevice(SDL_AudioDevice *device); // don't hold the device lock when calling this!
// BE CAREFUL: if you are holding the device lock and proxy to the management thread with wait_until_complete, and grab the lock again, you will deadlock.
typedef int (*ManagementThreadTask)(void *userdata);
int WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, int *wait_until_complete);
typedef bool (*ManagementThreadTask)(void *userdata);
bool WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, bool *wait_until_complete);
// These are functions that are implemented differently for Windows vs WinRT.
// UNLESS OTHERWISE NOTED THESE ALL HAPPEN ON THE MANAGEMENT THREAD.
int WASAPI_PlatformInit(void);
bool WASAPI_PlatformInit(void);
void WASAPI_PlatformDeinit(void);
void WASAPI_PlatformDeinitializeStart(void);
void WASAPI_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording);
int WASAPI_ActivateDevice(SDL_AudioDevice *device);
bool WASAPI_ActivateDevice(SDL_AudioDevice *device);
void WASAPI_PlatformThreadInit(SDL_AudioDevice *device); // this happens on the audio device thread, not the management thread.
void WASAPI_PlatformThreadDeinit(SDL_AudioDevice *device); // this happens on the audio device thread, not the management thread.
void WASAPI_PlatformDeleteActivationHandler(void *handler);

View File

@@ -48,12 +48,12 @@ static bool immdevice_initialized = false;
// Some GUIDs we need to know without linking to libraries that aren't available before Vista.
static const IID SDL_IID_IAudioClient = { 0x1cb9ad4c, 0xdbfa, 0x4c32, { 0xb1, 0x78, 0xc2, 0xf5, 0x68, 0xa7, 0x03, 0xb2 } };
static int mgmtthrtask_AudioDeviceDisconnected(void *userdata)
static bool mgmtthrtask_AudioDeviceDisconnected(void *userdata)
{
SDL_AudioDevice *device = (SDL_AudioDevice *) userdata;
SDL_AudioDeviceDisconnected(device);
UnrefPhysicalAudioDevice(device); // make sure this lived until the task completes.
return 0;
return true;
}
static void WASAPI_AudioDeviceDisconnected(SDL_AudioDevice *device)
@@ -65,12 +65,12 @@ static void WASAPI_AudioDeviceDisconnected(SDL_AudioDevice *device)
}
}
static int mgmtthrtask_DefaultAudioDeviceChanged(void *userdata)
static bool mgmtthrtask_DefaultAudioDeviceChanged(void *userdata)
{
SDL_AudioDevice *device = (SDL_AudioDevice *) userdata;
SDL_DefaultAudioDeviceChanged(device);
UnrefPhysicalAudioDevice(device); // make sure this lived until the task completes.
return 0;
return true;
}
static void WASAPI_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device)
@@ -82,13 +82,13 @@ static void WASAPI_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device
}
}
int WASAPI_PlatformInit(void)
bool WASAPI_PlatformInit(void)
{
const SDL_IMMDevice_callbacks callbacks = { WASAPI_AudioDeviceDisconnected, WASAPI_DefaultAudioDeviceChanged };
if (FAILED(WIN_CoInitialize())) {
return SDL_SetError("CoInitialize() failed");
} else if (SDL_IMMDevice_Init(&callbacks) < 0) {
return -1; // Error string is set by SDL_IMMDevice_Init
} else if (!SDL_IMMDevice_Init(&callbacks)) {
return false; // Error string is set by SDL_IMMDevice_Init
}
immdevice_initialized = true;
@@ -99,7 +99,7 @@ int WASAPI_PlatformInit(void)
pAvRevertMmThreadCharacteristics = (pfnAvRevertMmThreadCharacteristics)GetProcAddress(libavrt, "AvRevertMmThreadCharacteristics");
}
return 0;
return true;
}
static void StopWasapiHotplug(void)
@@ -161,12 +161,12 @@ void WASAPI_PlatformThreadDeinit(SDL_AudioDevice *device)
}
}
int WASAPI_ActivateDevice(SDL_AudioDevice *device)
bool WASAPI_ActivateDevice(SDL_AudioDevice *device)
{
IMMDevice *immdevice = NULL;
if (SDL_IMMDevice_Get(device, &immdevice, device->recording) < 0) {
if (!SDL_IMMDevice_Get(device, &immdevice, device->recording)) {
device->hidden->client = NULL;
return -1; // This is already set by SDL_IMMDevice_Get
return false; // This is already set by SDL_IMMDevice_Get
}
// this is _not_ async in standard win32, yay!
@@ -179,11 +179,11 @@ int WASAPI_ActivateDevice(SDL_AudioDevice *device)
}
SDL_assert(device->hidden->client != NULL);
if (WASAPI_PrepDevice(device) < 0) { // not async, fire it right away.
return -1;
if (!WASAPI_PrepDevice(device)) { // not async, fire it right away.
return false;
}
return 0; // good to go.
return true; // good to go.
}
void WASAPI_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)

View File

@@ -214,9 +214,9 @@ void SDL_WasapiDeviceEventHandler::WaitForCompletion()
static SDL_WasapiDeviceEventHandler *playback_device_event_handler;
static SDL_WasapiDeviceEventHandler *recording_device_event_handler;
int WASAPI_PlatformInit(void)
bool WASAPI_PlatformInit(void)
{
return 0;
return true;
}
static void StopWasapiHotplug(void)
@@ -292,7 +292,7 @@ void WASAPI_PlatformDeleteActivationHandler(void *handler)
((SDL_WasapiActivationHandler *)handler)->Release();
}
int WASAPI_ActivateDevice(SDL_AudioDevice *device)
bool WASAPI_ActivateDevice(SDL_AudioDevice *device)
{
LPCWSTR devid = (LPCWSTR) device->handle;
SDL_assert(devid != NULL);
@@ -334,11 +334,11 @@ int WASAPI_ActivateDevice(SDL_AudioDevice *device)
return SDL_SetError("Failed to query WASAPI client interface");
}
if (WASAPI_PrepDevice(device) == -1) {
return -1;
if (!WASAPI_PrepDevice(device)) {
return false;
}
return 0;
return true;
}
void WASAPI_PlatformThreadInit(SDL_AudioDevice *device)

View File

@@ -82,14 +82,14 @@ char *SDL_GetCameraThreadName(SDL_Camera *device, char *buf, size_t buflen)
return buf;
}
int SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormat format, SDL_Colorspace colorspace, int w, int h, int framerate_numerator, int framerate_denominator)
bool SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormat format, SDL_Colorspace colorspace, int w, int h, int framerate_numerator, int framerate_denominator)
{
SDL_assert(data != NULL);
if (data->allocated_specs <= data->num_specs) {
const int newalloc = data->allocated_specs ? (data->allocated_specs * 2) : 16;
void *ptr = SDL_realloc(data->specs, sizeof (SDL_CameraSpec) * newalloc);
if (!ptr) {
return -1;
return false;
}
data->specs = (SDL_CameraSpec *) ptr;
data->allocated_specs = newalloc;
@@ -105,7 +105,7 @@ int SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormat format, SDL_C
data->num_specs++;
return 0;
return true;
}
@@ -113,14 +113,14 @@ int SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormat format, SDL_C
// These get used when a device is disconnected or fails. Apps that ignore the
// loss notifications will get black frames but otherwise keep functioning.
static int ZombieWaitDevice(SDL_Camera *device)
static bool ZombieWaitDevice(SDL_Camera *device)
{
if (!SDL_AtomicGet(&device->shutdown)) {
// !!! FIXME: this is bad for several reasons (uses double, could be precalculated, doesn't track elasped time).
const double duration = ((double) device->actual_spec.framerate_denominator / ((double) device->actual_spec.framerate_numerator));
SDL_Delay((Uint32) (duration * 1000.0));
}
return 0;
return true;
}
static size_t GetFrameBufLen(const SDL_CameraSpec *spec)
@@ -145,7 +145,7 @@ static size_t GetFrameBufLen(const SDL_CameraSpec *spec)
return wxh * SDL_BYTESPERPIXEL(fmt);
}
static int ZombieAcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
static SDL_CameraFrameResult ZombieAcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
{
const SDL_CameraSpec *spec = &device->actual_spec;
@@ -155,7 +155,7 @@ static int ZombieAcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *ti
device->zombie_pixels = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), buflen);
if (!device->zombie_pixels) {
*timestampNS = 0;
return 0; // oh well, say there isn't a frame yet, so we'll go back to waiting. Maybe allocation will succeed later...?
return SDL_CAMERA_FRAME_SKIP; // oh well, say there isn't a frame yet, so we'll go back to waiting. Maybe allocation will succeed later...?
}
Uint8 *dst = device->zombie_pixels;
@@ -212,7 +212,7 @@ static int ZombieAcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *ti
SDL_Log("CAMERA: dev[%p] Acquired Zombie frame, timestamp %llu", device, (unsigned long long) *timestampNS);
#endif
return 1; // frame is available.
return SDL_CAMERA_FRAME_READY; // frame is available.
}
static void ZombieReleaseFrame(SDL_Camera *device, SDL_Surface *frame) // Reclaim frame->pixels and frame->pitch!
@@ -650,8 +650,10 @@ void SDL_CloseCamera(SDL_Camera *camera)
ClosePhysicalCamera(device);
}
int SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec)
SDL_bool SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec)
{
bool result;
if (!camera) {
return SDL_InvalidParamError("camera");
} else if (!spec) {
@@ -660,36 +662,38 @@ int SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec)
SDL_Camera *device = (SDL_Camera *) camera; // currently there's no separation between physical and logical device.
ObtainPhysicalCameraObj(device);
const int retval = (device->permission > 0) ? 0 : SDL_SetError("Camera permission has not been granted");
if (retval == 0) {
if (device->permission > 0) {
SDL_copyp(spec, &device->spec);
result = true;
} else {
SDL_zerop(spec);
result = SDL_SetError("Camera permission has not been granted");
}
ReleaseCamera(device);
return 0;
return result;
}
const char *SDL_GetCameraName(SDL_CameraID instance_id)
{
const char *retval = NULL;
const char *result = NULL;
SDL_Camera *device = ObtainPhysicalCamera(instance_id);
if (device) {
retval = SDL_GetPersistentString(device->name);
result = SDL_GetPersistentString(device->name);
ReleaseCamera(device);
}
return retval;
return result;
}
SDL_CameraPosition SDL_GetCameraPosition(SDL_CameraID instance_id)
{
SDL_CameraPosition retval = SDL_CAMERA_POSITION_UNKNOWN;
SDL_CameraPosition result = SDL_CAMERA_POSITION_UNKNOWN;
SDL_Camera *device = ObtainPhysicalCamera(instance_id);
if (device) {
retval = device->position;
result = device->position;
ReleaseCamera(device);
}
return retval;
return result;
}
@@ -706,12 +710,12 @@ SDL_CameraID *SDL_GetCameras(int *count)
return NULL;
}
SDL_CameraID *retval = NULL;
SDL_CameraID *result = NULL;
SDL_LockRWLockForReading(camera_driver.device_hash_lock);
int num_devices = SDL_AtomicGet(&camera_driver.device_count);
retval = (SDL_CameraID *) SDL_malloc((num_devices + 1) * sizeof (SDL_CameraID));
if (!retval) {
result = (SDL_CameraID *) SDL_malloc((num_devices + 1) * sizeof (SDL_CameraID));
if (!result) {
num_devices = 0;
} else {
int devs_seen = 0;
@@ -719,17 +723,17 @@ SDL_CameraID *SDL_GetCameras(int *count)
const void *value;
void *iter = NULL;
while (SDL_IterateHashTable(camera_driver.device_hash, &key, &value, &iter)) {
retval[devs_seen++] = (SDL_CameraID) (uintptr_t) key;
result[devs_seen++] = (SDL_CameraID) (uintptr_t) key;
}
SDL_assert(devs_seen == num_devices);
retval[devs_seen] = 0; // null-terminated.
result[devs_seen] = 0; // null-terminated.
}
SDL_UnlockRWLock(camera_driver.device_hash_lock);
*count = num_devices;
return retval;
return result;
}
SDL_CameraSpec **SDL_GetCameraSupportedFormats(SDL_CameraID instance_id, int *count)
@@ -745,14 +749,14 @@ SDL_CameraSpec **SDL_GetCameraSupportedFormats(SDL_CameraID instance_id, int *co
int i;
int num_specs = device->num_specs;
SDL_CameraSpec **retval = (SDL_CameraSpec **) SDL_malloc(((num_specs + 1) * sizeof(*retval)) + (num_specs * sizeof (**retval)));
if (retval) {
SDL_CameraSpec *specs = (SDL_CameraSpec *)(retval + (num_specs + 1));
SDL_CameraSpec **result = (SDL_CameraSpec **) SDL_malloc(((num_specs + 1) * sizeof(*result)) + (num_specs * sizeof (**result)));
if (result) {
SDL_CameraSpec *specs = (SDL_CameraSpec *)(result + (num_specs + 1));
SDL_memcpy(specs, device->all_specs, num_specs * sizeof(*specs));
for (i = 0; i < num_specs; ++i) {
retval[i] = specs++;
result[i] = specs++;
}
retval[i] = NULL;
result[i] = NULL;
if (count) {
*count = num_specs;
@@ -761,7 +765,7 @@ SDL_CameraSpec **SDL_GetCameraSupportedFormats(SDL_CameraID instance_id, int *co
ReleaseCamera(device);
return retval;
return result;
}
@@ -806,9 +810,9 @@ bool SDL_CameraThreadIterate(SDL_Camera *device)
Uint64 timestampNS = 0;
// AcquireFrame SHOULD NOT BLOCK, as we are holding a lock right now. Block in WaitDevice instead!
const int rc = device->AcquireFrame(device, device->acquire_surface, &timestampNS);
const SDL_CameraFrameResult rc = device->AcquireFrame(device, device->acquire_surface, &timestampNS);
if (rc == 1) { // new frame acquired!
if (rc == SDL_CAMERA_FRAME_READY) { // new frame acquired!
#if DEBUG_CAMERA
SDL_Log("CAMERA: New frame available! pixels=%p pitch=%d", device->acquire_surface->pixels, device->acquire_surface->pitch);
#endif
@@ -842,12 +846,11 @@ bool SDL_CameraThreadIterate(SDL_Camera *device)
acquired = device->acquire_surface;
slist->timestampNS = timestampNS;
}
} else if (rc == 0) { // no frame available yet; not an error.
} else if (rc == SDL_CAMERA_FRAME_SKIP) { // no frame available yet; not an error.
#if 0 //DEBUG_CAMERA
SDL_Log("CAMERA: No frame available yet.");
#endif
} else { // fatal error!
SDL_assert(rc == -1);
#if DEBUG_CAMERA
SDL_Log("CAMERA: dev[%p] error AcquireFrame: %s", device, SDL_GetError());
#endif
@@ -931,7 +934,7 @@ static int SDLCALL CameraThread(void *devicep)
SDL_CameraThreadSetup(device);
do {
if (device->WaitDevice(device) < 0) {
if (!device->WaitDevice(device)) {
SDL_CameraDisconnected(device); // doh. (but don't break out of the loop, just be a zombie for now!)
}
} while (SDL_CameraThreadIterate(device));
@@ -1091,7 +1094,7 @@ SDL_Camera *SDL_OpenCamera(SDL_CameraID instance_id, const SDL_CameraSpec *spec)
closest.width, closest.height, SDL_GetPixelFormatName(closest.format), closest.framerate_numerator, closest.framerate_denominator);
#endif
if (camera_driver.impl.OpenDevice(device, &closest) < 0) {
if (!camera_driver.impl.OpenDevice(device, &closest)) {
ClosePhysicalCamera(device); // in case anything is half-initialized.
ReleaseCamera(device);
return NULL;
@@ -1219,7 +1222,7 @@ SDL_Surface *SDL_AcquireCameraFrame(SDL_Camera *camera, Uint64 *timestampNS)
return NULL;
}
SDL_Surface *retval = NULL;
SDL_Surface *result = NULL;
// frames are in this list from newest to oldest, so find the end of the list...
SurfaceList *slistprev = &device->filled_output_surfaces;
@@ -1234,7 +1237,7 @@ SDL_Surface *SDL_AcquireCameraFrame(SDL_Camera *camera, Uint64 *timestampNS)
if (timestampNS) {
*timestampNS = slist->timestampNS;
}
retval = slist->surface;
result = slist->surface;
slistprev->next = slist->next; // remove from filled list.
slist->next = device->app_held_output_surfaces.next; // add to app_held list.
device->app_held_output_surfaces.next = slist;
@@ -1242,15 +1245,13 @@ SDL_Surface *SDL_AcquireCameraFrame(SDL_Camera *camera, Uint64 *timestampNS)
ReleaseCamera(device);
return retval;
return result;
}
int SDL_ReleaseCameraFrame(SDL_Camera *camera, SDL_Surface *frame)
void SDL_ReleaseCameraFrame(SDL_Camera *camera, SDL_Surface *frame)
{
if (!camera) {
return SDL_InvalidParamError("camera");
} else if (frame == NULL) {
return SDL_InvalidParamError("frame");
if (!camera || !frame) {
return;
}
SDL_Camera *device = (SDL_Camera *) camera; // currently there's no separation between physical and logical device.
@@ -1267,7 +1268,7 @@ int SDL_ReleaseCameraFrame(SDL_Camera *camera, SDL_Surface *frame)
if (!slist) {
ReleaseCamera(device);
return SDL_SetError("Surface was not acquired from this camera, or was already released");
return;
}
// this pointer was owned by the backend (DMA memory or whatever), clear it out.
@@ -1287,28 +1288,26 @@ int SDL_ReleaseCameraFrame(SDL_Camera *camera, SDL_Surface *frame)
device->empty_output_surfaces.next = slist;
ReleaseCamera(device);
return 0;
}
SDL_CameraID SDL_GetCameraID(SDL_Camera *camera)
{
SDL_CameraID retval = 0;
SDL_CameraID result = 0;
if (!camera) {
SDL_InvalidParamError("camera");
} else {
SDL_Camera *device = (SDL_Camera *) camera; // currently there's no separation between physical and logical device.
ObtainPhysicalCameraObj(device);
retval = device->instance_id;
result = device->instance_id;
ReleaseCamera(device);
}
return retval;
return result;
}
SDL_PropertiesID SDL_GetCameraProperties(SDL_Camera *camera)
{
SDL_PropertiesID retval = 0;
SDL_PropertiesID result = 0;
if (!camera) {
SDL_InvalidParamError("camera");
} else {
@@ -1317,26 +1316,26 @@ SDL_PropertiesID SDL_GetCameraProperties(SDL_Camera *camera)
if (device->props == 0) {
device->props = SDL_CreateProperties();
}
retval = device->props;
result = device->props;
ReleaseCamera(device);
}
return retval;
return result;
}
int SDL_GetCameraPermissionState(SDL_Camera *camera)
{
int retval;
int result;
if (!camera) {
retval = SDL_InvalidParamError("camera");
SDL_InvalidParamError("camera");
result = -1;
} else {
SDL_Camera *device = (SDL_Camera *) camera; // currently there's no separation between physical and logical device.
ObtainPhysicalCameraObj(device);
retval = device->permission;
result = device->permission;
ReleaseCamera(device);
}
return retval;
return result;
}
@@ -1408,7 +1407,7 @@ static void NukeCameraHashItem(const void *key, const void *value, void *data)
// no-op, keys and values in this hashtable are treated as Plain Old Data and don't get freed here.
}
int SDL_CameraInit(const char *driver_name)
SDL_bool SDL_CameraInit(const char *driver_name)
{
if (SDL_GetCurrentCameraDriver()) {
SDL_QuitCamera(); // shutdown driver if already running.
@@ -1416,13 +1415,13 @@ int SDL_CameraInit(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 camera subsystem.
if (!device_hash_lock) {
return -1;
return false;
}
SDL_HashTable *device_hash = SDL_CreateHashTable(NULL, 8, HashCameraID, MatchCameraID, NukeCameraHashItem, false);
if (!device_hash) {
SDL_DestroyRWLock(device_hash_lock);
return -1;
return false;
}
// Select the proper camera driver
@@ -1440,7 +1439,7 @@ int SDL_CameraInit(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) {
@@ -1501,7 +1500,7 @@ int SDL_CameraInit(const char *driver_name)
SDL_zero(camera_driver);
SDL_DestroyRWLock(device_hash_lock);
SDL_DestroyHashTable(device_hash);
return -1; // No driver was available, so fail.
return false; // No driver was available, so fail.
}
CompleteCameraEntryPoints();
@@ -1509,7 +1508,7 @@ int SDL_CameraInit(const char *driver_name)
// Make sure we have a list of devices available at startup...
camera_driver.impl.DetectDevices();
return 0;
return true;
}
// This is an internal function, so SDL_PumpEvents() can check for pending camera device events.

View File

@@ -24,10 +24,10 @@
#define SDL_camera_c_h_
// Initialize the camera subsystem
int SDL_CameraInit(const char *driver_name);
extern SDL_bool SDL_CameraInit(const char *driver_name);
// Shutdown the camera subsystem
void SDL_QuitCamera(void);
extern void SDL_QuitCamera(void);
// "Pump" the event queue.
extern void SDL_UpdateCamera(void);

View File

@@ -64,7 +64,14 @@ typedef struct CameraFormatAddData
int allocated_specs;
} CameraFormatAddData;
int SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormat format, SDL_Colorspace colorspace, int w, int h, int framerate_numerator, int framerate_denominator);
bool SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormat format, SDL_Colorspace colorspace, int w, int h, int framerate_numerator, int framerate_denominator);
typedef enum SDL_CameraFrameResult
{
SDL_CAMERA_FRAME_ERROR,
SDL_CAMERA_FRAME_SKIP,
SDL_CAMERA_FRAME_READY
} SDL_CameraFrameResult;
typedef struct SurfaceList
{
@@ -89,8 +96,8 @@ struct SDL_Camera
SDL_AtomicInt refcount;
// These are, initially, set from camera_driver, but we might swap them out with Zombie versions on disconnect/failure.
int (*WaitDevice)(SDL_Camera *device);
int (*AcquireFrame)(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS);
bool (*WaitDevice)(SDL_Camera *device);
SDL_CameraFrameResult (*AcquireFrame)(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS);
void (*ReleaseFrame)(SDL_Camera *device, SDL_Surface *frame);
// All supported formats/dimensions for this device.
@@ -161,10 +168,10 @@ struct SDL_Camera
typedef struct SDL_CameraDriverImpl
{
void (*DetectDevices)(void);
int (*OpenDevice)(SDL_Camera *device, const SDL_CameraSpec *spec);
bool (*OpenDevice)(SDL_Camera *device, const SDL_CameraSpec *spec);
void (*CloseDevice)(SDL_Camera *device);
int (*WaitDevice)(SDL_Camera *device);
int (*AcquireFrame)(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS); // set frame->pixels, frame->pitch, and *timestampNS!
bool (*WaitDevice)(SDL_Camera *device);
SDL_CameraFrameResult (*AcquireFrame)(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS); // set frame->pixels, frame->pitch, and *timestampNS!
void (*ReleaseFrame)(SDL_Camera *device, SDL_Surface *frame); // Reclaim frame->pixels and frame->pitch!
void (*FreeDeviceHandle)(SDL_Camera *device); // SDL is done with this device; free the handle from SDL_AddCamera()
void (*Deinitialize)(void);

View File

@@ -150,7 +150,7 @@ struct SDL_PrivateCameraData
SDL_CameraSpec requested_spec;
};
static int SetErrorStr(const char *what, const char *errstr, const int rc)
static bool SetErrorStr(const char *what, const char *errstr, const int rc)
{
char errbuf[128];
if (!errstr) {
@@ -185,7 +185,7 @@ static const char *CameraStatusStr(const camera_status_t rc)
return NULL; // unknown error
}
static int SetCameraError(const char *what, const camera_status_t rc)
static bool SetCameraError(const char *what, const camera_status_t rc)
{
return SetErrorStr(what, CameraStatusStr(rc), (int) rc);
}
@@ -225,7 +225,7 @@ static const char *MediaStatusStr(const media_status_t rc)
return NULL; // unknown error
}
static int SetMediaError(const char *what, const media_status_t rc)
static bool SetMediaError(const char *what, const media_status_t rc)
{
return SetErrorStr(what, MediaStatusStr(rc), (int) rc);
}
@@ -233,7 +233,7 @@ static int SetMediaError(const char *what, const media_status_t rc)
static ACameraManager *cameraMgr = NULL;
static int CreateCameraManager(void)
static bool CreateCameraManager(void)
{
SDL_assert(cameraMgr == NULL);
@@ -241,7 +241,7 @@ static int CreateCameraManager(void)
if (!cameraMgr) {
return SDL_SetError("Error creating ACameraManager");
}
return 0;
return true;
}
static void DestroyCameraManager(void)
@@ -289,14 +289,14 @@ static Uint32 format_sdl_to_android(SDL_PixelFormat fmt)
}
}
static int ANDROIDCAMERA_WaitDevice(SDL_Camera *device)
static bool ANDROIDCAMERA_WaitDevice(SDL_Camera *device)
{
return 0; // this isn't used atm, since we run our own thread via onImageAvailable callbacks.
return true; // this isn't used atm, since we run our own thread via onImageAvailable callbacks.
}
static int ANDROIDCAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
static SDL_CameraFrameResult ANDROIDCAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
{
int retval = 1;
SDL_CameraFrameResult result = SDL_CAMERA_FRAME_READY;
media_status_t res;
AImage *image = NULL;
@@ -307,7 +307,8 @@ static int ANDROIDCAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Ui
SDL_assert(res != AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE); // we should only be here if onImageAvailable was called.
if (res != AMEDIA_OK) {
return SetMediaError("Error AImageReader_acquireNextImage", res);
SetMediaError("Error AImageReader_acquireNextImage", res);
return SDL_CAMERA_FRAME_ERROR;
}
int64_t atimestamp = 0;
@@ -336,7 +337,7 @@ static int ANDROIDCAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Ui
frame->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), buflen);
if (frame->pixels == NULL) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
int32_t row_stride = 0;
Uint8 *dst = frame->pixels;
@@ -355,7 +356,7 @@ static int ANDROIDCAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Ui
pAImage_delete(image);
return retval;
return result;
}
static void ANDROIDCAMERA_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
@@ -458,7 +459,7 @@ static void ANDROIDCAMERA_CloseDevice(SDL_Camera *device)
}
// this is where the "opening" of the camera happens, after permission is granted.
static int PrepareCamera(SDL_Camera *device)
static bool PrepareCamera(SDL_Camera *device)
{
SDL_assert(device->hidden != NULL);
@@ -512,7 +513,7 @@ static int PrepareCamera(SDL_Camera *device)
return SetMediaError("Error AImageReader_setImageListener", res2);
}
return 0;
return true;
}
static void SDLCALL CameraPermissionCallback(void *userdata, const char *permission, SDL_bool granted)
@@ -521,7 +522,7 @@ static void SDLCALL CameraPermissionCallback(void *userdata, const char *permiss
if (device->hidden != NULL) { // if device was already closed, don't send an event.
if (!granted) {
SDL_CameraPermissionOutcome(device, false); // sorry, permission denied.
} else if (PrepareCamera(device) < 0) { // permission given? Actually open the camera now.
} else if (!PrepareCamera(device)) { // permission given? Actually open the camera now.
// uhoh, setup failed; since the app thinks we already "opened" the device, mark it as disconnected and don't report the permission.
SDL_CameraDisconnected(device);
} else {
@@ -534,7 +535,7 @@ static void SDLCALL CameraPermissionCallback(void *userdata, const char *permiss
}
static int ANDROIDCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
static bool ANDROIDCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
{
#if 0 // !!! FIXME: for now, we'll just let this fail if it is going to fail, without checking for this
/* Cannot open a second camera, while the first one is opened.
@@ -552,19 +553,19 @@ static int ANDROIDCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *sp
device->hidden = (struct SDL_PrivateCameraData *) SDL_calloc(1, sizeof (struct SDL_PrivateCameraData));
if (device->hidden == NULL) {
return -1;
return false;
}
RefPhysicalCamera(device); // ref'd until permission callback fires.
// just in case SDL_OpenCamera is overwriting device->spec as CameraPermissionCallback runs, we work from a different copy.
SDL_copyp(&device->hidden->requested_spec, spec);
if (SDL_RequestAndroidPermission("android.permission.CAMERA", CameraPermissionCallback, device) < 0) {
if (!SDL_RequestAndroidPermission("android.permission.CAMERA", CameraPermissionCallback, device)) {
UnrefPhysicalCamera(device);
return -1;
return false;
}
return 0; // we don't open the camera until permission is granted, so always succeed for now.
return true; // we don't open the camera until permission is granted, so always succeed for now.
}
static void ANDROIDCAMERA_FreeDeviceHandle(SDL_Camera *device)
@@ -864,7 +865,7 @@ static bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl)
dlclose(libcamera2);
}
if (CreateCameraManager() < 0) {
if (!CreateCameraManager()) {
dlclose(libmedia);
dlclose(libcamera2);
return false;

View File

@@ -141,14 +141,14 @@ static bool CheckCameraPermissions(SDL_Camera *device)
}
@end
static int COREMEDIA_WaitDevice(SDL_Camera *device)
static bool COREMEDIA_WaitDevice(SDL_Camera *device)
{
return 0; // this isn't used atm, since we run our own thread out of Grand Central Dispatch.
return true; // this isn't used atm, since we run our own thread out of Grand Central Dispatch.
}
static int COREMEDIA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
static SDL_CameraFrameResult COREMEDIA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
{
int retval = 1;
SDL_CameraFrameResult result = SDL_CAMERA_FRAME_READY;
SDLPrivateCameraData *hidden = (__bridge SDLPrivateCameraData *) device->hidden;
CMSampleBufferRef sample_buffer = hidden.current_sample;
hidden.current_sample = NULL;
@@ -185,7 +185,7 @@ static int COREMEDIA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64
const size_t buflen = pitch * frame->h;
frame->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), buflen);
if (frame->pixels == NULL) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
frame->pitch = pitch;
SDL_memcpy(frame->pixels, CVPixelBufferGetBaseAddress(image), buflen);
@@ -203,7 +203,7 @@ static int COREMEDIA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64
frame->pitch = (int)CVPixelBufferGetBytesPerRowOfPlane(image, 0); // this is what SDL3 currently expects
frame->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), buflen);
if (frame->pixels == NULL) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
Uint8 *dst = frame->pixels;
for (int i = 0; i < numPlanes; i++) {
@@ -219,7 +219,7 @@ static int COREMEDIA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64
CVPixelBufferUnlockBaseAddress(image, 0);
return retval;
return result;
}
static void COREMEDIA_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
@@ -248,7 +248,7 @@ static void COREMEDIA_CloseDevice(SDL_Camera *device)
}
}
static int COREMEDIA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
static bool COREMEDIA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
{
AVCaptureDevice *avdevice = (__bridge AVCaptureDevice *) device->handle;
@@ -364,7 +364,7 @@ static int COREMEDIA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
CheckCameraPermissions(device); // check right away, in case the process is already granted permission.
return 0;
return true;
}
static void COREMEDIA_FreeDeviceHandle(SDL_Camera *device)

View File

@@ -24,7 +24,7 @@
#include "../SDL_syscamera.h"
static int DUMMYCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
static bool DUMMYCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
{
return SDL_Unsupported();
}
@@ -33,14 +33,15 @@ static void DUMMYCAMERA_CloseDevice(SDL_Camera *device)
{
}
static int DUMMYCAMERA_WaitDevice(SDL_Camera *device)
static bool DUMMYCAMERA_WaitDevice(SDL_Camera *device)
{
return SDL_Unsupported();
}
static int DUMMYCAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
static SDL_CameraFrameResult DUMMYCAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
{
return SDL_Unsupported();
SDL_Unsupported();
return SDL_CAMERA_FRAME_ERROR;
}
static void DUMMYCAMERA_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)

View File

@@ -34,17 +34,17 @@
EM_JS_DEPS(sdlcamera, "$dynCall");
static int EMSCRIPTENCAMERA_WaitDevice(SDL_Camera *device)
static bool EMSCRIPTENCAMERA_WaitDevice(SDL_Camera *device)
{
SDL_assert(!"This shouldn't be called"); // we aren't using SDL's internal thread.
return -1;
return false;
}
static int EMSCRIPTENCAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
static SDL_CameraFrameResult EMSCRIPTENCAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
{
void *rgba = SDL_malloc(device->actual_spec.width * device->actual_spec.height * 4);
if (!rgba) {
return -1;
return SDL_CAMERA_FRAME_ERROR;
}
*timestampNS = SDL_GetTicksNS(); // best we can do here.
@@ -67,13 +67,13 @@ static int EMSCRIPTENCAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
if (!rc) {
SDL_free(rgba);
return 0; // something went wrong, maybe shutting down; just don't return a frame.
return SDL_CAMERA_FRAME_ERROR; // something went wrong, maybe shutting down; just don't return a frame.
}
frame->pixels = rgba;
frame->pitch = device->actual_spec.width * 4;
return 1;
return SDL_CAMERA_FRAME_READY;
}
static void EMSCRIPTENCAMERA_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
@@ -110,7 +110,7 @@ static void SDLEmscriptenCameraPermissionOutcome(SDL_Camera *device, int approve
SDL_CameraPermissionOutcome(device, approved ? true : false);
}
static int EMSCRIPTENCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
static bool EMSCRIPTENCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
{
MAIN_THREAD_EM_ASM({
// Since we can't get actual specs until we make a move that prompts the user for
@@ -203,7 +203,7 @@ static int EMSCRIPTENCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec
});
}, device, spec->width, spec->height, spec->framerate_numerator, spec->framerate_denominator, SDLEmscriptenCameraPermissionOutcome, SDL_CameraThreadIterate);
return 0; // the real work waits until the user approves a camera.
return true; // the real work waits until the user approves a camera.
}
static void EMSCRIPTENCAMERA_FreeDeviceHandle(SDL_Camera *device)

View File

@@ -347,7 +347,7 @@ typedef struct SDL_PrivateCameraData
int pitch;
} SDL_PrivateCameraData;
static int MEDIAFOUNDATION_WaitDevice(SDL_Camera *device)
static bool MEDIAFOUNDATION_WaitDevice(SDL_Camera *device)
{
SDL_assert(device->hidden->current_sample == NULL);
@@ -358,7 +358,7 @@ static int MEDIAFOUNDATION_WaitDevice(SDL_Camera *device)
DWORD stream_flags = 0;
const HRESULT ret = IMFSourceReader_ReadSample(srcreader, (DWORD)MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, NULL, &stream_flags, NULL, &sample);
if (FAILED(ret)) {
return -1; // ruh roh.
return false; // ruh roh.
}
// we currently ignore stream_flags format changes, but my _hope_ is that IMFSourceReader is handling this and
@@ -368,7 +368,7 @@ static int MEDIAFOUNDATION_WaitDevice(SDL_Camera *device)
if (sample != NULL) {
break;
} else if (stream_flags & (MF_SOURCE_READERF_ERROR | MF_SOURCE_READERF_ENDOFSTREAM)) {
return -1; // apparently this camera has gone down. :/
return false; // apparently this camera has gone down. :/
}
// otherwise, there was some minor burp, probably; just try again.
@@ -376,7 +376,7 @@ static int MEDIAFOUNDATION_WaitDevice(SDL_Camera *device)
device->hidden->current_sample = sample;
return 0;
return true;
}
@@ -421,17 +421,17 @@ static void SDLCALL CleanupIMFMediaBuffer(void *userdata, void *value)
SDL_free(objs);
}
static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
static SDL_CameraFrameResult MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
{
SDL_assert(device->hidden->current_sample != NULL);
int retval = 1;
SDL_CameraFrameResult result = SDL_CAMERA_FRAME_READY;
HRESULT ret;
LONGLONG timestamp100NS = 0;
SDL_IMFObjects *objs = (SDL_IMFObjects *) SDL_calloc(1, sizeof (SDL_IMFObjects));
if (objs == NULL) {
return -1;
return SDL_CAMERA_FRAME_ERROR;
}
objs->sample = device->hidden->current_sample;
@@ -439,21 +439,21 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
const SDL_PropertiesID surfprops = SDL_GetSurfaceProperties(frame);
if (!surfprops) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
ret = IMFSample_GetSampleTime(objs->sample, &timestamp100NS);
if (FAILED(ret)) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
}
*timestampNS = timestamp100NS * 100; // the timestamps are in 100-nanosecond increments; move to full nanoseconds.
}
ret = (retval < 0) ? E_FAIL : IMFSample_ConvertToContiguousBuffer(objs->sample, &objs->buffer); // IMFSample_GetBufferByIndex(objs->sample, 0, &objs->buffer);
ret = (result == SDL_CAMERA_FRAME_ERROR) ? E_FAIL : IMFSample_ConvertToContiguousBuffer(objs->sample, &objs->buffer); // IMFSample_GetBufferByIndex(objs->sample, 0, &objs->buffer);
if (FAILED(ret)) {
SDL_free(objs);
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
BYTE *pixels = NULL;
LONG pitch = 0;
@@ -463,25 +463,25 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
DWORD buflen = 0;
ret = IMF2DBuffer2_Lock2DSize(objs->buffer2d2, MF2DBuffer_LockFlags_Read, &pixels, &pitch, &bufstart, &buflen);
if (FAILED(ret)) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
CleanupIMF2DBuffer2(NULL, objs);
} else {
frame->pixels = pixels;
frame->pitch = (int) pitch;
if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMF2DBuffer2, NULL) < 0) {
retval = -1;
if (!SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMF2DBuffer2, NULL)) {
result = SDL_CAMERA_FRAME_ERROR;
}
}
} else if (SUCCEEDED(IMFMediaBuffer_QueryInterface(objs->buffer, &SDL_IID_IMF2DBuffer, (void **)&objs->buffer2d))) {
ret = IMF2DBuffer_Lock2D(objs->buffer2d, &pixels, &pitch);
if (FAILED(ret)) {
CleanupIMF2DBuffer(NULL, objs);
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
frame->pixels = pixels;
frame->pitch = (int) pitch;
if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMF2DBuffer, NULL) < 0) {
retval = -1;
if (!SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMF2DBuffer, NULL)) {
result = SDL_CAMERA_FRAME_ERROR;
}
}
} else {
@@ -489,7 +489,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
ret = IMFMediaBuffer_Lock(objs->buffer, &pixels, &maxlen, &currentlen);
if (FAILED(ret)) {
CleanupIMFMediaBuffer(NULL, objs);
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
pitch = (LONG) device->hidden->pitch;
if (pitch < 0) { // image rows are reversed.
@@ -497,18 +497,18 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
}
frame->pixels = pixels;
frame->pitch = (int) pitch;
if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMFMediaBuffer, NULL) < 0) {
retval = -1;
if (!SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMFMediaBuffer, NULL)) {
result = SDL_CAMERA_FRAME_ERROR;
}
}
}
}
if (retval < 0) {
if (result != SDL_CAMERA_FRAME_READY) {
*timestampNS = 0;
}
return retval;
return result;
}
static void MEDIAFOUNDATION_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
@@ -522,11 +522,11 @@ static void MEDIAFOUNDATION_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
#else
static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
static SDL_CameraFrameResult MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
{
SDL_assert(device->hidden->current_sample != NULL);
int retval = 1;
SDL_CameraFrameResult result = SDL_CAMERA_FRAME_READY;
HRESULT ret;
LONGLONG timestamp100NS = 0;
@@ -535,21 +535,21 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
const SDL_PropertiesID surfprops = SDL_GetSurfaceProperties(frame);
if (!surfprops) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
ret = IMFSample_GetSampleTime(sample, &timestamp100NS);
if (FAILED(ret)) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
}
*timestampNS = timestamp100NS * 100; // the timestamps are in 100-nanosecond increments; move to full nanoseconds.
}
IMFMediaBuffer *buffer = NULL;
ret = (retval < 0) ? E_FAIL : IMFSample_ConvertToContiguousBuffer(sample, &buffer); // IMFSample_GetBufferByIndex(sample, 0, &buffer);
ret = (result < 0) ? E_FAIL : IMFSample_ConvertToContiguousBuffer(sample, &buffer); // IMFSample_GetBufferByIndex(sample, 0, &buffer);
if (FAILED(ret)) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
IMF2DBuffer *buffer2d = NULL;
IMF2DBuffer2 *buffer2d2 = NULL;
@@ -561,11 +561,11 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
DWORD buflen = 0;
ret = IMF2DBuffer2_Lock2DSize(buffer2d2, MF2DBuffer_LockFlags_Read, &pixels, &pitch, &bufstart, &buflen);
if (FAILED(ret)) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
frame->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), buflen);
if (frame->pixels == NULL) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
SDL_memcpy(frame->pixels, pixels, buflen);
frame->pitch = (int)pitch;
@@ -576,7 +576,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
} else if (SUCCEEDED(IMFMediaBuffer_QueryInterface(buffer, &SDL_IID_IMF2DBuffer, (void **)&buffer2d))) {
ret = IMF2DBuffer_Lock2D(buffer2d, &pixels, &pitch);
if (FAILED(ret)) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
BYTE *bufstart = pixels;
const DWORD buflen = (SDL_abs((int)pitch) * frame->w) * frame->h;
@@ -585,7 +585,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
}
frame->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), buflen);
if (frame->pixels == NULL) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
SDL_memcpy(frame->pixels, bufstart, buflen);
frame->pitch = (int)pitch;
@@ -597,7 +597,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
DWORD maxlen = 0, currentlen = 0;
ret = IMFMediaBuffer_Lock(buffer, &pixels, &maxlen, &currentlen);
if (FAILED(ret)) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
BYTE *bufstart = pixels;
pitch = (LONG)device->hidden->pitch;
@@ -607,7 +607,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
}
frame->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), buflen);
if (frame->pixels == NULL) {
retval = -1;
result = SDL_CAMERA_FRAME_ERROR;
} else {
SDL_memcpy(frame->pixels, bufstart, buflen);
frame->pitch = (int)pitch;
@@ -620,11 +620,11 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
IMFSample_Release(sample);
if (retval < 0) {
if (result != SDL_CAMERA_FRAME_READY) {
*timestampNS = 0;
}
return retval;
return result;
}
static void MEDIAFOUNDATION_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
@@ -695,7 +695,7 @@ done:
}
static int MEDIAFOUNDATION_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
static bool MEDIAFOUNDATION_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
{
const char *utf8symlink = (const char *) device->handle;
IMFAttributes *attrs = NULL;
@@ -825,7 +825,7 @@ static int MEDIAFOUNDATION_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *
#undef CHECK_HRESULT
return 0;
return true;
failed:
@@ -861,7 +861,7 @@ failed:
}
SDL_free(wstrsymlink);
return -1;
return false;
}
static void MEDIAFOUNDATION_FreeDeviceHandle(SDL_Camera *device)

View File

@@ -86,8 +86,7 @@ static int (*PIPEWIRE_pw_core_disconnect)(struct pw_core *);
static struct pw_node_info * (*PIPEWIRE_pw_node_info_merge)(struct pw_node_info *info, const struct pw_node_info *update, bool reset);
static void (*PIPEWIRE_pw_node_info_free)(struct pw_node_info *info);
static struct pw_stream *(*PIPEWIRE_pw_stream_new)(struct pw_core *, const char *, struct pw_properties *);
static void (*PIPEWIRE_pw_stream_add_listener)(struct pw_stream *stream, struct spa_hook *listener,
const struct pw_stream_events *events, void *data);
static void (*PIPEWIRE_pw_stream_add_listener)(struct pw_stream *stream, struct spa_hook *listener, const struct pw_stream_events *events, void *data);
static void (*PIPEWIRE_pw_stream_destroy)(struct pw_stream *);
static int (*PIPEWIRE_pw_stream_connect)(struct pw_stream *, enum pw_direction, uint32_t, enum pw_stream_flags,
const struct spa_pod **, uint32_t);
@@ -104,26 +103,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; \
}
#define SDL_PIPEWIRE_SYM(x) \
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)
@@ -138,9 +136,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)
@@ -150,7 +148,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_check_library_version);
@@ -192,18 +190,18 @@ 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)
@@ -293,9 +291,9 @@ static uint32_t param_clear(struct spa_list *param_list, uint32_t id)
}
#if PW_CHECK_VERSION(0,3,60)
#define SPA_PARAMS_INFO_SEQ(p) ((p).seq)
#define SPA_PARAMS_INFO_SEQ(p) ((p).seq)
#else
#define SPA_PARAMS_INFO_SEQ(p) ((p).padding[0])
#define SPA_PARAMS_INFO_SEQ(p) ((p).padding[0])
#endif
static struct param *param_add(struct spa_list *params,
@@ -472,7 +470,7 @@ static const struct pw_stream_events stream_events = {
.process = on_process,
};
static int PIPEWIRECAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
static bool PIPEWIRECAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
{
struct pw_properties *props;
const struct spa_pod *params[3];
@@ -481,11 +479,11 @@ static int PIPEWIRECAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *s
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
if (!device) {
return -1;
return false;
}
device->hidden = (struct SDL_PrivateCameraData *) SDL_calloc(1, sizeof (struct SDL_PrivateCameraData));
if (device->hidden == NULL) {
return -1;
return false;
}
pw_array_init(&device->hidden->buffers, 64);
@@ -497,13 +495,12 @@ static int PIPEWIRECAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *s
PW_KEY_TARGET_OBJECT, device->name,
NULL);
if (props == NULL) {
return -1;
return false;
}
device->hidden->stream = PIPEWIRE_pw_stream_new(hotplug.core,
"SDL PipeWire Camera", props);
device->hidden->stream = PIPEWIRE_pw_stream_new(hotplug.core, "SDL PipeWire Camera", props);
if (device->hidden->stream == NULL) {
return -1;
return false;
}
PIPEWIRE_pw_stream_add_listener(device->hidden->stream,
@@ -525,12 +522,12 @@ static int PIPEWIRECAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *s
PW_STREAM_FLAG_AUTOCONNECT |
PW_STREAM_FLAG_MAP_BUFFERS,
params, n_params)) < 0) {
return -1;
return false;
}
PIPEWIRE_pw_thread_loop_unlock(hotplug.loop);
return 0;
return true;
}
static void PIPEWIRECAMERA_CloseDevice(SDL_Camera *device)
@@ -550,15 +547,15 @@ static void PIPEWIRECAMERA_CloseDevice(SDL_Camera *device)
PIPEWIRE_pw_thread_loop_unlock(hotplug.loop);
}
static int PIPEWIRECAMERA_WaitDevice(SDL_Camera *device)
static bool PIPEWIRECAMERA_WaitDevice(SDL_Camera *device)
{
PIPEWIRE_pw_thread_loop_lock(hotplug.loop);
PIPEWIRE_pw_thread_loop_wait(hotplug.loop);
PIPEWIRE_pw_thread_loop_unlock(hotplug.loop);
return 0;
return true;
}
static int PIPEWIRECAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
static SDL_CameraFrameResult PIPEWIRECAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
{
struct pw_buffer *b;
@@ -574,7 +571,7 @@ static int PIPEWIRECAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, U
}
if (b == NULL) {
PIPEWIRE_pw_thread_loop_unlock(hotplug.loop);
return 0;
return SDL_CAMERA_FRAME_SKIP;
}
#if PW_CHECK_VERSION(1,0,5)
@@ -587,7 +584,7 @@ static int PIPEWIRECAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, U
PIPEWIRE_pw_thread_loop_unlock(hotplug.loop);
return 1;
return SDL_CAMERA_FRAME_READY;
}
static void PIPEWIRECAMERA_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
@@ -625,7 +622,7 @@ static void collect_rates(CameraFormatAddData *data, struct param *p, SDL_PixelF
SPA_FALLTHROUGH;
case SPA_CHOICE_Enum:
for (i = 0; i < n_vals; i++) {
if (SDL_AddCameraFormat(data, sdlfmt, colorspace, size->width, size->height, rates[i].num, rates[i].denom) < 0) {
if (!SDL_AddCameraFormat(data, sdlfmt, colorspace, size->width, size->height, rates[i].num, rates[i].denom)) {
return; // Probably out of memory; we'll go with what we have, if anything.
}
}
@@ -976,7 +973,7 @@ static bool pipewire_server_version_at_least(int major, int minor, int patch)
}
// The hotplug thread
static int hotplug_loop_init(void)
static bool hotplug_loop_init(void)
{
int res;
@@ -1028,7 +1025,7 @@ static int hotplug_loop_init(void)
PW_REQUIRED_MAJOR, PW_REQUIRED_MINOR, PW_REQUIRED_PATCH);
}
return 0;
return true;
}
@@ -1037,24 +1034,24 @@ static void PIPEWIRECAMERA_Deinitialize(void)
if (pipewire_initialized) {
if (hotplug.loop) {
PIPEWIRE_pw_thread_loop_lock(hotplug.loop);
}
}
if (hotplug.registry) {
spa_hook_remove(&hotplug.registry_listener);
PIPEWIRE_pw_proxy_destroy((struct pw_proxy*)hotplug.registry);
}
spa_hook_remove(&hotplug.registry_listener);
PIPEWIRE_pw_proxy_destroy((struct pw_proxy *)hotplug.registry);
}
if (hotplug.core) {
spa_hook_remove(&hotplug.core_listener);
PIPEWIRE_pw_core_disconnect(hotplug.core);
}
spa_hook_remove(&hotplug.core_listener);
PIPEWIRE_pw_core_disconnect(hotplug.core);
}
if (hotplug.context) {
PIPEWIRE_pw_context_destroy(hotplug.context);
}
}
if (hotplug.loop) {
PIPEWIRE_pw_thread_loop_unlock(hotplug.loop);
PIPEWIRE_pw_thread_loop_destroy(hotplug.loop);
}
}
deinit_pipewire_library();
spa_zero(hotplug);
spa_zero(hotplug);
pipewire_initialized = false;
}
}
@@ -1063,13 +1060,13 @@ static bool PIPEWIRECAMERA_Init(SDL_CameraDriverImpl *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()) {
PIPEWIRECAMERA_Deinitialize();
return false;
}

View File

@@ -22,13 +22,14 @@
#ifdef SDL_CAMERA_DRIVER_V4L2
#include <stddef.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <fcntl.h> // low-level i/o
#include <dirent.h>
#include <errno.h>
#include <fcntl.h> // low-level i/o
#include <stddef.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <linux/videodev2.h>
#ifndef V4L2_CAP_DEVICE_CAPS
@@ -88,11 +89,11 @@ static int xioctl(int fh, int request, void *arg)
return r;
}
static int V4L2_WaitDevice(SDL_Camera *device)
static bool V4L2_WaitDevice(SDL_Camera *device)
{
const int fd = device->hidden->fd;
int retval;
int rc;
do {
fd_set fds;
@@ -103,22 +104,22 @@ static int V4L2_WaitDevice(SDL_Camera *device)
tv.tv_sec = 0;
tv.tv_usec = 100 * 1000;
retval = select(fd + 1, &fds, NULL, NULL, &tv);
if ((retval == -1) && (errno == EINTR)) {
retval = 0; // pretend it was a timeout, keep looping.
rc = select(fd + 1, &fds, NULL, NULL, &tv);
if ((rc == -1) && (errno == EINTR)) {
rc = 0; // pretend it was a timeout, keep looping.
}
// Thread is requested to shut down
if (SDL_AtomicGet(&device->shutdown)) {
return 0;
return true;
}
} while (retval == 0);
} while (rc == 0);
return retval;
return false;
}
static int V4L2_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
static SDL_CameraFrameResult V4L2_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
{
const int fd = device->hidden->fd;
const io_method io = device->hidden->io;
@@ -129,15 +130,16 @@ static int V4L2_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *tim
case IO_METHOD_READ:
if (read(fd, device->hidden->buffers[0].start, size) == -1) {
switch (errno) {
case EAGAIN:
return 0;
case EAGAIN:
return SDL_CAMERA_FRAME_SKIP;
case EIO:
// Could ignore EIO, see spec.
// fall through
case EIO:
// Could ignore EIO, see spec.
// fall through
default:
return SDL_SetError("read");
default:
SDL_SetError("read");
return SDL_CAMERA_FRAME_ERROR;
}
}
@@ -154,20 +156,22 @@ static int V4L2_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *tim
if (xioctl(fd, VIDIOC_DQBUF, &buf) == -1) {
switch (errno) {
case EAGAIN:
return 0;
case EAGAIN:
return SDL_CAMERA_FRAME_SKIP;
case EIO:
// Could ignore EIO, see spec.
// fall through
case EIO:
// Could ignore EIO, see spec.
// fall through
default:
return SDL_SetError("VIDIOC_DQBUF: %d", errno);
default:
SDL_SetError("VIDIOC_DQBUF: %d", errno);
return SDL_CAMERA_FRAME_ERROR;
}
}
if ((int)buf.index < 0 || (int)buf.index >= device->hidden->nb_buffers) {
return SDL_SetError("invalid buffer index");
SDL_SetError("invalid buffer index");
return SDL_CAMERA_FRAME_ERROR;
}
frame->pixels = device->hidden->buffers[buf.index].start;
@@ -189,16 +193,16 @@ static int V4L2_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *tim
if (xioctl(fd, VIDIOC_DQBUF, &buf) == -1) {
switch (errno) {
case EAGAIN:
return 0;
case EAGAIN:
return SDL_CAMERA_FRAME_SKIP;
case EIO:
// Could ignore EIO, see spec.
case EIO:
// Could ignore EIO, see spec.
// fall through
// fall through
default:
return SDL_SetError("VIDIOC_DQBUF");
default:
SDL_SetError("VIDIOC_DQBUF");
return SDL_CAMERA_FRAME_ERROR;
}
}
@@ -210,7 +214,8 @@ static int V4L2_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *tim
}
if (i >= device->hidden->nb_buffers) {
return SDL_SetError("invalid buffer index");
SDL_SetError("invalid buffer index");
return SDL_CAMERA_FRAME_ERROR;
}
frame->pixels = (void*)buf.m.userptr;
@@ -229,7 +234,7 @@ static int V4L2_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *tim
break;
}
return 1;
return SDL_CAMERA_FRAME_READY;
}
static void V4L2_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
@@ -289,7 +294,7 @@ static void V4L2_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
}
}
static int EnqueueBuffers(SDL_Camera *device)
static bool EnqueueBuffers(SDL_Camera *device)
{
const int fd = device->hidden->fd;
const io_method io = device->hidden->io;
@@ -335,17 +340,17 @@ static int EnqueueBuffers(SDL_Camera *device)
case IO_METHOD_INVALID: SDL_assert(!"Shouldn't have hit this"); break;
}
return 0;
return true;
}
static int AllocBufferRead(SDL_Camera *device, size_t buffer_size)
static bool AllocBufferRead(SDL_Camera *device, size_t buffer_size)
{
device->hidden->buffers[0].length = buffer_size;
device->hidden->buffers[0].start = SDL_calloc(1, buffer_size);
return device->hidden->buffers[0].start ? 0 : -1;
return (device->hidden->buffers[0].start != NULL);
}
static int AllocBufferMmap(SDL_Camera *device)
static bool AllocBufferMmap(SDL_Camera *device)
{
const int fd = device->hidden->fd;
int i;
@@ -374,10 +379,10 @@ static int AllocBufferMmap(SDL_Camera *device)
return SDL_SetError("mmap");
}
}
return 0;
return true;
}
static int AllocBufferUserPtr(SDL_Camera *device, size_t buffer_size)
static bool AllocBufferUserPtr(SDL_Camera *device, size_t buffer_size)
{
int i;
for (i = 0; i < device->hidden->nb_buffers; ++i) {
@@ -385,10 +390,10 @@ static int AllocBufferUserPtr(SDL_Camera *device, size_t buffer_size)
device->hidden->buffers[i].start = SDL_calloc(1, buffer_size);
if (!device->hidden->buffers[i].start) {
return -1;
return false;
}
}
return 0;
return true;
}
static void format_v4l2_to_sdl(Uint32 fmt, SDL_PixelFormat *format, SDL_Colorspace *colorspace)
@@ -415,7 +420,7 @@ static Uint32 format_sdl_to_v4l2(SDL_PixelFormat fmt)
CASE(V4L2_PIX_FMT_MJPEG, SDL_PIXELFORMAT_UNKNOWN);
#undef CASE
default:
return 0;
return true;
}
}
@@ -470,7 +475,7 @@ static void V4L2_CloseDevice(SDL_Camera *device)
}
}
static int V4L2_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
static bool V4L2_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
{
const V4L2DeviceHandle *handle = (const V4L2DeviceHandle *) device->handle;
struct stat st;
@@ -501,7 +506,7 @@ static int V4L2_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
device->hidden = (struct SDL_PrivateCameraData *) SDL_calloc(1, sizeof (struct SDL_PrivateCameraData));
if (device->hidden == NULL) {
close(fd);
return -1;
return false;
}
device->hidden->fd = fd;
@@ -597,13 +602,15 @@ static int V4L2_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
device->hidden->buffers = SDL_calloc(device->hidden->nb_buffers, sizeof(*device->hidden->buffers));
if (!device->hidden->buffers) {
return -1;
return false;
}
size_t size, pitch;
SDL_CalculateSurfaceSize(device->spec.format, device->spec.width, device->spec.height, &size, &pitch, false);
if (!SDL_CalculateSurfaceSize(device->spec.format, device->spec.width, device->spec.height, &size, &pitch, false)) {
return false;
}
int rc = 0;
bool rc = true;
switch (io) {
case IO_METHOD_READ:
rc = AllocBufferRead(device, size);
@@ -622,10 +629,10 @@ static int V4L2_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
break;
}
if (rc < 0) {
return -1;
} else if (EnqueueBuffers(device) < 0) {
return -1;
if (!rc) {
return false;
} else if (!EnqueueBuffers(device)) {
return false;
} else if (io != IO_METHOD_READ) {
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (xioctl(fd, VIDIOC_STREAMON, &type) == -1) {
@@ -636,7 +643,7 @@ static int V4L2_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
// Currently there is no user permission prompt for camera access, but maybe there will be a D-Bus portal interface at some point.
SDL_CameraPermissionOutcome(device, true);
return 0;
return true;
}
static bool FindV4L2CameraByBusInfoCallback(SDL_Camera *device, void *userdata)
@@ -645,7 +652,7 @@ static bool FindV4L2CameraByBusInfoCallback(SDL_Camera *device, void *userdata)
return (SDL_strcmp(handle->bus_info, (const char *) userdata) == 0);
}
static int AddCameraFormat(const int fd, CameraFormatAddData *data, SDL_PixelFormat sdlfmt, SDL_Colorspace colorspace, Uint32 v4l2fmt, int w, int h)
static bool AddCameraFormat(const int fd, CameraFormatAddData *data, SDL_PixelFormat sdlfmt, SDL_Colorspace colorspace, Uint32 v4l2fmt, int w, int h)
{
struct v4l2_frmivalenum frmivalenum;
SDL_zero(frmivalenum);
@@ -661,8 +668,8 @@ static int AddCameraFormat(const int fd, CameraFormatAddData *data, SDL_PixelFor
const float fps = (float) denominator / (float) numerator;
SDL_Log("CAMERA: * Has discrete frame interval (%d / %d), fps=%f", numerator, denominator, fps);
#endif
if (SDL_AddCameraFormat(data, sdlfmt, colorspace, w, h, denominator, numerator) == -1) {
return -1; // Probably out of memory; we'll go with what we have, if anything.
if (!SDL_AddCameraFormat(data, sdlfmt, colorspace, w, h, denominator, numerator)) {
return false; // Probably out of memory; we'll go with what we have, if anything.
}
frmivalenum.index++; // set up for the next one.
} else if ((frmivalenum.type == V4L2_FRMIVAL_TYPE_STEPWISE) || (frmivalenum.type == V4L2_FRMIVAL_TYPE_CONTINUOUS)) {
@@ -674,8 +681,8 @@ static int AddCameraFormat(const int fd, CameraFormatAddData *data, SDL_PixelFor
SDL_Log("CAMERA: * Has %s frame interval (%d / %d), fps=%f", (frmivalenum.type == V4L2_FRMIVAL_TYPE_STEPWISE) ? "stepwise" : "continuous", n, d, fps);
#endif
// SDL expects framerate, V4L2 provides interval
if (SDL_AddCameraFormat(data, sdlfmt, colorspace, w, h, d, n) == -1) {
return -1; // Probably out of memory; we'll go with what we have, if anything.
if (!SDL_AddCameraFormat(data, sdlfmt, colorspace, w, h, d, n)) {
return false; // Probably out of memory; we'll go with what we have, if anything.
}
d += (int) frmivalenum.stepwise.step.denominator;
}
@@ -683,7 +690,7 @@ static int AddCameraFormat(const int fd, CameraFormatAddData *data, SDL_PixelFor
}
}
return 0;
return true;
}
@@ -756,7 +763,7 @@ static void MaybeAddDevice(const char *path)
#if DEBUG_CAMERA
SDL_Log("CAMERA: * Has discrete size %dx%d", w, h);
#endif
if (AddCameraFormat(fd, &add_data, sdlfmt, colorspace, fmtdesc.pixelformat, w, h) == -1) {
if (!AddCameraFormat(fd, &add_data, sdlfmt, colorspace, fmtdesc.pixelformat, w, h)) {
break; // Probably out of memory; we'll go with what we have, if anything.
}
frmsizeenum.index++; // set up for the next one.
@@ -772,7 +779,7 @@ static void MaybeAddDevice(const char *path)
#if DEBUG_CAMERA
SDL_Log("CAMERA: * Has %s size %dx%d", (frmsizeenum.type == V4L2_FRMSIZE_TYPE_STEPWISE) ? "stepwise" : "continuous", w, h);
#endif
if (AddCameraFormat(fd, &add_data, sdlfmt, colorspace, fmtdesc.pixelformat, w, h) == -1) {
if (!AddCameraFormat(fd, &add_data, sdlfmt, colorspace, fmtdesc.pixelformat, w, h)) {
break; // Probably out of memory; we'll go with what we have, if anything.
}
}
@@ -856,12 +863,14 @@ static void V4L2_Deinitialize(void)
static void V4L2_DetectDevices(void)
{
#ifdef SDL_USE_LIBUDEV
if (SDL_UDEV_Init() == 0) {
if (SDL_UDEV_AddCallback(CameraUdevCallback) == 0) {
if (SDL_UDEV_Init()) {
if (SDL_UDEV_AddCallback(CameraUdevCallback)) {
SDL_UDEV_Scan(); // Force a scan to build the initial device list
}
return;
}
#else
#endif // SDL_USE_LIBUDEV
DIR *dirp = opendir("/dev");
if (dirp) {
struct dirent *dent;
@@ -875,7 +884,6 @@ static void V4L2_DetectDevices(void)
}
closedir(dirp);
}
#endif // SDL_USE_LIBUDEV
}
static bool V4L2_Init(SDL_CameraDriverImpl *impl)

View File

@@ -31,16 +31,16 @@ void SDL_SetX11EventHook(SDL_X11EventHook callback, void *userdata)
#ifndef SDL_PLATFORM_LINUX
SDL_DECLSPEC int SDLCALL SDL_SetLinuxThreadPriority(Sint64 threadID, int priority);
int SDL_SetLinuxThreadPriority(Sint64 threadID, int priority)
SDL_DECLSPEC SDL_bool SDLCALL SDL_SetLinuxThreadPriority(Sint64 threadID, int priority);
SDL_bool SDL_SetLinuxThreadPriority(Sint64 threadID, int priority)
{
(void)threadID;
(void)priority;
return SDL_Unsupported();
}
SDL_DECLSPEC int SDLCALL SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy);
int SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy)
SDL_DECLSPEC SDL_bool SDLCALL SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy);
SDL_bool SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy)
{
(void)threadID;
(void)sdlPriority;
@@ -58,8 +58,8 @@ void SDL_GDKSuspendComplete(void)
SDL_Unsupported();
}
SDL_DECLSPEC int SDLCALL SDL_GetGDKDefaultUser(void *outUserHandle); /* XUserHandle *outUserHandle */
int SDL_GetGDKDefaultUser(void *outUserHandle)
SDL_DECLSPEC SDL_bool SDLCALL SDL_GetGDKDefaultUser(void *outUserHandle); /* XUserHandle *outUserHandle */
SDL_bool SDL_GetGDKDefaultUser(void *outUserHandle)
{
return SDL_Unsupported();
}
@@ -68,8 +68,8 @@ int SDL_GetGDKDefaultUser(void *outUserHandle)
#if !(defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK))
SDL_DECLSPEC int SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst);
int SDL_RegisterApp(const char *name, Uint32 style, void *hInst)
SDL_DECLSPEC SDL_bool SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst);
SDL_bool SDL_RegisterApp(const char *name, Uint32 style, void *hInst)
{
(void)name;
(void)style;
@@ -163,8 +163,8 @@ void *SDL_GetAndroidJNIEnv(void)
}
typedef void (SDLCALL *SDL_RequestAndroidPermissionCallback)(void *userdata, const char *permission, bool granted);
SDL_DECLSPEC int SDLCALL SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata);
int SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata)
SDL_DECLSPEC SDL_bool SDLCALL SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata);
SDL_bool SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata)
{
(void)permission;
(void)cb;
@@ -172,16 +172,16 @@ int SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermi
return SDL_Unsupported();
}
SDL_DECLSPEC int SDLCALL SDL_SendAndroidMessage(Uint32 command, int param);
int SDL_SendAndroidMessage(Uint32 command, int param)
SDL_DECLSPEC SDL_bool SDLCALL SDL_SendAndroidMessage(Uint32 command, int param);
SDL_bool SDL_SendAndroidMessage(Uint32 command, int param)
{
(void)command;
(void)param;
return SDL_Unsupported();
}
SDL_DECLSPEC int SDLCALL SDL_ShowAndroidToast(const char* message, int duration, int gravity, int xoffset, int yoffset);
int SDL_ShowAndroidToast(const char* message, int duration, int gravity, int xoffset, int yoffset)
SDL_DECLSPEC SDL_bool SDLCALL SDL_ShowAndroidToast(const char* message, int duration, int gravity, int xoffset, int yoffset);
SDL_bool SDL_ShowAndroidToast(const char* message, int duration, int gravity, int xoffset, int yoffset)
{
(void)message;
(void)duration;

View File

@@ -268,11 +268,11 @@ static JNINativeMethod SDLAudioManager_tab[] = {
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(
JNIEnv *env, jclass jcls);
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)(
JNIEXPORT jboolean JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)(
JNIEnv *env, jclass jcls,
jint device_id, jint keycode);
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)(
JNIEXPORT jboolean JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)(
JNIEnv *env, jclass jcls,
jint device_id, jint keycode);
@@ -284,33 +284,33 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)(
JNIEnv *env, jclass jcls,
jint device_id, jint hat_id, jint x, jint y);
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
JNIEnv *env, jclass jcls,
jint device_id, jstring device_name, jstring device_desc, jint vendor_id, jint product_id,
jint button_mask, jint naxes, jint axis_mask, jint nhats, jboolean can_rumble);
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)(
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)(
JNIEnv *env, jclass jcls,
jint device_id);
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)(
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)(
JNIEnv *env, jclass jcls,
jint device_id, jstring device_name);
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)(
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)(
JNIEnv *env, jclass jcls,
jint device_id);
static JNINativeMethod SDLControllerManager_tab[] = {
{ "nativeSetupJNI", "()I", SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI) },
{ "onNativePadDown", "(II)I", SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown) },
{ "onNativePadUp", "(II)I", SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp) },
{ "onNativePadDown", "(II)Z", SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown) },
{ "onNativePadUp", "(II)Z", SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp) },
{ "onNativeJoy", "(IIF)V", SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy) },
{ "onNativeHat", "(IIII)V", SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat) },
{ "nativeAddJoystick", "(ILjava/lang/String;Ljava/lang/String;IIIIIIZ)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick) },
{ "nativeRemoveJoystick", "(I)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick) },
{ "nativeAddHaptic", "(ILjava/lang/String;)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic) },
{ "nativeRemoveHaptic", "(I)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic) }
{ "nativeAddJoystick", "(ILjava/lang/String;Ljava/lang/String;IIIIIIZ)V", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick) },
{ "nativeRemoveJoystick", "(I)V", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick) },
{ "nativeAddHaptic", "(ILjava/lang/String;)V", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic) },
{ "nativeRemoveHaptic", "(I)V", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic) }
};
// Uncomment this to log messages entering and exiting methods in this file
@@ -434,13 +434,14 @@ static int Android_NumLifecycleEvents;
*/
// Set local storage value
static int Android_JNI_SetEnv(JNIEnv *env)
static bool Android_JNI_SetEnv(JNIEnv *env)
{
int status = pthread_setspecific(mThreadKey, env);
if (status < 0) {
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed pthread_setspecific() in Android_JNI_SetEnv() (err=%d)", status);
return false;
}
return status;
return true;
}
// Get local storage value
@@ -467,7 +468,7 @@ JNIEnv *Android_JNI_GetEnv(void)
}
// Save JNIEnv into the Thread local storage
if (Android_JNI_SetEnv(env) < 0) {
if (!Android_JNI_SetEnv(env)) {
return NULL;
}
}
@@ -476,7 +477,7 @@ JNIEnv *Android_JNI_GetEnv(void)
}
// Set up an external thread for using JNI with Android_JNI_GetEnv()
int Android_JNI_SetupThread(void)
bool Android_JNI_SetupThread(void)
{
JNIEnv *env;
int status;
@@ -484,7 +485,7 @@ int Android_JNI_SetupThread(void)
// There should be a JVM
if (!mJavaVM) {
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM");
return 0;
return false;
}
/* Attach the current thread to the JVM and get a JNIEnv.
@@ -492,15 +493,15 @@ int Android_JNI_SetupThread(void)
status = (*mJavaVM)->AttachCurrentThread(mJavaVM, &env, NULL);
if (status < 0) {
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed to attach current thread (err=%d)", status);
return 0;
return false;
}
// Save JNIEnv into the Thread local storage
if (Android_JNI_SetEnv(env) < 0) {
return 0;
if (!Android_JNI_SetEnv(env)) {
return false;
}
return 1;
return true;
}
// Destructor called for each thread where mThreadKey is not NULL
@@ -642,9 +643,9 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
midIsTablet = (*env)->GetStaticMethodID(env, mActivityClass, "isTablet", "()Z");
midManualBackButton = (*env)->GetStaticMethodID(env, mActivityClass, "manualBackButton", "()V");
midMinimizeWindow = (*env)->GetStaticMethodID(env, mActivityClass, "minimizeWindow", "()V");
midOpenURL = (*env)->GetStaticMethodID(env, mActivityClass, "openURL", "(Ljava/lang/String;)I");
midOpenURL = (*env)->GetStaticMethodID(env, mActivityClass, "openURL", "(Ljava/lang/String;)Z");
midRequestPermission = (*env)->GetStaticMethodID(env, mActivityClass, "requestPermission", "(Ljava/lang/String;I)V");
midShowToast = (*env)->GetStaticMethodID(env, mActivityClass, "showToast", "(Ljava/lang/String;IIII)I");
midShowToast = (*env)->GetStaticMethodID(env, mActivityClass, "showToast", "(Ljava/lang/String;IIII)Z");
midSendMessage = (*env)->GetStaticMethodID(env, mActivityClass, "sendMessage", "(II)Z");
midSetActivityTitle = (*env)->GetStaticMethodID(env, mActivityClass, "setActivityTitle", "(Ljava/lang/String;)Z");
midSetCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "setCustomCursor", "(I)Z");
@@ -960,7 +961,7 @@ bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 timeout
{
bool got_event = false;
while (!got_event && SDL_WaitSemaphoreTimeoutNS(Android_LifecycleEventSem, timeoutNS) == 0) {
while (!got_event && SDL_WaitSemaphoreTimeoutNS(Android_LifecycleEventSem, timeoutNS)) {
SDL_LockMutex(Android_LifecycleMutex);
{
if (Android_NumLifecycleEvents > 0) {
@@ -1117,26 +1118,26 @@ SDL_JAVA_AUDIO_INTERFACE(removeAudioDevice)(JNIEnv *env, jclass jcls, jboolean r
}
// Paddown
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)(
JNIEXPORT jboolean JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)(
JNIEnv *env, jclass jcls,
jint device_id, jint keycode)
{
#ifdef SDL_JOYSTICK_ANDROID
return Android_OnPadDown(device_id, keycode);
#else
return -1;
return false;
#endif // SDL_JOYSTICK_ANDROID
}
// Padup
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)(
JNIEXPORT jboolean JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)(
JNIEnv *env, jclass jcls,
jint device_id, jint keycode)
{
#ifdef SDL_JOYSTICK_ANDROID
return Android_OnPadUp(device_id, keycode);
#else
return -1;
return false;
#endif // SDL_JOYSTICK_ANDROID
}
@@ -1160,61 +1161,49 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)(
#endif // SDL_JOYSTICK_ANDROID
}
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
JNIEnv *env, jclass jcls,
jint device_id, jstring device_name, jstring device_desc,
jint vendor_id, jint product_id,
jint button_mask, jint naxes, jint axis_mask, jint nhats, jboolean can_rumble)
{
int retval;
#ifdef SDL_JOYSTICK_ANDROID
const char *name = (*env)->GetStringUTFChars(env, device_name, NULL);
const char *desc = (*env)->GetStringUTFChars(env, device_desc, NULL);
retval = Android_AddJoystick(device_id, name, desc, vendor_id, product_id, button_mask, naxes, axis_mask, nhats, can_rumble);
Android_AddJoystick(device_id, name, desc, vendor_id, product_id, button_mask, naxes, axis_mask, nhats, can_rumble);
(*env)->ReleaseStringUTFChars(env, device_name, name);
(*env)->ReleaseStringUTFChars(env, device_desc, desc);
#else
retval = -1;
#endif // SDL_JOYSTICK_ANDROID
return retval;
}
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)(
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)(
JNIEnv *env, jclass jcls,
jint device_id)
{
#ifdef SDL_JOYSTICK_ANDROID
return Android_RemoveJoystick(device_id);
#else
return -1;
Android_RemoveJoystick(device_id);
#endif // SDL_JOYSTICK_ANDROID
}
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)(
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)(
JNIEnv *env, jclass jcls, jint device_id, jstring device_name)
{
int retval;
#ifdef SDL_HAPTIC_ANDROID
const char *name = (*env)->GetStringUTFChars(env, device_name, NULL);
retval = Android_AddHaptic(device_id, name);
Android_AddHaptic(device_id, name);
(*env)->ReleaseStringUTFChars(env, device_name, name);
#else
retval = -1;
#endif // SDL_HAPTIC_ANDROID
return retval;
}
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)(
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)(
JNIEnv *env, jclass jcls, jint device_id)
{
#ifdef SDL_HAPTIC_ANDROID
return Android_RemoveHaptic(device_id);
#else
return -1;
Android_RemoveHaptic(device_id);
#endif
}
@@ -1650,7 +1639,7 @@ bool Android_JNI_ShouldMinimizeOnFocusLoss(void)
bool Android_JNI_GetAccelerometerValues(float values[3])
{
bool retval = false;
bool result = false;
if (bHasNewData) {
int i;
@@ -1658,10 +1647,10 @@ bool Android_JNI_GetAccelerometerValues(float values[3])
values[i] = fLastAccelerometer[i];
}
bHasNewData = false;
retval = true;
result = true;
}
return retval;
return result;
}
/*
@@ -1789,7 +1778,7 @@ static void Internal_Android_Destroy_AssetManager(void)
}
}
int Android_JNI_FileOpen(void **puserdata, const char *fileName, const char *mode)
bool Android_JNI_FileOpen(void **puserdata, const char *fileName, const char *mode)
{
SDL_assert(puserdata != NULL);
@@ -1810,7 +1799,7 @@ int Android_JNI_FileOpen(void **puserdata, const char *fileName, const char *mod
}
*puserdata = (void *)asset;
return 0;
return true;
}
size_t Android_JNI_FileRead(void *userdata, void *buffer, size_t size, SDL_IOStatus *status)
@@ -1825,7 +1814,8 @@ size_t Android_JNI_FileRead(void *userdata, void *buffer, size_t size, SDL_IOSta
size_t Android_JNI_FileWrite(void *userdata, const void *buffer, size_t size, SDL_IOStatus *status)
{
return SDL_SetError("Cannot write to Android package filesystem");
SDL_SetError("Cannot write to Android package filesystem");
return 0;
}
Sint64 Android_JNI_FileSize(void *userdata)
@@ -1838,19 +1828,19 @@ Sint64 Android_JNI_FileSeek(void *userdata, Sint64 offset, SDL_IOWhence whence)
return (Sint64) AAsset_seek64((AAsset *)userdata, offset, (int)whence);
}
int Android_JNI_FileClose(void *userdata)
SDL_bool Android_JNI_FileClose(void *userdata)
{
AAsset_close((AAsset *)userdata);
return 0;
return true;
}
int Android_JNI_SetClipboardText(const char *text)
bool Android_JNI_SetClipboardText(const char *text)
{
JNIEnv *env = Android_JNI_GetEnv();
jstring string = (*env)->NewStringUTF(env, text);
(*env)->CallStaticVoidMethod(env, mActivityClass, midClipboardSetText, string);
(*env)->DeleteLocalRef(env, string);
return 0;
return true;
}
char *Android_JNI_GetClipboardText(void)
@@ -2038,24 +2028,22 @@ void Android_JNI_HapticStop(int device_id)
// See SDLActivity.java for constants.
#define COMMAND_SET_KEEP_SCREEN_ON 5
int SDL_SendAndroidMessage(Uint32 command, int param)
SDL_bool SDL_SendAndroidMessage(Uint32 command, int param)
{
if (command >= 0x8000) {
return Android_JNI_SendMessage(command, param);
if (command < 0x8000) {
return SDL_InvalidParamError("command");
}
return -1;
return Android_JNI_SendMessage(command, param);
}
// sends message to be handled on the UI event dispatch thread
int Android_JNI_SendMessage(int command, int param)
bool Android_JNI_SendMessage(int command, int param)
{
JNIEnv *env = Android_JNI_GetEnv();
jboolean success;
success = (*env)->CallStaticBooleanMethod(env, mActivityClass, midSendMessage, command, param);
return success ? 0 : -1;
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSendMessage, command, param);
}
int Android_JNI_SuspendScreenSaver(bool suspend)
bool Android_JNI_SuspendScreenSaver(bool suspend)
{
return Android_JNI_SendMessage(COMMAND_SET_KEEP_SCREEN_ON, (suspend == false) ? 0 : 1);
}
@@ -2086,7 +2074,7 @@ bool Android_JNI_IsScreenKeyboardShown(void)
return is_shown;
}
int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
bool Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
{
JNIEnv *env;
jclass clazz;
@@ -2176,7 +2164,7 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu
(*env)->DeleteLocalRef(env, button_texts);
(*env)->DeleteLocalRef(env, colors);
return 0;
return true;
}
/*
@@ -2431,7 +2419,7 @@ const char *SDL_GetAndroidCachePath(void)
return s_AndroidCachePath;
}
int SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xOffset, int yOffset)
SDL_bool SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xOffset, int yOffset)
{
return Android_JNI_ShowToast(message, duration, gravity, xOffset, yOffset);
}
@@ -2530,7 +2518,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePermissionResult)(
SDL_UnlockMutex(Android_ActivityMutex);
}
int SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata)
SDL_bool SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata)
{
if (!permission) {
return SDL_InvalidParamError("permission");
@@ -2540,13 +2528,13 @@ int SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermi
NativePermissionRequestInfo *info = (NativePermissionRequestInfo *) SDL_calloc(1, sizeof (NativePermissionRequestInfo));
if (!info) {
return -1;
return false;
}
info->permission = SDL_strdup(permission);
if (!info->permission) {
SDL_free(info);
return -1;
return false;
}
static SDL_AtomicInt next_request_code;
@@ -2565,13 +2553,13 @@ int SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermi
(*env)->CallStaticVoidMethod(env, mActivityClass, midRequestPermission, jpermission, info->request_code);
(*env)->DeleteLocalRef(env, jpermission);
return 0;
return true;
}
// Show toast notification
int Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset)
bool Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset)
{
int result = 0;
bool result;
JNIEnv *env = Android_JNI_GetEnv();
jstring jmessage = (*env)->NewStringUTF(env, message);
result = (*env)->CallStaticIntMethod(env, mActivityClass, midShowToast, jmessage, duration, gravity, xOffset, yOffset);
@@ -2579,7 +2567,7 @@ int Android_JNI_ShowToast(const char *message, int duration, int gravity, int xO
return result;
}
int Android_JNI_GetLocale(char *buf, size_t buflen)
bool Android_JNI_GetLocale(char *buf, size_t buflen)
{
AConfiguration *cfg;
@@ -2593,12 +2581,12 @@ int Android_JNI_GetLocale(char *buf, size_t buflen)
}
if (!asset_manager) {
return -1;
return false;
}
cfg = AConfiguration_new();
if (!cfg) {
return -1;
return false;
}
{
@@ -2634,16 +2622,17 @@ int Android_JNI_GetLocale(char *buf, size_t buflen)
AConfiguration_delete(cfg);
return 0;
return true;
}
int Android_JNI_OpenURL(const char *url)
bool Android_JNI_OpenURL(const char *url)
{
bool result;
JNIEnv *env = Android_JNI_GetEnv();
jstring jurl = (*env)->NewStringUTF(env, url);
const int ret = (*env)->CallStaticIntMethod(env, mActivityClass, midOpenURL, jurl);
result = (*env)->CallStaticIntMethod(env, mActivityClass, midOpenURL, jurl);
(*env)->DeleteLocalRef(env, jurl);
return ret;
return result;
}
int Android_JNI_OpenFileDescriptor(const char *uri, const char *mode)

View File

@@ -80,19 +80,19 @@ extern void Android_AudioThreadInit(SDL_AudioDevice *device);
extern bool Android_IsDeXMode(void);
extern bool Android_IsChromebook(void);
int Android_JNI_FileOpen(void **puserdata, const char *fileName, const char *mode);
bool Android_JNI_FileOpen(void **puserdata, const char *fileName, const char *mode);
Sint64 Android_JNI_FileSize(void *userdata);
Sint64 Android_JNI_FileSeek(void *userdata, Sint64 offset, SDL_IOWhence whence);
size_t Android_JNI_FileRead(void *userdata, void *buffer, size_t size, SDL_IOStatus *status);
size_t Android_JNI_FileWrite(void *userdata, const void *buffer, size_t size, SDL_IOStatus *status);
int Android_JNI_FileClose(void *userdata);
SDL_bool Android_JNI_FileClose(void *userdata);
// Environment support
void Android_JNI_GetManifestEnvironmentVariables(void);
int Android_JNI_OpenFileDescriptor(const char *uri, const char *mode);
// Clipboard support
int Android_JNI_SetClipboardText(const char *text);
bool Android_JNI_SetClipboardText(const char *text);
char *Android_JNI_GetClipboardText(void);
bool Android_JNI_HasClipboardText(void);
@@ -109,7 +109,7 @@ void Android_JNI_HapticRumble(int device_id, float low_frequency_intensity, floa
void Android_JNI_HapticStop(int device_id);
// Video
int Android_JNI_SuspendScreenSaver(bool suspend);
bool Android_JNI_SuspendScreenSaver(bool suspend);
// Touch support
void Android_JNI_InitTouch(void);
@@ -117,16 +117,16 @@ void Android_JNI_InitTouch(void);
// Threads
#include <jni.h>
JNIEnv *Android_JNI_GetEnv(void);
int Android_JNI_SetupThread(void);
bool Android_JNI_SetupThread(void);
// Locale
int Android_JNI_GetLocale(char *buf, size_t buflen);
bool Android_JNI_GetLocale(char *buf, size_t buflen);
// Generic messages
int Android_JNI_SendMessage(int command, int param);
bool Android_JNI_SendMessage(int command, int param);
// MessageBox
int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID);
bool Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID);
// Cursor support
int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y);
@@ -139,9 +139,9 @@ bool Android_JNI_SupportsRelativeMouse(void);
bool Android_JNI_SetRelativeMouseEnabled(bool enabled);
// Show toast notification
int Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset);
bool Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset);
int Android_JNI_OpenURL(const char *url);
bool Android_JNI_OpenURL(const char *url);
int SDL_GetAndroidSDKVersion(void);

View File

@@ -65,7 +65,7 @@ struct SDL_EVDEV_keyboard_state
unsigned int text_len;
};
static int SDL_EVDEV_kbd_load_keymaps(SDL_EVDEV_keyboard_state *kbd)
static bool SDL_EVDEV_kbd_load_keymaps(SDL_EVDEV_keyboard_state *kbd)
{
return ioctl(kbd->keyboard_fd, GIO_KEYMAP, kbd->key_map) >= 0;
}
@@ -408,7 +408,7 @@ static unsigned int handle_diacr(SDL_EVDEV_keyboard_state *kbd, unsigned int ch)
return ch;
}
static int vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
static bool vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
{
return (kbd->ledflagstate & flag) != 0;
}

View File

@@ -35,7 +35,7 @@ PAPPCONSTRAIN_REGISTRATION hCPLM = {};
HANDLE plmSuspendComplete = nullptr;
extern "C"
int SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue)
SDL_bool SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue)
{
// If this is the first call, first create the global task queue.
if (!GDK_GlobalTaskQueue) {
@@ -57,7 +57,7 @@ int SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue)
}
}
return 0;
return true;
}
extern "C"
@@ -74,13 +74,12 @@ void GDK_DispatchTaskQueue(void)
}
extern "C"
int GDK_RegisterChangeNotifications(void)
bool GDK_RegisterChangeNotifications(void)
{
// Register suspend/resume handling
plmSuspendComplete = CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE);
if (!plmSuspendComplete) {
SDL_SetError("[GDK] Unable to create plmSuspendComplete event");
return -1;
return SDL_SetError("[GDK] Unable to create plmSuspendComplete event");
}
auto rascn = [](BOOLEAN quiesced, PVOID context) {
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppStateChangeNotification handler");
@@ -98,8 +97,7 @@ int GDK_RegisterChangeNotifications(void)
}
};
if (RegisterAppStateChangeNotification(rascn, NULL, &hPLM)) {
SDL_SetError("[GDK] Unable to call RegisterAppStateChangeNotification");
return -1;
return SDL_SetError("[GDK] Unable to call RegisterAppStateChangeNotification");
}
// Register constrain/unconstrain handling
@@ -115,11 +113,10 @@ int GDK_RegisterChangeNotifications(void)
}
};
if (RegisterAppConstrainedChangeNotification(raccn, NULL, &hCPLM)) {
SDL_SetError("[GDK] Unable to call RegisterAppConstrainedChangeNotification");
return -1;
return SDL_SetError("[GDK] Unable to call RegisterAppConstrainedChangeNotification");
}
return 0;
return true;
}
extern "C"
@@ -142,7 +139,7 @@ void SDL_GDKSuspendComplete()
}
extern "C"
int SDL_GetGDKDefaultUser(XUserHandle *outUserHandle)
SDL_bool SDL_GetGDKDefaultUser(XUserHandle *outUserHandle)
{
XAsyncBlock block = { 0 };
HRESULT result;
@@ -158,5 +155,5 @@ int SDL_GetGDKDefaultUser(XUserHandle *outUserHandle)
return WIN_SetErrorFromHRESULT("XUserAddResult", result);
}
return 0;
return true;
}

View File

@@ -23,6 +23,5 @@
// This is called from WIN_PumpEvents on GDK
extern void GDK_DispatchTaskQueue(void);
extern int GDK_RegisterChangeNotifications(void);
extern bool GDK_RegisterChangeNotifications(void);
extern void GDK_UnregisterChangeNotifications(void);

View File

@@ -104,7 +104,7 @@ static int StartBeApp(void *unused)
}
static int StartBeLooper()
static bool StartBeLooper()
{
if (!be_app) {
SDL_AppThread = SDL_CreateThread(StartBeApp, "SDLApplication", NULL);
@@ -119,16 +119,18 @@ static int StartBeLooper()
SDL_Looper = new SDL_BLooper("SDLLooper");
SDL_Looper->Run();
return (0);
return true;
}
// Initialize the Be Application, if it's not already started
int SDL_InitBeApp(void)
bool SDL_InitBeApp(void)
{
// Create the BApplication that handles appserver interaction
if (SDL_BeAppActive <= 0) {
StartBeLooper();
if (!StartBeLooper()) {
return false;
}
// Mark the application active
SDL_BeAppActive = 0;
@@ -138,7 +140,7 @@ int SDL_InitBeApp(void)
++SDL_BeAppActive;
// The app is running, and we're ready to go
return 0;
return true;
}
// Quit the Be Application, if there's nothing left to do

View File

@@ -26,7 +26,7 @@ extern "C" {
// Handle the BeApp specific portions of the application
// Initialize the Be Application, if it's not already started
extern int SDL_InitBeApp(void);
extern bool SDL_InitBeApp(void);
// Quit the Be Application, if there's nothing left to do
extern void SDL_QuitBeApp(void);

View File

@@ -31,14 +31,14 @@ static char *inhibit_handle = NULL;
static unsigned int screensaver_cookie = 0;
static SDL_DBusContext dbus;
static int LoadDBUSSyms(void)
static bool LoadDBUSSyms(void)
{
#define SDL_DBUS_SYM2_OPTIONAL(TYPE, x, y) \
dbus.x = (TYPE)SDL_LoadFunction(dbus_handle, #y)
#define SDL_DBUS_SYM2(TYPE, x, y) \
if (!(dbus.x = (TYPE)SDL_LoadFunction(dbus_handle, #y))) \
return -1
return false
#define SDL_DBUS_SYM_OPTIONAL(TYPE, x) \
SDL_DBUS_SYM2_OPTIONAL(TYPE, x, dbus_##x)
@@ -93,7 +93,7 @@ static int LoadDBUSSyms(void)
#undef SDL_DBUS_SYM
#undef SDL_DBUS_SYM2
return 0;
return true;
}
static void UnloadDBUSLibrary(void)
@@ -104,23 +104,22 @@ static void UnloadDBUSLibrary(void)
}
}
static int LoadDBUSLibrary(void)
static bool LoadDBUSLibrary(void)
{
int retval = 0;
bool result = true;
if (!dbus_handle) {
dbus_handle = SDL_LoadObject(dbus_library);
if (!dbus_handle) {
retval = -1;
result = false;
// Don't call SDL_SetError(): SDL_LoadObject already did.
} else {
retval = LoadDBUSSyms();
if (retval < 0) {
result = LoadDBUSSyms();
if (!result) {
UnloadDBUSLibrary();
}
}
}
return retval;
return result;
}
static SDL_SpinLock spinlock_dbus_init = 0;
@@ -136,7 +135,7 @@ static void SDL_DBus_Init_Spinlocked(void)
if (!dbus.session_conn) {
DBusError err;
if (LoadDBUSLibrary() == -1) {
if (!LoadDBUSLibrary()) {
is_dbus_available = false; // can't load at all? Don't keep trying.
return;
}
@@ -209,7 +208,7 @@ SDL_DBusContext *SDL_DBus_GetContext(void)
static bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap)
{
bool retval = false;
bool result = false;
if (conn) {
DBusMessage *msg = dbus.message_new_method_call(node, path, interface, method);
@@ -237,7 +236,7 @@ static bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node,
}
firstarg = va_arg(ap_reply, int);
if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_get_args_valist(reply, NULL, firstarg, ap_reply)) {
retval = true;
result = true;
}
dbus.message_unref(reply);
}
@@ -247,32 +246,32 @@ static bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node,
}
}
return retval;
return result;
}
bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...)
{
bool retval;
bool result;
va_list ap;
va_start(ap, method);
retval = SDL_DBus_CallMethodInternal(conn, node, path, interface, method, ap);
result = SDL_DBus_CallMethodInternal(conn, node, path, interface, method, ap);
va_end(ap);
return retval;
return result;
}
bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...)
{
bool retval;
bool result;
va_list ap;
va_start(ap, method);
retval = SDL_DBus_CallMethodInternal(dbus.session_conn, node, path, interface, method, ap);
result = SDL_DBus_CallMethodInternal(dbus.session_conn, node, path, interface, method, ap);
va_end(ap);
return retval;
return result;
}
static bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap)
{
bool retval = false;
bool result = false;
if (conn) {
DBusMessage *msg = dbus.message_new_method_call(node, path, interface, method);
@@ -281,7 +280,7 @@ static bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *no
if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_append_args_valist(msg, firstarg, ap)) {
if (dbus.connection_send(conn, msg, NULL)) {
dbus.connection_flush(conn);
retval = true;
result = true;
}
}
@@ -289,7 +288,7 @@ static bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *no
}
}
return retval;
return result;
}
static bool SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *msg, const int expectedtype, void *result)
@@ -319,22 +318,22 @@ static bool SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *msg,
bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...)
{
bool retval;
bool result;
va_list ap;
va_start(ap, method);
retval = SDL_DBus_CallVoidMethodInternal(conn, node, path, interface, method, ap);
result = SDL_DBus_CallVoidMethodInternal(conn, node, path, interface, method, ap);
va_end(ap);
return retval;
return result;
}
bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...)
{
bool retval;
bool result;
va_list ap;
va_start(ap, method);
retval = SDL_DBus_CallVoidMethodInternal(dbus.session_conn, node, path, interface, method, ap);
result = SDL_DBus_CallVoidMethodInternal(dbus.session_conn, node, path, interface, method, ap);
va_end(ap);
return retval;
return result;
}
bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result)
@@ -449,7 +448,7 @@ bool SDL_DBus_ScreensaverInhibit(bool inhibit)
if (inhibit) {
DBusMessage *msg;
bool retval = false;
bool result = false;
const char *key = "reason";
const char *reply = NULL;
const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME);
@@ -477,11 +476,11 @@ bool SDL_DBus_ScreensaverInhibit(bool inhibit)
if (SDL_DBus_CallWithBasicReply(dbus.session_conn, msg, DBUS_TYPE_OBJECT_PATH, &reply)) {
inhibit_handle = SDL_strdup(reply);
retval = true;
result = true;
}
dbus.message_unref(msg);
return retval;
return result;
} else {
if (!SDL_DBus_CallVoidMethod(bus_name, inhibit_handle, "org.freedesktop.portal.Request", "Close", DBUS_TYPE_INVALID)) {
return false;

View File

@@ -132,9 +132,8 @@ static SDL_EVDEV_PrivateData *_this = NULL;
static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode);
static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item);
static int SDL_EVDEV_device_removed(const char *dev_path);
static int SDL_EVDEV_device_added(const char *dev_path, int udev_class);
static bool SDL_EVDEV_device_removed(const char *dev_path);
static bool SDL_EVDEV_device_added(const char *dev_path, int udev_class);
#ifdef SDL_USE_LIBUDEV
static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class, const char *dev_path);
#endif // SDL_USE_LIBUDEV
@@ -150,10 +149,10 @@ static Uint8 EVDEV_MouseButtons[] = {
SDL_BUTTON_X2 + 3 // BTN_TASK 0x117
};
static int SDL_EVDEV_SetRelativeMouseMode(bool enabled)
static bool SDL_EVDEV_SetRelativeMouseMode(bool enabled)
{
// Mice already send relative events through this interface
return 0;
return true;
}
static void SDL_EVDEV_UpdateKeyboardMute(void)
@@ -165,27 +164,27 @@ static void SDL_EVDEV_UpdateKeyboardMute(void)
}
}
int SDL_EVDEV_Init(void)
SDL_bool SDL_EVDEV_Init(void)
{
if (!_this) {
_this = (SDL_EVDEV_PrivateData *)SDL_calloc(1, sizeof(*_this));
if (!_this) {
return -1;
return false;
}
#ifdef SDL_USE_LIBUDEV
if (SDL_UDEV_Init() < 0) {
if (!SDL_UDEV_Init()) {
SDL_free(_this);
_this = NULL;
return -1;
return false;
}
// Set up the udev callback
if (SDL_UDEV_AddCallback(SDL_EVDEV_udev_callback) < 0) {
if (!SDL_UDEV_AddCallback(SDL_EVDEV_udev_callback)) {
SDL_UDEV_Quit();
SDL_free(_this);
_this = NULL;
return -1;
return false;
}
// Force a scan to build the initial device list
@@ -226,7 +225,7 @@ int SDL_EVDEV_Init(void)
_this->ref_count += 1;
return 0;
return true;
}
void SDL_EVDEV_Quit(void)
@@ -603,7 +602,7 @@ static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode)
return scancode;
}
static int SDL_EVDEV_init_keyboard(SDL_evdevlist_item *item, int udev_class)
static bool SDL_EVDEV_init_keyboard(SDL_evdevlist_item *item, int udev_class)
{
char name[128];
@@ -612,7 +611,7 @@ static int SDL_EVDEV_init_keyboard(SDL_evdevlist_item *item, int udev_class)
SDL_AddKeyboard((SDL_KeyboardID)item->fd, name, true);
return 0;
return true;
}
static void SDL_EVDEV_destroy_keyboard(SDL_evdevlist_item *item)
@@ -620,7 +619,7 @@ static void SDL_EVDEV_destroy_keyboard(SDL_evdevlist_item *item)
SDL_RemoveKeyboard((SDL_KeyboardID)item->fd, true);
}
static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
static bool SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
{
char name[128];
int ret;
@@ -634,7 +633,7 @@ static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
ret = ioctl(item->fd, EVIOCGABS(ABS_X), &abs_info);
if (ret < 0) {
// no absolute mode info, continue
return 0;
return true;
}
item->min_x = abs_info.minimum;
item->max_x = abs_info.maximum;
@@ -643,13 +642,13 @@ static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
ret = ioctl(item->fd, EVIOCGABS(ABS_Y), &abs_info);
if (ret < 0) {
// no absolute mode info, continue
return 0;
return true;
}
item->min_y = abs_info.minimum;
item->max_y = abs_info.maximum;
item->range_y = abs_info.maximum - abs_info.minimum;
return 0;
return true;
}
static void SDL_EVDEV_destroy_mouse(SDL_evdevlist_item *item)
@@ -657,7 +656,7 @@ static void SDL_EVDEV_destroy_mouse(SDL_evdevlist_item *item)
SDL_RemoveMouse((SDL_MouseID)item->fd, true);
}
static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
static bool SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
{
int ret;
unsigned long xreq, yreq;
@@ -665,12 +664,12 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
struct input_absinfo abs_info;
if (!item->is_touchscreen) {
return 0;
return true;
}
item->touchscreen_data = SDL_calloc(1, sizeof(*item->touchscreen_data));
if (!item->touchscreen_data) {
return -1;
return false;
}
ret = ioctl(item->fd, EVIOCGNAME(sizeof(name)), name);
@@ -682,7 +681,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
item->touchscreen_data->name = SDL_strdup(name);
if (!item->touchscreen_data->name) {
SDL_free(item->touchscreen_data);
return -1;
return false;
}
ret = ioctl(item->fd, EVIOCGABS(ABS_MT_SLOT), &abs_info);
@@ -738,7 +737,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
if (!item->touchscreen_data->slots) {
SDL_free(item->touchscreen_data->name);
SDL_free(item->touchscreen_data);
return -1;
return false;
}
ret = SDL_AddTouch(item->fd, // I guess our fd is unique enough
@@ -748,10 +747,10 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
SDL_free(item->touchscreen_data->slots);
SDL_free(item->touchscreen_data->name);
SDL_free(item->touchscreen_data);
return ret;
return false;
}
return 0;
return true;
}
static void SDL_EVDEV_destroy_touchscreen(SDL_evdevlist_item *item)
@@ -891,7 +890,7 @@ static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item)
#endif // EVIOCGMTSLOTS
}
static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
static bool SDL_EVDEV_device_added(const char *dev_path, int udev_class)
{
SDL_evdevlist_item *item;
unsigned long relbit[NBITS(REL_MAX)] = { 0 };
@@ -899,13 +898,13 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
// Check to make sure it's not already in list.
for (item = _this->first; item; item = item->next) {
if (SDL_strcmp(dev_path, item->path) == 0) {
return -1; // already have this one
return false; // already have this one
}
}
item = (SDL_evdevlist_item *)SDL_calloc(1, sizeof(SDL_evdevlist_item));
if (!item) {
return -1;
return false;
}
item->fd = open(dev_path, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
@@ -918,7 +917,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
if (!item->path) {
close(item->fd);
SDL_free(item);
return -1;
return false;
}
item->udev_class = udev_class;
@@ -931,30 +930,26 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
// For now, we just treat a touchpad like a touchscreen
if (udev_class & (SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD)) {
int ret;
item->is_touchscreen = true;
ret = SDL_EVDEV_init_touchscreen(item, udev_class);
if (ret < 0) {
if (!SDL_EVDEV_init_touchscreen(item, udev_class)) {
close(item->fd);
SDL_free(item->path);
SDL_free(item);
return ret;
return false;
}
} else if (udev_class & SDL_UDEV_DEVICE_MOUSE) {
int ret = SDL_EVDEV_init_mouse(item, udev_class);
if (ret < 0) {
if (!SDL_EVDEV_init_mouse(item, udev_class)) {
close(item->fd);
SDL_free(item->path);
SDL_free(item);
return ret;
return false;
}
} else if (udev_class & SDL_UDEV_DEVICE_KEYBOARD) {
int ret = SDL_EVDEV_init_keyboard(item, udev_class);
if (ret < 0) {
if (!SDL_EVDEV_init_keyboard(item, udev_class)) {
close(item->fd);
SDL_free(item->path);
SDL_free(item);
return ret;
return false;
}
}
@@ -969,10 +964,11 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
SDL_EVDEV_UpdateKeyboardMute();
return _this->num_devices++;
++_this->num_devices;
return true;
}
static int SDL_EVDEV_device_removed(const char *dev_path)
static bool SDL_EVDEV_device_removed(const char *dev_path)
{
SDL_evdevlist_item *item;
SDL_evdevlist_item *prev = NULL;
@@ -1001,12 +997,12 @@ static int SDL_EVDEV_device_removed(const char *dev_path)
SDL_free(item);
SDL_EVDEV_UpdateKeyboardMute();
_this->num_devices--;
return 0;
return true;
}
prev = item;
}
return -1;
return false;
}
Uint64 SDL_EVDEV_GetEventTimestamp(struct input_event *event)

View File

@@ -28,7 +28,7 @@
struct input_event;
extern int SDL_EVDEV_Init(void);
extern SDL_bool SDL_EVDEV_Init(void);
extern void SDL_EVDEV_Quit(void);
extern void SDL_EVDEV_SetVTSwitchCallbacks(void (*release_callback)(void*), void *release_callback_data,
void (*acquire_callback)(void*), void *acquire_callback_data);

View File

@@ -378,7 +378,7 @@ static void kbd_vt_quit(int console_fd)
ioctl(console_fd, VT_SETMODE, &mode);
}
static int kbd_vt_init(int console_fd)
static bool kbd_vt_init(int console_fd)
{
struct vt_mode mode;
@@ -386,7 +386,7 @@ static int kbd_vt_init(int console_fd)
vt_acquire_signal = find_free_signal(kbd_vt_acquire_signal_action);
if (!vt_release_signal || !vt_acquire_signal ) {
kbd_vt_quit(console_fd);
return -1;
return false;
}
SDL_zero(mode);
@@ -396,9 +396,9 @@ static int kbd_vt_init(int console_fd)
mode.frsig = SIGIO;
if (ioctl(console_fd, VT_SETMODE, &mode) < 0) {
kbd_vt_quit(console_fd);
return -1;
return false;
}
return 0;
return true;
}
static void kbd_vt_update(SDL_EVDEV_keyboard_state *state)
@@ -618,7 +618,7 @@ static unsigned int handle_diacr(SDL_EVDEV_keyboard_state *kbd, unsigned int ch)
return ch;
}
static int vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
static bool vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
{
return (kbd->ledflagstate & flag) != 0;
}

View File

@@ -252,7 +252,7 @@ static void SDLCALL Fcitx_SetCapabilities(void *data,
static bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appname, char **ic_path)
{
const char *program = "program";
bool retval = false;
bool result = false;
if (dbus && dbus->session_conn) {
DBusMessage *msg = dbus->message_new_method_call(FCITX_DBUS_SERVICE, FCITX_IM_DBUS_PATH, FCITX_IM_DBUS_INTERFACE, "CreateInputContext");
@@ -269,14 +269,14 @@ static bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appname,
reply = dbus->connection_send_with_reply_and_block(dbus->session_conn, msg, 300, NULL);
if (reply) {
if (dbus->message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, ic_path, DBUS_TYPE_INVALID)) {
retval = true;
result = true;
}
dbus->message_unref(reply);
}
dbus->message_unref(msg);
}
}
return retval;
return result;
}
static bool FcitxClientCreateIC(FcitxClient *client)

View File

@@ -249,13 +249,13 @@ static bool rtkit_setpriority_realtime(pid_t thread, int rt_priority)
#endif // threads
// this is a public symbol, so it has to exist even if threads are disabled.
int SDL_SetLinuxThreadPriority(Sint64 threadID, int priority)
SDL_bool SDL_SetLinuxThreadPriority(Sint64 threadID, int priority)
{
#ifdef SDL_THREADS_DISABLED
return SDL_Unsupported();
#else
if (setpriority(PRIO_PROCESS, (id_t)threadID, priority) == 0) {
return 0;
return true;
}
#ifdef SDL_USE_LIBDBUS
@@ -272,7 +272,7 @@ int SDL_SetLinuxThreadPriority(Sint64 threadID, int priority)
README and sample code at: http://git.0pointer.net/rtkit.git
*/
if (rtkit_setpriority_nice((pid_t)threadID, priority)) {
return 0;
return true;
}
#endif
@@ -281,7 +281,7 @@ int SDL_SetLinuxThreadPriority(Sint64 threadID, int priority)
}
// this is a public symbol, so it has to exist even if threads are disabled.
int SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy)
SDL_bool SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy)
{
#ifdef SDL_THREADS_DISABLED
return SDL_Unsupported();
@@ -310,7 +310,7 @@ int SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int sc
}
if (setpriority(PRIO_PROCESS, (id_t)threadID, osPriority) == 0) {
return 0;
return true;
}
}
@@ -329,11 +329,11 @@ int SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int sc
*/
if (schedPolicy == SCHED_RR || schedPolicy == SCHED_FIFO) {
if (rtkit_setpriority_realtime((pid_t)threadID, osPriority)) {
return 0;
return true;
}
} else {
if (rtkit_setpriority_nice((pid_t)threadID, osPriority)) {
return 0;
return true;
}
}
#endif

View File

@@ -41,7 +41,7 @@ static const char *SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };
static SDL_UDEV_PrivateData *_this = NULL;
static bool SDL_UDEV_load_sym(const char *fn, void **addr);
static int SDL_UDEV_load_syms(void);
static bool SDL_UDEV_load_syms(void);
static bool SDL_UDEV_hotplug_update_available(void);
static void get_caps(struct udev_device *dev, struct udev_device *pdev, const char *attr, unsigned long *bitmask, size_t bitmask_len);
static int guess_device_class(struct udev_device *dev);
@@ -59,12 +59,12 @@ static bool SDL_UDEV_load_sym(const char *fn, void **addr)
return true;
}
static int SDL_UDEV_load_syms(void)
static bool SDL_UDEV_load_syms(void)
{
/* cast funcs to char* first, to please GCC's strict aliasing rules. */
#define SDL_UDEV_SYM(x) \
if (!SDL_UDEV_load_sym(#x, (void **)(char *)&_this->syms.x)) \
return -1
return false
SDL_UDEV_SYM(udev_device_get_action);
SDL_UDEV_SYM(udev_device_get_devnode);
@@ -95,7 +95,7 @@ static int SDL_UDEV_load_syms(void)
SDL_UDEV_SYM(udev_device_get_devnum);
#undef SDL_UDEV_SYM
return 0;
return true;
}
static bool SDL_UDEV_hotplug_update_available(void)
@@ -109,20 +109,17 @@ static bool SDL_UDEV_hotplug_update_available(void)
return false;
}
int SDL_UDEV_Init(void)
bool SDL_UDEV_Init(void)
{
int retval = 0;
if (!_this) {
_this = (SDL_UDEV_PrivateData *)SDL_calloc(1, sizeof(*_this));
if (!_this) {
return -1;
return false;
}
retval = SDL_UDEV_LoadLibrary();
if (retval < 0) {
if (!SDL_UDEV_LoadLibrary()) {
SDL_UDEV_Quit();
return retval;
return false;
}
/* Set up udev monitoring
@@ -152,7 +149,7 @@ int SDL_UDEV_Init(void)
_this->ref_count += 1;
return retval;
return true;
}
void SDL_UDEV_Quit(void)
@@ -187,14 +184,14 @@ void SDL_UDEV_Quit(void)
}
}
int SDL_UDEV_Scan(void)
bool SDL_UDEV_Scan(void)
{
struct udev_enumerate *enumerate = NULL;
struct udev_list_entry *devs = NULL;
struct udev_list_entry *item = NULL;
if (!_this) {
return 0;
return true;
}
enumerate = _this->syms.udev_enumerate_new(_this->udev);
@@ -219,7 +216,7 @@ int SDL_UDEV_Scan(void)
}
_this->syms.udev_enumerate_unref(enumerate);
return 0;
return true;
}
bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class)
@@ -291,17 +288,17 @@ void SDL_UDEV_UnloadLibrary(void)
}
}
int SDL_UDEV_LoadLibrary(void)
bool SDL_UDEV_LoadLibrary(void)
{
int retval = 0, i;
bool result = true;
if (!_this) {
return SDL_SetError("UDEV not initialized");
}
// See if there is a udev library already loaded
if (SDL_UDEV_load_syms() == 0) {
return 0;
if (SDL_UDEV_load_syms()) {
return true;
}
#ifdef SDL_UDEV_DYNAMIC
@@ -309,8 +306,8 @@ int SDL_UDEV_LoadLibrary(void)
if (!_this->udev_handle) {
_this->udev_handle = SDL_LoadObject(SDL_UDEV_DYNAMIC);
if (_this->udev_handle) {
retval = SDL_UDEV_load_syms();
if (retval < 0) {
result = SDL_UDEV_load_syms();
if (!result) {
SDL_UDEV_UnloadLibrary();
}
}
@@ -318,11 +315,11 @@ int SDL_UDEV_LoadLibrary(void)
#endif
if (!_this->udev_handle) {
for (i = 0; i < SDL_arraysize(SDL_UDEV_LIBS); i++) {
for (int i = 0; i < SDL_arraysize(SDL_UDEV_LIBS); i++) {
_this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]);
if (_this->udev_handle) {
retval = SDL_UDEV_load_syms();
if (retval < 0) {
result = SDL_UDEV_load_syms();
if (!result) {
SDL_UDEV_UnloadLibrary();
} else {
break;
@@ -331,12 +328,12 @@ int SDL_UDEV_LoadLibrary(void)
}
if (!_this->udev_handle) {
retval = -1;
result = false;
// Don't call SDL_SetError(): SDL_LoadObject already did.
}
}
return retval;
return result;
}
static void get_caps(struct udev_device *dev, struct udev_device *pdev, const char *attr, unsigned long *bitmask, size_t bitmask_len)
@@ -529,12 +526,12 @@ void SDL_UDEV_Poll(void)
}
}
int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb)
bool SDL_UDEV_AddCallback(SDL_UDEV_Callback cb)
{
SDL_UDEV_CallbackList *item;
item = (SDL_UDEV_CallbackList *)SDL_calloc(1, sizeof(SDL_UDEV_CallbackList));
if (!item) {
return -1;
return false;
}
item->callback = cb;
@@ -546,7 +543,7 @@ int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb)
_this->last = item;
}
return 0;
return true;
}
void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
@@ -579,7 +576,7 @@ void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void)
{
if (SDL_UDEV_Init() < 0) {
if (!SDL_UDEV_Init()) {
SDL_SetError("Could not initialize UDEV");
return NULL;
}

View File

@@ -96,14 +96,14 @@ typedef struct SDL_UDEV_PrivateData
SDL_UDEV_Symbols syms;
} SDL_UDEV_PrivateData;
extern int SDL_UDEV_Init(void);
extern bool SDL_UDEV_Init(void);
extern void SDL_UDEV_Quit(void);
extern void SDL_UDEV_UnloadLibrary(void);
extern int SDL_UDEV_LoadLibrary(void);
extern bool SDL_UDEV_LoadLibrary(void);
extern void SDL_UDEV_Poll(void);
extern int SDL_UDEV_Scan(void);
extern bool SDL_UDEV_Scan(void);
extern bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class);
extern int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb);
extern bool SDL_UDEV_AddCallback(SDL_UDEV_Callback cb);
extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb);
extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void);
extern void SDL_UDEV_ReleaseUdevSyms(void);

View File

@@ -36,17 +36,17 @@ static HMODULE s_pHIDDLL = 0;
static int s_HIDDLLRefCount = 0;
int WIN_LoadHIDDLL(void)
bool WIN_LoadHIDDLL(void)
{
if (s_pHIDDLL) {
SDL_assert(s_HIDDLLRefCount > 0);
s_HIDDLLRefCount++;
return 0; // already loaded
return true; // already loaded
}
s_pHIDDLL = LoadLibrary(TEXT("hid.dll"));
if (!s_pHIDDLL) {
return -1;
return false;
}
SDL_assert(s_HIDDLLRefCount == 0);
@@ -63,10 +63,10 @@ int WIN_LoadHIDDLL(void)
!SDL_HidP_GetCaps || !SDL_HidP_GetButtonCaps ||
!SDL_HidP_GetValueCaps || !SDL_HidP_MaxDataListLength || !SDL_HidP_GetData) {
WIN_UnloadHIDDLL();
return -1;
return false;
}
return 0;
return true;
}
void WIN_UnloadHIDDLL(void)

View File

@@ -190,7 +190,7 @@ typedef struct
#define HIDP_STATUS_REPORT_DOES_NOT_EXIST HIDP_ERROR_CODES(0xC, 0x0010)
#define HIDP_STATUS_NOT_IMPLEMENTED HIDP_ERROR_CODES(0xC, 0x0020)
extern int WIN_LoadHIDDLL(void);
extern bool WIN_LoadHIDDLL(void);
extern void WIN_UnloadHIDDLL(void);
typedef BOOLEAN (WINAPI *HidD_GetString_t)(HANDLE HidDeviceObject, PVOID Buffer, ULONG BufferLength);

View File

@@ -207,12 +207,12 @@ static ULONG STDMETHODCALLTYPE SDLMMNotificationClient_Release(IMMNotificationCl
{
// client is a static object; we don't ever free it.
SDLMMNotificationClient *client = (SDLMMNotificationClient *)iclient;
const ULONG retval = SDL_AtomicDecRef(&client->refcount);
if (retval == 0) {
const ULONG rc = SDL_AtomicDecRef(&client->refcount);
if (rc == 0) {
SDL_AtomicSet(&client->refcount, 0); // uhh...
return 0;
}
return retval - 1;
return rc - 1;
}
// These are the entry points called when WASAPI device endpoints change.
@@ -288,7 +288,7 @@ static const IMMNotificationClientVtbl notification_client_vtbl = {
static SDLMMNotificationClient notification_client = { &notification_client_vtbl, { 1 } };
int SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks)
bool SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks)
{
HRESULT ret;
@@ -320,7 +320,7 @@ int SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks)
immcallbacks.default_audio_device_changed = SDL_DefaultAudioDeviceChanged;
}
return 0;
return true;
}
void SDL_IMMDevice_Quit(void)
@@ -336,7 +336,7 @@ void SDL_IMMDevice_Quit(void)
WIN_CoUninitialize();
}
int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, bool recording)
bool SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, bool recording)
{
const Uint64 timeout = SDL_GetTicks() + 8000; // intel's audio drivers can fail for up to EIGHT SECONDS after a device is connected or we wake from sleep.
@@ -357,8 +357,10 @@ int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, bool recor
break;
}
return SUCCEEDED(ret) ? 0 : WIN_SetErrorFromHRESULT("WASAPI can't find requested audio endpoint", ret);
if (!SUCCEEDED(ret)) {
return WIN_SetErrorFromHRESULT("WASAPI can't find requested audio endpoint", ret);
}
return true;
}
static void EnumerateEndpointsForFlow(const bool recording, SDL_AudioDevice **default_device)

View File

@@ -34,9 +34,9 @@ typedef struct SDL_IMMDevice_callbacks
void (*default_audio_device_changed)(SDL_AudioDevice *new_default_device);
} SDL_IMMDevice_callbacks;
int SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks);
bool SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks);
void SDL_IMMDevice_Quit(void);
int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, bool recording);
bool SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, bool recording);
void SDL_IMMDevice_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording);
LPGUID SDL_IMMDevice_GetDirectSoundGUID(SDL_AudioDevice *device);
LPCWSTR SDL_IMMDevice_GetDevID(SDL_AudioDevice *device);

View File

@@ -54,7 +54,7 @@ typedef enum RO_INIT_TYPE
#endif
// Sets an error message based on an HRESULT
int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
bool WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
{
TCHAR buffer[1024];
char *message;
@@ -73,11 +73,11 @@ int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
message = WIN_StringToUTF8(buffer);
SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
SDL_free(message);
return -1;
return false;
}
// Sets an error message based on GetLastError()
int WIN_SetError(const char *prefix)
bool WIN_SetError(const char *prefix)
{
return WIN_SetErrorFromHRESULT(prefix, GetLastError());
}
@@ -207,12 +207,12 @@ static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WO
#else
#define CHECKWINVER(notdesktop_platform_result, test) \
static bool checked = false; \
static BOOL retval = FALSE; \
static BOOL result = FALSE; \
if (!checked) { \
retval = (test); \
result = (test); \
checked = true; \
} \
return retval;
return result;
#endif
// this is the oldest thing we run on (and we may lose support for this in SDL3 at any time!),
@@ -275,7 +275,7 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
bool rc;
HKEY hkey;
DWORD len = 0;
char *retval = NULL;
char *result = NULL;
if (WIN_IsEqualGUID(guid, &nullguid)) {
return WIN_StringToUTF8(name); // No GUID, go with what we've got.
@@ -315,9 +315,9 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
strw[len / 2] = 0; // make sure it's null-terminated.
retval = WIN_StringToUTF8(strw);
result = WIN_StringToUTF8(strw);
SDL_free(strw);
return retval ? retval : WIN_StringToUTF8(name);
return result ? result : WIN_StringToUTF8(name);
#endif // if SDL_PLATFORM_WINRT / else
}

View File

@@ -117,10 +117,10 @@ extern "C" {
#endif
// Sets an error message based on a given HRESULT
extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
extern bool WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
// Sets an error message based on GetLastError(). Always return -1.
extern int WIN_SetError(const char *prefix);
extern bool WIN_SetError(const char *prefix);
#ifndef SDL_PLATFORM_WINRT
// Load a function from combase.dll

View File

@@ -39,7 +39,7 @@ static int s_XInputDLLRefCount = 0;
#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
int WIN_LoadXInputDLL(void)
bool WIN_LoadXInputDLL(void)
{
/* Getting handles to system dlls (via LoadLibrary and its variants) is not
* supported on WinRT, thus, pointers to XInput's functions can't be
@@ -61,7 +61,7 @@ int WIN_LoadXInputDLL(void)
// XInput 1.4 ships with Windows 8 and 8.1:
SDL_XInputVersion = (1 << 16) | 4;
return 0;
return true;
}
void WIN_UnloadXInputDLL(void)
@@ -70,14 +70,14 @@ void WIN_UnloadXInputDLL(void)
#else // !(defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
int WIN_LoadXInputDLL(void)
bool WIN_LoadXInputDLL(void)
{
DWORD version = 0;
if (s_pXInputDLL) {
SDL_assert(s_XInputDLLRefCount > 0);
s_XInputDLLRefCount++;
return 0; // already loaded
return true; // already loaded
}
/* NOTE: Don't load XinputUap.dll
@@ -98,7 +98,7 @@ int WIN_LoadXInputDLL(void)
s_pXInputDLL = LoadLibrary(TEXT("XInput9_1_0.dll"));
}
if (!s_pXInputDLL) {
return -1;
return false;
}
SDL_assert(s_XInputDLLRefCount == 0);
@@ -117,10 +117,10 @@ int WIN_LoadXInputDLL(void)
SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)GetProcAddress(s_pXInputDLL, "XInputGetBatteryInformation");
if (!SDL_XInputGetState || !SDL_XInputSetState || !SDL_XInputGetCapabilities) {
WIN_UnloadXInputDLL();
return -1;
return false;
}
return 0;
return true;
}
void WIN_UnloadXInputDLL(void)

View File

@@ -252,7 +252,7 @@ typedef DWORD(WINAPI *XInputGetBatteryInformation_t)(
BYTE devType,
XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation);
extern int WIN_LoadXInputDLL(void);
extern bool WIN_LoadXInputDLL(void);
extern void WIN_UnloadXInputDLL(void);
extern XInputGetState_t SDL_XInputGetState;

View File

@@ -94,12 +94,12 @@ IFrameworkView ^ SDLApplicationSource::CreateView()
return app;
}
int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **))
bool SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **))
{
WINRT_SDLAppEntryPoint = mainFunction;
auto direct3DApplicationSource = ref new SDLApplicationSource();
CoreApplication::Run(direct3DApplicationSource);
return 0;
return true;
}
static void WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identifying thing into WINRT_ProcessWindowSizeChange()

View File

@@ -20,7 +20,7 @@
*/
#include <Windows.h>
extern int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **));
extern bool SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **));
ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
{

View File

@@ -85,7 +85,7 @@ static void WINRT_OnRenderViaXAML(_In_ Platform::Object ^ sender, _In_ Platform:
* SDL + XAML Initialization
*/
int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable)
bool SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable)
{
#if SDL_WINAPI_FAMILY_PHONE
return SDL_SetError("XAML support is not yet available in Windows Phone.");
@@ -133,14 +133,14 @@ int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPane
// Make sure video modes are detected now, while we still have access to the WinRT
// CoreWindow. WinRT will not allow the app's CoreWindow to be accessed via the
// SDL/WinRT thread.
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
if (!SDL_InitSubSystem(SDL_INIT_VIDEO)) {
// SDL_InitSubSystem will, on error, set the SDL error. Let that propagate to
// the caller to here:
WINRT_XAMLWasEnabled = oldXAMLWasEnabledValue;
return -1;
return false;
}
// All done, for now.
return 0;
return true;
#endif // SDL_WINAPI_FAMILY_PHONE
}

View File

@@ -25,7 +25,7 @@
#ifdef __cplusplus
extern bool WINRT_XAMLWasEnabled;
extern int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable);
extern bool SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable);
#endif // ifdef __cplusplus
#endif // SDL_winrtapp_xaml_h_

View File

@@ -43,18 +43,18 @@ bool StringEndsWith(const std::string& str, const std::string& end)
std::vector<std::string> StringSplit(const std::string& str, const std::string& split)
{
std::vector<std::string> retval;
std::vector<std::string> result;
std::string s = str;
size_t pos = 0;
while ((pos = s.find(split)) != std::string::npos) {
retval.push_back(s.substr(0, pos));
result.push_back(s.substr(0, pos));
s = s.substr(pos + split.size());
}
retval.push_back(s);
result.push_back(s);
return retval;
return result;
}
class SDLBRefFilter : public BRefFilter
@@ -192,7 +192,7 @@ private:
void ShowDialog(bool save, SDL_DialogFileCallback callback, void *userdata, bool many, bool modal, const SDL_DialogFileFilter *filters, int nfilters, bool folder, const char *location)
{
if (SDL_InitBeApp()) {
if (!SDL_InitBeApp()) {
char* err = SDL_strdup(SDL_GetError());
SDL_SetError("Couldn't init Be app: %s", err);
SDL_free(err);

View File

@@ -440,7 +440,7 @@ void SDL_Portal_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* user
DBus_OpenDialog("OpenFile", "Open Folder", callback, userdata, window, NULL, 0, default_location, allow_many, 1);
}
int SDL_Portal_detect(void)
bool SDL_Portal_detect(void)
{
SDL_DBusContext *dbus = SDL_DBus_GetContext();
DBusMessage *msg = NULL, *reply = NULL;
@@ -450,14 +450,14 @@ int SDL_Portal_detect(void)
// No need for this if the result is cached.
if (portal_present != -1) {
return portal_present;
return (portal_present > 0);
}
portal_present = 0;
if (!dbus) {
SDL_SetError("%s", "Failed to connect to DBus!");
return 0;
return false;
}
// Use introspection to get the available services.
@@ -493,7 +493,7 @@ done:
dbus->message_unref(reply);
}
return portal_present;
return (portal_present > 0);
}
#else
@@ -518,9 +518,9 @@ void SDL_Portal_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* user
callback(userdata, NULL, -1);
}
int SDL_Portal_detect(void)
bool SDL_Portal_detect(void)
{
return 0;
return false;
}
#endif // SDL_USE_LIBDBUS

View File

@@ -26,4 +26,4 @@ void SDL_Portal_ShowSaveFileDialog(SDL_DialogFileCallback callback, void* userda
void SDL_Portal_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, bool allow_many);
/** @returns non-zero if available, zero if unavailable */
int SDL_Portal_detect(void);
bool SDL_Portal_detect(void);

View File

@@ -407,7 +407,7 @@ void SDL_Zenity_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* user
SDL_DetachThread(thread);
}
int SDL_Zenity_detect(void)
bool SDL_Zenity_detect(void)
{
pid_t process;
int status = -1;
@@ -416,7 +416,7 @@ int SDL_Zenity_detect(void)
if (process < 0) {
SDL_SetError("Could not fork process: %s", strerror(errno));
return 0;
return false;
} else if (process == 0){
// Disable output
close(STDERR_FILENO);
@@ -426,13 +426,13 @@ int SDL_Zenity_detect(void)
} else {
if (waitpid(process, &status, 0) == -1) {
SDL_SetError("waitpid failed");
return 0;
return false;
}
if (WIFEXITED(status)) {
status = WEXITSTATUS(status);
}
return !status;
return (status == 0);
}
}

View File

@@ -21,9 +21,9 @@
#include "SDL_internal.h"
void SDL_Zenity_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, bool allow_many);
void SDL_Zenity_ShowSaveFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location);
void SDL_Zenity_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, bool allow_many);
extern void SDL_Zenity_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, bool allow_many);
extern void SDL_Zenity_ShowSaveFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location);
extern void SDL_Zenity_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, bool allow_many);
/** @returns non-zero if available, zero if unavailable */
int SDL_Zenity_detect(void);
extern bool SDL_Zenity_detect(void);

View File

@@ -76,7 +76,7 @@ static void SDL_InitDynamicAPI(void);
}
#define SDL_DYNAPI_VARARGS(_static, name, initcall) \
_static int SDLCALL SDL_SetError##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \
_static SDL_bool SDLCALL SDL_SetError##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \
{ \
char buf[128], *str = buf; \
int result; \
@@ -95,62 +95,62 @@ static void SDL_InitDynamicAPI(void);
} \
} \
if (result >= 0) { \
result = jump_table.SDL_SetError("%s", str); \
jump_table.SDL_SetError("%s", str); \
} \
if (str != buf) { \
jump_table.SDL_free(str); \
} \
return result; \
return SDL_FALSE; \
} \
_static int SDLCALL SDL_sscanf##name(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...) \
{ \
int retval; \
int result; \
va_list ap; \
initcall; \
va_start(ap, fmt); \
retval = jump_table.SDL_vsscanf(buf, fmt, ap); \
result = jump_table.SDL_vsscanf(buf, fmt, ap); \
va_end(ap); \
return retval; \
return result; \
} \
_static int SDLCALL SDL_snprintf##name(SDL_OUT_Z_CAP(maxlen) char *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \
{ \
int retval; \
int result; \
va_list ap; \
initcall; \
va_start(ap, fmt); \
retval = jump_table.SDL_vsnprintf(buf, maxlen, fmt, ap); \
result = jump_table.SDL_vsnprintf(buf, maxlen, fmt, ap); \
va_end(ap); \
return retval; \
return result; \
} \
_static int SDLCALL SDL_swprintf##name(SDL_OUT_Z_CAP(maxlen) wchar_t *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt, ...) \
{ \
int retval; \
int result; \
va_list ap; \
initcall; \
va_start(ap, fmt); \
retval = jump_table.SDL_vswprintf(buf, maxlen, fmt, ap); \
result = jump_table.SDL_vswprintf(buf, maxlen, fmt, ap); \
va_end(ap); \
return retval; \
return result; \
} \
_static int SDLCALL SDL_asprintf##name(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \
{ \
int retval; \
int result; \
va_list ap; \
initcall; \
va_start(ap, fmt); \
retval = jump_table.SDL_vasprintf(strp, fmt, ap); \
result = jump_table.SDL_vasprintf(strp, fmt, ap); \
va_end(ap); \
return retval; \
return result; \
} \
_static size_t SDLCALL SDL_IOprintf##name(SDL_IOStream *context, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \
{ \
size_t retval; \
size_t result; \
va_list ap; \
initcall; \
va_start(ap, fmt); \
retval = jump_table.SDL_IOvprintf(context, fmt, ap); \
result = jump_table.SDL_IOvprintf(context, fmt, ap); \
va_end(ap); \
return retval; \
return result; \
} \
_static void SDLCALL SDL_Log##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \
{ \
@@ -232,7 +232,7 @@ SDL_DYNAPI_VARARGS(, , )
#define ENABLE_SDL_CALL_LOGGING 0
#if ENABLE_SDL_CALL_LOGGING
static int SDLCALL SDL_SetError_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
static SDL_bool SDLCALL SDL_SetError_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
char buf[512]; // !!! FIXME: dynamic allocation
va_list ap;
@@ -244,53 +244,53 @@ static int SDLCALL SDL_SetError_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char
}
static int SDLCALL SDL_sscanf_LOGSDLCALLS(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...)
{
int retval;
int result;
va_list ap;
SDL_Log_REAL("SDL3CALL SDL_sscanf");
va_start(ap, fmt);
retval = SDL_vsscanf_REAL(buf, fmt, ap);
result = SDL_vsscanf_REAL(buf, fmt, ap);
va_end(ap);
return retval;
return result;
}
static int SDLCALL SDL_snprintf_LOGSDLCALLS(SDL_OUT_Z_CAP(maxlen) char *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
int retval;
int result;
va_list ap;
SDL_Log_REAL("SDL3CALL SDL_snprintf");
va_start(ap, fmt);
retval = SDL_vsnprintf_REAL(buf, maxlen, fmt, ap);
result = SDL_vsnprintf_REAL(buf, maxlen, fmt, ap);
va_end(ap);
return retval;
return result;
}
static int SDLCALL SDL_asprintf_LOGSDLCALLS(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
int retval;
int result;
va_list ap;
SDL_Log_REAL("SDL3CALL SDL_asprintf");
va_start(ap, fmt);
retval = SDL_vasprintf_REAL(strp, fmt, ap);
result = SDL_vasprintf_REAL(strp, fmt, ap);
va_end(ap);
return retval;
return result;
}
static int SDLCALL SDL_swprintf_LOGSDLCALLS(SDL_OUT_Z_CAP(maxlen) wchar_t *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt, ...)
{
int retval;
int result;
va_list ap;
SDL_Log_REAL("SDL3CALL SDL_swprintf");
va_start(ap, fmt);
retval = SDL_vswprintf_REAL(buf, maxlen, fmt, ap);
result = SDL_vswprintf_REAL(buf, maxlen, fmt, ap);
va_end(ap);
return retval;
return result;
}
static size_t SDLCALL SDL_IOprintf_LOGSDLCALLS(SDL_IOStream *context, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
size_t retval;
size_t result;
va_list ap;
SDL_Log_REAL("SDL3CALL SDL_IOprintf");
va_start(ap, fmt);
retval = SDL_IOvprintf_REAL(context, fmt, ap);
result = SDL_IOvprintf_REAL(context, fmt, ap);
va_end(ap);
return retval;
return result;
}
static void SDLCALL SDL_Log_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
@@ -403,14 +403,14 @@ Sint32 SDL_DYNAPI_entry(Uint32 apiver, void *table, Uint32 tablesize)
static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
{
HMODULE lib = LoadLibraryA(fname);
void *retval = NULL;
void *result = NULL;
if (lib) {
retval = (void *) GetProcAddress(lib, sym);
if (!retval) {
result = (void *) GetProcAddress(lib, sym);
if (!result) {
FreeLibrary(lib);
}
}
return retval;
return result;
}
#elif defined(SDL_PLATFORM_UNIX) || defined(SDL_PLATFORM_APPLE) || defined(SDL_PLATFORM_HAIKU)
@@ -418,14 +418,14 @@ static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
{
void *lib = dlopen(fname, RTLD_NOW | RTLD_LOCAL);
void *retval = NULL;
void *result = NULL;
if (lib) {
retval = dlsym(lib, sym);
if (!retval) {
result = dlsym(lib, sym);
if (!result) {
dlclose(lib);
}
}
return retval;
return result;
}
#else

View File

@@ -39,7 +39,7 @@ SDL_DYNAPI_PROC(void,SDL_LogInfo,(int a, SDL_PRINTF_FORMAT_STRING const char *b,
SDL_DYNAPI_PROC(void,SDL_LogMessage,(int a, SDL_LogPriority b, SDL_PRINTF_FORMAT_STRING const char *c, ...),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_LogVerbose,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),)
SDL_DYNAPI_PROC(void,SDL_LogWarn,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),)
SDL_DYNAPI_PROC(int,SDL_SetError,(SDL_PRINTF_FORMAT_STRING const char *a, ...),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetError,(SDL_PRINTF_FORMAT_STRING const char *a, ...),(a),return)
SDL_DYNAPI_PROC(int,SDL_asprintf,(char **a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_snprintf,(SDL_OUT_Z_CAP(b) char *a, size_t b, SDL_PRINTF_FORMAT_STRING const char *c, ...),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_sscanf,(const char *a, SDL_SCANF_FORMAT_STRING const char *b, ...),(a,b),return)
@@ -48,15 +48,15 @@ SDL_DYNAPI_PROC(int,SDL_swprintf,(SDL_OUT_Z_CAP(b) wchar_t *a, size_t b, SDL_PRI
// New API symbols are added at the end
SDL_DYNAPI_PROC(SDL_Surface*,SDL_AcquireCameraFrame,(SDL_Camera *a, Uint64 *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_AddEventWatch,(SDL_EventFilter a, void *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_AddEventWatch,(SDL_EventFilter a, void *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_AddGamepadMapping,(const char *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_AddGamepadMappingsFromFile,(const char *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_AddGamepadMappingsFromIO,(SDL_IOStream *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_AddHintCallback,(const char *a, SDL_HintCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_AddSurfaceAlternateImage,(SDL_Surface *a, SDL_Surface *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_AddHintCallback,(const char *a, SDL_HintCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_AddSurfaceAlternateImage,(SDL_Surface *a, SDL_Surface *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_TimerID,SDL_AddTimer,(Uint32 a, SDL_TimerCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_TimerID,SDL_AddTimerNS,(Uint64 a, SDL_NSTimerCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_AddVulkanRenderSemaphores,(SDL_Renderer *a, Uint32 b, Sint64 c, Sint64 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_AddVulkanRenderSemaphores,(SDL_Renderer *a, Uint32 b, Sint64 c, Sint64 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_AtomicAdd,(SDL_AtomicInt *a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_AtomicCompareAndSwap,(SDL_AtomicInt *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_AtomicCompareAndSwapPointer,(void **a, void *b, void *c),(a,b,c),return)
@@ -66,47 +66,47 @@ SDL_DYNAPI_PROC(int,SDL_AtomicSet,(SDL_AtomicInt *a, int b),(a,b),return)
SDL_DYNAPI_PROC(void*,SDL_AtomicSetPtr,(void **a, void *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_JoystickID,SDL_AttachVirtualJoystick,(const SDL_VirtualJoystickDesc *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_AudioDevicePaused,(SDL_AudioDeviceID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_BindAudioStream,(SDL_AudioDeviceID a, SDL_AudioStream *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_BindAudioStreams,(SDL_AudioDeviceID a, SDL_AudioStream **b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_BlitSurface,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_BlitSurface9Grid,(SDL_Surface *a, const SDL_Rect *b, int c, int d, int e, int f, float g, SDL_ScaleMode h, SDL_Surface *i, const SDL_Rect *j),(a,b,c,d,e,f,g,h,i,j),return)
SDL_DYNAPI_PROC(int,SDL_BlitSurfaceScaled,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d, SDL_ScaleMode e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_BlitSurfaceTiled,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_BlitSurfaceTiledWithScale,(SDL_Surface *a, const SDL_Rect *b, float c, SDL_ScaleMode d, SDL_Surface *e, const SDL_Rect *f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(int,SDL_BlitSurfaceUnchecked,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_BlitSurfaceUncheckedScaled,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d, SDL_ScaleMode e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_BroadcastCondition,(SDL_Condition *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_CaptureMouse,(SDL_bool a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_BindAudioStream,(SDL_AudioDeviceID a, SDL_AudioStream *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_BindAudioStreams,(SDL_AudioDeviceID a, SDL_AudioStream **b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_BlitSurface,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_BlitSurface9Grid,(SDL_Surface *a, const SDL_Rect *b, int c, int d, int e, int f, float g, SDL_ScaleMode h, SDL_Surface *i, const SDL_Rect *j),(a,b,c,d,e,f,g,h,i,j),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_BlitSurfaceScaled,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d, SDL_ScaleMode e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_BlitSurfaceTiled,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_BlitSurfaceTiledWithScale,(SDL_Surface *a, const SDL_Rect *b, float c, SDL_ScaleMode d, SDL_Surface *e, const SDL_Rect *f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_BlitSurfaceUnchecked,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_BlitSurfaceUncheckedScaled,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d, SDL_ScaleMode e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(void,SDL_BroadcastCondition,(SDL_Condition *a),(a),)
SDL_DYNAPI_PROC(SDL_bool,SDL_CaptureMouse,(SDL_bool a),(a),return)
SDL_DYNAPI_PROC(void,SDL_CleanupTLS,(void),(),)
SDL_DYNAPI_PROC(int,SDL_ClearAudioStream,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_ClearClipboardData,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_ClearComposition,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_ClearError,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_ClearProperty,(SDL_PropertiesID a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_ClearSurface,(SDL_Surface *a, float b, float c, float d, float e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ClearAudioStream,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ClearClipboardData,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ClearComposition,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ClearError,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ClearProperty,(SDL_PropertiesID a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ClearSurface,(SDL_Surface *a, float b, float c, float d, float e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(void,SDL_CloseAudioDevice,(SDL_AudioDeviceID a),(a),)
SDL_DYNAPI_PROC(void,SDL_CloseCamera,(SDL_Camera *a),(a),)
SDL_DYNAPI_PROC(void,SDL_CloseGamepad,(SDL_Gamepad *a),(a),)
SDL_DYNAPI_PROC(void,SDL_CloseHaptic,(SDL_Haptic *a),(a),)
SDL_DYNAPI_PROC(int,SDL_CloseIO,(SDL_IOStream *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_CloseIO,(SDL_IOStream *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_CloseJoystick,(SDL_Joystick *a),(a),)
SDL_DYNAPI_PROC(void,SDL_CloseSensor,(SDL_Sensor *a),(a),)
SDL_DYNAPI_PROC(int,SDL_CloseStorage,(SDL_Storage *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_CloseStorage,(SDL_Storage *a),(a),return)
SDL_DYNAPI_PROC(SDL_BlendMode,SDL_ComposeCustomBlendMode,(SDL_BlendFactor a, SDL_BlendFactor b, SDL_BlendOperation c, SDL_BlendFactor d, SDL_BlendFactor e, SDL_BlendOperation f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(int,SDL_ConvertAudioSamples,(const SDL_AudioSpec *a, const Uint8 *b, int c, const SDL_AudioSpec *d, Uint8 **e, int *f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(int,SDL_ConvertEventToRenderCoordinates,(SDL_Renderer *a, SDL_Event *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_ConvertPixels,(int a, int b, SDL_PixelFormat c, const void *d, int e, SDL_PixelFormat f, void *g, int h),(a,b,c,d,e,f,g,h),return)
SDL_DYNAPI_PROC(int,SDL_ConvertPixelsAndColorspace,(int a, int b, SDL_PixelFormat c, SDL_Colorspace d, SDL_PropertiesID e, const void *f, int g, SDL_PixelFormat h, SDL_Colorspace i, SDL_PropertiesID j, void *k, int l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ConvertAudioSamples,(const SDL_AudioSpec *a, const Uint8 *b, int c, const SDL_AudioSpec *d, Uint8 **e, int *f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ConvertEventToRenderCoordinates,(SDL_Renderer *a, SDL_Event *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ConvertPixels,(int a, int b, SDL_PixelFormat c, const void *d, int e, SDL_PixelFormat f, void *g, int h),(a,b,c,d,e,f,g,h),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ConvertPixelsAndColorspace,(int a, int b, SDL_PixelFormat c, SDL_Colorspace d, SDL_PropertiesID e, const void *f, int g, SDL_PixelFormat h, SDL_Colorspace i, SDL_PropertiesID j, void *k, int l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurface,(SDL_Surface *a, SDL_PixelFormat b),(a,b),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurfaceAndColorspace,(SDL_Surface *a, SDL_PixelFormat b, SDL_Palette *c, SDL_Colorspace d, SDL_PropertiesID e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_CopyFile,(const char *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_CopyProperties,(SDL_PropertiesID a, SDL_PropertiesID b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_CopyStorageFile,(SDL_Storage *a, const char *b, const char *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_CopyFile,(const char *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_CopyProperties,(SDL_PropertiesID a, SDL_PropertiesID b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_CopyStorageFile,(SDL_Storage *a, const char *b, const char *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_AudioStream*,SDL_CreateAudioStream,(const SDL_AudioSpec *a, const SDL_AudioSpec *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_Cursor*,SDL_CreateColorCursor,(SDL_Surface *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_Condition*,SDL_CreateCondition,(void),(),return)
SDL_DYNAPI_PROC(SDL_Cursor*,SDL_CreateCursor,(const Uint8 *a, const Uint8 *b, int c, int d, int e, int f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(int,SDL_CreateDirectory,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_CreateDirectory,(const char *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_CreateHapticEffect,(SDL_Haptic *a, const SDL_HapticEffect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_Mutex*,SDL_CreateMutex,(void),(),return)
SDL_DYNAPI_PROC(SDL_Palette*,SDL_CreatePalette,(int a),(a),return)
@@ -117,7 +117,7 @@ SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateRenderer,(SDL_Window *a, const char *b),
SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateRendererWithProperties,(SDL_PropertiesID a),(a),return)
SDL_DYNAPI_PROC(SDL_Semaphore*,SDL_CreateSemaphore,(Uint32 a),(a),return)
SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateSoftwareRenderer,(SDL_Surface *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_CreateStorageDirectory,(SDL_Storage *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_CreateStorageDirectory,(SDL_Storage *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateSurface,(int a, int b, SDL_PixelFormat c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateSurfaceFrom,(int a, int b, SDL_PixelFormat c, void *d, int e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_Palette*,SDL_CreateSurfacePalette,(SDL_Surface *a),(a),return)
@@ -128,10 +128,10 @@ SDL_DYNAPI_PROC(SDL_Texture*,SDL_CreateTextureWithProperties,(SDL_Renderer *a, S
SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThreadRuntime,(SDL_ThreadFunction a, const char *b, void *c, SDL_FunctionPointer d, SDL_FunctionPointer e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThreadWithPropertiesRuntime,(SDL_PropertiesID a, SDL_FunctionPointer b, SDL_FunctionPointer c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_CreateWindow,(const char *a, int b, int c, SDL_WindowFlags d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_CreateWindowAndRenderer,(const char *a, int b, int c, SDL_WindowFlags d, SDL_Window **e, SDL_Renderer **f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_CreateWindowAndRenderer,(const char *a, int b, int c, SDL_WindowFlags d, SDL_Window **e, SDL_Renderer **f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_CreateWindowWithProperties,(SDL_PropertiesID a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_CursorVisible,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_DateTimeToTime,(const SDL_DateTime *a, SDL_Time *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_DateTimeToTime,(const SDL_DateTime *a, SDL_Time *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_DelEventWatch,(SDL_EventFilter a, void *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_DelHintCallback,(const char *a, SDL_HintCallback b, void *c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_Delay,(Uint32 a),(a),)
@@ -149,46 +149,46 @@ SDL_DYNAPI_PROC(void,SDL_DestroySemaphore,(SDL_Semaphore *a),(a),)
SDL_DYNAPI_PROC(void,SDL_DestroySurface,(SDL_Surface *a),(a),)
SDL_DYNAPI_PROC(void,SDL_DestroyTexture,(SDL_Texture *a),(a),)
SDL_DYNAPI_PROC(void,SDL_DestroyWindow,(SDL_Window *a),(a),)
SDL_DYNAPI_PROC(int,SDL_DestroyWindowSurface,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_DestroyWindowSurface,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_DetachThread,(SDL_Thread *a),(a),)
SDL_DYNAPI_PROC(int,SDL_DetachVirtualJoystick,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_DisableScreenSaver,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_DetachVirtualJoystick,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_DisableScreenSaver,(void),(),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_DuplicateSurface,(SDL_Surface *a),(a),return)
SDL_DYNAPI_PROC(SDL_EGLConfig,SDL_EGL_GetCurrentConfig,(void),(),return)
SDL_DYNAPI_PROC(SDL_EGLDisplay,SDL_EGL_GetCurrentDisplay,(void),(),return)
SDL_DYNAPI_PROC(SDL_FunctionPointer,SDL_EGL_GetProcAddress,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_EGLSurface,SDL_EGL_GetWindowSurface,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_EGL_SetAttributeCallbacks,(SDL_EGLAttribArrayCallback a, SDL_EGLIntArrayCallback b, SDL_EGLIntArrayCallback c),(a,b,c),)
SDL_DYNAPI_PROC(int,SDL_EnableScreenSaver,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_EnableScreenSaver,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_EnterAppMainCallbacks,(int a, char *b[], SDL_AppInit_func c, SDL_AppIterate_func d, SDL_AppEvent_func e, SDL_AppQuit_func f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(int,SDL_EnumerateDirectory,(const char *a, SDL_EnumerateDirectoryCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_EnumerateProperties,(SDL_PropertiesID a, SDL_EnumeratePropertiesCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_EnumerateStorageDirectory,(SDL_Storage *a, const char *b, SDL_EnumerateDirectoryCallback c, void *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_EnumerateDirectory,(const char *a, SDL_EnumerateDirectoryCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_EnumerateProperties,(SDL_PropertiesID a, SDL_EnumeratePropertiesCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_EnumerateStorageDirectory,(SDL_Storage *a, const char *b, SDL_EnumerateDirectoryCallback c, void *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_EventEnabled,(Uint32 a),(a),return)
SDL_DYNAPI_PROC(int,SDL_FillSurfaceRect,(SDL_Surface *a, const SDL_Rect *b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_FillSurfaceRects,(SDL_Surface *a, const SDL_Rect *b, int c, Uint32 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_FillSurfaceRect,(SDL_Surface *a, const SDL_Rect *b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_FillSurfaceRects,(SDL_Surface *a, const SDL_Rect *b, int c, Uint32 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(void,SDL_FilterEvents,(SDL_EventFilter a, void *b),(a,b),)
SDL_DYNAPI_PROC(int,SDL_FlashWindow,(SDL_Window *a, SDL_FlashOperation b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_FlipSurface,(SDL_Surface *a, SDL_FlipMode b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_FlushAudioStream,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_FlashWindow,(SDL_Window *a, SDL_FlashOperation b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_FlipSurface,(SDL_Surface *a, SDL_FlipMode b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_FlushAudioStream,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_FlushEvent,(Uint32 a),(a),)
SDL_DYNAPI_PROC(void,SDL_FlushEvents,(Uint32 a, Uint32 b),(a,b),)
SDL_DYNAPI_PROC(int,SDL_FlushRenderer,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_FlushRenderer,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_GDKSuspendComplete,(void),(),)
SDL_DYNAPI_PROC(SDL_GLContext,SDL_GL_CreateContext,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GL_DestroyContext,(SDL_GLContext a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GL_DestroyContext,(SDL_GLContext a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GL_ExtensionSupported,(const char *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GL_GetAttribute,(SDL_GLattr a, int *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GL_GetAttribute,(SDL_GLattr a, int *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_GLContext,SDL_GL_GetCurrentContext,(void),(),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_GL_GetCurrentWindow,(void),(),return)
SDL_DYNAPI_PROC(SDL_FunctionPointer,SDL_GL_GetProcAddress,(const char *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GL_GetSwapInterval,(int *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GL_LoadLibrary,(const char *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GL_MakeCurrent,(SDL_Window *a, SDL_GLContext b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GL_GetSwapInterval,(int *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GL_LoadLibrary,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GL_MakeCurrent,(SDL_Window *a, SDL_GLContext b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_GL_ResetAttributes,(void),(),)
SDL_DYNAPI_PROC(int,SDL_GL_SetAttribute,(SDL_GLattr a, int b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GL_SetSwapInterval,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GL_SwapWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GL_SetAttribute,(SDL_GLattr a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GL_SetSwapInterval,(int a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GL_SwapWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_GL_UnloadLibrary,(void),(),)
SDL_DYNAPI_PROC(void,SDL_GUIDToString,(SDL_GUID a, char *b, int c),(a,b,c),)
SDL_DYNAPI_PROC(SDL_bool,SDL_GamepadConnected,(SDL_Gamepad *a),(a),return)
@@ -208,7 +208,7 @@ SDL_DYNAPI_PROC(const char*,SDL_GetAppMetadataProperty,(const char *a),(a),retur
SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetAssertionHandler,(void **a),(a),return)
SDL_DYNAPI_PROC(const SDL_AssertData*,SDL_GetAssertionReport,(void),(),return)
SDL_DYNAPI_PROC(int*,SDL_GetAudioDeviceChannelMap,(SDL_AudioDeviceID a, int *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetAudioDeviceFormat,(SDL_AudioDeviceID a, SDL_AudioSpec *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetAudioDeviceFormat,(SDL_AudioDeviceID a, SDL_AudioSpec *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(float,SDL_GetAudioDeviceGain,(SDL_AudioDeviceID a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetAudioDeviceName,(SDL_AudioDeviceID a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetAudioDriver,(int a),(a),return)
@@ -218,7 +218,7 @@ SDL_DYNAPI_PROC(SDL_AudioDeviceID*,SDL_GetAudioRecordingDevices,(int *a),(a),ret
SDL_DYNAPI_PROC(int,SDL_GetAudioStreamAvailable,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetAudioStreamData,(SDL_AudioStream *a, void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_AudioDeviceID,SDL_GetAudioStreamDevice,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetAudioStreamFormat,(SDL_AudioStream *a, SDL_AudioSpec *b, SDL_AudioSpec *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetAudioStreamFormat,(SDL_AudioStream *a, SDL_AudioSpec *b, SDL_AudioSpec *c),(a,b,c),return)
SDL_DYNAPI_PROC(float,SDL_GetAudioStreamFrequencyRatio,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(float,SDL_GetAudioStreamGain,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(int*,SDL_GetAudioStreamInputChannelMap,(SDL_AudioStream *a, int *b),(a,b),return)
@@ -230,7 +230,7 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_GetBooleanProperty,(SDL_PropertiesID a, const char
SDL_DYNAPI_PROC(int,SDL_GetCPUCacheLineSize,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetCPUCount,(void),(),return)
SDL_DYNAPI_PROC(const char*,SDL_GetCameraDriver,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetCameraFormat,(SDL_Camera *a, SDL_CameraSpec *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetCameraFormat,(SDL_Camera *a, SDL_CameraSpec *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_CameraID,SDL_GetCameraID,(SDL_Camera *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetCameraName,(SDL_CameraID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetCameraPermissionState,(SDL_Camera *a),(a),return)
@@ -240,18 +240,18 @@ SDL_DYNAPI_PROC(SDL_CameraSpec**,SDL_GetCameraSupportedFormats,(SDL_CameraID a,
SDL_DYNAPI_PROC(SDL_CameraID*,SDL_GetCameras,(int *a),(a),return)
SDL_DYNAPI_PROC(void*,SDL_GetClipboardData,(const char *a, size_t *b),(a,b),return)
SDL_DYNAPI_PROC(char*,SDL_GetClipboardText,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetClosestFullscreenDisplayMode,(SDL_DisplayID a, int b, int c, float d, SDL_bool e, SDL_DisplayMode *f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetClosestFullscreenDisplayMode,(SDL_DisplayID a, int b, int c, float d, SDL_bool e, SDL_DisplayMode *f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(const char*,SDL_GetCurrentAudioDriver,(void),(),return)
SDL_DYNAPI_PROC(const char*,SDL_GetCurrentCameraDriver,(void),(),return)
SDL_DYNAPI_PROC(const SDL_DisplayMode*,SDL_GetCurrentDisplayMode,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayOrientation,SDL_GetCurrentDisplayOrientation,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetCurrentRenderOutputSize,(SDL_Renderer *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetCurrentRenderOutputSize,(SDL_Renderer *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_ThreadID,SDL_GetCurrentThreadID,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetCurrentTime,(SDL_Time *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetCurrentTime,(SDL_Time *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetCurrentVideoDriver,(void),(),return)
SDL_DYNAPI_PROC(SDL_Cursor*,SDL_GetCursor,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetDXGIOutputInfo,(SDL_DisplayID a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetDateTimeLocalePreferences,(SDL_DateFormat *a, SDL_TimeFormat *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetDXGIOutputInfo,(SDL_DisplayID a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetDateTimeLocalePreferences,(SDL_DateFormat *a, SDL_TimeFormat *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetDayOfWeek,(int a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetDayOfYear,(int a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetDaysInMonth,(int a, int b),(a,b),return)
@@ -259,21 +259,21 @@ SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetDefaultAssertionHandler,(void),(),re
SDL_DYNAPI_PROC(SDL_Cursor*,SDL_GetDefaultCursor,(void),(),return)
SDL_DYNAPI_PROC(const SDL_DisplayMode*,SDL_GetDesktopDisplayMode,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetDirect3D9AdapterIndex,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayBounds,(SDL_DisplayID a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetDisplayBounds,(SDL_DisplayID a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(float,SDL_GetDisplayContentScale,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetDisplayForPoint,(const SDL_Point *a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetDisplayForRect,(const SDL_Rect *a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetDisplayForWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetDisplayName,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetDisplayProperties,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayUsableBounds,(SDL_DisplayID a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetDisplayUsableBounds,(SDL_DisplayID a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_DisplayID*,SDL_GetDisplays,(int *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetError,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetEventFilter,(SDL_EventFilter *a, void **b),(a,b),return)
SDL_DYNAPI_PROC(float,SDL_GetFloatProperty,(SDL_PropertiesID a, const char *b, float c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_DisplayMode**,SDL_GetFullscreenDisplayModes,(SDL_DisplayID a, int *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetGDKDefaultUser,(XUserHandle *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetGDKTaskQueue,(XTaskQueueHandle *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetGDKDefaultUser,(XUserHandle *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetGDKTaskQueue,(XTaskQueueHandle *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetGamepadAppleSFSymbolsNameForAxis,(SDL_Gamepad *a, SDL_GamepadAxis b),(a,b),return)
SDL_DYNAPI_PROC(const char*,SDL_GetGamepadAppleSFSymbolsNameForButton,(SDL_Gamepad *a, SDL_GamepadButton b),(a,b),return)
SDL_DYNAPI_PROC(Sint16,SDL_GetGamepadAxis,(SDL_Gamepad *a, SDL_GamepadAxis b),(a,b),return)
@@ -306,14 +306,14 @@ SDL_DYNAPI_PROC(Uint16,SDL_GetGamepadProductForID,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(Uint16,SDL_GetGamepadProductVersion,(SDL_Gamepad *a),(a),return)
SDL_DYNAPI_PROC(Uint16,SDL_GetGamepadProductVersionForID,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetGamepadProperties,(SDL_Gamepad *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetGamepadSensorData,(SDL_Gamepad *a, SDL_SensorType b, float *c, int d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetGamepadSensorData,(SDL_Gamepad *a, SDL_SensorType b, float *c, int d),(a,b,c,d),return)
SDL_DYNAPI_PROC(float,SDL_GetGamepadSensorDataRate,(SDL_Gamepad *a, SDL_SensorType b),(a,b),return)
SDL_DYNAPI_PROC(const char*,SDL_GetGamepadSerial,(SDL_Gamepad *a),(a),return)
SDL_DYNAPI_PROC(Uint64,SDL_GetGamepadSteamHandle,(SDL_Gamepad *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetGamepadStringForAxis,(SDL_GamepadAxis a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetGamepadStringForButton,(SDL_GamepadButton a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetGamepadStringForType,(SDL_GamepadType a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetGamepadTouchpadFinger,(SDL_Gamepad *a, int b, int c, Uint8 *d, float *e, float *f, float *g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetGamepadTouchpadFinger,(SDL_Gamepad *a, int b, int c, Uint8 *d, float *e, float *f, float *g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(SDL_GamepadType,SDL_GetGamepadType,(SDL_Gamepad *a),(a),return)
SDL_DYNAPI_PROC(SDL_GamepadType,SDL_GetGamepadTypeForID,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(SDL_GamepadType,SDL_GetGamepadTypeFromString,(const char *a),(a),return)
@@ -323,7 +323,7 @@ SDL_DYNAPI_PROC(SDL_JoystickID*,SDL_GetGamepads,(int *a),(a),return)
SDL_DYNAPI_PROC(SDL_MouseButtonFlags,SDL_GetGlobalMouseState,(float *a, float *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetGlobalProperties,(void),(),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetGrabbedWindow,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetHapticEffectStatus,(SDL_Haptic *a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetHapticEffectStatus,(SDL_Haptic *a, int b),(a,b),return)
SDL_DYNAPI_PROC(Uint32,SDL_GetHapticFeatures,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(SDL_Haptic*,SDL_GetHapticFromID,(SDL_HapticID a),(a),return)
SDL_DYNAPI_PROC(SDL_HapticID,SDL_GetHapticID,(SDL_Haptic *a),(a),return)
@@ -337,7 +337,7 @@ SDL_DYNAPI_PROC(Sint64,SDL_GetIOSize,(SDL_IOStream *a),(a),return)
SDL_DYNAPI_PROC(SDL_IOStatus,SDL_GetIOStatus,(SDL_IOStream *a),(a),return)
SDL_DYNAPI_PROC(Sint16,SDL_GetJoystickAxis,(SDL_Joystick *a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetJoystickAxisInitialState,(SDL_Joystick *a, int b, Sint16 *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetJoystickBall,(SDL_Joystick *a, int b, int *c, int *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetJoystickBall,(SDL_Joystick *a, int b, int *c, int *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(Uint8,SDL_GetJoystickButton,(SDL_Joystick *a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_JoystickConnectionState,SDL_GetJoystickConnectionState,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(Uint16,SDL_GetJoystickFirmwareVersion,(SDL_Joystick *a),(a),return)
@@ -375,7 +375,7 @@ SDL_DYNAPI_PROC(const Uint8*,SDL_GetKeyboardState,(int *a),(a),return)
SDL_DYNAPI_PROC(SDL_KeyboardID*,SDL_GetKeyboards,(int *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_GetLogOutputFunction,(SDL_LogOutputFunction *a, void **b),(a,b),)
SDL_DYNAPI_PROC(SDL_LogPriority,SDL_GetLogPriority,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetMasksForPixelFormat,(SDL_PixelFormat a, int *b, Uint32 *c, Uint32 *d, Uint32 *e, Uint32 *f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetMasksForPixelFormat,(SDL_PixelFormat a, int *b, Uint32 *c, Uint32 *d, Uint32 *e, Uint32 *f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(int,SDL_GetMaxHapticEffects,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetMaxHapticEffectsPlaying,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_GetMemoryFunctions,(SDL_malloc_func *a, SDL_calloc_func *b, SDL_realloc_func *c, SDL_free_func *d),(a,b,c,d),)
@@ -399,7 +399,7 @@ SDL_DYNAPI_PROC(int,SDL_GetNumRenderDrivers,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetNumVideoDrivers,(void),(),return)
SDL_DYNAPI_PROC(Sint64,SDL_GetNumberProperty,(SDL_PropertiesID a, const char *b, Sint64 c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_GetOriginalMemoryFunctions,(SDL_malloc_func *a, SDL_calloc_func *b, SDL_realloc_func *c, SDL_free_func *d),(a,b,c,d),)
SDL_DYNAPI_PROC(int,SDL_GetPathInfo,(const char *a, SDL_PathInfo *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetPathInfo,(const char *a, SDL_PathInfo *b),(a,b),return)
SDL_DYNAPI_PROC(Uint64,SDL_GetPerformanceCounter,(void),(),return)
SDL_DYNAPI_PROC(Uint64,SDL_GetPerformanceFrequency,(void),(),return)
SDL_DYNAPI_PROC(const SDL_PixelFormatDetails*,SDL_GetPixelFormatDetails,(SDL_PixelFormat a),(a),return)
@@ -423,25 +423,25 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectEnclosingPoints,(const SDL_Point *a, int b,
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectEnclosingPointsFloat,(const SDL_FPoint *a, int b, const SDL_FRect *c, SDL_FRect *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectIntersection,(const SDL_Rect *a, const SDL_Rect *b, SDL_Rect *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectIntersectionFloat,(const SDL_FRect *a, const SDL_FRect *b, SDL_FRect *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetRectUnion,(const SDL_Rect *a, const SDL_Rect *b, SDL_Rect *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetRectUnionFloat,(const SDL_FRect *a, const SDL_FRect *b, SDL_FRect *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectUnion,(const SDL_Rect *a, const SDL_Rect *b, SDL_Rect *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectUnionFloat,(const SDL_FRect *a, const SDL_FRect *b, SDL_FRect *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_MouseButtonFlags,SDL_GetRelativeMouseState,(float *a, float *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderClipRect,(SDL_Renderer *a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderColorScale,(SDL_Renderer *a, float *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderDrawBlendMode,(SDL_Renderer *a, SDL_BlendMode *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderDrawColor,(SDL_Renderer *a, Uint8 *b, Uint8 *c, Uint8 *d, Uint8 *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderDrawColorFloat,(SDL_Renderer *a, float *b, float *c, float *d, float *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRenderClipRect,(SDL_Renderer *a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRenderColorScale,(SDL_Renderer *a, float *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRenderDrawBlendMode,(SDL_Renderer *a, SDL_BlendMode *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRenderDrawColor,(SDL_Renderer *a, Uint8 *b, Uint8 *c, Uint8 *d, Uint8 *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRenderDrawColorFloat,(SDL_Renderer *a, float *b, float *c, float *d, float *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(const char*,SDL_GetRenderDriver,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderLogicalPresentation,(SDL_Renderer *a, int *b, int *c, SDL_RendererLogicalPresentation *d, SDL_ScaleMode *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderLogicalPresentationRect,(SDL_Renderer *a, SDL_FRect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRenderLogicalPresentation,(SDL_Renderer *a, int *b, int *c, SDL_RendererLogicalPresentation *d, SDL_ScaleMode *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRenderLogicalPresentationRect,(SDL_Renderer *a, SDL_FRect *b),(a,b),return)
SDL_DYNAPI_PROC(void*,SDL_GetRenderMetalCommandEncoder,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(void*,SDL_GetRenderMetalLayer,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderOutputSize,(SDL_Renderer *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderSafeArea,(SDL_Renderer *a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderScale,(SDL_Renderer *a, float *b, float *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRenderOutputSize,(SDL_Renderer *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRenderSafeArea,(SDL_Renderer *a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRenderScale,(SDL_Renderer *a, float *b, float *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_Texture*,SDL_GetRenderTarget,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderVSync,(SDL_Renderer *a, int *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderViewport,(SDL_Renderer *a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRenderVSync,(SDL_Renderer *a, int *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRenderViewport,(SDL_Renderer *a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetRenderWindow,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(SDL_Renderer*,SDL_GetRenderer,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_Renderer*,SDL_GetRendererFromTexture,(SDL_Texture *a),(a),return)
@@ -453,7 +453,7 @@ SDL_DYNAPI_PROC(SDL_Scancode,SDL_GetScancodeFromKey,(SDL_Keycode a, SDL_Keymod *
SDL_DYNAPI_PROC(SDL_Scancode,SDL_GetScancodeFromName,(const char *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetScancodeName,(SDL_Scancode a),(a),return)
SDL_DYNAPI_PROC(Uint32,SDL_GetSemaphoreValue,(SDL_Semaphore *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetSensorData,(SDL_Sensor *a, float *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetSensorData,(SDL_Sensor *a, float *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_Sensor*,SDL_GetSensorFromID,(SDL_SensorID a),(a),return)
SDL_DYNAPI_PROC(SDL_SensorID,SDL_GetSensorID,(SDL_Sensor *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetSensorName,(SDL_Sensor *a),(a),return)
@@ -465,15 +465,15 @@ SDL_DYNAPI_PROC(SDL_SensorType,SDL_GetSensorType,(SDL_Sensor *a),(a),return)
SDL_DYNAPI_PROC(SDL_SensorType,SDL_GetSensorTypeForID,(SDL_SensorID a),(a),return)
SDL_DYNAPI_PROC(SDL_SensorID*,SDL_GetSensors,(int *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetSilenceValueForFormat,(SDL_AudioFormat a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetStorageFileSize,(SDL_Storage *a, const char *b, Uint64 *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetStoragePathInfo,(SDL_Storage *a, const char *b, SDL_PathInfo *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetStorageFileSize,(SDL_Storage *a, const char *b, Uint64 *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetStoragePathInfo,(SDL_Storage *a, const char *b, SDL_PathInfo *c),(a,b,c),return)
SDL_DYNAPI_PROC(Uint64,SDL_GetStorageSpaceRemaining,(SDL_Storage *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetStringProperty,(SDL_PropertiesID a, const char *b, const char *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetSurfaceAlphaMod,(SDL_Surface *a, Uint8 *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetSurfaceBlendMode,(SDL_Surface *a, SDL_BlendMode *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetSurfaceClipRect,(SDL_Surface *a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetSurfaceColorKey,(SDL_Surface *a, Uint32 *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetSurfaceColorMod,(SDL_Surface *a, Uint8 *b, Uint8 *c, Uint8 *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetSurfaceAlphaMod,(SDL_Surface *a, Uint8 *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetSurfaceBlendMode,(SDL_Surface *a, SDL_BlendMode *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetSurfaceClipRect,(SDL_Surface *a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetSurfaceColorKey,(SDL_Surface *a, Uint32 *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetSurfaceColorMod,(SDL_Surface *a, Uint8 *b, Uint8 *c, Uint8 *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_Colorspace,SDL_GetSurfaceColorspace,(SDL_Surface *a),(a),return)
SDL_DYNAPI_PROC(SDL_Surface**,SDL_GetSurfaceImages,(SDL_Surface *a, int *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_Palette*,SDL_GetSurfacePalette,(SDL_Surface *a),(a),return)
@@ -481,15 +481,15 @@ SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetSurfaceProperties,(SDL_Surface *a),(a),r
SDL_DYNAPI_PROC(int,SDL_GetSystemRAM,(void),(),return)
SDL_DYNAPI_PROC(SDL_SystemTheme,SDL_GetSystemTheme,(void),(),return)
SDL_DYNAPI_PROC(void*,SDL_GetTLS,(SDL_TLSID *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetTextInputArea,(SDL_Window *a, SDL_Rect *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetTextureAlphaMod,(SDL_Texture *a, Uint8 *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetTextureAlphaModFloat,(SDL_Texture *a, float *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetTextureBlendMode,(SDL_Texture *a, SDL_BlendMode *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetTextureColorMod,(SDL_Texture *a, Uint8 *b, Uint8 *c, Uint8 *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_GetTextureColorModFloat,(SDL_Texture *a, float *b, float *c, float *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetTextInputArea,(SDL_Window *a, SDL_Rect *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetTextureAlphaMod,(SDL_Texture *a, Uint8 *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetTextureAlphaModFloat,(SDL_Texture *a, float *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetTextureBlendMode,(SDL_Texture *a, SDL_BlendMode *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetTextureColorMod,(SDL_Texture *a, Uint8 *b, Uint8 *c, Uint8 *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetTextureColorModFloat,(SDL_Texture *a, float *b, float *c, float *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetTextureProperties,(SDL_Texture *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetTextureScaleMode,(SDL_Texture *a, SDL_ScaleMode *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetTextureSize,(SDL_Texture *a, float *b, float *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetTextureScaleMode,(SDL_Texture *a, SDL_ScaleMode *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetTextureSize,(SDL_Texture *a, float *b, float *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_ThreadID,SDL_GetThreadID,(SDL_Thread *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetThreadName,(SDL_Thread *a),(a),return)
SDL_DYNAPI_PROC(Uint64,SDL_GetTicks,(void),(),return)
@@ -503,8 +503,8 @@ SDL_DYNAPI_PROC(int,SDL_GetVersion,(void),(),return)
SDL_DYNAPI_PROC(const char*,SDL_GetVideoDriver,(int a),(a),return)
SDL_DYNAPI_PROC(SDL_WinRT_DeviceFamily,SDL_GetWinRTDeviceFamily,(void),(),return)
SDL_DYNAPI_PROC(const char*,SDL_GetWinRTFSPath,(SDL_WinRT_Path a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowAspectRatio,(SDL_Window *a, float *b, float *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowBordersSize,(SDL_Window *a, int *b, int *c, int *d, int *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowAspectRatio,(SDL_Window *a, float *b, float *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowBordersSize,(SDL_Window *a, int *b, int *c, int *d, int *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(float,SDL_GetWindowDisplayScale,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_WindowFlags,SDL_GetWindowFlags,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetWindowFromEvent,(const SDL_Event *a),(a),return)
@@ -513,22 +513,22 @@ SDL_DYNAPI_PROC(const SDL_DisplayMode*,SDL_GetWindowFullscreenMode,(SDL_Window *
SDL_DYNAPI_PROC(void*,SDL_GetWindowICCProfile,(SDL_Window *a, size_t *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_WindowID,SDL_GetWindowID,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowKeyboardGrab,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowMaximumSize,(SDL_Window *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowMinimumSize,(SDL_Window *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowMaximumSize,(SDL_Window *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowMinimumSize,(SDL_Window *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowMouseGrab,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(const SDL_Rect*,SDL_GetWindowMouseRect,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(float,SDL_GetWindowOpacity,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetWindowParent,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(float,SDL_GetWindowPixelDensity,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_PixelFormat,SDL_GetWindowPixelFormat,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowPosition,(SDL_Window *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowPosition,(SDL_Window *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetWindowProperties,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowRelativeMouseMode,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowSafeArea,(SDL_Window *a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowSize,(SDL_Window *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowSizeInPixels,(SDL_Window *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowSafeArea,(SDL_Window *a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowSize,(SDL_Window *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowSizeInPixels,(SDL_Window *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_GetWindowSurface,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowSurfaceVSync,(SDL_Window *a, int *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowSurfaceVSync,(SDL_Window *a, int *b),(a,b),return)
SDL_DYNAPI_PROC(const char*,SDL_GetWindowTitle,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_Window**,SDL_GetWindows,(int *a),(a),return)
SDL_DYNAPI_PROC(char **,SDL_GlobDirectory,(const char *a, const char *b, SDL_GlobFlags c, int *d),(a,b,c,d),return)
@@ -562,16 +562,16 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_HasSSE3,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_HasSSE41,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_HasSSE42,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_HasScreenKeyboardSupport,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_HideCursor,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_HideWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_HideCursor,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_HideWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_IOStream*,SDL_IOFromConstMem,(const void *a, size_t b),(a,b),return)
SDL_DYNAPI_PROC(SDL_IOStream*,SDL_IOFromDynamicMem,(void),(),return)
SDL_DYNAPI_PROC(SDL_IOStream*,SDL_IOFromFile,(const char *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_IOStream*,SDL_IOFromMem,(void *a, size_t b),(a,b),return)
SDL_DYNAPI_PROC(size_t,SDL_IOvprintf,(SDL_IOStream *a, SDL_PRINTF_FORMAT_STRING const char *b, va_list c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_Init,(SDL_InitFlags a),(a),return)
SDL_DYNAPI_PROC(int,SDL_InitHapticRumble,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_InitSubSystem,(SDL_InitFlags a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_Init,(SDL_InitFlags a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_InitHapticRumble,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_InitSubSystem,(SDL_InitFlags a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_IsAndroidTV,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_IsChromebook,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_IsDeXMode,(void),(),return)
@@ -588,31 +588,31 @@ SDL_DYNAPI_PROC(void*,SDL_LoadFile,(const char *a, size_t *b),(a,b),return)
SDL_DYNAPI_PROC(void*,SDL_LoadFile_IO,(SDL_IOStream *a, size_t *b, SDL_bool c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_FunctionPointer,SDL_LoadFunction,(void *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(void*,SDL_LoadObject,(const char *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_LoadWAV,(const char *a, SDL_AudioSpec *b, Uint8 **c, Uint32 *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_LoadWAV_IO,(SDL_IOStream *a, SDL_bool b, SDL_AudioSpec *c, Uint8 **d, Uint32 *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_LockAudioStream,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_LoadWAV,(const char *a, SDL_AudioSpec *b, Uint8 **c, Uint32 *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_LoadWAV_IO,(SDL_IOStream *a, SDL_bool b, SDL_AudioSpec *c, Uint8 **d, Uint32 *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_LockAudioStream,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_LockJoysticks,(void),(),)
SDL_DYNAPI_PROC(void,SDL_LockMutex,(SDL_Mutex *a),(a),)
SDL_DYNAPI_PROC(int,SDL_LockProperties,(SDL_PropertiesID a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_LockProperties,(SDL_PropertiesID a),(a),return)
SDL_DYNAPI_PROC(void,SDL_LockRWLockForReading,(SDL_RWLock *a),(a),)
SDL_DYNAPI_PROC(void,SDL_LockRWLockForWriting,(SDL_RWLock *a),(a),)
SDL_DYNAPI_PROC(void,SDL_LockSpinlock,(SDL_SpinLock *a),(a),)
SDL_DYNAPI_PROC(int,SDL_LockSurface,(SDL_Surface *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_LockTexture,(SDL_Texture *a, const SDL_Rect *b, void **c, int *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_LockTextureToSurface,(SDL_Texture *a, const SDL_Rect *b, SDL_Surface **c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_LockSurface,(SDL_Surface *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_LockTexture,(SDL_Texture *a, const SDL_Rect *b, void **c, int *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_LockTextureToSurface,(SDL_Texture *a, const SDL_Rect *b, SDL_Surface **c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_LogMessageV,(int a, SDL_LogPriority b, SDL_PRINTF_FORMAT_STRING const char *c, va_list d),(a,b,c,d),)
SDL_DYNAPI_PROC(Uint32,SDL_MapRGB,(const SDL_PixelFormatDetails *a, const SDL_Palette *b, Uint8 c, Uint8 d, Uint8 e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(Uint32,SDL_MapRGBA,(const SDL_PixelFormatDetails *a, const SDL_Palette *b, Uint8 c, Uint8 d, Uint8 e, Uint8 f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(Uint32,SDL_MapSurfaceRGB,(SDL_Surface *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(Uint32,SDL_MapSurfaceRGBA,(SDL_Surface *a, Uint8 b, Uint8 c, Uint8 d, Uint8 e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_MaximizeWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_MaximizeWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_MemoryBarrierAcquireFunction,(void),(),)
SDL_DYNAPI_PROC(void,SDL_MemoryBarrierReleaseFunction,(void),(),)
SDL_DYNAPI_PROC(SDL_MetalView,SDL_Metal_CreateView,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_Metal_DestroyView,(SDL_MetalView a),(a),)
SDL_DYNAPI_PROC(void*,SDL_Metal_GetLayer,(SDL_MetalView a),(a),return)
SDL_DYNAPI_PROC(int,SDL_MinimizeWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_MixAudio,(Uint8 *a, const Uint8 *b, SDL_AudioFormat c, Uint32 d, float e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_MinimizeWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_MixAudio,(Uint8 *a, const Uint8 *b, SDL_AudioFormat c, Uint32 d, float e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(void,SDL_OnApplicationDidChangeStatusBarOrientation,(void),(),)
SDL_DYNAPI_PROC(void,SDL_OnApplicationDidEnterBackground,(void),(),)
SDL_DYNAPI_PROC(void,SDL_OnApplicationDidEnterForeground,(void),(),)
@@ -633,23 +633,23 @@ SDL_DYNAPI_PROC(SDL_Joystick*,SDL_OpenJoystick,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(SDL_Sensor*,SDL_OpenSensor,(SDL_SensorID a),(a),return)
SDL_DYNAPI_PROC(SDL_Storage*,SDL_OpenStorage,(const SDL_StorageInterface *a, void *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_Storage*,SDL_OpenTitleStorage,(const char *a, SDL_PropertiesID b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_OpenURL,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_OpenURL,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_Storage*,SDL_OpenUserStorage,(const char *a, const char *b, SDL_PropertiesID c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_OutOfMemory,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_PauseAudioDevice,(SDL_AudioDeviceID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_PauseAudioStreamDevice,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_PauseHaptic,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_OutOfMemory,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_PauseAudioDevice,(SDL_AudioDeviceID a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_PauseAudioStreamDevice,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_PauseHaptic,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_PeepEvents,(SDL_Event *a, int b, SDL_EventAction c, Uint32 d, Uint32 e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_PlayHapticRumble,(SDL_Haptic *a, float b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_PlayHapticRumble,(SDL_Haptic *a, float b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_PollEvent,(SDL_Event *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_PremultiplyAlpha,(int a, int b, SDL_PixelFormat c, const void *d, int e, SDL_PixelFormat f, void *g, int h, SDL_bool i),(a,b,c,d,e,f,g,h,i),return)
SDL_DYNAPI_PROC(int,SDL_PremultiplySurfaceAlpha,(SDL_Surface *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_PremultiplyAlpha,(int a, int b, SDL_PixelFormat c, const void *d, int e, SDL_PixelFormat f, void *g, int h, SDL_bool i),(a,b,c,d,e,f,g,h,i),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_PremultiplySurfaceAlpha,(SDL_Surface *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_PumpEvents,(void),(),)
SDL_DYNAPI_PROC(int,SDL_PushEvent,(SDL_Event *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_PutAudioStreamData,(SDL_AudioStream *a, const void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_PushEvent,(SDL_Event *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_PutAudioStreamData,(SDL_AudioStream *a, const void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_Quit,(void),(),)
SDL_DYNAPI_PROC(void,SDL_QuitSubSystem,(SDL_InitFlags a),(a),)
SDL_DYNAPI_PROC(int,SDL_RaiseWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RaiseWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(size_t,SDL_ReadIO,(SDL_IOStream *a, void *b, size_t c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadS16BE,(SDL_IOStream *a, Sint16 *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadS16LE,(SDL_IOStream *a, Sint16 *b),(a,b),return)
@@ -658,9 +658,9 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_ReadS32LE,(SDL_IOStream *a, Sint32 *b),(a,b),return
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadS64BE,(SDL_IOStream *a, Sint64 *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadS64LE,(SDL_IOStream *a, Sint64 *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadS8,(SDL_IOStream *a, Sint8 *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_ReadStorageFile,(SDL_Storage *a, const char *b, void *c, Uint64 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_ReadSurfacePixel,(SDL_Surface *a, int b, int c, Uint8 *d, Uint8 *e, Uint8 *f, Uint8 *g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(int,SDL_ReadSurfacePixelFloat,(SDL_Surface *a, int b, int c, float *d, float *e, float *f, float *g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadStorageFile,(SDL_Storage *a, const char *b, void *c, Uint64 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadSurfacePixel,(SDL_Surface *a, int b, int c, Uint8 *d, Uint8 *e, Uint8 *f, Uint8 *g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadSurfacePixelFloat,(SDL_Surface *a, int b, int c, float *d, float *e, float *f, float *g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadU16BE,(SDL_IOStream *a, Uint16 *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadU16LE,(SDL_IOStream *a, Uint16 *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadU32BE,(SDL_IOStream *a, Uint32 *b),(a,b),return)
@@ -668,209 +668,209 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_ReadU32LE,(SDL_IOStream *a, Uint32 *b),(a,b),return
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadU64BE,(SDL_IOStream *a, Uint64 *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadU64LE,(SDL_IOStream *a, Uint64 *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadU8,(SDL_IOStream *a, Uint8 *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_RegisterApp,(const char *a, Uint32 b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RegisterApp,(const char *a, Uint32 b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(Uint32,SDL_RegisterEvents,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_ReleaseCameraFrame,(SDL_Camera *a, SDL_Surface *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_ReloadGamepadMappings,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_RemovePath,(const char *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_RemoveStoragePath,(SDL_Storage *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_ReleaseCameraFrame,(SDL_Camera *a, SDL_Surface *b),(a,b),)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReloadGamepadMappings,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RemovePath,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RemoveStoragePath,(SDL_Storage *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_RemoveSurfaceAlternateImages,(SDL_Surface *a),(a),)
SDL_DYNAPI_PROC(int,SDL_RemoveTimer,(SDL_TimerID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_RenamePath,(const char *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_RenameStoragePath,(SDL_Storage *a, const char *b, const char *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_RenderClear,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RemoveTimer,(SDL_TimerID a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenamePath,(const char *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenameStoragePath,(SDL_Storage *a, const char *b, const char *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderClear,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderClipEnabled,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_RenderCoordinatesFromWindow,(SDL_Renderer *a, float b, float c, float *d, float *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_RenderCoordinatesToWindow,(SDL_Renderer *a, float b, float c, float *d, float *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_RenderFillRect,(SDL_Renderer *a, const SDL_FRect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_RenderFillRects,(SDL_Renderer *a, const SDL_FRect *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_RenderGeometry,(SDL_Renderer *a, SDL_Texture *b, const SDL_Vertex *c, int d, const int *e, int f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(int,SDL_RenderGeometryRaw,(SDL_Renderer *a, SDL_Texture *b, const float *c, int d, const SDL_FColor *e, int f, const float *g, int h, int i, const void *j, int k, int l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
SDL_DYNAPI_PROC(int,SDL_RenderLine,(SDL_Renderer *a, float b, float c, float d, float e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_RenderLines,(SDL_Renderer *a, const SDL_FPoint *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_RenderPoint,(SDL_Renderer *a, float b, float c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_RenderPoints,(SDL_Renderer *a, const SDL_FPoint *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_RenderPresent,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderCoordinatesFromWindow,(SDL_Renderer *a, float b, float c, float *d, float *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderCoordinatesToWindow,(SDL_Renderer *a, float b, float c, float *d, float *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderFillRect,(SDL_Renderer *a, const SDL_FRect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderFillRects,(SDL_Renderer *a, const SDL_FRect *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderGeometry,(SDL_Renderer *a, SDL_Texture *b, const SDL_Vertex *c, int d, const int *e, int f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderGeometryRaw,(SDL_Renderer *a, SDL_Texture *b, const float *c, int d, const SDL_FColor *e, int f, const float *g, int h, int i, const void *j, int k, int l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderLine,(SDL_Renderer *a, float b, float c, float d, float e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderLines,(SDL_Renderer *a, const SDL_FPoint *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderPoint,(SDL_Renderer *a, float b, float c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderPoints,(SDL_Renderer *a, const SDL_FPoint *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderPresent,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_RenderReadPixels,(SDL_Renderer *a, const SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_RenderRect,(SDL_Renderer *a, const SDL_FRect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_RenderRects,(SDL_Renderer *a, const SDL_FRect *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_RenderTexture,(SDL_Renderer *a, SDL_Texture *b, const SDL_FRect *c, const SDL_FRect *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_RenderTexture9Grid,(SDL_Renderer *a, SDL_Texture *b, const SDL_FRect *c, float d, float e, float f, float g, float h, const SDL_FRect *i),(a,b,c,d,e,f,g,h,i),return)
SDL_DYNAPI_PROC(int,SDL_RenderTextureRotated,(SDL_Renderer *a, SDL_Texture *b, const SDL_FRect *c, const SDL_FRect *d, const double e, const SDL_FPoint *f, const SDL_FlipMode g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(int,SDL_RenderTextureTiled,(SDL_Renderer *a, SDL_Texture *b, const SDL_FRect *c, float d, const SDL_FRect *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderRect,(SDL_Renderer *a, const SDL_FRect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderRects,(SDL_Renderer *a, const SDL_FRect *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderTexture,(SDL_Renderer *a, SDL_Texture *b, const SDL_FRect *c, const SDL_FRect *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderTexture9Grid,(SDL_Renderer *a, SDL_Texture *b, const SDL_FRect *c, float d, float e, float f, float g, float h, const SDL_FRect *i),(a,b,c,d,e,f,g,h,i),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderTextureRotated,(SDL_Renderer *a, SDL_Texture *b, const SDL_FRect *c, const SDL_FRect *d, const double e, const SDL_FPoint *f, const SDL_FlipMode g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderTextureTiled,(SDL_Renderer *a, SDL_Texture *b, const SDL_FRect *c, float d, const SDL_FRect *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderViewportSet,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(SDL_AssertState,SDL_ReportAssertion,(SDL_AssertData *a, const char *b, const char *c, int d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_RequestAndroidPermission,(const char *a, SDL_RequestAndroidPermissionCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RequestAndroidPermission,(const char *a, SDL_RequestAndroidPermissionCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_ResetAssertionReport,(void),(),)
SDL_DYNAPI_PROC(int,SDL_ResetHint,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ResetHint,(const char *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_ResetHints,(void),(),)
SDL_DYNAPI_PROC(void,SDL_ResetKeyboard,(void),(),)
SDL_DYNAPI_PROC(void,SDL_ResetLogPriorities,(void),(),)
SDL_DYNAPI_PROC(int,SDL_RestoreWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_ResumeAudioDevice,(SDL_AudioDeviceID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_ResumeAudioStreamDevice,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_ResumeHaptic,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_RumbleGamepad,(SDL_Gamepad *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_RumbleGamepadTriggers,(SDL_Gamepad *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_RumbleJoystick,(SDL_Joystick *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_RumbleJoystickTriggers,(SDL_Joystick *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RestoreWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ResumeAudioDevice,(SDL_AudioDeviceID a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ResumeAudioStreamDevice,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ResumeHaptic,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RumbleGamepad,(SDL_Gamepad *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RumbleGamepadTriggers,(SDL_Gamepad *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RumbleJoystick,(SDL_Joystick *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RumbleJoystickTriggers,(SDL_Joystick *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_RunApp,(int a, char *b[], SDL_main_func c, void *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_RunHapticEffect,(SDL_Haptic *a, int b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SaveBMP,(SDL_Surface *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SaveBMP_IO,(SDL_Surface *a, SDL_IOStream *b, SDL_bool c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RunHapticEffect,(SDL_Haptic *a, int b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SaveBMP,(SDL_Surface *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SaveBMP_IO,(SDL_Surface *a, SDL_IOStream *b, SDL_bool c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_ScaleSurface,(SDL_Surface *a, int b, int c, SDL_ScaleMode d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ScreenKeyboardShown,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ScreenSaverEnabled,(void),(),return)
SDL_DYNAPI_PROC(Sint64,SDL_SeekIO,(SDL_IOStream *a, Sint64 b, SDL_IOWhence c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_SendAndroidBackButton,(void),(),)
SDL_DYNAPI_PROC(int,SDL_SendAndroidMessage,(Uint32 a, int b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SendGamepadEffect,(SDL_Gamepad *a, const void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SendJoystickEffect,(SDL_Joystick *a, const void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SendJoystickVirtualSensorData,(SDL_Joystick *a, SDL_SensorType b, Uint64 c, const float *d, int e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_SetAppMetadata,(const char *a, const char *b, const char *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetAppMetadataProperty,(const char *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SendAndroidMessage,(Uint32 a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SendGamepadEffect,(SDL_Gamepad *a, const void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SendJoystickEffect,(SDL_Joystick *a, const void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SendJoystickVirtualSensorData,(SDL_Joystick *a, SDL_SensorType b, Uint64 c, const float *d, int e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAppMetadata,(const char *a, const char *b, const char *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAppMetadataProperty,(const char *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_SetAssertionHandler,(SDL_AssertionHandler a, void *b),(a,b),)
SDL_DYNAPI_PROC(int,SDL_SetAudioDeviceGain,(SDL_AudioDeviceID a, float b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetAudioPostmixCallback,(SDL_AudioDeviceID a, SDL_AudioPostmixCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetAudioStreamFormat,(SDL_AudioStream *a, const SDL_AudioSpec *b, const SDL_AudioSpec *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetAudioStreamFrequencyRatio,(SDL_AudioStream *a, float b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetAudioStreamGain,(SDL_AudioStream *a, float b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetAudioStreamGetCallback,(SDL_AudioStream *a, SDL_AudioStreamCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetAudioStreamInputChannelMap,(SDL_AudioStream *a, const int *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetAudioStreamOutputChannelMap,(SDL_AudioStream *a, const int *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetAudioStreamPutCallback,(SDL_AudioStream *a, SDL_AudioStreamCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetBooleanProperty,(SDL_PropertiesID a, const char *b, SDL_bool c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetClipboardData,(SDL_ClipboardDataCallback a, SDL_ClipboardCleanupCallback b, void *c, const char **d, size_t e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_SetClipboardText,(const char *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SetCursor,(SDL_Cursor *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAudioDeviceGain,(SDL_AudioDeviceID a, float b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAudioPostmixCallback,(SDL_AudioDeviceID a, SDL_AudioPostmixCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAudioStreamFormat,(SDL_AudioStream *a, const SDL_AudioSpec *b, const SDL_AudioSpec *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAudioStreamFrequencyRatio,(SDL_AudioStream *a, float b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAudioStreamGain,(SDL_AudioStream *a, float b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAudioStreamGetCallback,(SDL_AudioStream *a, SDL_AudioStreamCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAudioStreamInputChannelMap,(SDL_AudioStream *a, const int *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAudioStreamOutputChannelMap,(SDL_AudioStream *a, const int *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAudioStreamPutCallback,(SDL_AudioStream *a, SDL_AudioStreamCallback b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetBooleanProperty,(SDL_PropertiesID a, const char *b, SDL_bool c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetClipboardData,(SDL_ClipboardDataCallback a, SDL_ClipboardCleanupCallback b, void *c, const char **d, size_t e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetClipboardText,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetCursor,(SDL_Cursor *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_SetEventEnabled,(Uint32 a, SDL_bool b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_SetEventFilter,(SDL_EventFilter a, void *b),(a,b),)
SDL_DYNAPI_PROC(int,SDL_SetFloatProperty,(SDL_PropertiesID a, const char *b, float c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetFloatProperty,(SDL_PropertiesID a, const char *b, float c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_SetGamepadEventsEnabled,(SDL_bool a),(a),)
SDL_DYNAPI_PROC(int,SDL_SetGamepadLED,(SDL_Gamepad *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_SetGamepadMapping,(SDL_JoystickID a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetGamepadPlayerIndex,(SDL_Gamepad *a, int b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetGamepadSensorEnabled,(SDL_Gamepad *a, SDL_SensorType b, SDL_bool c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetHapticAutocenter,(SDL_Haptic *a, int b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetHapticGain,(SDL_Haptic *a, int b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetHint,(const char *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetHintWithPriority,(const char *a, const char *b, SDL_HintPriority c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetGamepadLED,(SDL_Gamepad *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetGamepadMapping,(SDL_JoystickID a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetGamepadPlayerIndex,(SDL_Gamepad *a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetGamepadSensorEnabled,(SDL_Gamepad *a, SDL_SensorType b, SDL_bool c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetHapticAutocenter,(SDL_Haptic *a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetHapticGain,(SDL_Haptic *a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetHint,(const char *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetHintWithPriority,(const char *a, const char *b, SDL_HintPriority c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_SetJoystickEventsEnabled,(SDL_bool a),(a),)
SDL_DYNAPI_PROC(int,SDL_SetJoystickLED,(SDL_Joystick *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_SetJoystickPlayerIndex,(SDL_Joystick *a, int b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetJoystickVirtualAxis,(SDL_Joystick *a, int b, Sint16 c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetJoystickVirtualBall,(SDL_Joystick *a, int b, Sint16 c, Sint16 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_SetJoystickVirtualButton,(SDL_Joystick *a, int b, Uint8 c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetJoystickVirtualHat,(SDL_Joystick *a, int b, Uint8 c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetJoystickVirtualTouchpad,(SDL_Joystick *a, int b, int c, Uint8 d, float e, float f, float g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(int,SDL_SetLinuxThreadPriority,(Sint64 a, int b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetLinuxThreadPriorityAndPolicy,(Sint64 a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetJoystickLED,(SDL_Joystick *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetJoystickPlayerIndex,(SDL_Joystick *a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetJoystickVirtualAxis,(SDL_Joystick *a, int b, Sint16 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetJoystickVirtualBall,(SDL_Joystick *a, int b, Sint16 c, Sint16 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetJoystickVirtualButton,(SDL_Joystick *a, int b, Uint8 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetJoystickVirtualHat,(SDL_Joystick *a, int b, Uint8 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetJoystickVirtualTouchpad,(SDL_Joystick *a, int b, int c, Uint8 d, float e, float f, float g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetLinuxThreadPriority,(Sint64 a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetLinuxThreadPriorityAndPolicy,(Sint64 a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_SetLogOutputFunction,(SDL_LogOutputFunction a, void *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_SetLogPriorities,(SDL_LogPriority a),(a),)
SDL_DYNAPI_PROC(void,SDL_SetLogPriority,(int a, SDL_LogPriority b),(a,b),)
SDL_DYNAPI_PROC(int,SDL_SetLogPriorityPrefix,(SDL_LogPriority a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetLogPriorityPrefix,(SDL_LogPriority a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_SetMainReady,(void),(),)
SDL_DYNAPI_PROC(int,SDL_SetMemoryFunctions,(SDL_malloc_func a, SDL_calloc_func b, SDL_realloc_func c, SDL_free_func d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetMemoryFunctions,(SDL_malloc_func a, SDL_calloc_func b, SDL_realloc_func c, SDL_free_func d),(a,b,c,d),return)
SDL_DYNAPI_PROC(void,SDL_SetModState,(SDL_Keymod a),(a),)
SDL_DYNAPI_PROC(int,SDL_SetNumberProperty,(SDL_PropertiesID a, const char *b, Sint64 c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetPaletteColors,(SDL_Palette *a, const SDL_Color *b, int c, int d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_SetPointerProperty,(SDL_PropertiesID a, const char *b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetPointerPropertyWithCleanup,(SDL_PropertiesID a, const char *b, void *c, SDL_CleanupPropertyCallback d, void *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_SetPrimarySelectionText,(const char *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderClipRect,(SDL_Renderer *a, const SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderColorScale,(SDL_Renderer *a, float b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderDrawBlendMode,(SDL_Renderer *a, SDL_BlendMode b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderDrawColor,(SDL_Renderer *a, Uint8 b, Uint8 c, Uint8 d, Uint8 e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderDrawColorFloat,(SDL_Renderer *a, float b, float c, float d, float e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderLogicalPresentation,(SDL_Renderer *a, int b, int c, SDL_RendererLogicalPresentation d, SDL_ScaleMode e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderScale,(SDL_Renderer *a, float b, float c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderTarget,(SDL_Renderer *a, SDL_Texture *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderVSync,(SDL_Renderer *a, int b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderViewport,(SDL_Renderer *a, const SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetScancodeName,(SDL_Scancode a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetStringProperty,(SDL_PropertiesID a, const char *b, const char *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetSurfaceAlphaMod,(SDL_Surface *a, Uint8 b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetSurfaceBlendMode,(SDL_Surface *a, SDL_BlendMode b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetNumberProperty,(SDL_PropertiesID a, const char *b, Sint64 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetPaletteColors,(SDL_Palette *a, const SDL_Color *b, int c, int d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetPointerProperty,(SDL_PropertiesID a, const char *b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetPointerPropertyWithCleanup,(SDL_PropertiesID a, const char *b, void *c, SDL_CleanupPropertyCallback d, void *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetPrimarySelectionText,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetRenderClipRect,(SDL_Renderer *a, const SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetRenderColorScale,(SDL_Renderer *a, float b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetRenderDrawBlendMode,(SDL_Renderer *a, SDL_BlendMode b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetRenderDrawColor,(SDL_Renderer *a, Uint8 b, Uint8 c, Uint8 d, Uint8 e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetRenderDrawColorFloat,(SDL_Renderer *a, float b, float c, float d, float e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetRenderLogicalPresentation,(SDL_Renderer *a, int b, int c, SDL_RendererLogicalPresentation d, SDL_ScaleMode e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetRenderScale,(SDL_Renderer *a, float b, float c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetRenderTarget,(SDL_Renderer *a, SDL_Texture *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetRenderVSync,(SDL_Renderer *a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetRenderViewport,(SDL_Renderer *a, const SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetScancodeName,(SDL_Scancode a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetStringProperty,(SDL_PropertiesID a, const char *b, const char *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetSurfaceAlphaMod,(SDL_Surface *a, Uint8 b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetSurfaceBlendMode,(SDL_Surface *a, SDL_BlendMode b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetSurfaceClipRect,(SDL_Surface *a, const SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetSurfaceColorKey,(SDL_Surface *a, SDL_bool b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetSurfaceColorMod,(SDL_Surface *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_SetSurfaceColorspace,(SDL_Surface *a, SDL_Colorspace b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetSurfacePalette,(SDL_Surface *a, SDL_Palette *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetSurfaceRLE,(SDL_Surface *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetTLS,(SDL_TLSID *a, const void *b, SDL_TLSDestructorCallback c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetTextInputArea,(SDL_Window *a, const SDL_Rect *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetTextureAlphaMod,(SDL_Texture *a, Uint8 b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetTextureAlphaModFloat,(SDL_Texture *a, float b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetTextureBlendMode,(SDL_Texture *a, SDL_BlendMode b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetTextureColorMod,(SDL_Texture *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_SetTextureColorModFloat,(SDL_Texture *a, float b, float c, float d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_SetTextureScaleMode,(SDL_Texture *a, SDL_ScaleMode b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetThreadPriority,(SDL_ThreadPriority a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowAlwaysOnTop,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowAspectRatio,(SDL_Window *a, float b, float c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowBordered,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowFocusable,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowFullscreen,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowFullscreenMode,(SDL_Window *a, const SDL_DisplayMode *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowHitTest,(SDL_Window *a, SDL_HitTest b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowIcon,(SDL_Window *a, SDL_Surface *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowKeyboardGrab,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowMaximumSize,(SDL_Window *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowMinimumSize,(SDL_Window *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowModalFor,(SDL_Window *a, SDL_Window *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowMouseGrab,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowMouseRect,(SDL_Window *a, const SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowOpacity,(SDL_Window *a, float b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowPosition,(SDL_Window *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowRelativeMouseMode,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowResizable,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowShape,(SDL_Window *a, SDL_Surface *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowSize,(SDL_Window *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowSurfaceVSync,(SDL_Window *a, int b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowTitle,(SDL_Window *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetSurfaceColorKey,(SDL_Surface *a, SDL_bool b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetSurfaceColorMod,(SDL_Surface *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetSurfaceColorspace,(SDL_Surface *a, SDL_Colorspace b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetSurfacePalette,(SDL_Surface *a, SDL_Palette *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetSurfaceRLE,(SDL_Surface *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetTLS,(SDL_TLSID *a, const void *b, SDL_TLSDestructorCallback c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetTextInputArea,(SDL_Window *a, const SDL_Rect *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetTextureAlphaMod,(SDL_Texture *a, Uint8 b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetTextureAlphaModFloat,(SDL_Texture *a, float b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetTextureBlendMode,(SDL_Texture *a, SDL_BlendMode b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetTextureColorMod,(SDL_Texture *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetTextureColorModFloat,(SDL_Texture *a, float b, float c, float d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetTextureScaleMode,(SDL_Texture *a, SDL_ScaleMode b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetThreadPriority,(SDL_ThreadPriority a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowAlwaysOnTop,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowAspectRatio,(SDL_Window *a, float b, float c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowBordered,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowFocusable,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowFullscreen,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowFullscreenMode,(SDL_Window *a, const SDL_DisplayMode *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowHitTest,(SDL_Window *a, SDL_HitTest b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowIcon,(SDL_Window *a, SDL_Surface *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowKeyboardGrab,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowMaximumSize,(SDL_Window *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowMinimumSize,(SDL_Window *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowModalFor,(SDL_Window *a, SDL_Window *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowMouseGrab,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowMouseRect,(SDL_Window *a, const SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowOpacity,(SDL_Window *a, float b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowPosition,(SDL_Window *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowRelativeMouseMode,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowResizable,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowShape,(SDL_Window *a, SDL_Surface *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowSize,(SDL_Window *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowSurfaceVSync,(SDL_Window *a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetWindowTitle,(SDL_Window *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_SetWindowsMessageHook,(SDL_WindowsMessageHook a, void *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_SetX11EventHook,(SDL_X11EventHook a, void *b),(a,b),)
SDL_DYNAPI_PROC(int,SDL_SetiOSAnimationCallback,(SDL_Window *a, int b, SDL_iOSAnimationCallback c, void *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetiOSAnimationCallback,(SDL_Window *a, int b, SDL_iOSAnimationCallback c, void *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(void,SDL_SetiOSEventPump,(SDL_bool a),(a),)
SDL_DYNAPI_PROC(int,SDL_ShowAndroidToast,(const char *a, int b, int c, int d, int e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_ShowCursor,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_ShowMessageBox,(const SDL_MessageBoxData *a, int *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ShowAndroidToast,(const char *a, int b, int c, int d, int e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ShowCursor,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ShowMessageBox,(const SDL_MessageBoxData *a, int *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_ShowOpenFileDialog,(SDL_DialogFileCallback a, void *b, SDL_Window *c, const SDL_DialogFileFilter *d, int e, const char *f, SDL_bool g),(a,b,c,d,e,f,g),)
SDL_DYNAPI_PROC(void,SDL_ShowOpenFolderDialog,(SDL_DialogFileCallback a, void *b, SDL_Window *c, const char *d, SDL_bool e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(void,SDL_ShowSaveFileDialog,(SDL_DialogFileCallback a, void *b, SDL_Window *c, const SDL_DialogFileFilter *d, int e, const char *f),(a,b,c,d,e,f),)
SDL_DYNAPI_PROC(int,SDL_ShowSimpleMessageBox,(SDL_MessageBoxFlags a, const char *b, const char *c, SDL_Window *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_ShowWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_ShowWindowSystemMenu,(SDL_Window *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SignalCondition,(SDL_Condition *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SignalSemaphore,(SDL_Semaphore *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_StartTextInput,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_StartTextInputWithProperties,(SDL_Window *a, SDL_PropertiesID b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ShowSimpleMessageBox,(SDL_MessageBoxFlags a, const char *b, const char *c, SDL_Window *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ShowWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ShowWindowSystemMenu,(SDL_Window *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_SignalCondition,(SDL_Condition *a),(a),)
SDL_DYNAPI_PROC(void,SDL_SignalSemaphore,(SDL_Semaphore *a),(a),)
SDL_DYNAPI_PROC(SDL_bool,SDL_StartTextInput,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_StartTextInputWithProperties,(SDL_Window *a, SDL_PropertiesID b),(a,b),return)
SDL_DYNAPI_PROC(Uint32,SDL_StepUTF8,(const char **a, size_t *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_StopHapticEffect,(SDL_Haptic *a, int b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_StopHapticEffects,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_StopHapticRumble,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_StopTextInput,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_StopHapticEffect,(SDL_Haptic *a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_StopHapticEffects,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_StopHapticRumble,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_StopTextInput,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_StorageReady,(SDL_Storage *a),(a),return)
SDL_DYNAPI_PROC(SDL_GUID,SDL_StringToGUID,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SurfaceHasAlternateImages,(SDL_Surface *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SurfaceHasColorKey,(SDL_Surface *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SurfaceHasRLE,(SDL_Surface *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SyncWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SyncWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(Sint64,SDL_TellIO,(SDL_IOStream *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_TextInputActive,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_Time,SDL_TimeFromWindows,(Uint32 a, Uint32 b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_TimeToDateTime,(SDL_Time a, SDL_DateTime *b, SDL_bool c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_TimeToDateTime,(SDL_Time a, SDL_DateTime *b, SDL_bool c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_TimeToWindows,(SDL_Time a, Uint32 *b, Uint32 *c),(a,b,c),)
SDL_DYNAPI_PROC(int,SDL_TryLockMutex,(SDL_Mutex *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_TryLockRWLockForReading,(SDL_RWLock *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_TryLockRWLockForWriting,(SDL_RWLock *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_TryLockMutex,(SDL_Mutex *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_TryLockRWLockForReading,(SDL_RWLock *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_TryLockRWLockForWriting,(SDL_RWLock *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_TryLockSpinlock,(SDL_SpinLock *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_TryWaitSemaphore,(SDL_Semaphore *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_TryWaitSemaphore,(SDL_Semaphore *a),(a),return)
SDL_DYNAPI_PROC(char*,SDL_UCS4ToUTF8,(Uint32 a, char *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_UnbindAudioStream,(SDL_AudioStream *a),(a),)
SDL_DYNAPI_PROC(void,SDL_UnbindAudioStreams,(SDL_AudioStream **a, int b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_UnloadObject,(void *a),(a),)
SDL_DYNAPI_PROC(int,SDL_UnlockAudioStream,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_UnlockAudioStream,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_UnlockJoysticks,(void),(),)
SDL_DYNAPI_PROC(void,SDL_UnlockMutex,(SDL_Mutex *a),(a),)
SDL_DYNAPI_PROC(void,SDL_UnlockProperties,(SDL_PropertiesID a),(a),)
@@ -880,29 +880,29 @@ SDL_DYNAPI_PROC(void,SDL_UnlockSurface,(SDL_Surface *a),(a),)
SDL_DYNAPI_PROC(void,SDL_UnlockTexture,(SDL_Texture *a),(a),)
SDL_DYNAPI_PROC(void,SDL_UnregisterApp,(void),(),)
SDL_DYNAPI_PROC(void,SDL_UpdateGamepads,(void),(),)
SDL_DYNAPI_PROC(int,SDL_UpdateHapticEffect,(SDL_Haptic *a, int b, const SDL_HapticEffect *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_UpdateHapticEffect,(SDL_Haptic *a, int b, const SDL_HapticEffect *c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_UpdateJoysticks,(void),(),)
SDL_DYNAPI_PROC(int,SDL_UpdateNVTexture,(SDL_Texture *a, const SDL_Rect *b, const Uint8 *c, int d, const Uint8 *e, int f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_UpdateNVTexture,(SDL_Texture *a, const SDL_Rect *b, const Uint8 *c, int d, const Uint8 *e, int f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(void,SDL_UpdateSensors,(void),(),)
SDL_DYNAPI_PROC(int,SDL_UpdateTexture,(SDL_Texture *a, const SDL_Rect *b, const void *c, int d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_UpdateWindowSurface,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_UpdateWindowSurfaceRects,(SDL_Window *a, const SDL_Rect *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_UpdateYUVTexture,(SDL_Texture *a, const SDL_Rect *b, const Uint8 *c, int d, const Uint8 *e, int f, const Uint8 *g, int h),(a,b,c,d,e,f,g,h),return)
SDL_DYNAPI_PROC(int,SDL_Vulkan_CreateSurface,(SDL_Window *a, VkInstance b, const struct VkAllocationCallbacks *c, VkSurfaceKHR *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_UpdateTexture,(SDL_Texture *a, const SDL_Rect *b, const void *c, int d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_UpdateWindowSurface,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_UpdateWindowSurfaceRects,(SDL_Window *a, const SDL_Rect *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_UpdateYUVTexture,(SDL_Texture *a, const SDL_Rect *b, const Uint8 *c, int d, const Uint8 *e, int f, const Uint8 *g, int h),(a,b,c,d,e,f,g,h),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_Vulkan_CreateSurface,(SDL_Window *a, VkInstance b, const struct VkAllocationCallbacks *c, VkSurfaceKHR *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(void,SDL_Vulkan_DestroySurface,(VkInstance a, VkSurfaceKHR b, const struct VkAllocationCallbacks *c),(a,b,c),)
SDL_DYNAPI_PROC(char const* const*,SDL_Vulkan_GetInstanceExtensions,(Uint32 *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_Vulkan_GetPresentationSupport,(VkInstance a, VkPhysicalDevice b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_FunctionPointer,SDL_Vulkan_GetVkGetInstanceProcAddr,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_Vulkan_LoadLibrary,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_Vulkan_LoadLibrary,(const char *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_Vulkan_UnloadLibrary,(void),(),)
SDL_DYNAPI_PROC(int,SDL_WaitCondition,(SDL_Condition *a, SDL_Mutex *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_WaitConditionTimeout,(SDL_Condition *a, SDL_Mutex *b, Sint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_WaitCondition,(SDL_Condition *a, SDL_Mutex *b),(a,b),)
SDL_DYNAPI_PROC(SDL_bool,SDL_WaitConditionTimeout,(SDL_Condition *a, SDL_Mutex *b, Sint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_WaitEvent,(SDL_Event *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_WaitEventTimeout,(SDL_Event *a, Sint32 b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_WaitSemaphore,(SDL_Semaphore *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_WaitSemaphoreTimeout,(SDL_Semaphore *a, Sint32 b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_WaitSemaphore,(SDL_Semaphore *a),(a),)
SDL_DYNAPI_PROC(SDL_bool,SDL_WaitSemaphoreTimeout,(SDL_Semaphore *a, Sint32 b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_WaitThread,(SDL_Thread *a, int *b),(a,b),)
SDL_DYNAPI_PROC(int,SDL_WarpMouseGlobal,(float a, float b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_WarpMouseGlobal,(float a, float b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_WarpMouseInWindow,(SDL_Window *a, float b, float c),(a,b,c),)
SDL_DYNAPI_PROC(SDL_InitFlags,SDL_WasInit,(SDL_InitFlags a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_WindowHasSurface,(SDL_Window *a),(a),return)
@@ -914,9 +914,9 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_WriteS32LE,(SDL_IOStream *a, Sint32 b),(a,b),return
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteS64BE,(SDL_IOStream *a, Sint64 b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteS64LE,(SDL_IOStream *a, Sint64 b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteS8,(SDL_IOStream *a, Sint8 b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_WriteStorageFile,(SDL_Storage *a, const char *b, const void *c, Uint64 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_WriteSurfacePixel,(SDL_Surface *a, int b, int c, Uint8 d, Uint8 e, Uint8 f, Uint8 g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(int,SDL_WriteSurfacePixelFloat,(SDL_Surface *a, int b, int c, float d, float e, float f, float g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteStorageFile,(SDL_Storage *a, const char *b, const void *c, Uint64 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteSurfacePixel,(SDL_Surface *a, int b, int c, Uint8 d, Uint8 e, Uint8 f, Uint8 g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteSurfacePixelFloat,(SDL_Surface *a, int b, int c, float d, float e, float f, float g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteU16BE,(SDL_IOStream *a, Uint16 b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteU16LE,(SDL_IOStream *a, Uint16 b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteU32BE,(SDL_IOStream *a, Uint32 b),(a,b),return)

View File

@@ -38,7 +38,8 @@ SDL_EventCategory SDL_GetEventCategory(Uint32 type)
}
switch (type) {
default:
return SDL_SetError("Unknown event type");
SDL_SetError("Unknown event type");
return SDL_EVENTCATEGORY_UNKNOWN;
case SDL_EVENT_KEYMAP_CHANGED:
case SDL_EVENT_TERMINATING:

View File

@@ -25,6 +25,7 @@
typedef enum SDL_EventCategory
{
SDL_EVENTCATEGORY_UNKNOWN,
SDL_EVENTCATEGORY_SYSTEM,
SDL_EVENTCATEGORY_DISPLAY,
SDL_EVENTCATEGORY_WINDOW,

View File

@@ -25,17 +25,12 @@
#include "SDL_events_c.h"
#include "SDL_clipboardevents_c.h"
int SDL_SendClipboardUpdate(void)
void SDL_SendClipboardUpdate(void)
{
int posted;
// Post the event, if desired
posted = 0;
if (SDL_EventEnabled(SDL_EVENT_CLIPBOARD_UPDATE)) {
SDL_Event event;
event.type = SDL_EVENT_CLIPBOARD_UPDATE;
event.clipboard.timestamp = 0;
posted = (SDL_PushEvent(&event) > 0);
SDL_PushEvent(&event);
}
return posted;
}

View File

@@ -23,6 +23,6 @@
#ifndef SDL_clipboardevents_c_h_
#define SDL_clipboardevents_c_h_
extern int SDL_SendClipboardUpdate(void);
extern void SDL_SendClipboardUpdate(void);
#endif // SDL_clipboardevents_c_h_

View File

@@ -24,17 +24,15 @@
#include "SDL_events_c.h"
int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent, int data1, int data2)
void SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent, int data1, int data2)
{
int posted;
if (!display || display->id == 0) {
return 0;
return;
}
switch (displayevent) {
case SDL_EVENT_DISPLAY_ORIENTATION:
if (data1 == SDL_ORIENTATION_UNKNOWN || data1 == display->current_orientation) {
return 0;
return;
}
display->current_orientation = (SDL_DisplayOrientation)data1;
break;
@@ -43,7 +41,6 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent,
}
// Post the event, if desired
posted = 0;
if (SDL_EventEnabled(displayevent)) {
SDL_Event event;
event.type = displayevent;
@@ -51,7 +48,7 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent,
event.display.displayID = display->id;
event.display.data1 = data1;
event.display.data2 = data2;
posted = (SDL_PushEvent(&event) > 0);
SDL_PushEvent(&event);
}
switch (displayevent) {
@@ -64,6 +61,4 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent,
default:
break;
}
return posted;
}

View File

@@ -23,6 +23,6 @@
#ifndef SDL_displayevents_c_h_
#define SDL_displayevents_c_h_
extern int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent, int data1, int data2);
extern void SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent, int data1, int data2);
#endif // SDL_displayevents_c_h_

View File

@@ -27,12 +27,12 @@
#include "../video/SDL_sysvideo.h" // for SDL_Window internals.
static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *source, const char *data, float x, float y)
static bool SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *source, const char *data, float x, float y)
{
static bool app_is_dropping = false;
static float last_drop_x = 0;
static float last_drop_y = 0;
int posted = 0;
bool posted = false;
// Post the event, if desired
if (SDL_EventEnabled(evtype)) {
@@ -44,9 +44,9 @@ static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const ch
event.type = SDL_EVENT_DROP_BEGIN;
event.common.timestamp = 0;
event.drop.windowID = window ? window->id : 0;
posted = (SDL_PushEvent(&event) > 0);
posted = SDL_PushEvent(&event);
if (!posted) {
return 0;
return false;
}
if (window) {
window->is_dropping = true;
@@ -61,13 +61,13 @@ static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const ch
if (source) {
event.drop.source = SDL_CreateTemporaryString(source);
if (!event.drop.source) {
return 0;
return false;
}
}
if (data) {
event.drop.data = SDL_CreateTemporaryString(data);
if (!event.drop.data) {
return 0;
return false;
}
}
event.drop.windowID = window ? window->id : 0;
@@ -78,7 +78,7 @@ static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const ch
}
event.drop.x = last_drop_x;
event.drop.y = last_drop_y;
posted = (SDL_PushEvent(&event) > 0);
posted = SDL_PushEvent(&event);
if (posted && (evtype == SDL_EVENT_DROP_COMPLETE)) {
if (window) {
@@ -94,22 +94,22 @@ static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const ch
return posted;
}
int SDL_SendDropFile(SDL_Window *window, const char *source, const char *file)
bool SDL_SendDropFile(SDL_Window *window, const char *source, const char *file)
{
return SDL_SendDrop(window, SDL_EVENT_DROP_FILE, source, file, 0, 0);
}
int SDL_SendDropPosition(SDL_Window *window, float x, float y)
bool SDL_SendDropPosition(SDL_Window *window, float x, float y)
{
return SDL_SendDrop(window, SDL_EVENT_DROP_POSITION, NULL, NULL, x, y);
}
int SDL_SendDropText(SDL_Window *window, const char *text)
bool SDL_SendDropText(SDL_Window *window, const char *text)
{
return SDL_SendDrop(window, SDL_EVENT_DROP_TEXT, NULL, text, 0, 0);
}
int SDL_SendDropComplete(SDL_Window *window)
bool SDL_SendDropComplete(SDL_Window *window)
{
return SDL_SendDrop(window, SDL_EVENT_DROP_COMPLETE, NULL, NULL, 0, 0);
}

View File

@@ -23,9 +23,9 @@
#ifndef SDL_dropevents_c_h_
#define SDL_dropevents_c_h_
extern int SDL_SendDropFile(SDL_Window *window, const char *source, const char *file);
extern int SDL_SendDropPosition(SDL_Window *window, float x, float y);
extern int SDL_SendDropText(SDL_Window *window, const char *text);
extern int SDL_SendDropComplete(SDL_Window *window);
extern bool SDL_SendDropFile(SDL_Window *window, const char *source, const char *file);
extern bool SDL_SendDropPosition(SDL_Window *window, float x, float y);
extern bool SDL_SendDropText(SDL_Window *window, const char *text);
extern bool SDL_SendDropComplete(SDL_Window *window);
#endif // SDL_dropevents_c_h_

View File

@@ -134,7 +134,7 @@ static SDL_TemporaryMemoryState *SDL_GetTemporaryMemoryState(bool create)
return NULL;
}
if (SDL_SetTLS(&SDL_temporary_memory, state, SDL_CleanupTemporaryMemory) < 0) {
if (!SDL_SetTLS(&SDL_temporary_memory, state, SDL_CleanupTemporaryMemory)) {
SDL_free(state);
return NULL;
}
@@ -885,7 +885,7 @@ void SDL_StopEventLoop(void)
}
// This function (and associated calls) may be called more than once
int SDL_StartEventLoop(void)
bool SDL_StartEventLoop(void)
{
/* We'll leave the event queue alone, since we might have gotten
some important events at launch (like SDL_EVENT_DROP_FILE)
@@ -898,7 +898,7 @@ int SDL_StartEventLoop(void)
if (!SDL_EventQ.lock) {
SDL_EventQ.lock = SDL_CreateMutex();
if (SDL_EventQ.lock == NULL) {
return -1;
return false;
}
}
SDL_LockMutex(SDL_EventQ.lock);
@@ -907,14 +907,14 @@ int SDL_StartEventLoop(void)
SDL_event_watchers_lock = SDL_CreateMutex();
if (SDL_event_watchers_lock == NULL) {
SDL_UnlockMutex(SDL_EventQ.lock);
return -1;
return false;
}
}
#endif // !SDL_THREADS_DISABLED
SDL_EventQ.active = true;
SDL_UnlockMutex(SDL_EventQ.lock);
return 0;
return true;
}
// Add an event to the event queue -- called with the queue locked
@@ -1004,14 +1004,14 @@ static void SDL_CutEvent(SDL_EventEntry *entry)
SDL_AtomicAdd(&SDL_EventQ.count, -1);
}
static int SDL_SendWakeupEvent(void)
static void SDL_SendWakeupEvent(void)
{
#ifdef SDL_PLATFORM_ANDROID
Android_SendLifecycleEvent(SDL_ANDROID_LIFECYCLE_WAKE);
#else
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (_this == NULL || !_this->SendWakeupEvent) {
return 0;
return;
}
SDL_LockMutex(_this->wakeup_lock);
@@ -1025,8 +1025,6 @@ static int SDL_SendWakeupEvent(void)
}
SDL_UnlockMutex(_this->wakeup_lock);
#endif
return 0;
}
// Lock the event queue, take a peep at it, and unlock it
@@ -1502,21 +1500,22 @@ static bool SDL_CallEventWatchers(SDL_Event *event)
return true;
}
int SDL_PushEvent(SDL_Event *event)
SDL_bool SDL_PushEvent(SDL_Event *event)
{
if (!event->common.timestamp) {
event->common.timestamp = SDL_GetTicksNS();
}
if (!SDL_CallEventWatchers(event)) {
return 0;
SDL_ClearError();
return false;
}
if (SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0, 0) <= 0) {
return -1;
return false;
}
return 1;
return true;
}
void SDL_SetEventFilter(SDL_EventFilter filter, void *userdata)
@@ -1563,9 +1562,9 @@ SDL_bool SDL_GetEventFilter(SDL_EventFilter *filter, void **userdata)
return event_ok.callback ? true : false;
}
int SDL_AddEventWatch(SDL_EventFilter filter, void *userdata)
SDL_bool SDL_AddEventWatch(SDL_EventFilter filter, void *userdata)
{
int result = 0;
bool result = true;
SDL_LockMutex(SDL_event_watchers_lock);
{
@@ -1582,7 +1581,7 @@ int SDL_AddEventWatch(SDL_EventFilter filter, void *userdata)
watcher->removed = false;
++SDL_event_watchers_count;
} else {
result = -1;
result = false;
}
}
SDL_UnlockMutex(SDL_event_watchers_lock);
@@ -1715,11 +1714,8 @@ Uint32 SDL_RegisterEvents(int numevents)
return event_base;
}
int SDL_SendAppEvent(SDL_EventType eventType)
void SDL_SendAppEvent(SDL_EventType eventType)
{
int posted;
posted = 0;
if (SDL_EventEnabled(eventType)) {
SDL_Event event;
event.type = eventType;
@@ -1736,32 +1732,31 @@ int SDL_SendAppEvent(SDL_EventType eventType)
if (SDL_EventLoggingVerbosity > 0) {
SDL_LogEvent(&event);
}
posted = SDL_CallEventWatchers(&event);
SDL_CallEventWatchers(&event);
break;
default:
posted = (SDL_PushEvent(&event) > 0);
SDL_PushEvent(&event);
break;
}
}
return posted;
}
int SDL_SendKeymapChangedEvent(void)
void SDL_SendKeymapChangedEvent(void)
{
return SDL_SendAppEvent(SDL_EVENT_KEYMAP_CHANGED);
SDL_SendAppEvent(SDL_EVENT_KEYMAP_CHANGED);
}
int SDL_SendLocaleChangedEvent(void)
void SDL_SendLocaleChangedEvent(void)
{
return SDL_SendAppEvent(SDL_EVENT_LOCALE_CHANGED);
SDL_SendAppEvent(SDL_EVENT_LOCALE_CHANGED);
}
int SDL_SendSystemThemeChangedEvent(void)
void SDL_SendSystemThemeChangedEvent(void)
{
return SDL_SendAppEvent(SDL_EVENT_SYSTEM_THEME_CHANGED);
SDL_SendAppEvent(SDL_EVENT_SYSTEM_THEME_CHANGED);
}
int SDL_InitEvents(void)
bool SDL_InitEvents(void)
{
#ifdef SDL_PLATFORM_ANDROID
Android_InitEvents();
@@ -1774,14 +1769,14 @@ int SDL_InitEvents(void)
#endif
SDL_AddHintCallback(SDL_HINT_EVENT_LOGGING, SDL_EventLoggingChanged, NULL);
SDL_AddHintCallback(SDL_HINT_POLL_SENTINEL, SDL_PollSentinelChanged, NULL);
if (SDL_StartEventLoop() < 0) {
if (!SDL_StartEventLoop()) {
SDL_DelHintCallback(SDL_HINT_EVENT_LOGGING, SDL_EventLoggingChanged, NULL);
return -1;
return false;
}
SDL_InitQuit();
return 0;
return true;
}
void SDL_QuitEvents(void)

View File

@@ -37,28 +37,28 @@
#include "SDL_windowevents_c.h"
// Start and stop the event processing loop
extern int SDL_StartEventLoop(void);
extern bool SDL_StartEventLoop(void);
extern void SDL_StopEventLoop(void);
extern void SDL_QuitInterrupt(void);
extern int SDL_SendAppEvent(SDL_EventType eventType);
extern int SDL_SendKeymapChangedEvent(void);
extern int SDL_SendLocaleChangedEvent(void);
extern int SDL_SendSystemThemeChangedEvent(void);
extern void SDL_SendAppEvent(SDL_EventType eventType);
extern void SDL_SendKeymapChangedEvent(void);
extern void SDL_SendLocaleChangedEvent(void);
extern void SDL_SendSystemThemeChangedEvent(void);
extern void *SDL_AllocateTemporaryMemory(size_t size);
extern const char *SDL_CreateTemporaryString(const char *string);
extern void *SDL_ClaimTemporaryMemory(const void *mem);
extern void SDL_FreeTemporaryMemory(void);
extern int SDL_SendQuit(void);
extern void SDL_SendQuit(void);
extern int SDL_InitEvents(void);
extern bool SDL_InitEvents(void);
extern void SDL_QuitEvents(void);
extern void SDL_SendPendingSignalEvents(void);
extern int SDL_InitQuit(void);
extern bool SDL_InitQuit(void);
extern void SDL_QuitQuit(void);
#endif // SDL_events_c_h_

Some files were not shown because too many files have changed in this diff Show More