mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-28 15:39:10 +00:00
Use C99 bool internally in SDL
This commit is contained in:
parent
6501e90018
commit
8f546bb3c9
450 changed files with 6046 additions and 6033 deletions
|
@ -972,6 +972,7 @@ if(SDL_LIBC)
|
||||||
memory.h
|
memory.h
|
||||||
signal.h
|
signal.h
|
||||||
stdarg.h
|
stdarg.h
|
||||||
|
stdbool.h
|
||||||
stddef.h
|
stddef.h
|
||||||
stdint.h
|
stdint.h
|
||||||
stdio.h
|
stdio.h
|
||||||
|
|
|
@ -82,6 +82,7 @@ if(EMSCRIPTEN)
|
||||||
set(LIBC_HAS_SQRTF "1" CACHE INTERNAL "Have symbol sqrtf")
|
set(LIBC_HAS_SQRTF "1" CACHE INTERNAL "Have symbol sqrtf")
|
||||||
set(LIBC_HAS_SSCANF "1" CACHE INTERNAL "Have symbol sscanf")
|
set(LIBC_HAS_SSCANF "1" CACHE INTERNAL "Have symbol sscanf")
|
||||||
set(LIBC_HAS_STDARG_H "1" CACHE INTERNAL "Have include stdarg.h")
|
set(LIBC_HAS_STDARG_H "1" CACHE INTERNAL "Have include stdarg.h")
|
||||||
|
set(LIBC_HAS_STDBOOL_H "1" CACHE INTERNAL "Have include stdbool.h")
|
||||||
set(LIBC_HAS_STDDEF_H "1" CACHE INTERNAL "Have include stddef.h")
|
set(LIBC_HAS_STDDEF_H "1" CACHE INTERNAL "Have include stddef.h")
|
||||||
set(LIBC_HAS_STDINT_H "1" CACHE INTERNAL "Have include stdint.h")
|
set(LIBC_HAS_STDINT_H "1" CACHE INTERNAL "Have include stdint.h")
|
||||||
set(LIBC_HAS_STDIO_H "1" CACHE INTERNAL "Have include stdio.h")
|
set(LIBC_HAS_STDIO_H "1" CACHE INTERNAL "Have include stdio.h")
|
||||||
|
|
|
@ -96,6 +96,7 @@ if(MSVC)
|
||||||
set(LIBC_HAS_SQRTF "1" CACHE INTERNAL "Have symbol sqrtf")
|
set(LIBC_HAS_SQRTF "1" CACHE INTERNAL "Have symbol sqrtf")
|
||||||
set(LIBC_HAS_SSCANF "1" CACHE INTERNAL "Have symbol sscanf")
|
set(LIBC_HAS_SSCANF "1" CACHE INTERNAL "Have symbol sscanf")
|
||||||
set(LIBC_HAS_STDARG_H "1" CACHE INTERNAL "Have include stdarg.h")
|
set(LIBC_HAS_STDARG_H "1" CACHE INTERNAL "Have include stdarg.h")
|
||||||
|
set(LIBC_HAS_STDBOOL_H "1" CACHE INTERNAL "Have include stdbool.h")
|
||||||
set(LIBC_HAS_STDDEF_H "1" CACHE INTERNAL "Have include stddef.h")
|
set(LIBC_HAS_STDDEF_H "1" CACHE INTERNAL "Have include stddef.h")
|
||||||
set(LIBC_HAS_STDINT_H "1" CACHE INTERNAL "Have include stdint.h")
|
set(LIBC_HAS_STDINT_H "1" CACHE INTERNAL "Have include stdint.h")
|
||||||
set(LIBC_HAS_STDIO_H "1" CACHE INTERNAL "Have include stdio.h")
|
set(LIBC_HAS_STDIO_H "1" CACHE INTERNAL "Have include stdio.h")
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
#cmakedefine HAVE_MEMORY_H 1
|
#cmakedefine HAVE_MEMORY_H 1
|
||||||
#cmakedefine HAVE_SIGNAL_H 1
|
#cmakedefine HAVE_SIGNAL_H 1
|
||||||
#cmakedefine HAVE_STDARG_H 1
|
#cmakedefine HAVE_STDARG_H 1
|
||||||
|
#cmakedefine HAVE_STDBOOL_H 1
|
||||||
#cmakedefine HAVE_STDDEF_H 1
|
#cmakedefine HAVE_STDDEF_H 1
|
||||||
#cmakedefine HAVE_STDINT_H 1
|
#cmakedefine HAVE_STDINT_H 1
|
||||||
#cmakedefine HAVE_STDIO_H 1
|
#cmakedefine HAVE_STDIO_H 1
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#define HAVE_MATH_H 1
|
#define HAVE_MATH_H 1
|
||||||
#define HAVE_SIGNAL_H 1
|
#define HAVE_SIGNAL_H 1
|
||||||
#define HAVE_STDARG_H 1
|
#define HAVE_STDARG_H 1
|
||||||
|
#define HAVE_STDBOOL_H 1
|
||||||
#define HAVE_STDDEF_H 1
|
#define HAVE_STDDEF_H 1
|
||||||
#define HAVE_STDINT_H 1
|
#define HAVE_STDINT_H 1
|
||||||
#define HAVE_STDIO_H 1
|
#define HAVE_STDIO_H 1
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#define HAVE_MEMORY_H 1
|
#define HAVE_MEMORY_H 1
|
||||||
#define HAVE_SIGNAL_H 1
|
#define HAVE_SIGNAL_H 1
|
||||||
#define HAVE_STDARG_H 1
|
#define HAVE_STDARG_H 1
|
||||||
|
#define HAVE_STDBOOL_H 1
|
||||||
#define HAVE_STDDEF_H 1
|
#define HAVE_STDDEF_H 1
|
||||||
#define HAVE_STDINT_H 1
|
#define HAVE_STDINT_H 1
|
||||||
#define HAVE_STDIO_H 1
|
#define HAVE_STDIO_H 1
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#define HAVE_MATH_H 1
|
#define HAVE_MATH_H 1
|
||||||
#define HAVE_SIGNAL_H 1
|
#define HAVE_SIGNAL_H 1
|
||||||
#define HAVE_STDARG_H 1
|
#define HAVE_STDARG_H 1
|
||||||
|
#define HAVE_STDBOOL_H 1
|
||||||
#define HAVE_STDDEF_H 1
|
#define HAVE_STDDEF_H 1
|
||||||
#define HAVE_STDINT_H 1
|
#define HAVE_STDINT_H 1
|
||||||
#define HAVE_STDIO_H 1
|
#define HAVE_STDIO_H 1
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#define HAVE_MATH_H 1
|
#define HAVE_MATH_H 1
|
||||||
#define HAVE_SIGNAL_H 1
|
#define HAVE_SIGNAL_H 1
|
||||||
#define HAVE_STDARG_H 1
|
#define HAVE_STDARG_H 1
|
||||||
|
#define HAVE_STDBOOL_H 1
|
||||||
#define HAVE_STDDEF_H 1
|
#define HAVE_STDDEF_H 1
|
||||||
#define HAVE_STDINT_H 1
|
#define HAVE_STDINT_H 1
|
||||||
#define HAVE_STDIO_H 1
|
#define HAVE_STDIO_H 1
|
||||||
|
|
|
@ -124,6 +124,7 @@ typedef unsigned int uintptr_t;
|
||||||
#define HAVE_MATH_H 1
|
#define HAVE_MATH_H 1
|
||||||
#define HAVE_SIGNAL_H 1
|
#define HAVE_SIGNAL_H 1
|
||||||
#define HAVE_STDARG_H 1
|
#define HAVE_STDARG_H 1
|
||||||
|
#define HAVE_STDBOOL_H 1
|
||||||
#define HAVE_STDDEF_H 1
|
#define HAVE_STDDEF_H 1
|
||||||
#define HAVE_STDIO_H 1
|
#define HAVE_STDIO_H 1
|
||||||
#define HAVE_STDLIB_H 1
|
#define HAVE_STDLIB_H 1
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
#define HAVE_MATH_H 1
|
#define HAVE_MATH_H 1
|
||||||
#define HAVE_SIGNAL_H 1
|
#define HAVE_SIGNAL_H 1
|
||||||
#define HAVE_STDARG_H 1
|
#define HAVE_STDARG_H 1
|
||||||
|
#define HAVE_STDBOOL_H 1
|
||||||
#define HAVE_STDDEF_H 1
|
#define HAVE_STDDEF_H 1
|
||||||
#define HAVE_STDINT_H 1
|
#define HAVE_STDINT_H 1
|
||||||
#define HAVE_STDIO_H 1
|
#define HAVE_STDIO_H 1
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
#define HAVE_MATH_H 1
|
#define HAVE_MATH_H 1
|
||||||
#define HAVE_SIGNAL_H 1
|
#define HAVE_SIGNAL_H 1
|
||||||
#define HAVE_STDARG_H 1
|
#define HAVE_STDARG_H 1
|
||||||
|
#define HAVE_STDBOOL_H 1
|
||||||
#define HAVE_STDDEF_H 1
|
#define HAVE_STDDEF_H 1
|
||||||
#define HAVE_STDINT_H 1
|
#define HAVE_STDINT_H 1
|
||||||
#define HAVE_STDIO_H 1
|
#define HAVE_STDIO_H 1
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
#define HAVE_MATH_H 1
|
#define HAVE_MATH_H 1
|
||||||
#define HAVE_SIGNAL_H 1
|
#define HAVE_SIGNAL_H 1
|
||||||
#define HAVE_STDARG_H 1
|
#define HAVE_STDARG_H 1
|
||||||
|
#define HAVE_STDBOOL_H 1
|
||||||
#define HAVE_STDDEF_H 1
|
#define HAVE_STDDEF_H 1
|
||||||
#define HAVE_STDINT_H 1
|
#define HAVE_STDINT_H 1
|
||||||
#define HAVE_STDIO_H 1
|
#define HAVE_STDIO_H 1
|
||||||
|
|
38
src/SDL.c
38
src/SDL.c
|
@ -117,10 +117,10 @@ int SDL_SetAppMetadata(const char *appname, const char *appversion, const char *
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SDL_ValidMetadataProperty(const char *name)
|
static bool SDL_ValidMetadataProperty(const char *name)
|
||||||
{
|
{
|
||||||
if (!name || !*name) {
|
if (!name || !*name) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_strcmp(name, SDL_PROP_APP_METADATA_NAME_STRING) == 0 ||
|
if (SDL_strcmp(name, SDL_PROP_APP_METADATA_NAME_STRING) == 0 ||
|
||||||
|
@ -130,9 +130,9 @@ static SDL_bool SDL_ValidMetadataProperty(const char *name)
|
||||||
SDL_strcmp(name, SDL_PROP_APP_METADATA_COPYRIGHT_STRING) == 0 ||
|
SDL_strcmp(name, SDL_PROP_APP_METADATA_COPYRIGHT_STRING) == 0 ||
|
||||||
SDL_strcmp(name, SDL_PROP_APP_METADATA_URL_STRING) == 0 ||
|
SDL_strcmp(name, SDL_PROP_APP_METADATA_URL_STRING) == 0 ||
|
||||||
SDL_strcmp(name, SDL_PROP_APP_METADATA_TYPE_STRING) == 0) {
|
SDL_strcmp(name, SDL_PROP_APP_METADATA_TYPE_STRING) == 0) {
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_SetAppMetadataProperty(const char *name, const char *value)
|
int SDL_SetAppMetadataProperty(const char *name, const char *value)
|
||||||
|
@ -173,11 +173,11 @@ const char *SDL_GetAppMetadataProperty(const char *name)
|
||||||
|
|
||||||
// The initialized subsystems
|
// The initialized subsystems
|
||||||
#ifdef SDL_MAIN_NEEDED
|
#ifdef SDL_MAIN_NEEDED
|
||||||
static SDL_bool SDL_MainIsReady = SDL_FALSE;
|
static bool SDL_MainIsReady = false;
|
||||||
#else
|
#else
|
||||||
static SDL_bool SDL_MainIsReady = SDL_TRUE;
|
static bool SDL_MainIsReady = true;
|
||||||
#endif
|
#endif
|
||||||
static SDL_bool SDL_bInMainQuit = SDL_FALSE;
|
static bool SDL_bInMainQuit = false;
|
||||||
static Uint8 SDL_SubsystemRefCount[32];
|
static Uint8 SDL_SubsystemRefCount[32];
|
||||||
|
|
||||||
// Private helper to increment a subsystem's ref counter.
|
// Private helper to increment a subsystem's ref counter.
|
||||||
|
@ -204,7 +204,7 @@ static void SDL_DecrementSubsystemRefCount(Uint32 subsystem)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private helper to check if a system needs init.
|
// Private helper to check if a system needs init.
|
||||||
static SDL_bool SDL_ShouldInitSubsystem(Uint32 subsystem)
|
static bool SDL_ShouldInitSubsystem(Uint32 subsystem)
|
||||||
{
|
{
|
||||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||||
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
||||||
|
@ -212,11 +212,11 @@ static SDL_bool SDL_ShouldInitSubsystem(Uint32 subsystem)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private helper to check if a system needs to be quit.
|
// Private helper to check if a system needs to be quit.
|
||||||
static SDL_bool SDL_ShouldQuitSubsystem(Uint32 subsystem)
|
static bool SDL_ShouldQuitSubsystem(Uint32 subsystem)
|
||||||
{
|
{
|
||||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||||
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) {
|
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we're in SDL_Quit, we shut down every subsystem, even if refcount
|
/* If we're in SDL_Quit, we shut down every subsystem, even if refcount
|
||||||
|
@ -227,23 +227,23 @@ static SDL_bool SDL_ShouldQuitSubsystem(Uint32 subsystem)
|
||||||
|
|
||||||
/* Private helper to either increment's existing ref counter,
|
/* Private helper to either increment's existing ref counter,
|
||||||
* or fully init a new subsystem. */
|
* or fully init a new subsystem. */
|
||||||
static SDL_bool SDL_InitOrIncrementSubsystem(Uint32 subsystem)
|
static bool SDL_InitOrIncrementSubsystem(Uint32 subsystem)
|
||||||
{
|
{
|
||||||
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||||
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
||||||
if (subsystem_index < 0) {
|
if (subsystem_index < 0) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
if (SDL_SubsystemRefCount[subsystem_index] > 0) {
|
if (SDL_SubsystemRefCount[subsystem_index] > 0) {
|
||||||
++SDL_SubsystemRefCount[subsystem_index];
|
++SDL_SubsystemRefCount[subsystem_index];
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return SDL_InitSubSystem(subsystem) == 0;
|
return SDL_InitSubSystem(subsystem) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_SetMainReady(void)
|
void SDL_SetMainReady(void)
|
||||||
{
|
{
|
||||||
SDL_MainIsReady = SDL_TRUE;
|
SDL_MainIsReady = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize all the subsystems that require initialization before threads start
|
// Initialize all the subsystems that require initialization before threads start
|
||||||
|
@ -612,7 +612,7 @@ Uint32 SDL_WasInit(SDL_InitFlags flags)
|
||||||
|
|
||||||
void SDL_Quit(void)
|
void SDL_Quit(void)
|
||||||
{
|
{
|
||||||
SDL_bInMainQuit = SDL_TRUE;
|
SDL_bInMainQuit = true;
|
||||||
|
|
||||||
// Quit all subsystems
|
// Quit all subsystems
|
||||||
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
||||||
|
@ -638,7 +638,7 @@ void SDL_Quit(void)
|
||||||
|
|
||||||
SDL_QuitMainThread();
|
SDL_QuitMainThread();
|
||||||
|
|
||||||
SDL_bInMainQuit = SDL_FALSE;
|
SDL_bInMainQuit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the library version number
|
// Get the library version number
|
||||||
|
@ -726,13 +726,13 @@ const char *SDL_GetPlatform(void)
|
||||||
SDL_bool SDL_IsTablet(void)
|
SDL_bool SDL_IsTablet(void)
|
||||||
{
|
{
|
||||||
#ifdef SDL_PLATFORM_ANDROID
|
#ifdef SDL_PLATFORM_ANDROID
|
||||||
extern SDL_bool SDL_IsAndroidTablet(void);
|
extern bool SDL_IsAndroidTablet(void);
|
||||||
return SDL_IsAndroidTablet();
|
return SDL_IsAndroidTablet();
|
||||||
#elif defined(SDL_PLATFORM_IOS)
|
#elif defined(SDL_PLATFORM_IOS)
|
||||||
extern SDL_bool SDL_IsIPad(void);
|
extern bool SDL_IsIPad(void);
|
||||||
return SDL_IsIPad();
|
return SDL_IsIPad();
|
||||||
#else
|
#else
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
|
||||||
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
||||||
// This is nasty, but we can't block on a custom UI.
|
// This is nasty, but we can't block on a custom UI.
|
||||||
for (;;) {
|
for (;;) {
|
||||||
SDL_bool okay = SDL_TRUE;
|
bool okay = true;
|
||||||
/* *INDENT-OFF* */ // clang-format off
|
/* *INDENT-OFF* */ // clang-format off
|
||||||
char *buf = (char *) MAIN_THREAD_EM_ASM_PTR({
|
char *buf = (char *) MAIN_THREAD_EM_ASM_PTR({
|
||||||
var str =
|
var str =
|
||||||
|
@ -275,7 +275,7 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
|
||||||
} else if (SDL_strcmp(buf, "A") == 0) {
|
} else if (SDL_strcmp(buf, "A") == 0) {
|
||||||
state = SDL_ASSERTION_ALWAYS_IGNORE;
|
state = SDL_ASSERTION_ALWAYS_IGNORE;
|
||||||
} else {
|
} else {
|
||||||
okay = SDL_FALSE;
|
okay = false;
|
||||||
}
|
}
|
||||||
free(buf); // This should NOT be SDL_free()
|
free(buf); // This should NOT be SDL_free()
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ SDL_AssertState SDL_ReportAssertion(SDL_AssertData *data, const char *func, cons
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case SDL_ASSERTION_ALWAYS_IGNORE:
|
case SDL_ASSERTION_ALWAYS_IGNORE:
|
||||||
state = SDL_ASSERTION_IGNORE;
|
state = SDL_ASSERTION_IGNORE;
|
||||||
data->always_ignore = SDL_TRUE;
|
data->always_ignore = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_ASSERTION_IGNORE:
|
case SDL_ASSERTION_IGNORE:
|
||||||
|
@ -430,7 +430,7 @@ void SDL_ResetAssertionReport(void)
|
||||||
SDL_AssertData *item;
|
SDL_AssertData *item;
|
||||||
for (item = triggered_assertions; item; item = next) {
|
for (item = triggered_assertions; item; item = next) {
|
||||||
next = (SDL_AssertData *)item->next;
|
next = (SDL_AssertData *)item->next;
|
||||||
item->always_ignore = SDL_FALSE;
|
item->always_ignore = false;
|
||||||
item->trigger_count = 0;
|
item->trigger_count = 0;
|
||||||
item->next = NULL;
|
item->next = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
if (fmt) {
|
if (fmt) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
SDL_error *error = SDL_GetErrBuf(SDL_TRUE);
|
SDL_error *error = SDL_GetErrBuf(true);
|
||||||
|
|
||||||
error->error = SDL_ErrorCodeGeneric;
|
error->error = SDL_ErrorCodeGeneric;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
|
|
||||||
const char *SDL_GetError(void)
|
const char *SDL_GetError(void)
|
||||||
{
|
{
|
||||||
const SDL_error *error = SDL_GetErrBuf(SDL_FALSE);
|
const SDL_error *error = SDL_GetErrBuf(false);
|
||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -79,7 +79,7 @@ const char *SDL_GetError(void)
|
||||||
|
|
||||||
int SDL_ClearError(void)
|
int SDL_ClearError(void)
|
||||||
{
|
{
|
||||||
SDL_error *error = SDL_GetErrBuf(SDL_FALSE);
|
SDL_error *error = SDL_GetErrBuf(false);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
error->error = SDL_ErrorCodeNone;
|
error->error = SDL_ErrorCodeNone;
|
||||||
|
@ -89,7 +89,7 @@ int SDL_ClearError(void)
|
||||||
|
|
||||||
int SDL_OutOfMemory(void)
|
int SDL_OutOfMemory(void)
|
||||||
{
|
{
|
||||||
SDL_error *error = SDL_GetErrBuf(SDL_TRUE);
|
SDL_error *error = SDL_GetErrBuf(true);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
error->error = SDL_ErrorCodeOutOfMemory;
|
error->error = SDL_ErrorCodeOutOfMemory;
|
||||||
|
|
|
@ -44,6 +44,6 @@ typedef struct SDL_error
|
||||||
} SDL_error;
|
} SDL_error;
|
||||||
|
|
||||||
// Defined in SDL_thread.c
|
// Defined in SDL_thread.c
|
||||||
extern SDL_error *SDL_GetErrBuf(SDL_bool create);
|
extern SDL_error *SDL_GetErrBuf(bool create);
|
||||||
|
|
||||||
#endif // SDL_error_c_h_
|
#endif // SDL_error_c_h_
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct SDL_HashTable
|
||||||
SDL_HashItem **table;
|
SDL_HashItem **table;
|
||||||
Uint32 table_len;
|
Uint32 table_len;
|
||||||
int hash_shift;
|
int hash_shift;
|
||||||
SDL_bool stackable;
|
bool stackable;
|
||||||
void *data;
|
void *data;
|
||||||
SDL_HashTable_HashFn hash;
|
SDL_HashTable_HashFn hash;
|
||||||
SDL_HashTable_KeyMatchFn keymatch;
|
SDL_HashTable_KeyMatchFn keymatch;
|
||||||
|
@ -43,7 +43,7 @@ struct SDL_HashTable
|
||||||
SDL_HashTable *SDL_CreateHashTable(void *data, const Uint32 num_buckets, const SDL_HashTable_HashFn hashfn,
|
SDL_HashTable *SDL_CreateHashTable(void *data, const Uint32 num_buckets, const SDL_HashTable_HashFn hashfn,
|
||||||
const SDL_HashTable_KeyMatchFn keymatchfn,
|
const SDL_HashTable_KeyMatchFn keymatchfn,
|
||||||
const SDL_HashTable_NukeFn nukefn,
|
const SDL_HashTable_NukeFn nukefn,
|
||||||
const SDL_bool stackable)
|
const bool stackable)
|
||||||
{
|
{
|
||||||
SDL_HashTable *table;
|
SDL_HashTable *table;
|
||||||
|
|
||||||
|
@ -83,23 +83,23 @@ static SDL_INLINE Uint32 calc_hash(const SDL_HashTable *table, const void *key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SDL_bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const void *value)
|
bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const void *value)
|
||||||
{
|
{
|
||||||
SDL_HashItem *item;
|
SDL_HashItem *item;
|
||||||
Uint32 hash;
|
Uint32 hash;
|
||||||
|
|
||||||
if (!table) {
|
if (!table) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (!table->stackable) && (SDL_FindInHashTable(table, key, NULL)) ) {
|
if ( (!table->stackable) && (SDL_FindInHashTable(table, key, NULL)) ) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// !!! FIXME: grow and rehash table if it gets too saturated.
|
// !!! FIXME: grow and rehash table if it gets too saturated.
|
||||||
item = (SDL_HashItem *) SDL_malloc(sizeof (SDL_HashItem));
|
item = (SDL_HashItem *) SDL_malloc(sizeof (SDL_HashItem));
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hash = calc_hash(table, key);
|
hash = calc_hash(table, key);
|
||||||
|
@ -109,17 +109,17 @@ SDL_bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const vo
|
||||||
item->next = table->table[hash];
|
item->next = table->table[hash];
|
||||||
table->table[hash] = item;
|
table->table[hash] = item;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const void **_value)
|
bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const void **_value)
|
||||||
{
|
{
|
||||||
Uint32 hash;
|
Uint32 hash;
|
||||||
void *data;
|
void *data;
|
||||||
SDL_HashItem *i;
|
SDL_HashItem *i;
|
||||||
|
|
||||||
if (!table) {
|
if (!table) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hash = calc_hash(table, key);
|
hash = calc_hash(table, key);
|
||||||
|
@ -130,14 +130,14 @@ SDL_bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const
|
||||||
if (_value) {
|
if (_value) {
|
||||||
*_value = i->value;
|
*_value = i->value;
|
||||||
}
|
}
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key)
|
bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key)
|
||||||
{
|
{
|
||||||
Uint32 hash;
|
Uint32 hash;
|
||||||
SDL_HashItem *item = NULL;
|
SDL_HashItem *item = NULL;
|
||||||
|
@ -145,7 +145,7 @@ SDL_bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key)
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
if (!table) {
|
if (!table) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hash = calc_hash(table, key);
|
hash = calc_hash(table, key);
|
||||||
|
@ -163,21 +163,21 @@ SDL_bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key)
|
||||||
table->nuke(item->key, item->value, data);
|
table->nuke(item->key, item->value, data);
|
||||||
}
|
}
|
||||||
SDL_free(item);
|
SDL_free(item);
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
prev = item;
|
prev = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, const void **_value, void **iter)
|
bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, const void **_value, void **iter)
|
||||||
{
|
{
|
||||||
SDL_HashItem *item;
|
SDL_HashItem *item;
|
||||||
|
|
||||||
if (!table) {
|
if (!table) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
item = *iter ? ((SDL_HashItem *)*iter)->next : table->table[calc_hash(table, key)];
|
item = *iter ? ((SDL_HashItem *)*iter)->next : table->table[calc_hash(table, key)];
|
||||||
|
@ -186,7 +186,7 @@ SDL_bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, co
|
||||||
if (table->keymatch(key, item->key, table->data)) {
|
if (table->keymatch(key, item->key, table->data)) {
|
||||||
*_value = item->value;
|
*_value = item->value;
|
||||||
*iter = item;
|
*iter = item;
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
item = item->next;
|
item = item->next;
|
||||||
}
|
}
|
||||||
|
@ -194,16 +194,16 @@ SDL_bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, co
|
||||||
// no more matches.
|
// no more matches.
|
||||||
*_value = NULL;
|
*_value = NULL;
|
||||||
*iter = NULL;
|
*iter = NULL;
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, const void **_value, void **iter)
|
bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, const void **_value, void **iter)
|
||||||
{
|
{
|
||||||
SDL_HashItem *item = (SDL_HashItem *) *iter;
|
SDL_HashItem *item = (SDL_HashItem *) *iter;
|
||||||
Uint32 idx = 0;
|
Uint32 idx = 0;
|
||||||
|
|
||||||
if (!table) {
|
if (!table) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
|
@ -221,17 +221,17 @@ SDL_bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, con
|
||||||
if (!item) { // no more matches?
|
if (!item) { // no more matches?
|
||||||
*_key = NULL;
|
*_key = NULL;
|
||||||
*iter = NULL;
|
*iter = NULL;
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*_key = item->key;
|
*_key = item->key;
|
||||||
*_value = item->value;
|
*_value = item->value;
|
||||||
*iter = item;
|
*iter = item;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_HashTableEmpty(SDL_HashTable *table)
|
bool SDL_HashTableEmpty(SDL_HashTable *table)
|
||||||
{
|
{
|
||||||
if (table) {
|
if (table) {
|
||||||
Uint32 i;
|
Uint32 i;
|
||||||
|
@ -239,11 +239,11 @@ SDL_bool SDL_HashTableEmpty(SDL_HashTable *table)
|
||||||
for (i = 0; i < table->table_len; i++) {
|
for (i = 0; i < table->table_len; i++) {
|
||||||
SDL_HashItem *item = table->table[i];
|
SDL_HashItem *item = table->table[i];
|
||||||
if (item) {
|
if (item) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_EmptyHashTable(SDL_HashTable *table)
|
void SDL_EmptyHashTable(SDL_HashTable *table)
|
||||||
|
@ -292,12 +292,12 @@ Uint32 SDL_HashString(const void *key, void *data)
|
||||||
return hash_string_djbxor(str, SDL_strlen(str));
|
return hash_string_djbxor(str, SDL_strlen(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_KeyMatchString(const void *a, const void *b, void *data)
|
bool SDL_KeyMatchString(const void *a, const void *b, void *data)
|
||||||
{
|
{
|
||||||
if (a == b) {
|
if (a == b) {
|
||||||
return SDL_TRUE; // same pointer, must match.
|
return true; // same pointer, must match.
|
||||||
} else if (!a || !b) {
|
} else if (!a || !b) {
|
||||||
return SDL_FALSE; // one pointer is NULL (and first test shows they aren't the same pointer), must not match.
|
return false; // one pointer is NULL (and first test shows they aren't the same pointer), must not match.
|
||||||
}
|
}
|
||||||
return (SDL_strcmp((const char *)a, (const char *)b) == 0); // Check against actual string contents.
|
return (SDL_strcmp((const char *)a, (const char *)b) == 0); // Check against actual string contents.
|
||||||
}
|
}
|
||||||
|
@ -310,12 +310,12 @@ Uint32 SDL_HashID(const void *key, void *unused)
|
||||||
return (Uint32)(uintptr_t)key;
|
return (Uint32)(uintptr_t)key;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_KeyMatchID(const void *a, const void *b, void *unused)
|
bool SDL_KeyMatchID(const void *a, const void *b, void *unused)
|
||||||
{
|
{
|
||||||
if (a == b) {
|
if (a == b) {
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_NukeFreeValue(const void *key, const void *value, void *unused)
|
void SDL_NukeFreeValue(const void *key, const void *value, void *unused)
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
struct SDL_HashTable;
|
struct SDL_HashTable;
|
||||||
typedef struct SDL_HashTable SDL_HashTable;
|
typedef struct SDL_HashTable SDL_HashTable;
|
||||||
typedef Uint32 (*SDL_HashTable_HashFn)(const void *key, void *data);
|
typedef Uint32 (*SDL_HashTable_HashFn)(const void *key, void *data);
|
||||||
typedef SDL_bool (*SDL_HashTable_KeyMatchFn)(const void *a, const void *b, void *data);
|
typedef bool (*SDL_HashTable_KeyMatchFn)(const void *a, const void *b, void *data);
|
||||||
typedef void (*SDL_HashTable_NukeFn)(const void *key, const void *value, void *data);
|
typedef void (*SDL_HashTable_NukeFn)(const void *key, const void *value, void *data);
|
||||||
|
|
||||||
extern SDL_HashTable *SDL_CreateHashTable(void *data,
|
extern SDL_HashTable *SDL_CreateHashTable(void *data,
|
||||||
|
@ -34,26 +34,26 @@ extern SDL_HashTable *SDL_CreateHashTable(void *data,
|
||||||
const SDL_HashTable_HashFn hashfn,
|
const SDL_HashTable_HashFn hashfn,
|
||||||
const SDL_HashTable_KeyMatchFn keymatchfn,
|
const SDL_HashTable_KeyMatchFn keymatchfn,
|
||||||
const SDL_HashTable_NukeFn nukefn,
|
const SDL_HashTable_NukeFn nukefn,
|
||||||
const SDL_bool stackable);
|
const bool stackable);
|
||||||
|
|
||||||
extern void SDL_EmptyHashTable(SDL_HashTable *table);
|
extern void SDL_EmptyHashTable(SDL_HashTable *table);
|
||||||
extern void SDL_DestroyHashTable(SDL_HashTable *table);
|
extern void SDL_DestroyHashTable(SDL_HashTable *table);
|
||||||
extern SDL_bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const void *value);
|
extern bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const void *value);
|
||||||
extern SDL_bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key);
|
extern bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key);
|
||||||
extern SDL_bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const void **_value);
|
extern bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const void **_value);
|
||||||
extern SDL_bool SDL_HashTableEmpty(SDL_HashTable *table);
|
extern bool SDL_HashTableEmpty(SDL_HashTable *table);
|
||||||
|
|
||||||
// iterate all values for a specific key. This only makes sense if the hash is stackable. If not-stackable, just use SDL_FindInHashTable().
|
// iterate all values for a specific key. This only makes sense if the hash is stackable. If not-stackable, just use SDL_FindInHashTable().
|
||||||
extern SDL_bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, const void **_value, void **iter);
|
extern bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, const void **_value, void **iter);
|
||||||
|
|
||||||
// iterate all key/value pairs in a hash (stackable hashes can have duplicate keys with multiple values).
|
// iterate all key/value pairs in a hash (stackable hashes can have duplicate keys with multiple values).
|
||||||
extern SDL_bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, const void **_value, void **iter);
|
extern bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, const void **_value, void **iter);
|
||||||
|
|
||||||
extern Uint32 SDL_HashString(const void *key, void *unused);
|
extern Uint32 SDL_HashString(const void *key, void *unused);
|
||||||
extern SDL_bool SDL_KeyMatchString(const void *a, const void *b, void *unused);
|
extern bool SDL_KeyMatchString(const void *a, const void *b, void *unused);
|
||||||
|
|
||||||
extern Uint32 SDL_HashID(const void *key, void *unused);
|
extern Uint32 SDL_HashID(const void *key, void *unused);
|
||||||
extern SDL_bool SDL_KeyMatchID(const void *a, const void *b, void *unused);
|
extern bool SDL_KeyMatchID(const void *a, const void *b, void *unused);
|
||||||
|
|
||||||
extern void SDL_NukeFreeValue(const void *key, const void *value, void *unused);
|
extern void SDL_NukeFreeValue(const void *key, const void *value, void *unused);
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ typedef struct SDL_Hint
|
||||||
|
|
||||||
static SDL_PropertiesID SDL_hint_props = 0;
|
static SDL_PropertiesID SDL_hint_props = 0;
|
||||||
|
|
||||||
static SDL_PropertiesID GetHintProperties(SDL_bool create)
|
static SDL_PropertiesID GetHintProperties(bool create)
|
||||||
{
|
{
|
||||||
if (!SDL_hint_props && create) {
|
if (!SDL_hint_props && create) {
|
||||||
SDL_hint_props = SDL_CreateProperties();
|
SDL_hint_props = SDL_CreateProperties();
|
||||||
|
@ -49,7 +49,7 @@ static SDL_PropertiesID GetHintProperties(SDL_bool create)
|
||||||
void SDL_InitHints(void)
|
void SDL_InitHints(void)
|
||||||
{
|
{
|
||||||
// Just make sure the hint properties are created on the main thread
|
// Just make sure the hint properties are created on the main thread
|
||||||
(void)GetHintProperties(SDL_TRUE);
|
(void)GetHintProperties(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL CleanupHintProperty(void *userdata, void *value)
|
static void SDLCALL CleanupHintProperty(void *userdata, void *value)
|
||||||
|
@ -77,7 +77,7 @@ int SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPriorit
|
||||||
return SDL_SetError("An environment variable is taking priority");
|
return SDL_SetError("An environment variable is taking priority");
|
||||||
}
|
}
|
||||||
|
|
||||||
const SDL_PropertiesID hints = GetHintProperties(SDL_TRUE);
|
const SDL_PropertiesID hints = GetHintProperties(true);
|
||||||
if (!hints) {
|
if (!hints) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ int SDL_ResetHint(const char *name)
|
||||||
|
|
||||||
const char *env = SDL_getenv(name);
|
const char *env = SDL_getenv(name);
|
||||||
|
|
||||||
const SDL_PropertiesID hints = GetHintProperties(SDL_FALSE);
|
const SDL_PropertiesID hints = GetHintProperties(false);
|
||||||
if (!hints) {
|
if (!hints) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ static void SDLCALL ResetHintsCallback(void *userdata, SDL_PropertiesID hints, c
|
||||||
|
|
||||||
void SDL_ResetHints(void)
|
void SDL_ResetHints(void)
|
||||||
{
|
{
|
||||||
SDL_EnumerateProperties(GetHintProperties(SDL_FALSE), ResetHintsCallback, NULL);
|
SDL_EnumerateProperties(GetHintProperties(false), ResetHintsCallback, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_SetHint(const char *name, const char *value)
|
int SDL_SetHint(const char *name, const char *value)
|
||||||
|
@ -198,7 +198,7 @@ const char *SDL_GetHint(const char *name)
|
||||||
|
|
||||||
const char *retval = SDL_getenv(name);
|
const char *retval = SDL_getenv(name);
|
||||||
|
|
||||||
const SDL_PropertiesID hints = GetHintProperties(SDL_FALSE);
|
const SDL_PropertiesID hints = GetHintProperties(false);
|
||||||
if (hints) {
|
if (hints) {
|
||||||
SDL_LockProperties(hints);
|
SDL_LockProperties(hints);
|
||||||
|
|
||||||
|
@ -232,15 +232,15 @@ int SDL_GetStringInteger(const char *value, int default_value)
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_GetStringBoolean(const char *value, SDL_bool default_value)
|
bool SDL_GetStringBoolean(const char *value, bool default_value)
|
||||||
{
|
{
|
||||||
if (!value || !*value) {
|
if (!value || !*value) {
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
if (*value == '0' || SDL_strcasecmp(value, "false") == 0) {
|
if (*value == '0' || SDL_strcasecmp(value, "false") == 0) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_GetHintBoolean(const char *name, SDL_bool default_value)
|
SDL_bool SDL_GetHintBoolean(const char *name, SDL_bool default_value)
|
||||||
|
@ -257,7 +257,7 @@ int SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userd
|
||||||
return SDL_InvalidParamError("callback");
|
return SDL_InvalidParamError("callback");
|
||||||
}
|
}
|
||||||
|
|
||||||
const SDL_PropertiesID hints = GetHintProperties(SDL_TRUE);
|
const SDL_PropertiesID hints = GetHintProperties(true);
|
||||||
if (!hints) {
|
if (!hints) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -311,7 +311,7 @@ void SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *user
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SDL_PropertiesID hints = GetHintProperties(SDL_FALSE);
|
const SDL_PropertiesID hints = GetHintProperties(false);
|
||||||
if (!hints) {
|
if (!hints) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#define SDL_hints_c_h_
|
#define SDL_hints_c_h_
|
||||||
|
|
||||||
extern void SDL_InitHints(void);
|
extern void SDL_InitHints(void);
|
||||||
extern SDL_bool SDL_GetStringBoolean(const char *value, SDL_bool default_value);
|
extern bool SDL_GetStringBoolean(const char *value, bool default_value);
|
||||||
extern int SDL_GetStringInteger(const char *value, int default_value);
|
extern int SDL_GetStringInteger(const char *value, int default_value);
|
||||||
extern void SDL_QuitHints(void);
|
extern void SDL_QuitHints(void);
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,16 @@
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#ifdef HAVE_STDBOOL_H
|
||||||
|
#include <stdbool.h>
|
||||||
|
#else
|
||||||
|
typedef int bool;
|
||||||
|
#define true 1
|
||||||
|
#define false 0
|
||||||
|
#endif
|
||||||
|
#endif // !__cplusplus
|
||||||
|
|
||||||
// If you run into a warning that O_CLOEXEC is redefined, update the SDL configuration header for your platform to add HAVE_O_CLOEXEC
|
// If you run into a warning that O_CLOEXEC is redefined, update the SDL configuration header for your platform to add HAVE_O_CLOEXEC
|
||||||
#ifndef HAVE_O_CLOEXEC
|
#ifndef HAVE_O_CLOEXEC
|
||||||
#define O_CLOEXEC 0
|
#define O_CLOEXEC 0
|
||||||
|
|
|
@ -57,7 +57,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
||||||
static void SDL_ResetLogPrefixes(void);
|
static void SDL_ResetLogPrefixes(void);
|
||||||
|
|
||||||
static SDL_LogLevel *SDL_loglevels;
|
static SDL_LogLevel *SDL_loglevels;
|
||||||
static SDL_bool SDL_forced_priority = SDL_FALSE;
|
static bool SDL_forced_priority = false;
|
||||||
static SDL_LogPriority SDL_forced_priority_level;
|
static SDL_LogPriority SDL_forced_priority_level;
|
||||||
static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput;
|
static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput;
|
||||||
static void *SDL_log_userdata = NULL;
|
static void *SDL_log_userdata = NULL;
|
||||||
|
@ -139,7 +139,7 @@ void SDL_SetLogPriorities(SDL_LogPriority priority)
|
||||||
entry->priority = priority;
|
entry->priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_forced_priority = SDL_TRUE;
|
SDL_forced_priority = true;
|
||||||
SDL_forced_priority_level = priority;
|
SDL_forced_priority_level = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,30 +164,30 @@ void SDL_SetLogPriority(int category, SDL_LogPriority priority)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SDL_ParseLogCategory(const char *string, size_t length, int *category)
|
static bool SDL_ParseLogCategory(const char *string, size_t length, int *category)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (SDL_isdigit(*string)) {
|
if (SDL_isdigit(*string)) {
|
||||||
*category = SDL_atoi(string);
|
*category = SDL_atoi(string);
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*string == '*') {
|
if (*string == '*') {
|
||||||
*category = DEFAULT_CATEGORY;
|
*category = DEFAULT_CATEGORY;
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < SDL_arraysize(SDL_category_names); ++i) {
|
for (i = 0; i < SDL_arraysize(SDL_category_names); ++i) {
|
||||||
if (SDL_strncasecmp(string, SDL_category_names[i], length) == 0) {
|
if (SDL_strncasecmp(string, SDL_category_names[i], length) == 0) {
|
||||||
*category = i;
|
*category = i;
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SDL_ParseLogPriority(const char *string, size_t length, SDL_LogPriority *priority)
|
static bool SDL_ParseLogPriority(const char *string, size_t length, SDL_LogPriority *priority)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -196,30 +196,30 @@ static SDL_bool SDL_ParseLogPriority(const char *string, size_t length, SDL_LogP
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
// 0 has a special meaning of "disable this category"
|
// 0 has a special meaning of "disable this category"
|
||||||
*priority = SDL_NUM_LOG_PRIORITIES;
|
*priority = SDL_NUM_LOG_PRIORITIES;
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
if (i >= SDL_LOG_PRIORITY_VERBOSE && i < SDL_NUM_LOG_PRIORITIES) {
|
if (i >= SDL_LOG_PRIORITY_VERBOSE && i < SDL_NUM_LOG_PRIORITIES) {
|
||||||
*priority = (SDL_LogPriority)i;
|
*priority = (SDL_LogPriority)i;
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_strncasecmp(string, "quiet", length) == 0) {
|
if (SDL_strncasecmp(string, "quiet", length) == 0) {
|
||||||
*priority = SDL_NUM_LOG_PRIORITIES;
|
*priority = SDL_NUM_LOG_PRIORITIES;
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = SDL_LOG_PRIORITY_VERBOSE; i < SDL_NUM_LOG_PRIORITIES; ++i) {
|
for (i = SDL_LOG_PRIORITY_VERBOSE; i < SDL_NUM_LOG_PRIORITIES; ++i) {
|
||||||
if (SDL_strncasecmp(string, SDL_priority_names[i], length) == 0) {
|
if (SDL_strncasecmp(string, SDL_priority_names[i], length) == 0) {
|
||||||
*priority = (SDL_LogPriority)i;
|
*priority = (SDL_LogPriority)i;
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SDL_ParseLogCategoryPriority(const char *hint, int category, SDL_LogPriority *priority)
|
static bool SDL_ParseLogCategoryPriority(const char *hint, int category, SDL_LogPriority *priority)
|
||||||
{
|
{
|
||||||
const char *name, *next;
|
const char *name, *next;
|
||||||
int current_category;
|
int current_category;
|
||||||
|
@ -251,7 +251,7 @@ static SDL_bool SDL_ParseLogCategoryPriority(const char *hint, int category, SDL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_LogPriority SDL_GetDefaultLogPriority(int category)
|
static SDL_LogPriority SDL_GetDefaultLogPriority(int category)
|
||||||
|
@ -306,7 +306,7 @@ void SDL_ResetLogPriorities(void)
|
||||||
SDL_loglevels = entry->next;
|
SDL_loglevels = entry->next;
|
||||||
SDL_free(entry);
|
SDL_free(entry);
|
||||||
}
|
}
|
||||||
SDL_forced_priority = SDL_FALSE;
|
SDL_forced_priority = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_ResetLogPrefixes(void)
|
static void SDL_ResetLogPrefixes(void)
|
||||||
|
@ -533,7 +533,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
||||||
char *output;
|
char *output;
|
||||||
size_t length;
|
size_t length;
|
||||||
LPTSTR tstr;
|
LPTSTR tstr;
|
||||||
SDL_bool isstack;
|
bool isstack;
|
||||||
|
|
||||||
#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK)
|
#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK)
|
||||||
BOOL attachResult;
|
BOOL attachResult;
|
||||||
|
|
|
@ -33,7 +33,7 @@ typedef struct
|
||||||
char *string_value;
|
char *string_value;
|
||||||
Sint64 number_value;
|
Sint64 number_value;
|
||||||
float float_value;
|
float float_value;
|
||||||
SDL_bool boolean_value;
|
bool boolean_value;
|
||||||
} value;
|
} value;
|
||||||
|
|
||||||
char *string_storage;
|
char *string_storage;
|
||||||
|
@ -54,7 +54,7 @@ static SDL_PropertiesID SDL_last_properties_id;
|
||||||
static SDL_PropertiesID SDL_global_properties;
|
static SDL_PropertiesID SDL_global_properties;
|
||||||
|
|
||||||
|
|
||||||
static void SDL_FreePropertyWithCleanup(const void *key, const void *value, void *data, SDL_bool cleanup)
|
static void SDL_FreePropertyWithCleanup(const void *key, const void *value, void *data, bool cleanup)
|
||||||
{
|
{
|
||||||
SDL_Property *property = (SDL_Property *)value;
|
SDL_Property *property = (SDL_Property *)value;
|
||||||
if (property) {
|
if (property) {
|
||||||
|
@ -78,7 +78,7 @@ static void SDL_FreePropertyWithCleanup(const void *key, const void *value, void
|
||||||
|
|
||||||
static void SDL_FreeProperty(const void *key, const void *value, void *data)
|
static void SDL_FreeProperty(const void *key, const void *value, void *data)
|
||||||
{
|
{
|
||||||
SDL_FreePropertyWithCleanup(key, value, data, SDL_TRUE);
|
SDL_FreePropertyWithCleanup(key, value, data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_FreeProperties(const void *key, const void *value, void *data)
|
static void SDL_FreeProperties(const void *key, const void *value, void *data)
|
||||||
|
@ -106,7 +106,7 @@ int SDL_InitProperties(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!SDL_properties) {
|
if (!SDL_properties) {
|
||||||
SDL_properties = SDL_CreateHashTable(NULL, 16, SDL_HashID, SDL_KeyMatchID, SDL_FreeProperties, SDL_FALSE);
|
SDL_properties = SDL_CreateHashTable(NULL, 16, SDL_HashID, SDL_KeyMatchID, SDL_FreeProperties, false);
|
||||||
if (!SDL_properties) {
|
if (!SDL_properties) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ SDL_PropertiesID SDL_CreateProperties(void)
|
||||||
{
|
{
|
||||||
SDL_PropertiesID props = 0;
|
SDL_PropertiesID props = 0;
|
||||||
SDL_Properties *properties = NULL;
|
SDL_Properties *properties = NULL;
|
||||||
SDL_bool inserted = SDL_FALSE;
|
bool inserted = false;
|
||||||
|
|
||||||
if (!SDL_properties && SDL_InitProperties() < 0) {
|
if (!SDL_properties && SDL_InitProperties() < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -152,7 +152,7 @@ SDL_PropertiesID SDL_CreateProperties(void)
|
||||||
if (!properties) {
|
if (!properties) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
properties->props = SDL_CreateHashTable(NULL, 4, SDL_HashString, SDL_KeyMatchString, SDL_FreeProperty, SDL_FALSE);
|
properties->props = SDL_CreateHashTable(NULL, 4, SDL_HashString, SDL_KeyMatchString, SDL_FreeProperty, false);
|
||||||
if (!properties->props) {
|
if (!properties->props) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ SDL_PropertiesID SDL_CreateProperties(void)
|
||||||
}
|
}
|
||||||
props = SDL_last_properties_id;
|
props = SDL_last_properties_id;
|
||||||
if (SDL_InsertIntoHashTable(SDL_properties, (const void *)(uintptr_t)props, properties)) {
|
if (SDL_InsertIntoHashTable(SDL_properties, (const void *)(uintptr_t)props, properties)) {
|
||||||
inserted = SDL_TRUE;
|
inserted = true;
|
||||||
}
|
}
|
||||||
SDL_UnlockMutex(SDL_properties_lock);
|
SDL_UnlockMutex(SDL_properties_lock);
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ int SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst)
|
||||||
dst_property->value.string_value = SDL_strdup(src_property->value.string_value);
|
dst_property->value.string_value = SDL_strdup(src_property->value.string_value);
|
||||||
}
|
}
|
||||||
if (!SDL_InsertIntoHashTable(dst_properties->props, dst_name, dst_property)) {
|
if (!SDL_InsertIntoHashTable(dst_properties->props, dst_name, dst_property)) {
|
||||||
SDL_FreePropertyWithCleanup(dst_name, dst_property, NULL, SDL_FALSE);
|
SDL_FreePropertyWithCleanup(dst_name, dst_property, NULL, false);
|
||||||
result = -1;
|
result = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,11 +303,11 @@ static int SDL_PrivateSetProperty(SDL_PropertiesID props, const char *name, SDL_
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
if (!props) {
|
if (!props) {
|
||||||
SDL_FreePropertyWithCleanup(NULL, property, NULL, SDL_TRUE);
|
SDL_FreePropertyWithCleanup(NULL, property, NULL, true);
|
||||||
return SDL_InvalidParamError("props");
|
return SDL_InvalidParamError("props");
|
||||||
}
|
}
|
||||||
if (!name || !*name) {
|
if (!name || !*name) {
|
||||||
SDL_FreePropertyWithCleanup(NULL, property, NULL, SDL_TRUE);
|
SDL_FreePropertyWithCleanup(NULL, property, NULL, true);
|
||||||
return SDL_InvalidParamError("name");
|
return SDL_InvalidParamError("name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ static int SDL_PrivateSetProperty(SDL_PropertiesID props, const char *name, SDL_
|
||||||
SDL_UnlockMutex(SDL_properties_lock);
|
SDL_UnlockMutex(SDL_properties_lock);
|
||||||
|
|
||||||
if (!properties) {
|
if (!properties) {
|
||||||
SDL_FreePropertyWithCleanup(NULL, property, NULL, SDL_TRUE);
|
SDL_FreePropertyWithCleanup(NULL, property, NULL, true);
|
||||||
return SDL_InvalidParamError("props");
|
return SDL_InvalidParamError("props");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ static int SDL_PrivateSetProperty(SDL_PropertiesID props, const char *name, SDL_
|
||||||
if (property) {
|
if (property) {
|
||||||
char *key = SDL_strdup(name);
|
char *key = SDL_strdup(name);
|
||||||
if (!SDL_InsertIntoHashTable(properties->props, key, property)) {
|
if (!SDL_InsertIntoHashTable(properties->props, key, property)) {
|
||||||
SDL_FreePropertyWithCleanup(key, property, NULL, SDL_TRUE);
|
SDL_FreePropertyWithCleanup(key, property, NULL, true);
|
||||||
result = -1;
|
result = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ int SDL_SetPointerPropertyWithCleanup(SDL_PropertiesID props, const char *name,
|
||||||
if (cleanup) {
|
if (cleanup) {
|
||||||
cleanup(userdata, value);
|
cleanup(userdata, value);
|
||||||
}
|
}
|
||||||
SDL_FreePropertyWithCleanup(NULL, property, NULL, SDL_FALSE);
|
SDL_FreePropertyWithCleanup(NULL, property, NULL, false);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
property->type = SDL_PROPERTY_TYPE_POINTER;
|
property->type = SDL_PROPERTY_TYPE_POINTER;
|
||||||
|
@ -451,7 +451,7 @@ int SDL_SetBooleanProperty(SDL_PropertiesID props, const char *name, SDL_bool va
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
property->type = SDL_PROPERTY_TYPE_BOOLEAN;
|
property->type = SDL_PROPERTY_TYPE_BOOLEAN;
|
||||||
property->value.boolean_value = value ? SDL_TRUE : SDL_FALSE;
|
property->value.boolean_value = value ? true : false;
|
||||||
return SDL_PrivateSetProperty(props, name, property);
|
return SDL_PrivateSetProperty(props, name, property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,7 +688,7 @@ float SDL_GetFloatProperty(SDL_PropertiesID props, const char *name, float defau
|
||||||
SDL_bool SDL_GetBooleanProperty(SDL_PropertiesID props, const char *name, SDL_bool default_value)
|
SDL_bool SDL_GetBooleanProperty(SDL_PropertiesID props, const char *name, SDL_bool default_value)
|
||||||
{
|
{
|
||||||
SDL_Properties *properties = NULL;
|
SDL_Properties *properties = NULL;
|
||||||
SDL_bool value = default_value;
|
bool value = default_value ? true : false;
|
||||||
|
|
||||||
if (!props) {
|
if (!props) {
|
||||||
return value;
|
return value;
|
||||||
|
@ -790,7 +790,7 @@ static void SDLCALL SDL_DumpPropertiesCallback(void *userdata, SDL_PropertiesID
|
||||||
SDL_Log("%s: %g\n", name, SDL_GetFloatProperty(props, name, 0.0f));
|
SDL_Log("%s: %g\n", name, SDL_GetFloatProperty(props, name, 0.0f));
|
||||||
break;
|
break;
|
||||||
case SDL_PROPERTY_TYPE_BOOLEAN:
|
case SDL_PROPERTY_TYPE_BOOLEAN:
|
||||||
SDL_Log("%s: %s\n", name, SDL_GetBooleanProperty(props, name, SDL_FALSE) ? "true" : "false");
|
SDL_Log("%s: %s\n", name, SDL_GetBooleanProperty(props, name, false) ? "true" : "false");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SDL_Log("%s UNKNOWN TYPE\n", name);
|
SDL_Log("%s UNKNOWN TYPE\n", name);
|
||||||
|
|
|
@ -92,17 +92,17 @@ void SDL_CalculateFraction(float x, int *numerator, int *denominator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_endswith(const char *string, const char *suffix)
|
bool SDL_endswith(const char *string, const char *suffix)
|
||||||
{
|
{
|
||||||
size_t string_length = string ? SDL_strlen(string) : 0;
|
size_t string_length = string ? SDL_strlen(string) : 0;
|
||||||
size_t suffix_length = suffix ? SDL_strlen(suffix) : 0;
|
size_t suffix_length = suffix ? SDL_strlen(suffix) : 0;
|
||||||
|
|
||||||
if (suffix_length > 0 && suffix_length <= string_length) {
|
if (suffix_length > 0 && suffix_length <= string_length) {
|
||||||
if (SDL_memcmp(string + string_length - suffix_length, suffix, suffix_length) == 0) {
|
if (SDL_memcmp(string + string_length - suffix_length, suffix, suffix_length) == 0) {
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assume we can wrap SDL_AtomicInt values and cast to Uint32
|
// Assume we can wrap SDL_AtomicInt values and cast to Uint32
|
||||||
|
@ -126,18 +126,18 @@ static Uint32 SDL_HashObject(const void *key, void *unused)
|
||||||
return (Uint32)(uintptr_t)key;
|
return (Uint32)(uintptr_t)key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SDL_KeyMatchObject(const void *a, const void *b, void *unused)
|
static bool SDL_KeyMatchObject(const void *a, const void *b, void *unused)
|
||||||
{
|
{
|
||||||
return (a == b);
|
return (a == b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_SetObjectValid(void *object, SDL_ObjectType type, SDL_bool valid)
|
void SDL_SetObjectValid(void *object, SDL_ObjectType type, bool valid)
|
||||||
{
|
{
|
||||||
SDL_assert(object != NULL);
|
SDL_assert(object != NULL);
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (!SDL_objects) {
|
if (!SDL_objects) {
|
||||||
SDL_objects = SDL_CreateHashTable(NULL, 32, SDL_HashObject, SDL_KeyMatchObject, NULL, SDL_FALSE);
|
SDL_objects = SDL_CreateHashTable(NULL, 32, SDL_HashObject, SDL_KeyMatchObject, NULL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_InsertIntoHashTable(SDL_objects, object, (void *)(uintptr_t)type);
|
SDL_InsertIntoHashTable(SDL_objects, object, (void *)(uintptr_t)type);
|
||||||
|
@ -148,15 +148,15 @@ void SDL_SetObjectValid(void *object, SDL_ObjectType type, SDL_bool valid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_ObjectValid(void *object, SDL_ObjectType type)
|
bool SDL_ObjectValid(void *object, SDL_ObjectType type)
|
||||||
{
|
{
|
||||||
if (!object) {
|
if (!object) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *object_type;
|
const void *object_type;
|
||||||
if (!SDL_FindInHashTable(SDL_objects, object, &object_type)) {
|
if (!SDL_FindInHashTable(SDL_objects, object, &object_type)) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (((SDL_ObjectType)(uintptr_t)object_type) == type);
|
return (((SDL_ObjectType)(uintptr_t)object_type) == type);
|
||||||
|
@ -277,7 +277,7 @@ int SDL_URIToLocal(const char *src, char *dst)
|
||||||
return -1; // wrong scheme
|
return -1; // wrong scheme
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool local = src[0] != '/' || (src[0] != '\0' && src[1] == '/');
|
bool local = src[0] != '/' || (src[0] != '\0' && src[1] == '/');
|
||||||
|
|
||||||
// Check the hostname, if present. RFC 3986 states that the hostname component of a URI is not case-sensitive.
|
// Check the hostname, if present. RFC 3986 states that the hostname component of a URI is not case-sensitive.
|
||||||
if (!local && src[0] == '/' && src[2] != '/') {
|
if (!local && src[0] == '/' && src[2] != '/') {
|
||||||
|
@ -293,7 +293,7 @@ int SDL_URIToLocal(const char *src, char *dst)
|
||||||
hostname_len = SDL_strlen(hostname);
|
hostname_len = SDL_strlen(hostname);
|
||||||
if (hostname_len == src_len && SDL_strncasecmp(src + 1, hostname, src_len) == 0) {
|
if (hostname_len == src_len && SDL_strncasecmp(src + 1, hostname, src_len) == 0) {
|
||||||
src = hostname_end + 1;
|
src = hostname_end + 1;
|
||||||
local = SDL_TRUE;
|
local = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -303,7 +303,7 @@ int SDL_URIToLocal(const char *src, char *dst)
|
||||||
hostname_len = SDL_strlen(localhost);
|
hostname_len = SDL_strlen(localhost);
|
||||||
if (hostname_len == src_len && SDL_strncasecmp(src + 1, localhost, src_len) == 0) {
|
if (hostname_len == src_len && SDL_strncasecmp(src + 1, localhost, src_len) == 0) {
|
||||||
src = hostname_end + 1;
|
src = hostname_end + 1;
|
||||||
local = SDL_TRUE;
|
local = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,7 +344,7 @@ const char *SDL_GetPersistentString(const char *string)
|
||||||
|
|
||||||
SDL_HashTable *strings = (SDL_HashTable *)SDL_GetTLS(&SDL_string_storage);
|
SDL_HashTable *strings = (SDL_HashTable *)SDL_GetTLS(&SDL_string_storage);
|
||||||
if (!strings) {
|
if (!strings) {
|
||||||
strings = SDL_CreateHashTable(NULL, 32, SDL_HashString, SDL_KeyMatchString, SDL_NukeFreeValue, SDL_FALSE);
|
strings = SDL_CreateHashTable(NULL, 32, SDL_HashString, SDL_KeyMatchString, SDL_NukeFreeValue, false);
|
||||||
if (!strings) {
|
if (!strings) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ extern int SDL_powerof2(int x);
|
||||||
|
|
||||||
extern void SDL_CalculateFraction(float x, int *numerator, int *denominator);
|
extern void SDL_CalculateFraction(float x, int *numerator, int *denominator);
|
||||||
|
|
||||||
extern SDL_bool SDL_endswith(const char *string, const char *suffix);
|
extern bool SDL_endswith(const char *string, const char *suffix);
|
||||||
|
|
||||||
/** Convert URI to a local filename, stripping the "file://"
|
/** Convert URI to a local filename, stripping the "file://"
|
||||||
* preamble and hostname if present, and writes the result
|
* preamble and hostname if present, and writes the result
|
||||||
|
@ -61,8 +61,8 @@ typedef enum
|
||||||
} SDL_ObjectType;
|
} SDL_ObjectType;
|
||||||
|
|
||||||
extern Uint32 SDL_GetNextObjectID(void);
|
extern Uint32 SDL_GetNextObjectID(void);
|
||||||
extern void SDL_SetObjectValid(void *object, SDL_ObjectType type, SDL_bool valid);
|
extern void SDL_SetObjectValid(void *object, SDL_ObjectType type, bool valid);
|
||||||
extern SDL_bool SDL_ObjectValid(void *object, SDL_ObjectType type);
|
extern bool SDL_ObjectValid(void *object, SDL_ObjectType type);
|
||||||
extern void SDL_SetObjectsInvalid(void);
|
extern void SDL_SetObjectsInvalid(void);
|
||||||
|
|
||||||
extern const char *SDL_GetPersistentString(const char *string);
|
extern const char *SDL_GetPersistentString(const char *string);
|
||||||
|
|
|
@ -136,12 +136,12 @@ SDL_bool SDL_AtomicCompareAndSwap(SDL_AtomicInt *a, int oldval, int newval)
|
||||||
#elif defined(SDL_PLATFORM_SOLARIS)
|
#elif defined(SDL_PLATFORM_SOLARIS)
|
||||||
return ((int)atomic_cas_uint((volatile uint_t *)&a->value, (uint_t)oldval, (uint_t)newval) == oldval);
|
return ((int)atomic_cas_uint((volatile uint_t *)&a->value, (uint_t)oldval, (uint_t)newval) == oldval);
|
||||||
#elif defined(EMULATE_CAS)
|
#elif defined(EMULATE_CAS)
|
||||||
SDL_bool retval = SDL_FALSE;
|
bool retval = false;
|
||||||
|
|
||||||
enterLock(a);
|
enterLock(a);
|
||||||
if (a->value == oldval) {
|
if (a->value == oldval) {
|
||||||
a->value = newval;
|
a->value = newval;
|
||||||
retval = SDL_TRUE;
|
retval = true;
|
||||||
}
|
}
|
||||||
leaveLock(a);
|
leaveLock(a);
|
||||||
|
|
||||||
|
@ -166,12 +166,12 @@ SDL_bool SDL_AtomicCompareAndSwapPointer(void **a, void *oldval, void *newval)
|
||||||
#elif defined(SDL_PLATFORM_SOLARIS)
|
#elif defined(SDL_PLATFORM_SOLARIS)
|
||||||
return (atomic_cas_ptr(a, oldval, newval) == oldval);
|
return (atomic_cas_ptr(a, oldval, newval) == oldval);
|
||||||
#elif defined(EMULATE_CAS)
|
#elif defined(EMULATE_CAS)
|
||||||
SDL_bool retval = SDL_FALSE;
|
bool retval = false;
|
||||||
|
|
||||||
enterLock(a);
|
enterLock(a);
|
||||||
if (*a == oldval) {
|
if (*a == oldval) {
|
||||||
*a = newval;
|
*a = newval;
|
||||||
retval = SDL_TRUE;
|
retval = true;
|
||||||
}
|
}
|
||||||
leaveLock(a);
|
leaveLock(a);
|
||||||
|
|
||||||
|
|
|
@ -128,13 +128,13 @@ SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock)
|
||||||
return ((int)atomic_cas_32((volatile uint32_t *)lock, 0, 1) == 0);
|
return ((int)atomic_cas_32((volatile uint32_t *)lock, 0, 1) == 0);
|
||||||
#elif defined(PS2)
|
#elif defined(PS2)
|
||||||
uint32_t oldintr;
|
uint32_t oldintr;
|
||||||
SDL_bool res = SDL_FALSE;
|
bool res = false;
|
||||||
// disable interuption
|
// disable interuption
|
||||||
oldintr = DIntr();
|
oldintr = DIntr();
|
||||||
|
|
||||||
if (*lock == 0) {
|
if (*lock == 0) {
|
||||||
*lock = 1;
|
*lock = 1;
|
||||||
res = SDL_TRUE;
|
res = true;
|
||||||
}
|
}
|
||||||
// enable interuption
|
// enable interuption
|
||||||
if (oldintr) {
|
if (oldintr) {
|
||||||
|
@ -153,10 +153,10 @@ SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock)
|
||||||
if (*lock == 0) {
|
if (*lock == 0) {
|
||||||
*lock = 1;
|
*lock = 1;
|
||||||
SDL_UnlockMutex(_spinlock_mutex);
|
SDL_UnlockMutex(_spinlock_mutex);
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
SDL_UnlockMutex(_spinlock_mutex);
|
SDL_UnlockMutex(_spinlock_mutex);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,10 +112,10 @@ int SDL_GetNumAudioDrivers(void)
|
||||||
|
|
||||||
// Build a list of unique audio drivers.
|
// Build a list of unique audio drivers.
|
||||||
for (int i = 0; bootstrap[i] != NULL; ++i) {
|
for (int i = 0; bootstrap[i] != NULL; ++i) {
|
||||||
SDL_bool duplicate = SDL_FALSE;
|
bool duplicate = false;
|
||||||
for (int j = 0; j < i; ++j) {
|
for (int j = 0; j < i; ++j) {
|
||||||
if (SDL_strcmp(bootstrap[i]->name, bootstrap[j]->name) == 0) {
|
if (SDL_strcmp(bootstrap[i]->name, bootstrap[j]->name) == 0) {
|
||||||
duplicate = SDL_TRUE;
|
duplicate = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ void OnAudioStreamDestroy(SDL_AudioStream *stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
// device should be locked when calling this.
|
// device should be locked when calling this.
|
||||||
static SDL_bool AudioDeviceCanUseSimpleCopy(SDL_AudioDevice *device)
|
static bool AudioDeviceCanUseSimpleCopy(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
SDL_assert(device != NULL);
|
SDL_assert(device != NULL);
|
||||||
return (
|
return (
|
||||||
|
@ -240,7 +240,7 @@ static void UpdateAudioStreamFormatsPhysical(SDL_AudioDevice *device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const SDL_bool simple_copy = AudioDeviceCanUseSimpleCopy(device);
|
const bool simple_copy = AudioDeviceCanUseSimpleCopy(device);
|
||||||
SDL_AudioSpec spec;
|
SDL_AudioSpec spec;
|
||||||
|
|
||||||
device->simple_copy = simple_copy;
|
device->simple_copy = simple_copy;
|
||||||
|
@ -263,14 +263,14 @@ static void UpdateAudioStreamFormatsPhysical(SDL_AudioDevice *device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_AudioSpecsEqual(const SDL_AudioSpec *a, const SDL_AudioSpec *b, const int *channel_map_a, const int *channel_map_b)
|
bool SDL_AudioSpecsEqual(const SDL_AudioSpec *a, const SDL_AudioSpec *b, const int *channel_map_a, const int *channel_map_b)
|
||||||
{
|
{
|
||||||
if ((a->format != b->format) || (a->channels != b->channels) || (a->freq != b->freq) || ((channel_map_a != NULL) != (channel_map_b != NULL))) {
|
if ((a->format != b->format) || (a->channels != b->channels) || (a->freq != b->freq) || ((channel_map_a != NULL) != (channel_map_b != NULL))) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
} else if (channel_map_a && (SDL_memcmp(channel_map_a, channel_map_b, sizeof (*channel_map_a) * a->channels) != 0)) {
|
} else if (channel_map_a && (SDL_memcmp(channel_map_a, channel_map_b, sizeof (*channel_map_a) * a->channels) != 0)) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ static void ClosePhysicalAudioDevice(SDL_AudioDevice *device);
|
||||||
SDL_COMPILE_TIME_ASSERT(check_lowest_audio_default_value, SDL_AUDIO_DEVICE_DEFAULT_RECORDING < SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK);
|
SDL_COMPILE_TIME_ASSERT(check_lowest_audio_default_value, SDL_AUDIO_DEVICE_DEFAULT_RECORDING < SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK);
|
||||||
|
|
||||||
static SDL_AtomicInt last_device_instance_id; // increments on each device add to provide unique instance IDs
|
static SDL_AtomicInt last_device_instance_id; // increments on each device add to provide unique instance IDs
|
||||||
static SDL_AudioDeviceID AssignAudioDeviceInstanceId(SDL_bool recording, SDL_bool islogical)
|
static SDL_AudioDeviceID AssignAudioDeviceInstanceId(bool recording, bool islogical)
|
||||||
{
|
{
|
||||||
/* Assign an instance id! Start at 2, in case there are things from the SDL2 era that still think 1 is a special value.
|
/* Assign an instance id! Start at 2, in case there are things from the SDL2 era that still think 1 is a special value.
|
||||||
Also, make sure we don't assign SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, etc. */
|
Also, make sure we don't assign SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, etc. */
|
||||||
|
@ -374,7 +374,7 @@ static SDL_LogicalAudioDevice *ObtainLogicalAudioDevice(SDL_AudioDeviceID devid,
|
||||||
SDL_LogicalAudioDevice *logdev = NULL;
|
SDL_LogicalAudioDevice *logdev = NULL;
|
||||||
|
|
||||||
// bit #1 of devid is set for physical devices and unset for logical.
|
// bit #1 of devid is set for physical devices and unset for logical.
|
||||||
const SDL_bool islogical = !(devid & (1<<1));
|
const bool islogical = !(devid & (1<<1));
|
||||||
if (islogical) { // don't bother looking if it's not a logical device id value.
|
if (islogical) { // don't bother looking if it's not a logical device id value.
|
||||||
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
||||||
SDL_FindInHashTable(current_audio.device_hash, (const void *) (uintptr_t) devid, (const void **) &logdev);
|
SDL_FindInHashTable(current_audio.device_hash, (const void *) (uintptr_t) devid, (const void **) &logdev);
|
||||||
|
@ -388,7 +388,7 @@ static SDL_LogicalAudioDevice *ObtainLogicalAudioDevice(SDL_AudioDeviceID devid,
|
||||||
if (logdev) {
|
if (logdev) {
|
||||||
// we have to release the device_hash_lock before we take the device lock, to avoid deadlocks, so do a loop
|
// we have to release the device_hash_lock before we take the device lock, to avoid deadlocks, so do a loop
|
||||||
// to make sure the correct physical device gets locked, in case we're in a race with the default changing.
|
// to make sure the correct physical device gets locked, in case we're in a race with the default changing.
|
||||||
while (SDL_TRUE) {
|
while (true) {
|
||||||
SDL_LockMutex(device->lock);
|
SDL_LockMutex(device->lock);
|
||||||
SDL_AudioDevice *recheck_device = (SDL_AudioDevice *) SDL_AtomicGetPtr((void **) &logdev->physical_device);
|
SDL_AudioDevice *recheck_device = (SDL_AudioDevice *) SDL_AtomicGetPtr((void **) &logdev->physical_device);
|
||||||
if (device == recheck_device) {
|
if (device == recheck_device) {
|
||||||
|
@ -420,7 +420,7 @@ static SDL_AudioDevice *ObtainPhysicalAudioDevice(SDL_AudioDeviceID devid) // !
|
||||||
SDL_AudioDevice *device = NULL;
|
SDL_AudioDevice *device = NULL;
|
||||||
|
|
||||||
// bit #1 of devid is set for physical devices and unset for logical.
|
// bit #1 of devid is set for physical devices and unset for logical.
|
||||||
const SDL_bool islogical = !(devid & (1<<1));
|
const bool islogical = !(devid & (1<<1));
|
||||||
if (islogical) {
|
if (islogical) {
|
||||||
ObtainLogicalAudioDevice(devid, &device);
|
ObtainLogicalAudioDevice(devid, &device);
|
||||||
} else if (!SDL_GetCurrentAudioDriver()) { // (the `islogical` path, above, checks this in ObtainLogicalAudioDevice.)
|
} else if (!SDL_GetCurrentAudioDriver()) { // (the `islogical` path, above, checks this in ObtainLogicalAudioDevice.)
|
||||||
|
@ -442,14 +442,14 @@ static SDL_AudioDevice *ObtainPhysicalAudioDevice(SDL_AudioDeviceID devid) // !
|
||||||
|
|
||||||
static SDL_AudioDevice *ObtainPhysicalAudioDeviceDefaultAllowed(SDL_AudioDeviceID devid) // !!! FIXME: SDL_ACQUIRE
|
static SDL_AudioDevice *ObtainPhysicalAudioDeviceDefaultAllowed(SDL_AudioDeviceID devid) // !!! FIXME: SDL_ACQUIRE
|
||||||
{
|
{
|
||||||
const SDL_bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) || (devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING));
|
const bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) || (devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING));
|
||||||
if (!wants_default) {
|
if (!wants_default) {
|
||||||
return ObtainPhysicalAudioDevice(devid);
|
return ObtainPhysicalAudioDevice(devid);
|
||||||
}
|
}
|
||||||
|
|
||||||
const SDL_AudioDeviceID orig_devid = devid;
|
const SDL_AudioDeviceID orig_devid = devid;
|
||||||
|
|
||||||
while (SDL_TRUE) {
|
while (true) {
|
||||||
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
||||||
if (orig_devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) {
|
if (orig_devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) {
|
||||||
devid = current_audio.default_playback_device_id;
|
devid = current_audio.default_playback_device_id;
|
||||||
|
@ -469,12 +469,12 @@ static SDL_AudioDevice *ObtainPhysicalAudioDeviceDefaultAllowed(SDL_AudioDeviceI
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure the default didn't change while we were waiting for the lock...
|
// make sure the default didn't change while we were waiting for the lock...
|
||||||
SDL_bool got_it = SDL_FALSE;
|
bool got_it = false;
|
||||||
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
||||||
if ((orig_devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) && (devid == current_audio.default_playback_device_id)) {
|
if ((orig_devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) && (devid == current_audio.default_playback_device_id)) {
|
||||||
got_it = SDL_TRUE;
|
got_it = true;
|
||||||
} else if ((orig_devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING) && (devid == current_audio.default_recording_device_id)) {
|
} else if ((orig_devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING) && (devid == current_audio.default_recording_device_id)) {
|
||||||
got_it = SDL_TRUE;
|
got_it = true;
|
||||||
}
|
}
|
||||||
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
||||||
|
|
||||||
|
@ -571,7 +571,7 @@ void RefPhysicalAudioDevice(SDL_AudioDevice *device)
|
||||||
SDL_AtomicIncRef(&device->refcount);
|
SDL_AtomicIncRef(&device->refcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, SDL_bool recording, const SDL_AudioSpec *spec, void *handle, SDL_AtomicInt *device_count)
|
static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, bool recording, const SDL_AudioSpec *spec, void *handle, SDL_AtomicInt *device_count)
|
||||||
{
|
{
|
||||||
SDL_assert(name != NULL);
|
SDL_assert(name != NULL);
|
||||||
|
|
||||||
|
@ -617,7 +617,7 @@ static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, SDL_bool rec
|
||||||
device->silence_value = SDL_GetSilenceValueForFormat(device->spec.format);
|
device->silence_value = SDL_GetSilenceValueForFormat(device->spec.format);
|
||||||
device->handle = handle;
|
device->handle = handle;
|
||||||
|
|
||||||
device->instance_id = AssignAudioDeviceInstanceId(recording, /*islogical=*/SDL_FALSE);
|
device->instance_id = AssignAudioDeviceInstanceId(recording, /*islogical=*/false);
|
||||||
|
|
||||||
SDL_LockRWLockForWriting(current_audio.device_hash_lock);
|
SDL_LockRWLockForWriting(current_audio.device_hash_lock);
|
||||||
if (SDL_InsertIntoHashTable(current_audio.device_hash, (const void *) (uintptr_t) device->instance_id, device)) {
|
if (SDL_InsertIntoHashTable(current_audio.device_hash, (const void *) (uintptr_t) device->instance_id, device)) {
|
||||||
|
@ -638,16 +638,16 @@ static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, SDL_bool rec
|
||||||
static SDL_AudioDevice *CreateAudioRecordingDevice(const char *name, const SDL_AudioSpec *spec, void *handle)
|
static SDL_AudioDevice *CreateAudioRecordingDevice(const char *name, const SDL_AudioSpec *spec, void *handle)
|
||||||
{
|
{
|
||||||
SDL_assert(current_audio.impl.HasRecordingSupport);
|
SDL_assert(current_audio.impl.HasRecordingSupport);
|
||||||
return CreatePhysicalAudioDevice(name, SDL_TRUE, spec, handle, ¤t_audio.recording_device_count);
|
return CreatePhysicalAudioDevice(name, true, spec, handle, ¤t_audio.recording_device_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_AudioDevice *CreateAudioPlaybackDevice(const char *name, const SDL_AudioSpec *spec, void *handle)
|
static SDL_AudioDevice *CreateAudioPlaybackDevice(const char *name, const SDL_AudioSpec *spec, void *handle)
|
||||||
{
|
{
|
||||||
return CreatePhysicalAudioDevice(name, SDL_FALSE, spec, handle, ¤t_audio.playback_device_count);
|
return CreatePhysicalAudioDevice(name, false, spec, handle, ¤t_audio.playback_device_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The audio backends call this when a new device is plugged in.
|
// The audio backends call this when a new device is plugged in.
|
||||||
SDL_AudioDevice *SDL_AddAudioDevice(SDL_bool recording, const char *name, const SDL_AudioSpec *inspec, void *handle)
|
SDL_AudioDevice *SDL_AddAudioDevice(bool recording, const char *name, const SDL_AudioSpec *inspec, void *handle)
|
||||||
{
|
{
|
||||||
// device handles MUST be unique! If the target reuses the same handle for hardware with both recording and playback interfaces, wrap it in a pointer you SDL_malloc'd!
|
// device handles MUST be unique! If the target reuses the same handle for hardware with both recording and playback interfaces, wrap it in a pointer you SDL_malloc'd!
|
||||||
SDL_assert(SDL_FindPhysicalAudioDeviceByHandle(handle) == NULL);
|
SDL_assert(SDL_FindPhysicalAudioDeviceByHandle(handle) == NULL);
|
||||||
|
@ -708,10 +708,10 @@ void SDL_AudioDeviceDisconnected(SDL_AudioDevice *device)
|
||||||
|
|
||||||
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
||||||
const SDL_AudioDeviceID devid = device->instance_id;
|
const SDL_AudioDeviceID devid = device->instance_id;
|
||||||
const SDL_bool is_default_device = ((devid == current_audio.default_playback_device_id) || (devid == current_audio.default_recording_device_id));
|
const bool is_default_device = ((devid == current_audio.default_playback_device_id) || (devid == current_audio.default_recording_device_id));
|
||||||
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
||||||
|
|
||||||
const SDL_bool first_disconnect = SDL_AtomicCompareAndSwap(&device->zombie, 0, 1);
|
const bool first_disconnect = SDL_AtomicCompareAndSwap(&device->zombie, 0, 1);
|
||||||
if (first_disconnect) { // if already disconnected this device, don't do it twice.
|
if (first_disconnect) { // if already disconnected this device, don't do it twice.
|
||||||
// Swap in "Zombie" versions of the usual platform interfaces, so the device will keep
|
// Swap in "Zombie" versions of the usual platform interfaces, so the device will keep
|
||||||
// making progress until the app closes it. Otherwise, streams might continue to
|
// making progress until the app closes it. Otherwise, streams might continue to
|
||||||
|
@ -790,9 +790,9 @@ static void SDL_AudioDetectDevices_Default(SDL_AudioDevice **default_playback, S
|
||||||
SDL_assert(current_audio.impl.OnlyHasDefaultPlaybackDevice);
|
SDL_assert(current_audio.impl.OnlyHasDefaultPlaybackDevice);
|
||||||
SDL_assert(current_audio.impl.OnlyHasDefaultRecordingDevice || !current_audio.impl.HasRecordingSupport);
|
SDL_assert(current_audio.impl.OnlyHasDefaultRecordingDevice || !current_audio.impl.HasRecordingSupport);
|
||||||
|
|
||||||
*default_playback = SDL_AddAudioDevice(SDL_FALSE, DEFAULT_PLAYBACK_DEVNAME, NULL, (void *)((size_t)0x1));
|
*default_playback = SDL_AddAudioDevice(false, DEFAULT_PLAYBACK_DEVNAME, NULL, (void *)((size_t)0x1));
|
||||||
if (current_audio.impl.HasRecordingSupport) {
|
if (current_audio.impl.HasRecordingSupport) {
|
||||||
*default_recording = SDL_AddAudioDevice(SDL_TRUE, DEFAULT_RECORDING_DEVNAME, NULL, (void *)((size_t)0x2));
|
*default_recording = SDL_AddAudioDevice(true, DEFAULT_RECORDING_DEVNAME, NULL, (void *)((size_t)0x2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -833,7 +833,7 @@ static void CompleteAudioEntryPoints(void)
|
||||||
#undef FILL_STUB
|
#undef FILL_STUB
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_AudioDevice *GetFirstAddedAudioDevice(const SDL_bool recording)
|
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_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 *retval = NULL;
|
||||||
|
@ -848,8 +848,8 @@ static SDL_AudioDevice *GetFirstAddedAudioDevice(const SDL_bool recording)
|
||||||
const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
|
const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
|
||||||
// bit #0 of devid is set for playback devices and unset for recording.
|
// bit #0 of devid is set for playback devices and unset for recording.
|
||||||
// bit #1 of devid is set for physical devices and unset for logical.
|
// bit #1 of devid is set for physical devices and unset for logical.
|
||||||
const SDL_bool devid_recording = !(devid & (1 << 0));
|
const bool devid_recording = !(devid & (1 << 0));
|
||||||
const SDL_bool isphysical = (devid & (1 << 1));
|
const bool isphysical = (devid & (1 << 1));
|
||||||
if (isphysical && (devid_recording == recording) && (devid < highest)) {
|
if (isphysical && (devid_recording == recording) && (devid < highest)) {
|
||||||
highest = devid;
|
highest = devid;
|
||||||
retval = (SDL_AudioDevice *) value;
|
retval = (SDL_AudioDevice *) value;
|
||||||
|
@ -867,7 +867,7 @@ static Uint32 HashAudioDeviceID(const void *key, void *data)
|
||||||
return ((Uint32) ((uintptr_t) key)) >> 2;
|
return ((Uint32) ((uintptr_t) key)) >> 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool MatchAudioDeviceID(const void *a, const void *b, void *data)
|
static bool MatchAudioDeviceID(const void *a, const void *b, void *data)
|
||||||
{
|
{
|
||||||
return (a == b);
|
return (a == b);
|
||||||
}
|
}
|
||||||
|
@ -895,7 +895,7 @@ int SDL_InitAudio(const char *driver_name)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_HashTable *device_hash = SDL_CreateHashTable(NULL, 8, HashAudioDeviceID, MatchAudioDeviceID, NukeAudioDeviceHashItem, SDL_FALSE);
|
SDL_HashTable *device_hash = SDL_CreateHashTable(NULL, 8, HashAudioDeviceID, MatchAudioDeviceID, NukeAudioDeviceHashItem, false);
|
||||||
if (!device_hash) {
|
if (!device_hash) {
|
||||||
SDL_DestroyRWLock(device_hash_lock);
|
SDL_DestroyRWLock(device_hash_lock);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -906,8 +906,8 @@ int SDL_InitAudio(const char *driver_name)
|
||||||
driver_name = SDL_GetHint(SDL_HINT_AUDIO_DRIVER);
|
driver_name = SDL_GetHint(SDL_HINT_AUDIO_DRIVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool initialized = SDL_FALSE;
|
bool initialized = false;
|
||||||
SDL_bool tried_to_init = SDL_FALSE;
|
bool tried_to_init = false;
|
||||||
|
|
||||||
if (driver_name && *driver_name != 0) {
|
if (driver_name && *driver_name != 0) {
|
||||||
char *driver_name_copy = SDL_strdup(driver_name);
|
char *driver_name_copy = SDL_strdup(driver_name);
|
||||||
|
@ -934,7 +934,7 @@ int SDL_InitAudio(const char *driver_name)
|
||||||
|
|
||||||
for (int i = 0; bootstrap[i]; ++i) {
|
for (int i = 0; bootstrap[i]; ++i) {
|
||||||
if (SDL_strcasecmp(bootstrap[i]->name, driver_attempt) == 0) {
|
if (SDL_strcasecmp(bootstrap[i]->name, driver_attempt) == 0) {
|
||||||
tried_to_init = SDL_TRUE;
|
tried_to_init = true;
|
||||||
SDL_zero(current_audio);
|
SDL_zero(current_audio);
|
||||||
current_audio.pending_events_tail = ¤t_audio.pending_events;
|
current_audio.pending_events_tail = ¤t_audio.pending_events;
|
||||||
current_audio.device_hash_lock = device_hash_lock;
|
current_audio.device_hash_lock = device_hash_lock;
|
||||||
|
@ -942,7 +942,7 @@ int SDL_InitAudio(const char *driver_name)
|
||||||
if (bootstrap[i]->init(¤t_audio.impl)) {
|
if (bootstrap[i]->init(¤t_audio.impl)) {
|
||||||
current_audio.name = bootstrap[i]->name;
|
current_audio.name = bootstrap[i]->name;
|
||||||
current_audio.desc = bootstrap[i]->desc;
|
current_audio.desc = bootstrap[i]->desc;
|
||||||
initialized = SDL_TRUE;
|
initialized = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -958,7 +958,7 @@ int SDL_InitAudio(const char *driver_name)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tried_to_init = SDL_TRUE;
|
tried_to_init = true;
|
||||||
SDL_zero(current_audio);
|
SDL_zero(current_audio);
|
||||||
current_audio.pending_events_tail = ¤t_audio.pending_events;
|
current_audio.pending_events_tail = ¤t_audio.pending_events;
|
||||||
current_audio.device_hash_lock = device_hash_lock;
|
current_audio.device_hash_lock = device_hash_lock;
|
||||||
|
@ -966,7 +966,7 @@ int SDL_InitAudio(const char *driver_name)
|
||||||
if (bootstrap[i]->init(¤t_audio.impl)) {
|
if (bootstrap[i]->init(¤t_audio.impl)) {
|
||||||
current_audio.name = bootstrap[i]->name;
|
current_audio.name = bootstrap[i]->name;
|
||||||
current_audio.desc = bootstrap[i]->desc;
|
current_audio.desc = bootstrap[i]->desc;
|
||||||
initialized = SDL_TRUE;
|
initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -996,11 +996,11 @@ int SDL_InitAudio(const char *driver_name)
|
||||||
|
|
||||||
// If no default was _ever_ specified, just take the first device we see, if any.
|
// If no default was _ever_ specified, just take the first device we see, if any.
|
||||||
if (!default_playback) {
|
if (!default_playback) {
|
||||||
default_playback = GetFirstAddedAudioDevice(/*recording=*/SDL_FALSE);
|
default_playback = GetFirstAddedAudioDevice(/*recording=*/false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!default_recording) {
|
if (!default_recording) {
|
||||||
default_recording = GetFirstAddedAudioDevice(/*recording=*/SDL_TRUE);
|
default_recording = GetFirstAddedAudioDevice(/*recording=*/true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (default_playback) {
|
if (default_playback) {
|
||||||
|
@ -1051,7 +1051,7 @@ void SDL_QuitAudio(void)
|
||||||
while (SDL_IterateHashTable(device_hash, &key, &value, &iter)) {
|
while (SDL_IterateHashTable(device_hash, &key, &value, &iter)) {
|
||||||
// bit #1 of devid is set for physical devices and unset for logical.
|
// bit #1 of devid is set for physical devices and unset for logical.
|
||||||
const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
|
const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
|
||||||
const SDL_bool isphysical = (devid & (1<<1));
|
const bool isphysical = (devid & (1<<1));
|
||||||
if (isphysical) {
|
if (isphysical) {
|
||||||
DestroyPhysicalAudioDevice((SDL_AudioDevice *) value);
|
DestroyPhysicalAudioDevice((SDL_AudioDevice *) value);
|
||||||
}
|
}
|
||||||
|
@ -1087,7 +1087,7 @@ void SDL_PlaybackAudioThreadSetup(SDL_AudioDevice *device)
|
||||||
current_audio.impl.ThreadInit(device);
|
current_audio.impl.ThreadInit(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
|
bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
SDL_assert(!device->recording);
|
SDL_assert(!device->recording);
|
||||||
|
|
||||||
|
@ -1095,16 +1095,16 @@ SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
|
||||||
|
|
||||||
if (SDL_AtomicGet(&device->shutdown)) {
|
if (SDL_AtomicGet(&device->shutdown)) {
|
||||||
SDL_UnlockMutex(device->lock);
|
SDL_UnlockMutex(device->lock);
|
||||||
return SDL_FALSE; // we're done, shut it down.
|
return false; // we're done, shut it down.
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool failed = SDL_FALSE;
|
bool failed = false;
|
||||||
int buffer_size = device->buffer_size;
|
int buffer_size = device->buffer_size;
|
||||||
Uint8 *device_buffer = device->GetDeviceBuf(device, &buffer_size);
|
Uint8 *device_buffer = device->GetDeviceBuf(device, &buffer_size);
|
||||||
if (buffer_size == 0) {
|
if (buffer_size == 0) {
|
||||||
// WASAPI (maybe others, later) does this to say "just abandon this iteration and try again next time."
|
// WASAPI (maybe others, later) does this to say "just abandon this iteration and try again next time."
|
||||||
} else if (!device_buffer) {
|
} else if (!device_buffer) {
|
||||||
failed = SDL_TRUE;
|
failed = true;
|
||||||
} else {
|
} else {
|
||||||
SDL_assert(buffer_size <= device->buffer_size); // you can ask for less, but not more.
|
SDL_assert(buffer_size <= device->buffer_size); // you can ask for less, but not more.
|
||||||
SDL_assert(AudioDeviceCanUseSimpleCopy(device) == device->simple_copy); // make sure this hasn't gotten out of sync.
|
SDL_assert(AudioDeviceCanUseSimpleCopy(device) == device->simple_copy); // make sure this hasn't gotten out of sync.
|
||||||
|
@ -1119,7 +1119,7 @@ SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
|
||||||
|
|
||||||
const int br = SDL_AtomicGet(&logdev->paused) ? 0 : SDL_GetAudioStreamDataAdjustGain(stream, device_buffer, buffer_size, logdev->gain);
|
const int br = SDL_AtomicGet(&logdev->paused) ? 0 : SDL_GetAudioStreamDataAdjustGain(stream, device_buffer, buffer_size, logdev->gain);
|
||||||
if (br < 0) { // Probably OOM. Kill the audio device; the whole thing is likely dying soon anyhow.
|
if (br < 0) { // Probably OOM. Kill the audio device; the whole thing is likely dying soon anyhow.
|
||||||
failed = SDL_TRUE;
|
failed = true;
|
||||||
SDL_memset(device_buffer, device->silence_value, buffer_size); // just supply silence to the device before we die.
|
SDL_memset(device_buffer, device->silence_value, buffer_size); // just supply silence to the device before we die.
|
||||||
} else if (br < buffer_size) {
|
} else if (br < buffer_size) {
|
||||||
SDL_memset(device_buffer + br, device->silence_value, buffer_size - br); // silence whatever we didn't write to.
|
SDL_memset(device_buffer + br, device->silence_value, buffer_size - br); // silence whatever we didn't write to.
|
||||||
|
@ -1159,7 +1159,7 @@ SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
|
||||||
the same stream to different devices at the same time, though.) */
|
the same stream to different devices at the same time, though.) */
|
||||||
const int br = SDL_GetAudioStreamDataAdjustGain(stream, device->work_buffer, work_buffer_size, logdev->gain);
|
const int br = SDL_GetAudioStreamDataAdjustGain(stream, device->work_buffer, work_buffer_size, logdev->gain);
|
||||||
if (br < 0) { // Probably OOM. Kill the audio device; the whole thing is likely dying soon anyhow.
|
if (br < 0) { // Probably OOM. Kill the audio device; the whole thing is likely dying soon anyhow.
|
||||||
failed = SDL_TRUE;
|
failed = true;
|
||||||
break;
|
break;
|
||||||
} else if (br > 0) { // it's okay if we get less than requested, we mix what we have.
|
} else if (br > 0) { // it's okay if we get less than requested, we mix what we have.
|
||||||
MixFloat32Audio(mix_buffer, (float *) device->work_buffer, br);
|
MixFloat32Audio(mix_buffer, (float *) device->work_buffer, br);
|
||||||
|
@ -1183,7 +1183,7 @@ SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
|
||||||
|
|
||||||
// PlayDevice SHOULD NOT BLOCK, as we are holding a lock right now. Block in WaitDevice instead!
|
// 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) < 0) {
|
||||||
failed = SDL_TRUE;
|
failed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1193,7 +1193,7 @@ SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
|
||||||
SDL_AudioDeviceDisconnected(device); // doh.
|
SDL_AudioDeviceDisconnected(device); // doh.
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE; // always go on if not shutting down, even if device failed.
|
return true; // always go on if not shutting down, even if device failed.
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_PlaybackAudioThreadShutdown(SDL_AudioDevice *device)
|
void SDL_PlaybackAudioThreadShutdown(SDL_AudioDevice *device)
|
||||||
|
@ -1235,7 +1235,7 @@ void SDL_RecordingAudioThreadSetup(SDL_AudioDevice *device)
|
||||||
current_audio.impl.ThreadInit(device);
|
current_audio.impl.ThreadInit(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device)
|
bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
SDL_assert(device->recording);
|
SDL_assert(device->recording);
|
||||||
|
|
||||||
|
@ -1243,10 +1243,10 @@ SDL_bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device)
|
||||||
|
|
||||||
if (SDL_AtomicGet(&device->shutdown)) {
|
if (SDL_AtomicGet(&device->shutdown)) {
|
||||||
SDL_UnlockMutex(device->lock);
|
SDL_UnlockMutex(device->lock);
|
||||||
return SDL_FALSE; // we're done, shut it down.
|
return false; // we're done, shut it down.
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool failed = SDL_FALSE;
|
bool failed = false;
|
||||||
|
|
||||||
if (!device->logical_devices) {
|
if (!device->logical_devices) {
|
||||||
device->FlushRecording(device); // nothing wants data, dump anything pending.
|
device->FlushRecording(device); // nothing wants data, dump anything pending.
|
||||||
|
@ -1254,7 +1254,7 @@ SDL_bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device)
|
||||||
// this SHOULD NOT BLOCK, as we are holding a lock right now. Block in WaitRecordingDevice!
|
// this SHOULD NOT BLOCK, as we are holding a lock right now. Block in WaitRecordingDevice!
|
||||||
int br = device->RecordDevice(device, device->work_buffer, device->buffer_size);
|
int br = device->RecordDevice(device, device->work_buffer, device->buffer_size);
|
||||||
if (br < 0) { // uhoh, device failed for some reason!
|
if (br < 0) { // uhoh, device failed for some reason!
|
||||||
failed = SDL_TRUE;
|
failed = true;
|
||||||
} else if (br > 0) { // queue the new data to each bound stream.
|
} else if (br > 0) { // queue the new data to each bound stream.
|
||||||
for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev; logdev = logdev->next) {
|
for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev; logdev = logdev->next) {
|
||||||
if (SDL_AtomicGet(&logdev->paused)) {
|
if (SDL_AtomicGet(&logdev->paused)) {
|
||||||
|
@ -1290,7 +1290,7 @@ SDL_bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device)
|
||||||
the same stream to different devices at the same time, though.) */
|
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) < 0) {
|
||||||
// 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.
|
// 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 = SDL_TRUE;
|
failed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1304,7 +1304,7 @@ SDL_bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device)
|
||||||
SDL_AudioDeviceDisconnected(device); // doh.
|
SDL_AudioDeviceDisconnected(device); // doh.
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE; // always go on if not shutting down, even if device failed.
|
return true; // always go on if not shutting down, even if device failed.
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_RecordingAudioThreadShutdown(SDL_AudioDevice *device)
|
void SDL_RecordingAudioThreadShutdown(SDL_AudioDevice *device)
|
||||||
|
@ -1333,7 +1333,7 @@ static int SDLCALL RecordingAudioThread(void *devicep) // thread entry point
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static SDL_AudioDeviceID *GetAudioDevices(int *count, SDL_bool recording)
|
static SDL_AudioDeviceID *GetAudioDevices(int *count, bool recording)
|
||||||
{
|
{
|
||||||
SDL_AudioDeviceID *retval = NULL;
|
SDL_AudioDeviceID *retval = NULL;
|
||||||
int num_devices = 0;
|
int num_devices = 0;
|
||||||
|
@ -1352,8 +1352,8 @@ static SDL_AudioDeviceID *GetAudioDevices(int *count, SDL_bool recording)
|
||||||
const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
|
const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
|
||||||
// bit #0 of devid is set for playback devices and unset for recording.
|
// bit #0 of devid is set for playback devices and unset for recording.
|
||||||
// bit #1 of devid is set for physical devices and unset for logical.
|
// bit #1 of devid is set for physical devices and unset for logical.
|
||||||
const SDL_bool devid_recording = !(devid & (1<<0));
|
const bool devid_recording = !(devid & (1<<0));
|
||||||
const SDL_bool isphysical = (devid & (1<<1));
|
const bool isphysical = (devid & (1<<1));
|
||||||
if (isphysical && (devid_recording == recording)) {
|
if (isphysical && (devid_recording == recording)) {
|
||||||
SDL_assert(devs_seen < num_devices);
|
SDL_assert(devs_seen < num_devices);
|
||||||
retval[devs_seen++] = devid;
|
retval[devs_seen++] = devid;
|
||||||
|
@ -1381,16 +1381,16 @@ static SDL_AudioDeviceID *GetAudioDevices(int *count, SDL_bool recording)
|
||||||
|
|
||||||
SDL_AudioDeviceID *SDL_GetAudioPlaybackDevices(int *count)
|
SDL_AudioDeviceID *SDL_GetAudioPlaybackDevices(int *count)
|
||||||
{
|
{
|
||||||
return GetAudioDevices(count, SDL_FALSE);
|
return GetAudioDevices(count, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_AudioDeviceID *SDL_GetAudioRecordingDevices(int *count)
|
SDL_AudioDeviceID *SDL_GetAudioRecordingDevices(int *count)
|
||||||
{
|
{
|
||||||
return GetAudioDevices(count, SDL_TRUE);
|
return GetAudioDevices(count, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByCallback(SDL_bool (*callback)(SDL_AudioDevice *device, void *userdata), void *userdata)
|
SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByCallback(bool (*callback)(SDL_AudioDevice *device, void *userdata), void *userdata)
|
||||||
{
|
{
|
||||||
if (!SDL_GetCurrentAudioDriver()) {
|
if (!SDL_GetCurrentAudioDriver()) {
|
||||||
SDL_SetError("Audio subsystem is not initialized");
|
SDL_SetError("Audio subsystem is not initialized");
|
||||||
|
@ -1405,7 +1405,7 @@ SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByCallback(SDL_bool (*callback)(SDL_
|
||||||
while (SDL_IterateHashTable(current_audio.device_hash, &key, &value, &iter)) {
|
while (SDL_IterateHashTable(current_audio.device_hash, &key, &value, &iter)) {
|
||||||
const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
|
const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
|
||||||
// bit #1 of devid is set for physical devices and unset for logical.
|
// bit #1 of devid is set for physical devices and unset for logical.
|
||||||
const SDL_bool isphysical = (devid & (1<<1));
|
const bool isphysical = (devid & (1<<1));
|
||||||
if (isphysical) {
|
if (isphysical) {
|
||||||
SDL_AudioDevice *device = (SDL_AudioDevice *) value;
|
SDL_AudioDevice *device = (SDL_AudioDevice *) value;
|
||||||
if (callback(device, userdata)) { // found it?
|
if (callback(device, userdata)) { // found it?
|
||||||
|
@ -1420,7 +1420,7 @@ SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByCallback(SDL_bool (*callback)(SDL_
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool TestDeviceHandleCallback(SDL_AudioDevice *device, void *handle)
|
static bool TestDeviceHandleCallback(SDL_AudioDevice *device, void *handle)
|
||||||
{
|
{
|
||||||
return device->handle == handle;
|
return device->handle == handle;
|
||||||
}
|
}
|
||||||
|
@ -1511,7 +1511,7 @@ static void ClosePhysicalAudioDevice(SDL_AudioDevice *device)
|
||||||
|
|
||||||
if (device->currently_opened) {
|
if (device->currently_opened) {
|
||||||
current_audio.impl.CloseDevice(device); // if ProvidesOwnCallbackThread, this must join on any existing device thread before returning!
|
current_audio.impl.CloseDevice(device); // if ProvidesOwnCallbackThread, this must join on any existing device thread before returning!
|
||||||
device->currently_opened = SDL_FALSE;
|
device->currently_opened = false;
|
||||||
device->hidden = NULL; // just in case.
|
device->hidden = NULL; // just in case.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1572,7 +1572,7 @@ static SDL_AudioFormat ParseAudioFormatString(const char *string)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrepareAudioFormat(SDL_bool recording, SDL_AudioSpec *spec)
|
static void PrepareAudioFormat(bool recording, SDL_AudioSpec *spec)
|
||||||
{
|
{
|
||||||
if (spec->freq == 0) {
|
if (spec->freq == 0) {
|
||||||
spec->freq = recording ? DEFAULT_AUDIO_RECORDING_FREQUENCY : DEFAULT_AUDIO_PLAYBACK_FREQUENCY;
|
spec->freq = recording ? DEFAULT_AUDIO_RECORDING_FREQUENCY : DEFAULT_AUDIO_PLAYBACK_FREQUENCY;
|
||||||
|
@ -1655,7 +1655,7 @@ static int OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec
|
||||||
device->sample_frames = GetDefaultSampleFramesFromFreq(device->spec.freq);
|
device->sample_frames = GetDefaultSampleFramesFromFreq(device->spec.freq);
|
||||||
SDL_UpdatedAudioDeviceFormat(device); // start this off sane.
|
SDL_UpdatedAudioDeviceFormat(device); // start this off sane.
|
||||||
|
|
||||||
device->currently_opened = SDL_TRUE; // mark this true even if impl.OpenDevice fails, so we know to clean up.
|
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) < 0) {
|
||||||
ClosePhysicalAudioDevice(device); // clean up anything the backend left half-initialized.
|
ClosePhysicalAudioDevice(device); // clean up anything the backend left half-initialized.
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1700,11 +1700,11 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) || (devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING));
|
bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) || (devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING));
|
||||||
|
|
||||||
// this will let you use a logical device to make a new logical device on the parent physical device. Could be useful?
|
// this will let you use a logical device to make a new logical device on the parent physical device. Could be useful?
|
||||||
SDL_AudioDevice *device = NULL;
|
SDL_AudioDevice *device = NULL;
|
||||||
const SDL_bool islogical = (!wants_default && !(devid & (1<<1)));
|
const bool islogical = (!wants_default && !(devid & (1<<1)));
|
||||||
if (!islogical) {
|
if (!islogical) {
|
||||||
device = ObtainPhysicalAudioDeviceDefaultAllowed(devid);
|
device = ObtainPhysicalAudioDeviceDefaultAllowed(devid);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1728,7 +1728,7 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
|
||||||
} else {
|
} else {
|
||||||
RefPhysicalAudioDevice(device); // unref'd on successful SDL_CloseAudioDevice
|
RefPhysicalAudioDevice(device); // unref'd on successful SDL_CloseAudioDevice
|
||||||
SDL_AtomicSet(&logdev->paused, 0);
|
SDL_AtomicSet(&logdev->paused, 0);
|
||||||
retval = logdev->instance_id = AssignAudioDeviceInstanceId(device->recording, /*islogical=*/SDL_TRUE);
|
retval = logdev->instance_id = AssignAudioDeviceInstanceId(device->recording, /*islogical=*/true);
|
||||||
logdev->physical_device = device;
|
logdev->physical_device = device;
|
||||||
logdev->gain = 1.0f;
|
logdev->gain = 1.0f;
|
||||||
logdev->opened_as_default = wants_default;
|
logdev->opened_as_default = wants_default;
|
||||||
|
@ -1743,7 +1743,7 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
|
||||||
|
|
||||||
if (retval) {
|
if (retval) {
|
||||||
SDL_LockRWLockForWriting(current_audio.device_hash_lock);
|
SDL_LockRWLockForWriting(current_audio.device_hash_lock);
|
||||||
const SDL_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) retval, logdev);
|
||||||
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
||||||
if (!inserted) {
|
if (!inserted) {
|
||||||
SDL_CloseAudioDevice(retval);
|
SDL_CloseAudioDevice(retval);
|
||||||
|
@ -1780,9 +1780,9 @@ SDL_bool SDL_AudioDevicePaused(SDL_AudioDeviceID devid)
|
||||||
{
|
{
|
||||||
SDL_AudioDevice *device = NULL;
|
SDL_AudioDevice *device = NULL;
|
||||||
SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(devid, &device);
|
SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(devid, &device);
|
||||||
SDL_bool retval = SDL_FALSE;
|
bool retval = false;
|
||||||
if (logdev && SDL_AtomicGet(&logdev->paused)) {
|
if (logdev && SDL_AtomicGet(&logdev->paused)) {
|
||||||
retval = SDL_TRUE;
|
retval = true;
|
||||||
}
|
}
|
||||||
ReleaseAudioDevice(device);
|
ReleaseAudioDevice(device);
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -1809,7 +1809,7 @@ int SDL_SetAudioDeviceGain(SDL_AudioDeviceID devid, float gain)
|
||||||
if (logdev) {
|
if (logdev) {
|
||||||
logdev->gain = gain;
|
logdev->gain = gain;
|
||||||
if (device->recording) {
|
if (device->recording) {
|
||||||
const SDL_bool need_float32 = (logdev->postmix || logdev->gain != 1.0f);
|
const bool need_float32 = (logdev->postmix || logdev->gain != 1.0f);
|
||||||
for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) {
|
for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) {
|
||||||
// set the proper end of the stream to the device's format.
|
// set the proper end of the stream to the device's format.
|
||||||
// SDL_SetAudioStreamFormat does a ton of validation just to memcpy an audiospec.
|
// SDL_SetAudioStreamFormat does a ton of validation just to memcpy an audiospec.
|
||||||
|
@ -1844,7 +1844,7 @@ int SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallbac
|
||||||
logdev->postmix_userdata = userdata;
|
logdev->postmix_userdata = userdata;
|
||||||
|
|
||||||
if (device->recording) {
|
if (device->recording) {
|
||||||
const SDL_bool need_float32 = (callback || logdev->gain != 1.0f);
|
const bool need_float32 = (callback || logdev->gain != 1.0f);
|
||||||
for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) {
|
for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) {
|
||||||
// set the proper end of the stream to the device's format.
|
// set the proper end of the stream to the device's format.
|
||||||
// SDL_SetAudioStreamFormat does a ton of validation just to memcpy an audiospec.
|
// SDL_SetAudioStreamFormat does a ton of validation just to memcpy an audiospec.
|
||||||
|
@ -1863,7 +1863,7 @@ int SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallbac
|
||||||
|
|
||||||
int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int num_streams)
|
int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int num_streams)
|
||||||
{
|
{
|
||||||
const SDL_bool islogical = !(devid & (1<<1));
|
const bool islogical = !(devid & (1<<1));
|
||||||
SDL_AudioDevice *device = NULL;
|
SDL_AudioDevice *device = NULL;
|
||||||
SDL_LogicalAudioDevice *logdev = NULL;
|
SDL_LogicalAudioDevice *logdev = NULL;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
@ -1922,7 +1922,7 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
|
||||||
|
|
||||||
if (retval == 0) {
|
if (retval == 0) {
|
||||||
// Now that everything is verified, chain everything together.
|
// Now that everything is verified, chain everything together.
|
||||||
const SDL_bool recording = device->recording;
|
const bool recording = device->recording;
|
||||||
for (int i = 0; i < num_streams; i++) {
|
for (int i = 0; i < num_streams; i++) {
|
||||||
SDL_AudioStream *stream = streams[i];
|
SDL_AudioStream *stream = streams[i];
|
||||||
if (stream) { // shouldn't be NULL, but just in case...
|
if (stream) { // shouldn't be NULL, but just in case...
|
||||||
|
@ -1971,7 +1971,7 @@ void SDL_UnbindAudioStreams(SDL_AudioStream **streams, int num_streams)
|
||||||
continue; // nothing to do, it's a NULL stream.
|
continue; // nothing to do, it's a NULL stream.
|
||||||
}
|
}
|
||||||
|
|
||||||
while (SDL_TRUE) {
|
while (true) {
|
||||||
SDL_LockMutex(stream->lock); // lock to check this and then release it, in case the device isn't locked yet.
|
SDL_LockMutex(stream->lock); // lock to check this and then release it, in case the device isn't locked yet.
|
||||||
SDL_LogicalAudioDevice *bounddev = stream->bound_device;
|
SDL_LogicalAudioDevice *bounddev = stream->bound_device;
|
||||||
SDL_UnlockMutex(stream->lock);
|
SDL_UnlockMutex(stream->lock);
|
||||||
|
@ -2059,17 +2059,17 @@ SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_Au
|
||||||
return NULL; // error string should already be set.
|
return NULL; // error string should already be set.
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool failed = SDL_FALSE;
|
bool failed = false;
|
||||||
SDL_AudioStream *stream = NULL;
|
SDL_AudioStream *stream = NULL;
|
||||||
SDL_AudioDevice *device = NULL;
|
SDL_AudioDevice *device = NULL;
|
||||||
SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(logdevid, &device);
|
SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(logdevid, &device);
|
||||||
if (!logdev) { // this shouldn't happen, but just in case.
|
if (!logdev) { // this shouldn't happen, but just in case.
|
||||||
failed = SDL_TRUE;
|
failed = true;
|
||||||
} else {
|
} else {
|
||||||
SDL_AtomicSet(&logdev->paused, 1); // start the device paused, to match SDL2.
|
SDL_AtomicSet(&logdev->paused, 1); // start the device paused, to match SDL2.
|
||||||
|
|
||||||
SDL_assert(device != NULL);
|
SDL_assert(device != NULL);
|
||||||
const SDL_bool recording = device->recording;
|
const bool recording = device->recording;
|
||||||
|
|
||||||
// if the app didn't request a format _at all_, just make a stream that does no conversion; they can query for it later.
|
// if the app didn't request a format _at all_, just make a stream that does no conversion; they can query for it later.
|
||||||
SDL_AudioSpec tmpspec;
|
SDL_AudioSpec tmpspec;
|
||||||
|
@ -2085,14 +2085,14 @@ SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_Au
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stream) {
|
if (!stream) {
|
||||||
failed = SDL_TRUE;
|
failed = true;
|
||||||
} else {
|
} else {
|
||||||
// don't do all the complicated validation and locking of SDL_BindAudioStream just to set a few fields here.
|
// don't do all the complicated validation and locking of SDL_BindAudioStream just to set a few fields here.
|
||||||
logdev->bound_streams = stream;
|
logdev->bound_streams = stream;
|
||||||
logdev->simplified = SDL_TRUE; // forbid further binding changes on this logical device.
|
logdev->simplified = true; // forbid further binding changes on this logical device.
|
||||||
|
|
||||||
stream->bound_device = logdev;
|
stream->bound_device = logdev;
|
||||||
stream->simplified = SDL_TRUE; // so we know to close the audio device when this is destroyed.
|
stream->simplified = true; // so we know to close the audio device when this is destroyed.
|
||||||
|
|
||||||
UpdateAudioStreamFormatsPhysical(device);
|
UpdateAudioStreamFormatsPhysical(device);
|
||||||
|
|
||||||
|
@ -2204,12 +2204,12 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device)
|
||||||
return; // uhoh.
|
return; // uhoh.
|
||||||
}
|
}
|
||||||
|
|
||||||
const SDL_bool recording = new_default_device->recording;
|
const bool recording = new_default_device->recording;
|
||||||
|
|
||||||
// change the official default over right away, so new opens will go to the new device.
|
// change the official default over right away, so new opens will go to the new device.
|
||||||
SDL_LockRWLockForWriting(current_audio.device_hash_lock);
|
SDL_LockRWLockForWriting(current_audio.device_hash_lock);
|
||||||
const SDL_AudioDeviceID current_devid = recording ? current_audio.default_recording_device_id : current_audio.default_playback_device_id;
|
const SDL_AudioDeviceID current_devid = recording ? current_audio.default_recording_device_id : current_audio.default_playback_device_id;
|
||||||
const SDL_bool is_already_default = (new_default_device->instance_id == current_devid);
|
const bool is_already_default = (new_default_device->instance_id == current_devid);
|
||||||
if (!is_already_default) {
|
if (!is_already_default) {
|
||||||
if (recording) {
|
if (recording) {
|
||||||
current_audio.default_recording_device_id = new_default_device->instance_id;
|
current_audio.default_recording_device_id = new_default_device->instance_id;
|
||||||
|
@ -2244,12 +2244,12 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device)
|
||||||
|
|
||||||
// See if we have to open the new physical device, and if so, find the best audiospec for it.
|
// See if we have to open the new physical device, and if so, find the best audiospec for it.
|
||||||
SDL_AudioSpec spec;
|
SDL_AudioSpec spec;
|
||||||
SDL_bool needs_migration = SDL_FALSE;
|
bool needs_migration = false;
|
||||||
SDL_zero(spec);
|
SDL_zero(spec);
|
||||||
|
|
||||||
for (SDL_LogicalAudioDevice *logdev = current_default_device->logical_devices; logdev; logdev = logdev->next) {
|
for (SDL_LogicalAudioDevice *logdev = current_default_device->logical_devices; logdev; logdev = logdev->next) {
|
||||||
if (logdev->opened_as_default) {
|
if (logdev->opened_as_default) {
|
||||||
needs_migration = SDL_TRUE;
|
needs_migration = true;
|
||||||
for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) {
|
for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) {
|
||||||
const SDL_AudioSpec *streamspec = recording ? &stream->dst_spec : &stream->src_spec;
|
const SDL_AudioSpec *streamspec = recording ? &stream->dst_spec : &stream->src_spec;
|
||||||
if (SDL_AUDIO_BITSIZE(streamspec->format) > SDL_AUDIO_BITSIZE(spec.format)) {
|
if (SDL_AUDIO_BITSIZE(streamspec->format) > SDL_AUDIO_BITSIZE(spec.format)) {
|
||||||
|
@ -2268,13 +2268,13 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device)
|
||||||
if (needs_migration) {
|
if (needs_migration) {
|
||||||
// New default physical device not been opened yet? Open at the OS level...
|
// 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) < 0) {
|
||||||
needs_migration = SDL_FALSE; // uhoh, just leave everything on the old default, nothing to be done.
|
needs_migration = false; // uhoh, just leave everything on the old default, nothing to be done.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needs_migration) {
|
if (needs_migration) {
|
||||||
// we don't currently report channel map changes, so we'll leave them as NULL for now.
|
// we don't currently report channel map changes, so we'll leave them as NULL for now.
|
||||||
const SDL_bool spec_changed = !SDL_AudioSpecsEqual(¤t_default_device->spec, &new_default_device->spec, NULL, NULL);
|
const bool spec_changed = !SDL_AudioSpecsEqual(¤t_default_device->spec, &new_default_device->spec, NULL, NULL);
|
||||||
SDL_LogicalAudioDevice *next = NULL;
|
SDL_LogicalAudioDevice *next = NULL;
|
||||||
for (SDL_LogicalAudioDevice *logdev = current_default_device->logical_devices; logdev; logdev = next) {
|
for (SDL_LogicalAudioDevice *logdev = current_default_device->logical_devices; logdev; logdev = next) {
|
||||||
next = logdev->next;
|
next = logdev->next;
|
||||||
|
@ -2362,7 +2362,7 @@ int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL
|
||||||
SDL_copyp(&device->spec, newspec);
|
SDL_copyp(&device->spec, newspec);
|
||||||
UpdateAudioStreamFormatsPhysical(device);
|
UpdateAudioStreamFormatsPhysical(device);
|
||||||
|
|
||||||
SDL_bool kill_device = SDL_FALSE;
|
bool kill_device = false;
|
||||||
|
|
||||||
device->sample_frames = new_sample_frames;
|
device->sample_frames = new_sample_frames;
|
||||||
SDL_UpdatedAudioDeviceFormat(device);
|
SDL_UpdatedAudioDeviceFormat(device);
|
||||||
|
@ -2370,14 +2370,14 @@ int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL
|
||||||
SDL_aligned_free(device->work_buffer);
|
SDL_aligned_free(device->work_buffer);
|
||||||
device->work_buffer = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size);
|
device->work_buffer = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size);
|
||||||
if (!device->work_buffer) {
|
if (!device->work_buffer) {
|
||||||
kill_device = SDL_TRUE;
|
kill_device = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->postmix_buffer) {
|
if (device->postmix_buffer) {
|
||||||
SDL_aligned_free(device->postmix_buffer);
|
SDL_aligned_free(device->postmix_buffer);
|
||||||
device->postmix_buffer = (float *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size);
|
device->postmix_buffer = (float *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size);
|
||||||
if (!device->postmix_buffer) {
|
if (!device->postmix_buffer) {
|
||||||
kill_device = SDL_TRUE;
|
kill_device = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2386,7 +2386,7 @@ int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL
|
||||||
if (device->spec.format != SDL_AUDIO_F32) {
|
if (device->spec.format != SDL_AUDIO_F32) {
|
||||||
device->mix_buffer = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size);
|
device->mix_buffer = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size);
|
||||||
if (!device->mix_buffer) {
|
if (!device->mix_buffer) {
|
||||||
kill_device = SDL_TRUE;
|
kill_device = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ static void SDL_TARGETING("sse") SDL_ConvertMonoToStereo_SSE(float *dst, const f
|
||||||
// Include the autogenerated channel converters...
|
// Include the autogenerated channel converters...
|
||||||
#include "SDL_audio_channel_converters.h"
|
#include "SDL_audio_channel_converters.h"
|
||||||
|
|
||||||
static SDL_bool SDL_IsSupportedAudioFormat(const SDL_AudioFormat fmt)
|
static bool SDL_IsSupportedAudioFormat(const SDL_AudioFormat fmt)
|
||||||
{
|
{
|
||||||
switch (fmt) {
|
switch (fmt) {
|
||||||
case SDL_AUDIO_U8:
|
case SDL_AUDIO_U8:
|
||||||
|
@ -110,43 +110,43 @@ static SDL_bool SDL_IsSupportedAudioFormat(const SDL_AudioFormat fmt)
|
||||||
case SDL_AUDIO_S32BE:
|
case SDL_AUDIO_S32BE:
|
||||||
case SDL_AUDIO_F32LE:
|
case SDL_AUDIO_F32LE:
|
||||||
case SDL_AUDIO_F32BE:
|
case SDL_AUDIO_F32BE:
|
||||||
return SDL_TRUE; // supported.
|
return true; // supported.
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_FALSE; // unsupported.
|
return false; // unsupported.
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SDL_IsSupportedChannelCount(const int channels)
|
static bool SDL_IsSupportedChannelCount(const int channels)
|
||||||
{
|
{
|
||||||
return ((channels >= 1) && (channels <= 8));
|
return ((channels >= 1) && (channels <= 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_ChannelMapIsBogus(const int *chmap, int channels)
|
bool SDL_ChannelMapIsBogus(const int *chmap, int channels)
|
||||||
{
|
{
|
||||||
if (chmap) {
|
if (chmap) {
|
||||||
for (int i = 0; i < channels; i++) {
|
for (int i = 0; i < channels; i++) {
|
||||||
const int mapping = chmap[i];
|
const int mapping = chmap[i];
|
||||||
if ((mapping < 0) || (mapping >= channels)) {
|
if ((mapping < 0) || (mapping >= channels)) {
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_ChannelMapIsDefault(const int *chmap, int channels)
|
bool SDL_ChannelMapIsDefault(const int *chmap, int channels)
|
||||||
{
|
{
|
||||||
if (chmap) {
|
if (chmap) {
|
||||||
for (int i = 0; i < channels; i++) {
|
for (int i = 0; i < channels; i++) {
|
||||||
if (chmap[i] != i) {
|
if (chmap[i] != i) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Swizzle audio channels. src and dst can be the same pointer. It does not change the buffer size.
|
// Swizzle audio channels. src and dst can be the same pointer. It does not change the buffer size.
|
||||||
|
@ -162,7 +162,7 @@ static void SwizzleAudio(const int num_frames, void *dst, const void *src, int c
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} else { \
|
} else { \
|
||||||
SDL_bool isstack; \
|
bool isstack; \
|
||||||
Uint##bits *tmp = (Uint##bits *) SDL_small_alloc(int, channels, &isstack); /* !!! FIXME: allocate this when setting the channel map instead. */ \
|
Uint##bits *tmp = (Uint##bits *) SDL_small_alloc(int, channels, &isstack); /* !!! FIXME: allocate this when setting the channel map instead. */ \
|
||||||
if (tmp) { \
|
if (tmp) { \
|
||||||
for (int i = 0; i < num_frames; i++, tsrc += channels, tdst += channels) { \
|
for (int i = 0; i < num_frames; i++, tsrc += channels, tdst += channels) { \
|
||||||
|
@ -276,9 +276,9 @@ void ConvertAudio(int num_frames,
|
||||||
scratch = dst;
|
scratch = dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SDL_bool srcconvert = src_format != SDL_AUDIO_F32;
|
const bool srcconvert = src_format != SDL_AUDIO_F32;
|
||||||
const SDL_bool channelconvert = src_channels != dst_channels;
|
const bool channelconvert = src_channels != dst_channels;
|
||||||
const SDL_bool dstconvert = dst_format != SDL_AUDIO_F32;
|
const bool dstconvert = dst_format != SDL_AUDIO_F32;
|
||||||
|
|
||||||
// get us to float format.
|
// get us to float format.
|
||||||
if (srcconvert) {
|
if (srcconvert) {
|
||||||
|
@ -628,12 +628,12 @@ int SetAudioStreamChannelMap(SDL_AudioStream *stream, const SDL_AudioSpec *spec,
|
||||||
|
|
||||||
int SDL_SetAudioStreamInputChannelMap(SDL_AudioStream *stream, const int *chmap, int channels)
|
int SDL_SetAudioStreamInputChannelMap(SDL_AudioStream *stream, const int *chmap, int channels)
|
||||||
{
|
{
|
||||||
return SetAudioStreamChannelMap(stream, &stream->src_spec, &stream->src_chmap, chmap, channels, SDL_TRUE);
|
return SetAudioStreamChannelMap(stream, &stream->src_spec, &stream->src_chmap, chmap, channels, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_SetAudioStreamOutputChannelMap(SDL_AudioStream *stream, const int *chmap, int channels)
|
int SDL_SetAudioStreamOutputChannelMap(SDL_AudioStream *stream, const int *chmap, int channels)
|
||||||
{
|
{
|
||||||
return SetAudioStreamChannelMap(stream, &stream->dst_spec, &stream->dst_chmap, chmap, channels, SDL_FALSE);
|
return SetAudioStreamChannelMap(stream, &stream->dst_spec, &stream->dst_chmap, chmap, channels, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int *SDL_GetAudioStreamInputChannelMap(SDL_AudioStream *stream, int *count)
|
int *SDL_GetAudioStreamInputChannelMap(SDL_AudioStream *stream, int *count)
|
||||||
|
@ -876,10 +876,10 @@ static Uint8 *EnsureAudioStreamWorkBufferSize(SDL_AudioStream *stream, size_t ne
|
||||||
}
|
}
|
||||||
|
|
||||||
static Sint64 NextAudioStreamIter(SDL_AudioStream* stream, void** inout_iter,
|
static Sint64 NextAudioStreamIter(SDL_AudioStream* stream, void** inout_iter,
|
||||||
Sint64* inout_resample_offset, SDL_AudioSpec* out_spec, int **out_chmap, SDL_bool* out_flushed)
|
Sint64* inout_resample_offset, SDL_AudioSpec* out_spec, int **out_chmap, bool* out_flushed)
|
||||||
{
|
{
|
||||||
SDL_AudioSpec spec;
|
SDL_AudioSpec spec;
|
||||||
SDL_bool flushed;
|
bool flushed;
|
||||||
int *chmap;
|
int *chmap;
|
||||||
size_t queued_bytes = SDL_NextAudioQueueIter(stream->queue, inout_iter, &spec, &chmap, &flushed);
|
size_t queued_bytes = SDL_NextAudioQueueIter(stream->queue, inout_iter, &spec, &chmap, &flushed);
|
||||||
|
|
||||||
|
@ -896,7 +896,7 @@ static Sint64 NextAudioStreamIter(SDL_AudioStream* stream, void** inout_iter,
|
||||||
*inout_resample_offset = 0;
|
*inout_resample_offset = 0;
|
||||||
|
|
||||||
if (out_flushed) {
|
if (out_flushed) {
|
||||||
*out_flushed = SDL_FALSE;
|
*out_flushed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_MAX_SINT32;
|
return SDL_MAX_SINT32;
|
||||||
|
@ -954,13 +954,13 @@ static Sint64 GetAudioStreamAvailableFrames(SDL_AudioStream* stream, Sint64* out
|
||||||
return output_frames;
|
return output_frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Sint64 GetAudioStreamHead(SDL_AudioStream* stream, SDL_AudioSpec* out_spec, int **out_chmap, SDL_bool* out_flushed)
|
static Sint64 GetAudioStreamHead(SDL_AudioStream* stream, SDL_AudioSpec* out_spec, int **out_chmap, bool* out_flushed)
|
||||||
{
|
{
|
||||||
void* iter = SDL_BeginAudioQueueIter(stream->queue);
|
void* iter = SDL_BeginAudioQueueIter(stream->queue);
|
||||||
|
|
||||||
if (!iter) {
|
if (!iter) {
|
||||||
SDL_zerop(out_spec);
|
SDL_zerop(out_spec);
|
||||||
*out_flushed = SDL_FALSE;
|
*out_flushed = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1161,7 +1161,7 @@ int SDL_GetAudioStreamDataAdjustGain(SDL_AudioStream *stream, void *voidbuf, int
|
||||||
// Audio is processed a track at a time.
|
// Audio is processed a track at a time.
|
||||||
SDL_AudioSpec input_spec;
|
SDL_AudioSpec input_spec;
|
||||||
int *input_chmap;
|
int *input_chmap;
|
||||||
SDL_bool flushed;
|
bool flushed;
|
||||||
const Sint64 available_frames = GetAudioStreamHead(stream, &input_spec, &input_chmap, &flushed);
|
const Sint64 available_frames = GetAudioStreamHead(stream, &input_spec, &input_chmap, &flushed);
|
||||||
|
|
||||||
if (available_frames == 0) {
|
if (available_frames == 0) {
|
||||||
|
@ -1278,7 +1278,7 @@ void SDL_DestroyAudioStream(SDL_AudioStream *stream)
|
||||||
|
|
||||||
OnAudioStreamDestroy(stream);
|
OnAudioStreamDestroy(stream);
|
||||||
|
|
||||||
const SDL_bool simplified = stream->simplified;
|
const bool simplified = stream->simplified;
|
||||||
if (simplified) {
|
if (simplified) {
|
||||||
if (stream->bound_device) {
|
if (stream->bound_device) {
|
||||||
SDL_assert(stream->bound_device->simplified);
|
SDL_assert(stream->bound_device->simplified);
|
||||||
|
|
|
@ -45,13 +45,13 @@
|
||||||
#define SDL_PATH_DEV_AUDIO "/dev/audio"
|
#define SDL_PATH_DEV_AUDIO "/dev/audio"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void test_device(const SDL_bool recording, const char *fname, int flags, SDL_bool (*test)(int fd))
|
static void test_device(const bool recording, const char *fname, int flags, bool (*test)(int fd))
|
||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
const int audio_fd = open(fname, flags | O_CLOEXEC, 0);
|
const int audio_fd = open(fname, flags | O_CLOEXEC, 0);
|
||||||
if (audio_fd >= 0) {
|
if (audio_fd >= 0) {
|
||||||
if ((fstat(audio_fd, &sb) == 0) && (S_ISCHR(sb.st_mode))) {
|
if ((fstat(audio_fd, &sb) == 0) && (S_ISCHR(sb.st_mode))) {
|
||||||
const SDL_bool okay = test(audio_fd);
|
const bool okay = test(audio_fd);
|
||||||
close(audio_fd);
|
close(audio_fd);
|
||||||
if (okay) {
|
if (okay) {
|
||||||
static size_t dummyhandle = 0;
|
static size_t dummyhandle = 0;
|
||||||
|
@ -71,12 +71,12 @@ static void test_device(const SDL_bool recording, const char *fname, int flags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool test_stub(int fd)
|
static bool test_stub(int fd)
|
||||||
{
|
{
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_EnumUnixAudioDevices_Internal(const SDL_bool recording, const SDL_bool classic, SDL_bool (*test)(int))
|
static void SDL_EnumUnixAudioDevices_Internal(const bool recording, const bool classic, bool (*test)(int))
|
||||||
{
|
{
|
||||||
const int flags = recording ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT;
|
const int flags = recording ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT;
|
||||||
const char *audiodev;
|
const char *audiodev;
|
||||||
|
@ -115,10 +115,10 @@ static void SDL_EnumUnixAudioDevices_Internal(const SDL_bool recording, const SD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_EnumUnixAudioDevices(const SDL_bool classic, SDL_bool (*test)(int))
|
void SDL_EnumUnixAudioDevices(const bool classic, bool (*test)(int))
|
||||||
{
|
{
|
||||||
SDL_EnumUnixAudioDevices_Internal(SDL_TRUE, classic, test);
|
SDL_EnumUnixAudioDevices_Internal(true, classic, test);
|
||||||
SDL_EnumUnixAudioDevices_Internal(SDL_FALSE, classic, test);
|
SDL_EnumUnixAudioDevices_Internal(false, classic, test);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // Audio device selection
|
#endif // Audio device selection
|
||||||
|
|
|
@ -36,6 +36,6 @@
|
||||||
#define OPEN_FLAGS_INPUT (O_RDONLY | O_NONBLOCK)
|
#define OPEN_FLAGS_INPUT (O_RDONLY | O_NONBLOCK)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void SDL_EnumUnixAudioDevices(const SDL_bool classic, SDL_bool (*test)(int));
|
extern void SDL_EnumUnixAudioDevices(const bool classic, bool (*test)(int));
|
||||||
|
|
||||||
#endif // SDL_audiodev_c_h_
|
#endif // SDL_audiodev_c_h_
|
||||||
|
|
|
@ -37,7 +37,7 @@ struct SDL_AudioTrack
|
||||||
{
|
{
|
||||||
SDL_AudioSpec spec;
|
SDL_AudioSpec spec;
|
||||||
int *chmap;
|
int *chmap;
|
||||||
SDL_bool flushed;
|
bool flushed;
|
||||||
SDL_AudioTrack *next;
|
SDL_AudioTrack *next;
|
||||||
|
|
||||||
void *userdata;
|
void *userdata;
|
||||||
|
@ -192,7 +192,7 @@ void SDL_ClearAudioQueue(SDL_AudioQueue *queue)
|
||||||
|
|
||||||
static void FlushAudioTrack(SDL_AudioTrack *track)
|
static void FlushAudioTrack(SDL_AudioTrack *track)
|
||||||
{
|
{
|
||||||
track->flushed = SDL_TRUE;
|
track->flushed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_FlushAudioQueue(SDL_AudioQueue *queue)
|
void SDL_FlushAudioQueue(SDL_AudioQueue *queue)
|
||||||
|
@ -209,7 +209,7 @@ void SDL_PopAudioQueueHead(SDL_AudioQueue *queue)
|
||||||
SDL_AudioTrack *track = queue->head;
|
SDL_AudioTrack *track = queue->head;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
SDL_bool flushed = track->flushed;
|
bool flushed = track->flushed;
|
||||||
|
|
||||||
SDL_AudioTrack *next = track->next;
|
SDL_AudioTrack *next = track->next;
|
||||||
DestroyAudioTrack(queue, track);
|
DestroyAudioTrack(queue, track);
|
||||||
|
@ -370,7 +370,7 @@ void *SDL_BeginAudioQueueIter(SDL_AudioQueue *queue)
|
||||||
return queue->head;
|
return queue->head;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SDL_NextAudioQueueIter(SDL_AudioQueue *queue, void **inout_iter, SDL_AudioSpec *out_spec, int **out_chmap, SDL_bool *out_flushed)
|
size_t SDL_NextAudioQueueIter(SDL_AudioQueue *queue, void **inout_iter, SDL_AudioSpec *out_spec, int **out_chmap, bool *out_flushed)
|
||||||
{
|
{
|
||||||
SDL_AudioTrack *iter = (SDL_AudioTrack *)(*inout_iter);
|
SDL_AudioTrack *iter = (SDL_AudioTrack *)(*inout_iter);
|
||||||
SDL_assert(iter != NULL);
|
SDL_assert(iter != NULL);
|
||||||
|
@ -378,7 +378,7 @@ size_t SDL_NextAudioQueueIter(SDL_AudioQueue *queue, void **inout_iter, SDL_Audi
|
||||||
SDL_copyp(out_spec, &iter->spec);
|
SDL_copyp(out_spec, &iter->spec);
|
||||||
*out_chmap = iter->chmap;
|
*out_chmap = iter->chmap;
|
||||||
|
|
||||||
SDL_bool flushed = SDL_FALSE;
|
bool flushed = false;
|
||||||
size_t queued_bytes = 0;
|
size_t queued_bytes = 0;
|
||||||
|
|
||||||
while (iter) {
|
while (iter) {
|
||||||
|
@ -389,7 +389,7 @@ size_t SDL_NextAudioQueueIter(SDL_AudioQueue *queue, void **inout_iter, SDL_Audi
|
||||||
|
|
||||||
if (avail >= SDL_SIZE_MAX - queued_bytes) {
|
if (avail >= SDL_SIZE_MAX - queued_bytes) {
|
||||||
queued_bytes = SDL_SIZE_MAX;
|
queued_bytes = SDL_SIZE_MAX;
|
||||||
flushed = SDL_FALSE;
|
flushed = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ const Uint8 *SDL_ReadFromAudioQueue(SDL_AudioQueue *queue,
|
||||||
size_t dst_present_bytes = present_frames * dst_frame_size;
|
size_t dst_present_bytes = present_frames * dst_frame_size;
|
||||||
size_t dst_future_bytes = future_frames * dst_frame_size;
|
size_t dst_future_bytes = future_frames * dst_frame_size;
|
||||||
|
|
||||||
SDL_bool convert = (src_format != dst_format) || (src_channels != dst_channels);
|
bool convert = (src_format != dst_format) || (src_channels != dst_channels);
|
||||||
|
|
||||||
if (convert && !dst) {
|
if (convert && !dst) {
|
||||||
// The user didn't ask for the data to be copied, but we need to convert it, so store it in the scratch buffer
|
// The user didn't ask for the data to be copied, but we need to convert it, so store it in the scratch buffer
|
||||||
|
@ -609,7 +609,7 @@ size_t SDL_GetAudioQueueQueued(SDL_AudioQueue *queue)
|
||||||
while (iter) {
|
while (iter) {
|
||||||
SDL_AudioSpec src_spec;
|
SDL_AudioSpec src_spec;
|
||||||
int *src_chmap;
|
int *src_chmap;
|
||||||
SDL_bool flushed;
|
bool flushed;
|
||||||
|
|
||||||
size_t avail = SDL_NextAudioQueueIter(queue, &iter, &src_spec, &src_chmap, &flushed);
|
size_t avail = SDL_NextAudioQueueIter(queue, &iter, &src_spec, &src_chmap, &flushed);
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ void *SDL_BeginAudioQueueIter(SDL_AudioQueue *queue);
|
||||||
|
|
||||||
// Query and update the track iterator
|
// Query and update the track iterator
|
||||||
// REQUIRES: `*inout_iter != NULL` (a valid 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, SDL_bool *out_flushed);
|
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,
|
const Uint8 *SDL_ReadFromAudioQueue(SDL_AudioQueue *queue,
|
||||||
Uint8 *dst, SDL_AudioFormat dst_format, int dst_channels, const int *dst_map,
|
Uint8 *dst, SDL_AudioFormat dst_format, int dst_channels, const int *dst_map,
|
||||||
|
|
|
@ -533,7 +533,7 @@ static void Transpose4x4(Cubic *data)
|
||||||
static void SetupAudioResampler(void)
|
static void SetupAudioResampler(void)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
SDL_bool transpose = SDL_FALSE;
|
bool transpose = false;
|
||||||
|
|
||||||
GenerateResamplerFilter();
|
GenerateResamplerFilter();
|
||||||
|
|
||||||
|
@ -542,7 +542,7 @@ static void SetupAudioResampler(void)
|
||||||
for (i = 0; i < 8; ++i) {
|
for (i = 0; i < 8; ++i) {
|
||||||
ResampleFrame[i] = ResampleFrame_Generic_SSE;
|
ResampleFrame[i] = ResampleFrame_Generic_SSE;
|
||||||
}
|
}
|
||||||
transpose = SDL_TRUE;
|
transpose = true;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
#ifdef SDL_NEON_INTRINSICS
|
#ifdef SDL_NEON_INTRINSICS
|
||||||
|
@ -550,7 +550,7 @@ static void SetupAudioResampler(void)
|
||||||
for (i = 0; i < 8; ++i) {
|
for (i = 0; i < 8; ++i) {
|
||||||
ResampleFrame[i] = ResampleFrame_Generic_NEON;
|
ResampleFrame[i] = ResampleFrame_Generic_NEON;
|
||||||
}
|
}
|
||||||
transpose = SDL_TRUE;
|
transpose = true;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
|
@ -870,7 +870,7 @@ void ConvertAudioSwapEndian(void* dst, const void* src, int num_samples, int bit
|
||||||
|
|
||||||
void SDL_ChooseAudioConverters(void)
|
void SDL_ChooseAudioConverters(void)
|
||||||
{
|
{
|
||||||
static SDL_bool converters_chosen = SDL_FALSE;
|
static bool converters_chosen = false;
|
||||||
if (converters_chosen) {
|
if (converters_chosen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -921,5 +921,5 @@ void SDL_ChooseAudioConverters(void)
|
||||||
|
|
||||||
#undef SET_CONVERTER_FUNCS
|
#undef SET_CONVERTER_FUNCS
|
||||||
|
|
||||||
converters_chosen = SDL_TRUE;
|
converters_chosen = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ extern void SDL_SetupAudioResampler(void);
|
||||||
/* Backends should call this as devices are added to the system (such as
|
/* Backends should call this as devices are added to the system (such as
|
||||||
a USB headset being plugged in), and should also be called for
|
a USB headset being plugged in), and should also be called for
|
||||||
for every device found during DetectDevices(). */
|
for every device found during DetectDevices(). */
|
||||||
extern SDL_AudioDevice *SDL_AddAudioDevice(SDL_bool recording, const char *name, const SDL_AudioSpec *spec, void *handle);
|
extern SDL_AudioDevice *SDL_AddAudioDevice(bool recording, const char *name, const SDL_AudioSpec *spec, void *handle);
|
||||||
|
|
||||||
/* Backends should call this if an opened audio device is lost.
|
/* Backends should call this if an opened audio device is lost.
|
||||||
This can happen due to i/o errors, or a device being unplugged, etc. */
|
This can happen due to i/o errors, or a device being unplugged, etc. */
|
||||||
|
@ -88,7 +88,7 @@ extern int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, co
|
||||||
extern SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByHandle(void *handle);
|
extern SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByHandle(void *handle);
|
||||||
|
|
||||||
// Find an SDL_AudioDevice, selected by a callback. NULL if not found. DOES NOT LOCK THE DEVICE.
|
// Find an SDL_AudioDevice, selected by a callback. NULL if not found. DOES NOT LOCK THE DEVICE.
|
||||||
extern SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByCallback(SDL_bool (*callback)(SDL_AudioDevice *device, void *userdata), void *userdata);
|
extern SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByCallback(bool (*callback)(SDL_AudioDevice *device, void *userdata), void *userdata);
|
||||||
|
|
||||||
// Backends should call this if they change the device format, channels, freq, or sample_frames to keep other state correct.
|
// Backends should call this if they change the device format, channels, freq, or sample_frames to keep other state correct.
|
||||||
extern void SDL_UpdatedAudioDeviceFormat(SDL_AudioDevice *device);
|
extern void SDL_UpdatedAudioDeviceFormat(SDL_AudioDevice *device);
|
||||||
|
@ -102,10 +102,10 @@ extern void UnrefPhysicalAudioDevice(SDL_AudioDevice *device);
|
||||||
|
|
||||||
// These functions are the heart of the audio threads. Backends can call them directly if they aren't using the SDL-provided thread.
|
// These functions are the heart of the audio threads. Backends can call them directly if they aren't using the SDL-provided thread.
|
||||||
extern void SDL_PlaybackAudioThreadSetup(SDL_AudioDevice *device);
|
extern void SDL_PlaybackAudioThreadSetup(SDL_AudioDevice *device);
|
||||||
extern SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device);
|
extern bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device);
|
||||||
extern void SDL_PlaybackAudioThreadShutdown(SDL_AudioDevice *device);
|
extern void SDL_PlaybackAudioThreadShutdown(SDL_AudioDevice *device);
|
||||||
extern void SDL_RecordingAudioThreadSetup(SDL_AudioDevice *device);
|
extern void SDL_RecordingAudioThreadSetup(SDL_AudioDevice *device);
|
||||||
extern SDL_bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device);
|
extern bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device);
|
||||||
extern void SDL_RecordingAudioThreadShutdown(SDL_AudioDevice *device);
|
extern void SDL_RecordingAudioThreadShutdown(SDL_AudioDevice *device);
|
||||||
extern void SDL_AudioThreadFinalize(SDL_AudioDevice *device);
|
extern void SDL_AudioThreadFinalize(SDL_AudioDevice *device);
|
||||||
|
|
||||||
|
@ -113,8 +113,8 @@ extern void ConvertAudioToFloat(float *dst, const void *src, int num_samples, SD
|
||||||
extern void ConvertAudioFromFloat(void *dst, const float *src, int num_samples, SDL_AudioFormat dst_fmt);
|
extern void ConvertAudioFromFloat(void *dst, const float *src, int num_samples, SDL_AudioFormat dst_fmt);
|
||||||
extern void ConvertAudioSwapEndian(void* dst, const void* src, int num_samples, int bitsize);
|
extern void ConvertAudioSwapEndian(void* dst, const void* src, int num_samples, int bitsize);
|
||||||
|
|
||||||
extern SDL_bool SDL_ChannelMapIsDefault(const int *map, int channels);
|
extern bool SDL_ChannelMapIsDefault(const int *map, int channels);
|
||||||
extern SDL_bool SDL_ChannelMapIsBogus(const int *map, int channels);
|
extern bool SDL_ChannelMapIsBogus(const int *map, int channels);
|
||||||
|
|
||||||
// this gets used from the audio device threads. It has rules, don't use this if you don't know how to use it!
|
// this gets used from the audio device threads. It has rules, don't use this if you don't know how to use it!
|
||||||
extern void ConvertAudio(int num_frames,
|
extern void ConvertAudio(int num_frames,
|
||||||
|
@ -122,10 +122,10 @@ extern void ConvertAudio(int num_frames,
|
||||||
void *dst, SDL_AudioFormat dst_format, int dst_channels, const int *dst_map,
|
void *dst, SDL_AudioFormat dst_format, int dst_channels, const int *dst_map,
|
||||||
void* scratch, float gain);
|
void* scratch, float gain);
|
||||||
|
|
||||||
// Compare two SDL_AudioSpecs, return SDL_TRUE if they match exactly.
|
// Compare two SDL_AudioSpecs, return true if they match exactly.
|
||||||
// Using SDL_memcmp directly isn't safe, since potential padding might not be initialized.
|
// Using SDL_memcmp directly isn't safe, since potential padding might not be initialized.
|
||||||
// either channel maps can be NULL for the default (and both should be if you don't care about them).
|
// either channel maps can be NULL for the default (and both should be if you don't care about them).
|
||||||
extern SDL_bool SDL_AudioSpecsEqual(const SDL_AudioSpec *a, const SDL_AudioSpec *b, const int *channel_map_a, const int *channel_map_b);
|
extern bool SDL_AudioSpecsEqual(const SDL_AudioSpec *a, const SDL_AudioSpec *b, const int *channel_map_a, const int *channel_map_b);
|
||||||
|
|
||||||
// allocate+copy a channel map.
|
// allocate+copy a channel map.
|
||||||
extern int *SDL_ChannelMapDup(const int *origchmap, int channels);
|
extern int *SDL_ChannelMapDup(const int *origchmap, int channels);
|
||||||
|
@ -159,10 +159,10 @@ typedef struct SDL_AudioDriverImpl
|
||||||
void (*Deinitialize)(void);
|
void (*Deinitialize)(void);
|
||||||
|
|
||||||
// Some flags to push duplicate code into the core and reduce #ifdefs.
|
// Some flags to push duplicate code into the core and reduce #ifdefs.
|
||||||
SDL_bool ProvidesOwnCallbackThread; // !!! FIXME: rename this, it's not a callback thread anymore.
|
bool ProvidesOwnCallbackThread; // !!! FIXME: rename this, it's not a callback thread anymore.
|
||||||
SDL_bool HasRecordingSupport;
|
bool HasRecordingSupport;
|
||||||
SDL_bool OnlyHasDefaultPlaybackDevice;
|
bool OnlyHasDefaultPlaybackDevice;
|
||||||
SDL_bool OnlyHasDefaultRecordingDevice; // !!! FIXME: is there ever a time where you'd have a default playback and not a default recording (or vice versa)?
|
bool OnlyHasDefaultRecordingDevice; // !!! FIXME: is there ever a time where you'd have a default playback and not a default recording (or vice versa)?
|
||||||
} SDL_AudioDriverImpl;
|
} SDL_AudioDriverImpl;
|
||||||
|
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ struct SDL_AudioStream
|
||||||
Uint8 *work_buffer; // used for scratch space during data conversion/resampling.
|
Uint8 *work_buffer; // used for scratch space during data conversion/resampling.
|
||||||
size_t work_buffer_allocation;
|
size_t work_buffer_allocation;
|
||||||
|
|
||||||
SDL_bool simplified; // SDL_TRUE if created via SDL_OpenAudioDeviceStream
|
bool simplified; // true if created via SDL_OpenAudioDeviceStream
|
||||||
|
|
||||||
SDL_LogicalAudioDevice *bound_device;
|
SDL_LogicalAudioDevice *bound_device;
|
||||||
SDL_AudioStream *next_binding;
|
SDL_AudioStream *next_binding;
|
||||||
|
@ -253,11 +253,11 @@ struct SDL_LogicalAudioDevice
|
||||||
// double-linked list of all audio streams currently bound to this opened device.
|
// double-linked list of all audio streams currently bound to this opened device.
|
||||||
SDL_AudioStream *bound_streams;
|
SDL_AudioStream *bound_streams;
|
||||||
|
|
||||||
// SDL_TRUE if this was opened as a default device.
|
// true if this was opened as a default device.
|
||||||
SDL_bool opened_as_default;
|
bool opened_as_default;
|
||||||
|
|
||||||
// SDL_TRUE if device was opened with SDL_OpenAudioDeviceStream (so it forbids binding changes, etc).
|
// true if device was opened with SDL_OpenAudioDeviceStream (so it forbids binding changes, etc).
|
||||||
SDL_bool simplified;
|
bool simplified;
|
||||||
|
|
||||||
// If non-NULL, callback into the app that lets them access the final postmix buffer.
|
// If non-NULL, callback into the app that lets them access the final postmix buffer.
|
||||||
SDL_AudioPostmixCallback postmix;
|
SDL_AudioPostmixCallback postmix;
|
||||||
|
@ -319,11 +319,11 @@ struct SDL_AudioDevice
|
||||||
// non-zero if this was a disconnected device and we're waiting for it to be decommissioned.
|
// non-zero if this was a disconnected device and we're waiting for it to be decommissioned.
|
||||||
SDL_AtomicInt zombie;
|
SDL_AtomicInt zombie;
|
||||||
|
|
||||||
// SDL_TRUE if this is a recording device instead of an playback device
|
// true if this is a recording device instead of an playback device
|
||||||
SDL_bool recording;
|
bool recording;
|
||||||
|
|
||||||
// SDL_TRUE if audio thread can skip silence/mix/convert stages and just do a basic memcpy.
|
// true if audio thread can skip silence/mix/convert stages and just do a basic memcpy.
|
||||||
SDL_bool simple_copy;
|
bool simple_copy;
|
||||||
|
|
||||||
// Scratch buffers used for mixing.
|
// Scratch buffers used for mixing.
|
||||||
Uint8 *work_buffer;
|
Uint8 *work_buffer;
|
||||||
|
@ -336,8 +336,8 @@ struct SDL_AudioDevice
|
||||||
// A thread to feed the audio device
|
// A thread to feed the audio device
|
||||||
SDL_Thread *thread;
|
SDL_Thread *thread;
|
||||||
|
|
||||||
// SDL_TRUE if this physical device is currently opened by the backend.
|
// true if this physical device is currently opened by the backend.
|
||||||
SDL_bool currently_opened;
|
bool currently_opened;
|
||||||
|
|
||||||
// Data private to this driver
|
// Data private to this driver
|
||||||
struct SDL_PrivateAudioData *hidden;
|
struct SDL_PrivateAudioData *hidden;
|
||||||
|
@ -350,8 +350,8 @@ typedef struct AudioBootStrap
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *desc;
|
const char *desc;
|
||||||
SDL_bool (*init)(SDL_AudioDriverImpl *impl);
|
bool (*init)(SDL_AudioDriverImpl *impl);
|
||||||
SDL_bool demand_only; // if SDL_TRUE: request explicitly, or it won't be available.
|
bool demand_only; // if true: request explicitly, or it won't be available.
|
||||||
} AudioBootStrap;
|
} AudioBootStrap;
|
||||||
|
|
||||||
// Not all of these are available in a given build. Use #ifdefs, etc.
|
// Not all of these are available in a given build. Use #ifdefs, etc.
|
||||||
|
|
|
@ -1776,7 +1776,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||||
Uint32 chunkcountlimit = 10000;
|
Uint32 chunkcountlimit = 10000;
|
||||||
const char *hint;
|
const char *hint;
|
||||||
Sint64 RIFFstart, RIFFend, lastchunkpos;
|
Sint64 RIFFstart, RIFFend, lastchunkpos;
|
||||||
SDL_bool RIFFlengthknown = SDL_FALSE;
|
bool RIFFlengthknown = false;
|
||||||
WaveFormat *format = &file->format;
|
WaveFormat *format = &file->format;
|
||||||
WaveChunk *chunk = &file->chunk;
|
WaveChunk *chunk = &file->chunk;
|
||||||
WaveChunk RIFFchunk;
|
WaveChunk RIFFchunk;
|
||||||
|
@ -1842,7 +1842,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||||
SDL_FALLTHROUGH;
|
SDL_FALLTHROUGH;
|
||||||
case RiffSizeForce:
|
case RiffSizeForce:
|
||||||
RIFFend = RIFFchunk.position + RIFFchunk.length;
|
RIFFend = RIFFchunk.position + RIFFchunk.length;
|
||||||
RIFFlengthknown = SDL_TRUE;
|
RIFFlengthknown = true;
|
||||||
break;
|
break;
|
||||||
case RiffSizeMaximum:
|
case RiffSizeMaximum:
|
||||||
RIFFend = SDL_MAX_SINT64;
|
RIFFend = SDL_MAX_SINT64;
|
||||||
|
|
|
@ -282,7 +282,7 @@ static void AAUDIO_CloseDevice(SDL_AudioDevice *device)
|
||||||
static int BuildAAudioStream(SDL_AudioDevice *device)
|
static int BuildAAudioStream(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
struct SDL_PrivateAudioData *hidden = device->hidden;
|
struct SDL_PrivateAudioData *hidden = device->hidden;
|
||||||
const SDL_bool recording = device->recording;
|
const bool recording = device->recording;
|
||||||
aaudio_result_t res;
|
aaudio_result_t res;
|
||||||
|
|
||||||
SDL_AtomicSet(&hidden->error_callback_triggered, 0);
|
SDL_AtomicSet(&hidden->error_callback_triggered, 0);
|
||||||
|
@ -322,7 +322,7 @@ static int BuildAAudioStream(SDL_AudioDevice *device)
|
||||||
ctx.AAudioStreamBuilder_setErrorCallback(builder, AAUDIO_errorCallback, device);
|
ctx.AAudioStreamBuilder_setErrorCallback(builder, AAUDIO_errorCallback, device);
|
||||||
ctx.AAudioStreamBuilder_setDataCallback(builder, AAUDIO_dataCallback, device);
|
ctx.AAudioStreamBuilder_setDataCallback(builder, AAUDIO_dataCallback, device);
|
||||||
// Some devices have flat sounding audio when low latency mode is enabled, but this is a better experience for most people
|
// Some devices have flat sounding audio when low latency mode is enabled, but this is a better experience for most people
|
||||||
if (SDL_GetHintBoolean("SDL_ANDROID_LOW_LATENCY_AUDIO", SDL_TRUE)) {
|
if (SDL_GetHintBoolean("SDL_ANDROID_LOW_LATENCY_AUDIO", true)) {
|
||||||
ctx.AAudioStreamBuilder_setPerformanceMode(builder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
|
ctx.AAudioStreamBuilder_setPerformanceMode(builder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ static int AAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||||
return BuildAAudioStream(device);
|
return BuildAAudioStream(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool PauseOneDevice(SDL_AudioDevice *device, void *userdata)
|
static bool PauseOneDevice(SDL_AudioDevice *device, void *userdata)
|
||||||
{
|
{
|
||||||
struct SDL_PrivateAudioData *hidden = (struct SDL_PrivateAudioData *)device->hidden;
|
struct SDL_PrivateAudioData *hidden = (struct SDL_PrivateAudioData *)device->hidden;
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
|
@ -451,7 +451,7 @@ static SDL_bool PauseOneDevice(SDL_AudioDevice *device, void *userdata)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SDL_FALSE; // keep enumerating.
|
return false; // keep enumerating.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pause (block) all non already paused audio devices by taking their mixer lock
|
// Pause (block) all non already paused audio devices by taking their mixer lock
|
||||||
|
@ -463,7 +463,7 @@ void AAUDIO_PauseDevices(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resume (unblock) all non already paused audio devices by releasing their mixer lock
|
// Resume (unblock) all non already paused audio devices by releasing their mixer lock
|
||||||
static SDL_bool ResumeOneDevice(SDL_AudioDevice *device, void *userdata)
|
static bool ResumeOneDevice(SDL_AudioDevice *device, void *userdata)
|
||||||
{
|
{
|
||||||
struct SDL_PrivateAudioData *hidden = device->hidden;
|
struct SDL_PrivateAudioData *hidden = device->hidden;
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
|
@ -475,7 +475,7 @@ static SDL_bool ResumeOneDevice(SDL_AudioDevice *device, void *userdata)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SDL_FALSE; // keep enumerating.
|
return false; // keep enumerating.
|
||||||
}
|
}
|
||||||
|
|
||||||
void AAUDIO_ResumeDevices(void)
|
void AAUDIO_ResumeDevices(void)
|
||||||
|
@ -498,7 +498,7 @@ static void AAUDIO_Deinitialize(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static SDL_bool AAUDIO_Init(SDL_AudioDriverImpl *impl)
|
static bool AAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
LOGI(__func__);
|
LOGI(__func__);
|
||||||
|
|
||||||
|
@ -508,7 +508,7 @@ static SDL_bool AAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
* See https://github.com/google/oboe/issues/40 for more information.
|
* See https://github.com/google/oboe/issues/40 for more information.
|
||||||
*/
|
*/
|
||||||
if (SDL_GetAndroidSDKVersion() < 27) {
|
if (SDL_GetAndroidSDKVersion() < 27) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_zero(ctx);
|
SDL_zero(ctx);
|
||||||
|
@ -516,13 +516,13 @@ static SDL_bool AAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
ctx.handle = SDL_LoadObject(LIB_AAUDIO_SO);
|
ctx.handle = SDL_LoadObject(LIB_AAUDIO_SO);
|
||||||
if (!ctx.handle) {
|
if (!ctx.handle) {
|
||||||
LOGI("SDL couldn't find " LIB_AAUDIO_SO);
|
LOGI("SDL couldn't find " LIB_AAUDIO_SO);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AAUDIO_LoadFunctions(&ctx) < 0) {
|
if (AAUDIO_LoadFunctions(&ctx) < 0) {
|
||||||
SDL_UnloadObject(ctx.handle);
|
SDL_UnloadObject(ctx.handle);
|
||||||
SDL_zero(ctx);
|
SDL_zero(ctx);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->ThreadInit = Android_AudioThreadInit;
|
impl->ThreadInit = Android_AudioThreadInit;
|
||||||
|
@ -535,21 +535,21 @@ static SDL_bool AAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->WaitRecordingDevice = AAUDIO_WaitDevice;
|
impl->WaitRecordingDevice = AAUDIO_WaitDevice;
|
||||||
impl->RecordDevice = AAUDIO_RecordDevice;
|
impl->RecordDevice = AAUDIO_RecordDevice;
|
||||||
|
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
|
|
||||||
#if ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES
|
#if ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES
|
||||||
impl->DetectDevices = Android_StartAudioHotplug;
|
impl->DetectDevices = Android_StartAudioHotplug;
|
||||||
#else
|
#else
|
||||||
impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE;
|
impl->OnlyHasDefaultPlaybackDevice = true;
|
||||||
impl->OnlyHasDefaultRecordingDevice = SDL_TRUE;
|
impl->OnlyHasDefaultRecordingDevice = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LOGI("SDL AAUDIO_Init OK");
|
LOGI("SDL AAUDIO_Init OK");
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap AAUDIO_bootstrap = {
|
AudioBootStrap AAUDIO_bootstrap = {
|
||||||
"AAudio", "AAudio audio driver", AAUDIO_Init, SDL_FALSE
|
"AAudio", "AAudio audio driver", AAUDIO_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_AAUDIO
|
#endif // SDL_AUDIO_DRIVER_AAUDIO
|
||||||
|
|
|
@ -206,19 +206,19 @@ static int LoadALSALibrary(void)
|
||||||
typedef struct ALSA_Device
|
typedef struct ALSA_Device
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
SDL_bool recording;
|
bool recording;
|
||||||
struct ALSA_Device *next;
|
struct ALSA_Device *next;
|
||||||
} ALSA_Device;
|
} ALSA_Device;
|
||||||
|
|
||||||
static const ALSA_Device default_playback_handle = {
|
static const ALSA_Device default_playback_handle = {
|
||||||
"default",
|
"default",
|
||||||
SDL_FALSE,
|
false,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static const ALSA_Device default_recording_handle = {
|
static const ALSA_Device default_recording_handle = {
|
||||||
"default",
|
"default",
|
||||||
SDL_TRUE,
|
true,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ static int ALSA_set_buffer_size(SDL_AudioDevice *device, snd_pcm_hw_params_t *pa
|
||||||
|
|
||||||
static int ALSA_OpenDevice(SDL_AudioDevice *device)
|
static int ALSA_OpenDevice(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
const SDL_bool recording = device->recording;
|
const bool recording = device->recording;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
// Initialize all variables that we clean on shutdown
|
// Initialize all variables that we clean on shutdown
|
||||||
|
@ -622,7 +622,7 @@ static int ALSA_OpenDevice(SDL_AudioDevice *device)
|
||||||
return 0; // We're ready to rock and roll. :-)
|
return 0; // We're ready to rock and roll. :-)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_device(const SDL_bool recording, const char *name, void *hint, ALSA_Device **pSeen)
|
static void add_device(const bool recording, const char *name, void *hint, ALSA_Device **pSeen)
|
||||||
{
|
{
|
||||||
ALSA_Device *dev = SDL_malloc(sizeof(ALSA_Device));
|
ALSA_Device *dev = SDL_malloc(sizeof(ALSA_Device));
|
||||||
char *desc;
|
char *desc;
|
||||||
|
@ -683,7 +683,7 @@ static void add_device(const SDL_bool recording, const char *name, void *hint, A
|
||||||
|
|
||||||
static ALSA_Device *hotplug_devices = NULL;
|
static ALSA_Device *hotplug_devices = NULL;
|
||||||
|
|
||||||
static void ALSA_HotplugIteration(SDL_bool *has_default_playback, SDL_bool *has_default_recording)
|
static void ALSA_HotplugIteration(bool *has_default_playback, bool *has_default_recording)
|
||||||
{
|
{
|
||||||
void **hints = NULL;
|
void **hints = NULL;
|
||||||
ALSA_Device *unseen = NULL;
|
ALSA_Device *unseen = NULL;
|
||||||
|
@ -741,13 +741,13 @@ static void ALSA_HotplugIteration(SDL_bool *has_default_playback, SDL_bool *has_
|
||||||
}
|
}
|
||||||
|
|
||||||
// only want physical hardware interfaces
|
// only want physical hardware interfaces
|
||||||
const SDL_bool is_default = (has_default == i);
|
const bool is_default = (has_default == i);
|
||||||
if (is_default || (match && SDL_strncmp(name, match, match_len) == 0)) {
|
if (is_default || (match && SDL_strncmp(name, match, match_len) == 0)) {
|
||||||
char *ioid = ALSA_snd_device_name_get_hint(hints[i], "IOID");
|
char *ioid = ALSA_snd_device_name_get_hint(hints[i], "IOID");
|
||||||
const SDL_bool isoutput = (!ioid) || (SDL_strcmp(ioid, "Output") == 0);
|
const bool isoutput = (!ioid) || (SDL_strcmp(ioid, "Output") == 0);
|
||||||
const SDL_bool isinput = (!ioid) || (SDL_strcmp(ioid, "Input") == 0);
|
const bool isinput = (!ioid) || (SDL_strcmp(ioid, "Input") == 0);
|
||||||
SDL_bool have_output = SDL_FALSE;
|
bool have_output = false;
|
||||||
SDL_bool have_input = SDL_FALSE;
|
bool have_input = false;
|
||||||
|
|
||||||
free(ioid); // This should NOT be SDL_free()
|
free(ioid); // This should NOT be SDL_free()
|
||||||
|
|
||||||
|
@ -758,9 +758,9 @@ static void ALSA_HotplugIteration(SDL_bool *has_default_playback, SDL_bool *has_
|
||||||
|
|
||||||
if (is_default) {
|
if (is_default) {
|
||||||
if (has_default_playback && isoutput) {
|
if (has_default_playback && isoutput) {
|
||||||
*has_default_playback = SDL_TRUE;
|
*has_default_playback = true;
|
||||||
} else if (has_default_recording && isinput) {
|
} else if (has_default_recording && isinput) {
|
||||||
*has_default_recording = SDL_TRUE;
|
*has_default_recording = true;
|
||||||
}
|
}
|
||||||
free(name); // This should NOT be SDL_free()
|
free(name); // This should NOT be SDL_free()
|
||||||
continue;
|
continue;
|
||||||
|
@ -779,10 +779,10 @@ static void ALSA_HotplugIteration(SDL_bool *has_default_playback, SDL_bool *has_
|
||||||
dev->next = seen;
|
dev->next = seen;
|
||||||
seen = dev;
|
seen = dev;
|
||||||
if (isinput) {
|
if (isinput) {
|
||||||
have_input = SDL_TRUE;
|
have_input = true;
|
||||||
}
|
}
|
||||||
if (isoutput) {
|
if (isoutput) {
|
||||||
have_output = SDL_TRUE;
|
have_output = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
prev = dev;
|
prev = dev;
|
||||||
|
@ -790,10 +790,10 @@ static void ALSA_HotplugIteration(SDL_bool *has_default_playback, SDL_bool *has_
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isinput && !have_input) {
|
if (isinput && !have_input) {
|
||||||
add_device(SDL_TRUE, name, hints[i], &seen);
|
add_device(true, name, hints[i], &seen);
|
||||||
}
|
}
|
||||||
if (isoutput && !have_output) {
|
if (isoutput && !have_output) {
|
||||||
add_device(SDL_FALSE, name, hints[i], &seen);
|
add_device(false, name, hints[i], &seen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -843,13 +843,13 @@ static void ALSA_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevi
|
||||||
{
|
{
|
||||||
// ALSA doesn't have a concept of a changeable default device, afaik, so we expose a generic default
|
// ALSA doesn't have a concept of a changeable default device, afaik, so we expose a generic default
|
||||||
// device here. It's the best we can do at this level.
|
// device here. It's the best we can do at this level.
|
||||||
SDL_bool has_default_playback = SDL_FALSE, has_default_recording = SDL_FALSE;
|
bool has_default_playback = false, has_default_recording = false;
|
||||||
ALSA_HotplugIteration(&has_default_playback, &has_default_recording); // run once now before a thread continues to check.
|
ALSA_HotplugIteration(&has_default_playback, &has_default_recording); // run once now before a thread continues to check.
|
||||||
if (has_default_playback) {
|
if (has_default_playback) {
|
||||||
*default_playback = SDL_AddAudioDevice(/*recording=*/SDL_FALSE, "ALSA default playback device", NULL, (void*)&default_playback_handle);
|
*default_playback = SDL_AddAudioDevice(/*recording=*/false, "ALSA default playback device", NULL, (void*)&default_playback_handle);
|
||||||
}
|
}
|
||||||
if (has_default_recording) {
|
if (has_default_recording) {
|
||||||
*default_recording = SDL_AddAudioDevice(/*recording=*/SDL_TRUE, "ALSA default recording device", NULL, (void*)&default_recording_handle);
|
*default_recording = SDL_AddAudioDevice(/*recording=*/true, "ALSA default recording device", NULL, (void*)&default_recording_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SDL_ALSA_HOTPLUG_THREAD
|
#if SDL_ALSA_HOTPLUG_THREAD
|
||||||
|
@ -887,10 +887,10 @@ static void ALSA_Deinitialize(void)
|
||||||
UnloadALSALibrary();
|
UnloadALSALibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool ALSA_Init(SDL_AudioDriverImpl *impl)
|
static bool ALSA_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
if (LoadALSALibrary() < 0) {
|
if (LoadALSALibrary() < 0) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->DetectDevices = ALSA_DetectDevices;
|
impl->DetectDevices = ALSA_DetectDevices;
|
||||||
|
@ -905,13 +905,13 @@ static SDL_bool ALSA_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->RecordDevice = ALSA_RecordDevice;
|
impl->RecordDevice = ALSA_RecordDevice;
|
||||||
impl->FlushRecording = ALSA_FlushRecording;
|
impl->FlushRecording = ALSA_FlushRecording;
|
||||||
|
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap ALSA_bootstrap = {
|
AudioBootStrap ALSA_bootstrap = {
|
||||||
"alsa", "ALSA PCM audio", ALSA_Init, SDL_FALSE
|
"alsa", "ALSA PCM audio", ALSA_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_ALSA
|
#endif // SDL_AUDIO_DRIVER_ALSA
|
||||||
|
|
|
@ -60,7 +60,7 @@ struct SDL_PrivateAudioData
|
||||||
#ifdef MACOSX_COREAUDIO
|
#ifdef MACOSX_COREAUDIO
|
||||||
AudioDeviceID deviceID;
|
AudioDeviceID deviceID;
|
||||||
#else
|
#else
|
||||||
SDL_bool interrupted;
|
bool interrupted;
|
||||||
CFTypeRef interruption_listener;
|
CFTypeRef interruption_listener;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -48,17 +48,17 @@
|
||||||
typedef struct SDLCoreAudioHandle
|
typedef struct SDLCoreAudioHandle
|
||||||
{
|
{
|
||||||
AudioDeviceID devid;
|
AudioDeviceID devid;
|
||||||
SDL_bool recording;
|
bool recording;
|
||||||
} SDLCoreAudioHandle;
|
} SDLCoreAudioHandle;
|
||||||
|
|
||||||
static SDL_bool TestCoreAudioDeviceHandleCallback(SDL_AudioDevice *device, void *handle)
|
static bool TestCoreAudioDeviceHandleCallback(SDL_AudioDevice *device, void *handle)
|
||||||
{
|
{
|
||||||
const SDLCoreAudioHandle *a = (const SDLCoreAudioHandle *) device->handle;
|
const SDLCoreAudioHandle *a = (const SDLCoreAudioHandle *) device->handle;
|
||||||
const SDLCoreAudioHandle *b = (const SDLCoreAudioHandle *) handle;
|
const SDLCoreAudioHandle *b = (const SDLCoreAudioHandle *) handle;
|
||||||
return (a->devid == b->devid) && (!!a->recording == !!b->recording);
|
return (a->devid == b->devid) && (!!a->recording == !!b->recording);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_AudioDevice *FindCoreAudioDeviceByHandle(const AudioDeviceID devid, const SDL_bool recording)
|
static SDL_AudioDevice *FindCoreAudioDeviceByHandle(const AudioDeviceID devid, const bool recording)
|
||||||
{
|
{
|
||||||
SDLCoreAudioHandle handle = { devid, recording };
|
SDLCoreAudioHandle handle = { devid, recording };
|
||||||
return SDL_FindPhysicalAudioDeviceByCallback(TestCoreAudioDeviceHandleCallback, &handle);
|
return SDL_FindPhysicalAudioDeviceByCallback(TestCoreAudioDeviceHandleCallback, &handle);
|
||||||
|
@ -98,11 +98,11 @@ static OSStatus DeviceAliveNotification(AudioObjectID devid, UInt32 num_addr, co
|
||||||
UInt32 size = sizeof(alive);
|
UInt32 size = sizeof(alive);
|
||||||
const OSStatus error = AudioObjectGetPropertyData(devid, addrs, 0, NULL, &size, &alive);
|
const OSStatus error = AudioObjectGetPropertyData(devid, addrs, 0, NULL, &size, &alive);
|
||||||
|
|
||||||
SDL_bool dead = SDL_FALSE;
|
bool dead = false;
|
||||||
if (error == kAudioHardwareBadDeviceError) {
|
if (error == kAudioHardwareBadDeviceError) {
|
||||||
dead = SDL_TRUE; // device was unplugged.
|
dead = true; // device was unplugged.
|
||||||
} else if ((error == kAudioHardwareNoError) && (!alive)) {
|
} else if ((error == kAudioHardwareNoError) && (!alive)) {
|
||||||
dead = SDL_TRUE; // device died in some other way.
|
dead = true; // device died in some other way.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dead) {
|
if (dead) {
|
||||||
|
@ -127,7 +127,7 @@ static void RefreshPhysicalDevices(void)
|
||||||
{
|
{
|
||||||
UInt32 size = 0;
|
UInt32 size = 0;
|
||||||
AudioDeviceID *devs = NULL;
|
AudioDeviceID *devs = NULL;
|
||||||
SDL_bool isstack;
|
bool isstack;
|
||||||
|
|
||||||
if (AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &devlist_address, 0, NULL, &size) != kAudioHardwareNoError) {
|
if (AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &devlist_address, 0, NULL, &size) != kAudioHardwareNoError) {
|
||||||
return;
|
return;
|
||||||
|
@ -140,7 +140,7 @@ static void RefreshPhysicalDevices(void)
|
||||||
|
|
||||||
const UInt32 total_devices = (UInt32) (size / sizeof(AudioDeviceID));
|
const UInt32 total_devices = (UInt32) (size / sizeof(AudioDeviceID));
|
||||||
for (UInt32 i = 0; i < total_devices; i++) {
|
for (UInt32 i = 0; i < total_devices; i++) {
|
||||||
if (FindCoreAudioDeviceByHandle(devs[i], SDL_TRUE) || FindCoreAudioDeviceByHandle(devs[i], SDL_FALSE)) {
|
if (FindCoreAudioDeviceByHandle(devs[i], true) || FindCoreAudioDeviceByHandle(devs[i], false)) {
|
||||||
devs[i] = 0; // The system and SDL both agree it's already here, don't check it again.
|
devs[i] = 0; // The system and SDL both agree it's already here, don't check it again.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ static void RefreshPhysicalDevices(void)
|
||||||
|
|
||||||
CFIndex len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfstr), kCFStringEncodingUTF8);
|
CFIndex len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfstr), kCFStringEncodingUTF8);
|
||||||
char *name = (char *)SDL_malloc(len + 1);
|
char *name = (char *)SDL_malloc(len + 1);
|
||||||
SDL_bool usable = ((name != NULL) && (CFStringGetCString(cfstr, name, len + 1, kCFStringEncodingUTF8)));
|
bool usable = ((name != NULL) && (CFStringGetCString(cfstr, name, len + 1, kCFStringEncodingUTF8)));
|
||||||
|
|
||||||
CFRelease(cfstr);
|
CFRelease(cfstr);
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ static void RefreshPhysicalDevices(void)
|
||||||
SDLCoreAudioHandle *newhandle = (SDLCoreAudioHandle *) SDL_calloc(1, sizeof (*newhandle));
|
SDLCoreAudioHandle *newhandle = (SDLCoreAudioHandle *) SDL_calloc(1, sizeof (*newhandle));
|
||||||
if (newhandle) {
|
if (newhandle) {
|
||||||
newhandle->devid = dev;
|
newhandle->devid = dev;
|
||||||
newhandle->recording = recording ? SDL_TRUE : SDL_FALSE;
|
newhandle->recording = recording ? true : false;
|
||||||
SDL_AudioDevice *device = SDL_AddAudioDevice(newhandle->recording, name, &spec, newhandle);
|
SDL_AudioDevice *device = SDL_AddAudioDevice(newhandle->recording, name, &spec, newhandle);
|
||||||
if (device) {
|
if (device) {
|
||||||
AudioObjectAddPropertyListener(dev, &alive_address, DeviceAliveNotification, device);
|
AudioObjectAddPropertyListener(dev, &alive_address, DeviceAliveNotification, device);
|
||||||
|
@ -252,7 +252,7 @@ static OSStatus DeviceListChangedNotification(AudioObjectID systemObj, UInt32 nu
|
||||||
return noErr;
|
return noErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static OSStatus DefaultAudioDeviceChangedNotification(const SDL_bool recording, AudioObjectID inObjectID, const AudioObjectPropertyAddress *addr)
|
static OSStatus DefaultAudioDeviceChangedNotification(const bool recording, AudioObjectID inObjectID, const AudioObjectPropertyAddress *addr)
|
||||||
{
|
{
|
||||||
AudioDeviceID devid;
|
AudioDeviceID devid;
|
||||||
UInt32 size = sizeof(devid);
|
UInt32 size = sizeof(devid);
|
||||||
|
@ -268,7 +268,7 @@ static OSStatus DefaultPlaybackDeviceChangedNotification(AudioObjectID inObjectI
|
||||||
SDL_Log("COREAUDIO: default playback device changed!");
|
SDL_Log("COREAUDIO: default playback device changed!");
|
||||||
#endif
|
#endif
|
||||||
SDL_assert(inNumberAddresses == 1);
|
SDL_assert(inNumberAddresses == 1);
|
||||||
return DefaultAudioDeviceChangedNotification(SDL_FALSE, inObjectID, inAddresses);
|
return DefaultAudioDeviceChangedNotification(false, inObjectID, inAddresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
static OSStatus DefaultRecordingDeviceChangedNotification(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *inUserData)
|
static OSStatus DefaultRecordingDeviceChangedNotification(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *inUserData)
|
||||||
|
@ -277,7 +277,7 @@ static OSStatus DefaultRecordingDeviceChangedNotification(AudioObjectID inObject
|
||||||
SDL_Log("COREAUDIO: default recording device changed!");
|
SDL_Log("COREAUDIO: default recording device changed!");
|
||||||
#endif
|
#endif
|
||||||
SDL_assert(inNumberAddresses == 1);
|
SDL_assert(inNumberAddresses == 1);
|
||||||
return DefaultAudioDeviceChangedNotification(SDL_TRUE, inObjectID, inAddresses);
|
return DefaultAudioDeviceChangedNotification(true, inObjectID, inAddresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void COREAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
static void COREAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
||||||
|
@ -292,7 +292,7 @@ static void COREAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_Audi
|
||||||
|
|
||||||
size = sizeof(AudioDeviceID);
|
size = sizeof(AudioDeviceID);
|
||||||
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &default_playback_device_address, 0, NULL, &size, &devid) == noErr) {
|
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &default_playback_device_address, 0, NULL, &size, &devid) == noErr) {
|
||||||
SDL_AudioDevice *device = FindCoreAudioDeviceByHandle(devid, SDL_FALSE);
|
SDL_AudioDevice *device = FindCoreAudioDeviceByHandle(devid, false);
|
||||||
if (device) {
|
if (device) {
|
||||||
*default_playback = device;
|
*default_playback = device;
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ static void COREAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_Audi
|
||||||
|
|
||||||
size = sizeof(AudioDeviceID);
|
size = sizeof(AudioDeviceID);
|
||||||
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &default_recording_device_address, 0, NULL, &size, &devid) == noErr) {
|
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &default_recording_device_address, 0, NULL, &size, &devid) == noErr) {
|
||||||
SDL_AudioDevice *device = FindCoreAudioDeviceByHandle(devid, SDL_TRUE);
|
SDL_AudioDevice *device = FindCoreAudioDeviceByHandle(devid, true);
|
||||||
if (device) {
|
if (device) {
|
||||||
*default_recording = device;
|
*default_recording = device;
|
||||||
}
|
}
|
||||||
|
@ -311,14 +311,14 @@ static void COREAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_Audi
|
||||||
|
|
||||||
#else // iOS-specific section follows.
|
#else // iOS-specific section follows.
|
||||||
|
|
||||||
static SDL_bool session_active = SDL_FALSE;
|
static bool session_active = false;
|
||||||
|
|
||||||
static SDL_bool PauseOneAudioDevice(SDL_AudioDevice *device, void *userdata)
|
static bool PauseOneAudioDevice(SDL_AudioDevice *device, void *userdata)
|
||||||
{
|
{
|
||||||
if (device->hidden && device->hidden->audioQueue && !device->hidden->interrupted) {
|
if (device->hidden && device->hidden->audioQueue && !device->hidden->interrupted) {
|
||||||
AudioQueuePause(device->hidden->audioQueue);
|
AudioQueuePause(device->hidden->audioQueue);
|
||||||
}
|
}
|
||||||
return SDL_FALSE; // keep enumerating devices until we've paused them all.
|
return false; // keep enumerating devices until we've paused them all.
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PauseAudioDevices(void)
|
static void PauseAudioDevices(void)
|
||||||
|
@ -326,12 +326,12 @@ static void PauseAudioDevices(void)
|
||||||
(void) SDL_FindPhysicalAudioDeviceByCallback(PauseOneAudioDevice, NULL);
|
(void) SDL_FindPhysicalAudioDeviceByCallback(PauseOneAudioDevice, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool ResumeOneAudioDevice(SDL_AudioDevice *device, void *userdata)
|
static bool ResumeOneAudioDevice(SDL_AudioDevice *device, void *userdata)
|
||||||
{
|
{
|
||||||
if (device->hidden && device->hidden->audioQueue && !device->hidden->interrupted) {
|
if (device->hidden && device->hidden->audioQueue && !device->hidden->interrupted) {
|
||||||
AudioQueueStart(device->hidden->audioQueue, NULL);
|
AudioQueueStart(device->hidden->audioQueue, NULL);
|
||||||
}
|
}
|
||||||
return SDL_FALSE; // keep enumerating devices until we've resumed them all.
|
return false; // keep enumerating devices until we've resumed them all.
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ResumeAudioDevices(void)
|
static void ResumeAudioDevices(void)
|
||||||
|
@ -342,7 +342,7 @@ static void ResumeAudioDevices(void)
|
||||||
static void InterruptionBegin(SDL_AudioDevice *device)
|
static void InterruptionBegin(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
if (device != NULL && device->hidden->audioQueue != NULL) {
|
if (device != NULL && device->hidden->audioQueue != NULL) {
|
||||||
device->hidden->interrupted = SDL_TRUE;
|
device->hidden->interrupted = true;
|
||||||
AudioQueuePause(device->hidden->audioQueue);
|
AudioQueuePause(device->hidden->audioQueue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ static void InterruptionBegin(SDL_AudioDevice *device)
|
||||||
static void InterruptionEnd(SDL_AudioDevice *device)
|
static void InterruptionEnd(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
if (device != NULL && device->hidden != NULL && device->hidden->audioQueue != NULL && device->hidden->interrupted && AudioQueueStart(device->hidden->audioQueue, NULL) == AVAudioSessionErrorCodeNone) {
|
if (device != NULL && device->hidden != NULL && device->hidden->audioQueue != NULL && device->hidden->interrupted && AudioQueueStart(device->hidden->audioQueue, NULL) == AVAudioSessionErrorCodeNone) {
|
||||||
device->hidden->interrupted = SDL_FALSE;
|
device->hidden->interrupted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ typedef struct
|
||||||
int recording;
|
int recording;
|
||||||
} CountOpenAudioDevicesData;
|
} CountOpenAudioDevicesData;
|
||||||
|
|
||||||
static SDL_bool CountOpenAudioDevices(SDL_AudioDevice *device, void *userdata)
|
static bool CountOpenAudioDevices(SDL_AudioDevice *device, void *userdata)
|
||||||
{
|
{
|
||||||
CountOpenAudioDevicesData *data = (CountOpenAudioDevicesData *) userdata;
|
CountOpenAudioDevicesData *data = (CountOpenAudioDevicesData *) userdata;
|
||||||
if (device->hidden != NULL) { // assume it's open if hidden != NULL
|
if (device->hidden != NULL) { // assume it's open if hidden != NULL
|
||||||
|
@ -399,10 +399,10 @@ static SDL_bool CountOpenAudioDevices(SDL_AudioDevice *device, void *userdata)
|
||||||
data->playback++;
|
data->playback++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SDL_FALSE; // keep enumerating until all devices have been checked.
|
return false; // keep enumerating until all devices have been checked.
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_bool allow_playandrecord)
|
static bool UpdateAudioSession(SDL_AudioDevice *device, bool open, bool allow_playandrecord)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
AVAudioSession *session = [AVAudioSession sharedInstance];
|
AVAudioSession *session = [AVAudioSession sharedInstance];
|
||||||
|
@ -467,12 +467,12 @@ static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_b
|
||||||
// Stop the current session so we don't interrupt other application audio
|
// Stop the current session so we don't interrupt other application audio
|
||||||
PauseAudioDevices();
|
PauseAudioDevices();
|
||||||
[session setActive:NO error:nil];
|
[session setActive:NO error:nil];
|
||||||
session_active = SDL_FALSE;
|
session_active = false;
|
||||||
|
|
||||||
if (![session setCategory:category mode:mode options:options error:&err]) {
|
if (![session setCategory:category mode:mode options:options error:&err]) {
|
||||||
NSString *desc = err.description;
|
NSString *desc = err.description;
|
||||||
SDL_SetError("Could not set Audio Session category: %s", desc.UTF8String);
|
SDL_SetError("Could not set Audio Session category: %s", desc.UTF8String);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -480,12 +480,12 @@ static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_b
|
||||||
// Stop the current session so we don't interrupt other application audio
|
// Stop the current session so we don't interrupt other application audio
|
||||||
PauseAudioDevices();
|
PauseAudioDevices();
|
||||||
[session setActive:NO error:nil];
|
[session setActive:NO error:nil];
|
||||||
session_active = SDL_FALSE;
|
session_active = false;
|
||||||
|
|
||||||
if (![session setCategory:category error:&err]) {
|
if (![session setCategory:category error:&err]) {
|
||||||
NSString *desc = err.description;
|
NSString *desc = err.description;
|
||||||
SDL_SetError("Could not set Audio Session category: %s", desc.UTF8String);
|
SDL_SetError("Could not set Audio Session category: %s", desc.UTF8String);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -494,19 +494,19 @@ static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_b
|
||||||
if (![session setActive:YES error:&err]) {
|
if (![session setActive:YES error:&err]) {
|
||||||
if ([err code] == AVAudioSessionErrorCodeResourceNotAvailable &&
|
if ([err code] == AVAudioSessionErrorCodeResourceNotAvailable &&
|
||||||
category == AVAudioSessionCategoryPlayAndRecord) {
|
category == AVAudioSessionCategoryPlayAndRecord) {
|
||||||
return UpdateAudioSession(device, open, SDL_FALSE);
|
return UpdateAudioSession(device, open, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *desc = err.description;
|
NSString *desc = err.description;
|
||||||
SDL_SetError("Could not activate Audio Session: %s", desc.UTF8String);
|
SDL_SetError("Could not activate Audio Session: %s", desc.UTF8String);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
session_active = SDL_TRUE;
|
session_active = true;
|
||||||
ResumeAudioDevices();
|
ResumeAudioDevices();
|
||||||
} else if (!data.playback && !data.recording && session_active) {
|
} else if (!data.playback && !data.recording && session_active) {
|
||||||
PauseAudioDevices();
|
PauseAudioDevices();
|
||||||
[session setActive:NO error:nil];
|
[session setActive:NO error:nil];
|
||||||
session_active = SDL_FALSE;
|
session_active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (open) {
|
if (open) {
|
||||||
|
@ -543,7 +543,7 @@ static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -574,7 +574,7 @@ static void PlaybackBufferReadyCallback(void *inUserData, AudioQueueRef inAQ, Au
|
||||||
SDL_assert(inBuffer != NULL); // ...right?
|
SDL_assert(inBuffer != NULL); // ...right?
|
||||||
SDL_assert(device->hidden->current_buffer == NULL); // shouldn't have anything pending
|
SDL_assert(device->hidden->current_buffer == NULL); // shouldn't have anything pending
|
||||||
device->hidden->current_buffer = inBuffer;
|
device->hidden->current_buffer = inBuffer;
|
||||||
const SDL_bool okay = SDL_PlaybackAudioThreadIterate(device);
|
const bool okay = SDL_PlaybackAudioThreadIterate(device);
|
||||||
SDL_assert((device->hidden->current_buffer == NULL) || !okay); // PlayDevice should have enqueued and cleaned it out, unless we failed or shutdown.
|
SDL_assert((device->hidden->current_buffer == NULL) || !okay); // PlayDevice should have enqueued and cleaned it out, unless we failed or shutdown.
|
||||||
|
|
||||||
// buffer is unexpectedly here? We're probably dying, but try to requeue this buffer with silence.
|
// buffer is unexpectedly here? We're probably dying, but try to requeue this buffer with silence.
|
||||||
|
@ -646,7 +646,7 @@ static void COREAUDIO_CloseDevice(SDL_AudioDevice *device)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MACOSX_COREAUDIO
|
#ifndef MACOSX_COREAUDIO
|
||||||
UpdateAudioSession(device, SDL_FALSE, SDL_TRUE);
|
UpdateAudioSession(device, false, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (device->hidden->ready_semaphore) {
|
if (device->hidden->ready_semaphore) {
|
||||||
|
@ -722,7 +722,7 @@ static int AssignDeviceToAudioQueue(SDL_AudioDevice *device)
|
||||||
static int PrepareAudioQueue(SDL_AudioDevice *device)
|
static int PrepareAudioQueue(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
const AudioStreamBasicDescription *strdesc = &device->hidden->strdesc;
|
const AudioStreamBasicDescription *strdesc = &device->hidden->strdesc;
|
||||||
const SDL_bool recording = device->recording;
|
const bool recording = device->recording;
|
||||||
OSStatus result;
|
OSStatus result;
|
||||||
|
|
||||||
SDL_assert(CFRunLoopGetCurrent() != NULL);
|
SDL_assert(CFRunLoopGetCurrent() != NULL);
|
||||||
|
@ -864,7 +864,7 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MACOSX_COREAUDIO
|
#ifndef MACOSX_COREAUDIO
|
||||||
if (!UpdateAudioSession(device, SDL_TRUE, SDL_TRUE)) {
|
if (!UpdateAudioSession(device, true, true)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -975,7 +975,7 @@ static void COREAUDIO_DeinitializeStart(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool COREAUDIO_Init(SDL_AudioDriverImpl *impl)
|
static bool COREAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
impl->OpenDevice = COREAUDIO_OpenDevice;
|
impl->OpenDevice = COREAUDIO_OpenDevice;
|
||||||
impl->PlayDevice = COREAUDIO_PlayDevice;
|
impl->PlayDevice = COREAUDIO_PlayDevice;
|
||||||
|
@ -989,18 +989,18 @@ static SDL_bool COREAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->DetectDevices = COREAUDIO_DetectDevices;
|
impl->DetectDevices = COREAUDIO_DetectDevices;
|
||||||
impl->FreeDeviceHandle = COREAUDIO_FreeDeviceHandle;
|
impl->FreeDeviceHandle = COREAUDIO_FreeDeviceHandle;
|
||||||
#else
|
#else
|
||||||
impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE;
|
impl->OnlyHasDefaultPlaybackDevice = true;
|
||||||
impl->OnlyHasDefaultRecordingDevice = SDL_TRUE;
|
impl->OnlyHasDefaultRecordingDevice = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
impl->ProvidesOwnCallbackThread = SDL_TRUE;
|
impl->ProvidesOwnCallbackThread = true;
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap COREAUDIO_bootstrap = {
|
AudioBootStrap COREAUDIO_bootstrap = {
|
||||||
"coreaudio", "CoreAudio", COREAUDIO_Init, SDL_FALSE
|
"coreaudio", "CoreAudio", COREAUDIO_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_COREAUDIO
|
#endif // SDL_AUDIO_DRIVER_COREAUDIO
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
// For Vista+, we can enumerate DSound devices with IMMDevice
|
// For Vista+, we can enumerate DSound devices with IMMDevice
|
||||||
#ifdef HAVE_MMDEVICEAPI_H
|
#ifdef HAVE_MMDEVICEAPI_H
|
||||||
static SDL_bool SupportsIMMDevice = SDL_FALSE;
|
static bool SupportsIMMDevice = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// DirectX function pointers for audio
|
// DirectX function pointers for audio
|
||||||
|
@ -170,7 +170,7 @@ static void DSOUND_FreeDeviceHandle(SDL_AudioDevice *device)
|
||||||
// FindAllDevs is presumably only used on WinXP; Vista and later can use IMMDevice for better results.
|
// FindAllDevs is presumably only used on WinXP; Vista and later can use IMMDevice for better results.
|
||||||
typedef struct FindAllDevsData
|
typedef struct FindAllDevsData
|
||||||
{
|
{
|
||||||
SDL_bool recording;
|
bool recording;
|
||||||
SDL_AudioDevice **default_device;
|
SDL_AudioDevice **default_device;
|
||||||
LPCGUID default_device_guid;
|
LPCGUID default_device_guid;
|
||||||
} FindAllDevsData;
|
} FindAllDevsData;
|
||||||
|
@ -216,12 +216,12 @@ static void DSOUND_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDe
|
||||||
FindAllDevsData data;
|
FindAllDevsData data;
|
||||||
GUID guid;
|
GUID guid;
|
||||||
|
|
||||||
data.recording = SDL_TRUE;
|
data.recording = true;
|
||||||
data.default_device = default_recording;
|
data.default_device = default_recording;
|
||||||
data.default_device_guid = (pGetDeviceID(&SDL_DSDEVID_DefaultCapture, &guid) == DS_OK) ? &guid : NULL;
|
data.default_device_guid = (pGetDeviceID(&SDL_DSDEVID_DefaultCapture, &guid) == DS_OK) ? &guid : NULL;
|
||||||
pDirectSoundCaptureEnumerateW(FindAllDevs, &data);
|
pDirectSoundCaptureEnumerateW(FindAllDevs, &data);
|
||||||
|
|
||||||
data.recording = SDL_FALSE;
|
data.recording = false;
|
||||||
data.default_device = default_playback;
|
data.default_device = default_playback;
|
||||||
data.default_device_guid = (pGetDeviceID(&SDL_DSDEVID_DefaultPlayback, &guid) == DS_OK) ? &guid : NULL;
|
data.default_device_guid = (pGetDeviceID(&SDL_DSDEVID_DefaultPlayback, &guid) == DS_OK) ? &guid : NULL;
|
||||||
pDirectSoundEnumerateW(FindAllDevs, &data);
|
pDirectSoundEnumerateW(FindAllDevs, &data);
|
||||||
|
@ -533,7 +533,7 @@ static int DSOUND_OpenDevice(SDL_AudioDevice *device)
|
||||||
|
|
||||||
const DWORD numchunks = 8;
|
const DWORD numchunks = 8;
|
||||||
DWORD bufsize;
|
DWORD bufsize;
|
||||||
SDL_bool tried_format = SDL_FALSE;
|
bool tried_format = false;
|
||||||
SDL_AudioFormat test_format;
|
SDL_AudioFormat test_format;
|
||||||
const SDL_AudioFormat *closefmts = SDL_ClosestAudioFormats(device->spec.format);
|
const SDL_AudioFormat *closefmts = SDL_ClosestAudioFormats(device->spec.format);
|
||||||
while ((test_format = *(closefmts++)) != 0) {
|
while ((test_format = *(closefmts++)) != 0) {
|
||||||
|
@ -542,7 +542,7 @@ static int DSOUND_OpenDevice(SDL_AudioDevice *device)
|
||||||
case SDL_AUDIO_S16:
|
case SDL_AUDIO_S16:
|
||||||
case SDL_AUDIO_S32:
|
case SDL_AUDIO_S32:
|
||||||
case SDL_AUDIO_F32:
|
case SDL_AUDIO_F32:
|
||||||
tried_format = SDL_TRUE;
|
tried_format = true;
|
||||||
|
|
||||||
device->spec.format = test_format;
|
device->spec.format = test_format;
|
||||||
|
|
||||||
|
@ -641,14 +641,14 @@ static void DSOUND_Deinitialize(void)
|
||||||
{
|
{
|
||||||
DSOUND_Unload();
|
DSOUND_Unload();
|
||||||
#ifdef HAVE_MMDEVICEAPI_H
|
#ifdef HAVE_MMDEVICEAPI_H
|
||||||
SupportsIMMDevice = SDL_FALSE;
|
SupportsIMMDevice = false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool DSOUND_Init(SDL_AudioDriverImpl *impl)
|
static bool DSOUND_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
if (!DSOUND_Load()) {
|
if (!DSOUND_Load()) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_MMDEVICEAPI_H
|
#ifdef HAVE_MMDEVICEAPI_H
|
||||||
|
@ -668,13 +668,13 @@ static SDL_bool DSOUND_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->DeinitializeStart = DSOUND_DeinitializeStart;
|
impl->DeinitializeStart = DSOUND_DeinitializeStart;
|
||||||
impl->Deinitialize = DSOUND_Deinitialize;
|
impl->Deinitialize = DSOUND_Deinitialize;
|
||||||
|
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap DSOUND_bootstrap = {
|
AudioBootStrap DSOUND_bootstrap = {
|
||||||
"directsound", "DirectSound", DSOUND_Init, SDL_FALSE
|
"directsound", "DirectSound", DSOUND_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_DSOUND
|
#endif // SDL_AUDIO_DRIVER_DSOUND
|
||||||
|
|
|
@ -91,7 +91,7 @@ static void DISKAUDIO_CloseDevice(SDL_AudioDevice *device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *get_filename(const SDL_bool recording)
|
static const char *get_filename(const bool recording)
|
||||||
{
|
{
|
||||||
const char *devname = SDL_GetHint(recording ? SDL_HINT_AUDIO_DISK_INPUT_FILE : SDL_HINT_AUDIO_DISK_OUTPUT_FILE);
|
const char *devname = SDL_GetHint(recording ? SDL_HINT_AUDIO_DISK_INPUT_FILE : SDL_HINT_AUDIO_DISK_OUTPUT_FILE);
|
||||||
if (!devname) {
|
if (!devname) {
|
||||||
|
@ -102,7 +102,7 @@ static const char *get_filename(const SDL_bool recording)
|
||||||
|
|
||||||
static int DISKAUDIO_OpenDevice(SDL_AudioDevice *device)
|
static int DISKAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
SDL_bool recording = device->recording;
|
bool recording = device->recording;
|
||||||
const char *fname = get_filename(recording);
|
const char *fname = get_filename(recording);
|
||||||
|
|
||||||
device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
|
device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
|
||||||
|
@ -143,11 +143,11 @@ static int DISKAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||||
|
|
||||||
static void DISKAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
static void DISKAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
||||||
{
|
{
|
||||||
*default_playback = SDL_AddAudioDevice(SDL_FALSE, DEFAULT_PLAYBACK_DEVNAME, NULL, (void *)0x1);
|
*default_playback = SDL_AddAudioDevice(false, DEFAULT_PLAYBACK_DEVNAME, NULL, (void *)0x1);
|
||||||
*default_recording = SDL_AddAudioDevice(SDL_TRUE, DEFAULT_RECORDING_DEVNAME, NULL, (void *)0x2);
|
*default_recording = SDL_AddAudioDevice(true, DEFAULT_RECORDING_DEVNAME, NULL, (void *)0x2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool DISKAUDIO_Init(SDL_AudioDriverImpl *impl)
|
static bool DISKAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
impl->OpenDevice = DISKAUDIO_OpenDevice;
|
impl->OpenDevice = DISKAUDIO_OpenDevice;
|
||||||
impl->WaitDevice = DISKAUDIO_WaitDevice;
|
impl->WaitDevice = DISKAUDIO_WaitDevice;
|
||||||
|
@ -159,13 +159,13 @@ static SDL_bool DISKAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->CloseDevice = DISKAUDIO_CloseDevice;
|
impl->CloseDevice = DISKAUDIO_CloseDevice;
|
||||||
impl->DetectDevices = DISKAUDIO_DetectDevices;
|
impl->DetectDevices = DISKAUDIO_DetectDevices;
|
||||||
|
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap DISKAUDIO_bootstrap = {
|
AudioBootStrap DISKAUDIO_bootstrap = {
|
||||||
"disk", "direct-to-disk audio", DISKAUDIO_Init, SDL_TRUE
|
"disk", "direct-to-disk audio", DISKAUDIO_Init, true
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_DISK
|
#endif // SDL_AUDIO_DRIVER_DISK
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
static void DSP_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
static void DSP_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
||||||
{
|
{
|
||||||
SDL_EnumUnixAudioDevices(SDL_FALSE, NULL);
|
SDL_EnumUnixAudioDevices(false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DSP_CloseDevice(SDL_AudioDevice *device)
|
static void DSP_CloseDevice(SDL_AudioDevice *device)
|
||||||
|
@ -264,21 +264,21 @@ static void DSP_FlushRecording(SDL_AudioDevice *device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool InitTimeDevicesExist = SDL_FALSE;
|
static bool InitTimeDevicesExist = false;
|
||||||
static SDL_bool look_for_devices_test(int fd)
|
static bool look_for_devices_test(int fd)
|
||||||
{
|
{
|
||||||
InitTimeDevicesExist = SDL_TRUE; // note that _something_ exists.
|
InitTimeDevicesExist = true; // note that _something_ exists.
|
||||||
// Don't add to the device list, we're just seeing if any devices exist.
|
// Don't add to the device list, we're just seeing if any devices exist.
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool DSP_Init(SDL_AudioDriverImpl *impl)
|
static bool DSP_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
InitTimeDevicesExist = SDL_FALSE;
|
InitTimeDevicesExist = false;
|
||||||
SDL_EnumUnixAudioDevices(SDL_FALSE, look_for_devices_test);
|
SDL_EnumUnixAudioDevices(false, look_for_devices_test);
|
||||||
if (!InitTimeDevicesExist) {
|
if (!InitTimeDevicesExist) {
|
||||||
SDL_SetError("dsp: No such audio device");
|
SDL_SetError("dsp: No such audio device");
|
||||||
return SDL_FALSE; // maybe try a different backend.
|
return false; // maybe try a different backend.
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->DetectDevices = DSP_DetectDevices;
|
impl->DetectDevices = DSP_DetectDevices;
|
||||||
|
@ -291,13 +291,13 @@ static SDL_bool DSP_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->RecordDevice = DSP_RecordDevice;
|
impl->RecordDevice = DSP_RecordDevice;
|
||||||
impl->FlushRecording = DSP_FlushRecording;
|
impl->FlushRecording = DSP_FlushRecording;
|
||||||
|
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap DSP_bootstrap = {
|
AudioBootStrap DSP_bootstrap = {
|
||||||
"dsp", "Open Sound System (/dev/dsp)", DSP_Init, SDL_FALSE
|
"dsp", "Open Sound System (/dev/dsp)", DSP_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_OSS
|
#endif // SDL_AUDIO_DRIVER_OSS
|
||||||
|
|
|
@ -78,7 +78,7 @@ static int DUMMYAUDIO_RecordDevice(SDL_AudioDevice *device, void *buffer, int bu
|
||||||
return buflen;
|
return buflen;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool DUMMYAUDIO_Init(SDL_AudioDriverImpl *impl)
|
static bool DUMMYAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
impl->OpenDevice = DUMMYAUDIO_OpenDevice;
|
impl->OpenDevice = DUMMYAUDIO_OpenDevice;
|
||||||
impl->CloseDevice = DUMMYAUDIO_CloseDevice;
|
impl->CloseDevice = DUMMYAUDIO_CloseDevice;
|
||||||
|
@ -87,13 +87,13 @@ static SDL_bool DUMMYAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->WaitRecordingDevice = DUMMYAUDIO_WaitDevice;
|
impl->WaitRecordingDevice = DUMMYAUDIO_WaitDevice;
|
||||||
impl->RecordDevice = DUMMYAUDIO_RecordDevice;
|
impl->RecordDevice = DUMMYAUDIO_RecordDevice;
|
||||||
|
|
||||||
impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE;
|
impl->OnlyHasDefaultPlaybackDevice = true;
|
||||||
impl->OnlyHasDefaultRecordingDevice = SDL_TRUE;
|
impl->OnlyHasDefaultRecordingDevice = true;
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap DUMMYAUDIO_bootstrap = {
|
AudioBootStrap DUMMYAUDIO_bootstrap = {
|
||||||
"dummy", "SDL dummy audio driver", DUMMYAUDIO_Init, SDL_TRUE
|
"dummy", "SDL dummy audio driver", DUMMYAUDIO_Init, true
|
||||||
};
|
};
|
||||||
|
|
|
@ -297,9 +297,9 @@ static int EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl *impl)
|
static bool EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
SDL_bool available, recording_available;
|
bool available, recording_available;
|
||||||
|
|
||||||
impl->OpenDevice = EMSCRIPTENAUDIO_OpenDevice;
|
impl->OpenDevice = EMSCRIPTENAUDIO_OpenDevice;
|
||||||
impl->CloseDevice = EMSCRIPTENAUDIO_CloseDevice;
|
impl->CloseDevice = EMSCRIPTENAUDIO_CloseDevice;
|
||||||
|
@ -308,10 +308,10 @@ static SDL_bool EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->FlushRecording = EMSCRIPTENAUDIO_FlushRecording;
|
impl->FlushRecording = EMSCRIPTENAUDIO_FlushRecording;
|
||||||
impl->RecordDevice = EMSCRIPTENAUDIO_RecordDevice;
|
impl->RecordDevice = EMSCRIPTENAUDIO_RecordDevice;
|
||||||
|
|
||||||
impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE;
|
impl->OnlyHasDefaultPlaybackDevice = true;
|
||||||
|
|
||||||
// technically, this is just runs in idle time in the main thread, but it's close enough to a "thread" for our purposes.
|
// technically, this is just runs in idle time in the main thread, but it's close enough to a "thread" for our purposes.
|
||||||
impl->ProvidesOwnCallbackThread = SDL_TRUE;
|
impl->ProvidesOwnCallbackThread = true;
|
||||||
|
|
||||||
// check availability
|
// check availability
|
||||||
available = MAIN_THREAD_EM_ASM_INT({
|
available = MAIN_THREAD_EM_ASM_INT({
|
||||||
|
@ -343,7 +343,7 @@ static SDL_bool EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap EMSCRIPTENAUDIO_bootstrap = {
|
AudioBootStrap EMSCRIPTENAUDIO_bootstrap = {
|
||||||
"emscripten", "SDL emscripten audio driver", EMSCRIPTENAUDIO_Init, SDL_FALSE
|
"emscripten", "SDL emscripten audio driver", EMSCRIPTENAUDIO_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
/* *INDENT-ON* */ // clang-format on
|
/* *INDENT-ON* */ // clang-format on
|
||||||
|
|
|
@ -194,10 +194,10 @@ static void HAIKUAUDIO_Deinitialize(void)
|
||||||
SDL_QuitBeApp();
|
SDL_QuitBeApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool HAIKUAUDIO_Init(SDL_AudioDriverImpl *impl)
|
static bool HAIKUAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
if (SDL_InitBeApp() < 0) {
|
if (SDL_InitBeApp() < 0) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the function pointers
|
// Set the function pointers
|
||||||
|
@ -206,17 +206,17 @@ static SDL_bool HAIKUAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->PlayDevice = HAIKUAUDIO_PlayDevice;
|
impl->PlayDevice = HAIKUAUDIO_PlayDevice;
|
||||||
impl->CloseDevice = HAIKUAUDIO_CloseDevice;
|
impl->CloseDevice = HAIKUAUDIO_CloseDevice;
|
||||||
impl->Deinitialize = HAIKUAUDIO_Deinitialize;
|
impl->Deinitialize = HAIKUAUDIO_Deinitialize;
|
||||||
impl->ProvidesOwnCallbackThread = SDL_TRUE;
|
impl->ProvidesOwnCallbackThread = true;
|
||||||
impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE;
|
impl->OnlyHasDefaultPlaybackDevice = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" { extern AudioBootStrap HAIKUAUDIO_bootstrap; }
|
extern "C" { extern AudioBootStrap HAIKUAUDIO_bootstrap; }
|
||||||
|
|
||||||
AudioBootStrap HAIKUAUDIO_bootstrap = {
|
AudioBootStrap HAIKUAUDIO_bootstrap = {
|
||||||
"haiku", "Haiku BSoundPlayer", HAIKUAUDIO_Init, SDL_FALSE
|
"haiku", "Haiku BSoundPlayer", HAIKUAUDIO_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_HAIKU
|
#endif // SDL_AUDIO_DRIVER_HAIKU
|
||||||
|
|
|
@ -273,7 +273,7 @@ static int JACK_OpenDevice(SDL_AudioDevice *device)
|
||||||
data to us) and "input" for playback (we input audio data to them).
|
data to us) and "input" for playback (we input audio data to them).
|
||||||
Likewise, SDL's playback port will be "output" (we write data out)
|
Likewise, SDL's playback port will be "output" (we write data out)
|
||||||
and recording will be "input" (we read data in). */
|
and recording will be "input" (we read data in). */
|
||||||
const SDL_bool recording = device->recording;
|
const bool recording = device->recording;
|
||||||
const unsigned long sysportflags = recording ? JackPortIsOutput : JackPortIsInput;
|
const unsigned long sysportflags = recording ? JackPortIsOutput : JackPortIsInput;
|
||||||
const unsigned long sdlportflags = recording ? JackPortIsInput : JackPortIsOutput;
|
const unsigned long sdlportflags = recording ? JackPortIsInput : JackPortIsOutput;
|
||||||
const JackProcessCallback callback = recording ? jackProcessRecordingCallback : jackProcessPlaybackCallback;
|
const JackProcessCallback callback = recording ? jackProcessRecordingCallback : jackProcessPlaybackCallback;
|
||||||
|
@ -398,10 +398,10 @@ static void JACK_Deinitialize(void)
|
||||||
UnloadJackLibrary();
|
UnloadJackLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl)
|
static bool JACK_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
if (LoadJackLibrary() < 0) {
|
if (LoadJackLibrary() < 0) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// Make sure a JACK server is running and available.
|
// Make sure a JACK server is running and available.
|
||||||
jack_status_t status;
|
jack_status_t status;
|
||||||
|
@ -409,7 +409,7 @@ static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl)
|
||||||
if (!client) {
|
if (!client) {
|
||||||
UnloadJackLibrary();
|
UnloadJackLibrary();
|
||||||
SDL_SetError("Can't open JACK client");
|
SDL_SetError("Can't open JACK client");
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
JACK_jack_client_close(client);
|
JACK_jack_client_close(client);
|
||||||
}
|
}
|
||||||
|
@ -421,16 +421,16 @@ static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->Deinitialize = JACK_Deinitialize;
|
impl->Deinitialize = JACK_Deinitialize;
|
||||||
impl->RecordDevice = JACK_RecordDevice;
|
impl->RecordDevice = JACK_RecordDevice;
|
||||||
impl->FlushRecording = JACK_FlushRecording;
|
impl->FlushRecording = JACK_FlushRecording;
|
||||||
impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE;
|
impl->OnlyHasDefaultPlaybackDevice = true;
|
||||||
impl->OnlyHasDefaultRecordingDevice = SDL_TRUE;
|
impl->OnlyHasDefaultRecordingDevice = true;
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
impl->ProvidesOwnCallbackThread = SDL_TRUE;
|
impl->ProvidesOwnCallbackThread = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap JACK_bootstrap = {
|
AudioBootStrap JACK_bootstrap = {
|
||||||
"jack", "JACK Audio Connection Kit", JACK_Init, SDL_FALSE
|
"jack", "JACK Audio Connection Kit", JACK_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_JACK
|
#endif // SDL_AUDIO_DRIVER_JACK
|
||||||
|
|
|
@ -47,7 +47,7 @@ static void N3DSAUD_DspHook(DSP_HookType hook)
|
||||||
{
|
{
|
||||||
if (hook == DSPHOOK_ONCANCEL) {
|
if (hook == DSPHOOK_ONCANCEL) {
|
||||||
contextLock(audio_device);
|
contextLock(audio_device);
|
||||||
audio_device->hidden->isCancelled = SDL_TRUE;
|
audio_device->hidden->isCancelled = true;
|
||||||
SDL_AudioDeviceDisconnected(audio_device);
|
SDL_AudioDeviceDisconnected(audio_device);
|
||||||
CondVar_Broadcast(&audio_device->hidden->cv);
|
CondVar_Broadcast(&audio_device->hidden->cv);
|
||||||
contextUnlock(audio_device);
|
contextUnlock(audio_device);
|
||||||
|
@ -65,7 +65,7 @@ static void AudioFrameFinished(void *vdevice)
|
||||||
for (i = 0; i < NUM_BUFFERS; i++) {
|
for (i = 0; i < NUM_BUFFERS; i++) {
|
||||||
if (device->hidden->waveBuf[i].status == NDSP_WBUF_DONE) {
|
if (device->hidden->waveBuf[i].status == NDSP_WBUF_DONE) {
|
||||||
device->hidden->waveBuf[i].status = NDSP_WBUF_FREE;
|
device->hidden->waveBuf[i].status = NDSP_WBUF_FREE;
|
||||||
shouldBroadcast = SDL_TRUE;
|
shouldBroadcast = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ static void N3DSAUDIO_ThreadInit(SDL_AudioDevice *device)
|
||||||
svcSetThreadPriority(CUR_THREAD_HANDLE, current_priority);
|
svcSetThreadPriority(CUR_THREAD_HANDLE, current_priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool N3DSAUDIO_Init(SDL_AudioDriverImpl *impl)
|
static bool N3DSAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
impl->OpenDevice = N3DSAUDIO_OpenDevice;
|
impl->OpenDevice = N3DSAUDIO_OpenDevice;
|
||||||
impl->PlayDevice = N3DSAUDIO_PlayDevice;
|
impl->PlayDevice = N3DSAUDIO_PlayDevice;
|
||||||
|
@ -269,12 +269,12 @@ static SDL_bool N3DSAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->GetDeviceBuf = N3DSAUDIO_GetDeviceBuf;
|
impl->GetDeviceBuf = N3DSAUDIO_GetDeviceBuf;
|
||||||
impl->CloseDevice = N3DSAUDIO_CloseDevice;
|
impl->CloseDevice = N3DSAUDIO_CloseDevice;
|
||||||
impl->ThreadInit = N3DSAUDIO_ThreadInit;
|
impl->ThreadInit = N3DSAUDIO_ThreadInit;
|
||||||
impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE;
|
impl->OnlyHasDefaultPlaybackDevice = true;
|
||||||
|
|
||||||
// Should be possible, but micInit would fail
|
// Should be possible, but micInit would fail
|
||||||
impl->HasRecordingSupport = SDL_FALSE;
|
impl->HasRecordingSupport = false;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap N3DSAUDIO_bootstrap = {
|
AudioBootStrap N3DSAUDIO_bootstrap = {
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct SDL_PrivateAudioData
|
||||||
ndspWaveBuf waveBuf[NUM_BUFFERS];
|
ndspWaveBuf waveBuf[NUM_BUFFERS];
|
||||||
LightLock lock;
|
LightLock lock;
|
||||||
CondVar cv;
|
CondVar cv;
|
||||||
SDL_bool isCancelled;
|
bool isCancelled;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_n3dsaudio_h
|
#endif // SDL_n3dsaudio_h
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
static void NETBSDAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
static void NETBSDAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
||||||
{
|
{
|
||||||
SDL_EnumUnixAudioDevices(SDL_FALSE, NULL);
|
SDL_EnumUnixAudioDevices(false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void NETBSDAUDIO_Status(SDL_AudioDevice *device)
|
static void NETBSDAUDIO_Status(SDL_AudioDevice *device)
|
||||||
|
@ -116,7 +116,7 @@ static void NETBSDAUDIO_Status(SDL_AudioDevice *device)
|
||||||
|
|
||||||
static int NETBSDAUDIO_WaitDevice(SDL_AudioDevice *device)
|
static int NETBSDAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
const SDL_bool recording = device->recording;
|
const bool recording = device->recording;
|
||||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||||
audio_info_t info;
|
audio_info_t info;
|
||||||
const int rc = ioctl(device->hidden->audio_fd, AUDIO_GETINFO, &info);
|
const int rc = ioctl(device->hidden->audio_fd, AUDIO_GETINFO, &info);
|
||||||
|
@ -208,7 +208,7 @@ static void NETBSDAUDIO_CloseDevice(SDL_AudioDevice *device)
|
||||||
|
|
||||||
static int NETBSDAUDIO_OpenDevice(SDL_AudioDevice *device)
|
static int NETBSDAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
const SDL_bool recording = device->recording;
|
const bool recording = device->recording;
|
||||||
int encoding = AUDIO_ENCODING_NONE;
|
int encoding = AUDIO_ENCODING_NONE;
|
||||||
audio_info_t info, hwinfo;
|
audio_info_t info, hwinfo;
|
||||||
struct audio_prinfo *prinfo = recording ? &info.record : &info.play;
|
struct audio_prinfo *prinfo = recording ? &info.record : &info.play;
|
||||||
|
@ -304,7 +304,7 @@ static int NETBSDAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||||
return 0; // We're ready to rock and roll. :-)
|
return 0; // We're ready to rock and roll. :-)
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool NETBSDAUDIO_Init(SDL_AudioDriverImpl *impl)
|
static bool NETBSDAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
impl->DetectDevices = NETBSDAUDIO_DetectDevices;
|
impl->DetectDevices = NETBSDAUDIO_DetectDevices;
|
||||||
impl->OpenDevice = NETBSDAUDIO_OpenDevice;
|
impl->OpenDevice = NETBSDAUDIO_OpenDevice;
|
||||||
|
@ -316,13 +316,13 @@ static SDL_bool NETBSDAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->RecordDevice = NETBSDAUDIO_RecordDevice;
|
impl->RecordDevice = NETBSDAUDIO_RecordDevice;
|
||||||
impl->FlushRecording = NETBSDAUDIO_FlushRecording;
|
impl->FlushRecording = NETBSDAUDIO_FlushRecording;
|
||||||
|
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap NETBSDAUDIO_bootstrap = {
|
AudioBootStrap NETBSDAUDIO_bootstrap = {
|
||||||
"netbsd", "NetBSD audio", NETBSDAUDIO_Init, SDL_FALSE
|
"netbsd", "NetBSD audio", NETBSDAUDIO_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_NETBSD
|
#endif // SDL_AUDIO_DRIVER_NETBSD
|
||||||
|
|
|
@ -750,12 +750,12 @@ static void OPENSLES_CloseDevice(SDL_AudioDevice *device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool OPENSLES_Init(SDL_AudioDriverImpl *impl)
|
static bool OPENSLES_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
LOGI("OPENSLES_Init() called");
|
LOGI("OPENSLES_Init() called");
|
||||||
|
|
||||||
if (!OPENSLES_CreateEngine()) {
|
if (!OPENSLES_CreateEngine()) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGI("OPENSLES_Init() - set pointers");
|
LOGI("OPENSLES_Init() - set pointers");
|
||||||
|
@ -773,18 +773,18 @@ static SDL_bool OPENSLES_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->Deinitialize = OPENSLES_DestroyEngine;
|
impl->Deinitialize = OPENSLES_DestroyEngine;
|
||||||
|
|
||||||
// and the capabilities
|
// and the capabilities
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE;
|
impl->OnlyHasDefaultPlaybackDevice = true;
|
||||||
impl->OnlyHasDefaultRecordingDevice = SDL_TRUE;
|
impl->OnlyHasDefaultRecordingDevice = true;
|
||||||
|
|
||||||
LOGI("OPENSLES_Init() - success");
|
LOGI("OPENSLES_Init() - success");
|
||||||
|
|
||||||
// this audio target is available.
|
// this audio target is available.
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap OPENSLES_bootstrap = {
|
AudioBootStrap OPENSLES_bootstrap = {
|
||||||
"openslES", "OpenSL ES audio driver", OPENSLES_Init, SDL_FALSE
|
"openslES", "OpenSL ES audio driver", OPENSLES_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
void OPENSLES_ResumeDevices(void)
|
void OPENSLES_ResumeDevices(void)
|
||||||
|
|
|
@ -50,7 +50,7 @@ enum PW_READY_FLAGS
|
||||||
#define PW_ID_TO_HANDLE(x) (void *)((uintptr_t)x)
|
#define PW_ID_TO_HANDLE(x) (void *)((uintptr_t)x)
|
||||||
#define PW_HANDLE_TO_ID(x) (uint32_t)((uintptr_t)x)
|
#define PW_HANDLE_TO_ID(x) (uint32_t)((uintptr_t)x)
|
||||||
|
|
||||||
static SDL_bool pipewire_initialized = SDL_FALSE;
|
static bool pipewire_initialized = false;
|
||||||
|
|
||||||
// Pipewire entry points
|
// Pipewire entry points
|
||||||
static const char *(*PIPEWIRE_pw_get_library_version)(void);
|
static const char *(*PIPEWIRE_pw_get_library_version)(void);
|
||||||
|
@ -204,7 +204,7 @@ struct node_object
|
||||||
|
|
||||||
Uint32 id;
|
Uint32 id;
|
||||||
int seq;
|
int seq;
|
||||||
SDL_bool persist;
|
bool persist;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: If used, this is *must* be allocated with SDL_malloc() or similar
|
* NOTE: If used, this is *must* be allocated with SDL_malloc() or similar
|
||||||
|
@ -226,7 +226,7 @@ struct io_node
|
||||||
struct spa_list link;
|
struct spa_list link;
|
||||||
|
|
||||||
Uint32 id;
|
Uint32 id;
|
||||||
SDL_bool recording;
|
bool recording;
|
||||||
SDL_AudioSpec spec;
|
SDL_AudioSpec spec;
|
||||||
|
|
||||||
const char *name; // Friendly name
|
const char *name; // Friendly name
|
||||||
|
@ -245,8 +245,8 @@ static struct spa_hook hotplug_core_listener;
|
||||||
static struct spa_list hotplug_pending_list;
|
static struct spa_list hotplug_pending_list;
|
||||||
static struct spa_list hotplug_io_list;
|
static struct spa_list hotplug_io_list;
|
||||||
static int hotplug_init_seq_val;
|
static int hotplug_init_seq_val;
|
||||||
static SDL_bool hotplug_init_complete;
|
static bool hotplug_init_complete;
|
||||||
static SDL_bool hotplug_events_enabled;
|
static bool hotplug_events_enabled;
|
||||||
|
|
||||||
static int pipewire_version_major;
|
static int pipewire_version_major;
|
||||||
static int pipewire_version_minor;
|
static int pipewire_version_minor;
|
||||||
|
@ -254,7 +254,7 @@ static int pipewire_version_patch;
|
||||||
static char *pipewire_default_sink_id = NULL;
|
static char *pipewire_default_sink_id = NULL;
|
||||||
static char *pipewire_default_source_id = NULL;
|
static char *pipewire_default_source_id = NULL;
|
||||||
|
|
||||||
static SDL_bool pipewire_core_version_at_least(int major, int minor, int patch)
|
static bool pipewire_core_version_at_least(int major, int minor, int patch)
|
||||||
{
|
{
|
||||||
return (pipewire_version_major >= major) &&
|
return (pipewire_version_major >= major) &&
|
||||||
(pipewire_version_major > major || pipewire_version_minor >= minor) &&
|
(pipewire_version_major > major || pipewire_version_minor >= minor) &&
|
||||||
|
@ -262,15 +262,15 @@ static SDL_bool pipewire_core_version_at_least(int major, int minor, int patch)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The active node list
|
// The active node list
|
||||||
static SDL_bool io_list_check_add(struct io_node *node)
|
static bool io_list_check_add(struct io_node *node)
|
||||||
{
|
{
|
||||||
struct io_node *n;
|
struct io_node *n;
|
||||||
SDL_bool ret = SDL_TRUE;
|
bool ret = true;
|
||||||
|
|
||||||
// See if the node is already in the list
|
// See if the node is already in the list
|
||||||
spa_list_for_each (n, &hotplug_io_list, link) {
|
spa_list_for_each (n, &hotplug_io_list, link) {
|
||||||
if (n->id == node->id) {
|
if (n->id == node->id) {
|
||||||
ret = SDL_FALSE;
|
ret = false;
|
||||||
goto dup_found;
|
goto dup_found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,7 +402,7 @@ static void core_events_hotplug_init_callback(void *object, uint32_t id, int seq
|
||||||
spa_hook_remove(&hotplug_core_listener);
|
spa_hook_remove(&hotplug_core_listener);
|
||||||
|
|
||||||
// Signal that the initial I/O list is populated
|
// Signal that the initial I/O list is populated
|
||||||
hotplug_init_complete = SDL_TRUE;
|
hotplug_init_complete = true;
|
||||||
PIPEWIRE_pw_thread_loop_signal(hotplug_loop, false);
|
PIPEWIRE_pw_thread_loop_signal(hotplug_loop, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,7 @@ static void hotplug_core_sync(struct node_object *node)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helpers for retrieving values from params
|
// Helpers for retrieving values from params
|
||||||
static SDL_bool get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max)
|
static bool get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max)
|
||||||
{
|
{
|
||||||
const struct spa_pod_prop *prop;
|
const struct spa_pod_prop *prop;
|
||||||
struct spa_pod *value;
|
struct spa_pod *value;
|
||||||
|
@ -488,15 +488,15 @@ static SDL_bool get_range_param(const struct spa_pod *param, Uint32 key, int *de
|
||||||
*max = (int)v[2];
|
*max = (int)v[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool get_int_param(const struct spa_pod *param, Uint32 key, int *val)
|
static bool get_int_param(const struct spa_pod *param, Uint32 key, int *val)
|
||||||
{
|
{
|
||||||
const struct spa_pod_prop *prop;
|
const struct spa_pod_prop *prop;
|
||||||
Sint32 v;
|
Sint32 v;
|
||||||
|
@ -508,10 +508,10 @@ static SDL_bool get_int_param(const struct spa_pod *param, Uint32 key, int *val)
|
||||||
*val = (int)v;
|
*val = (int)v;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interface node callbacks
|
// Interface node callbacks
|
||||||
|
@ -607,14 +607,14 @@ static int metadata_property(void *object, Uint32 subject, const char *key, cons
|
||||||
SDL_free(pipewire_default_sink_id);
|
SDL_free(pipewire_default_sink_id);
|
||||||
}
|
}
|
||||||
pipewire_default_sink_id = get_name_from_json(value);
|
pipewire_default_sink_id = get_name_from_json(value);
|
||||||
node->persist = SDL_TRUE;
|
node->persist = true;
|
||||||
change_default_device(pipewire_default_sink_id);
|
change_default_device(pipewire_default_sink_id);
|
||||||
} else if (!SDL_strcmp(key, "default.audio.source")) {
|
} else if (!SDL_strcmp(key, "default.audio.source")) {
|
||||||
if (pipewire_default_source_id) {
|
if (pipewire_default_source_id) {
|
||||||
SDL_free(pipewire_default_source_id);
|
SDL_free(pipewire_default_source_id);
|
||||||
}
|
}
|
||||||
pipewire_default_source_id = get_name_from_json(value);
|
pipewire_default_source_id = get_name_from_json(value);
|
||||||
node->persist = SDL_TRUE;
|
node->persist = true;
|
||||||
change_default_device(pipewire_default_source_id);
|
change_default_device(pipewire_default_source_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -638,15 +638,15 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p
|
||||||
const char *node_desc;
|
const char *node_desc;
|
||||||
const char *node_path;
|
const char *node_path;
|
||||||
struct io_node *io;
|
struct io_node *io;
|
||||||
SDL_bool recording;
|
bool recording;
|
||||||
int desc_buffer_len;
|
int desc_buffer_len;
|
||||||
int path_buffer_len;
|
int path_buffer_len;
|
||||||
|
|
||||||
// Just want sink and source
|
// Just want sink and source
|
||||||
if (!SDL_strcasecmp(media_class, "Audio/Sink")) {
|
if (!SDL_strcasecmp(media_class, "Audio/Sink")) {
|
||||||
recording = SDL_FALSE;
|
recording = false;
|
||||||
} else if (!SDL_strcasecmp(media_class, "Audio/Source")) {
|
} else if (!SDL_strcasecmp(media_class, "Audio/Source")) {
|
||||||
recording = SDL_TRUE;
|
recording = true;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -757,8 +757,8 @@ static void hotplug_loop_destroy(void)
|
||||||
pending_list_clear();
|
pending_list_clear();
|
||||||
io_list_clear();
|
io_list_clear();
|
||||||
|
|
||||||
hotplug_init_complete = SDL_FALSE;
|
hotplug_init_complete = false;
|
||||||
hotplug_events_enabled = SDL_FALSE;
|
hotplug_events_enabled = false;
|
||||||
|
|
||||||
if (pipewire_default_sink_id) {
|
if (pipewire_default_sink_id) {
|
||||||
SDL_free(pipewire_default_sink_id);
|
SDL_free(pipewire_default_sink_id);
|
||||||
|
@ -814,7 +814,7 @@ static void PIPEWIRE_DetectDevices(SDL_AudioDevice **default_playback, SDL_Audio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hotplug_events_enabled = SDL_TRUE;
|
hotplug_events_enabled = true;
|
||||||
|
|
||||||
PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
|
PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
|
||||||
}
|
}
|
||||||
|
@ -901,7 +901,7 @@ static void initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info
|
||||||
|
|
||||||
static Uint8 *PIPEWIRE_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
static Uint8 *PIPEWIRE_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||||
{
|
{
|
||||||
// See if a buffer is available. If this returns NULL, SDL_PlaybackAudioThreadIterate will return SDL_FALSE, but since we own the thread, it won't kill playback.
|
// See if a buffer is available. If this returns NULL, SDL_PlaybackAudioThreadIterate will return false, but since we own the thread, it won't kill playback.
|
||||||
// !!! FIXME: It's not clear to me if this ever returns NULL or if this was just defensive coding.
|
// !!! FIXME: It's not clear to me if this ever returns NULL or if this was just defensive coding.
|
||||||
|
|
||||||
struct pw_stream *stream = device->hidden->stream;
|
struct pw_stream *stream = device->hidden->stream;
|
||||||
|
@ -985,7 +985,7 @@ static void stream_add_buffer_callback(void *data, struct pw_buffer *buffer)
|
||||||
{
|
{
|
||||||
SDL_AudioDevice *device = (SDL_AudioDevice *) data;
|
SDL_AudioDevice *device = (SDL_AudioDevice *) data;
|
||||||
|
|
||||||
if (device->recording == SDL_FALSE) {
|
if (device->recording == false) {
|
||||||
/* Clamp the output spec samples and size to the max size of the Pipewire buffer.
|
/* Clamp the output spec samples and size to the max size of the Pipewire buffer.
|
||||||
If they exceed the maximum size of the Pipewire buffer, double buffering will be used. */
|
If they exceed the maximum size of the Pipewire buffer, double buffering will be used. */
|
||||||
if (device->buffer_size > buffer->buffer->datas[0].maxsize) {
|
if (device->buffer_size > buffer->buffer->datas[0].maxsize) {
|
||||||
|
@ -1042,7 +1042,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device)
|
||||||
struct pw_properties *props;
|
struct pw_properties *props;
|
||||||
const char *app_name, *icon_name, *app_id, *stream_name, *stream_role, *error;
|
const char *app_name, *icon_name, *app_id, *stream_name, *stream_role, *error;
|
||||||
Uint32 node_id = !device->handle ? PW_ID_ANY : PW_HANDLE_TO_ID(device->handle);
|
Uint32 node_id = !device->handle ? PW_ID_ANY : PW_HANDLE_TO_ID(device->handle);
|
||||||
const SDL_bool recording = device->recording;
|
const bool recording = device->recording;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
// Clamp the period size to sane values
|
// Clamp the period size to sane values
|
||||||
|
@ -1214,23 +1214,23 @@ static void PIPEWIRE_Deinitialize(void)
|
||||||
{
|
{
|
||||||
if (pipewire_initialized) {
|
if (pipewire_initialized) {
|
||||||
deinit_pipewire_library();
|
deinit_pipewire_library();
|
||||||
pipewire_initialized = SDL_FALSE;
|
pipewire_initialized = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool PipewireInitialize(SDL_AudioDriverImpl *impl)
|
static bool PipewireInitialize(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
if (!pipewire_initialized) {
|
if (!pipewire_initialized) {
|
||||||
|
|
||||||
if (init_pipewire_library() < 0) {
|
if (init_pipewire_library() < 0) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pipewire_initialized = SDL_TRUE;
|
pipewire_initialized = true;
|
||||||
|
|
||||||
if (hotplug_loop_init() < 0) {
|
if (hotplug_loop_init() < 0) {
|
||||||
PIPEWIRE_Deinitialize();
|
PIPEWIRE_Deinitialize();
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1244,16 +1244,16 @@ static SDL_bool PipewireInitialize(SDL_AudioDriverImpl *impl)
|
||||||
impl->FlushRecording = PIPEWIRE_FlushRecording;
|
impl->FlushRecording = PIPEWIRE_FlushRecording;
|
||||||
impl->CloseDevice = PIPEWIRE_CloseDevice;
|
impl->CloseDevice = PIPEWIRE_CloseDevice;
|
||||||
|
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
impl->ProvidesOwnCallbackThread = SDL_TRUE;
|
impl->ProvidesOwnCallbackThread = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool PIPEWIRE_PREFERRED_Init(SDL_AudioDriverImpl *impl)
|
static bool PIPEWIRE_PREFERRED_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
if (!PipewireInitialize(impl)) {
|
if (!PipewireInitialize(impl)) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// run device detection but don't add any devices to SDL; we're just waiting to see if PipeWire sees any devices. If not, fall back to the next backend.
|
// run device detection but don't add any devices to SDL; we're just waiting to see if PipeWire sees any devices. If not, fall back to the next backend.
|
||||||
|
@ -1271,22 +1271,22 @@ static SDL_bool PIPEWIRE_PREFERRED_Init(SDL_AudioDriverImpl *impl)
|
||||||
if (no_devices || !pipewire_core_version_at_least(1, 0, 0)) {
|
if (no_devices || !pipewire_core_version_at_least(1, 0, 0)) {
|
||||||
hotplug_loop_destroy();
|
hotplug_loop_destroy();
|
||||||
PIPEWIRE_Deinitialize();
|
PIPEWIRE_Deinitialize();
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE; // this will move on to PIPEWIRE_DetectDevices and reuse hotplug_io_list.
|
return true; // this will move on to PIPEWIRE_DetectDevices and reuse hotplug_io_list.
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool PIPEWIRE_Init(SDL_AudioDriverImpl *impl)
|
static bool PIPEWIRE_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
return PipewireInitialize(impl);
|
return PipewireInitialize(impl);
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap PIPEWIRE_PREFERRED_bootstrap = {
|
AudioBootStrap PIPEWIRE_PREFERRED_bootstrap = {
|
||||||
"pipewire", "Pipewire", PIPEWIRE_PREFERRED_Init, SDL_FALSE
|
"pipewire", "Pipewire", PIPEWIRE_PREFERRED_Init, false
|
||||||
};
|
};
|
||||||
AudioBootStrap PIPEWIRE_bootstrap = {
|
AudioBootStrap PIPEWIRE_bootstrap = {
|
||||||
"pipewire", "Pipewire", PIPEWIRE_Init, SDL_FALSE
|
"pipewire", "Pipewire", PIPEWIRE_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_PIPEWIRE
|
#endif // SDL_AUDIO_DRIVER_PIPEWIRE
|
||||||
|
|
|
@ -137,10 +137,10 @@ static void PS2AUDIO_Deinitialize(void)
|
||||||
deinit_audio_driver();
|
deinit_audio_driver();
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool PS2AUDIO_Init(SDL_AudioDriverImpl *impl)
|
static bool PS2AUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
if (init_audio_driver() < 0) {
|
if (init_audio_driver() < 0) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->OpenDevice = PS2AUDIO_OpenDevice;
|
impl->OpenDevice = PS2AUDIO_OpenDevice;
|
||||||
|
@ -150,10 +150,10 @@ static SDL_bool PS2AUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->CloseDevice = PS2AUDIO_CloseDevice;
|
impl->CloseDevice = PS2AUDIO_CloseDevice;
|
||||||
impl->ThreadInit = PS2AUDIO_ThreadInit;
|
impl->ThreadInit = PS2AUDIO_ThreadInit;
|
||||||
impl->Deinitialize = PS2AUDIO_Deinitialize;
|
impl->Deinitialize = PS2AUDIO_Deinitialize;
|
||||||
impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE;
|
impl->OnlyHasDefaultPlaybackDevice = true;
|
||||||
return SDL_TRUE; // this audio target is available.
|
return true; // this audio target is available.
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap PS2AUDIO_bootstrap = {
|
AudioBootStrap PS2AUDIO_bootstrap = {
|
||||||
"ps2", "PS2 audio driver", PS2AUDIO_Init, SDL_FALSE
|
"ps2", "PS2 audio driver", PS2AUDIO_Init, false
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include <pspaudio.h>
|
#include <pspaudio.h>
|
||||||
#include <pspthreadman.h>
|
#include <pspthreadman.h>
|
||||||
|
|
||||||
static inline SDL_bool isBasicAudioConfig(const SDL_AudioSpec *spec)
|
static bool isBasicAudioConfig(const SDL_AudioSpec *spec)
|
||||||
{
|
{
|
||||||
return spec->freq == 44100;
|
return spec->freq == 44100;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ static void PSPAUDIO_ThreadInit(SDL_AudioDevice *device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool PSPAUDIO_Init(SDL_AudioDriverImpl *impl)
|
static bool PSPAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
impl->OpenDevice = PSPAUDIO_OpenDevice;
|
impl->OpenDevice = PSPAUDIO_OpenDevice;
|
||||||
impl->PlayDevice = PSPAUDIO_PlayDevice;
|
impl->PlayDevice = PSPAUDIO_PlayDevice;
|
||||||
|
@ -170,14 +170,14 @@ static SDL_bool PSPAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->GetDeviceBuf = PSPAUDIO_GetDeviceBuf;
|
impl->GetDeviceBuf = PSPAUDIO_GetDeviceBuf;
|
||||||
impl->CloseDevice = PSPAUDIO_CloseDevice;
|
impl->CloseDevice = PSPAUDIO_CloseDevice;
|
||||||
impl->ThreadInit = PSPAUDIO_ThreadInit;
|
impl->ThreadInit = PSPAUDIO_ThreadInit;
|
||||||
impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE;
|
impl->OnlyHasDefaultPlaybackDevice = true;
|
||||||
//impl->HasRecordingSupport = SDL_TRUE;
|
//impl->HasRecordingSupport = true;
|
||||||
//impl->OnlyHasDefaultRecordingDevice = SDL_TRUE;
|
//impl->OnlyHasDefaultRecordingDevice = true;
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap PSPAUDIO_bootstrap = {
|
AudioBootStrap PSPAUDIO_bootstrap = {
|
||||||
"psp", "PSP audio driver", PSPAUDIO_Init, SDL_FALSE
|
"psp", "PSP audio driver", PSPAUDIO_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_PSP
|
#endif // SDL_AUDIO_DRIVER_PSP
|
||||||
|
|
|
@ -46,7 +46,7 @@ typedef struct PulseDeviceHandle
|
||||||
} PulseDeviceHandle;
|
} PulseDeviceHandle;
|
||||||
|
|
||||||
// should we include monitors in the device list? Set at SDL_Init time
|
// should we include monitors in the device list? Set at SDL_Init time
|
||||||
static SDL_bool include_monitors = SDL_FALSE;
|
static bool include_monitors = false;
|
||||||
|
|
||||||
static pa_threaded_mainloop *pulseaudio_threaded_mainloop = NULL;
|
static pa_threaded_mainloop *pulseaudio_threaded_mainloop = NULL;
|
||||||
static pa_context *pulseaudio_context = NULL;
|
static pa_context *pulseaudio_context = NULL;
|
||||||
|
@ -58,8 +58,8 @@ static SDL_AtomicInt pulseaudio_hotplug_thread_active;
|
||||||
// to the change.
|
// to the change.
|
||||||
static char *default_sink_path = NULL;
|
static char *default_sink_path = NULL;
|
||||||
static char *default_source_path = NULL;
|
static char *default_source_path = NULL;
|
||||||
static SDL_bool default_sink_changed = SDL_FALSE;
|
static bool default_sink_changed = false;
|
||||||
static SDL_bool default_source_changed = SDL_FALSE;
|
static bool default_source_changed = false;
|
||||||
|
|
||||||
|
|
||||||
static const char *(*PULSEAUDIO_pa_get_library_version)(void);
|
static const char *(*PULSEAUDIO_pa_get_library_version)(void);
|
||||||
|
@ -593,7 +593,7 @@ static void PulseStreamStateChangeCallback(pa_stream *stream, void *userdata)
|
||||||
|
|
||||||
static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
|
static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
const SDL_bool recording = device->recording;
|
const bool recording = device->recording;
|
||||||
struct SDL_PrivateAudioData *h = NULL;
|
struct SDL_PrivateAudioData *h = NULL;
|
||||||
SDL_AudioFormat test_format;
|
SDL_AudioFormat test_format;
|
||||||
const SDL_AudioFormat *closefmts;
|
const SDL_AudioFormat *closefmts;
|
||||||
|
@ -761,7 +761,7 @@ static SDL_AudioFormat PulseFormatToSDLFormat(pa_sample_format_t format)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AddPulseAudioDevice(const SDL_bool recording, const char *description, const char *name, const uint32_t index, const pa_sample_spec *sample_spec)
|
static void AddPulseAudioDevice(const bool recording, const char *description, const char *name, const uint32_t index, const pa_sample_spec *sample_spec)
|
||||||
{
|
{
|
||||||
SDL_AudioSpec spec;
|
SDL_AudioSpec spec;
|
||||||
SDL_zero(spec);
|
SDL_zero(spec);
|
||||||
|
@ -784,7 +784,7 @@ static void AddPulseAudioDevice(const SDL_bool recording, const char *descriptio
|
||||||
static void SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
|
static void SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
|
||||||
{
|
{
|
||||||
if (i) {
|
if (i) {
|
||||||
AddPulseAudioDevice(SDL_FALSE, i->description, i->name, i->index, &i->sample_spec);
|
AddPulseAudioDevice(false, i->description, i->name, i->index, &i->sample_spec);
|
||||||
}
|
}
|
||||||
PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0);
|
PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0);
|
||||||
}
|
}
|
||||||
|
@ -794,7 +794,7 @@ static void SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_la
|
||||||
{
|
{
|
||||||
// Maybe skip "monitor" sources. These are just output from other sinks.
|
// Maybe skip "monitor" sources. These are just output from other sinks.
|
||||||
if (i && (include_monitors || (i->monitor_of_sink == PA_INVALID_INDEX))) {
|
if (i && (include_monitors || (i->monitor_of_sink == PA_INVALID_INDEX))) {
|
||||||
AddPulseAudioDevice(SDL_TRUE, i->description, i->name, i->index, &i->sample_spec);
|
AddPulseAudioDevice(true, i->description, i->name, i->index, &i->sample_spec);
|
||||||
}
|
}
|
||||||
PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0);
|
PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0);
|
||||||
}
|
}
|
||||||
|
@ -808,7 +808,7 @@ static void ServerInfoCallback(pa_context *c, const pa_server_info *i, void *dat
|
||||||
if (str) {
|
if (str) {
|
||||||
SDL_free(default_sink_path);
|
SDL_free(default_sink_path);
|
||||||
default_sink_path = str;
|
default_sink_path = str;
|
||||||
default_sink_changed = SDL_TRUE;
|
default_sink_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,21 +817,21 @@ static void ServerInfoCallback(pa_context *c, const pa_server_info *i, void *dat
|
||||||
if (str) {
|
if (str) {
|
||||||
SDL_free(default_source_path);
|
SDL_free(default_source_path);
|
||||||
default_source_path = str;
|
default_source_path = str;
|
||||||
default_source_changed = SDL_TRUE;
|
default_source_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0);
|
PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool FindAudioDeviceByIndex(SDL_AudioDevice *device, void *userdata)
|
static bool FindAudioDeviceByIndex(SDL_AudioDevice *device, void *userdata)
|
||||||
{
|
{
|
||||||
const uint32_t idx = (uint32_t) (uintptr_t) userdata;
|
const uint32_t idx = (uint32_t) (uintptr_t) userdata;
|
||||||
const PulseDeviceHandle *handle = (const PulseDeviceHandle *) device->handle;
|
const PulseDeviceHandle *handle = (const PulseDeviceHandle *) device->handle;
|
||||||
return (handle->device_index == idx);
|
return (handle->device_index == idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool FindAudioDeviceByPath(SDL_AudioDevice *device, void *userdata)
|
static bool FindAudioDeviceByPath(SDL_AudioDevice *device, void *userdata)
|
||||||
{
|
{
|
||||||
const char *path = (const char *) userdata;
|
const char *path = (const char *) userdata;
|
||||||
const PulseDeviceHandle *handle = (const PulseDeviceHandle *) device->handle;
|
const PulseDeviceHandle *handle = (const PulseDeviceHandle *) device->handle;
|
||||||
|
@ -841,13 +841,13 @@ static SDL_bool FindAudioDeviceByPath(SDL_AudioDevice *device, void *userdata)
|
||||||
// This is called when PulseAudio has a device connected/removed/changed.
|
// This is called when PulseAudio has a device connected/removed/changed.
|
||||||
static void HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *data)
|
static void HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *data)
|
||||||
{
|
{
|
||||||
const SDL_bool added = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW);
|
const bool added = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW);
|
||||||
const SDL_bool removed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE);
|
const bool removed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE);
|
||||||
const SDL_bool changed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CHANGE);
|
const bool changed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CHANGE);
|
||||||
|
|
||||||
if (added || removed || changed) { // we only care about add/remove events.
|
if (added || removed || changed) { // we only care about add/remove events.
|
||||||
const SDL_bool sink = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK);
|
const bool sink = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK);
|
||||||
const SDL_bool source = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE);
|
const bool source = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE);
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
PULSEAUDIO_pa_operation_unref(PULSEAUDIO_pa_context_get_server_info(pulseaudio_context, ServerInfoCallback, NULL));
|
PULSEAUDIO_pa_operation_unref(PULSEAUDIO_pa_context_get_server_info(pulseaudio_context, ServerInfoCallback, NULL));
|
||||||
|
@ -868,20 +868,20 @@ static void HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint3
|
||||||
PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0);
|
PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool CheckDefaultDevice(const SDL_bool changed, char *device_path)
|
static bool CheckDefaultDevice(const bool changed, char *device_path)
|
||||||
{
|
{
|
||||||
if (!changed) {
|
if (!changed) {
|
||||||
return SDL_FALSE; // nothing's happening, leave the flag marked as unchanged.
|
return false; // nothing's happening, leave the flag marked as unchanged.
|
||||||
} else if (!device_path) {
|
} else if (!device_path) {
|
||||||
return SDL_TRUE; // check again later, we don't have a device name...
|
return true; // check again later, we don't have a device name...
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_AudioDevice *device = SDL_FindPhysicalAudioDeviceByCallback(FindAudioDeviceByPath, device_path);
|
SDL_AudioDevice *device = SDL_FindPhysicalAudioDeviceByCallback(FindAudioDeviceByPath, device_path);
|
||||||
if (device) { // if NULL, we might still be waiting for a SinkInfoCallback or something, we'll try later.
|
if (device) { // if NULL, we might still be waiting for a SinkInfoCallback or something, we'll try later.
|
||||||
SDL_DefaultAudioDeviceChanged(device);
|
SDL_DefaultAudioDeviceChanged(device);
|
||||||
return SDL_FALSE; // changing complete, set flag to unchanged for future tests.
|
return false; // changing complete, set flag to unchanged for future tests.
|
||||||
}
|
}
|
||||||
return SDL_TRUE; // couldn't find the changed device, leave it marked as changed to try again later.
|
return true; // couldn't find the changed device, leave it marked as changed to try again later.
|
||||||
}
|
}
|
||||||
|
|
||||||
// this runs as a thread while the Pulse target is initialized to catch hotplug events.
|
// this runs as a thread while the Pulse target is initialized to catch hotplug events.
|
||||||
|
@ -906,11 +906,11 @@ static int SDLCALL HotplugThread(void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update default devices; don't hold the pulse lock during this, since it could deadlock vs a playing device that we're about to lock here.
|
// Update default devices; don't hold the pulse lock during this, since it could deadlock vs a playing device that we're about to lock here.
|
||||||
SDL_bool check_default_sink = default_sink_changed;
|
bool check_default_sink = default_sink_changed;
|
||||||
SDL_bool check_default_source = default_source_changed;
|
bool check_default_source = default_source_changed;
|
||||||
char *current_default_sink = check_default_sink ? SDL_strdup(default_sink_path) : NULL;
|
char *current_default_sink = check_default_sink ? SDL_strdup(default_sink_path) : NULL;
|
||||||
char *current_default_source = check_default_source ? SDL_strdup(default_source_path) : NULL;
|
char *current_default_source = check_default_source ? SDL_strdup(default_source_path) : NULL;
|
||||||
default_sink_changed = default_source_changed = SDL_FALSE;
|
default_sink_changed = default_source_changed = false;
|
||||||
PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop);
|
PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop);
|
||||||
check_default_sink = CheckDefaultDevice(check_default_sink, current_default_sink);
|
check_default_sink = CheckDefaultDevice(check_default_sink, current_default_sink);
|
||||||
check_default_source = CheckDefaultDevice(check_default_source, current_default_source);
|
check_default_source = CheckDefaultDevice(check_default_source, current_default_source);
|
||||||
|
@ -984,24 +984,24 @@ static void PULSEAUDIO_Deinitialize(void)
|
||||||
|
|
||||||
SDL_free(default_sink_path);
|
SDL_free(default_sink_path);
|
||||||
default_sink_path = NULL;
|
default_sink_path = NULL;
|
||||||
default_sink_changed = SDL_FALSE;
|
default_sink_changed = false;
|
||||||
SDL_free(default_source_path);
|
SDL_free(default_source_path);
|
||||||
default_source_path = NULL;
|
default_source_path = NULL;
|
||||||
default_source_changed = SDL_FALSE;
|
default_source_changed = false;
|
||||||
|
|
||||||
UnloadPulseAudioLibrary();
|
UnloadPulseAudioLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool PULSEAUDIO_Init(SDL_AudioDriverImpl *impl)
|
static bool PULSEAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
if (LoadPulseAudioLibrary() < 0) {
|
if (LoadPulseAudioLibrary() < 0) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
} else if (ConnectToPulseServer() < 0) {
|
} else if (ConnectToPulseServer() < 0) {
|
||||||
UnloadPulseAudioLibrary();
|
UnloadPulseAudioLibrary();
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
include_monitors = SDL_GetHintBoolean(SDL_HINT_AUDIO_INCLUDE_MONITORS, SDL_FALSE);
|
include_monitors = SDL_GetHintBoolean(SDL_HINT_AUDIO_INCLUDE_MONITORS, false);
|
||||||
|
|
||||||
impl->DetectDevices = PULSEAUDIO_DetectDevices;
|
impl->DetectDevices = PULSEAUDIO_DetectDevices;
|
||||||
impl->OpenDevice = PULSEAUDIO_OpenDevice;
|
impl->OpenDevice = PULSEAUDIO_OpenDevice;
|
||||||
|
@ -1016,13 +1016,13 @@ static SDL_bool PULSEAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->FlushRecording = PULSEAUDIO_FlushRecording;
|
impl->FlushRecording = PULSEAUDIO_FlushRecording;
|
||||||
impl->FreeDeviceHandle = PULSEAUDIO_FreeDeviceHandle;
|
impl->FreeDeviceHandle = PULSEAUDIO_FreeDeviceHandle;
|
||||||
|
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap PULSEAUDIO_bootstrap = {
|
AudioBootStrap PULSEAUDIO_bootstrap = {
|
||||||
"pulseaudio", "PulseAudio", PULSEAUDIO_Init, SDL_FALSE
|
"pulseaudio", "PulseAudio", PULSEAUDIO_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_PULSEAUDIO
|
#endif // SDL_AUDIO_DRIVER_PULSEAUDIO
|
||||||
|
|
|
@ -100,10 +100,10 @@ static int QSA_WaitDevice(SDL_AudioDevice *device)
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "QSA: SDL_IOReady() failed: %s", strerror(errno));
|
SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "QSA: SDL_IOReady() failed: %s", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
case 0:
|
case 0:
|
||||||
device->hidden->timeout_on_wait = SDL_TRUE; // !!! FIXME: Should we just disconnect the device in this case?
|
device->hidden->timeout_on_wait = true; // !!! FIXME: Should we just disconnect the device in this case?
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
device->hidden->timeout_on_wait = SDL_FALSE;
|
device->hidden->timeout_on_wait = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ static int QSA_OpenDevice(SDL_AudioDevice *device)
|
||||||
const Uint32 sdlhandle = (Uint32) ((size_t) device->handle);
|
const Uint32 sdlhandle = (Uint32) ((size_t) device->handle);
|
||||||
const uint32_t cardno = (uint32_t) (sdlhandle & 0xFFFF);
|
const uint32_t cardno = (uint32_t) (sdlhandle & 0xFFFF);
|
||||||
const uint32_t deviceno = (uint32_t) ((sdlhandle >> 16) & 0xFFFF);
|
const uint32_t deviceno = (uint32_t) ((sdlhandle >> 16) & 0xFFFF);
|
||||||
const SDL_bool recording = device->recording;
|
const bool recording = device->recording;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
// Initialize all variables that we clean on shutdown
|
// Initialize all variables that we clean on shutdown
|
||||||
|
@ -318,7 +318,7 @@ static void QSA_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevic
|
||||||
// this value can be changed in the runtime
|
// this value can be changed in the runtime
|
||||||
int num_cards = 0;
|
int num_cards = 0;
|
||||||
(void) snd_cards_list(NULL, 0, &alloc_num_cards);
|
(void) snd_cards_list(NULL, 0, &alloc_num_cards);
|
||||||
SDL_bool isstack = SDL_FALSE;
|
bool isstack = false;
|
||||||
int *cards = SDL_small_alloc(int, num_cards, &isstack);
|
int *cards = SDL_small_alloc(int, num_cards, &isstack);
|
||||||
if (!cards) {
|
if (!cards) {
|
||||||
return; // we're in trouble.
|
return; // we're in trouble.
|
||||||
|
@ -350,13 +350,13 @@ static void QSA_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevic
|
||||||
SDL_snprintf(fullname, sizeof (fullname), "%s d%d", name, (int) deviceno);
|
SDL_snprintf(fullname, sizeof (fullname), "%s d%d", name, (int) deviceno);
|
||||||
|
|
||||||
// Check if this device id could play anything
|
// Check if this device id could play anything
|
||||||
SDL_bool recording = SDL_FALSE;
|
bool recording = false;
|
||||||
status = snd_pcm_open(&handle, card, deviceno, SND_PCM_OPEN_PLAYBACK);
|
status = snd_pcm_open(&handle, card, deviceno, SND_PCM_OPEN_PLAYBACK);
|
||||||
if (status != EOK) { // no? See if it's a recording device instead.
|
if (status != EOK) { // no? See if it's a recording device instead.
|
||||||
#if 0 // !!! FIXME: most of this code has support for recording devices, but there's no RecordDevice, etc functions. Fill them in!
|
#if 0 // !!! FIXME: most of this code has support for recording devices, but there's no RecordDevice, etc functions. Fill them in!
|
||||||
status = snd_pcm_open(&handle, card, deviceno, SND_PCM_OPEN_CAPTURE);
|
status = snd_pcm_open(&handle, card, deviceno, SND_PCM_OPEN_CAPTURE);
|
||||||
if (status == EOK) {
|
if (status == EOK) {
|
||||||
recording = SDL_TRUE;
|
recording = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -426,7 +426,7 @@ static void QSA_Deinitialize(void)
|
||||||
// nothing to do here atm.
|
// nothing to do here atm.
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool QSA_Init(SDL_AudioDriverImpl * impl)
|
static bool QSA_Init(SDL_AudioDriverImpl * impl)
|
||||||
{
|
{
|
||||||
impl->DetectDevices = QSA_DetectDevices;
|
impl->DetectDevices = QSA_DetectDevices;
|
||||||
impl->OpenDevice = QSA_OpenDevice;
|
impl->OpenDevice = QSA_OpenDevice;
|
||||||
|
@ -438,9 +438,9 @@ static SDL_bool QSA_Init(SDL_AudioDriverImpl * impl)
|
||||||
impl->Deinitialize = QSA_Deinitialize;
|
impl->Deinitialize = QSA_Deinitialize;
|
||||||
|
|
||||||
// !!! FIXME: most of this code has support for recording devices, but there's no RecordDevice, etc functions. Fill them in!
|
// !!! FIXME: most of this code has support for recording devices, but there's no RecordDevice, etc functions. Fill them in!
|
||||||
//impl->HasRecordingSupport = SDL_TRUE;
|
//impl->HasRecordingSupport = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap QSAAUDIO_bootstrap = {
|
AudioBootStrap QSAAUDIO_bootstrap = {
|
||||||
|
|
|
@ -32,7 +32,7 @@ struct SDL_PrivateAudioData
|
||||||
{
|
{
|
||||||
snd_pcm_t *audio_handle; // The audio device handle
|
snd_pcm_t *audio_handle; // The audio device handle
|
||||||
int audio_fd; // The audio file descriptor, for selecting on
|
int audio_fd; // The audio file descriptor, for selecting on
|
||||||
SDL_bool timeout_on_wait; // Select timeout status
|
bool timeout_on_wait; // Select timeout status
|
||||||
Uint8 *pcm_buf; // Raw mixing buffer
|
Uint8 *pcm_buf; // Raw mixing buffer
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ static int LoadSNDIOLibrary(void)
|
||||||
|
|
||||||
static int SNDIO_WaitDevice(SDL_AudioDevice *device)
|
static int SNDIO_WaitDevice(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
const SDL_bool recording = device->recording;
|
const bool recording = device->recording;
|
||||||
|
|
||||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||||
if (SNDIO_sio_eof(device->hidden->dev)) {
|
if (SNDIO_sio_eof(device->hidden->dev)) {
|
||||||
|
@ -323,14 +323,14 @@ static void SNDIO_Deinitialize(void)
|
||||||
|
|
||||||
static void SNDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
static void SNDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
||||||
{
|
{
|
||||||
*default_playback = SDL_AddAudioDevice(SDL_FALSE, DEFAULT_PLAYBACK_DEVNAME, NULL, (void *)0x1);
|
*default_playback = SDL_AddAudioDevice(false, DEFAULT_PLAYBACK_DEVNAME, NULL, (void *)0x1);
|
||||||
*default_recording = SDL_AddAudioDevice(SDL_TRUE, DEFAULT_RECORDING_DEVNAME, NULL, (void *)0x2);
|
*default_recording = SDL_AddAudioDevice(true, DEFAULT_RECORDING_DEVNAME, NULL, (void *)0x2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SNDIO_Init(SDL_AudioDriverImpl *impl)
|
static bool SNDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
if (LoadSNDIOLibrary() < 0) {
|
if (LoadSNDIOLibrary() < 0) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->OpenDevice = SNDIO_OpenDevice;
|
impl->OpenDevice = SNDIO_OpenDevice;
|
||||||
|
@ -344,13 +344,13 @@ static SDL_bool SNDIO_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->Deinitialize = SNDIO_Deinitialize;
|
impl->Deinitialize = SNDIO_Deinitialize;
|
||||||
impl->DetectDevices = SNDIO_DetectDevices;
|
impl->DetectDevices = SNDIO_DetectDevices;
|
||||||
|
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap SNDIO_bootstrap = {
|
AudioBootStrap SNDIO_bootstrap = {
|
||||||
"sndio", "OpenBSD sndio", SNDIO_Init, SDL_FALSE
|
"sndio", "OpenBSD sndio", SNDIO_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_SNDIO
|
#endif // SDL_AUDIO_DRIVER_SNDIO
|
||||||
|
|
|
@ -211,7 +211,7 @@ static void VITAAUD_ThreadInit(SDL_AudioDevice *device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool VITAAUD_Init(SDL_AudioDriverImpl *impl)
|
static bool VITAAUD_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
impl->OpenDevice = VITAAUD_OpenDevice;
|
impl->OpenDevice = VITAAUD_OpenDevice;
|
||||||
impl->PlayDevice = VITAAUD_PlayDevice;
|
impl->PlayDevice = VITAAUD_PlayDevice;
|
||||||
|
@ -223,15 +223,15 @@ static SDL_bool VITAAUD_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->FlushRecording = VITAAUD_FlushRecording;
|
impl->FlushRecording = VITAAUD_FlushRecording;
|
||||||
impl->RecordDevice = VITAAUD_RecordDevice;
|
impl->RecordDevice = VITAAUD_RecordDevice;
|
||||||
|
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE;
|
impl->OnlyHasDefaultPlaybackDevice = true;
|
||||||
impl->OnlyHasDefaultRecordingDevice = SDL_TRUE;
|
impl->OnlyHasDefaultRecordingDevice = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap VITAAUD_bootstrap = {
|
AudioBootStrap VITAAUD_bootstrap = {
|
||||||
"vita", "VITA audio driver", VITAAUD_Init, SDL_FALSE
|
"vita", "VITA audio driver", VITAAUD_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_VITA
|
#endif // SDL_AUDIO_DRIVER_VITA
|
||||||
|
|
|
@ -286,17 +286,17 @@ void WASAPI_DisconnectDevice(SDL_AudioDevice *device)
|
||||||
WASAPI_ProxyToManagementThread(mgmtthrtask_DisconnectDevice, device, &rc);
|
WASAPI_ProxyToManagementThread(mgmtthrtask_DisconnectDevice, device, &rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool WasapiFailed(SDL_AudioDevice *device, const HRESULT err)
|
static bool WasapiFailed(SDL_AudioDevice *device, const HRESULT err)
|
||||||
{
|
{
|
||||||
if (err == S_OK) {
|
if (err == S_OK) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
} else if (err == AUDCLNT_E_DEVICE_INVALIDATED) {
|
} else if (err == AUDCLNT_E_DEVICE_INVALIDATED) {
|
||||||
device->hidden->device_lost = SDL_TRUE;
|
device->hidden->device_lost = true;
|
||||||
} else {
|
} else {
|
||||||
device->hidden->device_dead = SDL_TRUE;
|
device->hidden->device_dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mgmtthrtask_StopAndReleaseClient(void *userdata)
|
static int mgmtthrtask_StopAndReleaseClient(void *userdata)
|
||||||
|
@ -397,38 +397,38 @@ static int ActivateWasapiDevice(SDL_AudioDevice *device)
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not call when holding the device lock!
|
// do not call when holding the device lock!
|
||||||
static SDL_bool RecoverWasapiDevice(SDL_AudioDevice *device)
|
static bool RecoverWasapiDevice(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
ResetWasapiDevice(device); // dump the lost device's handles.
|
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.
|
// This handles a non-default device that simply had its format changed in the Windows Control Panel.
|
||||||
if (ActivateWasapiDevice(device) < 0) {
|
if (ActivateWasapiDevice(device) < 0) {
|
||||||
WASAPI_DisconnectDevice(device);
|
WASAPI_DisconnectDevice(device);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
device->hidden->device_lost = SDL_FALSE;
|
device->hidden->device_lost = false;
|
||||||
|
|
||||||
return SDL_TRUE; // okay, carry on with new device details!
|
return true; // okay, carry on with new device details!
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not call when holding the device lock!
|
// do not call when holding the device lock!
|
||||||
static SDL_bool RecoverWasapiIfLost(SDL_AudioDevice *device)
|
static bool RecoverWasapiIfLost(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
if (SDL_AtomicGet(&device->shutdown)) {
|
if (SDL_AtomicGet(&device->shutdown)) {
|
||||||
return SDL_FALSE; // already failed.
|
return false; // already failed.
|
||||||
} else if (device->hidden->device_dead) { // had a fatal error elsewhere, clean up and quit
|
} else if (device->hidden->device_dead) { // had a fatal error elsewhere, clean up and quit
|
||||||
IAudioClient_Stop(device->hidden->client);
|
IAudioClient_Stop(device->hidden->client);
|
||||||
WASAPI_DisconnectDevice(device);
|
WASAPI_DisconnectDevice(device);
|
||||||
SDL_assert(SDL_AtomicGet(&device->shutdown)); // so we don't come back through here.
|
SDL_assert(SDL_AtomicGet(&device->shutdown)); // so we don't come back through here.
|
||||||
return SDL_FALSE; // already failed.
|
return false; // already failed.
|
||||||
} else if (SDL_AtomicGet(&device->zombie)) {
|
} else if (SDL_AtomicGet(&device->zombie)) {
|
||||||
return SDL_FALSE; // we're already dead, so just leave and let the Zombie implementations take over.
|
return false; // we're already dead, so just leave and let the Zombie implementations take over.
|
||||||
} else if (!device->hidden->client) {
|
} else if (!device->hidden->client) {
|
||||||
return SDL_TRUE; // still waiting for activation.
|
return true; // still waiting for activation.
|
||||||
}
|
}
|
||||||
|
|
||||||
return device->hidden->device_lost ? RecoverWasapiDevice(device) : SDL_TRUE;
|
return device->hidden->device_lost ? RecoverWasapiDevice(device) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Uint8 *WASAPI_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
static Uint8 *WASAPI_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||||
|
@ -524,7 +524,7 @@ static int WASAPI_RecordDevice(SDL_AudioDevice *device, void *buffer, int buflen
|
||||||
const int total = ((int)frames) * device->hidden->framesize;
|
const int total = ((int)frames) * device->hidden->framesize;
|
||||||
const int cpy = SDL_min(buflen, total);
|
const int cpy = SDL_min(buflen, total);
|
||||||
const int leftover = total - cpy;
|
const int leftover = total - cpy;
|
||||||
const SDL_bool silent = (flags & AUDCLNT_BUFFERFLAGS_SILENT) ? SDL_TRUE : SDL_FALSE;
|
const bool silent = (flags & AUDCLNT_BUFFERFLAGS_SILENT) ? true : false;
|
||||||
|
|
||||||
SDL_assert(leftover == 0); // according to MSDN, this isn't everything available, just one "packet" of data per-GetBuffer call.
|
SDL_assert(leftover == 0); // according to MSDN, this isn't everything available, just one "packet" of data per-GetBuffer call.
|
||||||
|
|
||||||
|
@ -656,7 +656,7 @@ static int mgmtthrtask_PrepDevice(void *userdata)
|
||||||
streamflags |= AUDCLNT_STREAMFLAGS_EVENTCALLBACK;
|
streamflags |= AUDCLNT_STREAMFLAGS_EVENTCALLBACK;
|
||||||
|
|
||||||
int new_sample_frames = 0;
|
int new_sample_frames = 0;
|
||||||
SDL_bool iaudioclient3_initialized = SDL_FALSE;
|
bool iaudioclient3_initialized = false;
|
||||||
|
|
||||||
#ifdef __IAudioClient3_INTERFACE_DEFINED__
|
#ifdef __IAudioClient3_INTERFACE_DEFINED__
|
||||||
// Try querying IAudioClient3 if sharemode is AUDCLNT_SHAREMODE_SHARED
|
// Try querying IAudioClient3 if sharemode is AUDCLNT_SHAREMODE_SHARED
|
||||||
|
@ -678,7 +678,7 @@ static int mgmtthrtask_PrepDevice(void *userdata)
|
||||||
ret = IAudioClient3_InitializeSharedAudioStream(client3, streamflags, period_in_frames, waveformat, NULL);
|
ret = IAudioClient3_InitializeSharedAudioStream(client3, streamflags, period_in_frames, waveformat, NULL);
|
||||||
if (SUCCEEDED(ret)) {
|
if (SUCCEEDED(ret)) {
|
||||||
new_sample_frames = (int)period_in_frames;
|
new_sample_frames = (int)period_in_frames;
|
||||||
iaudioclient3_initialized = SDL_TRUE;
|
iaudioclient3_initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,10 +822,10 @@ static void WASAPI_Deinitialize(void)
|
||||||
DeinitManagementThread();
|
DeinitManagementThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool WASAPI_Init(SDL_AudioDriverImpl *impl)
|
static bool WASAPI_Init(SDL_AudioDriverImpl *impl)
|
||||||
{
|
{
|
||||||
if (InitManagementThread() < 0) {
|
if (InitManagementThread() < 0) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->DetectDevices = WASAPI_DetectDevices;
|
impl->DetectDevices = WASAPI_DetectDevices;
|
||||||
|
@ -843,13 +843,13 @@ static SDL_bool WASAPI_Init(SDL_AudioDriverImpl *impl)
|
||||||
impl->Deinitialize = WASAPI_Deinitialize;
|
impl->Deinitialize = WASAPI_Deinitialize;
|
||||||
impl->FreeDeviceHandle = WASAPI_FreeDeviceHandle;
|
impl->FreeDeviceHandle = WASAPI_FreeDeviceHandle;
|
||||||
|
|
||||||
impl->HasRecordingSupport = SDL_TRUE;
|
impl->HasRecordingSupport = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBootStrap WASAPI_bootstrap = {
|
AudioBootStrap WASAPI_bootstrap = {
|
||||||
"wasapi", "WASAPI", WASAPI_Init, SDL_FALSE
|
"wasapi", "WASAPI", WASAPI_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_AUDIO_DRIVER_WASAPI
|
#endif // SDL_AUDIO_DRIVER_WASAPI
|
||||||
|
|
|
@ -38,10 +38,10 @@ struct SDL_PrivateAudioData
|
||||||
IAudioCaptureClient *capture;
|
IAudioCaptureClient *capture;
|
||||||
HANDLE event;
|
HANDLE event;
|
||||||
HANDLE task;
|
HANDLE task;
|
||||||
SDL_bool coinitialized;
|
bool coinitialized;
|
||||||
int framesize;
|
int framesize;
|
||||||
SDL_bool device_lost;
|
bool device_lost;
|
||||||
SDL_bool device_dead;
|
bool device_dead;
|
||||||
void *activation_handler;
|
void *activation_handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ typedef BOOL(WINAPI *pfnAvRevertMmThreadCharacteristics)(HANDLE);
|
||||||
static pfnAvSetMmThreadCharacteristicsW pAvSetMmThreadCharacteristicsW = NULL;
|
static pfnAvSetMmThreadCharacteristicsW pAvSetMmThreadCharacteristicsW = NULL;
|
||||||
static pfnAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics = NULL;
|
static pfnAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics = NULL;
|
||||||
|
|
||||||
static SDL_bool immdevice_initialized = SDL_FALSE;
|
static bool immdevice_initialized = false;
|
||||||
|
|
||||||
// Some GUIDs we need to know without linking to libraries that aren't available before Vista.
|
// 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 const IID SDL_IID_IAudioClient = { 0x1cb9ad4c, 0xdbfa, 0x4c32, { 0xb1, 0x78, 0xc2, 0xf5, 0x68, 0xa7, 0x03, 0xb2 } };
|
||||||
|
@ -91,7 +91,7 @@ int WASAPI_PlatformInit(void)
|
||||||
return -1; // Error string is set by SDL_IMMDevice_Init
|
return -1; // Error string is set by SDL_IMMDevice_Init
|
||||||
}
|
}
|
||||||
|
|
||||||
immdevice_initialized = SDL_TRUE;
|
immdevice_initialized = true;
|
||||||
|
|
||||||
libavrt = LoadLibrary(TEXT("avrt.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now!
|
libavrt = LoadLibrary(TEXT("avrt.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now!
|
||||||
if (libavrt) {
|
if (libavrt) {
|
||||||
|
@ -106,7 +106,7 @@ static void StopWasapiHotplug(void)
|
||||||
{
|
{
|
||||||
if (immdevice_initialized) {
|
if (immdevice_initialized) {
|
||||||
SDL_IMMDevice_Quit();
|
SDL_IMMDevice_Quit();
|
||||||
immdevice_initialized = SDL_FALSE;
|
immdevice_initialized = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ void WASAPI_PlatformThreadInit(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
// this thread uses COM.
|
// this thread uses COM.
|
||||||
if (SUCCEEDED(WIN_CoInitialize())) { // can't report errors, hope it worked!
|
if (SUCCEEDED(WIN_CoInitialize())) { // can't report errors, hope it worked!
|
||||||
device->hidden->coinitialized = SDL_TRUE;
|
device->hidden->coinitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set this thread to very high "Pro Audio" priority.
|
// Set this thread to very high "Pro Audio" priority.
|
||||||
|
@ -157,7 +157,7 @@ void WASAPI_PlatformThreadDeinit(SDL_AudioDevice *device)
|
||||||
|
|
||||||
if (device->hidden->coinitialized) {
|
if (device->hidden->coinitialized) {
|
||||||
WIN_CoUninitialize();
|
WIN_CoUninitialize();
|
||||||
device->hidden->coinitialized = SDL_FALSE;
|
device->hidden->coinitialized = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ using namespace Microsoft::WRL;
|
||||||
static Platform::String ^ SDL_PKEY_AudioEngine_DeviceFormat = L"{f19f064d-082c-4e27-bc73-6882a1bb8e4c} 0";
|
static Platform::String ^ SDL_PKEY_AudioEngine_DeviceFormat = L"{f19f064d-082c-4e27-bc73-6882a1bb8e4c} 0";
|
||||||
|
|
||||||
|
|
||||||
static SDL_bool FindWinRTAudioDeviceCallback(SDL_AudioDevice *device, void *userdata)
|
static bool FindWinRTAudioDeviceCallback(SDL_AudioDevice *device, void *userdata)
|
||||||
{
|
{
|
||||||
return (SDL_wcscmp((LPCWSTR) device->handle, (LPCWSTR) userdata) == 0);
|
return (SDL_wcscmp((LPCWSTR) device->handle, (LPCWSTR) userdata) == 0);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ static SDL_AudioDevice *FindWinRTAudioDevice(LPCWSTR devid)
|
||||||
class SDL_WasapiDeviceEventHandler
|
class SDL_WasapiDeviceEventHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SDL_WasapiDeviceEventHandler(const SDL_bool _recording);
|
SDL_WasapiDeviceEventHandler(const bool _recording);
|
||||||
~SDL_WasapiDeviceEventHandler();
|
~SDL_WasapiDeviceEventHandler();
|
||||||
void OnDeviceAdded(DeviceWatcher ^ sender, DeviceInformation ^ args);
|
void OnDeviceAdded(DeviceWatcher ^ sender, DeviceInformation ^ args);
|
||||||
void OnDeviceRemoved(DeviceWatcher ^ sender, DeviceInformationUpdate ^ args);
|
void OnDeviceRemoved(DeviceWatcher ^ sender, DeviceInformationUpdate ^ args);
|
||||||
|
@ -78,7 +78,7 @@ class SDL_WasapiDeviceEventHandler
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDL_Semaphore *completed_semaphore;
|
SDL_Semaphore *completed_semaphore;
|
||||||
const SDL_bool recording;
|
const bool recording;
|
||||||
DeviceWatcher ^ watcher;
|
DeviceWatcher ^ watcher;
|
||||||
Windows::Foundation::EventRegistrationToken added_handler;
|
Windows::Foundation::EventRegistrationToken added_handler;
|
||||||
Windows::Foundation::EventRegistrationToken removed_handler;
|
Windows::Foundation::EventRegistrationToken removed_handler;
|
||||||
|
@ -87,7 +87,7 @@ class SDL_WasapiDeviceEventHandler
|
||||||
Windows::Foundation::EventRegistrationToken default_changed_handler;
|
Windows::Foundation::EventRegistrationToken default_changed_handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
SDL_WasapiDeviceEventHandler::SDL_WasapiDeviceEventHandler(const SDL_bool _recording)
|
SDL_WasapiDeviceEventHandler::SDL_WasapiDeviceEventHandler(const bool _recording)
|
||||||
: recording(_recording), completed_semaphore(SDL_CreateSemaphore(0))
|
: recording(_recording), completed_semaphore(SDL_CreateSemaphore(0))
|
||||||
{
|
{
|
||||||
if (!completed_semaphore) {
|
if (!completed_semaphore) {
|
||||||
|
@ -245,14 +245,14 @@ void WASAPI_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevi
|
||||||
// DeviceWatchers will fire an Added event for each existing device at
|
// DeviceWatchers will fire an Added event for each existing device at
|
||||||
// startup, so we don't need to enumerate them separately before
|
// startup, so we don't need to enumerate them separately before
|
||||||
// listening for updates.
|
// listening for updates.
|
||||||
playback_device_event_handler = new SDL_WasapiDeviceEventHandler(SDL_FALSE);
|
playback_device_event_handler = new SDL_WasapiDeviceEventHandler(false);
|
||||||
playback_device_event_handler->WaitForCompletion();
|
playback_device_event_handler->WaitForCompletion();
|
||||||
defdevid = MediaDevice::GetDefaultAudioRenderId(AudioDeviceRole::Default);
|
defdevid = MediaDevice::GetDefaultAudioRenderId(AudioDeviceRole::Default);
|
||||||
if (defdevid) {
|
if (defdevid) {
|
||||||
*default_playback = FindWinRTAudioDevice(defdevid->Data());
|
*default_playback = FindWinRTAudioDevice(defdevid->Data());
|
||||||
}
|
}
|
||||||
|
|
||||||
recording_device_event_handler = new SDL_WasapiDeviceEventHandler(SDL_TRUE);
|
recording_device_event_handler = new SDL_WasapiDeviceEventHandler(true);
|
||||||
recording_device_event_handler->WaitForCompletion();
|
recording_device_event_handler->WaitForCompletion();
|
||||||
defdevid = MediaDevice::GetDefaultAudioCaptureId(AudioDeviceRole::Default);
|
defdevid = MediaDevice::GetDefaultAudioCaptureId(AudioDeviceRole::Default);
|
||||||
if (defdevid) {
|
if (defdevid) {
|
||||||
|
|
|
@ -542,7 +542,7 @@ void SDL_CameraDisconnected(SDL_Camera *device)
|
||||||
|
|
||||||
ObtainPhysicalCameraObj(device);
|
ObtainPhysicalCameraObj(device);
|
||||||
|
|
||||||
const SDL_bool first_disconnect = SDL_AtomicCompareAndSwap(&device->zombie, 0, 1);
|
const bool first_disconnect = SDL_AtomicCompareAndSwap(&device->zombie, 0, 1);
|
||||||
if (first_disconnect) { // if already disconnected this device, don't do it twice.
|
if (first_disconnect) { // if already disconnected this device, don't do it twice.
|
||||||
// Swap in "Zombie" versions of the usual platform interfaces, so the device will keep
|
// Swap in "Zombie" versions of the usual platform interfaces, so the device will keep
|
||||||
// making progress until the app closes it. Otherwise, streams might continue to
|
// making progress until the app closes it. Otherwise, streams might continue to
|
||||||
|
@ -580,7 +580,7 @@ void SDL_CameraDisconnected(SDL_Camera *device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_CameraPermissionOutcome(SDL_Camera *device, SDL_bool approved)
|
void SDL_CameraPermissionOutcome(SDL_Camera *device, bool approved)
|
||||||
{
|
{
|
||||||
if (!device) {
|
if (!device) {
|
||||||
return;
|
return;
|
||||||
|
@ -618,7 +618,7 @@ void SDL_CameraPermissionOutcome(SDL_Camera *device, SDL_bool approved)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SDL_Camera *SDL_FindPhysicalCameraByCallback(SDL_bool (*callback)(SDL_Camera *device, void *userdata), void *userdata)
|
SDL_Camera *SDL_FindPhysicalCameraByCallback(bool (*callback)(SDL_Camera *device, void *userdata), void *userdata)
|
||||||
{
|
{
|
||||||
if (!SDL_GetCurrentCameraDriver()) {
|
if (!SDL_GetCurrentCameraDriver()) {
|
||||||
SDL_SetError("Camera subsystem is not initialized");
|
SDL_SetError("Camera subsystem is not initialized");
|
||||||
|
@ -784,22 +784,22 @@ void SDL_CameraThreadSetup(SDL_Camera *device)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_CameraThreadIterate(SDL_Camera *device)
|
bool SDL_CameraThreadIterate(SDL_Camera *device)
|
||||||
{
|
{
|
||||||
SDL_LockMutex(device->lock);
|
SDL_LockMutex(device->lock);
|
||||||
|
|
||||||
if (SDL_AtomicGet(&device->shutdown)) {
|
if (SDL_AtomicGet(&device->shutdown)) {
|
||||||
SDL_UnlockMutex(device->lock);
|
SDL_UnlockMutex(device->lock);
|
||||||
return SDL_FALSE; // we're done, shut it down.
|
return false; // we're done, shut it down.
|
||||||
}
|
}
|
||||||
|
|
||||||
const int permission = device->permission;
|
const int permission = device->permission;
|
||||||
if (permission <= 0) {
|
if (permission <= 0) {
|
||||||
SDL_UnlockMutex(device->lock);
|
SDL_UnlockMutex(device->lock);
|
||||||
return (permission < 0) ? SDL_FALSE : SDL_TRUE; // if permission was denied, shut it down. if undecided, we're done for now.
|
return (permission < 0) ? false : true; // if permission was denied, shut it down. if undecided, we're done for now.
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool failed = SDL_FALSE; // set to true if disaster worthy of treating the device as lost has happened.
|
bool failed = false; // set to true if disaster worthy of treating the device as lost has happened.
|
||||||
SDL_Surface *acquired = NULL;
|
SDL_Surface *acquired = NULL;
|
||||||
SDL_Surface *output_surface = NULL;
|
SDL_Surface *output_surface = NULL;
|
||||||
SurfaceList *slist = NULL;
|
SurfaceList *slist = NULL;
|
||||||
|
@ -851,7 +851,7 @@ SDL_bool SDL_CameraThreadIterate(SDL_Camera *device)
|
||||||
#if DEBUG_CAMERA
|
#if DEBUG_CAMERA
|
||||||
SDL_Log("CAMERA: dev[%p] error AcquireFrame: %s", device, SDL_GetError());
|
SDL_Log("CAMERA: dev[%p] error AcquireFrame: %s", device, SDL_GetError());
|
||||||
#endif
|
#endif
|
||||||
failed = SDL_TRUE;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we can let go of the lock once we've tried to grab a frame of video and maybe moved the output frame off the empty list.
|
// we can let go of the lock once we've tried to grab a frame of video and maybe moved the output frame off the empty list.
|
||||||
|
@ -908,7 +908,7 @@ SDL_bool SDL_CameraThreadIterate(SDL_Camera *device)
|
||||||
SDL_UnlockMutex(device->lock);
|
SDL_UnlockMutex(device->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE; // always go on if not shutting down, even if device failed.
|
return true; // always go on if not shutting down, even if device failed.
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_CameraThreadShutdown(SDL_Camera *device)
|
void SDL_CameraThreadShutdown(SDL_Camera *device)
|
||||||
|
@ -1140,7 +1140,7 @@ SDL_Camera *SDL_OpenCamera(SDL_CameraID instance_id, const SDL_CameraSpec *spec)
|
||||||
|
|
||||||
// if we have to scale _and_ convert, we need a middleman surface, since we can't do both changes at once.
|
// if we have to scale _and_ convert, we need a middleman surface, since we can't do both changes at once.
|
||||||
if (device->needs_scaling && device->needs_conversion) {
|
if (device->needs_scaling && device->needs_conversion) {
|
||||||
const SDL_bool downsampling_first = (device->needs_scaling < 0);
|
const bool downsampling_first = (device->needs_scaling < 0);
|
||||||
const SDL_CameraSpec *s = downsampling_first ? &device->spec : &closest;
|
const SDL_CameraSpec *s = downsampling_first ? &device->spec : &closest;
|
||||||
const SDL_PixelFormat fmt = downsampling_first ? closest.format : device->spec.format;
|
const SDL_PixelFormat fmt = downsampling_first ? closest.format : device->spec.format;
|
||||||
device->conversion_surface = SDL_CreateSurface(s->width, s->height, fmt);
|
device->conversion_surface = SDL_CreateSurface(s->width, s->height, fmt);
|
||||||
|
@ -1229,7 +1229,7 @@ SDL_Surface *SDL_AcquireCameraFrame(SDL_Camera *camera, Uint64 *timestampNS)
|
||||||
slist = slist->next;
|
slist = slist->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SDL_bool list_is_empty = (slist == slistprev);
|
const bool list_is_empty = (slist == slistprev);
|
||||||
if (!list_is_empty) { // report the oldest frame.
|
if (!list_is_empty) { // report the oldest frame.
|
||||||
if (timestampNS) {
|
if (timestampNS) {
|
||||||
*timestampNS = slist->timestampNS;
|
*timestampNS = slist->timestampNS;
|
||||||
|
@ -1398,7 +1398,7 @@ static Uint32 HashCameraID(const void *key, void *data)
|
||||||
return ((Uint32) ((uintptr_t) key)) - 1;
|
return ((Uint32) ((uintptr_t) key)) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool MatchCameraID(const void *a, const void *b, void *data)
|
static bool MatchCameraID(const void *a, const void *b, void *data)
|
||||||
{
|
{
|
||||||
return (a == b); // simple integers, just compare them as pointer values.
|
return (a == b); // simple integers, just compare them as pointer values.
|
||||||
}
|
}
|
||||||
|
@ -1419,7 +1419,7 @@ int SDL_CameraInit(const char *driver_name)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_HashTable *device_hash = SDL_CreateHashTable(NULL, 8, HashCameraID, MatchCameraID, NukeCameraHashItem, SDL_FALSE);
|
SDL_HashTable *device_hash = SDL_CreateHashTable(NULL, 8, HashCameraID, MatchCameraID, NukeCameraHashItem, false);
|
||||||
if (!device_hash) {
|
if (!device_hash) {
|
||||||
SDL_DestroyRWLock(device_hash_lock);
|
SDL_DestroyRWLock(device_hash_lock);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1430,8 +1430,8 @@ int SDL_CameraInit(const char *driver_name)
|
||||||
driver_name = SDL_GetHint(SDL_HINT_CAMERA_DRIVER);
|
driver_name = SDL_GetHint(SDL_HINT_CAMERA_DRIVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool initialized = SDL_FALSE;
|
bool initialized = false;
|
||||||
SDL_bool tried_to_init = SDL_FALSE;
|
bool tried_to_init = false;
|
||||||
|
|
||||||
if (driver_name && (*driver_name != 0)) {
|
if (driver_name && (*driver_name != 0)) {
|
||||||
char *driver_name_copy = SDL_strdup(driver_name);
|
char *driver_name_copy = SDL_strdup(driver_name);
|
||||||
|
@ -1451,7 +1451,7 @@ int SDL_CameraInit(const char *driver_name)
|
||||||
|
|
||||||
for (int i = 0; bootstrap[i]; i++) {
|
for (int i = 0; bootstrap[i]; i++) {
|
||||||
if (SDL_strcasecmp(bootstrap[i]->name, driver_attempt) == 0) {
|
if (SDL_strcasecmp(bootstrap[i]->name, driver_attempt) == 0) {
|
||||||
tried_to_init = SDL_TRUE;
|
tried_to_init = true;
|
||||||
SDL_zero(camera_driver);
|
SDL_zero(camera_driver);
|
||||||
camera_driver.pending_events_tail = &camera_driver.pending_events;
|
camera_driver.pending_events_tail = &camera_driver.pending_events;
|
||||||
camera_driver.device_hash_lock = device_hash_lock;
|
camera_driver.device_hash_lock = device_hash_lock;
|
||||||
|
@ -1459,7 +1459,7 @@ int SDL_CameraInit(const char *driver_name)
|
||||||
if (bootstrap[i]->init(&camera_driver.impl)) {
|
if (bootstrap[i]->init(&camera_driver.impl)) {
|
||||||
camera_driver.name = bootstrap[i]->name;
|
camera_driver.name = bootstrap[i]->name;
|
||||||
camera_driver.desc = bootstrap[i]->desc;
|
camera_driver.desc = bootstrap[i]->desc;
|
||||||
initialized = SDL_TRUE;
|
initialized = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1475,7 +1475,7 @@ int SDL_CameraInit(const char *driver_name)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tried_to_init = SDL_TRUE;
|
tried_to_init = true;
|
||||||
SDL_zero(camera_driver);
|
SDL_zero(camera_driver);
|
||||||
camera_driver.pending_events_tail = &camera_driver.pending_events;
|
camera_driver.pending_events_tail = &camera_driver.pending_events;
|
||||||
camera_driver.device_hash_lock = device_hash_lock;
|
camera_driver.device_hash_lock = device_hash_lock;
|
||||||
|
@ -1483,7 +1483,7 @@ int SDL_CameraInit(const char *driver_name)
|
||||||
if (bootstrap[i]->init(&camera_driver.impl)) {
|
if (bootstrap[i]->init(&camera_driver.impl)) {
|
||||||
camera_driver.name = bootstrap[i]->name;
|
camera_driver.name = bootstrap[i]->name;
|
||||||
camera_driver.desc = bootstrap[i]->desc;
|
camera_driver.desc = bootstrap[i]->desc;
|
||||||
initialized = SDL_TRUE;
|
initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,10 +39,10 @@ extern SDL_Camera *SDL_AddCamera(const char *name, SDL_CameraPosition position,
|
||||||
extern void SDL_CameraDisconnected(SDL_Camera *device);
|
extern void SDL_CameraDisconnected(SDL_Camera *device);
|
||||||
|
|
||||||
// Find an SDL_Camera, selected by a callback. NULL if not found. DOES NOT LOCK THE DEVICE.
|
// Find an SDL_Camera, selected by a callback. NULL if not found. DOES NOT LOCK THE DEVICE.
|
||||||
extern SDL_Camera *SDL_FindPhysicalCameraByCallback(SDL_bool (*callback)(SDL_Camera *device, void *userdata), void *userdata);
|
extern SDL_Camera *SDL_FindPhysicalCameraByCallback(bool (*callback)(SDL_Camera *device, void *userdata), void *userdata);
|
||||||
|
|
||||||
// Backends should call this when the user has approved/denied access to a camera.
|
// Backends should call this when the user has approved/denied access to a camera.
|
||||||
extern void SDL_CameraPermissionOutcome(SDL_Camera *device, SDL_bool approved);
|
extern void SDL_CameraPermissionOutcome(SDL_Camera *device, bool approved);
|
||||||
|
|
||||||
// Backends can call this to get a standardized name for a thread to power a specific camera device.
|
// Backends can call this to get a standardized name for a thread to power a specific camera device.
|
||||||
extern char *SDL_GetCameraThreadName(SDL_Camera *device, char *buf, size_t buflen);
|
extern char *SDL_GetCameraThreadName(SDL_Camera *device, char *buf, size_t buflen);
|
||||||
|
@ -53,7 +53,7 @@ extern void UnrefPhysicalCamera(SDL_Camera *device);
|
||||||
|
|
||||||
// These functions are the heart of the camera threads. Backends can call them directly if they aren't using the SDL-provided thread.
|
// These functions are the heart of the camera threads. Backends can call them directly if they aren't using the SDL-provided thread.
|
||||||
extern void SDL_CameraThreadSetup(SDL_Camera *device);
|
extern void SDL_CameraThreadSetup(SDL_Camera *device);
|
||||||
extern SDL_bool SDL_CameraThreadIterate(SDL_Camera *device);
|
extern bool SDL_CameraThreadIterate(SDL_Camera *device);
|
||||||
extern void SDL_CameraThreadShutdown(SDL_Camera *device);
|
extern void SDL_CameraThreadShutdown(SDL_Camera *device);
|
||||||
|
|
||||||
// common utility functionality to gather up camera specs. Not required!
|
// common utility functionality to gather up camera specs. Not required!
|
||||||
|
@ -138,8 +138,8 @@ struct SDL_Camera
|
||||||
// non-zero if acquire_surface needs to be scaled for final output.
|
// non-zero if acquire_surface needs to be scaled for final output.
|
||||||
int needs_scaling; // -1: downscale, 0: no scaling, 1: upscale
|
int needs_scaling; // -1: downscale, 0: no scaling, 1: upscale
|
||||||
|
|
||||||
// SDL_TRUE if acquire_surface needs to be converted for final output.
|
// true if acquire_surface needs to be converted for final output.
|
||||||
SDL_bool needs_conversion;
|
bool needs_conversion;
|
||||||
|
|
||||||
// Current state flags
|
// Current state flags
|
||||||
SDL_AtomicInt shutdown;
|
SDL_AtomicInt shutdown;
|
||||||
|
@ -169,7 +169,7 @@ typedef struct SDL_CameraDriverImpl
|
||||||
void (*FreeDeviceHandle)(SDL_Camera *device); // SDL is done with this device; free the handle from SDL_AddCamera()
|
void (*FreeDeviceHandle)(SDL_Camera *device); // SDL is done with this device; free the handle from SDL_AddCamera()
|
||||||
void (*Deinitialize)(void);
|
void (*Deinitialize)(void);
|
||||||
|
|
||||||
SDL_bool ProvidesOwnCallbackThread;
|
bool ProvidesOwnCallbackThread;
|
||||||
} SDL_CameraDriverImpl;
|
} SDL_CameraDriverImpl;
|
||||||
|
|
||||||
typedef struct SDL_PendingCameraEvent
|
typedef struct SDL_PendingCameraEvent
|
||||||
|
@ -198,8 +198,8 @@ typedef struct CameraBootStrap
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *desc;
|
const char *desc;
|
||||||
SDL_bool (*init)(SDL_CameraDriverImpl *impl);
|
bool (*init)(SDL_CameraDriverImpl *impl);
|
||||||
SDL_bool demand_only; // if SDL_TRUE: request explicitly, or it won't be available.
|
bool demand_only; // if true: request explicitly, or it won't be available.
|
||||||
} CameraBootStrap;
|
} CameraBootStrap;
|
||||||
|
|
||||||
// Not all of these are available in a given build. Use #ifdefs, etc.
|
// Not all of these are available in a given build. Use #ifdefs, etc.
|
||||||
|
|
|
@ -520,13 +520,13 @@ static void SDLCALL CameraPermissionCallback(void *userdata, const char *permiss
|
||||||
SDL_Camera *device = (SDL_Camera *) userdata;
|
SDL_Camera *device = (SDL_Camera *) userdata;
|
||||||
if (device->hidden != NULL) { // if device was already closed, don't send an event.
|
if (device->hidden != NULL) { // if device was already closed, don't send an event.
|
||||||
if (!granted) {
|
if (!granted) {
|
||||||
SDL_CameraPermissionOutcome(device, SDL_FALSE); // sorry, permission denied.
|
SDL_CameraPermissionOutcome(device, false); // sorry, permission denied.
|
||||||
} else if (PrepareCamera(device) < 0) { // permission given? Actually open the camera now.
|
} else if (PrepareCamera(device) < 0) { // 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.
|
// 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);
|
SDL_CameraDisconnected(device);
|
||||||
} else {
|
} else {
|
||||||
// okay! We have permission to use the camera _and_ opening the hardware worked out, report that the camera is usable!
|
// okay! We have permission to use the camera _and_ opening the hardware worked out, report that the camera is usable!
|
||||||
SDL_CameraPermissionOutcome(device, SDL_TRUE); // go go go!
|
SDL_CameraPermissionOutcome(device, true); // go go go!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +666,7 @@ static void GatherCameraSpecs(const char *devid, CameraFormatAddData *add_data,
|
||||||
pACameraMetadata_free(metadata);
|
pACameraMetadata_free(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool FindAndroidCameraByID(SDL_Camera *device, void *userdata)
|
static bool FindAndroidCameraByID(SDL_Camera *device, void *userdata)
|
||||||
{
|
{
|
||||||
const char *devid = (const char *) userdata;
|
const char *devid = (const char *) userdata;
|
||||||
return (SDL_strcmp(devid, (const char *) device->handle) == 0);
|
return (SDL_strcmp(devid, (const char *) device->handle) == 0);
|
||||||
|
@ -800,25 +800,25 @@ static void ANDROIDCAMERA_Deinitialize(void)
|
||||||
pAImageReader_new = NULL;
|
pAImageReader_new = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl)
|
static bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||||
{
|
{
|
||||||
// !!! FIXME: slide this off into a subroutine
|
// !!! FIXME: slide this off into a subroutine
|
||||||
// system libraries are in android-24 and later; we currently target android-16 and later, so check if they exist at runtime.
|
// system libraries are in android-24 and later; we currently target android-16 and later, so check if they exist at runtime.
|
||||||
void *libcamera2 = dlopen("libcamera2ndk.so", RTLD_NOW | RTLD_LOCAL);
|
void *libcamera2 = dlopen("libcamera2ndk.so", RTLD_NOW | RTLD_LOCAL);
|
||||||
if (!libcamera2) {
|
if (!libcamera2) {
|
||||||
SDL_Log("CAMERA: libcamera2ndk.so can't be loaded: %s", dlerror());
|
SDL_Log("CAMERA: libcamera2ndk.so can't be loaded: %s", dlerror());
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *libmedia = dlopen("libmediandk.so", RTLD_NOW | RTLD_LOCAL);
|
void *libmedia = dlopen("libmediandk.so", RTLD_NOW | RTLD_LOCAL);
|
||||||
if (!libmedia) {
|
if (!libmedia) {
|
||||||
SDL_Log("CAMERA: libmediandk.so can't be loaded: %s", dlerror());
|
SDL_Log("CAMERA: libmediandk.so can't be loaded: %s", dlerror());
|
||||||
dlclose(libcamera2);
|
dlclose(libcamera2);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool okay = SDL_TRUE;
|
bool okay = true;
|
||||||
#define LOADSYM(lib, fn) if (okay) { p##fn = (pfn##fn) dlsym(lib, #fn); if (!p##fn) { SDL_Log("CAMERA: symbol '%s' can't be found in %s: %s", #fn, #lib "ndk.so", dlerror()); okay = SDL_FALSE; } }
|
#define LOADSYM(lib, fn) if (okay) { p##fn = (pfn##fn) dlsym(lib, #fn); if (!p##fn) { SDL_Log("CAMERA: symbol '%s' can't be found in %s: %s", #fn, #lib "ndk.so", dlerror()); okay = false; } }
|
||||||
//#define LOADSYM(lib, fn) p##fn = (pfn##fn) fn
|
//#define LOADSYM(lib, fn) p##fn = (pfn##fn) fn
|
||||||
LOADSYM(libcamera2, ACameraManager_create);
|
LOADSYM(libcamera2, ACameraManager_create);
|
||||||
LOADSYM(libcamera2, ACameraManager_registerAvailabilityCallback);
|
LOADSYM(libcamera2, ACameraManager_registerAvailabilityCallback);
|
||||||
|
@ -867,7 +867,7 @@ static SDL_bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||||
if (CreateCameraManager() < 0) {
|
if (CreateCameraManager() < 0) {
|
||||||
dlclose(libmedia);
|
dlclose(libmedia);
|
||||||
dlclose(libcamera2);
|
dlclose(libcamera2);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
libcamera2ndk = libcamera2;
|
libcamera2ndk = libcamera2;
|
||||||
|
@ -882,13 +882,13 @@ static SDL_bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||||
impl->FreeDeviceHandle = ANDROIDCAMERA_FreeDeviceHandle;
|
impl->FreeDeviceHandle = ANDROIDCAMERA_FreeDeviceHandle;
|
||||||
impl->Deinitialize = ANDROIDCAMERA_Deinitialize;
|
impl->Deinitialize = ANDROIDCAMERA_Deinitialize;
|
||||||
|
|
||||||
impl->ProvidesOwnCallbackThread = SDL_TRUE;
|
impl->ProvidesOwnCallbackThread = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraBootStrap ANDROIDCAMERA_bootstrap = {
|
CameraBootStrap ANDROIDCAMERA_bootstrap = {
|
||||||
"android", "SDL Android camera driver", ANDROIDCAMERA_Init, SDL_FALSE
|
"android", "SDL Android camera driver", ANDROIDCAMERA_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -83,16 +83,16 @@ static void CoreMediaFormatToSDL(FourCharCode fmt, SDL_PixelFormat *pixel_format
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
static SDL_bool CheckCameraPermissions(SDL_Camera *device)
|
static bool CheckCameraPermissions(SDL_Camera *device)
|
||||||
{
|
{
|
||||||
if (device->permission == 0) { // still expecting a permission result.
|
if (device->permission == 0) { // still expecting a permission result.
|
||||||
if (@available(macOS 14, *)) {
|
if (@available(macOS 14, *)) {
|
||||||
const AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
|
const AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
|
||||||
if (status != AVAuthorizationStatusNotDetermined) { // NotDetermined == still waiting for an answer from the user.
|
if (status != AVAuthorizationStatusNotDetermined) { // NotDetermined == still waiting for an answer from the user.
|
||||||
SDL_CameraPermissionOutcome(device, (status == AVAuthorizationStatusAuthorized) ? SDL_TRUE : SDL_FALSE);
|
SDL_CameraPermissionOutcome(device, (status == AVAuthorizationStatusAuthorized) ? true : false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SDL_CameraPermissionOutcome(device, SDL_TRUE); // always allowed (or just unqueryable...?) on older macOS.
|
SDL_CameraPermissionOutcome(device, true); // always allowed (or just unqueryable...?) on older macOS.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,11 +408,11 @@ static void GatherCameraSpecs(AVCaptureDevice *device, CameraFormatAddData *add_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool FindCoreMediaCameraByUniqueID(SDL_Camera *device, void *userdata)
|
static bool FindCoreMediaCameraByUniqueID(SDL_Camera *device, void *userdata)
|
||||||
{
|
{
|
||||||
NSString *uniqueid = (__bridge NSString *) userdata;
|
NSString *uniqueid = (__bridge NSString *) userdata;
|
||||||
AVCaptureDevice *avdev = (__bridge AVCaptureDevice *) device->handle;
|
AVCaptureDevice *avdev = (__bridge AVCaptureDevice *) device->handle;
|
||||||
return ([uniqueid isEqualToString:avdev.uniqueID]) ? SDL_TRUE : SDL_FALSE;
|
return ([uniqueid isEqualToString:avdev.uniqueID]) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MaybeAddDevice(AVCaptureDevice *avdevice)
|
static void MaybeAddDevice(AVCaptureDevice *avdevice)
|
||||||
|
@ -484,7 +484,7 @@ static void COREMEDIA_Deinitialize(void)
|
||||||
// !!! FIXME: disable hotplug.
|
// !!! FIXME: disable hotplug.
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool COREMEDIA_Init(SDL_CameraDriverImpl *impl)
|
static bool COREMEDIA_Init(SDL_CameraDriverImpl *impl)
|
||||||
{
|
{
|
||||||
impl->DetectDevices = COREMEDIA_DetectDevices;
|
impl->DetectDevices = COREMEDIA_DetectDevices;
|
||||||
impl->OpenDevice = COREMEDIA_OpenDevice;
|
impl->OpenDevice = COREMEDIA_OpenDevice;
|
||||||
|
@ -495,13 +495,13 @@ static SDL_bool COREMEDIA_Init(SDL_CameraDriverImpl *impl)
|
||||||
impl->FreeDeviceHandle = COREMEDIA_FreeDeviceHandle;
|
impl->FreeDeviceHandle = COREMEDIA_FreeDeviceHandle;
|
||||||
impl->Deinitialize = COREMEDIA_Deinitialize;
|
impl->Deinitialize = COREMEDIA_Deinitialize;
|
||||||
|
|
||||||
impl->ProvidesOwnCallbackThread = SDL_TRUE;
|
impl->ProvidesOwnCallbackThread = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraBootStrap COREMEDIA_bootstrap = {
|
CameraBootStrap COREMEDIA_bootstrap = {
|
||||||
"coremedia", "SDL Apple CoreMedia camera driver", COREMEDIA_Init, SDL_FALSE
|
"coremedia", "SDL Apple CoreMedia camera driver", COREMEDIA_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_CAMERA_DRIVER_COREMEDIA
|
#endif // SDL_CAMERA_DRIVER_COREMEDIA
|
||||||
|
|
|
@ -59,7 +59,7 @@ static void DUMMYCAMERA_Deinitialize(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool DUMMYCAMERA_Init(SDL_CameraDriverImpl *impl)
|
static bool DUMMYCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||||
{
|
{
|
||||||
impl->DetectDevices = DUMMYCAMERA_DetectDevices;
|
impl->DetectDevices = DUMMYCAMERA_DetectDevices;
|
||||||
impl->OpenDevice = DUMMYCAMERA_OpenDevice;
|
impl->OpenDevice = DUMMYCAMERA_OpenDevice;
|
||||||
|
@ -70,11 +70,11 @@ static SDL_bool DUMMYCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||||
impl->FreeDeviceHandle = DUMMYCAMERA_FreeDeviceHandle;
|
impl->FreeDeviceHandle = DUMMYCAMERA_FreeDeviceHandle;
|
||||||
impl->Deinitialize = DUMMYCAMERA_Deinitialize;
|
impl->Deinitialize = DUMMYCAMERA_Deinitialize;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraBootStrap DUMMYCAMERA_bootstrap = {
|
CameraBootStrap DUMMYCAMERA_bootstrap = {
|
||||||
"dummy", "SDL dummy camera driver", DUMMYCAMERA_Init, SDL_TRUE
|
"dummy", "SDL dummy camera driver", DUMMYCAMERA_Init, true
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_CAMERA_DRIVER_DUMMY
|
#endif // SDL_CAMERA_DRIVER_DUMMY
|
||||||
|
|
|
@ -107,7 +107,7 @@ static void SDLEmscriptenCameraPermissionOutcome(SDL_Camera *device, int approve
|
||||||
device->acquire_surface->w = w;
|
device->acquire_surface->w = w;
|
||||||
device->acquire_surface->h = h;
|
device->acquire_surface->h = h;
|
||||||
}
|
}
|
||||||
SDL_CameraPermissionOutcome(device, approved ? SDL_TRUE : SDL_FALSE);
|
SDL_CameraPermissionOutcome(device, approved ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int EMSCRIPTENCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
|
static int EMSCRIPTENCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
|
||||||
|
@ -234,7 +234,7 @@ static void EMSCRIPTENCAMERA_DetectDevices(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool EMSCRIPTENCAMERA_Init(SDL_CameraDriverImpl *impl)
|
static bool EMSCRIPTENCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||||
{
|
{
|
||||||
MAIN_THREAD_EM_ASM({
|
MAIN_THREAD_EM_ASM({
|
||||||
if (typeof(Module['SDL3']) === 'undefined') {
|
if (typeof(Module['SDL3']) === 'undefined') {
|
||||||
|
@ -252,13 +252,13 @@ static SDL_bool EMSCRIPTENCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||||
impl->FreeDeviceHandle = EMSCRIPTENCAMERA_FreeDeviceHandle;
|
impl->FreeDeviceHandle = EMSCRIPTENCAMERA_FreeDeviceHandle;
|
||||||
impl->Deinitialize = EMSCRIPTENCAMERA_Deinitialize;
|
impl->Deinitialize = EMSCRIPTENCAMERA_Deinitialize;
|
||||||
|
|
||||||
impl->ProvidesOwnCallbackThread = SDL_TRUE;
|
impl->ProvidesOwnCallbackThread = true;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraBootStrap EMSCRIPTENCAMERA_bootstrap = {
|
CameraBootStrap EMSCRIPTENCAMERA_bootstrap = {
|
||||||
"emscripten", "SDL Emscripten MediaStream camera driver", EMSCRIPTENCAMERA_Init, SDL_FALSE
|
"emscripten", "SDL Emscripten MediaStream camera driver", EMSCRIPTENCAMERA_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
/* *INDENT-ON* */ // clang-format on
|
/* *INDENT-ON* */ // clang-format on
|
||||||
|
|
|
@ -821,7 +821,7 @@ static int MEDIAFOUNDATION_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *
|
||||||
IMFMediaSource_Release(source); // srcreader is holding a reference to this.
|
IMFMediaSource_Release(source); // srcreader is holding a reference to this.
|
||||||
|
|
||||||
// There is no user permission prompt for camera access (I think?)
|
// There is no user permission prompt for camera access (I think?)
|
||||||
SDL_CameraPermissionOutcome(device, SDL_TRUE);
|
SDL_CameraPermissionOutcome(device, true);
|
||||||
|
|
||||||
#undef CHECK_HRESULT
|
#undef CHECK_HRESULT
|
||||||
|
|
||||||
|
@ -962,7 +962,7 @@ static void GatherCameraSpecs(IMFMediaSource *source, CameraFormatAddData *add_d
|
||||||
IMFPresentationDescriptor_Release(presentdesc);
|
IMFPresentationDescriptor_Release(presentdesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool FindMediaFoundationCameraBySymlink(SDL_Camera *device, void *userdata)
|
static bool FindMediaFoundationCameraBySymlink(SDL_Camera *device, void *userdata)
|
||||||
{
|
{
|
||||||
return (SDL_strcmp((const char *) device->handle, (const char *) userdata) == 0);
|
return (SDL_strcmp((const char *) device->handle, (const char *) userdata) == 0);
|
||||||
}
|
}
|
||||||
|
@ -1051,29 +1051,29 @@ static void MEDIAFOUNDATION_Deinitialize(void)
|
||||||
pMFGetStrideForBitmapInfoHeader = NULL;
|
pMFGetStrideForBitmapInfoHeader = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl)
|
static bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl)
|
||||||
{
|
{
|
||||||
// !!! FIXME: slide this off into a subroutine
|
// !!! FIXME: slide this off into a subroutine
|
||||||
HMODULE mf = LoadLibrary(TEXT("Mf.dll")); // this library is available in Vista and later, but also can be on XP with service packs and Windows
|
HMODULE mf = LoadLibrary(TEXT("Mf.dll")); // this library is available in Vista and later, but also can be on XP with service packs and Windows
|
||||||
if (!mf) {
|
if (!mf) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HMODULE mfplat = LoadLibrary(TEXT("Mfplat.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now!
|
HMODULE mfplat = LoadLibrary(TEXT("Mfplat.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now!
|
||||||
if (!mfplat) {
|
if (!mfplat) {
|
||||||
FreeLibrary(mf);
|
FreeLibrary(mf);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HMODULE mfreadwrite = LoadLibrary(TEXT("Mfreadwrite.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now!
|
HMODULE mfreadwrite = LoadLibrary(TEXT("Mfreadwrite.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now!
|
||||||
if (!mfreadwrite) {
|
if (!mfreadwrite) {
|
||||||
FreeLibrary(mfplat);
|
FreeLibrary(mfplat);
|
||||||
FreeLibrary(mf);
|
FreeLibrary(mf);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool okay = SDL_TRUE;
|
bool okay = true;
|
||||||
#define LOADSYM(lib, fn) if (okay) { p##fn = (pfn##fn) GetProcAddress(lib, #fn); if (!p##fn) { okay = SDL_FALSE; } }
|
#define LOADSYM(lib, fn) if (okay) { p##fn = (pfn##fn) GetProcAddress(lib, #fn); if (!p##fn) { okay = false; } }
|
||||||
LOADSYM(mf, MFEnumDeviceSources);
|
LOADSYM(mf, MFEnumDeviceSources);
|
||||||
LOADSYM(mf, MFCreateDeviceSource);
|
LOADSYM(mf, MFCreateDeviceSource);
|
||||||
LOADSYM(mfplat, MFStartup);
|
LOADSYM(mfplat, MFStartup);
|
||||||
|
@ -1087,7 +1087,7 @@ static SDL_bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl)
|
||||||
if (okay) {
|
if (okay) {
|
||||||
const HRESULT ret = pMFStartup(MF_VERSION, MFSTARTUP_LITE);
|
const HRESULT ret = pMFStartup(MF_VERSION, MFSTARTUP_LITE);
|
||||||
if (FAILED(ret)) {
|
if (FAILED(ret)) {
|
||||||
okay = SDL_FALSE;
|
okay = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1095,7 +1095,7 @@ static SDL_bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl)
|
||||||
FreeLibrary(mfreadwrite);
|
FreeLibrary(mfreadwrite);
|
||||||
FreeLibrary(mfplat);
|
FreeLibrary(mfplat);
|
||||||
FreeLibrary(mf);
|
FreeLibrary(mf);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
libmf = mf;
|
libmf = mf;
|
||||||
|
@ -1111,11 +1111,11 @@ static SDL_bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl)
|
||||||
impl->FreeDeviceHandle = MEDIAFOUNDATION_FreeDeviceHandle;
|
impl->FreeDeviceHandle = MEDIAFOUNDATION_FreeDeviceHandle;
|
||||||
impl->Deinitialize = MEDIAFOUNDATION_Deinitialize;
|
impl->Deinitialize = MEDIAFOUNDATION_Deinitialize;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraBootStrap MEDIAFOUNDATION_bootstrap = {
|
CameraBootStrap MEDIAFOUNDATION_bootstrap = {
|
||||||
"mediafoundation", "SDL Windows Media Foundation camera driver", MEDIAFOUNDATION_Init, SDL_FALSE
|
"mediafoundation", "SDL Windows Media Foundation camera driver", MEDIAFOUNDATION_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_CAMERA_DRIVER_MEDIAFOUNDATION
|
#endif // SDL_CAMERA_DRIVER_MEDIAFOUNDATION
|
||||||
|
|
|
@ -54,7 +54,7 @@ enum PW_READY_FLAGS
|
||||||
#define PW_ID_TO_HANDLE(x) (void *)((uintptr_t)x)
|
#define PW_ID_TO_HANDLE(x) (void *)((uintptr_t)x)
|
||||||
#define PW_HANDLE_TO_ID(x) (uint32_t)((uintptr_t)x)
|
#define PW_HANDLE_TO_ID(x) (uint32_t)((uintptr_t)x)
|
||||||
|
|
||||||
static SDL_bool pipewire_initialized = SDL_FALSE;
|
static bool pipewire_initialized = false;
|
||||||
|
|
||||||
// Pipewire entry points
|
// Pipewire entry points
|
||||||
static const char *(*PIPEWIRE_pw_get_library_version)(void);
|
static const char *(*PIPEWIRE_pw_get_library_version)(void);
|
||||||
|
@ -232,9 +232,9 @@ static struct
|
||||||
|
|
||||||
struct spa_list global_list;
|
struct spa_list global_list;
|
||||||
|
|
||||||
SDL_bool have_1_0_5;
|
bool have_1_0_5;
|
||||||
SDL_bool init_complete;
|
bool init_complete;
|
||||||
SDL_bool events_enabled;
|
bool events_enabled;
|
||||||
} hotplug;
|
} hotplug;
|
||||||
|
|
||||||
struct global
|
struct global
|
||||||
|
@ -258,7 +258,7 @@ struct global
|
||||||
struct spa_list pending_list;
|
struct spa_list pending_list;
|
||||||
struct spa_list param_list;
|
struct spa_list param_list;
|
||||||
|
|
||||||
SDL_bool added;
|
bool added;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct global_class
|
struct global_class
|
||||||
|
@ -434,7 +434,7 @@ static void on_stream_state_changed(void *data, enum pw_stream_state old,
|
||||||
case PW_STREAM_STATE_UNCONNECTED:
|
case PW_STREAM_STATE_UNCONNECTED:
|
||||||
break;
|
break;
|
||||||
case PW_STREAM_STATE_STREAMING:
|
case PW_STREAM_STATE_STREAMING:
|
||||||
SDL_CameraPermissionOutcome(device, SDL_TRUE);
|
SDL_CameraPermissionOutcome(device, true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -722,7 +722,7 @@ static void add_device(struct global *g)
|
||||||
}
|
}
|
||||||
SDL_free(data.specs);
|
SDL_free(data.specs);
|
||||||
|
|
||||||
g->added = SDL_TRUE;
|
g->added = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PIPEWIRECAMERA_DetectDevices(void)
|
static void PIPEWIRECAMERA_DetectDevices(void)
|
||||||
|
@ -742,7 +742,7 @@ static void PIPEWIRECAMERA_DetectDevices(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hotplug.events_enabled = SDL_TRUE;
|
hotplug.events_enabled = true;
|
||||||
|
|
||||||
PIPEWIRE_pw_thread_loop_unlock(hotplug.loop);
|
PIPEWIRE_pw_thread_loop_unlock(hotplug.loop);
|
||||||
}
|
}
|
||||||
|
@ -954,7 +954,7 @@ static void hotplug_core_done_callback(void *object, uint32_t id, int seq)
|
||||||
add_device(g);
|
add_device(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hotplug.init_complete = SDL_TRUE;
|
hotplug.init_complete = true;
|
||||||
PIPEWIRE_pw_thread_loop_signal(hotplug.loop, false);
|
PIPEWIRE_pw_thread_loop_signal(hotplug.loop, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -968,7 +968,7 @@ static const struct pw_core_events hotplug_core_events =
|
||||||
/* When in a container, the library version can differ from the underlying core version,
|
/* When in a container, the library version can differ from the underlying core version,
|
||||||
* so make sure the underlying Pipewire implementation meets the version requirement.
|
* so make sure the underlying Pipewire implementation meets the version requirement.
|
||||||
*/
|
*/
|
||||||
static SDL_bool pipewire_server_version_at_least(int major, int minor, int patch)
|
static bool pipewire_server_version_at_least(int major, int minor, int patch)
|
||||||
{
|
{
|
||||||
return (hotplug.server_major >= major) &&
|
return (hotplug.server_major >= major) &&
|
||||||
(hotplug.server_major > major || hotplug.server_minor >= minor) &&
|
(hotplug.server_major > major || hotplug.server_minor >= minor) &&
|
||||||
|
@ -1055,23 +1055,23 @@ static void PIPEWIRECAMERA_Deinitialize(void)
|
||||||
}
|
}
|
||||||
deinit_pipewire_library();
|
deinit_pipewire_library();
|
||||||
spa_zero(hotplug);
|
spa_zero(hotplug);
|
||||||
pipewire_initialized = SDL_FALSE;
|
pipewire_initialized = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool PIPEWIRECAMERA_Init(SDL_CameraDriverImpl *impl)
|
static bool PIPEWIRECAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||||
{
|
{
|
||||||
if (!pipewire_initialized) {
|
if (!pipewire_initialized) {
|
||||||
|
|
||||||
if (init_pipewire_library() < 0) {
|
if (init_pipewire_library() < 0) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pipewire_initialized = SDL_TRUE;
|
pipewire_initialized = true;
|
||||||
|
|
||||||
if (hotplug_loop_init() < 0) {
|
if (hotplug_loop_init() < 0) {
|
||||||
PIPEWIRECAMERA_Deinitialize();
|
PIPEWIRECAMERA_Deinitialize();
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1084,11 +1084,11 @@ static SDL_bool PIPEWIRECAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||||
impl->FreeDeviceHandle = PIPEWIRECAMERA_FreeDeviceHandle;
|
impl->FreeDeviceHandle = PIPEWIRECAMERA_FreeDeviceHandle;
|
||||||
impl->Deinitialize = PIPEWIRECAMERA_Deinitialize;
|
impl->Deinitialize = PIPEWIRECAMERA_Deinitialize;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraBootStrap PIPEWIRECAMERA_bootstrap = {
|
CameraBootStrap PIPEWIRECAMERA_bootstrap = {
|
||||||
"pipewire", "SDL PipeWire camera driver", PIPEWIRECAMERA_Init, SDL_FALSE
|
"pipewire", "SDL PipeWire camera driver", PIPEWIRECAMERA_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_CAMERA_DRIVER_PIPEWIRE
|
#endif // SDL_CAMERA_DRIVER_PIPEWIRE
|
||||||
|
|
|
@ -601,7 +601,7 @@ static int V4L2_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size, pitch;
|
size_t size, pitch;
|
||||||
SDL_CalculateSurfaceSize(device->spec.format, device->spec.width, device->spec.height, &size, &pitch, SDL_FALSE);
|
SDL_CalculateSurfaceSize(device->spec.format, device->spec.width, device->spec.height, &size, &pitch, false);
|
||||||
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
switch (io) {
|
switch (io) {
|
||||||
|
@ -634,12 +634,12 @@ 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.
|
// 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, SDL_TRUE);
|
SDL_CameraPermissionOutcome(device, true);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool FindV4L2CameraByBusInfoCallback(SDL_Camera *device, void *userdata)
|
static bool FindV4L2CameraByBusInfoCallback(SDL_Camera *device, void *userdata)
|
||||||
{
|
{
|
||||||
const V4L2DeviceHandle *handle = (const V4L2DeviceHandle *) device->handle;
|
const V4L2DeviceHandle *handle = (const V4L2DeviceHandle *) device->handle;
|
||||||
return (SDL_strcmp(handle->bus_info, (const char *) userdata) == 0);
|
return (SDL_strcmp(handle->bus_info, (const char *) userdata) == 0);
|
||||||
|
@ -820,7 +820,7 @@ static void V4L2_FreeDeviceHandle(SDL_Camera *device)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SDL_USE_LIBUDEV
|
#ifdef SDL_USE_LIBUDEV
|
||||||
static SDL_bool FindV4L2CameraByPathCallback(SDL_Camera *device, void *userdata)
|
static bool FindV4L2CameraByPathCallback(SDL_Camera *device, void *userdata)
|
||||||
{
|
{
|
||||||
const V4L2DeviceHandle *handle = (const V4L2DeviceHandle *) device->handle;
|
const V4L2DeviceHandle *handle = (const V4L2DeviceHandle *) device->handle;
|
||||||
return (SDL_strcmp(handle->path, (const char *) userdata) == 0);
|
return (SDL_strcmp(handle->path, (const char *) userdata) == 0);
|
||||||
|
@ -878,7 +878,7 @@ static void V4L2_DetectDevices(void)
|
||||||
#endif // SDL_USE_LIBUDEV
|
#endif // SDL_USE_LIBUDEV
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool V4L2_Init(SDL_CameraDriverImpl *impl)
|
static bool V4L2_Init(SDL_CameraDriverImpl *impl)
|
||||||
{
|
{
|
||||||
impl->DetectDevices = V4L2_DetectDevices;
|
impl->DetectDevices = V4L2_DetectDevices;
|
||||||
impl->OpenDevice = V4L2_OpenDevice;
|
impl->OpenDevice = V4L2_OpenDevice;
|
||||||
|
@ -889,11 +889,11 @@ static SDL_bool V4L2_Init(SDL_CameraDriverImpl *impl)
|
||||||
impl->FreeDeviceHandle = V4L2_FreeDeviceHandle;
|
impl->FreeDeviceHandle = V4L2_FreeDeviceHandle;
|
||||||
impl->Deinitialize = V4L2_Deinitialize;
|
impl->Deinitialize = V4L2_Deinitialize;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraBootStrap V4L2_bootstrap = {
|
CameraBootStrap V4L2_bootstrap = {
|
||||||
"v4l2", "SDL Video4Linux2 camera driver", V4L2_Init, SDL_FALSE
|
"v4l2", "SDL Video4Linux2 camera driver", V4L2_Init, false
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_CAMERA_DRIVER_V4L2
|
#endif // SDL_CAMERA_DRIVER_V4L2
|
||||||
|
|
|
@ -162,7 +162,7 @@ void *SDL_GetAndroidJNIEnv(void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (SDLCALL *SDL_RequestAndroidPermissionCallback)(void *userdata, const char *permission, SDL_bool granted);
|
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);
|
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)
|
int SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata)
|
||||||
{
|
{
|
||||||
|
@ -201,21 +201,21 @@ SDL_DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void);
|
||||||
SDL_bool SDL_IsAndroidTV(void)
|
SDL_bool SDL_IsAndroidTV(void)
|
||||||
{
|
{
|
||||||
SDL_Unsupported();
|
SDL_Unsupported();
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void);
|
SDL_DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void);
|
||||||
SDL_bool SDL_IsChromebook(void)
|
SDL_bool SDL_IsChromebook(void)
|
||||||
{
|
{
|
||||||
SDL_Unsupported();
|
SDL_Unsupported();
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void);
|
SDL_DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void);
|
||||||
SDL_bool SDL_IsDeXMode(void)
|
SDL_bool SDL_IsDeXMode(void)
|
||||||
{
|
{
|
||||||
SDL_Unsupported();
|
SDL_Unsupported();
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DECLSPEC Sint32 SDLCALL JNI_OnLoad(void *vm, void *reserved);
|
SDL_DECLSPEC Sint32 SDLCALL JNI_OnLoad(void *vm, void *reserved);
|
||||||
|
|
|
@ -388,9 +388,9 @@ static jmethodID midHapticStop;
|
||||||
static SDL_DisplayOrientation displayNaturalOrientation;
|
static SDL_DisplayOrientation displayNaturalOrientation;
|
||||||
static SDL_DisplayOrientation displayCurrentOrientation;
|
static SDL_DisplayOrientation displayCurrentOrientation;
|
||||||
static float fLastAccelerometer[3];
|
static float fLastAccelerometer[3];
|
||||||
static SDL_bool bHasNewData;
|
static bool bHasNewData;
|
||||||
|
|
||||||
static SDL_bool bHasEnvironmentVariables;
|
static bool bHasEnvironmentVariables;
|
||||||
|
|
||||||
// Android AssetManager
|
// Android AssetManager
|
||||||
static void Internal_Android_Create_AssetManager(void);
|
static void Internal_Android_Create_AssetManager(void);
|
||||||
|
@ -557,7 +557,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||||
register_methods(env, "org/libsdl/app/SDLAudioManager", SDLAudioManager_tab, SDL_arraysize(SDLAudioManager_tab));
|
register_methods(env, "org/libsdl/app/SDLAudioManager", SDLAudioManager_tab, SDL_arraysize(SDLAudioManager_tab));
|
||||||
register_methods(env, "org/libsdl/app/SDLControllerManager", SDLControllerManager_tab, SDL_arraysize(SDLControllerManager_tab));
|
register_methods(env, "org/libsdl/app/SDLControllerManager", SDLControllerManager_tab, SDL_arraysize(SDLControllerManager_tab));
|
||||||
register_methods(env, "org/libsdl/app/HIDDeviceManager", HIDDeviceManager_tab, SDL_arraysize(HIDDeviceManager_tab));
|
register_methods(env, "org/libsdl/app/HIDDeviceManager", HIDDeviceManager_tab, SDL_arraysize(HIDDeviceManager_tab));
|
||||||
SDL_AtomicSet(&bAllowRecreateActivity, SDL_FALSE);
|
SDL_AtomicSet(&bAllowRecreateActivity, false);
|
||||||
|
|
||||||
return JNI_VERSION_1_4;
|
return JNI_VERSION_1_4;
|
||||||
}
|
}
|
||||||
|
@ -759,10 +759,10 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeCheckSDLThreadCounter)(
|
||||||
|
|
||||||
static void SDLCALL SDL_AllowRecreateActivityChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
static void SDLCALL SDL_AllowRecreateActivityChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||||
{
|
{
|
||||||
if (SDL_GetStringBoolean(hint, SDL_FALSE)) {
|
if (SDL_GetStringBoolean(hint, false)) {
|
||||||
SDL_AtomicSet(&bAllowRecreateActivity, SDL_TRUE);
|
SDL_AtomicSet(&bAllowRecreateActivity, true);
|
||||||
} else {
|
} else {
|
||||||
SDL_AtomicSet(&bAllowRecreateActivity, SDL_FALSE);
|
SDL_AtomicSet(&bAllowRecreateActivity, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,7 +824,7 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls,
|
||||||
int argc;
|
int argc;
|
||||||
int len;
|
int len;
|
||||||
char **argv;
|
char **argv;
|
||||||
SDL_bool isstack;
|
bool isstack;
|
||||||
|
|
||||||
// Prepare the arguments.
|
// Prepare the arguments.
|
||||||
len = (*env)->GetArrayLength(env, array);
|
len = (*env)->GetArrayLength(env, array);
|
||||||
|
@ -902,14 +902,14 @@ void Android_SendLifecycleEvent(SDL_AndroidLifecycleEvent event)
|
||||||
SDL_LockMutex(Android_LifecycleMutex);
|
SDL_LockMutex(Android_LifecycleMutex);
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
SDL_bool add_event = SDL_TRUE;
|
bool add_event = true;
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case SDL_ANDROID_LIFECYCLE_WAKE:
|
case SDL_ANDROID_LIFECYCLE_WAKE:
|
||||||
// We don't need more than one wake queued
|
// We don't need more than one wake queued
|
||||||
index = FindLifecycleEvent(SDL_ANDROID_LIFECYCLE_WAKE);
|
index = FindLifecycleEvent(SDL_ANDROID_LIFECYCLE_WAKE);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
add_event = SDL_FALSE;
|
add_event = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_ANDROID_LIFECYCLE_PAUSE:
|
case SDL_ANDROID_LIFECYCLE_PAUSE:
|
||||||
|
@ -917,7 +917,7 @@ void Android_SendLifecycleEvent(SDL_AndroidLifecycleEvent event)
|
||||||
index = FindLifecycleEvent(SDL_ANDROID_LIFECYCLE_RESUME);
|
index = FindLifecycleEvent(SDL_ANDROID_LIFECYCLE_RESUME);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
RemoveLifecycleEvent(index);
|
RemoveLifecycleEvent(index);
|
||||||
add_event = SDL_FALSE;
|
add_event = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_ANDROID_LIFECYCLE_RESUME:
|
case SDL_ANDROID_LIFECYCLE_RESUME:
|
||||||
|
@ -925,14 +925,14 @@ void Android_SendLifecycleEvent(SDL_AndroidLifecycleEvent event)
|
||||||
index = FindLifecycleEvent(SDL_ANDROID_LIFECYCLE_PAUSE);
|
index = FindLifecycleEvent(SDL_ANDROID_LIFECYCLE_PAUSE);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
RemoveLifecycleEvent(index);
|
RemoveLifecycleEvent(index);
|
||||||
add_event = SDL_FALSE;
|
add_event = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_ANDROID_LIFECYCLE_LOWMEMORY:
|
case SDL_ANDROID_LIFECYCLE_LOWMEMORY:
|
||||||
// We don't need more than one low memory event queued
|
// We don't need more than one low memory event queued
|
||||||
index = FindLifecycleEvent(SDL_ANDROID_LIFECYCLE_LOWMEMORY);
|
index = FindLifecycleEvent(SDL_ANDROID_LIFECYCLE_LOWMEMORY);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
add_event = SDL_FALSE;
|
add_event = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_ANDROID_LIFECYCLE_DESTROY:
|
case SDL_ANDROID_LIFECYCLE_DESTROY:
|
||||||
|
@ -943,7 +943,7 @@ void Android_SendLifecycleEvent(SDL_AndroidLifecycleEvent event)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SDL_assert(!"Sending unexpected lifecycle event");
|
SDL_assert(!"Sending unexpected lifecycle event");
|
||||||
add_event = SDL_FALSE;
|
add_event = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -956,9 +956,9 @@ void Android_SendLifecycleEvent(SDL_AndroidLifecycleEvent event)
|
||||||
SDL_UnlockMutex(Android_LifecycleMutex);
|
SDL_UnlockMutex(Android_LifecycleMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 timeoutNS)
|
bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 timeoutNS)
|
||||||
{
|
{
|
||||||
SDL_bool got_event = SDL_FALSE;
|
bool got_event = false;
|
||||||
|
|
||||||
while (!got_event && SDL_WaitSemaphoreTimeoutNS(Android_LifecycleEventSem, timeoutNS) == 0) {
|
while (!got_event && SDL_WaitSemaphoreTimeoutNS(Android_LifecycleEventSem, timeoutNS) == 0) {
|
||||||
SDL_LockMutex(Android_LifecycleMutex);
|
SDL_LockMutex(Android_LifecycleMutex);
|
||||||
|
@ -966,7 +966,7 @@ SDL_bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 tim
|
||||||
if (Android_NumLifecycleEvents > 0) {
|
if (Android_NumLifecycleEvents > 0) {
|
||||||
*event = Android_LifecycleEvents[0];
|
*event = Android_LifecycleEvents[0];
|
||||||
RemoveLifecycleEvent(0);
|
RemoveLifecycleEvent(0);
|
||||||
got_event = SDL_TRUE;
|
got_event = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_UnlockMutex(Android_LifecycleMutex);
|
SDL_UnlockMutex(Android_LifecycleMutex);
|
||||||
|
@ -1333,7 +1333,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)(
|
||||||
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(onNativeSoftReturnKey)(
|
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(onNativeSoftReturnKey)(
|
||||||
JNIEnv *env, jclass jcls)
|
JNIEnv *env, jclass jcls)
|
||||||
{
|
{
|
||||||
if (SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, SDL_FALSE)) {
|
if (SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, false)) {
|
||||||
SDL_StopTextInput(Android_Window);
|
SDL_StopTextInput(Android_Window);
|
||||||
return JNI_TRUE;
|
return JNI_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1381,7 +1381,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)(
|
||||||
fLastAccelerometer[0] = x;
|
fLastAccelerometer[0] = x;
|
||||||
fLastAccelerometer[1] = y;
|
fLastAccelerometer[1] = y;
|
||||||
fLastAccelerometer[2] = z;
|
fLastAccelerometer[2] = z;
|
||||||
bHasNewData = SDL_TRUE;
|
bHasNewData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clipboard
|
// Clipboard
|
||||||
|
@ -1563,16 +1563,16 @@ static struct LocalReferenceHolder LocalReferenceHolder_Setup(const char *func)
|
||||||
return refholder;
|
return refholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool LocalReferenceHolder_Init(struct LocalReferenceHolder *refholder, JNIEnv *env)
|
static bool LocalReferenceHolder_Init(struct LocalReferenceHolder *refholder, JNIEnv *env)
|
||||||
{
|
{
|
||||||
const int capacity = 16;
|
const int capacity = 16;
|
||||||
if ((*env)->PushLocalFrame(env, capacity) < 0) {
|
if ((*env)->PushLocalFrame(env, capacity) < 0) {
|
||||||
SDL_SetError("Failed to allocate enough JVM local references");
|
SDL_SetError("Failed to allocate enough JVM local references");
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
SDL_AtomicIncRef(&s_active);
|
SDL_AtomicIncRef(&s_active);
|
||||||
refholder->m_env = env;
|
refholder->m_env = env;
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LocalReferenceHolder_Cleanup(struct LocalReferenceHolder *refholder)
|
static void LocalReferenceHolder_Cleanup(struct LocalReferenceHolder *refholder)
|
||||||
|
@ -1611,7 +1611,7 @@ void Android_JNI_SetActivityTitle(const char *title)
|
||||||
(*env)->DeleteLocalRef(env, jtitle);
|
(*env)->DeleteLocalRef(env, jtitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Android_JNI_SetWindowStyle(SDL_bool fullscreen)
|
void Android_JNI_SetWindowStyle(bool fullscreen)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
(*env)->CallStaticVoidMethod(env, mActivityClass, midSetWindowStyle, fullscreen ? 1 : 0);
|
(*env)->CallStaticVoidMethod(env, mActivityClass, midSetWindowStyle, fullscreen ? 1 : 0);
|
||||||
|
@ -1642,23 +1642,23 @@ void Android_JNI_MinizeWindow(void)
|
||||||
(*env)->CallStaticVoidMethod(env, mActivityClass, midMinimizeWindow);
|
(*env)->CallStaticVoidMethod(env, mActivityClass, midMinimizeWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void)
|
bool Android_JNI_ShouldMinimizeOnFocusLoss(void)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midShouldMinimizeOnFocusLoss);
|
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midShouldMinimizeOnFocusLoss);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_JNI_GetAccelerometerValues(float values[3])
|
bool Android_JNI_GetAccelerometerValues(float values[3])
|
||||||
{
|
{
|
||||||
SDL_bool retval = SDL_FALSE;
|
bool retval = false;
|
||||||
|
|
||||||
if (bHasNewData) {
|
if (bHasNewData) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 3; ++i) {
|
for (i = 0; i < 3; ++i) {
|
||||||
values[i] = fLastAccelerometer[i];
|
values[i] = fLastAccelerometer[i];
|
||||||
}
|
}
|
||||||
bHasNewData = SDL_FALSE;
|
bHasNewData = false;
|
||||||
retval = SDL_TRUE;
|
retval = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -1694,7 +1694,7 @@ void Android_AudioThreadInit(SDL_AudioDevice *device)
|
||||||
|
|
||||||
// Test for an exception and call SDL_SetError with its detail if one occurs
|
// Test for an exception and call SDL_SetError with its detail if one occurs
|
||||||
// If the parameter silent is truthy then SDL_SetError() will not be called.
|
// If the parameter silent is truthy then SDL_SetError() will not be called.
|
||||||
static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
|
static bool Android_JNI_ExceptionOccurred(bool silent)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
jthrowable exception;
|
jthrowable exception;
|
||||||
|
@ -1734,10 +1734,10 @@ static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
|
||||||
(*env)->ReleaseStringUTFChars(env, exceptionName, exceptionNameUTF8);
|
(*env)->ReleaseStringUTFChars(env, exceptionName, exceptionNameUTF8);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Internal_Android_Create_AssetManager(void)
|
static void Internal_Android_Create_AssetManager(void)
|
||||||
|
@ -1773,7 +1773,7 @@ static void Internal_Android_Create_AssetManager(void)
|
||||||
|
|
||||||
if (!asset_manager) {
|
if (!asset_manager) {
|
||||||
(*env)->DeleteGlobalRef(env, javaAssetManagerRef);
|
(*env)->DeleteGlobalRef(env, javaAssetManagerRef);
|
||||||
Android_JNI_ExceptionOccurred(SDL_TRUE);
|
Android_JNI_ExceptionOccurred(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalReferenceHolder_Cleanup(&refs);
|
LocalReferenceHolder_Cleanup(&refs);
|
||||||
|
@ -1872,7 +1872,7 @@ char *Android_JNI_GetClipboardText(void)
|
||||||
return (!text) ? SDL_strdup("") : text;
|
return (!text) ? SDL_strdup("") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_JNI_HasClipboardText(void)
|
bool Android_JNI_HasClipboardText(void)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midClipboardHasText);
|
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midClipboardHasText);
|
||||||
|
@ -2055,9 +2055,9 @@ int Android_JNI_SendMessage(int command, int param)
|
||||||
return success ? 0 : -1;
|
return success ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Android_JNI_SuspendScreenSaver(SDL_bool suspend)
|
int Android_JNI_SuspendScreenSaver(bool suspend)
|
||||||
{
|
{
|
||||||
return Android_JNI_SendMessage(COMMAND_SET_KEEP_SCREEN_ON, (suspend == SDL_FALSE) ? 0 : 1);
|
return Android_JNI_SendMessage(COMMAND_SET_KEEP_SCREEN_ON, (suspend == false) ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Android_JNI_ShowScreenKeyboard(int input_type, SDL_Rect *inputRect)
|
void Android_JNI_ShowScreenKeyboard(int input_type, SDL_Rect *inputRect)
|
||||||
|
@ -2078,7 +2078,7 @@ void Android_JNI_HideScreenKeyboard(void)
|
||||||
Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0);
|
Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_JNI_IsScreenKeyboardShown(void)
|
bool Android_JNI_IsScreenKeyboardShown(void)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
jboolean is_shown = 0;
|
jboolean is_shown = 0;
|
||||||
|
@ -2216,7 +2216,7 @@ int SDL_GetAndroidSDKVersion(void)
|
||||||
return sdk_version;
|
return sdk_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_IsAndroidTablet(void)
|
bool SDL_IsAndroidTablet(void)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsTablet);
|
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsTablet);
|
||||||
|
@ -2286,7 +2286,7 @@ const char *SDL_GetAndroidInternalStoragePath(void)
|
||||||
mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject),
|
mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject),
|
||||||
"getCanonicalPath", "()Ljava/lang/String;");
|
"getCanonicalPath", "()Ljava/lang/String;");
|
||||||
pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid);
|
pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid);
|
||||||
if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
|
if (Android_JNI_ExceptionOccurred(false)) {
|
||||||
LocalReferenceHolder_Cleanup(&refs);
|
LocalReferenceHolder_Cleanup(&refs);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2445,9 +2445,9 @@ void Android_JNI_GetManifestEnvironmentVariables(void)
|
||||||
|
|
||||||
if (!bHasEnvironmentVariables) {
|
if (!bHasEnvironmentVariables) {
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
SDL_bool ret = (*env)->CallStaticBooleanMethod(env, mActivityClass, midGetManifestEnvironmentVariables);
|
bool ret = (*env)->CallStaticBooleanMethod(env, mActivityClass, midGetManifestEnvironmentVariables);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
bHasEnvironmentVariables = SDL_TRUE;
|
bHasEnvironmentVariables = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2474,25 +2474,25 @@ void Android_JNI_DestroyCustomCursor(int cursorID)
|
||||||
(*env)->CallStaticVoidMethod(env, mActivityClass, midDestroyCustomCursor, cursorID);
|
(*env)->CallStaticVoidMethod(env, mActivityClass, midDestroyCustomCursor, cursorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_JNI_SetCustomCursor(int cursorID)
|
bool Android_JNI_SetCustomCursor(int cursorID)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetCustomCursor, cursorID);
|
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetCustomCursor, cursorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_JNI_SetSystemCursor(int cursorID)
|
bool Android_JNI_SetSystemCursor(int cursorID)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetSystemCursor, cursorID);
|
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetSystemCursor, cursorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_JNI_SupportsRelativeMouse(void)
|
bool Android_JNI_SupportsRelativeMouse(void)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSupportsRelativeMouse);
|
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSupportsRelativeMouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled)
|
bool Android_JNI_SetRelativeMouseEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetRelativeMouseEnabled, (enabled == 1));
|
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetRelativeMouseEnabled, (enabled == 1));
|
||||||
|
@ -2519,7 +2519,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePermissionResult)(
|
||||||
if (info->request_code == (int) requestCode) {
|
if (info->request_code == (int) requestCode) {
|
||||||
prev->next = info->next;
|
prev->next = info->next;
|
||||||
SDL_UnlockMutex(Android_ActivityMutex);
|
SDL_UnlockMutex(Android_ActivityMutex);
|
||||||
info->callback(info->userdata, info->permission, result ? SDL_TRUE : SDL_FALSE);
|
info->callback(info->userdata, info->permission, result ? true : false);
|
||||||
SDL_free(info->permission);
|
SDL_free(info->permission);
|
||||||
SDL_free(info);
|
SDL_free(info);
|
||||||
return;
|
return;
|
||||||
|
@ -2776,18 +2776,18 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeFileDialog)(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_JNI_OpenFileDialog(
|
bool Android_JNI_OpenFileDialog(
|
||||||
SDL_DialogFileCallback callback, void* userdata,
|
SDL_DialogFileCallback callback, void* userdata,
|
||||||
const SDL_DialogFileFilter *filters, int nfilters, SDL_bool forwrite,
|
const SDL_DialogFileFilter *filters, int nfilters, bool forwrite,
|
||||||
SDL_bool multiple)
|
bool multiple)
|
||||||
{
|
{
|
||||||
if (mAndroidFileDialogData.callback != NULL) {
|
if (mAndroidFileDialogData.callback != NULL) {
|
||||||
SDL_SetError("Only one file dialog can be run at a time.");
|
SDL_SetError("Only one file dialog can be run at a time.");
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forwrite) {
|
if (forwrite) {
|
||||||
multiple = SDL_FALSE;
|
multiple = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
|
@ -2821,10 +2821,10 @@ SDL_bool Android_JNI_OpenFileDialog(
|
||||||
SDL_AtomicAdd(&next_request_code, -1);
|
SDL_AtomicAdd(&next_request_code, -1);
|
||||||
SDL_SetError("Unspecified error in JNI");
|
SDL_SetError("Unspecified error in JNI");
|
||||||
|
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SDL_PLATFORM_ANDROID
|
#endif // SDL_PLATFORM_ANDROID
|
||||||
|
|
|
@ -50,22 +50,22 @@ typedef enum
|
||||||
} SDL_AndroidLifecycleEvent;
|
} SDL_AndroidLifecycleEvent;
|
||||||
|
|
||||||
void Android_SendLifecycleEvent(SDL_AndroidLifecycleEvent event);
|
void Android_SendLifecycleEvent(SDL_AndroidLifecycleEvent event);
|
||||||
SDL_bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 timeoutNS);
|
bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 timeoutNS);
|
||||||
|
|
||||||
void Android_LockActivityMutex(void);
|
void Android_LockActivityMutex(void);
|
||||||
void Android_UnlockActivityMutex(void);
|
void Android_UnlockActivityMutex(void);
|
||||||
|
|
||||||
// Interface from the SDL library into the Android Java activity
|
// Interface from the SDL library into the Android Java activity
|
||||||
extern void Android_JNI_SetActivityTitle(const char *title);
|
extern void Android_JNI_SetActivityTitle(const char *title);
|
||||||
extern void Android_JNI_SetWindowStyle(SDL_bool fullscreen);
|
extern void Android_JNI_SetWindowStyle(bool fullscreen);
|
||||||
extern void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint);
|
extern void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint);
|
||||||
extern void Android_JNI_MinizeWindow(void);
|
extern void Android_JNI_MinizeWindow(void);
|
||||||
extern SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void);
|
extern bool Android_JNI_ShouldMinimizeOnFocusLoss(void);
|
||||||
|
|
||||||
extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]);
|
extern bool Android_JNI_GetAccelerometerValues(float values[3]);
|
||||||
extern void Android_JNI_ShowScreenKeyboard(int input_type, SDL_Rect *inputRect);
|
extern void Android_JNI_ShowScreenKeyboard(int input_type, SDL_Rect *inputRect);
|
||||||
extern void Android_JNI_HideScreenKeyboard(void);
|
extern void Android_JNI_HideScreenKeyboard(void);
|
||||||
extern SDL_bool Android_JNI_IsScreenKeyboardShown(void);
|
extern bool Android_JNI_IsScreenKeyboardShown(void);
|
||||||
extern ANativeWindow *Android_JNI_GetNativeWindow(void);
|
extern ANativeWindow *Android_JNI_GetNativeWindow(void);
|
||||||
|
|
||||||
extern SDL_DisplayOrientation Android_JNI_GetDisplayNaturalOrientation(void);
|
extern SDL_DisplayOrientation Android_JNI_GetDisplayNaturalOrientation(void);
|
||||||
|
@ -77,8 +77,8 @@ void Android_StopAudioHotplug(void);
|
||||||
extern void Android_AudioThreadInit(SDL_AudioDevice *device);
|
extern void Android_AudioThreadInit(SDL_AudioDevice *device);
|
||||||
|
|
||||||
// Detecting device type
|
// Detecting device type
|
||||||
extern SDL_bool Android_IsDeXMode(void);
|
extern bool Android_IsDeXMode(void);
|
||||||
extern SDL_bool Android_IsChromebook(void);
|
extern bool Android_IsChromebook(void);
|
||||||
|
|
||||||
int Android_JNI_FileOpen(void **puserdata, const char *fileName, const char *mode);
|
int Android_JNI_FileOpen(void **puserdata, const char *fileName, const char *mode);
|
||||||
Sint64 Android_JNI_FileSize(void *userdata);
|
Sint64 Android_JNI_FileSize(void *userdata);
|
||||||
|
@ -94,7 +94,7 @@ int Android_JNI_OpenFileDescriptor(const char *uri, const char *mode);
|
||||||
// Clipboard support
|
// Clipboard support
|
||||||
int Android_JNI_SetClipboardText(const char *text);
|
int Android_JNI_SetClipboardText(const char *text);
|
||||||
char *Android_JNI_GetClipboardText(void);
|
char *Android_JNI_GetClipboardText(void);
|
||||||
SDL_bool Android_JNI_HasClipboardText(void);
|
bool Android_JNI_HasClipboardText(void);
|
||||||
|
|
||||||
// Power support
|
// Power support
|
||||||
int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seconds, int *percent);
|
int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seconds, int *percent);
|
||||||
|
@ -109,7 +109,7 @@ void Android_JNI_HapticRumble(int device_id, float low_frequency_intensity, floa
|
||||||
void Android_JNI_HapticStop(int device_id);
|
void Android_JNI_HapticStop(int device_id);
|
||||||
|
|
||||||
// Video
|
// Video
|
||||||
int Android_JNI_SuspendScreenSaver(SDL_bool suspend);
|
int Android_JNI_SuspendScreenSaver(bool suspend);
|
||||||
|
|
||||||
// Touch support
|
// Touch support
|
||||||
void Android_JNI_InitTouch(void);
|
void Android_JNI_InitTouch(void);
|
||||||
|
@ -131,12 +131,12 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu
|
||||||
// Cursor support
|
// Cursor support
|
||||||
int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y);
|
int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y);
|
||||||
void Android_JNI_DestroyCustomCursor(int cursorID);
|
void Android_JNI_DestroyCustomCursor(int cursorID);
|
||||||
SDL_bool Android_JNI_SetCustomCursor(int cursorID);
|
bool Android_JNI_SetCustomCursor(int cursorID);
|
||||||
SDL_bool Android_JNI_SetSystemCursor(int cursorID);
|
bool Android_JNI_SetSystemCursor(int cursorID);
|
||||||
|
|
||||||
// Relative mouse support
|
// Relative mouse support
|
||||||
SDL_bool Android_JNI_SupportsRelativeMouse(void);
|
bool Android_JNI_SupportsRelativeMouse(void);
|
||||||
SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled);
|
bool Android_JNI_SetRelativeMouseEnabled(bool enabled);
|
||||||
|
|
||||||
// Show toast notification
|
// Show toast notification
|
||||||
int Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset);
|
int Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset);
|
||||||
|
@ -145,15 +145,12 @@ int Android_JNI_OpenURL(const char *url);
|
||||||
|
|
||||||
int SDL_GetAndroidSDKVersion(void);
|
int SDL_GetAndroidSDKVersion(void);
|
||||||
|
|
||||||
SDL_bool SDL_IsAndroidTablet(void);
|
bool SDL_IsAndroidTablet(void);
|
||||||
SDL_bool SDL_IsAndroidTV(void);
|
|
||||||
SDL_bool SDL_IsChromebook(void);
|
|
||||||
SDL_bool SDL_IsDeXMode(void);
|
|
||||||
|
|
||||||
// File Dialogs
|
// File Dialogs
|
||||||
SDL_bool Android_JNI_OpenFileDialog(SDL_DialogFileCallback callback, void* userdata,
|
bool Android_JNI_OpenFileDialog(SDL_DialogFileCallback callback, void* userdata,
|
||||||
const SDL_DialogFileFilter *filters, int nfilters, SDL_bool forwrite,
|
const SDL_DialogFileFilter *filters, int nfilters, bool forwrite,
|
||||||
SDL_bool multiple);
|
bool multiple);
|
||||||
|
|
||||||
// Ends C function definitions when using C++
|
// Ends C function definitions when using C++
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -53,11 +53,11 @@ struct SDL_EVDEV_keyboard_state
|
||||||
keymap_t *key_map;
|
keymap_t *key_map;
|
||||||
keyboard_info_t *kbInfo;
|
keyboard_info_t *kbInfo;
|
||||||
unsigned char shift_down[4]; // shift state counters..
|
unsigned char shift_down[4]; // shift state counters..
|
||||||
SDL_bool dead_key_next;
|
bool dead_key_next;
|
||||||
int npadch; // -1 or number assembled on pad
|
int npadch; // -1 or number assembled on pad
|
||||||
accentmap_t *accents;
|
accentmap_t *accents;
|
||||||
unsigned int diacr;
|
unsigned int diacr;
|
||||||
SDL_bool rep; // flag telling character repeat
|
bool rep; // flag telling character repeat
|
||||||
unsigned char lockstate;
|
unsigned char lockstate;
|
||||||
unsigned char ledflagstate;
|
unsigned char ledflagstate;
|
||||||
char shift_state;
|
char shift_state;
|
||||||
|
@ -265,7 +265,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
|
||||||
kbd->key_map = &keymap_default_us_acc;
|
kbd->key_map = &keymap_default_us_acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_GetHintBoolean(SDL_HINT_MUTE_CONSOLE_KEYBOARD, SDL_TRUE)) {
|
if (SDL_GetHintBoolean(SDL_HINT_MUTE_CONSOLE_KEYBOARD, true)) {
|
||||||
/* Take keyboard from console and open the actual keyboard device.
|
/* Take keyboard from console and open the actual keyboard device.
|
||||||
* Ensures that the keystrokes do not leak through to the console.
|
* Ensures that the keystrokes do not leak through to the console.
|
||||||
*/
|
*/
|
||||||
|
@ -281,7 +281,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
|
||||||
/* Make sure to restore keyboard if application fails to call
|
/* Make sure to restore keyboard if application fails to call
|
||||||
* SDL_Quit before exit or fatal signal is raised.
|
* SDL_Quit before exit or fatal signal is raised.
|
||||||
*/
|
*/
|
||||||
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) {
|
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, false)) {
|
||||||
kbd_register_emerg_cleanup(kbd);
|
kbd_register_emerg_cleanup(kbd);
|
||||||
}
|
}
|
||||||
SDL_free(devicePath);
|
SDL_free(devicePath);
|
||||||
|
@ -320,7 +320,7 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd)
|
||||||
SDL_free(kbd);
|
SDL_free(kbd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
|
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, bool muted)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ static void k_self(SDL_EVDEV_keyboard_state *kbd, unsigned int value, char up_fl
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kbd->dead_key_next) {
|
if (kbd->dead_key_next) {
|
||||||
kbd->dead_key_next = SDL_FALSE;
|
kbd->dead_key_next = false;
|
||||||
kbd->diacr = value;
|
kbd->diacr = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,7 +254,7 @@ class SDL_BLooper : public BLooper
|
||||||
if (!be_app->IsCursorHidden())
|
if (!be_app->IsCursorHidden())
|
||||||
be_app->HideCursor();
|
be_app->HideCursor();
|
||||||
} else {
|
} else {
|
||||||
SDL_SendMouseMotion(0, win, SDL_DEFAULT_MOUSE_ID, SDL_FALSE, (float)x, (float)y);
|
SDL_SendMouseMotion(0, win, SDL_DEFAULT_MOUSE_ID, false, (float)x, (float)y);
|
||||||
if (SDL_CursorVisible() && be_app->IsCursorHidden())
|
if (SDL_CursorVisible() && be_app->IsCursorHidden())
|
||||||
be_app->ShowCursor();
|
be_app->ShowCursor();
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ static SDL_SpinLock spinlock_dbus_init = 0;
|
||||||
// you must hold spinlock_dbus_init before calling this!
|
// you must hold spinlock_dbus_init before calling this!
|
||||||
static void SDL_DBus_Init_Spinlocked(void)
|
static void SDL_DBus_Init_Spinlocked(void)
|
||||||
{
|
{
|
||||||
static SDL_bool is_dbus_available = SDL_TRUE;
|
static bool is_dbus_available = true;
|
||||||
if (!is_dbus_available) {
|
if (!is_dbus_available) {
|
||||||
return; // don't keep trying if this fails.
|
return; // don't keep trying if this fails.
|
||||||
}
|
}
|
||||||
|
@ -137,12 +137,12 @@ static void SDL_DBus_Init_Spinlocked(void)
|
||||||
DBusError err;
|
DBusError err;
|
||||||
|
|
||||||
if (LoadDBUSLibrary() == -1) {
|
if (LoadDBUSLibrary() == -1) {
|
||||||
is_dbus_available = SDL_FALSE; // can't load at all? Don't keep trying.
|
is_dbus_available = false; // can't load at all? Don't keep trying.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dbus.threads_init_default()) {
|
if (!dbus.threads_init_default()) {
|
||||||
is_dbus_available = SDL_FALSE;
|
is_dbus_available = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ static void SDL_DBus_Init_Spinlocked(void)
|
||||||
if (dbus.error_is_set(&err)) {
|
if (dbus.error_is_set(&err)) {
|
||||||
dbus.error_free(&err);
|
dbus.error_free(&err);
|
||||||
SDL_DBus_Quit();
|
SDL_DBus_Quit();
|
||||||
is_dbus_available = SDL_FALSE;
|
is_dbus_available = false;
|
||||||
return; // oh well
|
return; // oh well
|
||||||
}
|
}
|
||||||
dbus.connection_set_exit_on_disconnect(dbus.session_conn, 0);
|
dbus.connection_set_exit_on_disconnect(dbus.session_conn, 0);
|
||||||
|
@ -186,7 +186,7 @@ void SDL_DBus_Quit(void)
|
||||||
dbus.connection_unref(dbus.session_conn);
|
dbus.connection_unref(dbus.session_conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_GetHintBoolean(SDL_HINT_SHUTDOWN_DBUS_ON_QUIT, SDL_FALSE)) {
|
if (SDL_GetHintBoolean(SDL_HINT_SHUTDOWN_DBUS_ON_QUIT, false)) {
|
||||||
if (dbus.shutdown) {
|
if (dbus.shutdown) {
|
||||||
dbus.shutdown();
|
dbus.shutdown();
|
||||||
}
|
}
|
||||||
|
@ -207,9 +207,9 @@ SDL_DBusContext *SDL_DBus_GetContext(void)
|
||||||
return (dbus_handle && dbus.session_conn) ? &dbus : NULL;
|
return (dbus_handle && dbus.session_conn) ? &dbus : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap)
|
static bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap)
|
||||||
{
|
{
|
||||||
SDL_bool retval = SDL_FALSE;
|
bool retval = false;
|
||||||
|
|
||||||
if (conn) {
|
if (conn) {
|
||||||
DBusMessage *msg = dbus.message_new_method_call(node, path, interface, method);
|
DBusMessage *msg = dbus.message_new_method_call(node, path, interface, method);
|
||||||
|
@ -237,7 +237,7 @@ static SDL_bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *no
|
||||||
}
|
}
|
||||||
firstarg = va_arg(ap_reply, int);
|
firstarg = va_arg(ap_reply, int);
|
||||||
if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_get_args_valist(reply, NULL, firstarg, ap_reply)) {
|
if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_get_args_valist(reply, NULL, firstarg, ap_reply)) {
|
||||||
retval = SDL_TRUE;
|
retval = true;
|
||||||
}
|
}
|
||||||
dbus.message_unref(reply);
|
dbus.message_unref(reply);
|
||||||
}
|
}
|
||||||
|
@ -250,9 +250,9 @@ static SDL_bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *no
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...)
|
bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...)
|
||||||
{
|
{
|
||||||
SDL_bool retval;
|
bool retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, method);
|
va_start(ap, method);
|
||||||
retval = SDL_DBus_CallMethodInternal(conn, node, path, interface, method, ap);
|
retval = SDL_DBus_CallMethodInternal(conn, node, path, interface, method, ap);
|
||||||
|
@ -260,9 +260,9 @@ SDL_bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...)
|
bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...)
|
||||||
{
|
{
|
||||||
SDL_bool retval;
|
bool retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, method);
|
va_start(ap, method);
|
||||||
retval = SDL_DBus_CallMethodInternal(dbus.session_conn, node, path, interface, method, ap);
|
retval = SDL_DBus_CallMethodInternal(dbus.session_conn, node, path, interface, method, ap);
|
||||||
|
@ -270,9 +270,9 @@ SDL_bool SDL_DBus_CallMethod(const char *node, const char *path, const char *int
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap)
|
static bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap)
|
||||||
{
|
{
|
||||||
SDL_bool retval = SDL_FALSE;
|
bool retval = false;
|
||||||
|
|
||||||
if (conn) {
|
if (conn) {
|
||||||
DBusMessage *msg = dbus.message_new_method_call(node, path, interface, method);
|
DBusMessage *msg = dbus.message_new_method_call(node, path, interface, method);
|
||||||
|
@ -281,7 +281,7 @@ static SDL_bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char
|
||||||
if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_append_args_valist(msg, firstarg, ap)) {
|
if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_append_args_valist(msg, firstarg, ap)) {
|
||||||
if (dbus.connection_send(conn, msg, NULL)) {
|
if (dbus.connection_send(conn, msg, NULL)) {
|
||||||
dbus.connection_flush(conn);
|
dbus.connection_flush(conn);
|
||||||
retval = SDL_TRUE;
|
retval = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,9 +292,9 @@ static SDL_bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *msg, const int expectedtype, void *result)
|
static bool SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *msg, const int expectedtype, void *result)
|
||||||
{
|
{
|
||||||
SDL_bool retval = SDL_FALSE;
|
bool retval = false;
|
||||||
|
|
||||||
DBusMessage *reply = dbus.connection_send_with_reply_and_block(conn, msg, 300, NULL);
|
DBusMessage *reply = dbus.connection_send_with_reply_and_block(conn, msg, 300, NULL);
|
||||||
if (reply) {
|
if (reply) {
|
||||||
|
@ -308,7 +308,7 @@ static SDL_bool SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *m
|
||||||
|
|
||||||
if (dbus.message_iter_get_arg_type(&actual_iter) == expectedtype) {
|
if (dbus.message_iter_get_arg_type(&actual_iter) == expectedtype) {
|
||||||
dbus.message_iter_get_basic(&actual_iter, result);
|
dbus.message_iter_get_basic(&actual_iter, result);
|
||||||
retval = SDL_TRUE;
|
retval = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus.message_unref(reply);
|
dbus.message_unref(reply);
|
||||||
|
@ -317,9 +317,9 @@ static SDL_bool SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *m
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...)
|
bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...)
|
||||||
{
|
{
|
||||||
SDL_bool retval;
|
bool retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, method);
|
va_start(ap, method);
|
||||||
retval = SDL_DBus_CallVoidMethodInternal(conn, node, path, interface, method, ap);
|
retval = SDL_DBus_CallVoidMethodInternal(conn, node, path, interface, method, ap);
|
||||||
|
@ -327,9 +327,9 @@ SDL_bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *n
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...)
|
bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...)
|
||||||
{
|
{
|
||||||
SDL_bool retval;
|
bool retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, method);
|
va_start(ap, method);
|
||||||
retval = SDL_DBus_CallVoidMethodInternal(dbus.session_conn, node, path, interface, method, ap);
|
retval = SDL_DBus_CallVoidMethodInternal(dbus.session_conn, node, path, interface, method, ap);
|
||||||
|
@ -337,9 +337,9 @@ SDL_bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result)
|
bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result)
|
||||||
{
|
{
|
||||||
SDL_bool retval = SDL_FALSE;
|
bool retval = false;
|
||||||
|
|
||||||
if (conn) {
|
if (conn) {
|
||||||
DBusMessage *msg = dbus.message_new_method_call(node, path, "org.freedesktop.DBus.Properties", "Get");
|
DBusMessage *msg = dbus.message_new_method_call(node, path, "org.freedesktop.DBus.Properties", "Get");
|
||||||
|
@ -354,7 +354,7 @@ SDL_bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *no
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result)
|
bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result)
|
||||||
{
|
{
|
||||||
return SDL_DBus_QueryPropertyOnConnection(dbus.session_conn, node, path, interface, property, expectedtype, result);
|
return SDL_DBus_QueryPropertyOnConnection(dbus.session_conn, node, path, interface, property, expectedtype, result);
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ void SDL_DBus_ScreensaverTickle(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SDL_DBus_AppendDictWithKeysAndValues(DBusMessageIter *iterInit, const char **keys, const char **values, int count)
|
static bool SDL_DBus_AppendDictWithKeysAndValues(DBusMessageIter *iterInit, const char **keys, const char **values, int count)
|
||||||
{
|
{
|
||||||
DBusMessageIter iterDict;
|
DBusMessageIter iterDict;
|
||||||
|
|
||||||
|
@ -406,16 +406,16 @@ static SDL_bool SDL_DBus_AppendDictWithKeysAndValues(DBusMessageIter *iterInit,
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
/* message_iter_abandon_container_if_open() and message_iter_abandon_container() might be
|
/* message_iter_abandon_container_if_open() and message_iter_abandon_container() might be
|
||||||
* missing if libdbus is too old. Instead, we just return without cleaning up any eventual
|
* missing if libdbus is too old. Instead, we just return without cleaning up any eventual
|
||||||
* open container */
|
* open container */
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SDL_DBus_AppendDictWithKeyValue(DBusMessageIter *iterInit, const char *key, const char *value)
|
static bool SDL_DBus_AppendDictWithKeyValue(DBusMessageIter *iterInit, const char *key, const char *value)
|
||||||
{
|
{
|
||||||
const char *keys[1];
|
const char *keys[1];
|
||||||
const char *values[1];
|
const char *values[1];
|
||||||
|
@ -425,18 +425,18 @@ static SDL_bool SDL_DBus_AppendDictWithKeyValue(DBusMessageIter *iterInit, const
|
||||||
return SDL_DBus_AppendDictWithKeysAndValues(iterInit, keys, values, 1);
|
return SDL_DBus_AppendDictWithKeysAndValues(iterInit, keys, values, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
bool SDL_DBus_ScreensaverInhibit(bool inhibit)
|
||||||
{
|
{
|
||||||
const char *default_inhibit_reason = "Playing a game";
|
const char *default_inhibit_reason = "Playing a game";
|
||||||
|
|
||||||
if ((inhibit && (screensaver_cookie != 0 || inhibit_handle)) || (!inhibit && (screensaver_cookie == 0 && !inhibit_handle))) {
|
if ((inhibit && (screensaver_cookie != 0 || inhibit_handle)) || (!inhibit && (screensaver_cookie == 0 && !inhibit_handle))) {
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dbus.session_conn) {
|
if (!dbus.session_conn) {
|
||||||
/* We either lost connection to the session bus or were not able to
|
/* We either lost connection to the session bus or were not able to
|
||||||
* load the D-Bus library at all. */
|
* load the D-Bus library at all. */
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_DetectSandbox() != SDL_SANDBOX_NONE) {
|
if (SDL_DetectSandbox() != SDL_SANDBOX_NONE) {
|
||||||
|
@ -449,7 +449,7 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
||||||
|
|
||||||
if (inhibit) {
|
if (inhibit) {
|
||||||
DBusMessage *msg;
|
DBusMessage *msg;
|
||||||
SDL_bool retval = SDL_FALSE;
|
bool retval = false;
|
||||||
const char *key = "reason";
|
const char *key = "reason";
|
||||||
const char *reply = NULL;
|
const char *reply = NULL;
|
||||||
const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME);
|
const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME);
|
||||||
|
@ -459,12 +459,12 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
||||||
|
|
||||||
msg = dbus.message_new_method_call(bus_name, path, interface, "Inhibit");
|
msg = dbus.message_new_method_call(bus_name, path, interface, "Inhibit");
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dbus.message_append_args(msg, DBUS_TYPE_STRING, &window, DBUS_TYPE_UINT32, &INHIBIT_IDLE, DBUS_TYPE_INVALID)) {
|
if (!dbus.message_append_args(msg, DBUS_TYPE_STRING, &window, DBUS_TYPE_UINT32, &INHIBIT_IDLE, DBUS_TYPE_INVALID)) {
|
||||||
dbus.message_unref(msg);
|
dbus.message_unref(msg);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus.message_iter_init_append(msg, &iterInit);
|
dbus.message_iter_init_append(msg, &iterInit);
|
||||||
|
@ -472,19 +472,19 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
||||||
// a{sv}
|
// a{sv}
|
||||||
if (!SDL_DBus_AppendDictWithKeyValue(&iterInit, key, reason)) {
|
if (!SDL_DBus_AppendDictWithKeyValue(&iterInit, key, reason)) {
|
||||||
dbus.message_unref(msg);
|
dbus.message_unref(msg);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_DBus_CallWithBasicReply(dbus.session_conn, msg, DBUS_TYPE_OBJECT_PATH, &reply)) {
|
if (SDL_DBus_CallWithBasicReply(dbus.session_conn, msg, DBUS_TYPE_OBJECT_PATH, &reply)) {
|
||||||
inhibit_handle = SDL_strdup(reply);
|
inhibit_handle = SDL_strdup(reply);
|
||||||
retval = SDL_TRUE;
|
retval = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus.message_unref(msg);
|
dbus.message_unref(msg);
|
||||||
return retval;
|
return retval;
|
||||||
} else {
|
} else {
|
||||||
if (!SDL_DBus_CallVoidMethod(bus_name, inhibit_handle, "org.freedesktop.portal.Request", "Close", DBUS_TYPE_INVALID)) {
|
if (!SDL_DBus_CallVoidMethod(bus_name, inhibit_handle, "org.freedesktop.portal.Request", "Close", DBUS_TYPE_INVALID)) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
SDL_free(inhibit_handle);
|
SDL_free(inhibit_handle);
|
||||||
inhibit_handle = NULL;
|
inhibit_handle = NULL;
|
||||||
|
@ -504,18 +504,18 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
||||||
if (!SDL_DBus_CallMethod(bus_name, path, interface, "Inhibit",
|
if (!SDL_DBus_CallMethod(bus_name, path, interface, "Inhibit",
|
||||||
DBUS_TYPE_STRING, &app, DBUS_TYPE_STRING, &reason, DBUS_TYPE_INVALID,
|
DBUS_TYPE_STRING, &app, DBUS_TYPE_STRING, &reason, DBUS_TYPE_INVALID,
|
||||||
DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) {
|
DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
return (screensaver_cookie != 0);
|
return (screensaver_cookie != 0);
|
||||||
} else {
|
} else {
|
||||||
if (!SDL_DBus_CallVoidMethod(bus_name, path, interface, "UnInhibit", DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) {
|
if (!SDL_DBus_CallVoidMethod(bus_name, path, interface, "UnInhibit", DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
screensaver_cookie = 0;
|
screensaver_cookie = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_DBus_PumpEvents(void)
|
void SDL_DBus_PumpEvents(void)
|
||||||
|
|
|
@ -92,17 +92,17 @@ extern void SDL_DBus_Quit(void);
|
||||||
extern SDL_DBusContext *SDL_DBus_GetContext(void);
|
extern SDL_DBusContext *SDL_DBus_GetContext(void);
|
||||||
|
|
||||||
// These use the built-in Session connection.
|
// These use the built-in Session connection.
|
||||||
extern SDL_bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...);
|
extern bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...);
|
||||||
extern SDL_bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...);
|
extern bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...);
|
||||||
extern SDL_bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result);
|
extern bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result);
|
||||||
|
|
||||||
// These use whatever connection you like.
|
// These use whatever connection you like.
|
||||||
extern SDL_bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
|
extern bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
|
||||||
extern SDL_bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
|
extern bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
|
||||||
extern SDL_bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result);
|
extern bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result);
|
||||||
|
|
||||||
extern void SDL_DBus_ScreensaverTickle(void);
|
extern void SDL_DBus_ScreensaverTickle(void);
|
||||||
extern SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit);
|
extern bool SDL_DBus_ScreensaverInhibit(bool inhibit);
|
||||||
|
|
||||||
extern void SDL_DBus_PumpEvents(void);
|
extern void SDL_DBus_PumpEvents(void);
|
||||||
extern char *SDL_DBus_GetLocalMachineId(void);
|
extern char *SDL_DBus_GetLocalMachineId(void);
|
||||||
|
|
|
@ -76,12 +76,12 @@ typedef struct SDL_evdevlist_item
|
||||||
int udev_class;
|
int udev_class;
|
||||||
|
|
||||||
// TODO: use this for every device, not just touchscreen
|
// TODO: use this for every device, not just touchscreen
|
||||||
SDL_bool out_of_sync;
|
bool out_of_sync;
|
||||||
|
|
||||||
/* TODO: expand on this to have data for every possible class (mouse,
|
/* TODO: expand on this to have data for every possible class (mouse,
|
||||||
keyboard, touchpad, etc.). Also there's probably some things in here we
|
keyboard, touchpad, etc.). Also there's probably some things in here we
|
||||||
can pull out to the SDL_evdevlist_item i.e. name */
|
can pull out to the SDL_evdevlist_item i.e. name */
|
||||||
SDL_bool is_touchscreen;
|
bool is_touchscreen;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -108,9 +108,9 @@ typedef struct SDL_evdevlist_item
|
||||||
} *touchscreen_data;
|
} *touchscreen_data;
|
||||||
|
|
||||||
// Mouse state
|
// Mouse state
|
||||||
SDL_bool high_res_wheel;
|
bool high_res_wheel;
|
||||||
SDL_bool high_res_hwheel;
|
bool high_res_hwheel;
|
||||||
SDL_bool relative_mouse;
|
bool relative_mouse;
|
||||||
int mouse_x, mouse_y;
|
int mouse_x, mouse_y;
|
||||||
int mouse_wheel, mouse_hwheel;
|
int mouse_wheel, mouse_hwheel;
|
||||||
int min_x, max_x, range_x;
|
int min_x, max_x, range_x;
|
||||||
|
@ -150,7 +150,7 @@ static Uint8 EVDEV_MouseButtons[] = {
|
||||||
SDL_BUTTON_X2 + 3 // BTN_TASK 0x117
|
SDL_BUTTON_X2 + 3 // BTN_TASK 0x117
|
||||||
};
|
};
|
||||||
|
|
||||||
static int SDL_EVDEV_SetRelativeMouseMode(SDL_bool enabled)
|
static int SDL_EVDEV_SetRelativeMouseMode(bool enabled)
|
||||||
{
|
{
|
||||||
// Mice already send relative events through this interface
|
// Mice already send relative events through this interface
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -159,9 +159,9 @@ static int SDL_EVDEV_SetRelativeMouseMode(SDL_bool enabled)
|
||||||
static void SDL_EVDEV_UpdateKeyboardMute(void)
|
static void SDL_EVDEV_UpdateKeyboardMute(void)
|
||||||
{
|
{
|
||||||
if (SDL_EVDEV_GetDeviceCount(SDL_UDEV_DEVICE_KEYBOARD) > 0) {
|
if (SDL_EVDEV_GetDeviceCount(SDL_UDEV_DEVICE_KEYBOARD) > 0) {
|
||||||
SDL_EVDEV_kbd_set_muted(_this->kbd, SDL_TRUE);
|
SDL_EVDEV_kbd_set_muted(_this->kbd, true);
|
||||||
} else {
|
} else {
|
||||||
SDL_EVDEV_kbd_set_muted(_this->kbd, SDL_FALSE);
|
SDL_EVDEV_kbd_set_muted(_this->kbd, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,11 +544,11 @@ void SDL_EVDEV_Poll(void)
|
||||||
* be window-relative in that case. */
|
* be window-relative in that case. */
|
||||||
switch (item->touchscreen_data->slots[j].delta) {
|
switch (item->touchscreen_data->slots[j].delta) {
|
||||||
case EVDEV_TOUCH_SLOTDELTA_DOWN:
|
case EVDEV_TOUCH_SLOTDELTA_DOWN:
|
||||||
SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, SDL_TRUE, norm_x, norm_y, norm_pressure);
|
SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, true, norm_x, norm_y, norm_pressure);
|
||||||
item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
|
item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
|
||||||
break;
|
break;
|
||||||
case EVDEV_TOUCH_SLOTDELTA_UP:
|
case EVDEV_TOUCH_SLOTDELTA_UP:
|
||||||
SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, SDL_FALSE, norm_x, norm_y, norm_pressure);
|
SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, false, norm_x, norm_y, norm_pressure);
|
||||||
item->touchscreen_data->slots[j].tracking_id = 0;
|
item->touchscreen_data->slots[j].tracking_id = 0;
|
||||||
item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
|
item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
|
||||||
break;
|
break;
|
||||||
|
@ -562,12 +562,12 @@ void SDL_EVDEV_Poll(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->out_of_sync) {
|
if (item->out_of_sync) {
|
||||||
item->out_of_sync = SDL_FALSE;
|
item->out_of_sync = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SYN_DROPPED:
|
case SYN_DROPPED:
|
||||||
if (item->is_touchscreen) {
|
if (item->is_touchscreen) {
|
||||||
item->out_of_sync = SDL_TRUE;
|
item->out_of_sync = true;
|
||||||
}
|
}
|
||||||
SDL_EVDEV_sync_device(item);
|
SDL_EVDEV_sync_device(item);
|
||||||
break;
|
break;
|
||||||
|
@ -610,14 +610,14 @@ static int SDL_EVDEV_init_keyboard(SDL_evdevlist_item *item, int udev_class)
|
||||||
name[0] = '\0';
|
name[0] = '\0';
|
||||||
ioctl(item->fd, EVIOCGNAME(sizeof(name)), name);
|
ioctl(item->fd, EVIOCGNAME(sizeof(name)), name);
|
||||||
|
|
||||||
SDL_AddKeyboard((SDL_KeyboardID)item->fd, name, SDL_TRUE);
|
SDL_AddKeyboard((SDL_KeyboardID)item->fd, name, true);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_EVDEV_destroy_keyboard(SDL_evdevlist_item *item)
|
static void SDL_EVDEV_destroy_keyboard(SDL_evdevlist_item *item)
|
||||||
{
|
{
|
||||||
SDL_RemoveKeyboard((SDL_KeyboardID)item->fd, SDL_TRUE);
|
SDL_RemoveKeyboard((SDL_KeyboardID)item->fd, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
|
static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
|
||||||
|
@ -629,7 +629,7 @@ static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
|
||||||
name[0] = '\0';
|
name[0] = '\0';
|
||||||
ioctl(item->fd, EVIOCGNAME(sizeof(name)), name);
|
ioctl(item->fd, EVIOCGNAME(sizeof(name)), name);
|
||||||
|
|
||||||
SDL_AddMouse((SDL_MouseID)item->fd, name, SDL_TRUE);
|
SDL_AddMouse((SDL_MouseID)item->fd, name, true);
|
||||||
|
|
||||||
ret = ioctl(item->fd, EVIOCGABS(ABS_X), &abs_info);
|
ret = ioctl(item->fd, EVIOCGABS(ABS_X), &abs_info);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -654,7 +654,7 @@ static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
|
||||||
|
|
||||||
static void SDL_EVDEV_destroy_mouse(SDL_evdevlist_item *item)
|
static void SDL_EVDEV_destroy_mouse(SDL_evdevlist_item *item)
|
||||||
{
|
{
|
||||||
SDL_RemoveMouse((SDL_MouseID)item->fd, SDL_TRUE);
|
SDL_RemoveMouse((SDL_MouseID)item->fd, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
||||||
|
@ -932,7 +932,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||||
// For now, we just treat a touchpad like a touchscreen
|
// For now, we just treat a touchpad like a touchscreen
|
||||||
if (udev_class & (SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD)) {
|
if (udev_class & (SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD)) {
|
||||||
int ret;
|
int ret;
|
||||||
item->is_touchscreen = SDL_TRUE;
|
item->is_touchscreen = true;
|
||||||
ret = SDL_EVDEV_init_touchscreen(item, udev_class);
|
ret = SDL_EVDEV_init_touchscreen(item, udev_class);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
close(item->fd);
|
close(item->fd);
|
||||||
|
|
|
@ -84,15 +84,15 @@ static fn_handler_fn *fn_handler[] = {
|
||||||
struct SDL_EVDEV_keyboard_state
|
struct SDL_EVDEV_keyboard_state
|
||||||
{
|
{
|
||||||
int console_fd;
|
int console_fd;
|
||||||
SDL_bool muted;
|
bool muted;
|
||||||
int old_kbd_mode;
|
int old_kbd_mode;
|
||||||
unsigned short **key_maps;
|
unsigned short **key_maps;
|
||||||
unsigned char shift_down[NR_SHIFT]; // shift state counters..
|
unsigned char shift_down[NR_SHIFT]; // shift state counters..
|
||||||
SDL_bool dead_key_next;
|
bool dead_key_next;
|
||||||
int npadch; // -1 or number assembled on pad
|
int npadch; // -1 or number assembled on pad
|
||||||
struct kbdiacrs *accents;
|
struct kbdiacrs *accents;
|
||||||
unsigned int diacr;
|
unsigned int diacr;
|
||||||
SDL_bool rep; // flag telling character repeat
|
bool rep; // flag telling character repeat
|
||||||
unsigned char lockstate;
|
unsigned char lockstate;
|
||||||
unsigned char slockstate;
|
unsigned char slockstate;
|
||||||
unsigned char ledflagstate;
|
unsigned char ledflagstate;
|
||||||
|
@ -321,7 +321,7 @@ static void kbd_vt_acquire_signal_action(int signum)
|
||||||
SDL_AtomicSet(&vt_signal_pending, VT_SIGNAL_ACQUIRE);
|
SDL_AtomicSet(&vt_signal_pending, VT_SIGNAL_ACQUIRE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool setup_vt_signal(int signum, signal_handler handler)
|
static bool setup_vt_signal(int signum, signal_handler handler)
|
||||||
{
|
{
|
||||||
struct sigaction *old_action_p;
|
struct sigaction *old_action_p;
|
||||||
struct sigaction new_action;
|
struct sigaction new_action;
|
||||||
|
@ -330,14 +330,14 @@ static SDL_bool setup_vt_signal(int signum, signal_handler handler)
|
||||||
new_action.sa_handler = handler;
|
new_action.sa_handler = handler;
|
||||||
new_action.sa_flags = SA_RESTART;
|
new_action.sa_flags = SA_RESTART;
|
||||||
if (sigaction(signum, &new_action, old_action_p) < 0) {
|
if (sigaction(signum, &new_action, old_action_p) < 0) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
if (old_action_p->sa_handler != SIG_DFL) {
|
if (old_action_p->sa_handler != SIG_DFL) {
|
||||||
// This signal is already in use
|
// This signal is already in use
|
||||||
sigaction(signum, old_action_p, NULL);
|
sigaction(signum, old_action_p, NULL);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int find_free_signal(signal_handler handler)
|
static int find_free_signal(signal_handler handler)
|
||||||
|
@ -462,7 +462,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
|
||||||
return kbd;
|
return kbd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
|
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, bool muted)
|
||||||
{
|
{
|
||||||
if (!state) {
|
if (!state) {
|
||||||
return;
|
return;
|
||||||
|
@ -473,7 +473,7 @@ void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (muted) {
|
if (muted) {
|
||||||
if (SDL_GetHintBoolean(SDL_HINT_MUTE_CONSOLE_KEYBOARD, SDL_TRUE)) {
|
if (SDL_GetHintBoolean(SDL_HINT_MUTE_CONSOLE_KEYBOARD, true)) {
|
||||||
/* Mute the keyboard so keystrokes only generate evdev events
|
/* Mute the keyboard so keystrokes only generate evdev events
|
||||||
* and do not leak through to the console
|
* and do not leak through to the console
|
||||||
*/
|
*/
|
||||||
|
@ -482,7 +482,7 @@ void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
|
||||||
/* Make sure to restore keyboard if application fails to call
|
/* Make sure to restore keyboard if application fails to call
|
||||||
* SDL_Quit before exit or fatal signal is raised.
|
* SDL_Quit before exit or fatal signal is raised.
|
||||||
*/
|
*/
|
||||||
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) {
|
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, false)) {
|
||||||
kbd_register_emerg_cleanup(state);
|
kbd_register_emerg_cleanup(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -522,7 +522,7 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_EVDEV_kbd_set_muted(state, SDL_FALSE);
|
SDL_EVDEV_kbd_set_muted(state, false);
|
||||||
|
|
||||||
kbd_vt_quit(state->console_fd);
|
kbd_vt_quit(state->console_fd);
|
||||||
|
|
||||||
|
@ -690,7 +690,7 @@ static void fn_num(SDL_EVDEV_keyboard_state *kbd)
|
||||||
|
|
||||||
static void fn_compose(SDL_EVDEV_keyboard_state *kbd)
|
static void fn_compose(SDL_EVDEV_keyboard_state *kbd)
|
||||||
{
|
{
|
||||||
kbd->dead_key_next = SDL_TRUE;
|
kbd->dead_key_next = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -729,7 +729,7 @@ static void k_self(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_f
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kbd->dead_key_next) {
|
if (kbd->dead_key_next) {
|
||||||
kbd->dead_key_next = SDL_FALSE;
|
kbd->dead_key_next = false;
|
||||||
kbd->diacr = value;
|
kbd->diacr = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -974,7 +974,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
|
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, bool muted)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ struct SDL_EVDEV_keyboard_state;
|
||||||
typedef struct SDL_EVDEV_keyboard_state SDL_EVDEV_keyboard_state;
|
typedef struct SDL_EVDEV_keyboard_state SDL_EVDEV_keyboard_state;
|
||||||
|
|
||||||
extern SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void);
|
extern SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void);
|
||||||
extern void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted);
|
extern void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, bool muted);
|
||||||
extern void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data);
|
extern void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data);
|
||||||
extern void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state);
|
extern void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state);
|
||||||
extern void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down);
|
extern void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down);
|
||||||
|
|
|
@ -249,10 +249,10 @@ static void SDLCALL Fcitx_SetCapabilities(void *data,
|
||||||
SDL_DBus_CallVoidMethod(FCITX_DBUS_SERVICE, client->ic_path, FCITX_IC_DBUS_INTERFACE, "SetCapability", DBUS_TYPE_UINT64, &caps, DBUS_TYPE_INVALID);
|
SDL_DBus_CallVoidMethod(FCITX_DBUS_SERVICE, client->ic_path, FCITX_IC_DBUS_INTERFACE, "SetCapability", DBUS_TYPE_UINT64, &caps, DBUS_TYPE_INVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appname, char **ic_path)
|
static bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appname, char **ic_path)
|
||||||
{
|
{
|
||||||
const char *program = "program";
|
const char *program = "program";
|
||||||
SDL_bool retval = SDL_FALSE;
|
bool retval = false;
|
||||||
|
|
||||||
if (dbus && dbus->session_conn) {
|
if (dbus && dbus->session_conn) {
|
||||||
DBusMessage *msg = dbus->message_new_method_call(FCITX_DBUS_SERVICE, FCITX_IM_DBUS_PATH, FCITX_IM_DBUS_INTERFACE, "CreateInputContext");
|
DBusMessage *msg = dbus->message_new_method_call(FCITX_DBUS_SERVICE, FCITX_IM_DBUS_PATH, FCITX_IM_DBUS_INTERFACE, "CreateInputContext");
|
||||||
|
@ -269,7 +269,7 @@ static SDL_bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appna
|
||||||
reply = dbus->connection_send_with_reply_and_block(dbus->session_conn, msg, 300, NULL);
|
reply = dbus->connection_send_with_reply_and_block(dbus->session_conn, msg, 300, NULL);
|
||||||
if (reply) {
|
if (reply) {
|
||||||
if (dbus->message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, ic_path, DBUS_TYPE_INVALID)) {
|
if (dbus->message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, ic_path, DBUS_TYPE_INVALID)) {
|
||||||
retval = SDL_TRUE;
|
retval = true;
|
||||||
}
|
}
|
||||||
dbus->message_unref(reply);
|
dbus->message_unref(reply);
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ static SDL_bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appna
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool FcitxClientCreateIC(FcitxClient *client)
|
static bool FcitxClientCreateIC(FcitxClient *client)
|
||||||
{
|
{
|
||||||
char *appname = GetAppName();
|
char *appname = GetAppName();
|
||||||
char *ic_path = NULL;
|
char *ic_path = NULL;
|
||||||
|
@ -305,10 +305,10 @@ static SDL_bool FcitxClientCreateIC(FcitxClient *client)
|
||||||
dbus->connection_flush(dbus->session_conn);
|
dbus->connection_flush(dbus->session_conn);
|
||||||
|
|
||||||
SDL_AddHintCallback(SDL_HINT_IME_IMPLEMENTED_UI, Fcitx_SetCapabilities, client);
|
SDL_AddHintCallback(SDL_HINT_IME_IMPLEMENTED_UI, Fcitx_SetCapabilities, client);
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Uint32 Fcitx_ModState(void)
|
static Uint32 Fcitx_ModState(void)
|
||||||
|
@ -344,7 +344,7 @@ static Uint32 Fcitx_ModState(void)
|
||||||
return fcitx_mods;
|
return fcitx_mods;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_Fcitx_Init(void)
|
bool SDL_Fcitx_Init(void)
|
||||||
{
|
{
|
||||||
fcitx_client.dbus = SDL_DBus_GetContext();
|
fcitx_client.dbus = SDL_DBus_GetContext();
|
||||||
|
|
||||||
|
@ -365,7 +365,7 @@ void SDL_Fcitx_Quit(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_Fcitx_SetFocus(SDL_bool focused)
|
void SDL_Fcitx_SetFocus(bool focused)
|
||||||
{
|
{
|
||||||
if (focused) {
|
if (focused) {
|
||||||
FcitxClientICCallMethod(&fcitx_client, "FocusIn");
|
FcitxClientICCallMethod(&fcitx_client, "FocusIn");
|
||||||
|
@ -379,15 +379,15 @@ void SDL_Fcitx_Reset(void)
|
||||||
FcitxClientICCallMethod(&fcitx_client, "Reset");
|
FcitxClientICCallMethod(&fcitx_client, "Reset");
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
|
bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
|
||||||
{
|
{
|
||||||
Uint32 mod_state = Fcitx_ModState();
|
Uint32 mod_state = Fcitx_ModState();
|
||||||
Uint32 handled = SDL_FALSE;
|
Uint32 handled = false;
|
||||||
Uint32 is_release = (state == SDL_RELEASED);
|
Uint32 is_release = (state == SDL_RELEASED);
|
||||||
Uint32 event_time = 0;
|
Uint32 event_time = 0;
|
||||||
|
|
||||||
if (!fcitx_client.ic_path) {
|
if (!fcitx_client.ic_path) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_DBus_CallMethod(FCITX_DBUS_SERVICE, fcitx_client.ic_path, FCITX_IC_DBUS_INTERFACE, "ProcessKeyEvent",
|
if (SDL_DBus_CallMethod(FCITX_DBUS_SERVICE, fcitx_client.ic_path, FCITX_IC_DBUS_INTERFACE, "ProcessKeyEvent",
|
||||||
|
@ -395,11 +395,11 @@ SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
|
||||||
DBUS_TYPE_BOOLEAN, &handled, DBUS_TYPE_INVALID)) {
|
DBUS_TYPE_BOOLEAN, &handled, DBUS_TYPE_INVALID)) {
|
||||||
if (handled) {
|
if (handled) {
|
||||||
SDL_Fcitx_UpdateTextInputArea(SDL_GetKeyboardFocus());
|
SDL_Fcitx_UpdateTextInputArea(SDL_GetKeyboardFocus());
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_Fcitx_UpdateTextInputArea(SDL_Window *window)
|
void SDL_Fcitx_UpdateTextInputArea(SDL_Window *window)
|
||||||
|
|
|
@ -24,11 +24,11 @@
|
||||||
|
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
extern SDL_bool SDL_Fcitx_Init(void);
|
extern bool SDL_Fcitx_Init(void);
|
||||||
extern void SDL_Fcitx_Quit(void);
|
extern void SDL_Fcitx_Quit(void);
|
||||||
extern void SDL_Fcitx_SetFocus(SDL_bool focused);
|
extern void SDL_Fcitx_SetFocus(bool focused);
|
||||||
extern void SDL_Fcitx_Reset(void);
|
extern void SDL_Fcitx_Reset(void);
|
||||||
extern SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
|
extern bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
|
||||||
extern void SDL_Fcitx_UpdateTextInputArea(SDL_Window *window);
|
extern void SDL_Fcitx_UpdateTextInputArea(SDL_Window *window);
|
||||||
extern void SDL_Fcitx_PumpEvents(void);
|
extern void SDL_Fcitx_PumpEvents(void);
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ static const char *ibus_input_interface = NULL;
|
||||||
static char *input_ctx_path = NULL;
|
static char *input_ctx_path = NULL;
|
||||||
static SDL_Rect ibus_cursor_rect = { 0, 0, 0, 0 };
|
static SDL_Rect ibus_cursor_rect = { 0, 0, 0, 0 };
|
||||||
static DBusConnection *ibus_conn = NULL;
|
static DBusConnection *ibus_conn = NULL;
|
||||||
static SDL_bool ibus_is_portal_interface = SDL_FALSE;
|
static bool ibus_is_portal_interface = false;
|
||||||
static char *ibus_addr_file = NULL;
|
static char *ibus_addr_file = NULL;
|
||||||
static int inotify_fd = -1, inotify_wd = -1;
|
static int inotify_fd = -1, inotify_wd = -1;
|
||||||
|
|
||||||
|
@ -91,40 +91,40 @@ static Uint32 IBus_ModState(void)
|
||||||
return ibus_mods;
|
return ibus_mods;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
|
static bool IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
|
||||||
DBusMessageIter *inside, const char *struct_id, size_t id_size)
|
DBusMessageIter *inside, const char *struct_id, size_t id_size)
|
||||||
{
|
{
|
||||||
DBusMessageIter sub;
|
DBusMessageIter sub;
|
||||||
if (dbus->message_iter_get_arg_type(iter) != DBUS_TYPE_VARIANT) {
|
if (dbus->message_iter_get_arg_type(iter) != DBUS_TYPE_VARIANT) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus->message_iter_recurse(iter, &sub);
|
dbus->message_iter_recurse(iter, &sub);
|
||||||
|
|
||||||
if (dbus->message_iter_get_arg_type(&sub) != DBUS_TYPE_STRUCT) {
|
if (dbus->message_iter_get_arg_type(&sub) != DBUS_TYPE_STRUCT) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus->message_iter_recurse(&sub, inside);
|
dbus->message_iter_recurse(&sub, inside);
|
||||||
|
|
||||||
if (dbus->message_iter_get_arg_type(inside) != DBUS_TYPE_STRING) {
|
if (dbus->message_iter_get_arg_type(inside) != DBUS_TYPE_STRING) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus->message_iter_get_basic(inside, &struct_id);
|
dbus->message_iter_get_basic(inside, &struct_id);
|
||||||
if (!struct_id || SDL_strncmp(struct_id, struct_id, id_size) != 0) {
|
if (!struct_id || SDL_strncmp(struct_id, struct_id, id_size) != 0) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
|
static bool IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
|
||||||
Uint32 *start_pos, Uint32 *end_pos)
|
Uint32 *start_pos, Uint32 *end_pos)
|
||||||
{
|
{
|
||||||
DBusMessageIter sub1, sub2, array;
|
DBusMessageIter sub1, sub2, array;
|
||||||
|
|
||||||
if (!IBus_EnterVariant(conn, iter, dbus, &sub1, "IBusText", sizeof("IBusText"))) {
|
if (!IBus_EnterVariant(conn, iter, dbus, &sub1, "IBusText", sizeof("IBusText"))) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus->message_iter_next(&sub1);
|
dbus->message_iter_next(&sub1);
|
||||||
|
@ -132,14 +132,14 @@ static SDL_bool IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter
|
||||||
dbus->message_iter_next(&sub1);
|
dbus->message_iter_next(&sub1);
|
||||||
|
|
||||||
if (!IBus_EnterVariant(conn, &sub1, dbus, &sub2, "IBusAttrList", sizeof("IBusAttrList"))) {
|
if (!IBus_EnterVariant(conn, &sub1, dbus, &sub2, "IBusAttrList", sizeof("IBusAttrList"))) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus->message_iter_next(&sub2);
|
dbus->message_iter_next(&sub2);
|
||||||
dbus->message_iter_next(&sub2);
|
dbus->message_iter_next(&sub2);
|
||||||
|
|
||||||
if (dbus->message_iter_get_arg_type(&sub2) != DBUS_TYPE_ARRAY) {
|
if (dbus->message_iter_get_arg_type(&sub2) != DBUS_TYPE_ARRAY) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus->message_iter_recurse(&sub2, &array);
|
dbus->message_iter_recurse(&sub2, &array);
|
||||||
|
@ -172,14 +172,14 @@ static SDL_bool IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter
|
||||||
if (dbus->message_iter_get_arg_type(&sub) == DBUS_TYPE_UINT32) {
|
if (dbus->message_iter_get_arg_type(&sub) == DBUS_TYPE_UINT32) {
|
||||||
dbus->message_iter_get_basic(&sub, end_pos);
|
dbus->message_iter_get_basic(&sub, end_pos);
|
||||||
*start_pos = start;
|
*start_pos = start;
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dbus->message_iter_next(&array);
|
dbus->message_iter_next(&array);
|
||||||
}
|
}
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *IBus_GetVariantText(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus)
|
static const char *IBus_GetVariantText(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus)
|
||||||
|
@ -203,18 +203,18 @@ static const char *IBus_GetVariantText(DBusConnection *conn, DBusMessageIter *it
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool IBus_GetVariantCursorPos(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
|
static bool IBus_GetVariantCursorPos(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
|
||||||
Uint32 *pos)
|
Uint32 *pos)
|
||||||
{
|
{
|
||||||
dbus->message_iter_next(iter);
|
dbus->message_iter_next(iter);
|
||||||
|
|
||||||
if (dbus->message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32) {
|
if (dbus->message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus->message_iter_get_basic(iter, pos);
|
dbus->message_iter_get_basic(iter, pos);
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DBusHandlerResult IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data)
|
static DBusHandlerResult IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data)
|
||||||
|
@ -242,8 +242,8 @@ static DBusHandlerResult IBus_MessageHandler(DBusConnection *conn, DBusMessage *
|
||||||
|
|
||||||
if (text) {
|
if (text) {
|
||||||
Uint32 pos, start_pos, end_pos;
|
Uint32 pos, start_pos, end_pos;
|
||||||
SDL_bool has_pos = SDL_FALSE;
|
bool has_pos = false;
|
||||||
SDL_bool has_dec_pos = SDL_FALSE;
|
bool has_dec_pos = false;
|
||||||
|
|
||||||
dbus->message_iter_init(msg, &iter);
|
dbus->message_iter_init(msg, &iter);
|
||||||
has_dec_pos = IBus_GetDecorationPosition(conn, &iter, dbus, &start_pos, &end_pos);
|
has_dec_pos = IBus_GetDecorationPosition(conn, &iter, dbus, &start_pos, &end_pos);
|
||||||
|
@ -277,7 +277,7 @@ static DBusHandlerResult IBus_MessageHandler(DBusConnection *conn, DBusMessage *
|
||||||
static char *IBus_ReadAddressFromFile(const char *file_path)
|
static char *IBus_ReadAddressFromFile(const char *file_path)
|
||||||
{
|
{
|
||||||
char addr_buf[1024];
|
char addr_buf[1024];
|
||||||
SDL_bool success = SDL_FALSE;
|
bool success = false;
|
||||||
FILE *addr_file;
|
FILE *addr_file;
|
||||||
|
|
||||||
addr_file = fopen(file_path, "r");
|
addr_file = fopen(file_path, "r");
|
||||||
|
@ -294,7 +294,7 @@ static char *IBus_ReadAddressFromFile(const char *file_path)
|
||||||
if (addr_buf[sz - 2] == '\r') {
|
if (addr_buf[sz - 2] == '\r') {
|
||||||
addr_buf[sz - 2] = 0;
|
addr_buf[sz - 2] = 0;
|
||||||
}
|
}
|
||||||
success = SDL_TRUE;
|
success = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,7 @@ static char *IBus_GetDBusAddressFilename(void)
|
||||||
return SDL_strdup(file_path);
|
return SDL_strdup(file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus);
|
static bool IBus_CheckConnection(SDL_DBusContext *dbus);
|
||||||
|
|
||||||
static void SDLCALL IBus_SetCapabilities(void *data, const char *name, const char *old_val,
|
static void SDLCALL IBus_SetCapabilities(void *data, const char *name, const char *old_val,
|
||||||
const char *hint)
|
const char *hint)
|
||||||
|
@ -423,11 +423,11 @@ static void SDLCALL IBus_SetCapabilities(void *data, const char *name, const cha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
|
static bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
|
||||||
{
|
{
|
||||||
const char *client_name = "SDL3_Application";
|
const char *client_name = "SDL3_Application";
|
||||||
const char *path = NULL;
|
const char *path = NULL;
|
||||||
SDL_bool result = SDL_FALSE;
|
bool result = false;
|
||||||
DBusObjectPathVTable ibus_vtable;
|
DBusObjectPathVTable ibus_vtable;
|
||||||
|
|
||||||
SDL_zero(ibus_vtable);
|
SDL_zero(ibus_vtable);
|
||||||
|
@ -436,7 +436,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
|
||||||
/* try the portal interface first. Modern systems have this in general,
|
/* try the portal interface first. Modern systems have this in general,
|
||||||
and sandbox things like FlakPak and Snaps, etc, require it. */
|
and sandbox things like FlakPak and Snaps, etc, require it. */
|
||||||
|
|
||||||
ibus_is_portal_interface = SDL_TRUE;
|
ibus_is_portal_interface = true;
|
||||||
ibus_service = IBUS_PORTAL_SERVICE;
|
ibus_service = IBUS_PORTAL_SERVICE;
|
||||||
ibus_interface = IBUS_PORTAL_INTERFACE;
|
ibus_interface = IBUS_PORTAL_INTERFACE;
|
||||||
ibus_input_interface = IBUS_PORTAL_INPUT_INTERFACE;
|
ibus_input_interface = IBUS_PORTAL_INPUT_INTERFACE;
|
||||||
|
@ -446,21 +446,21 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
|
||||||
DBUS_TYPE_STRING, &client_name, DBUS_TYPE_INVALID,
|
DBUS_TYPE_STRING, &client_name, DBUS_TYPE_INVALID,
|
||||||
DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID);
|
DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
ibus_is_portal_interface = SDL_FALSE;
|
ibus_is_portal_interface = false;
|
||||||
ibus_service = IBUS_SERVICE;
|
ibus_service = IBUS_SERVICE;
|
||||||
ibus_interface = IBUS_INTERFACE;
|
ibus_interface = IBUS_INTERFACE;
|
||||||
ibus_input_interface = IBUS_INPUT_INTERFACE;
|
ibus_input_interface = IBUS_INPUT_INTERFACE;
|
||||||
ibus_conn = dbus->connection_open_private(addr, NULL);
|
ibus_conn = dbus->connection_open_private(addr, NULL);
|
||||||
|
|
||||||
if (!ibus_conn) {
|
if (!ibus_conn) {
|
||||||
return SDL_FALSE; // oh well.
|
return false; // oh well.
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus->connection_flush(ibus_conn);
|
dbus->connection_flush(ibus_conn);
|
||||||
|
|
||||||
if (!dbus->bus_register(ibus_conn, NULL)) {
|
if (!dbus->bus_register(ibus_conn, NULL)) {
|
||||||
ibus_conn = NULL;
|
ibus_conn = NULL;
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus->connection_flush(ibus_conn);
|
dbus->connection_flush(ibus_conn);
|
||||||
|
@ -486,22 +486,22 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
|
||||||
|
|
||||||
SDL_Window *window = SDL_GetKeyboardFocus();
|
SDL_Window *window = SDL_GetKeyboardFocus();
|
||||||
if (SDL_TextInputActive(window)) {
|
if (SDL_TextInputActive(window)) {
|
||||||
SDL_IBus_SetFocus(SDL_TRUE);
|
SDL_IBus_SetFocus(true);
|
||||||
SDL_IBus_UpdateTextInputArea(window);
|
SDL_IBus_UpdateTextInputArea(window);
|
||||||
} else {
|
} else {
|
||||||
SDL_IBus_SetFocus(SDL_FALSE);
|
SDL_IBus_SetFocus(false);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus)
|
static bool IBus_CheckConnection(SDL_DBusContext *dbus)
|
||||||
{
|
{
|
||||||
if (!dbus) {
|
if (!dbus) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ibus_conn && dbus->connection_get_is_connected(ibus_conn)) {
|
if (ibus_conn && dbus->connection_get_is_connected(ibus_conn)) {
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inotify_fd > 0 && inotify_wd > 0) {
|
if (inotify_fd > 0 && inotify_wd > 0) {
|
||||||
|
@ -510,18 +510,18 @@ static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus)
|
||||||
if (readsize > 0) {
|
if (readsize > 0) {
|
||||||
|
|
||||||
char *p;
|
char *p;
|
||||||
SDL_bool file_updated = SDL_FALSE;
|
bool file_updated = false;
|
||||||
|
|
||||||
for (p = buf; p < buf + readsize; /**/) {
|
for (p = buf; p < buf + readsize; /**/) {
|
||||||
struct inotify_event *event = (struct inotify_event *)p;
|
struct inotify_event *event = (struct inotify_event *)p;
|
||||||
if (event->len > 0) {
|
if (event->len > 0) {
|
||||||
char *addr_file_no_path = SDL_strrchr(ibus_addr_file, '/');
|
char *addr_file_no_path = SDL_strrchr(ibus_addr_file, '/');
|
||||||
if (!addr_file_no_path) {
|
if (!addr_file_no_path) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_strcmp(addr_file_no_path + 1, event->name) == 0) {
|
if (SDL_strcmp(addr_file_no_path + 1, event->name) == 0) {
|
||||||
file_updated = SDL_TRUE;
|
file_updated = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -532,7 +532,7 @@ static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus)
|
||||||
if (file_updated) {
|
if (file_updated) {
|
||||||
char *addr = IBus_ReadAddressFromFile(ibus_addr_file);
|
char *addr = IBus_ReadAddressFromFile(ibus_addr_file);
|
||||||
if (addr) {
|
if (addr) {
|
||||||
SDL_bool result = IBus_SetupConnection(dbus, addr);
|
bool result = IBus_SetupConnection(dbus, addr);
|
||||||
SDL_free(addr);
|
SDL_free(addr);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -540,12 +540,12 @@ static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_IBus_Init(void)
|
bool SDL_IBus_Init(void)
|
||||||
{
|
{
|
||||||
SDL_bool result = SDL_FALSE;
|
bool result = false;
|
||||||
SDL_DBusContext *dbus = SDL_DBus_GetContext();
|
SDL_DBusContext *dbus = SDL_DBus_GetContext();
|
||||||
|
|
||||||
if (dbus) {
|
if (dbus) {
|
||||||
|
@ -554,13 +554,13 @@ SDL_bool SDL_IBus_Init(void)
|
||||||
char *addr_file_dir;
|
char *addr_file_dir;
|
||||||
|
|
||||||
if (!addr_file) {
|
if (!addr_file) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
addr = IBus_ReadAddressFromFile(addr_file);
|
addr = IBus_ReadAddressFromFile(addr_file);
|
||||||
if (!addr) {
|
if (!addr) {
|
||||||
SDL_free(addr_file);
|
SDL_free(addr_file);
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ibus_addr_file) {
|
if (ibus_addr_file) {
|
||||||
|
@ -626,7 +626,7 @@ void SDL_IBus_Quit(void)
|
||||||
ibus_service = NULL;
|
ibus_service = NULL;
|
||||||
ibus_interface = NULL;
|
ibus_interface = NULL;
|
||||||
ibus_input_interface = NULL;
|
ibus_input_interface = NULL;
|
||||||
ibus_is_portal_interface = SDL_FALSE;
|
ibus_is_portal_interface = false;
|
||||||
|
|
||||||
if (inotify_fd > 0 && inotify_wd > 0) {
|
if (inotify_fd > 0 && inotify_wd > 0) {
|
||||||
inotify_rm_watch(inotify_fd, inotify_wd);
|
inotify_rm_watch(inotify_fd, inotify_wd);
|
||||||
|
@ -649,7 +649,7 @@ static void IBus_SimpleMessage(const char *method)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_IBus_SetFocus(SDL_bool focused)
|
void SDL_IBus_SetFocus(bool focused)
|
||||||
{
|
{
|
||||||
const char *method = focused ? "FocusIn" : "FocusOut";
|
const char *method = focused ? "FocusIn" : "FocusOut";
|
||||||
IBus_SimpleMessage(method);
|
IBus_SimpleMessage(method);
|
||||||
|
@ -660,7 +660,7 @@ void SDL_IBus_Reset(void)
|
||||||
IBus_SimpleMessage("Reset");
|
IBus_SimpleMessage("Reset");
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
|
bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
|
||||||
{
|
{
|
||||||
Uint32 result = 0;
|
Uint32 result = 0;
|
||||||
SDL_DBusContext *dbus = SDL_DBus_GetContext();
|
SDL_DBusContext *dbus = SDL_DBus_GetContext();
|
||||||
|
|
|
@ -28,19 +28,19 @@
|
||||||
#define SDL_USE_IBUS 1
|
#define SDL_USE_IBUS 1
|
||||||
#include <ibus.h>
|
#include <ibus.h>
|
||||||
|
|
||||||
extern SDL_bool SDL_IBus_Init(void);
|
extern bool SDL_IBus_Init(void);
|
||||||
extern void SDL_IBus_Quit(void);
|
extern void SDL_IBus_Quit(void);
|
||||||
|
|
||||||
// Lets the IBus server know about changes in window focus
|
// Lets the IBus server know about changes in window focus
|
||||||
extern void SDL_IBus_SetFocus(SDL_bool focused);
|
extern void SDL_IBus_SetFocus(bool focused);
|
||||||
|
|
||||||
// Closes the candidate list and resets any text currently being edited
|
// Closes the candidate list and resets any text currently being edited
|
||||||
extern void SDL_IBus_Reset(void);
|
extern void SDL_IBus_Reset(void);
|
||||||
|
|
||||||
/* Sends a keypress event to IBus, returns SDL_TRUE if IBus used this event to
|
/* Sends a keypress event to IBus, returns true if IBus used this event to
|
||||||
update its candidate list or change input methods. PumpEvents should be
|
update its candidate list or change input methods. PumpEvents should be
|
||||||
called some time after this, to receive the TextInput / TextEditing event back. */
|
called some time after this, to receive the TextInput / TextEditing event back. */
|
||||||
extern SDL_bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
|
extern bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
|
||||||
|
|
||||||
/* Update the position of IBus' candidate list. If rect is NULL then this will
|
/* Update the position of IBus' candidate list. If rect is NULL then this will
|
||||||
just reposition it relative to the focused window's new position. */
|
just reposition it relative to the focused window's new position. */
|
||||||
|
|
|
@ -24,11 +24,11 @@
|
||||||
#include "SDL_ibus.h"
|
#include "SDL_ibus.h"
|
||||||
#include "SDL_fcitx.h"
|
#include "SDL_fcitx.h"
|
||||||
|
|
||||||
typedef SDL_bool (*SDL_IME_Init_t)(void);
|
typedef bool (*SDL_IME_Init_t)(void);
|
||||||
typedef void (*SDL_IME_Quit_t)(void);
|
typedef void (*SDL_IME_Quit_t)(void);
|
||||||
typedef void (*SDL_IME_SetFocus_t)(SDL_bool);
|
typedef void (*SDL_IME_SetFocus_t)(bool);
|
||||||
typedef void (*SDL_IME_Reset_t)(void);
|
typedef void (*SDL_IME_Reset_t)(void);
|
||||||
typedef SDL_bool (*SDL_IME_ProcessKeyEvent_t)(Uint32, Uint32, Uint8 state);
|
typedef bool (*SDL_IME_ProcessKeyEvent_t)(Uint32, Uint32, Uint8 state);
|
||||||
typedef void (*SDL_IME_UpdateTextInputArea_t)(SDL_Window *window);
|
typedef void (*SDL_IME_UpdateTextInputArea_t)(SDL_Window *window);
|
||||||
typedef void (*SDL_IME_PumpEvents_t)(void);
|
typedef void (*SDL_IME_PumpEvents_t)(void);
|
||||||
|
|
||||||
|
@ -42,17 +42,17 @@ static SDL_IME_PumpEvents_t SDL_IME_PumpEvents_Real = NULL;
|
||||||
|
|
||||||
static void InitIME(void)
|
static void InitIME(void)
|
||||||
{
|
{
|
||||||
static SDL_bool inited = SDL_FALSE;
|
static bool inited = false;
|
||||||
#ifdef HAVE_FCITX
|
#ifdef HAVE_FCITX
|
||||||
const char *im_module = SDL_getenv("SDL_IM_MODULE");
|
const char *im_module = SDL_getenv("SDL_IM_MODULE");
|
||||||
const char *xmodifiers = SDL_getenv("XMODIFIERS");
|
const char *xmodifiers = SDL_getenv("XMODIFIERS");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (inited == SDL_TRUE) {
|
if (inited == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
inited = SDL_TRUE;
|
inited = true;
|
||||||
|
|
||||||
// See if fcitx IME support is being requested
|
// See if fcitx IME support is being requested
|
||||||
#ifdef HAVE_FCITX
|
#ifdef HAVE_FCITX
|
||||||
|
@ -83,13 +83,13 @@ static void InitIME(void)
|
||||||
#endif // HAVE_IBUS_IBUS_H
|
#endif // HAVE_IBUS_IBUS_H
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_IME_Init(void)
|
bool SDL_IME_Init(void)
|
||||||
{
|
{
|
||||||
InitIME();
|
InitIME();
|
||||||
|
|
||||||
if (SDL_IME_Init_Real) {
|
if (SDL_IME_Init_Real) {
|
||||||
if (SDL_IME_Init_Real()) {
|
if (SDL_IME_Init_Real()) {
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// uhoh, the IME implementation's init failed! Disable IME support.
|
// uhoh, the IME implementation's init failed! Disable IME support.
|
||||||
|
@ -102,7 +102,7 @@ SDL_bool SDL_IME_Init(void)
|
||||||
SDL_IME_PumpEvents_Real = NULL;
|
SDL_IME_PumpEvents_Real = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_IME_Quit(void)
|
void SDL_IME_Quit(void)
|
||||||
|
@ -112,7 +112,7 @@ void SDL_IME_Quit(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_IME_SetFocus(SDL_bool focused)
|
void SDL_IME_SetFocus(bool focused)
|
||||||
{
|
{
|
||||||
if (SDL_IME_SetFocus_Real) {
|
if (SDL_IME_SetFocus_Real) {
|
||||||
SDL_IME_SetFocus_Real(focused);
|
SDL_IME_SetFocus_Real(focused);
|
||||||
|
@ -126,13 +126,13 @@ void SDL_IME_Reset(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
|
bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
|
||||||
{
|
{
|
||||||
if (SDL_IME_ProcessKeyEvent_Real) {
|
if (SDL_IME_ProcessKeyEvent_Real) {
|
||||||
return SDL_IME_ProcessKeyEvent_Real(keysym, keycode, state);
|
return SDL_IME_ProcessKeyEvent_Real(keysym, keycode, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_IME_UpdateTextInputArea(SDL_Window *window)
|
void SDL_IME_UpdateTextInputArea(SDL_Window *window)
|
||||||
|
|
|
@ -24,11 +24,11 @@
|
||||||
|
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
extern SDL_bool SDL_IME_Init(void);
|
extern bool SDL_IME_Init(void);
|
||||||
extern void SDL_IME_Quit(void);
|
extern void SDL_IME_Quit(void);
|
||||||
extern void SDL_IME_SetFocus(SDL_bool focused);
|
extern void SDL_IME_SetFocus(bool focused);
|
||||||
extern void SDL_IME_Reset(void);
|
extern void SDL_IME_Reset(void);
|
||||||
extern SDL_bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
|
extern bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
|
||||||
extern void SDL_IME_UpdateTextInputArea(SDL_Window *window);
|
extern void SDL_IME_UpdateTextInputArea(SDL_Window *window);
|
||||||
extern void SDL_IME_PumpEvents(void);
|
extern void SDL_IME_PumpEvents(void);
|
||||||
|
|
||||||
|
|
|
@ -44,16 +44,16 @@ typedef struct SystemThemeData
|
||||||
|
|
||||||
static SystemThemeData system_theme_data;
|
static SystemThemeData system_theme_data;
|
||||||
|
|
||||||
static SDL_bool DBus_ExtractThemeVariant(DBusMessageIter *iter, SDL_SystemTheme *theme) {
|
static bool DBus_ExtractThemeVariant(DBusMessageIter *iter, SDL_SystemTheme *theme) {
|
||||||
SDL_DBusContext *dbus = system_theme_data.dbus;
|
SDL_DBusContext *dbus = system_theme_data.dbus;
|
||||||
Uint32 color_scheme;
|
Uint32 color_scheme;
|
||||||
DBusMessageIter variant_iter;
|
DBusMessageIter variant_iter;
|
||||||
|
|
||||||
if (dbus->message_iter_get_arg_type(iter) != DBUS_TYPE_VARIANT)
|
if (dbus->message_iter_get_arg_type(iter) != DBUS_TYPE_VARIANT)
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
dbus->message_iter_recurse(iter, &variant_iter);
|
dbus->message_iter_recurse(iter, &variant_iter);
|
||||||
if (dbus->message_iter_get_arg_type(&variant_iter) != DBUS_TYPE_UINT32)
|
if (dbus->message_iter_get_arg_type(&variant_iter) != DBUS_TYPE_UINT32)
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
dbus->message_iter_get_basic(&variant_iter, &color_scheme);
|
dbus->message_iter_get_basic(&variant_iter, &color_scheme);
|
||||||
switch (color_scheme) {
|
switch (color_scheme) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -66,7 +66,7 @@ static SDL_bool DBus_ExtractThemeVariant(DBusMessageIter *iter, SDL_SystemTheme
|
||||||
*theme = SDL_SYSTEM_THEME_LIGHT;
|
*theme = SDL_SYSTEM_THEME_LIGHT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data) {
|
static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data) {
|
||||||
|
@ -106,7 +106,7 @@ not_our_signal:
|
||||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_SystemTheme_Init(void)
|
bool SDL_SystemTheme_Init(void)
|
||||||
{
|
{
|
||||||
SDL_DBusContext *dbus = SDL_DBus_GetContext();
|
SDL_DBusContext *dbus = SDL_DBus_GetContext();
|
||||||
DBusMessage *msg;
|
DBusMessage *msg;
|
||||||
|
@ -116,7 +116,7 @@ SDL_bool SDL_SystemTheme_Init(void)
|
||||||
system_theme_data.theme = SDL_SYSTEM_THEME_UNKNOWN;
|
system_theme_data.theme = SDL_SYSTEM_THEME_UNKNOWN;
|
||||||
system_theme_data.dbus = dbus;
|
system_theme_data.dbus = dbus;
|
||||||
if (!dbus) {
|
if (!dbus) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = dbus->message_new_method_call(PORTAL_DESTINATION, PORTAL_PATH, PORTAL_INTERFACE, PORTAL_METHOD);
|
msg = dbus->message_new_method_call(PORTAL_DESTINATION, PORTAL_PATH, PORTAL_INTERFACE, PORTAL_METHOD);
|
||||||
|
@ -147,7 +147,7 @@ incorrect_type:
|
||||||
dbus->connection_add_filter(dbus->session_conn,
|
dbus->connection_add_filter(dbus->session_conn,
|
||||||
&DBus_MessageFilter, dbus, NULL);
|
&DBus_MessageFilter, dbus, NULL);
|
||||||
dbus->connection_flush(dbus->session_conn);
|
dbus->connection_flush(dbus->session_conn);
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SystemTheme SDL_SystemTheme_Get(void)
|
SDL_SystemTheme SDL_SystemTheme_Get(void)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
extern SDL_bool SDL_SystemTheme_Init(void);
|
extern bool SDL_SystemTheme_Init(void);
|
||||||
extern SDL_SystemTheme SDL_SystemTheme_Get(void);
|
extern SDL_SystemTheme SDL_SystemTheme_Get(void);
|
||||||
|
|
||||||
#endif // SDL_system_theme_h_
|
#endif // SDL_system_theme_h_
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
#define XDG_PORTAL_DBUS_PATH "/org/freedesktop/portal/desktop"
|
#define XDG_PORTAL_DBUS_PATH "/org/freedesktop/portal/desktop"
|
||||||
#define XDG_PORTAL_DBUS_INTERFACE "org.freedesktop.portal.Realtime"
|
#define XDG_PORTAL_DBUS_INTERFACE "org.freedesktop.portal.Realtime"
|
||||||
|
|
||||||
static SDL_bool rtkit_use_session_conn;
|
static bool rtkit_use_session_conn;
|
||||||
static const char *rtkit_dbus_node;
|
static const char *rtkit_dbus_node;
|
||||||
static const char *rtkit_dbus_path;
|
static const char *rtkit_dbus_path;
|
||||||
static const char *rtkit_dbus_interface;
|
static const char *rtkit_dbus_interface;
|
||||||
|
@ -67,7 +67,7 @@ static Sint64 rtkit_max_rttime_usec = 200000;
|
||||||
* - The desktop portal exists and supports the realtime interface.
|
* - The desktop portal exists and supports the realtime interface.
|
||||||
* - The realtime interface is new enough to have the required bug fixes applied.
|
* - The realtime interface is new enough to have the required bug fixes applied.
|
||||||
*/
|
*/
|
||||||
static SDL_bool realtime_portal_supported(DBusConnection *conn)
|
static bool realtime_portal_supported(DBusConnection *conn)
|
||||||
{
|
{
|
||||||
Sint64 res;
|
Sint64 res;
|
||||||
return SDL_DBus_QueryPropertyOnConnection(conn, XDG_PORTAL_DBUS_NODE, XDG_PORTAL_DBUS_PATH, XDG_PORTAL_DBUS_INTERFACE,
|
return SDL_DBus_QueryPropertyOnConnection(conn, XDG_PORTAL_DBUS_NODE, XDG_PORTAL_DBUS_PATH, XDG_PORTAL_DBUS_INTERFACE,
|
||||||
|
@ -80,12 +80,12 @@ static void set_rtkit_interface(void)
|
||||||
|
|
||||||
// xdg-desktop-portal works in all instances, so check for it first.
|
// xdg-desktop-portal works in all instances, so check for it first.
|
||||||
if (dbus && realtime_portal_supported(dbus->session_conn)) {
|
if (dbus && realtime_portal_supported(dbus->session_conn)) {
|
||||||
rtkit_use_session_conn = SDL_TRUE;
|
rtkit_use_session_conn = true;
|
||||||
rtkit_dbus_node = XDG_PORTAL_DBUS_NODE;
|
rtkit_dbus_node = XDG_PORTAL_DBUS_NODE;
|
||||||
rtkit_dbus_path = XDG_PORTAL_DBUS_PATH;
|
rtkit_dbus_path = XDG_PORTAL_DBUS_PATH;
|
||||||
rtkit_dbus_interface = XDG_PORTAL_DBUS_INTERFACE;
|
rtkit_dbus_interface = XDG_PORTAL_DBUS_INTERFACE;
|
||||||
} else { // Fall back to the standard rtkit interface in all other cases.
|
} else { // Fall back to the standard rtkit interface in all other cases.
|
||||||
rtkit_use_session_conn = SDL_FALSE;
|
rtkit_use_session_conn = false;
|
||||||
rtkit_dbus_node = RTKIT_DBUS_NODE;
|
rtkit_dbus_node = RTKIT_DBUS_NODE;
|
||||||
rtkit_dbus_path = RTKIT_DBUS_PATH;
|
rtkit_dbus_path = RTKIT_DBUS_PATH;
|
||||||
rtkit_dbus_interface = RTKIT_DBUS_INTERFACE;
|
rtkit_dbus_interface = RTKIT_DBUS_INTERFACE;
|
||||||
|
@ -129,7 +129,7 @@ static void rtkit_initialize(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool rtkit_initialize_realtime_thread(void)
|
static bool rtkit_initialize_realtime_thread(void)
|
||||||
{
|
{
|
||||||
// Following is an excerpt from rtkit README that outlines the requirements
|
// Following is an excerpt from rtkit README that outlines the requirements
|
||||||
// a thread must meet before making rtkit requests:
|
// a thread must meet before making rtkit requests:
|
||||||
|
@ -163,7 +163,7 @@ static SDL_bool rtkit_initialize_realtime_thread(void)
|
||||||
// Requirement #1: Set RLIMIT_RTTIME
|
// Requirement #1: Set RLIMIT_RTTIME
|
||||||
err = getrlimit(nLimit, &rlimit);
|
err = getrlimit(nLimit, &rlimit);
|
||||||
if (err) {
|
if (err) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Current rtkit allows a max of 200ms right now
|
// Current rtkit allows a max of 200ms right now
|
||||||
|
@ -171,24 +171,24 @@ static SDL_bool rtkit_initialize_realtime_thread(void)
|
||||||
rlimit.rlim_cur = rlimit.rlim_max / 2;
|
rlimit.rlim_cur = rlimit.rlim_max / 2;
|
||||||
err = setrlimit(nLimit, &rlimit);
|
err = setrlimit(nLimit, &rlimit);
|
||||||
if (err) {
|
if (err) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Requirement #2: Add SCHED_RESET_ON_FORK to the scheduler policy
|
// Requirement #2: Add SCHED_RESET_ON_FORK to the scheduler policy
|
||||||
err = sched_getparam(nPid, &schedParam);
|
err = sched_getparam(nPid, &schedParam);
|
||||||
if (err) {
|
if (err) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = sched_setscheduler(nPid, nSchedPolicy, &schedParam);
|
err = sched_setscheduler(nPid, nSchedPolicy, &schedParam);
|
||||||
if (err) {
|
if (err) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool rtkit_setpriority_nice(pid_t thread, int nice_level)
|
static bool rtkit_setpriority_nice(pid_t thread, int nice_level)
|
||||||
{
|
{
|
||||||
DBusConnection *dbus_conn;
|
DBusConnection *dbus_conn;
|
||||||
Uint64 pid = (Uint64)getpid();
|
Uint64 pid = (Uint64)getpid();
|
||||||
|
@ -206,12 +206,12 @@ static SDL_bool rtkit_setpriority_nice(pid_t thread, int nice_level)
|
||||||
rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadHighPriorityWithPID",
|
rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadHighPriorityWithPID",
|
||||||
DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_INT32, &nice, DBUS_TYPE_INVALID,
|
DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_INT32, &nice, DBUS_TYPE_INVALID,
|
||||||
DBUS_TYPE_INVALID)) {
|
DBUS_TYPE_INVALID)) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool rtkit_setpriority_realtime(pid_t thread, int rt_priority)
|
static bool rtkit_setpriority_realtime(pid_t thread, int rt_priority)
|
||||||
{
|
{
|
||||||
DBusConnection *dbus_conn;
|
DBusConnection *dbus_conn;
|
||||||
Uint64 pid = (Uint64)getpid();
|
Uint64 pid = (Uint64)getpid();
|
||||||
|
@ -237,9 +237,9 @@ static SDL_bool rtkit_setpriority_realtime(pid_t thread, int rt_priority)
|
||||||
rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadRealtimeWithPID",
|
rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadRealtimeWithPID",
|
||||||
DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_UINT32, &priority, DBUS_TYPE_INVALID,
|
DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_UINT32, &priority, DBUS_TYPE_INVALID,
|
||||||
DBUS_TYPE_INVALID)) {
|
DBUS_TYPE_INVALID)) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -40,23 +40,23 @@ static const char *SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };
|
||||||
|
|
||||||
static SDL_UDEV_PrivateData *_this = NULL;
|
static SDL_UDEV_PrivateData *_this = NULL;
|
||||||
|
|
||||||
static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr);
|
static bool SDL_UDEV_load_sym(const char *fn, void **addr);
|
||||||
static int SDL_UDEV_load_syms(void);
|
static int SDL_UDEV_load_syms(void);
|
||||||
static SDL_bool SDL_UDEV_hotplug_update_available(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 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);
|
static int guess_device_class(struct udev_device *dev);
|
||||||
static int device_class(struct udev_device *dev);
|
static int device_class(struct udev_device *dev);
|
||||||
static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev);
|
static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev);
|
||||||
|
|
||||||
static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr)
|
static bool SDL_UDEV_load_sym(const char *fn, void **addr)
|
||||||
{
|
{
|
||||||
*addr = SDL_LoadFunction(_this->udev_handle, fn);
|
*addr = SDL_LoadFunction(_this->udev_handle, fn);
|
||||||
if (!*addr) {
|
if (!*addr) {
|
||||||
// Don't call SDL_SetError(): SDL_LoadFunction already did.
|
// Don't call SDL_SetError(): SDL_LoadFunction already did.
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDL_UDEV_load_syms(void)
|
static int SDL_UDEV_load_syms(void)
|
||||||
|
@ -98,15 +98,15 @@ static int SDL_UDEV_load_syms(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SDL_UDEV_hotplug_update_available(void)
|
static bool SDL_UDEV_hotplug_update_available(void)
|
||||||
{
|
{
|
||||||
if (_this->udev_mon) {
|
if (_this->udev_mon) {
|
||||||
const int fd = _this->syms.udev_monitor_get_fd(_this->udev_mon);
|
const int fd = _this->syms.udev_monitor_get_fd(_this->udev_mon);
|
||||||
if (SDL_IOReady(fd, SDL_IOR_READ, 0)) {
|
if (SDL_IOReady(fd, SDL_IOR_READ, 0)) {
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_UDEV_Init(void)
|
int SDL_UDEV_Init(void)
|
||||||
|
@ -222,7 +222,7 @@ int SDL_UDEV_Scan(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class)
|
bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class)
|
||||||
{
|
{
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
char type;
|
char type;
|
||||||
|
@ -231,11 +231,11 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16
|
||||||
int class_temp;
|
int class_temp;
|
||||||
|
|
||||||
if (!_this) {
|
if (!_this) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat(device_path, &statbuf) == -1) {
|
if (stat(device_path, &statbuf) == -1) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISBLK(statbuf.st_mode)) {
|
if (S_ISBLK(statbuf.st_mode)) {
|
||||||
|
@ -245,13 +245,13 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16
|
||||||
type = 'c';
|
type = 'c';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev = _this->syms.udev_device_new_from_devnum(_this->udev, type, statbuf.st_rdev);
|
dev = _this->syms.udev_device_new_from_devnum(_this->udev, type, statbuf.st_rdev);
|
||||||
|
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
val = _this->syms.udev_device_get_property_value(dev, "ID_VENDOR_ID");
|
val = _this->syms.udev_device_get_property_value(dev, "ID_VENDOR_ID");
|
||||||
|
@ -276,7 +276,7 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16
|
||||||
|
|
||||||
_this->syms.udev_device_unref(dev);
|
_this->syms.udev_device_unref(dev);
|
||||||
|
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_UDEV_UnloadLibrary(void)
|
void SDL_UDEV_UnloadLibrary(void)
|
||||||
|
|
|
@ -102,7 +102,7 @@ extern void SDL_UDEV_UnloadLibrary(void);
|
||||||
extern int SDL_UDEV_LoadLibrary(void);
|
extern int SDL_UDEV_LoadLibrary(void);
|
||||||
extern void SDL_UDEV_Poll(void);
|
extern void SDL_UDEV_Poll(void);
|
||||||
extern int SDL_UDEV_Scan(void);
|
extern int SDL_UDEV_Scan(void);
|
||||||
extern SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class);
|
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 int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb);
|
||||||
extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb);
|
extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb);
|
||||||
extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void);
|
extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void);
|
||||||
|
|
|
@ -433,7 +433,7 @@ static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
input->keyboardID = SDL_GetNextObjectID();
|
input->keyboardID = SDL_GetNextObjectID();
|
||||||
SDL_AddKeyboard(input->keyboardID, NULL, SDL_FALSE);
|
SDL_AddKeyboard(input->keyboardID, NULL, false);
|
||||||
|
|
||||||
input->keymap.map = SDL_calloc(sizeof(struct wscons_keymap), KS_NUMKEYCODES);
|
input->keymap.map = SDL_calloc(sizeof(struct wscons_keymap), KS_NUMKEYCODES);
|
||||||
if (!input->keymap.map) {
|
if (!input->keymap.map) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ SDL_WSCONS_mouse_input_data *SDL_WSCONS_Init_Mouse(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
input->mouseID = SDL_GetNextObjectID();
|
input->mouseID = SDL_GetNextObjectID();
|
||||||
SDL_AddMouse(input->mouseID, NULL, SDL_FALSE);
|
SDL_AddMouse(input->mouseID, NULL, false);
|
||||||
|
|
||||||
#ifdef WSMOUSEIO_SETMODE
|
#ifdef WSMOUSEIO_SETMODE
|
||||||
ioctl(input->fd, WSMOUSEIO_SETMODE, WSMOUSE_COMPAT);
|
ioctl(input->fd, WSMOUSEIO_SETMODE, WSMOUSE_COMPAT);
|
||||||
|
|
|
@ -56,16 +56,16 @@ static const PROPERTYKEY SDL_PKEY_AudioEngine_DeviceFormat = { { 0xf19f064d, 0x8
|
||||||
static const PROPERTYKEY SDL_PKEY_AudioEndpoint_GUID = { { 0x1da5d803, 0xd492, 0x4edd,{ 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, } }, 4 };
|
static const PROPERTYKEY SDL_PKEY_AudioEndpoint_GUID = { { 0x1da5d803, 0xd492, 0x4edd,{ 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, } }, 4 };
|
||||||
/* *INDENT-ON* */ // clang-format on
|
/* *INDENT-ON* */ // clang-format on
|
||||||
|
|
||||||
static SDL_bool FindByDevIDCallback(SDL_AudioDevice *device, void *userdata)
|
static bool FindByDevIDCallback(SDL_AudioDevice *device, void *userdata)
|
||||||
{
|
{
|
||||||
LPCWSTR devid = (LPCWSTR)userdata;
|
LPCWSTR devid = (LPCWSTR)userdata;
|
||||||
if (devid && device && device->handle) {
|
if (devid && device && device->handle) {
|
||||||
const SDL_IMMDevice_HandleData *handle = (const SDL_IMMDevice_HandleData *)device->handle;
|
const SDL_IMMDevice_HandleData *handle = (const SDL_IMMDevice_HandleData *)device->handle;
|
||||||
if (handle->immdevice_id && SDL_wcscmp(handle->immdevice_id, devid) == 0) {
|
if (handle->immdevice_id && SDL_wcscmp(handle->immdevice_id, devid) == 0) {
|
||||||
return SDL_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SDL_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_AudioDevice *SDL_IMMDevice_FindByDevID(LPCWSTR devid)
|
static SDL_AudioDevice *SDL_IMMDevice_FindByDevID(LPCWSTR devid)
|
||||||
|
@ -120,7 +120,7 @@ void SDL_IMMDevice_FreeDeviceHandle(SDL_AudioDevice *device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_AudioDevice *SDL_IMMDevice_Add(const SDL_bool recording, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid, GUID *dsoundguid)
|
static SDL_AudioDevice *SDL_IMMDevice_Add(const bool recording, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid, GUID *dsoundguid)
|
||||||
{
|
{
|
||||||
/* You can have multiple endpoints on a device that are mutually exclusive ("Speakers" vs "Line Out" or whatever).
|
/* You can have multiple endpoints on a device that are mutually exclusive ("Speakers" vs "Line Out" or whatever).
|
||||||
In a perfect world, things that are unplugged won't be in this collection. The only gotcha is probably for
|
In a perfect world, things that are unplugged won't be in this collection. The only gotcha is probably for
|
||||||
|
@ -248,7 +248,7 @@ static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDeviceStateChanged(IM
|
||||||
if (SUCCEEDED(IMMDevice_QueryInterface(device, &SDL_IID_IMMEndpoint, (void **)&endpoint))) {
|
if (SUCCEEDED(IMMDevice_QueryInterface(device, &SDL_IID_IMMEndpoint, (void **)&endpoint))) {
|
||||||
EDataFlow flow;
|
EDataFlow flow;
|
||||||
if (SUCCEEDED(IMMEndpoint_GetDataFlow(endpoint, &flow))) {
|
if (SUCCEEDED(IMMEndpoint_GetDataFlow(endpoint, &flow))) {
|
||||||
const SDL_bool recording = (flow == eCapture);
|
const bool recording = (flow == eCapture);
|
||||||
if (dwNewState == DEVICE_STATE_ACTIVE) {
|
if (dwNewState == DEVICE_STATE_ACTIVE) {
|
||||||
char *utf8dev;
|
char *utf8dev;
|
||||||
WAVEFORMATEXTENSIBLE fmt;
|
WAVEFORMATEXTENSIBLE fmt;
|
||||||
|
@ -336,7 +336,7 @@ void SDL_IMMDevice_Quit(void)
|
||||||
WIN_CoUninitialize();
|
WIN_CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, SDL_bool recording)
|
int 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.
|
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.
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, SDL_bool r
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EnumerateEndpointsForFlow(const SDL_bool recording, SDL_AudioDevice **default_device)
|
static void EnumerateEndpointsForFlow(const bool recording, SDL_AudioDevice **default_device)
|
||||||
{
|
{
|
||||||
/* Note that WASAPI separates "adapter devices" from "audio endpoint devices"
|
/* Note that WASAPI separates "adapter devices" from "audio endpoint devices"
|
||||||
...one adapter device ("SoundBlaster Pro") might have multiple endpoint devices ("Speakers", "Line-Out"). */
|
...one adapter device ("SoundBlaster Pro") might have multiple endpoint devices ("Speakers", "Line-Out"). */
|
||||||
|
@ -422,8 +422,8 @@ static void EnumerateEndpointsForFlow(const SDL_bool recording, SDL_AudioDevice
|
||||||
|
|
||||||
void SDL_IMMDevice_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
void SDL_IMMDevice_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
||||||
{
|
{
|
||||||
EnumerateEndpointsForFlow(SDL_FALSE, default_playback);
|
EnumerateEndpointsForFlow(false, default_playback);
|
||||||
EnumerateEndpointsForFlow(SDL_TRUE, default_recording);
|
EnumerateEndpointsForFlow(true, default_recording);
|
||||||
|
|
||||||
// if this fails, we just won't get hotplug events. Carry on anyhow.
|
// if this fails, we just won't get hotplug events. Carry on anyhow.
|
||||||
IMMDeviceEnumerator_RegisterEndpointNotificationCallback(enumerator, (IMMNotificationClient *)¬ification_client);
|
IMMDeviceEnumerator_RegisterEndpointNotificationCallback(enumerator, (IMMNotificationClient *)¬ification_client);
|
||||||
|
|
|
@ -36,7 +36,7 @@ typedef struct SDL_IMMDevice_callbacks
|
||||||
|
|
||||||
int SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks);
|
int SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks);
|
||||||
void SDL_IMMDevice_Quit(void);
|
void SDL_IMMDevice_Quit(void);
|
||||||
int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, SDL_bool recording);
|
int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, bool recording);
|
||||||
void SDL_IMMDevice_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording);
|
void SDL_IMMDevice_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording);
|
||||||
LPGUID SDL_IMMDevice_GetDirectSoundGUID(SDL_AudioDevice *device);
|
LPGUID SDL_IMMDevice_GetDirectSoundGUID(SDL_AudioDevice *device);
|
||||||
LPCWSTR SDL_IMMDevice_GetDevID(SDL_AudioDevice *device);
|
LPCWSTR SDL_IMMDevice_GetDevID(SDL_AudioDevice *device);
|
||||||
|
|
|
@ -126,12 +126,12 @@ void WIN_CoUninitialize(void)
|
||||||
#ifndef SDL_PLATFORM_WINRT
|
#ifndef SDL_PLATFORM_WINRT
|
||||||
FARPROC WIN_LoadComBaseFunction(const char *name)
|
FARPROC WIN_LoadComBaseFunction(const char *name)
|
||||||
{
|
{
|
||||||
static SDL_bool s_bLoaded;
|
static bool s_bLoaded;
|
||||||
static HMODULE s_hComBase;
|
static HMODULE s_hComBase;
|
||||||
|
|
||||||
if (!s_bLoaded) {
|
if (!s_bLoaded) {
|
||||||
s_hComBase = LoadLibraryEx(TEXT("combase.dll"), NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
s_hComBase = LoadLibraryEx(TEXT("combase.dll"), NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||||
s_bLoaded = SDL_TRUE;
|
s_bLoaded = true;
|
||||||
}
|
}
|
||||||
if (s_hComBase) {
|
if (s_hComBase) {
|
||||||
return GetProcAddress(s_hComBase, name);
|
return GetProcAddress(s_hComBase, name);
|
||||||
|
@ -206,11 +206,11 @@ static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WO
|
||||||
#define CHECKWINVER(notdesktop_platform_result, test) return (notdesktop_platform_result);
|
#define CHECKWINVER(notdesktop_platform_result, test) return (notdesktop_platform_result);
|
||||||
#else
|
#else
|
||||||
#define CHECKWINVER(notdesktop_platform_result, test) \
|
#define CHECKWINVER(notdesktop_platform_result, test) \
|
||||||
static SDL_bool checked = SDL_FALSE; \
|
static bool checked = false; \
|
||||||
static BOOL retval = FALSE; \
|
static BOOL retval = FALSE; \
|
||||||
if (!checked) { \
|
if (!checked) { \
|
||||||
retval = (test); \
|
retval = (test); \
|
||||||
checked = SDL_TRUE; \
|
checked = true; \
|
||||||
} \
|
} \
|
||||||
return retval;
|
return retval;
|
||||||
#endif
|
#endif
|
||||||
|
@ -272,7 +272,7 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
|
||||||
const unsigned char *ptr;
|
const unsigned char *ptr;
|
||||||
char keystr[128];
|
char keystr[128];
|
||||||
WCHAR *strw = NULL;
|
WCHAR *strw = NULL;
|
||||||
SDL_bool rc;
|
bool rc;
|
||||||
HKEY hkey;
|
HKEY hkey;
|
||||||
DWORD len = 0;
|
DWORD len = 0;
|
||||||
char *retval = NULL;
|
char *retval = NULL;
|
||||||
|
|
|
@ -135,16 +135,16 @@ extern void WIN_CoUninitialize(void);
|
||||||
extern HRESULT WIN_RoInitialize(void);
|
extern HRESULT WIN_RoInitialize(void);
|
||||||
extern void WIN_RoUninitialize(void);
|
extern void WIN_RoUninitialize(void);
|
||||||
|
|
||||||
// Returns SDL_TRUE if we're running on Windows XP (any service pack). DOES NOT CHECK XP "OR GREATER"!
|
// Returns true if we're running on Windows XP (any service pack). DOES NOT CHECK XP "OR GREATER"!
|
||||||
extern BOOL WIN_IsWindowsXP(void);
|
extern BOOL WIN_IsWindowsXP(void);
|
||||||
|
|
||||||
// Returns SDL_TRUE if we're running on Windows Vista and newer
|
// Returns true if we're running on Windows Vista and newer
|
||||||
extern BOOL WIN_IsWindowsVistaOrGreater(void);
|
extern BOOL WIN_IsWindowsVistaOrGreater(void);
|
||||||
|
|
||||||
// Returns SDL_TRUE if we're running on Windows 7 and newer
|
// Returns true if we're running on Windows 7 and newer
|
||||||
extern BOOL WIN_IsWindows7OrGreater(void);
|
extern BOOL WIN_IsWindows7OrGreater(void);
|
||||||
|
|
||||||
// Returns SDL_TRUE if we're running on Windows 8 and newer
|
// Returns true if we're running on Windows 8 and newer
|
||||||
extern BOOL WIN_IsWindows8OrGreater(void);
|
extern BOOL WIN_IsWindows8OrGreater(void);
|
||||||
|
|
||||||
// You need to SDL_free() the result of this call.
|
// You need to SDL_free() the result of this call.
|
||||||
|
@ -158,7 +158,7 @@ extern BOOL WIN_IsEqualIID(REFIID a, REFIID b);
|
||||||
extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect);
|
extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect);
|
||||||
extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect);
|
extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect);
|
||||||
|
|
||||||
// Returns SDL_TRUE if the rect is empty
|
// Returns true if the rect is empty
|
||||||
extern BOOL WIN_IsRectEmpty(const RECT *rect);
|
extern BOOL WIN_IsRectEmpty(const RECT *rect);
|
||||||
|
|
||||||
extern SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat);
|
extern SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue