mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-28 03:26:15 +08:00
Use C99 bool internally in SDL
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -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;
|
||||||
|
|||||||
+1
-1
@@ -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_
|
||||||
|
|||||||
+32
-32
@@ -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)
|
||||||
|
|||||||
+10
-10
@@ -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);
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -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
|
||||||
|
|||||||
+18
-18
@@ -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;
|
||||||
|
|||||||
+16
-16
@@ -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);
|
||||||
|
|||||||
+13
-13
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
+92
-92
File diff suppressed because it is too large
Load Diff
+23
-23
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-25
@@ -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
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user