Update for SDL3 coding style (#6717)

I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594
This commit is contained in:
Sam Lantinga
2022-11-30 12:51:59 -08:00
committed by GitHub
parent 14b902faca
commit 5750bcb174
781 changed files with 51659 additions and 55763 deletions

View File

@@ -16,8 +16,8 @@ AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: All
AlwaysBreakAfterReturnType: AllDefinitions
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
@@ -35,7 +35,7 @@ BraceWrapping:
AfterUnion: true
AfterExternBlock: false
BeforeElse: false
BeforeWhile: true
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
@@ -48,7 +48,7 @@ IncludeBlocks: Preserve
# clang-format version 4.0 through 12.0:
#SortIncludes: false
# clang-format version 13.0+:
#SortIncludes: Never
SortIncludes: Never
# No length limit, in case it breaks macros, you can
# disable it with /* clang-format off/on */ comments
@@ -62,7 +62,8 @@ IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: NoIndent
SpaceAfterCStyleCast: true
PointerAlignment: Right
SpaceAfterCStyleCast: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true

View File

@@ -0,0 +1,32 @@
#!/bin/sh
cd "$(dirname $0)/../src"
echo "Running clang-format in $(pwd)"
find . -regex '.*\.[chm]p*' -exec clang-format -i {} \;
# Revert third-party code
git checkout \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
libm \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
video/arm \
video/khronos \
video/x11/edid-parse.c \
video/yuv2rgb
clang-format -i hidapi/SDL_hidapi.c
# Revert generated code
git checkout dynapi/SDL_dynapi_overrides.h
git checkout dynapi/SDL_dynapi_procs.h
git checkout render/metal/SDL_shaders_metal_*.h
echo "clang-format complete!"

View File

@@ -99,7 +99,6 @@ SDL_NORETURN void SDL_ExitProcess(int exitcode)
#endif
}
/* The initialized subsystems */
#ifdef SDL_MAIN_NEEDED
static SDL_bool SDL_MainIsReady = SDL_FALSE;
@@ -110,8 +109,7 @@ static SDL_bool SDL_bInMainQuit = SDL_FALSE;
static Uint8 SDL_SubsystemRefCount[32];
/* Private helper to increment a subsystem's ref counter. */
static void
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
static void SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
{
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
@@ -121,8 +119,7 @@ SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
}
/* Private helper to decrement a subsystem's ref counter. */
static void
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
static void SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
{
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] > 0)) {
@@ -131,8 +128,7 @@ SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
}
/* Private helper to check if a system needs init. */
static SDL_bool
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
static SDL_bool SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
{
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
@@ -140,8 +136,8 @@ SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
}
/* Private helper to check if a system needs to be quit. */
static SDL_bool
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
static SDL_bool SDL_PrivateShouldQuitSubsystem(Uint32 subsystem)
{
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) {
return SDL_FALSE;
@@ -153,14 +149,12 @@ SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
}
void
SDL_SetMainReady(void)
void SDL_SetMainReady(void)
{
SDL_MainIsReady = SDL_TRUE;
}
int
SDL_InitSubSystem(Uint32 flags)
int SDL_InitSubSystem(Uint32 flags)
{
Uint32 flags_initialized = 0;
@@ -335,14 +329,12 @@ quit_and_error:
return -1;
}
int
SDL_Init(Uint32 flags)
int SDL_Init(Uint32 flags)
{
return SDL_InitSubSystem(flags);
}
void
SDL_QuitSubSystem(Uint32 flags)
void SDL_QuitSubSystem(Uint32 flags)
{
/* Shut down requested initialized subsystems */
#if !SDL_SENSOR_DISABLED
@@ -459,8 +451,7 @@ SDL_WasInit(Uint32 flags)
return initialized;
}
void
SDL_Quit(void)
void SDL_Quit(void)
{
SDL_bInMainQuit = SDL_TRUE;
@@ -494,13 +485,13 @@ SDL_Quit(void)
}
/* Get the library version number */
void
SDL_GetVersion(SDL_version * ver)
void SDL_GetVersion(SDL_version *ver)
{
static SDL_bool check_hint = SDL_TRUE;
static SDL_bool legacy_version = SDL_FALSE;
if (ver == NULL) { return;
if (ver == NULL) {
return;
}
SDL_VERSION(ver);

View File

@@ -40,8 +40,7 @@
/* The size of the stack buffer to use for rendering assert messages. */
#define SDL_MAX_ASSERT_MESSAGE_STACK 256
static SDL_assert_state SDLCALL
SDL_PromptAssertion(const SDL_assert_data *data, void *userdata);
static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data, void *userdata);
/*
* We keep all triggered assertions in a singly-linked list so we can
@@ -57,12 +56,10 @@ static SDL_AssertionHandler assertion_handler = SDL_PromptAssertion;
static void *assertion_userdata = NULL;
#ifdef __GNUC__
static void
debug_print(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
static void debug_print(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
#endif
static void
debug_print(const char *fmt, ...)
static void debug_print(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@@ -70,7 +67,6 @@ debug_print(const char *fmt, ...)
va_end(ap);
}
static void SDL_AddAssertionToReport(SDL_assert_data *data)
{
/* (data) is always a static struct defined with the assert macros, so
@@ -88,13 +84,13 @@ static void SDL_AddAssertionToReport(SDL_assert_data *data)
#define ENDLINE "\n"
#endif
static int SDL_RenderAssertMessage(char *buf, size_t buf_len, const SDL_assert_data *data) {
static int SDL_RenderAssertMessage(char *buf, size_t buf_len, const SDL_assert_data *data)
{
return SDL_snprintf(buf, buf_len,
"Assertion failure at %s (%s:%d), triggered %u %s:" ENDLINE " '%s'",
data->function, data->filename, data->linenum,
data->trigger_count, (data->trigger_count == 1) ? "time" : "times",
data->condition
);
data->condition);
}
static void SDL_GenerateAssertionReport(void)
@@ -124,7 +120,6 @@ static void SDL_GenerateAssertionReport(void)
}
}
/* This is not declared in any header, although it is shared between some
parts of SDL, because we don't want anything calling it without an
extremely good reason. */
@@ -134,7 +129,6 @@ extern void SDL_ExitProcess(int exitcode);
#endif
extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
#if defined(__WATCOMC__)
static void SDL_AbortAssertion(void);
#pragma aux SDL_AbortAssertion aborts;
@@ -145,8 +139,7 @@ static SDL_NORETURN void SDL_AbortAssertion(void)
SDL_ExitProcess(42);
}
static SDL_assert_state SDLCALL
SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
{
const char *envr;
SDL_assert_state state = SDL_ASSERTION_ABORT;
@@ -249,6 +242,7 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
/* This is nasty, but we can't block on a custom UI. */
for (;;) {
SDL_bool okay = SDL_TRUE;
/* *INDENT-OFF* */ /* clang-format off */
char *buf = (char *) EM_ASM_INT({
var str =
UTF8ToString($0) + '\n\n' +
@@ -259,12 +253,14 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
}
return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL);
}, message);
/* *INDENT-ON* */ /* clang-format on */
if (SDL_strcmp(buf, "a") == 0) {
state = SDL_ASSERTION_ABORT;
/* (currently) no break functionality on Emscripten
#if 0 /* (currently) no break functionality on Emscripten */
} else if (SDL_strcmp(buf, "b") == 0) {
state = SDL_ASSERTION_BREAK; */
state = SDL_ASSERTION_BREAK;
#endif
} else if (SDL_strcmp(buf, "r") == 0) {
state = SDL_ASSERTION_RETRY;
} else if (SDL_strcmp(buf, "i") == 0) {
@@ -322,7 +318,6 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
return state;
}
SDL_assert_state
SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
int line)
@@ -363,7 +358,8 @@ SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
} else if (assertion_running == 3) { /* Abort asserted! */
SDL_ExitProcess(42);
} else {
while (1) { /* do nothing but spin; what else can you do?! */ }
while (1) { /* do nothing but spin; what else can you do?! */
}
}
}
@@ -371,8 +367,7 @@ SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
state = assertion_handler(data, assertion_userdata);
}
switch (state)
{
switch (state) {
case SDL_ASSERTION_ALWAYS_IGNORE:
state = SDL_ASSERTION_IGNORE;
data->always_ignore = 1;
@@ -397,7 +392,6 @@ SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
return state;
}
void SDL_AssertionsQuit(void)
{
#if SDL_ASSERT_LEVEL > 0

View File

@@ -39,8 +39,7 @@ struct SDL_DataQueue
size_t queued_bytes; /* number of bytes of data in the queue. */
};
static void
SDL_FreeDataQueueList(SDL_DataQueuePacket *packet)
static void SDL_FreeDataQueueList(SDL_DataQueuePacket *packet)
{
while (packet) {
SDL_DataQueuePacket *next = packet->next;
@@ -49,7 +48,6 @@ SDL_FreeDataQueueList(SDL_DataQueuePacket *packet)
}
}
/* this all expects that you managed thread safety elsewhere. */
SDL_DataQueue *
@@ -82,8 +80,7 @@ SDL_NewDataQueue(const size_t _packetlen, const size_t initialslack)
return queue;
}
void
SDL_FreeDataQueue(SDL_DataQueue *queue)
void SDL_FreeDataQueue(SDL_DataQueue *queue)
{
if (queue) {
SDL_FreeDataQueueList(queue->head);
@@ -92,8 +89,7 @@ SDL_FreeDataQueue(SDL_DataQueue *queue)
}
}
void
SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack)
void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack)
{
const size_t packet_size = queue ? queue->packet_size : 1;
const size_t slackpackets = (slack + (packet_size - 1)) / packet_size;
@@ -135,8 +131,7 @@ SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack)
SDL_FreeDataQueueList(packet); /* free extra packets */
}
static SDL_DataQueuePacket *
AllocateDataQueuePacket(SDL_DataQueue *queue)
static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue)
{
SDL_DataQueuePacket *packet;
@@ -168,9 +163,7 @@ AllocateDataQueuePacket(SDL_DataQueue *queue)
return packet;
}
int
SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _len)
int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _len)
{
size_t len = _len;
const Uint8 *data = (const Uint8 *)_data;
@@ -334,4 +327,3 @@ SDL_ReserveSpaceInDataQueue(SDL_DataQueue *queue, const size_t len)
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -52,4 +52,3 @@ void *SDL_ReserveSpaceInDataQueue(SDL_DataQueue *queue, const size_t len);
#endif /* SDL_dataqueue_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -24,8 +24,7 @@
#include "SDL_error_c.h"
int
SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
/* Ignore call if invalid format pointer was passed */
if (fmt != NULL) {
@@ -51,7 +50,6 @@ SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
}
}
if (SDL_LogGetPriority(SDL_LOG_CATEGORY_ERROR) <= SDL_LOG_PRIORITY_DEBUG) {
/* If we are in debug mode, print out the error message */
SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", error->str);
@@ -69,15 +67,13 @@ SDL_GetError(void)
return error->error ? error->str : "";
}
void
SDL_ClearError(void)
void SDL_ClearError(void)
{
SDL_GetErrBuf()->error = 0;
}
/* Very common errors go here */
int
SDL_Error(SDL_errorcode code)
int SDL_Error(SDL_errorcode code)
{
switch (code) {
case SDL_ENOMEM:
@@ -96,8 +92,7 @@ SDL_Error(SDL_errorcode code)
}
#ifdef TEST_ERROR
int
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
char buffer[BUFSIZ + 1];
@@ -112,7 +107,6 @@ main(int argc, char *argv[])
}
#endif
char *
SDL_GetErrorMsg(char *errstr, int maxlen)
{

View File

@@ -20,8 +20,6 @@
*/
#include "SDL_internal.h"
/* convert the guid to a printable string */
void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID)
{

View File

@@ -22,17 +22,18 @@
#include "SDL_hints_c.h"
/* Assuming there aren't many hints set and they aren't being queried in
critical performance paths, we'll just use linked lists here.
*/
typedef struct SDL_HintWatch {
typedef struct SDL_HintWatch
{
SDL_HintCallback callback;
void *userdata;
struct SDL_HintWatch *next;
} SDL_HintWatch;
typedef struct SDL_Hint {
typedef struct SDL_Hint
{
char *name;
char *value;
SDL_HintPriority priority;
@@ -127,8 +128,7 @@ SDL_ResetHint(const char *name)
return SDL_FALSE;
}
void
SDL_ResetHints(void)
void SDL_ResetHints(void)
{
const char *env;
SDL_Hint *hint;
@@ -195,8 +195,7 @@ SDL_GetHintBoolean(const char *name, SDL_bool default_value)
return SDL_GetStringBoolean(hint, default_value);
}
void
SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
{
SDL_Hint *hint;
SDL_HintWatch *entry;
@@ -257,8 +256,7 @@ SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
callback(userdata, name, value, value);
}
void
SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
void SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
{
SDL_Hint *hint;
SDL_HintWatch *entry, *prev;

View File

@@ -42,7 +42,12 @@
#define SDL_MAX_SMALL_ALLOC_STACKSIZE 128
#define SDL_small_alloc(type, count, pisstack) ((*(pisstack) = ((sizeof(type) * (count)) < SDL_MAX_SMALL_ALLOC_STACKSIZE)), (*(pisstack) ? SDL_stack_alloc(type, count) : (type *)SDL_malloc(sizeof(type) * (count))))
#define SDL_small_free(ptr, isstack) if ((isstack)) { SDL_stack_free(ptr); } else { SDL_free(ptr); }
#define SDL_small_free(ptr, isstack) \
if ((isstack)) { \
SDL_stack_free(ptr); \
} else { \
SDL_free(ptr); \
}
#include "dynapi/SDL_dynapi.h"
@@ -105,7 +110,6 @@
#include <float.h>
#endif
/* 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
#define O_CLOEXEC 0

View File

@@ -23,8 +23,7 @@
#include "./SDL_list.h"
/* Push */
int
SDL_ListAdd(SDL_ListNode **head, void *ent)
int SDL_ListAdd(SDL_ListNode **head, void *ent)
{
SDL_ListNode *node = SDL_malloc(sizeof(*node));
@@ -39,8 +38,7 @@ SDL_ListAdd(SDL_ListNode **head, void *ent)
}
/* Pop from end as a FIFO (if add with SDL_ListAdd) */
void
SDL_ListPop(SDL_ListNode **head, void **ent)
void SDL_ListPop(SDL_ListNode **head, void **ent)
{
SDL_ListNode **ptr = head;
@@ -61,8 +59,7 @@ SDL_ListPop(SDL_ListNode **head, void **ent)
*ptr = NULL;
}
void
SDL_ListRemove(SDL_ListNode **head, void *ent)
void SDL_ListRemove(SDL_ListNode **head, void *ent)
{
SDL_ListNode **ptr = head;
@@ -77,8 +74,7 @@ SDL_ListRemove(SDL_ListNode **head, void *ent)
}
}
void
SDL_ListClear(SDL_ListNode **head)
void SDL_ListClear(SDL_ListNode **head)
{
SDL_ListNode *l = *head;
*head = NULL;

View File

@@ -28,7 +28,6 @@ typedef struct SDL_ListNode
struct SDL_ListNode *next;
} SDL_ListNode;
int SDL_ListAdd(SDL_ListNode **head, void *ent);
void SDL_ListPop(SDL_ListNode **head, void **ent);
void SDL_ListRemove(SDL_ListNode **head, void *ent);

View File

@@ -38,7 +38,6 @@
#include "stdlib/SDL_vacopy.h"
/* The size of the stack buffer to use for rendering log messages. */
#define SDL_MAX_LOG_MESSAGE_STACK 256
@@ -102,8 +101,7 @@ static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = {
};
#endif /* __ANDROID__ */
void
SDL_LogInit(void)
void SDL_LogInit(void)
{
if (log_function_mutex == NULL) {
/* if this fails we'll try to continue without it. */
@@ -111,8 +109,7 @@ SDL_LogInit(void)
}
}
void
SDL_LogQuit(void)
void SDL_LogQuit(void)
{
SDL_LogResetPriorities();
if (log_function_mutex) {
@@ -121,8 +118,7 @@ SDL_LogQuit(void)
}
}
void
SDL_LogSetAllPriority(SDL_LogPriority priority)
void SDL_LogSetAllPriority(SDL_LogPriority priority)
{
SDL_LogLevel *entry;
@@ -134,8 +130,7 @@ SDL_LogSetAllPriority(SDL_LogPriority priority)
SDL_application_priority = priority;
}
void
SDL_LogSetPriority(int category, SDL_LogPriority priority)
void SDL_LogSetPriority(int category, SDL_LogPriority priority)
{
SDL_LogLevel *entry;
@@ -178,8 +173,7 @@ SDL_LogGetPriority(int category)
}
}
void
SDL_LogResetPriorities(void)
void SDL_LogResetPriorities(void)
{
SDL_LogLevel *entry;
@@ -195,8 +189,7 @@ SDL_LogResetPriorities(void)
SDL_test_priority = DEFAULT_TEST_PRIORITY;
}
void
SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
void SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
va_list ap;
@@ -205,8 +198,7 @@ SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(ap);
}
void
SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
void SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
va_list ap;
@@ -215,8 +207,7 @@ SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(ap);
}
void
SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
void SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
va_list ap;
@@ -225,8 +216,7 @@ SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(ap);
}
void
SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
void SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
va_list ap;
@@ -235,8 +225,7 @@ SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(ap);
}
void
SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
void SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
va_list ap;
@@ -245,8 +234,7 @@ SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(ap);
}
void
SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
void SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
va_list ap;
@@ -255,8 +243,7 @@ SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(ap);
}
void
SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
void SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
va_list ap;
@@ -265,8 +252,7 @@ SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(ap);
}
void
SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
void SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
va_list ap;
@@ -276,8 +262,7 @@ SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING
}
#ifdef __ANDROID__
static const char *
GetCategoryPrefix(int category)
static const char *GetCategoryPrefix(int category)
{
if (category < SDL_LOG_CATEGORY_RESERVED1) {
return SDL_category_prefixes[category];
@@ -289,8 +274,7 @@ GetCategoryPrefix(int category)
}
#endif /* __ANDROID__ */
void
SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap)
void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap)
{
char *message = NULL;
char stack_buf[SDL_MAX_LOG_MESSAGE_STACK];
@@ -373,8 +357,7 @@ static int consoleAttached = 0;
static HANDLE stderrHandle = NULL;
#endif
static void SDLCALL
SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
const char *message)
{
#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)
@@ -503,8 +486,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
#endif
}
void
SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
void SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
{
if (callback) {
*callback = SDL_log_function;
@@ -514,8 +496,7 @@ SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
}
}
void
SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata)
void SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata)
{
SDL_log_function = callback;
SDL_log_userdata = userdata;

View File

@@ -20,7 +20,6 @@
*/
#include "SDL_internal.h"
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
#include <intrin.h>
#define HAVE_MSC_ATOMICS 1
@@ -49,6 +48,7 @@
#endif
#endif
/* *INDENT-OFF* */ /* clang-format off */
#if defined(__WATCOMC__) && defined(__386__)
SDL_COMPILE_TIME_ASSERT(intsize, 4==sizeof(int));
#define HAVE_WATCOM_ATOMICS
@@ -73,7 +73,9 @@ extern __inline int _SDL_xadd_watcom(volatile int *a, int v);
parm [ecx] [eax] \
value [eax] \
modify exact [eax];
#endif /* __WATCOMC__ && __386__ */
/* *INDENT-ON* */ /* clang-format on */
/*
If any of the operations are not provided then we must emulate some
@@ -105,16 +107,14 @@ extern __inline int _SDL_xadd_watcom(volatile int *a, int v);
#if EMULATE_CAS
static SDL_SpinLock locks[32];
static SDL_INLINE void
enterLock(void *a)
static SDL_INLINE void enterLock(void *a)
{
uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f);
SDL_AtomicLock(&locks[index]);
}
static SDL_INLINE void
leaveLock(void *a)
static SDL_INLINE void leaveLock(void *a)
{
uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f);
@@ -122,7 +122,6 @@ leaveLock(void *a)
}
#endif
SDL_bool
SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval)
{
@@ -184,8 +183,7 @@ SDL_AtomicCASPtr(void **a, void *oldval, void *newval)
#endif
}
int
SDL_AtomicSet(SDL_atomic_t *a, int v)
int SDL_AtomicSet(SDL_atomic_t *a, int v)
{
#ifdef HAVE_MSC_ATOMICS
SDL_COMPILE_TIME_ASSERT(atomic_set, sizeof(long) == sizeof(a->value));
@@ -225,8 +223,7 @@ SDL_AtomicSetPtr(void **a, void *v)
#endif
}
int
SDL_AtomicAdd(SDL_atomic_t *a, int v)
int SDL_AtomicAdd(SDL_atomic_t *a, int v)
{
#ifdef HAVE_MSC_ATOMICS
SDL_COMPILE_TIME_ASSERT(atomic_add, sizeof(long) == sizeof(a->value));
@@ -249,8 +246,7 @@ SDL_AtomicAdd(SDL_atomic_t *a, int v)
#endif
}
int
SDL_AtomicGet(SDL_atomic_t *a)
int SDL_AtomicGet(SDL_atomic_t *a)
{
#ifdef HAVE_ATOMIC_LOAD_N
return __atomic_load_n(&a->value, __ATOMIC_SEQ_CST);
@@ -298,14 +294,12 @@ SDL_AtomicGetPtr(void **a)
#error This file should be built in arm mode so the mcr instruction is available for memory barriers
#endif
void
SDL_MemoryBarrierReleaseFunction(void)
void SDL_MemoryBarrierReleaseFunction(void)
{
SDL_MemoryBarrierRelease();
}
void
SDL_MemoryBarrierAcquireFunction(void)
void SDL_MemoryBarrierAcquireFunction(void)
{
SDL_MemoryBarrierAcquire();
}

View File

@@ -24,7 +24,6 @@
#include "../core/windows/SDL_windows.h"
#endif
#if !defined(HAVE_GCC_ATOMICS) && defined(__SOLARIS__)
#include <atomic.h>
#endif
@@ -45,6 +44,7 @@
#include <libkern/OSAtomic.h>
#endif
/* *INDENT-OFF* */ /* clang-format off */
#if defined(__WATCOMC__) && defined(__386__)
SDL_COMPILE_TIME_ASSERT(locksize, 4==sizeof(SDL_SpinLock));
extern __inline int _SDL_xchg_watcom(volatile int *a, int v);
@@ -54,6 +54,7 @@ extern __inline int _SDL_xchg_watcom(volatile int *a, int v);
value [eax] \
modify exact [eax];
#endif /* __WATCOMC__ && __386__ */
/* *INDENT-ON* */ /* clang-format on */
/* This function is where all the magic happens... */
SDL_bool
@@ -101,28 +102,36 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
if (__cpucap_have_rex()) {
__asm__ __volatile__(
"ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]"
: "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory");
: "=&r"(result)
: "r"(1), "r"(lock)
: "cc", "memory");
return result == 0;
}
#endif
__asm__ __volatile__(
"swp %0, %1, [%2]\n"
: "=&r,&r" (result) : "r,0" (1), "r,r" (lock) : "memory");
: "=&r,&r"(result)
: "r,0"(1), "r,r"(lock)
: "memory");
return result == 0;
#elif defined(__GNUC__) && defined(__arm__)
int result;
__asm__ __volatile__(
"ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]"
: "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory");
: "=&r"(result)
: "r"(1), "r"(lock)
: "cc", "memory");
return result == 0;
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
int result;
__asm__ __volatile__(
"lock ; xchgl %0, (%1)\n"
: "=r" (result) : "r" (lock), "0" (1) : "cc", "memory");
: "=r"(result)
: "r"(lock), "0"(1)
: "cc", "memory");
return result == 0;
#elif defined(__MACOS__) || defined(__IOS__) || defined(__TVOS__)
@@ -147,7 +156,9 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
res = SDL_TRUE;
}
// enable interuption
if (oldintr) { EIntr(); }
if (oldintr) {
EIntr();
}
return res;
#else
#error Please implement for your platform.
@@ -155,8 +166,7 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
#endif
}
void
SDL_AtomicLock(SDL_SpinLock *lock)
void SDL_AtomicLock(SDL_SpinLock *lock)
{
int iterations = 0;
/* FIXME: Should we have an eventual timeout? */
@@ -171,8 +181,7 @@ SDL_AtomicLock(SDL_SpinLock *lock)
}
}
void
SDL_AtomicUnlock(SDL_SpinLock *lock)
void SDL_AtomicUnlock(SDL_SpinLock *lock)
{
#if HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
__sync_lock_release(lock);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1059,4 +1059,3 @@ static const float ResamplerFilterDifference[RESAMPLER_FILTER_SIZE] = {
};
/* vi: set ts=4 sw=4 expandtab: */

File diff suppressed because it is too large Load Diff

View File

@@ -45,8 +45,7 @@
#define _PATH_DEV_AUDIO "/dev/audio"
#endif
static void
test_device(const int iscapture, const char *fname, int flags, int (*test) (int fd))
static void test_device(const int iscapture, const char *fname, int flags, int (*test)(int fd))
{
struct stat sb;
if ((stat(fname, &sb) == 0) && (S_ISCHR(sb.st_mode))) {
@@ -70,14 +69,12 @@ test_device(const int iscapture, const char *fname, int flags, int (*test) (int
}
}
static int
test_stub(int fd)
static int test_stub(int fd)
{
return 1;
}
static void
SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*test)(int))
static void SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*test)(int))
{
const int flags = iscapture ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT;
const char *audiodev;
@@ -96,9 +93,7 @@ SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*
struct stat sb;
/* Added support for /dev/sound/\* in Linux 2.4 */
if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode))
&& ((stat(_PATH_DEV_DSP24, &sb) == 0)
&& S_ISCHR(sb.st_mode))) {
if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && ((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode))) {
audiodev = _PATH_DEV_DSP24;
} else {
audiodev = _PATH_DEV_DSP;
@@ -118,8 +113,7 @@ SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*
}
}
void
SDL_EnumUnixAudioDevices(const int classic, int (*test)(int))
void SDL_EnumUnixAudioDevices(const int classic, int (*test)(int))
{
SDL_EnumUnixAudioDevices_Internal(SDL_TRUE, classic, test);
SDL_EnumUnixAudioDevices_Internal(SDL_FALSE, classic, test);

File diff suppressed because it is too large Load Diff

View File

@@ -82,9 +82,7 @@ static const Uint8 mix8[] = {
#define ADJUST_VOLUME_U8(s, v) (s = (((s - 128) * v) / SDL_MIX_MAXVOLUME) + 128)
#define ADJUST_VOLUME_U16(s, v) (s = (((s - 32768) * v) / SDL_MIX_MAXVOLUME) + 32768)
void
SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
void SDL_MixAudioFormat(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format,
Uint32 len, int volume)
{
if (volume == 0) {
@@ -104,8 +102,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
++dst;
++src;
}
}
break;
} break;
case AUDIO_S8:
{
@@ -130,8 +127,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
++dst8;
++src8;
}
}
break;
} break;
case AUDIO_S16LSB:
{
@@ -155,8 +151,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
*(Sint16 *)dst = SDL_SwapLE16(dst_sample);
dst += 2;
}
}
break;
} break;
case AUDIO_S16MSB:
{
@@ -180,8 +175,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
*(Sint16 *)dst = SDL_SwapBE16(dst_sample);
dst += 2;
}
}
break;
} break;
case AUDIO_U16LSB:
{
@@ -206,8 +200,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
*(Uint16 *)dst = SDL_SwapLE16(dst_sample);
dst += 2;
}
}
break;
} break;
case AUDIO_U16MSB:
{
@@ -232,8 +225,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
*(Uint16 *)dst = SDL_SwapBE16(dst_sample);
dst += 2;
}
}
break;
} break;
case AUDIO_S32LSB:
{
@@ -258,8 +250,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
}
*(dst32++) = SDL_SwapLE32((Uint32)((Sint32)dst_sample));
}
}
break;
} break;
case AUDIO_S32MSB:
{
@@ -284,8 +275,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
}
*(dst32++) = SDL_SwapBE32((Uint32)((Sint32)dst_sample));
}
}
break;
} break;
case AUDIO_F32LSB:
{
@@ -313,8 +303,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
}
*(dst32++) = SDL_SwapFloatLE((float)dst_sample);
}
}
break;
} break;
case AUDIO_F32MSB:
{
@@ -342,8 +331,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
}
*(dst32++) = SDL_SwapFloatBE((float)dst_sample);
}
}
break;
} break;
default: /* If this happens... FIXME! */
SDL_SetError("SDL_MixAudioFormat(): unknown audio format");

View File

@@ -89,7 +89,6 @@ typedef struct SDL_AudioDriverImpl
SDL_bool SupportsNonPow2Samples;
} SDL_AudioDriverImpl;
typedef struct SDL_AudioDeviceItem
{
void *handle;
@@ -100,7 +99,6 @@ typedef struct SDL_AudioDeviceItem
struct SDL_AudioDeviceItem *next;
} SDL_AudioDeviceItem;
typedef struct SDL_AudioDriver
{
/* * * */
@@ -123,7 +121,6 @@ typedef struct SDL_AudioDriver
SDL_AudioDeviceItem *inputDevices;
} SDL_AudioDriver;
/* Define the SDL audio driver structure */
struct SDL_AudioDevice
{

View File

@@ -41,8 +41,7 @@
* Returns 0 on success, or -1 if the multiplication overflows, in which case f1
* does not get modified.
*/
static int
SafeMult(size_t *f1, size_t f2)
static int SafeMult(size_t *f1, size_t f2)
{
if (*f1 > 0 && SIZE_MAX / *f1 <= f2) {
return -1;
@@ -64,21 +63,24 @@ typedef struct ADPCM_DecoderState
void *cstate; /* Decoding state for each channel. */
/* ADPCM data. */
struct {
struct
{
Uint8 *data;
size_t size;
size_t pos;
} input;
/* Current ADPCM block in the ADPCM data above. */
struct {
struct
{
Uint8 *data;
size_t size;
size_t pos;
} block;
/* Decoded 16-bit PCM data. */
struct {
struct
{
Sint16 *data;
size_t size;
size_t pos;
@@ -100,8 +102,7 @@ typedef struct MS_ADPCM_ChannelState
} MS_ADPCM_ChannelState;
#ifdef SDL_WAVE_DEBUG_LOG_FORMAT
static void
WaveDebugLogFormat(WaveFile *file)
static void WaveDebugLogFormat(WaveFile *file)
{
WaveFormat *format = &file->format;
const char *fmtstr = "WAVE file: %s, %u Hz, %s, %u bits, %u %s/s";
@@ -135,9 +136,14 @@ WaveDebugLogFormat(WaveFile *file)
break;
}
#define SDL_WAVE_DEBUG_CHANNELCFG(STR, CODE) case CODE: wavechannel = STR; break;
#define SDL_WAVE_DEBUG_CHANNELSTR(STR, CODE) if (format->channelmask & CODE) { \
SDL_strlcat(channelstr, channelstr[0] ? "-" STR : STR, sizeof(channelstr));}
#define SDL_WAVE_DEBUG_CHANNELCFG(STR, CODE) \
case CODE: \
wavechannel = STR; \
break;
#define SDL_WAVE_DEBUG_CHANNELSTR(STR, CODE) \
if (format->channelmask & CODE) { \
SDL_strlcat(channelstr, channelstr[0] ? "-" STR : STR, sizeof(channelstr)); \
}
if (format->formattag == EXTENSIBLE_CODE && format->channelmask > 0) {
switch (format->channelmask) {
@@ -224,8 +230,7 @@ WaveDebugLogFormat(WaveFile *file)
#endif
#ifdef SDL_WAVE_DEBUG_DUMP_FORMAT
static void
WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, Uint32 datalen)
static void WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, Uint32 datalen)
{
WaveFormat *format = &file->format;
const char *fmtstr1 = "WAVE chunk dump:\n"
@@ -315,8 +320,7 @@ WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, Uint32 datale
}
#endif
static Sint64
WaveAdjustToFactValue(WaveFile *file, Sint64 sampleframes)
static Sint64 WaveAdjustToFactValue(WaveFile *file, Sint64 sampleframes)
{
if (file->fact.status == 2) {
if (file->facthint == FactStrict && sampleframes < file->fact.samplelength) {
@@ -329,8 +333,7 @@ WaveAdjustToFactValue(WaveFile *file, Sint64 sampleframes)
return sampleframes;
}
static int
MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
static int MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
{
WaveFormat *format = &file->format;
const size_t blockheadersize = (size_t)file->format.channels * 7;
@@ -369,8 +372,7 @@ MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
return 0;
}
static int
MS_ADPCM_Init(WaveFile *file, size_t datalength)
static int MS_ADPCM_Init(WaveFile *file, size_t datalength)
{
WaveFormat *format = &file->format;
WaveChunk *chunk = &file->chunk;
@@ -488,8 +490,7 @@ MS_ADPCM_Init(WaveFile *file, size_t datalength)
return 0;
}
static Sint16
MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sample1, Sint32 sample2, Uint8 nybble)
static Sint16 MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sample1, Sint32 sample2, Uint8 nybble)
{
const Sint32 max_audioval = 32767;
const Sint32 min_audioval = -32768;
@@ -525,8 +526,7 @@ MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sample1, Sint32 sam
return (Sint16)new_sample;
}
static int
MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
{
Uint8 coeffindex;
const Uint32 channels = state->channels;
@@ -586,8 +586,7 @@ MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
* will always contain full sample frames (same sample count for each channel).
* Incomplete sample frames are discarded.
*/
static int
MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
static int MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
{
Uint16 nybble = 0;
Sint16 sample1, sample2;
@@ -634,8 +633,7 @@ MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
return 0;
}
static int
MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{
int result;
size_t bytesleft, outputsize;
@@ -734,8 +732,7 @@ MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0;
}
static int
IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
static int IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
{
WaveFormat *format = &file->format;
const size_t blockheadersize = (size_t)format->channels * 4;
@@ -788,8 +785,7 @@ IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
return 0;
}
static int
IMA_ADPCM_Init(WaveFile *file, size_t datalength)
static int IMA_ADPCM_Init(WaveFile *file, size_t datalength)
{
WaveFormat *format = &file->format;
WaveChunk *chunk = &file->chunk;
@@ -854,8 +850,7 @@ IMA_ADPCM_Init(WaveFile *file, size_t datalength)
return 0;
}
static Sint16
IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 nybble)
static Sint16 IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 nybble)
{
const Sint32 max_audioval = 32767;
const Sint32 min_audioval = -32768;
@@ -924,8 +919,7 @@ IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 nybble)
return (Sint16)sample;
}
static int
IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
static int IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
{
Sint16 step;
Uint32 c;
@@ -964,8 +958,7 @@ IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
* contains full sample frames (same sample count for each channel).
* Incomplete sample frames are discarded.
*/
static int
IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
static int IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
{
size_t i;
int retval = 0;
@@ -1034,8 +1027,7 @@ IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
return retval;
}
static int
IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{
int result;
size_t bytesleft, outputsize;
@@ -1138,8 +1130,7 @@ IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0;
}
static int
LAW_Init(WaveFile *file, size_t datalength)
static int LAW_Init(WaveFile *file, size_t datalength)
{
WaveFormat *format = &file->format;
@@ -1167,8 +1158,7 @@ LAW_Init(WaveFile *file, size_t datalength)
return 0;
}
static int
LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{
#ifdef SDL_WAVE_LAW_LUT
const Sint16 alaw_lut[256] = {
@@ -1310,8 +1300,7 @@ LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0;
}
static int
PCM_Init(WaveFile *file, size_t datalength)
static int PCM_Init(WaveFile *file, size_t datalength)
{
WaveFormat *format = &file->format;
@@ -1354,8 +1343,7 @@ PCM_Init(WaveFile *file, size_t datalength)
return 0;
}
static int
PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{
WaveFormat *format = &file->format;
WaveChunk *chunk = &file->chunk;
@@ -1406,8 +1394,7 @@ PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0;
}
static int
PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
static int PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{
WaveFormat *format = &file->format;
WaveChunk *chunk = &file->chunk;
@@ -1449,8 +1436,7 @@ PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0;
}
static WaveRiffSizeHint
WaveGetRiffSizeHint()
static WaveRiffSizeHint WaveGetRiffSizeHint()
{
const char *hint = SDL_GetHint(SDL_HINT_WAVE_RIFF_CHUNK_SIZE);
@@ -1469,8 +1455,7 @@ WaveGetRiffSizeHint()
return RiffSizeNoHint;
}
static WaveTruncationHint
WaveGetTruncationHint()
static WaveTruncationHint WaveGetTruncationHint()
{
const char *hint = SDL_GetHint(SDL_HINT_WAVE_TRUNCATION);
@@ -1489,8 +1474,7 @@ WaveGetTruncationHint()
return TruncNoHint;
}
static WaveFactChunkHint
WaveGetFactChunkHint()
static WaveFactChunkHint WaveGetFactChunkHint()
{
const char *hint = SDL_GetHint(SDL_HINT_WAVE_FACT_CHUNK);
@@ -1509,8 +1493,7 @@ WaveGetFactChunkHint()
return FactNoHint;
}
static void
WaveFreeChunkData(WaveChunk *chunk)
static void WaveFreeChunkData(WaveChunk *chunk)
{
if (chunk->data != NULL) {
SDL_free(chunk->data);
@@ -1519,8 +1502,7 @@ WaveFreeChunkData(WaveChunk *chunk)
chunk->size = 0;
}
static int
WaveNextChunk(SDL_RWops *src, WaveChunk *chunk)
static int WaveNextChunk(SDL_RWops *src, WaveChunk *chunk)
{
Uint32 chunkheader[2];
Sint64 nextposition = chunk->position + chunk->length;
@@ -1552,8 +1534,7 @@ WaveNextChunk(SDL_RWops *src, WaveChunk *chunk)
return 0;
}
static int
WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t length)
static int WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t length)
{
WaveFreeChunkData(chunk);
@@ -1581,19 +1562,22 @@ WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t length)
return 0;
}
static int
WaveReadChunkData(SDL_RWops *src, WaveChunk *chunk)
static int WaveReadChunkData(SDL_RWops *src, WaveChunk *chunk)
{
return WaveReadPartialChunkData(src, chunk, chunk->length);
}
typedef struct WaveExtensibleGUID {
typedef struct WaveExtensibleGUID
{
Uint16 encoding;
Uint8 guid[16];
} WaveExtensibleGUID;
/* Some of the GUIDs that are used by WAVEFORMATEXTENSIBLE. */
#define WAVE_FORMATTAG_GUID(tag) {(tag) & 0xff, (tag) >> 8, 0, 0, 0, 0, 16, 0, 128, 0, 0, 170, 0, 56, 155, 113}
#define WAVE_FORMATTAG_GUID(tag) \
{ \
(tag) & 0xff, (tag) >> 8, 0, 0, 0, 0, 16, 0, 128, 0, 0, 170, 0, 56, 155, 113 \
}
static WaveExtensibleGUID extensible_guids[] = {
{ PCM_CODE, WAVE_FORMATTAG_GUID(PCM_CODE) },
{ MS_ADPCM_CODE, WAVE_FORMATTAG_GUID(MS_ADPCM_CODE) },
@@ -1603,8 +1587,7 @@ static WaveExtensibleGUID extensible_guids[] = {
{ IMA_ADPCM_CODE, WAVE_FORMATTAG_GUID(IMA_ADPCM_CODE) }
};
static Uint16
WaveGetFormatGUIDEncoding(WaveFormat *format)
static Uint16 WaveGetFormatGUIDEncoding(WaveFormat *format)
{
size_t i;
for (i = 0; i < SDL_arraysize(extensible_guids); i++) {
@@ -1615,8 +1598,7 @@ WaveGetFormatGUIDEncoding(WaveFormat *format)
return UNKNOWN_CODE;
}
static int
WaveReadFormat(WaveFile *file)
static int WaveReadFormat(WaveFile *file)
{
WaveChunk *chunk = &file->chunk;
WaveFormat *format = &file->format;
@@ -1677,8 +1659,7 @@ WaveReadFormat(WaveFile *file)
return 0;
}
static int
WaveCheckFormat(WaveFile *file, size_t datalength)
static int WaveCheckFormat(WaveFile *file, size_t datalength)
{
WaveFormat *format = &file->format;
@@ -1785,8 +1766,7 @@ WaveCheckFormat(WaveFile *file, size_t datalength)
return 0;
}
static int
WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
{
int result;
Uint32 chunkcount = 0;
@@ -2148,8 +2128,7 @@ SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_b
/* Since the WAV memory is allocated in the shared library, it must also
be freed here. (Necessary under Win32, VC++)
*/
void
SDL_FreeWAV(Uint8 *audio_buf)
void SDL_FreeWAV(Uint8 *audio_buf)
{
SDL_free(audio_buf);
}

View File

@@ -70,7 +70,8 @@ typedef struct WaveFormat
} WaveFormat;
/* Stores information on the fact chunk. */
typedef struct WaveFact {
typedef struct WaveFact
{
/* Represents the state of the fact chunk in the WAVE file.
* Set to -1 if the fact chunk is invalid.
* Set to 0 if the fact chunk is not present
@@ -101,7 +102,8 @@ typedef struct WaveChunk
} WaveChunk;
/* Controls how the size of the RIFF chunk affects the loading of a WAVE file. */
typedef enum WaveRiffSizeHint {
typedef enum WaveRiffSizeHint
{
RiffSizeNoHint,
RiffSizeForce,
RiffSizeIgnoreZero,
@@ -110,7 +112,8 @@ typedef enum WaveRiffSizeHint {
} WaveRiffSizeHint;
/* Controls how a truncated WAVE file is handled. */
typedef enum WaveTruncationHint {
typedef enum WaveTruncationHint
{
TruncNoHint,
TruncVeryStrict,
TruncStrict,
@@ -119,7 +122,8 @@ typedef enum WaveTruncationHint {
} WaveTruncationHint;
/* Controls how the fact chunk affects the loading of a WAVE file. */
typedef enum WaveFactChunkHint {
typedef enum WaveFactChunkHint
{
FactNoHint,
FactTruncate,
FactStrict,

View File

@@ -68,8 +68,7 @@ void aaudio_errorCallback( AAudioStream *stream, void *userData, aaudio_result_t
#define LIB_AAUDIO_SO "libaaudio.so"
static int
aaudio_OpenDevice(_THIS, const char *devname)
static int aaudio_OpenDevice(_THIS, const char *devname)
{
struct SDL_PrivateAudioData *private;
SDL_bool iscapture = this->iscapture;
@@ -165,8 +164,7 @@ aaudio_OpenDevice(_THIS, const char *devname)
return 0;
}
static void
aaudio_CloseDevice(_THIS)
static void aaudio_CloseDevice(_THIS)
{
struct SDL_PrivateAudioData *private = this->hidden;
aaudio_result_t res;
@@ -200,15 +198,13 @@ aaudio_CloseDevice(_THIS)
SDL_free(this->hidden);
}
static Uint8 *
aaudio_GetDeviceBuf(_THIS)
static Uint8 *aaudio_GetDeviceBuf(_THIS)
{
struct SDL_PrivateAudioData *private = this->hidden;
return private->mixbuf;
}
static void
aaudio_PlayDevice(_THIS)
static void aaudio_PlayDevice(_THIS)
{
struct SDL_PrivateAudioData *private = this->hidden;
aaudio_result_t res;
@@ -233,8 +229,7 @@ aaudio_PlayDevice(_THIS)
#endif
}
static int
aaudio_CaptureFromDevice(_THIS, void *buffer, int buflen)
static int aaudio_CaptureFromDevice(_THIS, void *buffer, int buflen)
{
struct SDL_PrivateAudioData *private = this->hidden;
aaudio_result_t res;
@@ -248,8 +243,7 @@ aaudio_CaptureFromDevice(_THIS, void *buffer, int buflen)
return res * private->frame_size;
}
static void
aaudio_Deinitialize(void)
static void aaudio_Deinitialize(void)
{
LOGI(__func__);
if (ctx.handle) {
@@ -267,8 +261,7 @@ aaudio_Deinitialize(void)
LOGI("End AAUDIO %s", SDL_GetError());
}
static SDL_bool
aaudio_Init(SDL_AudioDriverImpl *impl)
static SDL_bool aaudio_Init(SDL_AudioDriverImpl *impl)
{
aaudio_result_t res;
LOGI(__func__);

View File

@@ -47,7 +47,6 @@ void aaudio_ResumeDevices(void);
void aaudio_PauseDevices(void);
SDL_bool aaudio_DetectBrokenPlayState(void);
#endif /* _SDL_aaudio_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -77,4 +77,3 @@ SDL_PROC_UNUSED(aaudio_content_type_t, AAudioStream_getContentType, (AAudioStrea
SDL_PROC_UNUSED(aaudio_input_preset_t, AAudioStream_getInputPreset, (AAudioStream * stream)) /* API 28 */
SDL_PROC_UNUSED(aaudio_allowed_capture_policy_t, AAudioStream_getAllowedCapturePolicy, (AAudioStream * stream)) /* API 29 */
SDL_PROC_UNUSED(bool, AAudioStream_isPrivacySensitive, (AAudioStream * stream)) /* API 30 */

View File

@@ -43,56 +43,38 @@
#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
#endif
static int (*ALSA_snd_pcm_open)
(snd_pcm_t **, const char *, snd_pcm_stream_t, int);
static int (*ALSA_snd_pcm_open)(snd_pcm_t **, const char *, snd_pcm_stream_t, int);
static int (*ALSA_snd_pcm_close)(snd_pcm_t *pcm);
static snd_pcm_sframes_t (*ALSA_snd_pcm_writei)
(snd_pcm_t *, const void *, snd_pcm_uframes_t);
static snd_pcm_sframes_t (*ALSA_snd_pcm_readi)
(snd_pcm_t *, void *, snd_pcm_uframes_t);
static snd_pcm_sframes_t (*ALSA_snd_pcm_writei)(snd_pcm_t *, const void *, snd_pcm_uframes_t);
static snd_pcm_sframes_t (*ALSA_snd_pcm_readi)(snd_pcm_t *, void *, snd_pcm_uframes_t);
static int (*ALSA_snd_pcm_recover)(snd_pcm_t *, int, int);
static int (*ALSA_snd_pcm_prepare)(snd_pcm_t *);
static int (*ALSA_snd_pcm_drain)(snd_pcm_t *);
static const char *(*ALSA_snd_strerror)(int);
static size_t (*ALSA_snd_pcm_hw_params_sizeof)(void);
static size_t (*ALSA_snd_pcm_sw_params_sizeof)(void);
static void (*ALSA_snd_pcm_hw_params_copy)
(snd_pcm_hw_params_t *, const snd_pcm_hw_params_t *);
static void (*ALSA_snd_pcm_hw_params_copy)(snd_pcm_hw_params_t *, const snd_pcm_hw_params_t *);
static int (*ALSA_snd_pcm_hw_params_any)(snd_pcm_t *, snd_pcm_hw_params_t *);
static int (*ALSA_snd_pcm_hw_params_set_access)
(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_access_t);
static int (*ALSA_snd_pcm_hw_params_set_format)
(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_format_t);
static int (*ALSA_snd_pcm_hw_params_set_channels)
(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int);
static int (*ALSA_snd_pcm_hw_params_get_channels)
(const snd_pcm_hw_params_t *, unsigned int *);
static int (*ALSA_snd_pcm_hw_params_set_rate_near)
(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
static int (*ALSA_snd_pcm_hw_params_set_period_size_near)
(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *);
static int (*ALSA_snd_pcm_hw_params_get_period_size)
(const snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *);
static int (*ALSA_snd_pcm_hw_params_set_periods_min)
(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
static int (*ALSA_snd_pcm_hw_params_set_periods_first)
(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
static int (*ALSA_snd_pcm_hw_params_get_periods)
(const snd_pcm_hw_params_t *, unsigned int *, int *);
static int (*ALSA_snd_pcm_hw_params_set_buffer_size_near)
(snd_pcm_t *pcm, snd_pcm_hw_params_t *, snd_pcm_uframes_t *);
static int (*ALSA_snd_pcm_hw_params_get_buffer_size)
(const snd_pcm_hw_params_t *, snd_pcm_uframes_t *);
static int (*ALSA_snd_pcm_hw_params_set_access)(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_access_t);
static int (*ALSA_snd_pcm_hw_params_set_format)(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_format_t);
static int (*ALSA_snd_pcm_hw_params_set_channels)(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int);
static int (*ALSA_snd_pcm_hw_params_get_channels)(const snd_pcm_hw_params_t *, unsigned int *);
static int (*ALSA_snd_pcm_hw_params_set_rate_near)(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
static int (*ALSA_snd_pcm_hw_params_set_period_size_near)(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *);
static int (*ALSA_snd_pcm_hw_params_get_period_size)(const snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *);
static int (*ALSA_snd_pcm_hw_params_set_periods_min)(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
static int (*ALSA_snd_pcm_hw_params_set_periods_first)(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
static int (*ALSA_snd_pcm_hw_params_get_periods)(const snd_pcm_hw_params_t *, unsigned int *, int *);
static int (*ALSA_snd_pcm_hw_params_set_buffer_size_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *, snd_pcm_uframes_t *);
static int (*ALSA_snd_pcm_hw_params_get_buffer_size)(const snd_pcm_hw_params_t *, snd_pcm_uframes_t *);
static int (*ALSA_snd_pcm_hw_params)(snd_pcm_t *, snd_pcm_hw_params_t *);
static int (*ALSA_snd_pcm_sw_params_current)(snd_pcm_t *,
snd_pcm_sw_params_t *);
static int (*ALSA_snd_pcm_sw_params_set_start_threshold)
(snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
static int (*ALSA_snd_pcm_sw_params_set_start_threshold)(snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
static int (*ALSA_snd_pcm_sw_params)(snd_pcm_t *, snd_pcm_sw_params_t *);
static int (*ALSA_snd_pcm_nonblock)(snd_pcm_t *, int);
static int (*ALSA_snd_pcm_wait)(snd_pcm_t *, int);
static int (*ALSA_snd_pcm_sw_params_set_avail_min)
(snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
static int (*ALSA_snd_pcm_sw_params_set_avail_min)(snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
static int (*ALSA_snd_pcm_reset)(snd_pcm_t *);
static int (*ALSA_snd_device_name_hint)(int, const char *, void ***);
static char *(*ALSA_snd_device_name_get_hint)(const void *, const char *);
@@ -110,8 +92,7 @@ static int (*ALSA_snd_pcm_chmap_print) (const snd_pcm_chmap_t *map, size_t maxle
static const char *alsa_library = SDL_AUDIO_DRIVER_ALSA_DYNAMIC;
static void *alsa_handle = NULL;
static int
load_alsa_sym(const char *fn, void **addr)
static int load_alsa_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(alsa_handle, fn);
if (*addr == NULL) {
@@ -124,13 +105,13 @@ load_alsa_sym(const char *fn, void **addr)
/* cast funcs to char* first, to please GCC's strict aliasing rules. */
#define SDL_ALSA_SYM(x) \
if (!load_alsa_sym(#x, (void **) (char *) &ALSA_##x)) return -1
if (!load_alsa_sym(#x, (void **)(char *)&ALSA_##x)) \
return -1
#else
#define SDL_ALSA_SYM(x) ALSA_##x = x
#endif
static int
load_alsa_syms(void)
static int load_alsa_syms(void)
{
SDL_ALSA_SYM(snd_pcm_open);
SDL_ALSA_SYM(snd_pcm_close);
@@ -180,8 +161,7 @@ load_alsa_syms(void)
#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
static void
UnloadALSALibrary(void)
static void UnloadALSALibrary(void)
{
if (alsa_handle != NULL) {
SDL_UnloadObject(alsa_handle);
@@ -189,8 +169,7 @@ UnloadALSALibrary(void)
}
}
static int
LoadALSALibrary(void)
static int LoadALSALibrary(void)
{
int retval = 0;
if (alsa_handle == NULL) {
@@ -210,13 +189,11 @@ LoadALSALibrary(void)
#else
static void
UnloadALSALibrary(void)
static void UnloadALSALibrary(void)
{
}
static int
LoadALSALibrary(void)
static int LoadALSALibrary(void)
{
load_alsa_syms();
return 0;
@@ -224,8 +201,7 @@ LoadALSALibrary(void)
#endif /* SDL_AUDIO_DRIVER_ALSA_DYNAMIC */
static const char *
get_audio_device(void *handle, const int channels)
static const char *get_audio_device(void *handle, const int channels)
{
const char *device;
@@ -248,10 +224,8 @@ get_audio_device(void *handle, const int channels)
return "default";
}
/* This function waits until it is possible to write a full sound buffer */
static void
ALSA_WaitDevice(_THIS)
static void ALSA_WaitDevice(_THIS)
{
#if SDL_ALSA_NON_BLOCKING
const snd_pcm_sframes_t needed = (snd_pcm_sframes_t)this->spec.samples;
@@ -273,7 +247,6 @@ ALSA_WaitDevice(_THIS)
#endif
}
/* !!! FIXME: is there a channel swizzler in alsalib instead? */
/*
* https://bugzilla.libsdl.org/show_bug.cgi?id=110
@@ -281,17 +254,21 @@ ALSA_WaitDevice(_THIS)
* and for Windows DirectX [and CoreAudio], this is FL-FR-C-LFE-RL-RR"
*/
#define SWIZ6(T) \
static void swizzle_alsa_channels_6_##T(void *buffer, const Uint32 bufferlen) { \
static void swizzle_alsa_channels_6_##T(void *buffer, const Uint32 bufferlen) \
{ \
T *ptr = (T *)buffer; \
Uint32 i; \
for (i = 0; i < bufferlen; i++, ptr += 6) { \
T tmp; \
tmp = ptr[2]; ptr[2] = ptr[4]; ptr[4] = tmp; \
tmp = ptr[3]; ptr[3] = ptr[5]; ptr[5] = tmp; \
tmp = ptr[2]; \
ptr[2] = ptr[4]; \
ptr[4] = tmp; \
tmp = ptr[3]; \
ptr[3] = ptr[5]; \
ptr[5] = tmp; \
} \
}
/* !!! FIXME: is there a channel swizzler in alsalib instead? */
/* !!! FIXME: this screams for a SIMD shuffle operation. */
/*
@@ -300,7 +277,8 @@ static void swizzle_alsa_channels_6_##T(void *buffer, const Uint32 bufferlen) {
* and for Windows DirectX [and CoreAudio], this is FL-FR-C-LFE-SL-SR-RL-RR"
*/
#define SWIZ8(T) \
static void swizzle_alsa_channels_8_##T(void *buffer, const Uint32 bufferlen) { \
static void swizzle_alsa_channels_8_##T(void *buffer, const Uint32 bufferlen) \
{ \
T *ptr = (T *)buffer; \
Uint32 i; \
for (i = 0; i < bufferlen; i++, ptr += 6) { \
@@ -332,44 +310,50 @@ CHANNEL_SWIZZLE(SWIZ8)
#undef SWIZ6
#undef SWIZ8
/*
* Called right before feeding this->hidden->mixbuf to the hardware. Swizzle
* channels from Windows/Mac order to the format alsalib will want.
*/
static void
swizzle_alsa_channels(_THIS, void *buffer, Uint32 bufferlen)
static void swizzle_alsa_channels(_THIS, void *buffer, Uint32 bufferlen)
{
switch (this->spec.channels) {
#define CHANSWIZ(chans) \
case chans: \
switch ((this->spec.format & (0xFF))) { \
case 8: swizzle_alsa_channels_##chans##_Uint8(buffer, bufferlen); break; \
case 16: swizzle_alsa_channels_##chans##_Uint16(buffer, bufferlen); break; \
case 32: swizzle_alsa_channels_##chans##_Uint32(buffer, bufferlen); break; \
case 64: swizzle_alsa_channels_##chans##_Uint64(buffer, bufferlen); break; \
default: SDL_assert(!"unhandled bitsize"); break; \
case 8: \
swizzle_alsa_channels_##chans##_Uint8(buffer, bufferlen); \
break; \
case 16: \
swizzle_alsa_channels_##chans##_Uint16(buffer, bufferlen); \
break; \
case 32: \
swizzle_alsa_channels_##chans##_Uint32(buffer, bufferlen); \
break; \
case 64: \
swizzle_alsa_channels_##chans##_Uint64(buffer, bufferlen); \
break; \
default: \
SDL_assert(!"unhandled bitsize"); \
break; \
} \
return;
CHANSWIZ(6);
CHANSWIZ(8);
#undef CHANSWIZ
default: break;
default:
break;
}
}
#ifdef SND_CHMAP_API_VERSION
/* Some devices have the right channel map, no swizzling necessary */
static void
no_swizzle(_THIS, void *buffer, Uint32 bufferlen)
static void no_swizzle(_THIS, void *buffer, Uint32 bufferlen)
{
}
#endif /* SND_CHMAP_API_VERSION */
static void
ALSA_PlayDevice(_THIS)
static void ALSA_PlayDevice(_THIS)
{
const Uint8 *sample_buf = (const Uint8 *)this->hidden->mixbuf;
const int frame_size = ((SDL_AUDIO_BITSIZE(this->spec.format)) / 8) *
@@ -410,14 +394,12 @@ ALSA_PlayDevice(_THIS)
}
}
static Uint8 *
ALSA_GetDeviceBuf(_THIS)
static Uint8 *ALSA_GetDeviceBuf(_THIS)
{
return this->hidden->mixbuf;
}
static int
ALSA_CaptureFromDevice(_THIS, void *buffer, int buflen)
static int ALSA_CaptureFromDevice(_THIS, void *buffer, int buflen)
{
Uint8 *sample_buf = (Uint8 *)buffer;
const int frame_size = ((SDL_AUDIO_BITSIZE(this->spec.format)) / 8) *
@@ -459,14 +441,12 @@ ALSA_CaptureFromDevice(_THIS, void *buffer, int buflen)
return (total_frames - frames_left) * frame_size;
}
static void
ALSA_FlushCapture(_THIS)
static void ALSA_FlushCapture(_THIS)
{
ALSA_snd_pcm_reset(this->hidden->pcm_handle);
}
static void
ALSA_CloseDevice(_THIS)
static void ALSA_CloseDevice(_THIS)
{
if (this->hidden->pcm_handle) {
/* Wait for the submitted audio to drain
@@ -481,8 +461,7 @@ ALSA_CloseDevice(_THIS)
SDL_free(this->hidden);
}
static int
ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params)
static int ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params)
{
int status;
snd_pcm_hw_params_t *hwparams;
@@ -537,8 +516,7 @@ ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params)
return 0;
}
static int
ALSA_OpenDevice(_THIS, const char *devname)
static int ALSA_OpenDevice(_THIS, const char *devname)
{
int status = 0;
SDL_bool iscapture = this->iscapture;
@@ -728,8 +706,7 @@ typedef struct ALSA_Device
struct ALSA_Device *next;
} ALSA_Device;
static void
add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSeen)
static void add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSeen)
{
ALSA_Device *dev = SDL_malloc(sizeof(ALSA_Device));
char *desc;
@@ -788,11 +765,9 @@ add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSee
*pSeen = dev;
}
static ALSA_Device *hotplug_devices = NULL;
static void
ALSA_HotplugIteration(void)
static void ALSA_HotplugIteration(void)
{
void **hints = NULL;
ALSA_Device *dev;
@@ -925,8 +900,7 @@ ALSA_HotplugIteration(void)
static SDL_atomic_t ALSA_hotplug_shutdown;
static SDL_Thread *ALSA_hotplug_thread;
static int SDLCALL
ALSA_HotplugThread(void *arg)
static int SDLCALL ALSA_HotplugThread(void *arg)
{
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW);
@@ -944,8 +918,7 @@ ALSA_HotplugThread(void *arg)
}
#endif
static void
ALSA_DetectDevices(void)
static void ALSA_DetectDevices(void)
{
ALSA_HotplugIteration(); /* run once now before a thread continues to check. */
@@ -956,8 +929,7 @@ ALSA_DetectDevices(void)
#endif
}
static void
ALSA_Deinitialize(void)
static void ALSA_Deinitialize(void)
{
ALSA_Device *dev;
ALSA_Device *next;
@@ -982,8 +954,7 @@ ALSA_Deinitialize(void)
UnloadALSALibrary();
}
static SDL_bool
ALSA_Init(SDL_AudioDriverImpl * impl)
static SDL_bool ALSA_Init(SDL_AudioDriverImpl *impl)
{
if (LoadALSALibrary() < 0) {
return SDL_FALSE;
@@ -1006,7 +977,6 @@ ALSA_Init(SDL_AudioDriverImpl * impl)
return SDL_TRUE; /* this audio target is available. */
}
AudioBootStrap ALSA_bootstrap = {
"alsa", "ALSA PCM audio", ALSA_Init, SDL_FALSE
};

View File

@@ -34,8 +34,7 @@
static SDL_AudioDevice *audioDevice = NULL;
static SDL_AudioDevice *captureDevice = NULL;
static int
ANDROIDAUDIO_OpenDevice(_THIS, const char *devname)
static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname)
{
SDL_AudioFormat test_format;
SDL_bool iscapture = this->iscapture;
@@ -77,32 +76,27 @@ ANDROIDAUDIO_OpenDevice(_THIS, const char *devname)
return 0;
}
static void
ANDROIDAUDIO_PlayDevice(_THIS)
static void ANDROIDAUDIO_PlayDevice(_THIS)
{
Android_JNI_WriteAudioBuffer();
}
static Uint8 *
ANDROIDAUDIO_GetDeviceBuf(_THIS)
static Uint8 *ANDROIDAUDIO_GetDeviceBuf(_THIS)
{
return Android_JNI_GetAudioBuffer();
}
static int
ANDROIDAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
static int ANDROIDAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
{
return Android_JNI_CaptureAudioBuffer(buffer, buflen);
}
static void
ANDROIDAUDIO_FlushCapture(_THIS)
static void ANDROIDAUDIO_FlushCapture(_THIS)
{
Android_JNI_FlushCapturedAudio();
}
static void
ANDROIDAUDIO_CloseDevice(_THIS)
static void ANDROIDAUDIO_CloseDevice(_THIS)
{
/* At this point SDL_CloseAudioDevice via close_audio_device took care of terminating the audio thread
so it's safe to terminate the Java side buffer and AudioTrack
@@ -118,8 +112,7 @@ ANDROIDAUDIO_CloseDevice(_THIS)
SDL_free(this->hidden);
}
static SDL_bool
ANDROIDAUDIO_Init(SDL_AudioDriverImpl * impl)
static SDL_bool ANDROIDAUDIO_Init(SDL_AudioDriverImpl *impl)
{
/* Set the function pointers */
impl->OpenDevice = ANDROIDAUDIO_OpenDevice;
@@ -203,4 +196,3 @@ void ANDROIDAUDIO_PauseDevices(void) {}
#endif /* SDL_AUDIO_DRIVER_ANDROID */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -46,7 +46,6 @@
}
#endif
#if MACOSX_COREAUDIO
static const AudioObjectPropertyAddress devlist_address = {
kAudioHardwarePropertyDevices,
@@ -66,8 +65,7 @@ typedef struct AudioDeviceList
static AudioDeviceList *output_devs = NULL;
static AudioDeviceList *capture_devs = NULL;
static SDL_bool
add_to_internal_dev_list(const int iscapture, AudioDeviceID devId)
static SDL_bool add_to_internal_dev_list(const int iscapture, AudioDeviceID devId)
{
AudioDeviceList *item = (AudioDeviceList *)SDL_malloc(sizeof(AudioDeviceList));
if (item == NULL) {
@@ -85,16 +83,14 @@ add_to_internal_dev_list(const int iscapture, AudioDeviceID devId)
return SDL_TRUE;
}
static void
addToDevList(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data)
static void addToDevList(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data)
{
if (add_to_internal_dev_list(iscapture, devId)) {
SDL_AddAudioDevice(iscapture, name, spec, (void *)((size_t)devId));
}
}
static void
build_device_list(int iscapture, addDevFn addfn, void *addfndata)
static void build_device_list(int iscapture, addDevFn addfn, void *addfndata)
{
OSStatus result = noErr;
UInt32 size = 0;
@@ -182,8 +178,7 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata)
ptr = (char *)SDL_malloc(len + 1);
usable = ((ptr != NULL) &&
(CFStringGetCString
(cfstr, ptr, len + 1, kCFStringEncodingUTF8)));
(CFStringGetCString(cfstr, ptr, len + 1, kCFStringEncodingUTF8)));
CFRelease(cfstr);
@@ -210,8 +205,7 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata)
}
}
static void
free_audio_device_list(AudioDeviceList **list)
static void free_audio_device_list(AudioDeviceList **list)
{
AudioDeviceList *item = *list;
while (item) {
@@ -222,15 +216,13 @@ free_audio_device_list(AudioDeviceList **list)
*list = NULL;
}
static void
COREAUDIO_DetectDevices(void)
static void COREAUDIO_DetectDevices(void)
{
build_device_list(SDL_TRUE, addToDevList, NULL);
build_device_list(SDL_FALSE, addToDevList, NULL);
}
static void
build_device_change_list(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data)
static void build_device_change_list(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data)
{
AudioDeviceList **list = (AudioDeviceList **)data;
AudioDeviceList *item;
@@ -245,8 +237,7 @@ build_device_change_list(const char *name, SDL_AudioSpec *spec, const int iscapt
SDL_AddAudioDevice(iscapture, name, spec, (void *)((size_t)devId));
}
static void
reprocess_device_list(const int iscapture, AudioDeviceList **list)
static void reprocess_device_list(const int iscapture, AudioDeviceList **list)
{
AudioDeviceList *item;
AudioDeviceList *prev = NULL;
@@ -276,8 +267,7 @@ reprocess_device_list(const int iscapture, AudioDeviceList **list)
}
/* this is called when the system's list of available audio devices changes. */
static OSStatus
device_list_changed(AudioObjectID systemObj, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data)
static OSStatus device_list_changed(AudioObjectID systemObj, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data)
{
reprocess_device_list(SDL_TRUE, &capture_devs);
reprocess_device_list(SDL_FALSE, &output_devs);
@@ -285,7 +275,6 @@ device_list_changed(AudioObjectID systemObj, UInt32 num_addr, const AudioObjectP
}
#endif
static int open_playback_devices;
static int open_capture_devices;
static int num_open_devices;
@@ -337,9 +326,7 @@ static void interruption_begin(_THIS)
static void interruption_end(_THIS)
{
if (this != NULL && this->hidden != NULL && this->hidden->audioQueue != NULL
&& this->hidden->interrupted
&& AudioQueueStart(this->hidden->audioQueue, NULL) == AVAudioSessionErrorCodeNone) {
if (this != NULL && this->hidden != NULL && this->hidden->audioQueue != NULL && this->hidden->interrupted && AudioQueueStart(this->hidden->audioQueue, NULL) == AVAudioSessionErrorCodeNone) {
this->hidden->interrupted = SDL_FALSE;
}
}
@@ -514,10 +501,8 @@ static BOOL update_audio_session(_THIS, SDL_bool open, SDL_bool allow_playandrec
}
#endif
/* The AudioQueue callback */
static void
outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer)
static void outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer)
{
SDL_AudioDevice *this = (SDL_AudioDevice *)inUserData;
@@ -581,8 +566,7 @@ outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffe
if (len > remaining) {
len = remaining;
}
SDL_memcpy(ptr, (char *)this->hidden->buffer +
this->hidden->bufferOffset, len);
SDL_memcpy(ptr, (char *)this->hidden->buffer + this->hidden->bufferOffset, len);
ptr = ptr + len;
remaining -= len;
this->hidden->bufferOffset += len;
@@ -596,8 +580,7 @@ outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffe
SDL_UnlockMutex(this->mixer_lock);
}
static void
inputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer,
static void inputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer,
const AudioTimeStamp *inStartTime, UInt32 inNumberPacketDescriptions,
const AudioStreamPacketDescription *inPacketDescs)
{
@@ -634,17 +617,14 @@ inputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer
AudioQueueEnqueueBuffer(this->hidden->audioQueue, inBuffer, 0, NULL);
}
#if MACOSX_COREAUDIO
static const AudioObjectPropertyAddress alive_address =
{
static const AudioObjectPropertyAddress alive_address = {
kAudioDevicePropertyDeviceIsAlive,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMain
};
static OSStatus
device_unplugged(AudioObjectID devid, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data)
static OSStatus device_unplugged(AudioObjectID devid, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data)
{
SDL_AudioDevice *this = (SDL_AudioDevice *)data;
SDL_bool dead = SDL_FALSE;
@@ -673,8 +653,7 @@ device_unplugged(AudioObjectID devid, UInt32 num_addr, const AudioObjectProperty
}
/* macOS calls this when the default device changed (if we have a default device open). */
static OSStatus
default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *inUserData)
static OSStatus default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *inUserData)
{
SDL_AudioDevice *this = (SDL_AudioDevice *)inUserData;
#if DEBUG_COREAUDIO
@@ -685,8 +664,7 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
}
#endif
static void
COREAUDIO_CloseDevice(_THIS)
static void COREAUDIO_CloseDevice(_THIS)
{
const SDL_bool iscapture = this->iscapture;
int i;
@@ -748,8 +726,7 @@ COREAUDIO_CloseDevice(_THIS)
}
#if MACOSX_COREAUDIO
static int
prepare_device(_THIS)
static int prepare_device(_THIS)
{
void *handle = this->handle;
SDL_bool iscapture = this->iscapture;
@@ -768,21 +745,18 @@ prepare_device(_THIS)
if (handle == NULL) {
size = sizeof(AudioDeviceID);
addr.mSelector =
((iscapture) ? kAudioHardwarePropertyDefaultInputDevice :
kAudioHardwarePropertyDefaultOutputDevice);
((iscapture) ? kAudioHardwarePropertyDefaultInputDevice : kAudioHardwarePropertyDefaultOutputDevice);
result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
0, NULL, &size, &devid);
CHECK_RESULT("AudioHardwareGetProperty (default device)");
}
addr.mSelector = kAudioDevicePropertyDeviceIsAlive;
addr.mScope = iscapture ? kAudioDevicePropertyScopeInput :
kAudioDevicePropertyScopeOutput;
addr.mScope = iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
size = sizeof(alive);
result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &alive);
CHECK_RESULT
("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)");
CHECK_RESULT("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)");
if (!alive) {
SDL_SetError("CoreAudio: requested device exists, but isn't alive.");
@@ -803,8 +777,7 @@ prepare_device(_THIS)
return 1;
}
static int
assign_device_to_audioqueue(_THIS)
static int assign_device_to_audioqueue(_THIS)
{
const AudioObjectPropertyAddress prop = {
kAudioDevicePropertyDeviceUID,
@@ -824,8 +797,7 @@ assign_device_to_audioqueue(_THIS)
}
#endif
static int
prepare_audioqueue(_THIS)
static int prepare_audioqueue(_THIS)
{
const AudioStreamBasicDescription *strdesc = &this->hidden->strdesc;
const int iscapture = this->iscapture;
@@ -833,7 +805,8 @@ prepare_audioqueue(_THIS)
int i, numAudioBuffers = 2;
AudioChannelLayout layout;
double MINIMUM_AUDIO_BUFFER_TIME_MS;
const double msecs = (this->spec.samples / ((double) this->spec.freq)) * 1000.0;;
const double msecs = (this->spec.samples / ((double)this->spec.freq)) * 1000.0;
;
SDL_assert(CFRunLoopGetCurrent() != NULL);
@@ -948,8 +921,7 @@ prepare_audioqueue(_THIS)
return 1;
}
static int
audioqueue_thread(void *arg)
static int audioqueue_thread(void *arg)
{
SDL_AudioDevice *this = (SDL_AudioDevice *)arg;
int rc;
@@ -1025,8 +997,7 @@ audioqueue_thread(void *arg)
return 0;
}
static int
COREAUDIO_OpenDevice(_THIS, const char *devname)
static int COREAUDIO_OpenDevice(_THIS, const char *devname)
{
AudioStreamBasicDescription *strdesc;
SDL_AudioFormat test_format;
@@ -1151,8 +1122,7 @@ COREAUDIO_OpenDevice(_THIS, const char *devname)
}
#if !MACOSX_COREAUDIO
static int
COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
static int COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
{
AVAudioSession *session = [AVAudioSession sharedInstance];
@@ -1165,8 +1135,7 @@ COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
return 0;
}
#else /* MACOSX_COREAUDIO */
static int
COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
static int COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
{
AudioDeviceID devid;
AudioBufferList *buflist;
@@ -1286,8 +1255,7 @@ COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
}
#endif /* MACOSX_COREAUDIO */
static void
COREAUDIO_Deinitialize(void)
static void COREAUDIO_Deinitialize(void)
{
#if MACOSX_COREAUDIO
AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &devlist_address, device_list_changed, NULL);
@@ -1296,8 +1264,7 @@ COREAUDIO_Deinitialize(void)
#endif
}
static SDL_bool
COREAUDIO_Init(SDL_AudioDriverImpl * impl)
static SDL_bool COREAUDIO_Init(SDL_AudioDriverImpl *impl)
{
/* Set the function pointers */
impl->OpenDevice = COREAUDIO_OpenDevice;

View File

@@ -54,8 +54,7 @@ static fnDirectSoundCaptureEnumerateW pDirectSoundCaptureEnumerateW = NULL;
static const GUID SDL_KSDATAFORMAT_SUBTYPE_PCM = { 0x00000001, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } };
static const GUID SDL_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = { 0x00000003, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } };
static void
DSOUND_Unload(void)
static void DSOUND_Unload(void)
{
pDirectSoundCreate8 = NULL;
pDirectSoundEnumerateW = NULL;
@@ -68,9 +67,7 @@ DSOUND_Unload(void)
}
}
static int
DSOUND_Load(void)
static int DSOUND_Load(void)
{
int loaded = 0;
@@ -81,9 +78,11 @@ DSOUND_Load(void)
SDL_SetError("DirectSound: failed to load DSOUND.DLL");
} else {
/* Now make sure we have DirectX 8 or better... */
#define DSOUNDLOAD(f) { \
#define DSOUNDLOAD(f) \
{ \
p##f = (fn##f)SDL_LoadFunction(DSoundDLL, #f); \
if (!p##f) loaded = 0; \
if (!p##f) \
loaded = 0; \
}
loaded = 1; /* will reset if necessary. */
DSOUNDLOAD(DirectSoundCreate8);
@@ -104,8 +103,7 @@ DSOUND_Load(void)
return loaded;
}
static int
SetDSerror(const char *function, int code)
static int SetDSerror(const char *function, int code)
{
const char *error;
@@ -151,14 +149,12 @@ SetDSerror(const char *function, int code)
return SDL_SetError("%s: %s (0x%x)", function, error, code);
}
static void
DSOUND_FreeDeviceHandle(void *handle)
static void DSOUND_FreeDeviceHandle(void *handle)
{
SDL_free(handle);
}
static int
DSOUND_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
static int DSOUND_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
{
#if HAVE_MMDEVICEAPI_H
if (SupportsIMMDevice) {
@@ -168,8 +164,7 @@ DSOUND_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
return SDL_Unsupported();
}
static BOOL CALLBACK
FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data)
static BOOL CALLBACK FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data)
{
const int iscapture = (int)((size_t)data);
if (guid != NULL) { /* skip default device */
@@ -189,8 +184,7 @@ FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data)
return TRUE; /* keep enumerating. */
}
static void
DSOUND_DetectDevices(void)
static void DSOUND_DetectDevices(void)
{
#if HAVE_MMDEVICEAPI_H
if (SupportsIMMDevice) {
@@ -204,9 +198,7 @@ DSOUND_DetectDevices(void)
#endif /* HAVE_MMDEVICEAPI_H*/
}
static void
DSOUND_WaitDevice(_THIS)
static void DSOUND_WaitDevice(_THIS)
{
DWORD status = 0;
DWORD cursor = 0;
@@ -263,8 +255,7 @@ DSOUND_WaitDevice(_THIS)
}
}
static void
DSOUND_PlayDevice(_THIS)
static void DSOUND_PlayDevice(_THIS)
{
/* Unlock the buffer, allowing it to play */
if (this->hidden->locked_buf) {
@@ -274,8 +265,7 @@ DSOUND_PlayDevice(_THIS)
}
}
static Uint8 *
DSOUND_GetDeviceBuf(_THIS)
static Uint8 *DSOUND_GetDeviceBuf(_THIS)
{
DWORD cursor = 0;
DWORD junk = 0;
@@ -322,8 +312,7 @@ DSOUND_GetDeviceBuf(_THIS)
IDirectSoundBuffer_Restore(this->hidden->mixbuf);
result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor,
this->spec.size,
(LPVOID *) & this->
hidden->locked_buf, &rawlen, NULL,
(LPVOID *)&this->hidden->locked_buf, &rawlen, NULL,
&junk, 0);
}
if (result != DS_OK) {
@@ -333,8 +322,7 @@ DSOUND_GetDeviceBuf(_THIS)
return this->hidden->locked_buf;
}
static int
DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen)
static int DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen)
{
struct SDL_PrivateAudioData *h = this->hidden;
DWORD junk, cursor, ptr1len, ptr2len;
@@ -377,8 +365,7 @@ DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen)
return ptr1len;
}
static void
DSOUND_FlushCapture(_THIS)
static void DSOUND_FlushCapture(_THIS)
{
struct SDL_PrivateAudioData *h = this->hidden;
DWORD junk, cursor;
@@ -387,8 +374,7 @@ DSOUND_FlushCapture(_THIS)
}
}
static void
DSOUND_CloseDevice(_THIS)
static void DSOUND_CloseDevice(_THIS)
{
if (this->hidden->mixbuf != NULL) {
IDirectSoundBuffer_Stop(this->hidden->mixbuf);
@@ -411,8 +397,7 @@ DSOUND_CloseDevice(_THIS)
number of audio chunks available in the created buffer. This is for
playback devices, not capture.
*/
static int
CreateSecondary(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt)
static int CreateSecondary(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt)
{
LPDIRECTSOUND sndObj = this->hidden->sound;
LPDIRECTSOUNDBUFFER *sndbuf = &this->hidden->mixbuf;
@@ -454,8 +439,7 @@ CreateSecondary(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt)
number of audio chunks available in the created buffer. This is for
capture devices, not playback.
*/
static int
CreateCaptureBuffer(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt)
static int CreateCaptureBuffer(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt)
{
LPDIRECTSOUNDCAPTURE capture = this->hidden->capture;
LPDIRECTSOUNDCAPTUREBUFFER *capturebuf = &this->hidden->capturebuf;
@@ -494,8 +478,7 @@ CreateCaptureBuffer(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt)
return 0;
}
static int
DSOUND_OpenDevice(_THIS, const char *devname)
static int DSOUND_OpenDevice(_THIS, const char *devname)
{
const DWORD numchunks = 8;
HRESULT result;
@@ -565,8 +548,7 @@ DSOUND_OpenDevice(_THIS, const char *devname)
}
wfmt.Samples.wValidBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
switch (this->spec.channels)
{
switch (this->spec.channels) {
case 3: /* 3.0 (or 2.1) */
wfmt.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER;
break;
@@ -626,9 +608,7 @@ DSOUND_OpenDevice(_THIS, const char *devname)
return 0; /* good to go. */
}
static void
DSOUND_Deinitialize(void)
static void DSOUND_Deinitialize(void)
{
#if HAVE_MMDEVICEAPI_H
if (SupportsIMMDevice) {
@@ -639,9 +619,7 @@ DSOUND_Deinitialize(void)
DSOUND_Unload();
}
static SDL_bool
DSOUND_Init(SDL_AudioDriverImpl * impl)
static SDL_bool DSOUND_Init(SDL_AudioDriverImpl *impl)
{
if (!DSOUND_Load()) {
return SDL_FALSE;

View File

@@ -40,14 +40,12 @@
#define DISKENVR_IODELAY "SDL_DISKAUDIODELAY"
/* This function waits until it is possible to write a full sound buffer */
static void
DISKAUDIO_WaitDevice(_THIS)
static void DISKAUDIO_WaitDevice(_THIS)
{
SDL_Delay(_this->hidden->io_delay);
}
static void
DISKAUDIO_PlayDevice(_THIS)
static void DISKAUDIO_PlayDevice(_THIS)
{
const size_t written = SDL_RWwrite(_this->hidden->io,
_this->hidden->mixbuf,
@@ -62,14 +60,12 @@ DISKAUDIO_PlayDevice(_THIS)
#endif
}
static Uint8 *
DISKAUDIO_GetDeviceBuf(_THIS)
static Uint8 *DISKAUDIO_GetDeviceBuf(_THIS)
{
return _this->hidden->mixbuf;
}
static int
DISKAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
static int DISKAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
{
struct SDL_PrivateAudioData *h = _this->hidden;
const int origbuflen = buflen;
@@ -92,15 +88,12 @@ DISKAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
return origbuflen;
}
static void
DISKAUDIO_FlushCapture(_THIS)
static void DISKAUDIO_FlushCapture(_THIS)
{
/* no op...we don't advance the file pointer or anything. */
}
static void
DISKAUDIO_CloseDevice(_THIS)
static void DISKAUDIO_CloseDevice(_THIS)
{
if (_this->hidden->io != NULL) {
SDL_RWclose(_this->hidden->io);
@@ -109,9 +102,7 @@ DISKAUDIO_CloseDevice(_THIS)
SDL_free(_this->hidden);
}
static const char *
get_filename(const SDL_bool iscapture, const char *devname)
static const char *get_filename(const SDL_bool iscapture, const char *devname)
{
if (devname == NULL) {
devname = SDL_getenv(iscapture ? DISKENVR_INFILE : DISKENVR_OUTFILE);
@@ -122,8 +113,7 @@ get_filename(const SDL_bool iscapture, const char *devname)
return devname;
}
static int
DISKAUDIO_OpenDevice(_THIS, const char *devname)
static int DISKAUDIO_OpenDevice(_THIS, const char *devname)
{
void *handle = _this->handle;
/* handle != NULL means "user specified the placeholder name on the fake detected device list" */
@@ -169,15 +159,13 @@ DISKAUDIO_OpenDevice(_THIS, const char *devname)
return 0;
}
static void
DISKAUDIO_DetectDevices(void)
static void DISKAUDIO_DetectDevices(void)
{
SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *)0x1);
SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *)0x2);
}
static SDL_bool
DISKAUDIO_Init(SDL_AudioDriverImpl * impl)
static SDL_bool DISKAUDIO_Init(SDL_AudioDriverImpl *impl)
{
/* Set the function pointers */
impl->OpenDevice = DISKAUDIO_OpenDevice;

View File

@@ -40,16 +40,12 @@
#include "../SDL_audiodev_c.h"
#include "SDL_dspaudio.h"
static void
DSP_DetectDevices(void)
static void DSP_DetectDevices(void)
{
SDL_EnumUnixAudioDevices(0, NULL);
}
static void
DSP_CloseDevice(_THIS)
static void DSP_CloseDevice(_THIS)
{
if (this->hidden->audio_fd >= 0) {
close(this->hidden->audio_fd);
@@ -58,9 +54,7 @@ DSP_CloseDevice(_THIS)
SDL_free(this->hidden);
}
static int
DSP_OpenDevice(_THIS, const char *devname)
static int DSP_OpenDevice(_THIS, const char *devname)
{
SDL_bool iscapture = this->iscapture;
const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
@@ -203,7 +197,8 @@ DSP_OpenDevice(_THIS, const char *devname)
SDL_CalculateAudioSpec(&this->spec);
/* Determine the power of two of the fragment size */
for (frag_spec = 0; (0x01U << frag_spec) < this->spec.size; ++frag_spec);
for (frag_spec = 0; (0x01U << frag_spec) < this->spec.size; ++frag_spec)
;
if ((0x01U << frag_spec) != this->spec.size) {
return SDL_SetError("Fragment size must be a power of two");
}
@@ -242,9 +237,7 @@ DSP_OpenDevice(_THIS, const char *devname)
return 0;
}
static void
DSP_PlayDevice(_THIS)
static void DSP_PlayDevice(_THIS)
{
struct SDL_PrivateAudioData *h = this->hidden;
if (write(h->audio_fd, h->mixbuf, h->mixlen) == -1) {
@@ -256,20 +249,17 @@ DSP_PlayDevice(_THIS)
#endif
}
static Uint8 *
DSP_GetDeviceBuf(_THIS)
static Uint8 *DSP_GetDeviceBuf(_THIS)
{
return this->hidden->mixbuf;
}
static int
DSP_CaptureFromDevice(_THIS, void *buffer, int buflen)
static int DSP_CaptureFromDevice(_THIS, void *buffer, int buflen)
{
return (int)read(this->hidden->audio_fd, buffer, buflen);
}
static void
DSP_FlushCapture(_THIS)
static void DSP_FlushCapture(_THIS)
{
struct SDL_PrivateAudioData *h = this->hidden;
audio_buf_info info;
@@ -287,16 +277,14 @@ DSP_FlushCapture(_THIS)
}
static SDL_bool InitTimeDevicesExist = SDL_FALSE;
static int
look_for_devices_test(int fd)
static int look_for_devices_test(int fd)
{
InitTimeDevicesExist = SDL_TRUE; /* note that _something_ exists. */
/* Don't add to the device list, we're just seeing if any devices exist. */
return 0;
}
static SDL_bool
DSP_Init(SDL_AudioDriverImpl * impl)
static SDL_bool DSP_Init(SDL_AudioDriverImpl *impl)
{
InitTimeDevicesExist = SDL_FALSE;
SDL_EnumUnixAudioDevices(0, look_for_devices_test);
@@ -320,7 +308,6 @@ DSP_Init(SDL_AudioDriverImpl * impl)
return SDL_TRUE; /* this audio target is available. */
}
AudioBootStrap DSP_bootstrap = {
"dsp", "OSS /dev/dsp standard audio", DSP_Init, SDL_FALSE
};

View File

@@ -25,15 +25,14 @@
#include "../SDL_audio_c.h"
#include "SDL_dummyaudio.h"
static int
DUMMYAUDIO_OpenDevice(_THIS, const char *devname)
static int DUMMYAUDIO_OpenDevice(_THIS, const char *devname)
{
_this->hidden = (void *)0x1; /* just something non-NULL */
return 0; /* always succeeds. */
}
static int
DUMMYAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
static int DUMMYAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
{
/* Delay to make this sort of simulate real audio input. */
SDL_Delay((_this->spec.samples * 1000) / _this->spec.freq);
@@ -43,8 +42,7 @@ DUMMYAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
return buflen;
}
static SDL_bool
DUMMYAUDIO_Init(SDL_AudioDriverImpl * impl)
static SDL_bool DUMMYAUDIO_Init(SDL_AudioDriverImpl *impl)
{
/* Set the function pointers */
impl->OpenDevice = DUMMYAUDIO_OpenDevice;

View File

@@ -32,10 +32,10 @@
!!! FIXME: true always once pthread support becomes widespread. Revisit this code
!!! FIXME: at some point and see what needs to be done for that! */
static void
FeedAudioDevice(_THIS, const void *buf, const int buflen)
static void FeedAudioDevice(_THIS, const void *buf, const int buflen)
{
const int framelen = (SDL_AUDIO_BITSIZE(this->spec.format) / 8) * this->spec.channels;
/* *INDENT-OFF* */ /* clang-format off */
MAIN_THREAD_EM_ASM({
var SDL3 = Module['SDL3'];
var numChannels = SDL3.audio.currentOutputBuffer['numberOfChannels'];
@@ -50,10 +50,10 @@ FeedAudioDevice(_THIS, const void *buf, const int buflen)
}
}
}, buf, buflen / framelen);
/* *INDENT-ON* */ /* clang-format on */
}
static void
HandleAudioProcess(_THIS)
static void HandleAudioProcess(_THIS)
{
SDL_AudioCallback callback = this->callbackspec.callback;
const int stream_len = this->callbackspec.size;
@@ -93,8 +93,7 @@ HandleAudioProcess(_THIS)
FeedAudioDevice(this, this->work_buffer, this->spec.size);
}
static void
HandleCaptureProcess(_THIS)
static void HandleCaptureProcess(_THIS)
{
SDL_AudioCallback callback = this->callbackspec.callback;
const int stream_len = this->callbackspec.size;
@@ -105,6 +104,7 @@ HandleCaptureProcess(_THIS)
return;
}
/* *INDENT-OFF* */ /* clang-format off */
MAIN_THREAD_EM_ASM({
var SDL3 = Module['SDL3'];
var numChannels = SDL3.capture.currentCaptureBuffer.numberOfChannels;
@@ -125,6 +125,7 @@ HandleCaptureProcess(_THIS)
}
}
}, this->work_buffer, (this->spec.size / sizeof (float)) / this->spec.channels);
/* *INDENT-ON* */ /* clang-format on */
/* okay, we've got an interleaved float32 array in C now. */
@@ -147,10 +148,9 @@ HandleCaptureProcess(_THIS)
}
}
static void
EMSCRIPTENAUDIO_CloseDevice(_THIS)
static void EMSCRIPTENAUDIO_CloseDevice(_THIS)
{
/* *INDENT-OFF* */ /* clang-format off */
MAIN_THREAD_EM_ASM({
var SDL3 = Module['SDL3'];
if ($0) {
@@ -189,14 +189,14 @@ EMSCRIPTENAUDIO_CloseDevice(_THIS)
SDL3.audioContext = undefined;
}
}, this->iscapture);
/* *INDENT-ON* */ /* clang-format on */
#if 0 /* !!! FIXME: currently not used. Can we move some stuff off the SDL3 namespace? --ryan. */
SDL_free(this->hidden);
#endif
}
static int
EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
{
SDL_AudioFormat test_format;
SDL_bool iscapture = this->iscapture;
@@ -204,6 +204,7 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
/* based on parts of library_sdl.js */
/* *INDENT-OFF* */ /* clang-format off */
/* create context */
result = MAIN_THREAD_EM_ASM_INT({
if (typeof(Module['SDL3']) === 'undefined') {
@@ -228,6 +229,8 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
}
return SDL3.audioContext === undefined ? -1 : 0;
}, iscapture);
/* *INDENT-ON* */ /* clang-format on */
if (result < 0) {
return SDL_SetError("Web Audio API is not available!");
}
@@ -267,6 +270,7 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
SDL_CalculateAudioSpec(&this->spec);
/* *INDENT-OFF* */ /* clang-format off */
if (iscapture) {
/* The idea is to take the capture media stream, hook it up to an
audio graph where we can pass it through a ScriptProcessorNode
@@ -338,17 +342,16 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
SDL3.audio.scriptProcessorNode['connect'](SDL3.audioContext['destination']);
}, this->spec.channels, this->spec.samples, HandleAudioProcess, this);
}
/* *INDENT-ON* */ /* clang-format on */
return 0;
}
static void
EMSCRIPTENAUDIO_LockOrUnlockDeviceWithNoMixerLock(SDL_AudioDevice * device)
static void EMSCRIPTENAUDIO_LockOrUnlockDeviceWithNoMixerLock(SDL_AudioDevice *device)
{
}
static SDL_bool
EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl * impl)
static SDL_bool EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl *impl)
{
SDL_bool available, capture_available;
@@ -362,6 +365,7 @@ EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl * impl)
impl->LockDevice = impl->UnlockDevice = EMSCRIPTENAUDIO_LockOrUnlockDeviceWithNoMixerLock;
impl->ProvidesOwnCallbackThread = SDL_TRUE;
/* *INDENT-OFF* */ /* clang-format off */
/* check availability */
available = MAIN_THREAD_EM_ASM_INT({
if (typeof(AudioContext) !== 'undefined') {
@@ -371,11 +375,13 @@ EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl * impl)
}
return false;
});
/* *INDENT-ON* */ /* clang-format on */
if (!available) {
SDL_SetError("No audio context available");
}
/* *INDENT-OFF* */ /* clang-format off */
capture_available = available && MAIN_THREAD_EM_ASM_INT({
if ((typeof(navigator.mediaDevices) !== 'undefined') && (typeof(navigator.mediaDevices.getUserMedia) !== 'undefined')) {
return true;
@@ -384,6 +390,7 @@ EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl * impl)
}
return false;
});
/* *INDENT-ON* */ /* clang-format on */
impl->HasCaptureSupport = capture_available ? SDL_TRUE : SDL_FALSE;
impl->OnlyHasDefaultCaptureDevice = capture_available ? SDL_TRUE : SDL_FALSE;

View File

@@ -41,8 +41,7 @@ extern "C"
/* !!! FIXME: have the callback call the higher level to avoid code dupe. */
/* The Haiku callback for handling the audio buffer */
static void
FillSound(void *device, void *stream, size_t len,
static void FillSound(void *device, void *stream, size_t len,
const media_raw_audio_format & format)
{
SDL_AudioDevice *audio = (SDL_AudioDevice *) device;
@@ -84,8 +83,7 @@ FillSound(void *device, void *stream, size_t len,
SDL_UnlockMutex(audio->mixer_lock);
}
static void
HAIKUAUDIO_CloseDevice(_THIS)
static void HAIKUAUDIO_CloseDevice(_THIS)
{
if (_this->hidden->audio_obj) {
_this->hidden->audio_obj->Stop();
@@ -99,8 +97,7 @@ static const int sig_list[] = {
SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGWINCH, 0
};
static inline void
MaskSignals(sigset_t * omask)
static inline void MaskSignals(sigset_t * omask)
{
sigset_t mask;
int i;
@@ -112,15 +109,13 @@ MaskSignals(sigset_t * omask)
sigprocmask(SIG_BLOCK, &mask, omask);
}
static inline void
UnmaskSignals(sigset_t * omask)
static inline void UnmaskSignals(sigset_t * omask)
{
sigprocmask(SIG_SETMASK, omask, NULL);
}
static int
HAIKUAUDIO_OpenDevice(_THIS, const char *devname)
static int HAIKUAUDIO_OpenDevice(_THIS, const char *devname)
{
media_raw_audio_format format;
SDL_AudioFormat test_format;
@@ -207,14 +202,12 @@ HAIKUAUDIO_OpenDevice(_THIS, const char *devname)
return 0;
}
static void
HAIKUAUDIO_Deinitialize(void)
static void HAIKUAUDIO_Deinitialize(void)
{
SDL_QuitBeApp();
}
static SDL_bool
HAIKUAUDIO_Init(SDL_AudioDriverImpl * impl)
static SDL_bool HAIKUAUDIO_Init(SDL_AudioDriverImpl * impl)
{
/* Initialize the Be Application, if it's not already started */
if (SDL_InitBeApp() < 0) {

View File

@@ -26,7 +26,6 @@
#include "SDL_jackaudio.h"
#include "../../thread/SDL_systhread.h"
static jack_client_t *(*JACK_jack_client_open)(const char *, jack_options_t, jack_status_t *, ...);
static int (*JACK_jack_client_close)(jack_client_t *);
static void (*JACK_jack_on_shutdown)(jack_client_t *, JackShutdownCallback, void *);
@@ -47,15 +46,13 @@ static int (*JACK_jack_set_process_callback) (jack_client_t *, JackProcessCallba
static int load_jack_syms(void);
#ifdef SDL_AUDIO_DRIVER_JACK_DYNAMIC
static const char *jack_library = SDL_AUDIO_DRIVER_JACK_DYNAMIC;
static void *jack_handle = NULL;
/* !!! FIXME: this is copy/pasted in several places now */
static int
load_jack_sym(const char *fn, void **addr)
static int load_jack_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(jack_handle, fn);
if (*addr == NULL) {
@@ -68,10 +65,10 @@ load_jack_sym(const char *fn, void **addr)
/* cast funcs to char* first, to please GCC's strict aliasing rules. */
#define SDL_JACK_SYM(x) \
if (!load_jack_sym(#x, (void **) (char *) &JACK_##x)) return -1
if (!load_jack_sym(#x, (void **)(char *)&JACK_##x)) \
return -1
static void
UnloadJackLibrary(void)
static void UnloadJackLibrary(void)
{
if (jack_handle != NULL) {
SDL_UnloadObject(jack_handle);
@@ -79,8 +76,7 @@ UnloadJackLibrary(void)
}
}
static int
LoadJackLibrary(void)
static int LoadJackLibrary(void)
{
int retval = 0;
if (jack_handle == NULL) {
@@ -102,13 +98,11 @@ LoadJackLibrary(void)
#define SDL_JACK_SYM(x) JACK_##x = x
static void
UnloadJackLibrary(void)
static void UnloadJackLibrary(void)
{
}
static int
LoadJackLibrary(void)
static int LoadJackLibrary(void)
{
load_jack_syms();
return 0;
@@ -116,9 +110,7 @@ LoadJackLibrary(void)
#endif /* SDL_AUDIO_DRIVER_JACK_DYNAMIC */
static int
load_jack_syms(void)
static int load_jack_syms(void)
{
SDL_JACK_SYM(jack_client_open);
SDL_JACK_SYM(jack_client_close);
@@ -140,9 +132,7 @@ load_jack_syms(void)
return 0;
}
static void
jackShutdownCallback(void *arg) /* JACK went away; device is lost. */
static void jackShutdownCallback(void *arg) /* JACK went away; device is lost. */
{
SDL_AudioDevice *this = (SDL_AudioDevice *)arg;
SDL_OpenedAudioDeviceDisconnected(this);
@@ -153,8 +143,7 @@ jackShutdownCallback(void *arg) /* JACK went away; device is lost. */
// typedef int(* JackSampleRateCallback)(jack_nframes_t nframes, void *arg)
// typedef int(* JackBufferSizeCallback)(jack_nframes_t nframes, void *arg)
static int
jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg)
static int jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg)
{
SDL_AudioDevice *this = (SDL_AudioDevice *)arg;
jack_port_t **ports = this->hidden->sdlports;
@@ -180,13 +169,11 @@ jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg)
}
SDL_SemPost(this->hidden->iosem); /* tell SDL thread we're done; refill the buffer. */
return 0; /* success */
return 0;
}
/* This function waits until it is possible to write a full sound buffer */
static void
JACK_WaitDevice(_THIS)
static void JACK_WaitDevice(_THIS)
{
if (SDL_AtomicGet(&this->enabled)) {
if (SDL_SemWait(this->hidden->iosem) == -1) {
@@ -195,15 +182,12 @@ JACK_WaitDevice(_THIS)
}
}
static Uint8 *
JACK_GetDeviceBuf(_THIS)
static Uint8 *JACK_GetDeviceBuf(_THIS)
{
return (Uint8 *)this->hidden->iobuffer;
}
static int
jackProcessCaptureCallback(jack_nframes_t nframes, void *arg)
static int jackProcessCaptureCallback(jack_nframes_t nframes, void *arg)
{
SDL_AudioDevice *this = (SDL_AudioDevice *)arg;
if (SDL_AtomicGet(&this->enabled)) {
@@ -226,11 +210,10 @@ jackProcessCaptureCallback(jack_nframes_t nframes, void *arg)
}
SDL_SemPost(this->hidden->iosem); /* tell SDL thread we're done; new buffer is ready! */
return 0; /* success */
return 0;
}
static int
JACK_CaptureFromDevice(_THIS, void *buffer, int buflen)
static int JACK_CaptureFromDevice(_THIS, void *buffer, int buflen)
{
SDL_assert(buflen == this->spec.size); /* we always fill a full buffer. */
@@ -243,15 +226,12 @@ JACK_CaptureFromDevice(_THIS, void *buffer, int buflen)
return buflen;
}
static void
JACK_FlushCapture(_THIS)
static void JACK_FlushCapture(_THIS)
{
SDL_SemWait(this->hidden->iosem);
}
static void
JACK_CloseDevice(_THIS)
static void JACK_CloseDevice(_THIS)
{
if (this->hidden->client) {
JACK_jack_deactivate(this->hidden->client);
@@ -276,8 +256,7 @@ JACK_CloseDevice(_THIS)
SDL_free(this->hidden);
}
static int
JACK_OpenDevice(_THIS, const char *devname)
static int JACK_OpenDevice(_THIS, const char *devname)
{
/* Note that JACK uses "output" for capture devices (they output audio
data to us) and "input" for playback (we input audio data to them).
@@ -333,7 +312,6 @@ JACK_OpenDevice(_THIS, const char *devname)
return SDL_SetError("No physical JACK ports available");
}
/* !!! FIXME: docs say about buffer size: "This size may change, clients that depend on it must register a bufsize_callback so they will be notified if it does." */
/* Jack pretty much demands what it wants. */
@@ -397,14 +375,12 @@ JACK_OpenDevice(_THIS, const char *devname)
return 0;
}
static void
JACK_Deinitialize(void)
static void JACK_Deinitialize(void)
{
UnloadJackLibrary();
}
static SDL_bool
JACK_Init(SDL_AudioDriverImpl * impl)
static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl)
{
if (LoadJackLibrary() < 0) {
return SDL_FALSE;

View File

@@ -22,7 +22,6 @@
#ifdef SDL_AUDIO_DRIVER_N3DS
/* N3DS Audio driver */
#include "../SDL_sysaudio.h"
@@ -36,32 +35,27 @@ static SDL_AudioDevice *audio_device;
static void FreePrivateData(_THIS);
static int FindAudioFormat(_THIS);
static SDL_INLINE void
contextLock(_THIS)
static SDL_INLINE void contextLock(_THIS)
{
LightLock_Lock(&this->hidden->lock);
}
static SDL_INLINE void
contextUnlock(_THIS)
static SDL_INLINE void contextUnlock(_THIS)
{
LightLock_Unlock(&this->hidden->lock);
}
static void
N3DSAUD_LockAudio(_THIS)
static void N3DSAUD_LockAudio(_THIS)
{
contextLock(this);
}
static void
N3DSAUD_UnlockAudio(_THIS)
static void N3DSAUD_UnlockAudio(_THIS)
{
contextUnlock(this);
}
static void
N3DSAUD_DspHook(DSP_HookType hook)
static void N3DSAUD_DspHook(DSP_HookType hook)
{
if (hook == DSPHOOK_ONCANCEL) {
contextLock(audio_device);
@@ -72,8 +66,7 @@ N3DSAUD_DspHook(DSP_HookType hook)
}
}
static void
AudioFrameFinished(void *device)
static void AudioFrameFinished(void *device)
{
bool shouldBroadcast = false;
unsigned i;
@@ -95,8 +88,7 @@ AudioFrameFinished(void *device)
contextUnlock(this);
}
static int
N3DSAUDIO_OpenDevice(_THIS, const char *devname)
static int N3DSAUDIO_OpenDevice(_THIS, const char *devname)
{
Result ndsp_init_res;
Uint8 *data_vaddr;
@@ -186,8 +178,7 @@ N3DSAUDIO_OpenDevice(_THIS, const char *devname)
return 0;
}
static int
N3DSAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
static int N3DSAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
{
/* Delay to make this sort of simulate real audio input. */
SDL_Delay((this->spec.samples * 1000) / this->spec.freq);
@@ -197,8 +188,7 @@ N3DSAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
return buflen;
}
static void
N3DSAUDIO_PlayDevice(_THIS)
static void N3DSAUDIO_PlayDevice(_THIS)
{
size_t nextbuf;
size_t sampleLen;
@@ -224,8 +214,7 @@ N3DSAUDIO_PlayDevice(_THIS)
ndspChnWaveBufAdd(0, &this->hidden->waveBuf[nextbuf]);
}
static void
N3DSAUDIO_WaitDevice(_THIS)
static void N3DSAUDIO_WaitDevice(_THIS)
{
contextLock(this);
while (!this->hidden->isCancelled &&
@@ -235,14 +224,12 @@ N3DSAUDIO_WaitDevice(_THIS)
contextUnlock(this);
}
static Uint8 *
N3DSAUDIO_GetDeviceBuf(_THIS)
static Uint8 *N3DSAUDIO_GetDeviceBuf(_THIS)
{
return this->hidden->mixbuf;
}
static void
N3DSAUDIO_CloseDevice(_THIS)
static void N3DSAUDIO_CloseDevice(_THIS)
{
contextLock(this);
@@ -262,8 +249,7 @@ N3DSAUDIO_CloseDevice(_THIS)
FreePrivateData(this);
}
static void
N3DSAUDIO_ThreadInit(_THIS)
static void N3DSAUDIO_ThreadInit(_THIS)
{
s32 current_priority;
svcGetThreadPriority(&current_priority, CUR_THREAD_HANDLE);
@@ -273,8 +259,7 @@ N3DSAUDIO_ThreadInit(_THIS)
svcSetThreadPriority(CUR_THREAD_HANDLE, current_priority);
}
static SDL_bool
N3DSAUDIO_Init(SDL_AudioDriverImpl *impl)
static SDL_bool N3DSAUDIO_Init(SDL_AudioDriverImpl *impl)
{
/* Set the function pointers */
impl->OpenDevice = N3DSAUDIO_OpenDevice;
@@ -304,8 +289,7 @@ AudioBootStrap N3DSAUDIO_bootstrap = {
/**
* Cleans up all allocated memory, safe to call with null pointers
*/
static void
FreePrivateData(_THIS)
static void FreePrivateData(_THIS)
{
if (!this->hidden) {
return;
@@ -324,8 +308,7 @@ FreePrivateData(_THIS)
this->hidden = NULL;
}
static int
FindAudioFormat(_THIS)
static int FindAudioFormat(_THIS)
{
SDL_bool found_valid_format = SDL_FALSE;
Uint16 test_format = SDL_FirstAudioFormat(this->spec.format);

View File

@@ -43,15 +43,12 @@
/* #define DEBUG_AUDIO */
static void
NETBSDAUDIO_DetectDevices(void)
static void NETBSDAUDIO_DetectDevices(void)
{
SDL_EnumUnixAudioDevices(0, NULL);
}
static void
NETBSDAUDIO_Status(_THIS)
static void NETBSDAUDIO_Status(_THIS)
{
#ifdef DEBUG_AUDIO
/* *INDENT-OFF* */ /* clang-format off */
@@ -117,12 +114,11 @@ NETBSDAUDIO_Status(_THIS)
this->spec.format,
this->spec.size);
/* *INDENT-ON* */ /* clang-format on */
#endif /* DEBUG_AUDIO */
}
static void
NETBSDAUDIO_PlayDevice(_THIS)
static void NETBSDAUDIO_PlayDevice(_THIS)
{
struct SDL_PrivateAudioData *h = this->hidden;
int written;
@@ -141,15 +137,12 @@ NETBSDAUDIO_PlayDevice(_THIS)
#endif
}
static Uint8 *
NETBSDAUDIO_GetDeviceBuf(_THIS)
static Uint8 *NETBSDAUDIO_GetDeviceBuf(_THIS)
{
return this->hidden->mixbuf;
}
static int
NETBSDAUDIO_CaptureFromDevice(_THIS, void *_buffer, int buflen)
static int NETBSDAUDIO_CaptureFromDevice(_THIS, void *_buffer, int buflen)
{
Uint8 *buffer = (Uint8 *)_buffer;
int br;
@@ -167,8 +160,7 @@ NETBSDAUDIO_CaptureFromDevice(_THIS, void *_buffer, int buflen)
return 0;
}
static void
NETBSDAUDIO_FlushCapture(_THIS)
static void NETBSDAUDIO_FlushCapture(_THIS)
{
audio_info_t info;
size_t remain;
@@ -189,8 +181,7 @@ NETBSDAUDIO_FlushCapture(_THIS)
}
}
static void
NETBSDAUDIO_CloseDevice(_THIS)
static void NETBSDAUDIO_CloseDevice(_THIS)
{
if (this->hidden->audio_fd >= 0) {
close(this->hidden->audio_fd);
@@ -199,8 +190,7 @@ NETBSDAUDIO_CloseDevice(_THIS)
SDL_free(this->hidden);
}
static int
NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
{
SDL_bool iscapture = this->iscapture;
SDL_AudioFormat test_format;
@@ -239,8 +229,7 @@ NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
* Use the device's native sample rate so the kernel doesn't have to
* resample.
*/
this->spec.freq = iscapture ?
hwinfo.record.sample_rate : hwinfo.play.sample_rate;
this->spec.freq = iscapture ? hwinfo.record.sample_rate : hwinfo.play.sample_rate;
}
#endif
@@ -318,8 +307,7 @@ NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
return 0;
}
static SDL_bool
NETBSDAUDIO_Init(SDL_AudioDriverImpl * impl)
static SDL_bool NETBSDAUDIO_Init(SDL_AudioDriverImpl *impl)
{
/* Set the function pointers */
impl->DetectDevices = NETBSDAUDIO_DetectDevices;
@@ -336,7 +324,6 @@ NETBSDAUDIO_Init(SDL_AudioDriverImpl * impl)
return SDL_TRUE; /* this audio target is available. */
}
AudioBootStrap NETBSDAUDIO_bootstrap = {
"netbsd", "NetBSD audio", NETBSDAUDIO_Init, SDL_FALSE
};

View File

@@ -127,8 +127,7 @@ static void openslES_DestroyEngine(void)
}
}
static int
openslES_CreateEngine(void)
static int openslES_CreateEngine(void)
{
const SLInterfaceID ids[1] = { SL_IID_VOLUME };
const SLboolean req[1] = { SL_BOOLEAN_FALSE };
@@ -182,8 +181,7 @@ error:
}
/* this callback handler is called every time a buffer finishes recording */
static void
bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
static void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
{
struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context;
@@ -191,8 +189,7 @@ bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
SDL_SemPost(audiodata->playsem);
}
static void
openslES_DestroyPCMRecorder(_THIS)
static void openslES_DestroyPCMRecorder(_THIS)
{
struct SDL_PrivateAudioData *audiodata = this->hidden;
SLresult result;
@@ -223,8 +220,7 @@ openslES_DestroyPCMRecorder(_THIS)
}
}
static int
openslES_CreatePCMRecorder(_THIS)
static int openslES_CreatePCMRecorder(_THIS)
{
struct SDL_PrivateAudioData *audiodata = this->hidden;
SLDataFormat_PCM format_pcm;
@@ -362,8 +358,7 @@ failed:
}
/* this callback handler is called every time a buffer finishes playing */
static void
bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
{
struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context;
@@ -371,8 +366,7 @@ bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
SDL_SemPost(audiodata->playsem);
}
static void
openslES_DestroyPCMPlayer(_THIS)
static void openslES_DestroyPCMPlayer(_THIS)
{
struct SDL_PrivateAudioData *audiodata = this->hidden;
SLresult result;
@@ -404,8 +398,7 @@ openslES_DestroyPCMPlayer(_THIS)
}
}
static int
openslES_CreatePCMPlayer(_THIS)
static int openslES_CreatePCMPlayer(_THIS)
{
struct SDL_PrivateAudioData *audiodata = this->hidden;
SLDataLocator_AndroidSimpleBufferQueue loc_bufq;
@@ -465,8 +458,7 @@ openslES_CreatePCMPlayer(_THIS)
format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
}
switch (this->spec.channels)
{
switch (this->spec.channels) {
case 1:
format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT;
break;
@@ -595,8 +587,7 @@ failed:
return -1;
}
static int
openslES_OpenDevice(_THIS, const char *devname)
static int openslES_OpenDevice(_THIS, const char *devname)
{
this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, (sizeof *this->hidden));
if (this->hidden == NULL) {
@@ -624,12 +615,10 @@ openslES_OpenDevice(_THIS, const char *devname)
} else {
return SDL_SetError("Open device failed!");
}
}
}
static void
openslES_WaitDevice(_THIS)
static void openslES_WaitDevice(_THIS)
{
struct SDL_PrivateAudioData *audiodata = this->hidden;
@@ -639,8 +628,7 @@ openslES_WaitDevice(_THIS)
SDL_SemWait(audiodata->playsem);
}
static void
openslES_PlayDevice(_THIS)
static void openslES_PlayDevice(_THIS)
{
struct SDL_PrivateAudioData *audiodata = this->hidden;
SLresult result;
@@ -674,8 +662,7 @@ openslES_PlayDevice(_THIS)
/* */
/* okay.. */
static Uint8 *
openslES_GetDeviceBuf(_THIS)
static Uint8 *openslES_GetDeviceBuf(_THIS)
{
struct SDL_PrivateAudioData *audiodata = this->hidden;
@@ -683,8 +670,7 @@ openslES_GetDeviceBuf(_THIS)
return audiodata->pmixbuff[audiodata->next_buffer];
}
static int
openslES_CaptureFromDevice(_THIS, void *buffer, int buflen)
static int openslES_CaptureFromDevice(_THIS, void *buffer, int buflen)
{
struct SDL_PrivateAudioData *audiodata = this->hidden;
SLresult result;
@@ -711,8 +697,7 @@ openslES_CaptureFromDevice(_THIS, void *buffer, int buflen)
return this->spec.size;
}
static void
openslES_CloseDevice(_THIS)
static void openslES_CloseDevice(_THIS)
{
/* struct SDL_PrivateAudioData *audiodata = this->hidden; */
@@ -727,8 +712,7 @@ openslES_CloseDevice(_THIS)
SDL_free(this->hidden);
}
static SDL_bool
openslES_Init(SDL_AudioDriverImpl * impl)
static SDL_bool openslES_Init(SDL_AudioDriverImpl *impl)
{
LOGI("openslES_Init() called");

View File

@@ -123,8 +123,7 @@ static int pipewire_version_patch;
static const char *pipewire_library = SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC;
static void *pipewire_handle = NULL;
static int
pipewire_dlsym(const char *fn, void **addr)
static int pipewire_dlsym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(pipewire_handle, fn);
if (*addr == NULL) {
@@ -140,8 +139,7 @@ pipewire_dlsym(const char *fn, void **addr)
return -1; \
}
static int
load_pipewire_library()
static int load_pipewire_library()
{
if ((pipewire_handle = SDL_LoadObject(pipewire_library))) {
return 0;
@@ -150,8 +148,7 @@ load_pipewire_library()
return -1;
}
static void
unload_pipewire_library()
static void unload_pipewire_library()
{
if (pipewire_handle) {
SDL_UnloadObject(pipewire_handle);
@@ -163,21 +160,18 @@ unload_pipewire_library()
#define SDL_PIPEWIRE_SYM(x) PIPEWIRE_##x = x
static int
load_pipewire_library()
static int load_pipewire_library()
{
return 0;
}
static void
unload_pipewire_library()
static void unload_pipewire_library()
{ /* Nothing to do */
}
#endif /* SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC */
static int
load_pipewire_syms()
static int load_pipewire_syms()
{
SDL_PIPEWIRE_SYM(pw_get_library_version);
SDL_PIPEWIRE_SYM(pw_init);
@@ -219,8 +213,7 @@ pipewire_version_at_least(int major, int minor, int patch)
(pipewire_version_major > major || pipewire_version_minor > minor || pipewire_version_patch >= patch);
}
static int
init_pipewire_library()
static int init_pipewire_library()
{
if (!load_pipewire_library()) {
if (!load_pipewire_syms()) {
@@ -242,8 +235,7 @@ init_pipewire_library()
return -1;
}
static void
deinit_pipewire_library()
static void deinit_pipewire_library()
{
PIPEWIRE_pw_deinit();
unload_pipewire_library();
@@ -304,8 +296,7 @@ static char *pipewire_default_sink_id = NULL;
static char *pipewire_default_source_id = NULL;
/* The active node list */
static SDL_bool
io_list_check_add(struct io_node *node)
static SDL_bool io_list_check_add(struct io_node *node)
{
struct io_node *n;
SDL_bool ret = SDL_TRUE;
@@ -330,8 +321,7 @@ dup_found:
return ret;
}
static void
io_list_remove(Uint32 id)
static void io_list_remove(Uint32 id)
{
struct io_node *n, *temp;
@@ -351,8 +341,7 @@ io_list_remove(Uint32 id)
}
}
static void
io_list_sort()
static void io_list_sort()
{
struct io_node *default_sink = NULL, *default_source = NULL;
struct io_node *n, *temp;
@@ -377,8 +366,7 @@ io_list_sort()
}
}
static void
io_list_clear()
static void io_list_clear()
{
struct io_node *n, *temp;
@@ -412,8 +400,7 @@ io_list_get_by_path(char *path)
return NULL;
}
static void
node_object_destroy(struct node_object *node)
static void node_object_destroy(struct node_object *node)
{
SDL_assert(node);
@@ -425,15 +412,13 @@ node_object_destroy(struct node_object *node)
}
/* The pending node list */
static void
pending_list_add(struct node_object *node)
static void pending_list_add(struct node_object *node)
{
SDL_assert(node);
spa_list_append(&hotplug_pending_list, &node->link);
}
static void
pending_list_remove(Uint32 id)
static void pending_list_remove(Uint32 id)
{
struct node_object *node, *temp;
@@ -444,8 +429,7 @@ pending_list_remove(Uint32 id)
}
}
static void
pending_list_clear()
static void pending_list_clear()
{
struct node_object *node, *temp;
@@ -454,8 +438,7 @@ pending_list_clear()
}
}
static void *
node_object_new(Uint32 id, const char *type, Uint32 version, const void *funcs, const struct pw_core_events *core_events)
static void *node_object_new(Uint32 id, const char *type, Uint32 version, const void *funcs, const struct pw_core_events *core_events)
{
struct pw_proxy *proxy;
struct node_object *node;
@@ -484,8 +467,7 @@ node_object_new(Uint32 id, const char *type, Uint32 version, const void *funcs,
}
/* Core sync points */
static void
core_events_hotplug_init_callback(void *object, uint32_t id, int seq)
static void core_events_hotplug_init_callback(void *object, uint32_t id, int seq)
{
if (id == PW_ID_CORE && seq == hotplug_init_seq_val) {
/* This core listener is no longer needed. */
@@ -497,8 +479,7 @@ core_events_hotplug_init_callback(void *object, uint32_t id, int seq)
}
}
static void
core_events_interface_callback(void *object, uint32_t id, int seq)
static void core_events_interface_callback(void *object, uint32_t id, int seq)
{
struct node_object *node = object;
struct io_node *io = node->userdata;
@@ -516,8 +497,7 @@ core_events_interface_callback(void *object, uint32_t id, int seq)
}
}
static void
core_events_metadata_callback(void *object, uint32_t id, int seq)
static void core_events_metadata_callback(void *object, uint32_t id, int seq)
{
struct node_object *node = object;
@@ -530,8 +510,7 @@ static const struct pw_core_events hotplug_init_core_events = { PW_VERSION_CORE_
static const struct pw_core_events interface_core_events = { PW_VERSION_CORE_EVENTS, .done = core_events_interface_callback };
static const struct pw_core_events metadata_core_events = { PW_VERSION_CORE_EVENTS, .done = core_events_metadata_callback };
static void
hotplug_core_sync(struct node_object *node)
static void hotplug_core_sync(struct node_object *node)
{
/*
* Node sync events *must* come before the hotplug init sync events or the initial
@@ -547,8 +526,7 @@ hotplug_core_sync(struct node_object *node)
}
/* Helpers for retrieving values from params */
static SDL_bool
get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max)
static SDL_bool get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max)
{
const struct spa_pod_prop *prop;
struct spa_pod *value;
@@ -581,8 +559,7 @@ get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int
return SDL_FALSE;
}
static SDL_bool
get_int_param(const struct spa_pod *param, Uint32 key, int *val)
static SDL_bool get_int_param(const struct spa_pod *param, Uint32 key, int *val)
{
const struct spa_pod_prop *prop;
Sint32 v;
@@ -601,8 +578,7 @@ get_int_param(const struct spa_pod *param, Uint32 key, int *val)
}
/* Interface node callbacks */
static void
node_event_info(void *object, const struct pw_node_info *info)
static void node_event_info(void *object, const struct pw_node_info *info)
{
struct node_object *node = object;
struct io_node *io = node->userdata;
@@ -624,8 +600,7 @@ node_event_info(void *object, const struct pw_node_info *info)
}
}
static void
node_event_param(void *object, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param)
static void node_event_param(void *object, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param)
{
struct node_object *node = object;
struct io_node *io = node->userdata;
@@ -650,8 +625,7 @@ node_event_param(void *object, int seq, uint32_t id, uint32_t index, uint32_t ne
static const struct pw_node_events interface_node_events = { PW_VERSION_NODE_EVENTS, .info = node_event_info,
.param = node_event_param };
static char*
get_name_from_json(const char *json)
static char *get_name_from_json(const char *json)
{
struct spa_json parser[2];
char key[7]; /* "name" */
@@ -673,8 +647,7 @@ get_name_from_json(const char *json)
}
/* Metadata node callback */
static int
metadata_property(void *object, Uint32 subject, const char *key, const char *type, const char *value)
static int metadata_property(void *object, Uint32 subject, const char *key, const char *type, const char *value)
{
struct node_object *node = object;
@@ -700,8 +673,7 @@ metadata_property(void *object, Uint32 subject, const char *key, const char *typ
static const struct pw_metadata_events metadata_node_events = { PW_VERSION_METADATA_EVENTS, .property = metadata_property };
/* Global registry callbacks */
static void
registry_event_global_callback(void *object, uint32_t id, uint32_t permissions, const char *type, uint32_t version,
static void registry_event_global_callback(void *object, uint32_t id, uint32_t permissions, const char *type, uint32_t version,
const struct spa_dict *props)
{
struct node_object *node;
@@ -772,8 +744,7 @@ registry_event_global_callback(void *object, uint32_t id, uint32_t permissions,
}
}
static void
registry_event_remove_callback(void *object, uint32_t id)
static void registry_event_remove_callback(void *object, uint32_t id)
{
io_list_remove(id);
pending_list_remove(id);
@@ -783,8 +754,7 @@ static const struct pw_registry_events registry_events = { PW_VERSION_REGISTRY_E
.global_remove = registry_event_remove_callback };
/* The hotplug thread */
static int
hotplug_loop_init()
static int hotplug_loop_init()
{
int res;
@@ -827,8 +797,7 @@ hotplug_loop_init()
return 0;
}
static void
hotplug_loop_destroy()
static void hotplug_loop_destroy()
{
if (hotplug_loop) {
PIPEWIRE_pw_thread_loop_stop(hotplug_loop);
@@ -870,8 +839,7 @@ hotplug_loop_destroy()
}
}
static void
PIPEWIRE_DetectDevices()
static void PIPEWIRE_DetectDevices()
{
struct io_node *io;
@@ -913,8 +881,7 @@ static const enum spa_audio_channel PIPEWIRE_channel_map_8[] = { SPA_AUDIO_CHANN
#define COPY_CHANNEL_MAP(c) SDL_memcpy(info->position, PIPEWIRE_channel_map_##c, sizeof(PIPEWIRE_channel_map_##c))
static void
initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info_raw *info)
static void initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info_raw *info)
{
info->channels = spec->channels;
info->rate = spec->freq;
@@ -981,8 +948,7 @@ initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info_raw *info)
}
}
static void
output_callback(void *data)
static void output_callback(void *data)
{
struct pw_buffer *pw_buf;
struct spa_buffer *spa_buf;
@@ -1047,8 +1013,7 @@ output_callback(void *data)
PIPEWIRE_pw_stream_queue_buffer(stream, pw_buf);
}
static void
input_callback(void *data)
static void input_callback(void *data)
{
struct pw_buffer *pw_buf;
struct spa_buffer *spa_buf;
@@ -1103,8 +1068,7 @@ input_callback(void *data)
PIPEWIRE_pw_stream_queue_buffer(stream, pw_buf);
}
static void
stream_add_buffer_callback(void *data, struct pw_buffer *buffer)
static void stream_add_buffer_callback(void *data, struct pw_buffer *buffer)
{
_THIS = data;
@@ -1134,8 +1098,7 @@ stream_add_buffer_callback(void *data, struct pw_buffer *buffer)
PIPEWIRE_pw_thread_loop_signal(this->hidden->loop, false);
}
static void
stream_state_changed_callback(void *data, enum pw_stream_state old, enum pw_stream_state state, const char *error)
static void stream_state_changed_callback(void *data, enum pw_stream_state old, enum pw_stream_state state, const char *error)
{
_THIS = data;
@@ -1157,8 +1120,7 @@ static const struct pw_stream_events stream_input_events = { PW_VERSION_STREAM_
.add_buffer = stream_add_buffer_callback,
.process = input_callback };
static int
PIPEWIRE_OpenDevice(_THIS, const char *devname)
static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
{
/*
* NOTE: The PW_STREAM_FLAG_RT_PROCESS flag can be set to call the stream
@@ -1341,8 +1303,7 @@ static void PIPEWIRE_CloseDevice(_THIS)
SDL_free(this->hidden);
}
static int
PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
static int PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
{
struct io_node *node;
char *target;
@@ -1380,8 +1341,7 @@ failed:
return ret;
}
static void
PIPEWIRE_Deinitialize()
static void PIPEWIRE_Deinitialize()
{
if (pipewire_initialized) {
hotplug_loop_destroy();
@@ -1390,8 +1350,7 @@ PIPEWIRE_Deinitialize()
}
}
static SDL_bool
PIPEWIRE_Init(SDL_AudioDriverImpl *impl)
static SDL_bool PIPEWIRE_Init(SDL_AudioDriverImpl *impl)
{
if (!pipewire_initialized) {
if (init_pipewire_library() < 0) {

View File

@@ -33,8 +33,7 @@
/* The tag name used by PS2 audio */
#define PS2AUDIO_DRIVER_NAME "ps2"
static int
PS2AUDIO_OpenDevice(_THIS, const char *devname)
static int PS2AUDIO_OpenDevice(_THIS, const char *devname)
{
int i, mixlen;
struct audsrv_fmt_t format;
@@ -46,7 +45,6 @@ PS2AUDIO_OpenDevice(_THIS, const char *devname)
}
SDL_zerop(this->hidden);
/* These are the native supported audio PS2 configs */
switch (this->spec.freq) {
case 11025:

View File

@@ -38,8 +38,7 @@
/* The tag name used by PSP audio */
#define PSPAUDIO_DRIVER_NAME "psp"
static int
PSPAUDIO_OpenDevice(_THIS, const char *devname)
static int PSPAUDIO_OpenDevice(_THIS, const char *devname)
{
int format, mixlen, i;
@@ -155,8 +154,7 @@ static void PSPAUDIO_ThreadInit(_THIS)
}
}
static SDL_bool
PSPAUDIO_Init(SDL_AudioDriverImpl * impl)
static SDL_bool PSPAUDIO_Init(SDL_AudioDriverImpl *impl)
{
/* Set the function pointers */
impl->OpenDevice = PSPAUDIO_OpenDevice;

View File

@@ -29,7 +29,8 @@
#define NUM_BUFFERS 2
struct SDL_PrivateAudioData {
struct SDL_PrivateAudioData
{
/* The hardware output channel. */
int channel;
/* The raw allocated mixing buffer. */

View File

@@ -45,19 +45,19 @@
/* should we include monitors in the device list? Set at SDL_Init time */
static SDL_bool include_monitors = SDL_FALSE;
#if (PA_API_VERSION < 12)
/** Return non-zero if the passed state is one of the connected states */
static SDL_INLINE int PA_CONTEXT_IS_GOOD(pa_context_state_t x) {
static SDL_INLINE int PA_CONTEXT_IS_GOOD(pa_context_state_t x)
{
return x == PA_CONTEXT_CONNECTING || x == PA_CONTEXT_AUTHORIZING || x == PA_CONTEXT_SETTING_NAME || x == PA_CONTEXT_READY;
}
/** Return non-zero if the passed state is one of the connected states */
static SDL_INLINE int PA_STREAM_IS_GOOD(pa_stream_state_t x) {
static SDL_INLINE int PA_STREAM_IS_GOOD(pa_stream_state_t x)
{
return x == PA_STREAM_CREATING || x == PA_STREAM_READY;
}
#endif /* pulseaudio <= 0.9.10 */
static const char *(*PULSEAUDIO_pa_get_library_version)(void);
static pa_channel_map *(*PULSEAUDIO_pa_channel_map_init_auto)(
pa_channel_map *, unsigned, pa_channel_map_def_t);
@@ -112,14 +112,12 @@ static pa_operation * (*PULSEAUDIO_pa_context_get_server_info)(pa_context *, pa_
static int load_pulseaudio_syms(void);
#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
static const char *pulseaudio_library = SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC;
static void *pulseaudio_handle = NULL;
static int
load_pulseaudio_sym(const char *fn, void **addr)
static int load_pulseaudio_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(pulseaudio_handle, fn);
if (*addr == NULL) {
@@ -132,10 +130,10 @@ load_pulseaudio_sym(const char *fn, void **addr)
/* cast funcs to char* first, to please GCC's strict aliasing rules. */
#define SDL_PULSEAUDIO_SYM(x) \
if (!load_pulseaudio_sym(#x, (void **) (char *) &PULSEAUDIO_##x)) return -1
if (!load_pulseaudio_sym(#x, (void **)(char *)&PULSEAUDIO_##x)) \
return -1
static void
UnloadPulseAudioLibrary(void)
static void UnloadPulseAudioLibrary(void)
{
if (pulseaudio_handle != NULL) {
SDL_UnloadObject(pulseaudio_handle);
@@ -143,8 +141,7 @@ UnloadPulseAudioLibrary(void)
}
}
static int
LoadPulseAudioLibrary(void)
static int LoadPulseAudioLibrary(void)
{
int retval = 0;
if (pulseaudio_handle == NULL) {
@@ -166,13 +163,11 @@ LoadPulseAudioLibrary(void)
#define SDL_PULSEAUDIO_SYM(x) PULSEAUDIO_##x = x
static void
UnloadPulseAudioLibrary(void)
static void UnloadPulseAudioLibrary(void)
{
}
static int
LoadPulseAudioLibrary(void)
static int LoadPulseAudioLibrary(void)
{
load_pulseaudio_syms();
return 0;
@@ -180,9 +175,7 @@ LoadPulseAudioLibrary(void)
#endif /* SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */
static int
load_pulseaudio_syms(void)
static int load_pulseaudio_syms(void)
{
SDL_PULSEAUDIO_SYM(pa_get_library_version);
SDL_PULSEAUDIO_SYM(pa_mainloop_new);
@@ -225,15 +218,13 @@ load_pulseaudio_syms(void)
return 0;
}
static SDL_INLINE int
squashVersion(const int major, const int minor, const int patch)
static SDL_INLINE int squashVersion(const int major, const int minor, const int patch)
{
return ((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF);
}
/* Workaround for older pulse: pa_context_new() must have non-NULL appname */
static const char *
getAppName(void)
static const char *getAppName(void)
{
const char *retval = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME);
if (retval && *retval) {
@@ -257,8 +248,7 @@ getAppName(void)
return retval;
}
static void
WaitForPulseOperation(pa_mainloop *mainloop, pa_operation *o)
static void WaitForPulseOperation(pa_mainloop *mainloop, pa_operation *o)
{
/* This checks for NO errors currently. Either fix that, check results elsewhere, or do things you don't care about. */
if (mainloop && o) {
@@ -270,8 +260,7 @@ WaitForPulseOperation(pa_mainloop *mainloop, pa_operation *o)
}
}
static void
DisconnectFromPulseServer(pa_mainloop *mainloop, pa_context *context)
static void DisconnectFromPulseServer(pa_mainloop *mainloop, pa_context *context)
{
if (context) {
PULSEAUDIO_pa_context_disconnect(context);
@@ -282,8 +271,7 @@ DisconnectFromPulseServer(pa_mainloop *mainloop, pa_context *context)
}
}
static int
ConnectToPulseServer_Internal(pa_mainloop **_mainloop, pa_context **_context)
static int ConnectToPulseServer_Internal(pa_mainloop **_mainloop, pa_context **_context)
{
pa_mainloop *mainloop = NULL;
pa_context *context = NULL;
@@ -334,8 +322,7 @@ ConnectToPulseServer_Internal(pa_mainloop **_mainloop, pa_context **_context)
return 0; /* connected and ready! */
}
static int
ConnectToPulseServer(pa_mainloop **_mainloop, pa_context **_context)
static int ConnectToPulseServer(pa_mainloop **_mainloop, pa_context **_context)
{
const int retval = ConnectToPulseServer_Internal(_mainloop, _context);
if (retval < 0) {
@@ -344,10 +331,8 @@ ConnectToPulseServer(pa_mainloop **_mainloop, pa_context **_context)
return retval;
}
/* This function waits until it is possible to write a full sound buffer */
static void
PULSEAUDIO_WaitDevice(_THIS)
static void PULSEAUDIO_WaitDevice(_THIS)
{
/* this is a no-op; we wait in PULSEAUDIO_PlayDevice now. */
}
@@ -359,8 +344,7 @@ static void WriteCallback(pa_stream *p, size_t nbytes, void *userdata)
h->bytes_requested += nbytes;
}
static void
PULSEAUDIO_PlayDevice(_THIS)
static void PULSEAUDIO_PlayDevice(_THIS)
{
struct SDL_PrivateAudioData *h = this->hidden;
int available = h->mixlen;
@@ -395,15 +379,12 @@ PULSEAUDIO_PlayDevice(_THIS)
/*printf("PULSEAUDIO PLAYDEVICE END! written=%d\n", written);*/
}
static Uint8 *
PULSEAUDIO_GetDeviceBuf(_THIS)
static Uint8 *PULSEAUDIO_GetDeviceBuf(_THIS)
{
return this->hidden->mixbuf;
}
static int
PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
static int PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
{
struct SDL_PrivateAudioData *h = this->hidden;
const void *data = NULL;
@@ -437,7 +418,8 @@ PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
/* a new fragment is available! */
PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes);
SDL_assert(nbytes > 0);
if (data == NULL) { /* NULL==buffer had a hole. Ignore that. */
/* If data == NULL, then the buffer had a hole, ignore that */
if (data == NULL) {
PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */
} else {
/* store this fragment's data, start feeding it to SDL. */
@@ -450,8 +432,7 @@ PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
return -1; /* not enabled? */
}
static void
PULSEAUDIO_FlushCapture(_THIS)
static void PULSEAUDIO_FlushCapture(_THIS)
{
struct SDL_PrivateAudioData *h = this->hidden;
const void *data = NULL;
@@ -481,8 +462,7 @@ PULSEAUDIO_FlushCapture(_THIS)
}
}
static void
PULSEAUDIO_CloseDevice(_THIS)
static void PULSEAUDIO_CloseDevice(_THIS)
{
if (this->hidden->stream) {
if (this->hidden->capturebuf != NULL) {
@@ -498,8 +478,7 @@ PULSEAUDIO_CloseDevice(_THIS)
SDL_free(this->hidden);
}
static void
SinkDeviceNameCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
static void SinkDeviceNameCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
{
if (i) {
char **devname = (char **)data;
@@ -507,8 +486,7 @@ SinkDeviceNameCallback(pa_context *c, const pa_sink_info *i, int is_last, void *
}
}
static void
SourceDeviceNameCallback(pa_context *c, const pa_source_info *i, int is_last, void *data)
static void SourceDeviceNameCallback(pa_context *c, const pa_source_info *i, int is_last, void *data)
{
if (i) {
char **devname = (char **)data;
@@ -516,8 +494,7 @@ SourceDeviceNameCallback(pa_context *c, const pa_source_info *i, int is_last, vo
}
}
static SDL_bool
FindDeviceName(struct SDL_PrivateAudioData *h, const SDL_bool iscapture, void *handle)
static SDL_bool FindDeviceName(struct SDL_PrivateAudioData *h, const SDL_bool iscapture, void *handle)
{
const uint32_t idx = ((uint32_t)((intptr_t)handle)) - 1;
@@ -538,8 +515,7 @@ FindDeviceName(struct SDL_PrivateAudioData *h, const SDL_bool iscapture, void *h
return h->device_name != NULL;
}
static int
PULSEAUDIO_OpenDevice(_THIS, const char *devname)
static int PULSEAUDIO_OpenDevice(_THIS, const char *devname)
{
struct SDL_PrivateAudioData *h = NULL;
SDL_AudioFormat test_format;
@@ -692,8 +668,7 @@ static char *default_source_name = NULL;
/* device handles are device index + 1, cast to void*, so we never pass a NULL. */
static SDL_AudioFormat
PulseFormatToSDLFormat(pa_sample_format_t format)
static SDL_AudioFormat PulseFormatToSDLFormat(pa_sample_format_t format)
{
switch (format) {
case PA_SAMPLE_U8:
@@ -716,8 +691,7 @@ PulseFormatToSDLFormat(pa_sample_format_t format)
}
/* This is called when PulseAudio adds an output ("sink") device. */
static void
SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
static void SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
{
SDL_AudioSpec spec;
SDL_bool add = (SDL_bool)((intptr_t)data);
@@ -745,8 +719,7 @@ SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
}
/* This is called when PulseAudio adds a capture ("source") device. */
static void
SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *data)
static void SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *data)
{
SDL_AudioSpec spec;
SDL_bool add = (SDL_bool)((intptr_t)data);
@@ -776,8 +749,7 @@ SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *da
}
}
static void
ServerInfoCallback(pa_context *c, const pa_server_info *i, void *data)
static void ServerInfoCallback(pa_context *c, const pa_server_info *i, void *data)
{
if (default_sink_path != NULL) {
SDL_free(default_sink_path);
@@ -790,8 +762,7 @@ ServerInfoCallback(pa_context *c, const pa_server_info *i, void *data)
}
/* This is called when PulseAudio has a device connected/removed/changed. */
static void
HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *data)
static void HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *data)
{
const SDL_bool added = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW);
const SDL_bool removed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE);
@@ -820,8 +791,7 @@ HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, voi
}
/* this runs as a thread while the Pulse target is initialized to catch hotplug events. */
static int SDLCALL
HotplugThread(void *data)
static int SDLCALL HotplugThread(void *data)
{
pa_operation *o;
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW);
@@ -832,8 +802,7 @@ HotplugThread(void *data)
return 0;
}
static void
PULSEAUDIO_DetectDevices()
static void PULSEAUDIO_DetectDevices()
{
WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_server_info(hotplug_context, ServerInfoCallback, NULL));
WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_sink_info_list(hotplug_context, SinkInfoCallback, (void *)((intptr_t)SDL_TRUE)));
@@ -843,8 +812,7 @@ PULSEAUDIO_DetectDevices()
hotplug_thread = SDL_CreateThreadInternal(HotplugThread, "PulseHotplug", 256 * 1024, NULL);
}
static int
PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
{
int i;
int numdevices;
@@ -875,8 +843,7 @@ PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
return SDL_SetError("Could not find default PulseAudio device");
}
static void
PULSEAUDIO_Deinitialize(void)
static void PULSEAUDIO_Deinitialize(void)
{
if (hotplug_thread) {
PULSEAUDIO_pa_mainloop_quit(hotplug_mainloop, 0);
@@ -908,8 +875,7 @@ PULSEAUDIO_Deinitialize(void)
UnloadPulseAudioLibrary();
}
static SDL_bool
PULSEAUDIO_Init(SDL_AudioDriverImpl * impl)
static SDL_bool PULSEAUDIO_Init(SDL_AudioDriverImpl *impl)
{
if (LoadPulseAudioLibrary() < 0) {
return SDL_FALSE;

View File

@@ -68,8 +68,7 @@ static void (*SNDIO_sio_initpar)(struct sio_par *);
static const char *sndio_library = SDL_AUDIO_DRIVER_SNDIO_DYNAMIC;
static void *sndio_handle = NULL;
static int
load_sndio_sym(const char *fn, void **addr)
static int load_sndio_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(sndio_handle, fn);
if (*addr == NULL) {
@@ -82,13 +81,13 @@ load_sndio_sym(const char *fn, void **addr)
/* cast funcs to char* first, to please GCC's strict aliasing rules. */
#define SDL_SNDIO_SYM(x) \
if (!load_sndio_sym(#x, (void **) (char *) &SNDIO_##x)) return -1
if (!load_sndio_sym(#x, (void **)(char *)&SNDIO_##x)) \
return -1
#else
#define SDL_SNDIO_SYM(x) SNDIO_##x = x
#endif
static int
load_sndio_syms(void)
static int load_sndio_syms(void)
{
SDL_SNDIO_SYM(sio_open);
SDL_SNDIO_SYM(sio_close);
@@ -110,8 +109,7 @@ load_sndio_syms(void)
#ifdef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC
static void
UnloadSNDIOLibrary(void)
static void UnloadSNDIOLibrary(void)
{
if (sndio_handle != NULL) {
SDL_UnloadObject(sndio_handle);
@@ -119,8 +117,7 @@ UnloadSNDIOLibrary(void)
}
}
static int
LoadSNDIOLibrary(void)
static int LoadSNDIOLibrary(void)
{
int retval = 0;
if (sndio_handle == NULL) {
@@ -140,13 +137,11 @@ LoadSNDIOLibrary(void)
#else
static void
UnloadSNDIOLibrary(void)
static void UnloadSNDIOLibrary(void)
{
}
static int
LoadSNDIOLibrary(void)
static int LoadSNDIOLibrary(void)
{
load_sndio_syms();
return 0;
@@ -154,17 +149,12 @@ LoadSNDIOLibrary(void)
#endif /* SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */
static void
SNDIO_WaitDevice(_THIS)
static void SNDIO_WaitDevice(_THIS)
{
/* no-op; SNDIO_sio_write() blocks if necessary. */
}
static void
SNDIO_PlayDevice(_THIS)
static void SNDIO_PlayDevice(_THIS)
{
const int written = SNDIO_sio_write(this->hidden->dev,
this->hidden->mixbuf,
@@ -179,8 +169,7 @@ SNDIO_PlayDevice(_THIS)
#endif
}
static int
SNDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
static int SNDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
{
size_t r;
int revents;
@@ -189,8 +178,7 @@ SNDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
/* Emulate a blocking read */
r = SNDIO_sio_read(this->hidden->dev, buffer, buflen);
while (r == 0 && !SNDIO_sio_eof(this->hidden->dev)) {
if ((nfds = SNDIO_sio_pollfd(this->hidden->dev, this->hidden->pfd, POLLIN)) <= 0
|| poll(this->hidden->pfd, nfds, INFTIM) < 0) {
if ((nfds = SNDIO_sio_pollfd(this->hidden->dev, this->hidden->pfd, POLLIN)) <= 0 || poll(this->hidden->pfd, nfds, INFTIM) < 0) {
return -1;
}
revents = SNDIO_sio_revents(this->hidden->dev, this->hidden->pfd);
@@ -204,8 +192,7 @@ SNDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
return (int)r;
}
static void
SNDIO_FlushCapture(_THIS)
static void SNDIO_FlushCapture(_THIS)
{
char buf[512];
@@ -214,14 +201,12 @@ SNDIO_FlushCapture(_THIS)
}
}
static Uint8 *
SNDIO_GetDeviceBuf(_THIS)
static Uint8 *SNDIO_GetDeviceBuf(_THIS)
{
return this->hidden->mixbuf;
}
static void
SNDIO_CloseDevice(_THIS)
static void SNDIO_CloseDevice(_THIS)
{
if (this->hidden->pfd != NULL) {
SDL_free(this->hidden->pfd);
@@ -234,8 +219,7 @@ SNDIO_CloseDevice(_THIS)
SDL_free(this->hidden);
}
static int
SNDIO_OpenDevice(_THIS, const char *devname)
static int SNDIO_OpenDevice(_THIS, const char *devname)
{
SDL_AudioFormat test_format;
struct sio_par par;
@@ -339,21 +323,18 @@ SNDIO_OpenDevice(_THIS, const char *devname)
return 0;
}
static void
SNDIO_Deinitialize(void)
static void SNDIO_Deinitialize(void)
{
UnloadSNDIOLibrary();
}
static void
SNDIO_DetectDevices(void)
static void SNDIO_DetectDevices(void)
{
SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *)0x1);
SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *)0x2);
}
static SDL_bool
SNDIO_Init(SDL_AudioDriverImpl * impl)
static SDL_bool SNDIO_Init(SDL_AudioDriverImpl *impl)
{
if (LoadSNDIOLibrary() < 0) {
return SDL_FALSE;

View File

@@ -39,8 +39,7 @@
#define SCE_AUDIO_SAMPLE_ALIGN(s) (((s) + 63) & ~63)
#define SCE_AUDIO_MAX_VOLUME 0x8000
static int
VITAAUD_OpenCaptureDevice(_THIS)
static int VITAAUD_OpenCaptureDevice(_THIS)
{
this->spec.freq = 16000;
this->spec.samples = 512;
@@ -57,8 +56,7 @@ VITAAUD_OpenCaptureDevice(_THIS)
return 0;
}
static int
VITAAUD_OpenDevice(_THIS, const char *devname)
static int VITAAUD_OpenDevice(_THIS, const char *devname)
{
int format, mixlen, i, port = SCE_AUDIO_OUT_PORT_TYPE_MAIN;
int vols[2] = { SCE_AUDIO_MAX_VOLUME, SCE_AUDIO_MAX_VOLUME };
@@ -191,8 +189,7 @@ static void VITAAUD_ThreadInit(_THIS)
}
}
static SDL_bool
VITAAUD_Init(SDL_AudioDriverImpl * impl)
static SDL_bool VITAAUD_Init(SDL_AudioDriverImpl *impl)
{
/* Set the function pointers */
impl->OpenDevice = VITAAUD_OpenDevice;

View File

@@ -29,7 +29,8 @@
#define NUM_BUFFERS 2
struct SDL_PrivateAudioData {
struct SDL_PrivateAudioData
{
/* The hardware input/output port. */
int port;
/* The raw allocated mixing buffer. */

View File

@@ -47,14 +47,12 @@
static const IID SDL_IID_IAudioRenderClient = { 0xf294acfc, 0x3146, 0x4483, { 0xa7, 0xbf, 0xad, 0xdc, 0xa7, 0xc2, 0x60, 0xe2 } };
static const IID SDL_IID_IAudioCaptureClient = { 0xc8adbd64, 0xe71e, 0x48a0, { 0xa4, 0xde, 0x18, 0x5c, 0x39, 0x5c, 0xd3, 0x17 } };
static void
WASAPI_DetectDevices(void)
static void WASAPI_DetectDevices(void)
{
WASAPI_EnumerateEndpoints();
}
static SDL_INLINE SDL_bool
WasapiFailed(_THIS, const HRESULT err)
static SDL_INLINE SDL_bool WasapiFailed(_THIS, const HRESULT err)
{
if (err == S_OK) {
return SDL_FALSE;
@@ -71,8 +69,7 @@ WasapiFailed(_THIS, const HRESULT err)
return SDL_TRUE;
}
static int
UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
{
/* Since WASAPI requires us to handle all audio conversion, and our
device format might have changed, we might have to add/remove/change
@@ -124,11 +121,9 @@ UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
return 0;
}
static void ReleaseWasapiDevice(_THIS);
static SDL_bool
RecoverWasapiDevice(_THIS)
static SDL_bool RecoverWasapiDevice(_THIS)
{
ReleaseWasapiDevice(this); /* dump the lost device's handles. */
@@ -151,8 +146,7 @@ RecoverWasapiDevice(_THIS)
return SDL_TRUE; /* okay, carry on with new device details! */
}
static SDL_bool
RecoverWasapiIfLost(_THIS)
static SDL_bool RecoverWasapiIfLost(_THIS)
{
const int generation = this->hidden->default_device_generation;
SDL_bool lost = this->hidden->device_lost;
@@ -175,8 +169,7 @@ RecoverWasapiIfLost(_THIS)
return lost ? RecoverWasapiDevice(this) : SDL_TRUE;
}
static Uint8 *
WASAPI_GetDeviceBuf(_THIS)
static Uint8 *WASAPI_GetDeviceBuf(_THIS)
{
/* get an endpoint buffer from WASAPI. */
BYTE *buffer = NULL;
@@ -191,8 +184,7 @@ WASAPI_GetDeviceBuf(_THIS)
return (Uint8 *)buffer;
}
static void
WASAPI_PlayDevice(_THIS)
static void WASAPI_PlayDevice(_THIS)
{
if (this->hidden->render != NULL) { /* definitely activated? */
/* WasapiFailed() will mark the device for reacquisition or removal elsewhere. */
@@ -200,8 +192,7 @@ WASAPI_PlayDevice(_THIS)
}
}
static void
WASAPI_WaitDevice(_THIS)
static void WASAPI_WaitDevice(_THIS)
{
while (RecoverWasapiIfLost(this) && this->hidden->client && this->hidden->event) {
DWORD waitResult = WaitForSingleObjectEx(this->hidden->event, 200, FALSE);
@@ -228,8 +219,7 @@ WASAPI_WaitDevice(_THIS)
}
}
static int
WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen)
static int WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen)
{
SDL_AudioStream *stream = this->hidden->capturestream;
const int avail = SDL_AudioStreamAvailable(stream);
@@ -293,8 +283,7 @@ WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen)
return -1; /* unrecoverable error. */
}
static void
WASAPI_FlushCapture(_THIS)
static void WASAPI_FlushCapture(_THIS)
{
BYTE *ptr = NULL;
UINT32 frames = 0;
@@ -318,8 +307,7 @@ WASAPI_FlushCapture(_THIS)
SDL_AudioStreamClear(this->hidden->capturestream);
}
static void
ReleaseWasapiDevice(_THIS)
static void ReleaseWasapiDevice(_THIS)
{
if (this->hidden->client) {
IAudioClient_Stop(this->hidden->client);
@@ -358,20 +346,17 @@ ReleaseWasapiDevice(_THIS)
}
}
static void
WASAPI_CloseDevice(_THIS)
static void WASAPI_CloseDevice(_THIS)
{
WASAPI_UnrefDevice(this);
}
void
WASAPI_RefDevice(_THIS)
void WASAPI_RefDevice(_THIS)
{
SDL_AtomicIncRef(&this->hidden->refcount);
}
void
WASAPI_UnrefDevice(_THIS)
void WASAPI_UnrefDevice(_THIS)
{
if (!SDL_AtomicDecRef(&this->hidden->refcount)) {
return;
@@ -388,8 +373,7 @@ WASAPI_UnrefDevice(_THIS)
}
/* This is called once a device is activated, possibly asynchronously. */
int
WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
{
/* !!! FIXME: we could request an exclusive mode stream, which is lower latency;
!!! it will write into the kernel's audio buffer directly instead of
@@ -539,9 +523,7 @@ WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
return 0; /* good to go. */
}
static int
WASAPI_OpenDevice(_THIS, const char *devname)
static int WASAPI_OpenDevice(_THIS, const char *devname)
{
LPCWSTR devid = (LPCWSTR)this->handle;
@@ -579,26 +561,22 @@ WASAPI_OpenDevice(_THIS, const char *devname)
return 0;
}
static void
WASAPI_ThreadInit(_THIS)
static void WASAPI_ThreadInit(_THIS)
{
WASAPI_PlatformThreadInit(this);
}
static void
WASAPI_ThreadDeinit(_THIS)
static void WASAPI_ThreadDeinit(_THIS)
{
WASAPI_PlatformThreadDeinit(this);
}
static void
WASAPI_Deinitialize(void)
static void WASAPI_Deinitialize(void)
{
WASAPI_PlatformDeinit();
}
static SDL_bool
WASAPI_Init(SDL_AudioDriverImpl * impl)
static SDL_bool WASAPI_Init(SDL_AudioDriverImpl *impl)
{
if (WASAPI_PlatformInit() == -1) {
return SDL_FALSE;

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