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
+6 -5
View File
@@ -16,8 +16,8 @@ AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: All AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: AllDefinitions AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine AlwaysBreakTemplateDeclarations: MultiLine
@@ -35,7 +35,7 @@ BraceWrapping:
AfterUnion: true AfterUnion: true
AfterExternBlock: false AfterExternBlock: false
BeforeElse: false BeforeElse: false
BeforeWhile: true BeforeWhile: false
IndentBraces: false IndentBraces: false
SplitEmptyFunction: true SplitEmptyFunction: true
SplitEmptyRecord: true SplitEmptyRecord: true
@@ -48,7 +48,7 @@ IncludeBlocks: Preserve
# clang-format version 4.0 through 12.0: # clang-format version 4.0 through 12.0:
#SortIncludes: false #SortIncludes: false
# clang-format version 13.0+: # clang-format version 13.0+:
#SortIncludes: Never SortIncludes: Never
# No length limit, in case it breaks macros, you can # No length limit, in case it breaks macros, you can
# disable it with /* clang-format off/on */ comments # disable it with /* clang-format off/on */ comments
@@ -62,7 +62,8 @@ IndentGotoLabels: true
IndentPPDirectives: None IndentPPDirectives: None
IndentExternBlock: NoIndent IndentExternBlock: NoIndent
SpaceAfterCStyleCast: true PointerAlignment: Right
SpaceAfterCStyleCast: false
SpacesInCStyleCastParentheses: false SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false SpacesInConditionalStatement: false
SpacesInContainerLiterals: true SpacesInContainerLiterals: true
+32
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!"
+13 -22
View File
@@ -99,7 +99,6 @@ SDL_NORETURN void SDL_ExitProcess(int exitcode)
#endif #endif
} }
/* The initialized subsystems */ /* The initialized subsystems */
#ifdef SDL_MAIN_NEEDED #ifdef SDL_MAIN_NEEDED
static SDL_bool SDL_MainIsReady = SDL_FALSE; static SDL_bool SDL_MainIsReady = SDL_FALSE;
@@ -110,8 +109,7 @@ static SDL_bool SDL_bInMainQuit = SDL_FALSE;
static Uint8 SDL_SubsystemRefCount[32]; static Uint8 SDL_SubsystemRefCount[32];
/* Private helper to increment a subsystem's ref counter. */ /* Private helper to increment a subsystem's ref counter. */
static void static void SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
{ {
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255)); SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
@@ -121,8 +119,7 @@ SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
} }
/* Private helper to decrement a subsystem's ref counter. */ /* Private helper to decrement a subsystem's ref counter. */
static void static void SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
{ {
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] > 0)) { if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] > 0)) {
@@ -131,8 +128,7 @@ SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
} }
/* Private helper to check if a system needs init. */ /* Private helper to check if a system needs init. */
static SDL_bool static SDL_bool SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
{ {
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255)); SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
@@ -140,8 +136,8 @@ SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
} }
/* Private helper to check if a system needs to be quit. */ /* Private helper to check if a system needs to be quit. */
static SDL_bool static SDL_bool SDL_PrivateShouldQuitSubsystem(Uint32 subsystem)
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) { {
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) { if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) {
return SDL_FALSE; return 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; return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
} }
void void SDL_SetMainReady(void)
SDL_SetMainReady(void)
{ {
SDL_MainIsReady = SDL_TRUE; SDL_MainIsReady = SDL_TRUE;
} }
int int SDL_InitSubSystem(Uint32 flags)
SDL_InitSubSystem(Uint32 flags)
{ {
Uint32 flags_initialized = 0; Uint32 flags_initialized = 0;
@@ -335,14 +329,12 @@ quit_and_error:
return -1; return -1;
} }
int int SDL_Init(Uint32 flags)
SDL_Init(Uint32 flags)
{ {
return SDL_InitSubSystem(flags); return SDL_InitSubSystem(flags);
} }
void void SDL_QuitSubSystem(Uint32 flags)
SDL_QuitSubSystem(Uint32 flags)
{ {
/* Shut down requested initialized subsystems */ /* Shut down requested initialized subsystems */
#if !SDL_SENSOR_DISABLED #if !SDL_SENSOR_DISABLED
@@ -459,8 +451,7 @@ SDL_WasInit(Uint32 flags)
return initialized; return initialized;
} }
void void SDL_Quit(void)
SDL_Quit(void)
{ {
SDL_bInMainQuit = SDL_TRUE; SDL_bInMainQuit = SDL_TRUE;
@@ -494,13 +485,13 @@ SDL_Quit(void)
} }
/* Get the library version number */ /* Get the library version number */
void void SDL_GetVersion(SDL_version *ver)
SDL_GetVersion(SDL_version * ver)
{ {
static SDL_bool check_hint = SDL_TRUE; static SDL_bool check_hint = SDL_TRUE;
static SDL_bool legacy_version = SDL_FALSE; static SDL_bool legacy_version = SDL_FALSE;
if (ver == NULL) { return; if (ver == NULL) {
return;
} }
SDL_VERSION(ver); SDL_VERSION(ver);
+15 -21
View File
@@ -40,8 +40,7 @@
/* The size of the stack buffer to use for rendering assert messages. */ /* The size of the stack buffer to use for rendering assert messages. */
#define SDL_MAX_ASSERT_MESSAGE_STACK 256 #define SDL_MAX_ASSERT_MESSAGE_STACK 256
static SDL_assert_state SDLCALL static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data, void *userdata);
SDL_PromptAssertion(const SDL_assert_data *data, void *userdata);
/* /*
* We keep all triggered assertions in a singly-linked list so we can * 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; static void *assertion_userdata = NULL;
#ifdef __GNUC__ #ifdef __GNUC__
static void static void debug_print(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
debug_print(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
#endif #endif
static void static void debug_print(const char *fmt, ...)
debug_print(const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
@@ -70,7 +67,6 @@ debug_print(const char *fmt, ...)
va_end(ap); va_end(ap);
} }
static void SDL_AddAssertionToReport(SDL_assert_data *data) static void SDL_AddAssertionToReport(SDL_assert_data *data)
{ {
/* (data) is always a static struct defined with the assert macros, so /* (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" #define ENDLINE "\n"
#endif #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, return SDL_snprintf(buf, buf_len,
"Assertion failure at %s (%s:%d), triggered %u %s:" ENDLINE " '%s'", "Assertion failure at %s (%s:%d), triggered %u %s:" ENDLINE " '%s'",
data->function, data->filename, data->linenum, data->function, data->filename, data->linenum,
data->trigger_count, (data->trigger_count == 1) ? "time" : "times", data->trigger_count, (data->trigger_count == 1) ? "time" : "times",
data->condition data->condition);
);
} }
static void SDL_GenerateAssertionReport(void) 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 /* 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 parts of SDL, because we don't want anything calling it without an
extremely good reason. */ extremely good reason. */
@@ -134,7 +129,6 @@ extern void SDL_ExitProcess(int exitcode);
#endif #endif
extern SDL_NORETURN void SDL_ExitProcess(int exitcode); extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
#if defined(__WATCOMC__) #if defined(__WATCOMC__)
static void SDL_AbortAssertion(void); static void SDL_AbortAssertion(void);
#pragma aux SDL_AbortAssertion aborts; #pragma aux SDL_AbortAssertion aborts;
@@ -145,8 +139,7 @@ static SDL_NORETURN void SDL_AbortAssertion(void)
SDL_ExitProcess(42); SDL_ExitProcess(42);
} }
static SDL_assert_state SDLCALL static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
{ {
const char *envr; const char *envr;
SDL_assert_state state = SDL_ASSERTION_ABORT; 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. */ /* This is nasty, but we can't block on a custom UI. */
for (;;) { for (;;) {
SDL_bool okay = SDL_TRUE; SDL_bool okay = SDL_TRUE;
/* *INDENT-OFF* */ /* clang-format off */
char *buf = (char *) EM_ASM_INT({ char *buf = (char *) EM_ASM_INT({
var str = var str =
UTF8ToString($0) + '\n\n' + UTF8ToString($0) + '\n\n' +
@@ -259,12 +253,14 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
} }
return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL); return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL);
}, message); }, message);
/* *INDENT-ON* */ /* clang-format on */
if (SDL_strcmp(buf, "a") == 0) { if (SDL_strcmp(buf, "a") == 0) {
state = SDL_ASSERTION_ABORT; 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) { } else if (SDL_strcmp(buf, "b") == 0) {
state = SDL_ASSERTION_BREAK; */ state = SDL_ASSERTION_BREAK;
#endif
} else if (SDL_strcmp(buf, "r") == 0) { } else if (SDL_strcmp(buf, "r") == 0) {
state = SDL_ASSERTION_RETRY; state = SDL_ASSERTION_RETRY;
} else if (SDL_strcmp(buf, "i") == 0) { } else if (SDL_strcmp(buf, "i") == 0) {
@@ -322,7 +318,6 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
return state; return state;
} }
SDL_assert_state SDL_assert_state
SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file, SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
int line) 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! */ } else if (assertion_running == 3) { /* Abort asserted! */
SDL_ExitProcess(42); SDL_ExitProcess(42);
} else { } 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); state = assertion_handler(data, assertion_userdata);
} }
switch (state) switch (state) {
{
case SDL_ASSERTION_ALWAYS_IGNORE: case SDL_ASSERTION_ALWAYS_IGNORE:
state = SDL_ASSERTION_IGNORE; state = SDL_ASSERTION_IGNORE;
data->always_ignore = 1; data->always_ignore = 1;
@@ -397,7 +392,6 @@ SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
return state; return state;
} }
void SDL_AssertionsQuit(void) void SDL_AssertionsQuit(void)
{ {
#if SDL_ASSERT_LEVEL > 0 #if SDL_ASSERT_LEVEL > 0
+5 -13
View File
@@ -39,8 +39,7 @@ struct SDL_DataQueue
size_t queued_bytes; /* number of bytes of data in the queue. */ size_t queued_bytes; /* number of bytes of data in the queue. */
}; };
static void static void SDL_FreeDataQueueList(SDL_DataQueuePacket *packet)
SDL_FreeDataQueueList(SDL_DataQueuePacket *packet)
{ {
while (packet) { while (packet) {
SDL_DataQueuePacket *next = packet->next; SDL_DataQueuePacket *next = packet->next;
@@ -49,7 +48,6 @@ SDL_FreeDataQueueList(SDL_DataQueuePacket *packet)
} }
} }
/* this all expects that you managed thread safety elsewhere. */ /* this all expects that you managed thread safety elsewhere. */
SDL_DataQueue * SDL_DataQueue *
@@ -82,8 +80,7 @@ SDL_NewDataQueue(const size_t _packetlen, const size_t initialslack)
return queue; return queue;
} }
void void SDL_FreeDataQueue(SDL_DataQueue *queue)
SDL_FreeDataQueue(SDL_DataQueue *queue)
{ {
if (queue) { if (queue) {
SDL_FreeDataQueueList(queue->head); SDL_FreeDataQueueList(queue->head);
@@ -92,8 +89,7 @@ SDL_FreeDataQueue(SDL_DataQueue *queue)
} }
} }
void void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack)
SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack)
{ {
const size_t packet_size = queue ? queue->packet_size : 1; const size_t packet_size = queue ? queue->packet_size : 1;
const size_t slackpackets = (slack + (packet_size - 1)) / packet_size; 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 */ SDL_FreeDataQueueList(packet); /* free extra packets */
} }
static SDL_DataQueuePacket * static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue)
AllocateDataQueuePacket(SDL_DataQueue *queue)
{ {
SDL_DataQueuePacket *packet; SDL_DataQueuePacket *packet;
@@ -168,9 +163,7 @@ AllocateDataQueuePacket(SDL_DataQueue *queue)
return packet; 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; size_t len = _len;
const Uint8 *data = (const Uint8 *)_data; 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: */ /* vi: set ts=4 sw=4 expandtab: */
-1
View File
@@ -52,4 +52,3 @@ void *SDL_ReserveSpaceInDataQueue(SDL_DataQueue *queue, const size_t len);
#endif /* SDL_dataqueue_h_ */ #endif /* SDL_dataqueue_h_ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
+4 -10
View File
@@ -24,8 +24,7 @@
#include "SDL_error_c.h" #include "SDL_error_c.h"
int int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{ {
/* Ignore call if invalid format pointer was passed */ /* Ignore call if invalid format pointer was passed */
if (fmt != NULL) { 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 (SDL_LogGetPriority(SDL_LOG_CATEGORY_ERROR) <= SDL_LOG_PRIORITY_DEBUG) {
/* If we are in debug mode, print out the error message */ /* If we are in debug mode, print out the error message */
SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", error->str); SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", error->str);
@@ -69,15 +67,13 @@ SDL_GetError(void)
return error->error ? error->str : ""; return error->error ? error->str : "";
} }
void void SDL_ClearError(void)
SDL_ClearError(void)
{ {
SDL_GetErrBuf()->error = 0; SDL_GetErrBuf()->error = 0;
} }
/* Very common errors go here */ /* Very common errors go here */
int int SDL_Error(SDL_errorcode code)
SDL_Error(SDL_errorcode code)
{ {
switch (code) { switch (code) {
case SDL_ENOMEM: case SDL_ENOMEM:
@@ -96,8 +92,7 @@ SDL_Error(SDL_errorcode code)
} }
#ifdef TEST_ERROR #ifdef TEST_ERROR
int int main(int argc, char *argv[])
main(int argc, char *argv[])
{ {
char buffer[BUFSIZ + 1]; char buffer[BUFSIZ + 1];
@@ -112,7 +107,6 @@ main(int argc, char *argv[])
} }
#endif #endif
char * char *
SDL_GetErrorMsg(char *errstr, int maxlen) SDL_GetErrorMsg(char *errstr, int maxlen)
{ {
-2
View File
@@ -20,8 +20,6 @@
*/ */
#include "SDL_internal.h" #include "SDL_internal.h"
/* convert the guid to a printable string */ /* convert the guid to a printable string */
void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID) void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID)
{ {
+7 -9
View File
@@ -22,17 +22,18 @@
#include "SDL_hints_c.h" #include "SDL_hints_c.h"
/* Assuming there aren't many hints set and they aren't being queried in /* Assuming there aren't many hints set and they aren't being queried in
critical performance paths, we'll just use linked lists here. critical performance paths, we'll just use linked lists here.
*/ */
typedef struct SDL_HintWatch { typedef struct SDL_HintWatch
{
SDL_HintCallback callback; SDL_HintCallback callback;
void *userdata; void *userdata;
struct SDL_HintWatch *next; struct SDL_HintWatch *next;
} SDL_HintWatch; } SDL_HintWatch;
typedef struct SDL_Hint { typedef struct SDL_Hint
{
char *name; char *name;
char *value; char *value;
SDL_HintPriority priority; SDL_HintPriority priority;
@@ -127,8 +128,7 @@ SDL_ResetHint(const char *name)
return SDL_FALSE; return SDL_FALSE;
} }
void void SDL_ResetHints(void)
SDL_ResetHints(void)
{ {
const char *env; const char *env;
SDL_Hint *hint; SDL_Hint *hint;
@@ -195,8 +195,7 @@ SDL_GetHintBoolean(const char *name, SDL_bool default_value)
return SDL_GetStringBoolean(hint, default_value); return SDL_GetStringBoolean(hint, default_value);
} }
void void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
{ {
SDL_Hint *hint; SDL_Hint *hint;
SDL_HintWatch *entry; SDL_HintWatch *entry;
@@ -257,8 +256,7 @@ SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
callback(userdata, name, value, value); callback(userdata, name, value, value);
} }
void void SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
{ {
SDL_Hint *hint; SDL_Hint *hint;
SDL_HintWatch *entry, *prev; SDL_HintWatch *entry, *prev;
+6 -2
View File
@@ -42,7 +42,12 @@
#define SDL_MAX_SMALL_ALLOC_STACKSIZE 128 #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_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" #include "dynapi/SDL_dynapi.h"
@@ -105,7 +110,6 @@
#include <float.h> #include <float.h>
#endif #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 */ /* If you run into a warning that O_CLOEXEC is redefined, update the SDL configuration header for your platform to add HAVE_O_CLOEXEC */
#ifndef HAVE_O_CLOEXEC #ifndef HAVE_O_CLOEXEC
#define O_CLOEXEC 0 #define O_CLOEXEC 0
+4 -8
View File
@@ -23,8 +23,7 @@
#include "./SDL_list.h" #include "./SDL_list.h"
/* Push */ /* Push */
int int SDL_ListAdd(SDL_ListNode **head, void *ent)
SDL_ListAdd(SDL_ListNode **head, void *ent)
{ {
SDL_ListNode *node = SDL_malloc(sizeof(*node)); 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) */ /* Pop from end as a FIFO (if add with SDL_ListAdd) */
void void SDL_ListPop(SDL_ListNode **head, void **ent)
SDL_ListPop(SDL_ListNode **head, void **ent)
{ {
SDL_ListNode **ptr = head; SDL_ListNode **ptr = head;
@@ -61,8 +59,7 @@ SDL_ListPop(SDL_ListNode **head, void **ent)
*ptr = NULL; *ptr = NULL;
} }
void void SDL_ListRemove(SDL_ListNode **head, void *ent)
SDL_ListRemove(SDL_ListNode **head, void *ent)
{ {
SDL_ListNode **ptr = head; SDL_ListNode **ptr = head;
@@ -77,8 +74,7 @@ SDL_ListRemove(SDL_ListNode **head, void *ent)
} }
} }
void void SDL_ListClear(SDL_ListNode **head)
SDL_ListClear(SDL_ListNode **head)
{ {
SDL_ListNode *l = *head; SDL_ListNode *l = *head;
*head = NULL; *head = NULL;
-1
View File
@@ -28,7 +28,6 @@ typedef struct SDL_ListNode
struct SDL_ListNode *next; struct SDL_ListNode *next;
} SDL_ListNode; } SDL_ListNode;
int SDL_ListAdd(SDL_ListNode **head, void *ent); int SDL_ListAdd(SDL_ListNode **head, void *ent);
void SDL_ListPop(SDL_ListNode **head, void **ent); void SDL_ListPop(SDL_ListNode **head, void **ent);
void SDL_ListRemove(SDL_ListNode **head, void *ent); void SDL_ListRemove(SDL_ListNode **head, void *ent);
+18 -37
View File
@@ -38,7 +38,6 @@
#include "stdlib/SDL_vacopy.h" #include "stdlib/SDL_vacopy.h"
/* The size of the stack buffer to use for rendering log messages. */ /* The size of the stack buffer to use for rendering log messages. */
#define SDL_MAX_LOG_MESSAGE_STACK 256 #define SDL_MAX_LOG_MESSAGE_STACK 256
@@ -102,8 +101,7 @@ static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = {
}; };
#endif /* __ANDROID__ */ #endif /* __ANDROID__ */
void void SDL_LogInit(void)
SDL_LogInit(void)
{ {
if (log_function_mutex == NULL) { if (log_function_mutex == NULL) {
/* if this fails we'll try to continue without it. */ /* if this fails we'll try to continue without it. */
@@ -111,8 +109,7 @@ SDL_LogInit(void)
} }
} }
void void SDL_LogQuit(void)
SDL_LogQuit(void)
{ {
SDL_LogResetPriorities(); SDL_LogResetPriorities();
if (log_function_mutex) { if (log_function_mutex) {
@@ -121,8 +118,7 @@ SDL_LogQuit(void)
} }
} }
void void SDL_LogSetAllPriority(SDL_LogPriority priority)
SDL_LogSetAllPriority(SDL_LogPriority priority)
{ {
SDL_LogLevel *entry; SDL_LogLevel *entry;
@@ -134,8 +130,7 @@ SDL_LogSetAllPriority(SDL_LogPriority priority)
SDL_application_priority = priority; SDL_application_priority = priority;
} }
void void SDL_LogSetPriority(int category, SDL_LogPriority priority)
SDL_LogSetPriority(int category, SDL_LogPriority priority)
{ {
SDL_LogLevel *entry; SDL_LogLevel *entry;
@@ -178,8 +173,7 @@ SDL_LogGetPriority(int category)
} }
} }
void void SDL_LogResetPriorities(void)
SDL_LogResetPriorities(void)
{ {
SDL_LogLevel *entry; SDL_LogLevel *entry;
@@ -195,8 +189,7 @@ SDL_LogResetPriorities(void)
SDL_test_priority = DEFAULT_TEST_PRIORITY; SDL_test_priority = DEFAULT_TEST_PRIORITY;
} }
void void SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{ {
va_list ap; va_list ap;
@@ -205,8 +198,7 @@ SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(ap); va_end(ap);
} }
void void SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{ {
va_list ap; va_list ap;
@@ -215,8 +207,7 @@ SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(ap); va_end(ap);
} }
void void SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{ {
va_list ap; va_list ap;
@@ -225,8 +216,7 @@ SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(ap); va_end(ap);
} }
void void SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{ {
va_list ap; va_list ap;
@@ -235,8 +225,7 @@ SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(ap); va_end(ap);
} }
void void SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{ {
va_list ap; va_list ap;
@@ -245,8 +234,7 @@ SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(ap); va_end(ap);
} }
void void SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{ {
va_list ap; va_list ap;
@@ -255,8 +243,7 @@ SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(ap); va_end(ap);
} }
void void SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{ {
va_list ap; va_list ap;
@@ -265,8 +252,7 @@ SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(ap); va_end(ap);
} }
void void SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{ {
va_list ap; va_list ap;
@@ -276,8 +262,7 @@ SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING
} }
#ifdef __ANDROID__ #ifdef __ANDROID__
static const char * static const char *GetCategoryPrefix(int category)
GetCategoryPrefix(int category)
{ {
if (category < SDL_LOG_CATEGORY_RESERVED1) { if (category < SDL_LOG_CATEGORY_RESERVED1) {
return SDL_category_prefixes[category]; return SDL_category_prefixes[category];
@@ -289,8 +274,7 @@ GetCategoryPrefix(int category)
} }
#endif /* __ANDROID__ */ #endif /* __ANDROID__ */
void void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap)
SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap)
{ {
char *message = NULL; char *message = NULL;
char stack_buf[SDL_MAX_LOG_MESSAGE_STACK]; char stack_buf[SDL_MAX_LOG_MESSAGE_STACK];
@@ -373,8 +357,7 @@ static int consoleAttached = 0;
static HANDLE stderrHandle = NULL; static HANDLE stderrHandle = NULL;
#endif #endif
static void SDLCALL static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
const char *message) const char *message)
{ {
#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) #if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)
@@ -503,8 +486,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
#endif #endif
} }
void void SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
{ {
if (callback) { if (callback) {
*callback = SDL_log_function; *callback = SDL_log_function;
@@ -514,8 +496,7 @@ SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
} }
} }
void void SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata)
SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata)
{ {
SDL_log_function = callback; SDL_log_function = callback;
SDL_log_userdata = userdata; SDL_log_userdata = userdata;
+10 -16
View File
@@ -20,7 +20,6 @@
*/ */
#include "SDL_internal.h" #include "SDL_internal.h"
#if defined(_MSC_VER) && (_MSC_VER >= 1500) #if defined(_MSC_VER) && (_MSC_VER >= 1500)
#include <intrin.h> #include <intrin.h>
#define HAVE_MSC_ATOMICS 1 #define HAVE_MSC_ATOMICS 1
@@ -49,6 +48,7 @@
#endif #endif
#endif #endif
/* *INDENT-OFF* */ /* clang-format off */
#if defined(__WATCOMC__) && defined(__386__) #if defined(__WATCOMC__) && defined(__386__)
SDL_COMPILE_TIME_ASSERT(intsize, 4==sizeof(int)); SDL_COMPILE_TIME_ASSERT(intsize, 4==sizeof(int));
#define HAVE_WATCOM_ATOMICS #define HAVE_WATCOM_ATOMICS
@@ -73,7 +73,9 @@ extern __inline int _SDL_xadd_watcom(volatile int *a, int v);
parm [ecx] [eax] \ parm [ecx] [eax] \
value [eax] \ value [eax] \
modify exact [eax]; modify exact [eax];
#endif /* __WATCOMC__ && __386__ */ #endif /* __WATCOMC__ && __386__ */
/* *INDENT-ON* */ /* clang-format on */
/* /*
If any of the operations are not provided then we must emulate some 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 #if EMULATE_CAS
static SDL_SpinLock locks[32]; static SDL_SpinLock locks[32];
static SDL_INLINE void static SDL_INLINE void enterLock(void *a)
enterLock(void *a)
{ {
uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f); uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f);
SDL_AtomicLock(&locks[index]); SDL_AtomicLock(&locks[index]);
} }
static SDL_INLINE void static SDL_INLINE void leaveLock(void *a)
leaveLock(void *a)
{ {
uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f); uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f);
@@ -122,7 +122,6 @@ leaveLock(void *a)
} }
#endif #endif
SDL_bool SDL_bool
SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval) SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval)
{ {
@@ -184,8 +183,7 @@ SDL_AtomicCASPtr(void **a, void *oldval, void *newval)
#endif #endif
} }
int int SDL_AtomicSet(SDL_atomic_t *a, int v)
SDL_AtomicSet(SDL_atomic_t *a, int v)
{ {
#ifdef HAVE_MSC_ATOMICS #ifdef HAVE_MSC_ATOMICS
SDL_COMPILE_TIME_ASSERT(atomic_set, sizeof(long) == sizeof(a->value)); SDL_COMPILE_TIME_ASSERT(atomic_set, sizeof(long) == sizeof(a->value));
@@ -225,8 +223,7 @@ SDL_AtomicSetPtr(void **a, void *v)
#endif #endif
} }
int int SDL_AtomicAdd(SDL_atomic_t *a, int v)
SDL_AtomicAdd(SDL_atomic_t *a, int v)
{ {
#ifdef HAVE_MSC_ATOMICS #ifdef HAVE_MSC_ATOMICS
SDL_COMPILE_TIME_ASSERT(atomic_add, sizeof(long) == sizeof(a->value)); SDL_COMPILE_TIME_ASSERT(atomic_add, sizeof(long) == sizeof(a->value));
@@ -249,8 +246,7 @@ SDL_AtomicAdd(SDL_atomic_t *a, int v)
#endif #endif
} }
int int SDL_AtomicGet(SDL_atomic_t *a)
SDL_AtomicGet(SDL_atomic_t *a)
{ {
#ifdef HAVE_ATOMIC_LOAD_N #ifdef HAVE_ATOMIC_LOAD_N
return __atomic_load_n(&a->value, __ATOMIC_SEQ_CST); 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 #error This file should be built in arm mode so the mcr instruction is available for memory barriers
#endif #endif
void void SDL_MemoryBarrierReleaseFunction(void)
SDL_MemoryBarrierReleaseFunction(void)
{ {
SDL_MemoryBarrierRelease(); SDL_MemoryBarrierRelease();
} }
void void SDL_MemoryBarrierAcquireFunction(void)
SDL_MemoryBarrierAcquireFunction(void)
{ {
SDL_MemoryBarrierAcquire(); SDL_MemoryBarrierAcquire();
} }
+19 -10
View File
@@ -24,7 +24,6 @@
#include "../core/windows/SDL_windows.h" #include "../core/windows/SDL_windows.h"
#endif #endif
#if !defined(HAVE_GCC_ATOMICS) && defined(__SOLARIS__) #if !defined(HAVE_GCC_ATOMICS) && defined(__SOLARIS__)
#include <atomic.h> #include <atomic.h>
#endif #endif
@@ -45,6 +44,7 @@
#include <libkern/OSAtomic.h> #include <libkern/OSAtomic.h>
#endif #endif
/* *INDENT-OFF* */ /* clang-format off */
#if defined(__WATCOMC__) && defined(__386__) #if defined(__WATCOMC__) && defined(__386__)
SDL_COMPILE_TIME_ASSERT(locksize, 4==sizeof(SDL_SpinLock)); SDL_COMPILE_TIME_ASSERT(locksize, 4==sizeof(SDL_SpinLock));
extern __inline int _SDL_xchg_watcom(volatile int *a, int v); 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] \ value [eax] \
modify exact [eax]; modify exact [eax];
#endif /* __WATCOMC__ && __386__ */ #endif /* __WATCOMC__ && __386__ */
/* *INDENT-ON* */ /* clang-format on */
/* This function is where all the magic happens... */ /* This function is where all the magic happens... */
SDL_bool SDL_bool
@@ -101,28 +102,36 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
if (__cpucap_have_rex()) { if (__cpucap_have_rex()) {
__asm__ __volatile__( __asm__ __volatile__(
"ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]" "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; return result == 0;
} }
#endif #endif
__asm__ __volatile__( __asm__ __volatile__(
"swp %0, %1, [%2]\n" "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; return result == 0;
#elif defined(__GNUC__) && defined(__arm__) #elif defined(__GNUC__) && defined(__arm__)
int result; int result;
__asm__ __volatile__( __asm__ __volatile__(
"ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]" "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; return result == 0;
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
int result; int result;
__asm__ __volatile__( __asm__ __volatile__(
"lock ; xchgl %0, (%1)\n" "lock ; xchgl %0, (%1)\n"
: "=r" (result) : "r" (lock), "0" (1) : "cc", "memory"); : "=r"(result)
: "r"(lock), "0"(1)
: "cc", "memory");
return result == 0; return result == 0;
#elif defined(__MACOS__) || defined(__IOS__) || defined(__TVOS__) #elif defined(__MACOS__) || defined(__IOS__) || defined(__TVOS__)
@@ -147,7 +156,9 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
res = SDL_TRUE; res = SDL_TRUE;
} }
// enable interuption // enable interuption
if (oldintr) { EIntr(); } if (oldintr) {
EIntr();
}
return res; return res;
#else #else
#error Please implement for your platform. #error Please implement for your platform.
@@ -155,8 +166,7 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
#endif #endif
} }
void void SDL_AtomicLock(SDL_SpinLock *lock)
SDL_AtomicLock(SDL_SpinLock *lock)
{ {
int iterations = 0; int iterations = 0;
/* FIXME: Should we have an eventual timeout? */ /* FIXME: Should we have an eventual timeout? */
@@ -171,8 +181,7 @@ SDL_AtomicLock(SDL_SpinLock *lock)
} }
} }
void void SDL_AtomicUnlock(SDL_SpinLock *lock)
SDL_AtomicUnlock(SDL_SpinLock *lock)
{ {
#if HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET #if HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
__sync_lock_release(lock); __sync_lock_release(lock);
+63 -134
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-1
View File
@@ -1059,4 +1059,3 @@ static const float ResamplerFilterDifference[RESAMPLER_FILTER_SIZE] = {
}; };
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
+125 -103
View File
File diff suppressed because it is too large Load Diff
+5 -11
View File
@@ -45,8 +45,7 @@
#define _PATH_DEV_AUDIO "/dev/audio" #define _PATH_DEV_AUDIO "/dev/audio"
#endif #endif
static void static void test_device(const int iscapture, const char *fname, int flags, int (*test)(int fd))
test_device(const int iscapture, const char *fname, int flags, int (*test) (int fd))
{ {
struct stat sb; struct stat sb;
if ((stat(fname, &sb) == 0) && (S_ISCHR(sb.st_mode))) { 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 static int test_stub(int fd)
test_stub(int fd)
{ {
return 1; return 1;
} }
static void static void SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*test)(int))
SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*test)(int))
{ {
const int flags = iscapture ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT; const int flags = iscapture ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT;
const char *audiodev; const char *audiodev;
@@ -96,9 +93,7 @@ SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*
struct stat sb; struct stat sb;
/* Added support for /dev/sound/\* in Linux 2.4 */ /* Added support for /dev/sound/\* in Linux 2.4 */
if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(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))) {
&& ((stat(_PATH_DEV_DSP24, &sb) == 0)
&& S_ISCHR(sb.st_mode))) {
audiodev = _PATH_DEV_DSP24; audiodev = _PATH_DEV_DSP24;
} else { } else {
audiodev = _PATH_DEV_DSP; audiodev = _PATH_DEV_DSP;
@@ -118,8 +113,7 @@ SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*
} }
} }
void void SDL_EnumUnixAudioDevices(const int classic, int (*test)(int))
SDL_EnumUnixAudioDevices(const int classic, int (*test)(int))
{ {
SDL_EnumUnixAudioDevices_Internal(SDL_TRUE, classic, test); SDL_EnumUnixAudioDevices_Internal(SDL_TRUE, classic, test);
SDL_EnumUnixAudioDevices_Internal(SDL_FALSE, classic, test); SDL_EnumUnixAudioDevices_Internal(SDL_FALSE, classic, test);
File diff suppressed because it is too large Load Diff
+11 -23
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_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) #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) Uint32 len, int volume)
{ {
if (volume == 0) { if (volume == 0) {
@@ -104,8 +102,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
++dst; ++dst;
++src; ++src;
} }
} } break;
break;
case AUDIO_S8: case AUDIO_S8:
{ {
@@ -130,8 +127,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
++dst8; ++dst8;
++src8; ++src8;
} }
} } break;
break;
case AUDIO_S16LSB: case AUDIO_S16LSB:
{ {
@@ -155,8 +151,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
*(Sint16 *)dst = SDL_SwapLE16(dst_sample); *(Sint16 *)dst = SDL_SwapLE16(dst_sample);
dst += 2; dst += 2;
} }
} } break;
break;
case AUDIO_S16MSB: case AUDIO_S16MSB:
{ {
@@ -180,8 +175,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
*(Sint16 *)dst = SDL_SwapBE16(dst_sample); *(Sint16 *)dst = SDL_SwapBE16(dst_sample);
dst += 2; dst += 2;
} }
} } break;
break;
case AUDIO_U16LSB: case AUDIO_U16LSB:
{ {
@@ -206,8 +200,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
*(Uint16 *)dst = SDL_SwapLE16(dst_sample); *(Uint16 *)dst = SDL_SwapLE16(dst_sample);
dst += 2; dst += 2;
} }
} } break;
break;
case AUDIO_U16MSB: case AUDIO_U16MSB:
{ {
@@ -232,8 +225,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
*(Uint16 *)dst = SDL_SwapBE16(dst_sample); *(Uint16 *)dst = SDL_SwapBE16(dst_sample);
dst += 2; dst += 2;
} }
} } break;
break;
case AUDIO_S32LSB: case AUDIO_S32LSB:
{ {
@@ -258,8 +250,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
} }
*(dst32++) = SDL_SwapLE32((Uint32)((Sint32)dst_sample)); *(dst32++) = SDL_SwapLE32((Uint32)((Sint32)dst_sample));
} }
} } break;
break;
case AUDIO_S32MSB: case AUDIO_S32MSB:
{ {
@@ -284,8 +275,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
} }
*(dst32++) = SDL_SwapBE32((Uint32)((Sint32)dst_sample)); *(dst32++) = SDL_SwapBE32((Uint32)((Sint32)dst_sample));
} }
} } break;
break;
case AUDIO_F32LSB: case AUDIO_F32LSB:
{ {
@@ -313,8 +303,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
} }
*(dst32++) = SDL_SwapFloatLE((float)dst_sample); *(dst32++) = SDL_SwapFloatLE((float)dst_sample);
} }
} } break;
break;
case AUDIO_F32MSB: case AUDIO_F32MSB:
{ {
@@ -342,8 +331,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
} }
*(dst32++) = SDL_SwapFloatBE((float)dst_sample); *(dst32++) = SDL_SwapFloatBE((float)dst_sample);
} }
} } break;
break;
default: /* If this happens... FIXME! */ default: /* If this happens... FIXME! */
SDL_SetError("SDL_MixAudioFormat(): unknown audio format"); SDL_SetError("SDL_MixAudioFormat(): unknown audio format");
-3
View File
@@ -89,7 +89,6 @@ typedef struct SDL_AudioDriverImpl
SDL_bool SupportsNonPow2Samples; SDL_bool SupportsNonPow2Samples;
} SDL_AudioDriverImpl; } SDL_AudioDriverImpl;
typedef struct SDL_AudioDeviceItem typedef struct SDL_AudioDeviceItem
{ {
void *handle; void *handle;
@@ -100,7 +99,6 @@ typedef struct SDL_AudioDeviceItem
struct SDL_AudioDeviceItem *next; struct SDL_AudioDeviceItem *next;
} SDL_AudioDeviceItem; } SDL_AudioDeviceItem;
typedef struct SDL_AudioDriver typedef struct SDL_AudioDriver
{ {
/* * * */ /* * * */
@@ -123,7 +121,6 @@ typedef struct SDL_AudioDriver
SDL_AudioDeviceItem *inputDevices; SDL_AudioDeviceItem *inputDevices;
} SDL_AudioDriver; } SDL_AudioDriver;
/* Define the SDL audio driver structure */ /* Define the SDL audio driver structure */
struct SDL_AudioDevice struct SDL_AudioDevice
{ {
+53 -74
View File
@@ -41,8 +41,7 @@
* Returns 0 on success, or -1 if the multiplication overflows, in which case f1 * Returns 0 on success, or -1 if the multiplication overflows, in which case f1
* does not get modified. * does not get modified.
*/ */
static int static int SafeMult(size_t *f1, size_t f2)
SafeMult(size_t *f1, size_t f2)
{ {
if (*f1 > 0 && SIZE_MAX / *f1 <= f2) { if (*f1 > 0 && SIZE_MAX / *f1 <= f2) {
return -1; return -1;
@@ -64,21 +63,24 @@ typedef struct ADPCM_DecoderState
void *cstate; /* Decoding state for each channel. */ void *cstate; /* Decoding state for each channel. */
/* ADPCM data. */ /* ADPCM data. */
struct { struct
{
Uint8 *data; Uint8 *data;
size_t size; size_t size;
size_t pos; size_t pos;
} input; } input;
/* Current ADPCM block in the ADPCM data above. */ /* Current ADPCM block in the ADPCM data above. */
struct { struct
{
Uint8 *data; Uint8 *data;
size_t size; size_t size;
size_t pos; size_t pos;
} block; } block;
/* Decoded 16-bit PCM data. */ /* Decoded 16-bit PCM data. */
struct { struct
{
Sint16 *data; Sint16 *data;
size_t size; size_t size;
size_t pos; size_t pos;
@@ -100,8 +102,7 @@ typedef struct MS_ADPCM_ChannelState
} MS_ADPCM_ChannelState; } MS_ADPCM_ChannelState;
#ifdef SDL_WAVE_DEBUG_LOG_FORMAT #ifdef SDL_WAVE_DEBUG_LOG_FORMAT
static void static void WaveDebugLogFormat(WaveFile *file)
WaveDebugLogFormat(WaveFile *file)
{ {
WaveFormat *format = &file->format; WaveFormat *format = &file->format;
const char *fmtstr = "WAVE file: %s, %u Hz, %s, %u bits, %u %s/s"; const char *fmtstr = "WAVE file: %s, %u Hz, %s, %u bits, %u %s/s";
@@ -135,9 +136,14 @@ WaveDebugLogFormat(WaveFile *file)
break; break;
} }
#define SDL_WAVE_DEBUG_CHANNELCFG(STR, CODE) case CODE: wavechannel = STR; break; #define SDL_WAVE_DEBUG_CHANNELCFG(STR, CODE) \
#define SDL_WAVE_DEBUG_CHANNELSTR(STR, CODE) if (format->channelmask & CODE) { \ case CODE: \
SDL_strlcat(channelstr, channelstr[0] ? "-" STR : STR, sizeof(channelstr));} 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) { if (format->formattag == EXTENSIBLE_CODE && format->channelmask > 0) {
switch (format->channelmask) { switch (format->channelmask) {
@@ -224,8 +230,7 @@ WaveDebugLogFormat(WaveFile *file)
#endif #endif
#ifdef SDL_WAVE_DEBUG_DUMP_FORMAT #ifdef SDL_WAVE_DEBUG_DUMP_FORMAT
static void static void WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, Uint32 datalen)
WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, Uint32 datalen)
{ {
WaveFormat *format = &file->format; WaveFormat *format = &file->format;
const char *fmtstr1 = "WAVE chunk dump:\n" const char *fmtstr1 = "WAVE chunk dump:\n"
@@ -315,8 +320,7 @@ WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, Uint32 datale
} }
#endif #endif
static Sint64 static Sint64 WaveAdjustToFactValue(WaveFile *file, Sint64 sampleframes)
WaveAdjustToFactValue(WaveFile *file, Sint64 sampleframes)
{ {
if (file->fact.status == 2) { if (file->fact.status == 2) {
if (file->facthint == FactStrict && sampleframes < file->fact.samplelength) { if (file->facthint == FactStrict && sampleframes < file->fact.samplelength) {
@@ -329,8 +333,7 @@ WaveAdjustToFactValue(WaveFile *file, Sint64 sampleframes)
return sampleframes; return sampleframes;
} }
static int static int MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
{ {
WaveFormat *format = &file->format; WaveFormat *format = &file->format;
const size_t blockheadersize = (size_t)file->format.channels * 7; const size_t blockheadersize = (size_t)file->format.channels * 7;
@@ -369,8 +372,7 @@ MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
return 0; return 0;
} }
static int static int MS_ADPCM_Init(WaveFile *file, size_t datalength)
MS_ADPCM_Init(WaveFile *file, size_t datalength)
{ {
WaveFormat *format = &file->format; WaveFormat *format = &file->format;
WaveChunk *chunk = &file->chunk; WaveChunk *chunk = &file->chunk;
@@ -488,8 +490,7 @@ MS_ADPCM_Init(WaveFile *file, size_t datalength)
return 0; return 0;
} }
static Sint16 static Sint16 MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sample1, Sint32 sample2, Uint8 nybble)
MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sample1, Sint32 sample2, Uint8 nybble)
{ {
const Sint32 max_audioval = 32767; const Sint32 max_audioval = 32767;
const Sint32 min_audioval = -32768; const Sint32 min_audioval = -32768;
@@ -525,8 +526,7 @@ MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sample1, Sint32 sam
return (Sint16)new_sample; return (Sint16)new_sample;
} }
static int static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
{ {
Uint8 coeffindex; Uint8 coeffindex;
const Uint32 channels = state->channels; 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). * will always contain full sample frames (same sample count for each channel).
* Incomplete sample frames are discarded. * Incomplete sample frames are discarded.
*/ */
static int static int MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
{ {
Uint16 nybble = 0; Uint16 nybble = 0;
Sint16 sample1, sample2; Sint16 sample1, sample2;
@@ -634,8 +633,7 @@ MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
return 0; return 0;
} }
static int static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{ {
int result; int result;
size_t bytesleft, outputsize; size_t bytesleft, outputsize;
@@ -734,8 +732,7 @@ MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0; return 0;
} }
static int static int IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
{ {
WaveFormat *format = &file->format; WaveFormat *format = &file->format;
const size_t blockheadersize = (size_t)format->channels * 4; const size_t blockheadersize = (size_t)format->channels * 4;
@@ -788,8 +785,7 @@ IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
return 0; return 0;
} }
static int static int IMA_ADPCM_Init(WaveFile *file, size_t datalength)
IMA_ADPCM_Init(WaveFile *file, size_t datalength)
{ {
WaveFormat *format = &file->format; WaveFormat *format = &file->format;
WaveChunk *chunk = &file->chunk; WaveChunk *chunk = &file->chunk;
@@ -854,8 +850,7 @@ IMA_ADPCM_Init(WaveFile *file, size_t datalength)
return 0; return 0;
} }
static Sint16 static Sint16 IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 nybble)
IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 nybble)
{ {
const Sint32 max_audioval = 32767; const Sint32 max_audioval = 32767;
const Sint32 min_audioval = -32768; const Sint32 min_audioval = -32768;
@@ -924,8 +919,7 @@ IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 nybble)
return (Sint16)sample; return (Sint16)sample;
} }
static int static int IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
{ {
Sint16 step; Sint16 step;
Uint32 c; Uint32 c;
@@ -964,8 +958,7 @@ IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
* contains full sample frames (same sample count for each channel). * contains full sample frames (same sample count for each channel).
* Incomplete sample frames are discarded. * Incomplete sample frames are discarded.
*/ */
static int static int IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
{ {
size_t i; size_t i;
int retval = 0; int retval = 0;
@@ -1034,8 +1027,7 @@ IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
return retval; return retval;
} }
static int static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{ {
int result; int result;
size_t bytesleft, outputsize; size_t bytesleft, outputsize;
@@ -1138,8 +1130,7 @@ IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0; return 0;
} }
static int static int LAW_Init(WaveFile *file, size_t datalength)
LAW_Init(WaveFile *file, size_t datalength)
{ {
WaveFormat *format = &file->format; WaveFormat *format = &file->format;
@@ -1167,8 +1158,7 @@ LAW_Init(WaveFile *file, size_t datalength)
return 0; return 0;
} }
static int static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{ {
#ifdef SDL_WAVE_LAW_LUT #ifdef SDL_WAVE_LAW_LUT
const Sint16 alaw_lut[256] = { const Sint16 alaw_lut[256] = {
@@ -1310,8 +1300,7 @@ LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0; return 0;
} }
static int static int PCM_Init(WaveFile *file, size_t datalength)
PCM_Init(WaveFile *file, size_t datalength)
{ {
WaveFormat *format = &file->format; WaveFormat *format = &file->format;
@@ -1354,8 +1343,7 @@ PCM_Init(WaveFile *file, size_t datalength)
return 0; return 0;
} }
static int static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{ {
WaveFormat *format = &file->format; WaveFormat *format = &file->format;
WaveChunk *chunk = &file->chunk; WaveChunk *chunk = &file->chunk;
@@ -1406,8 +1394,7 @@ PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0; return 0;
} }
static int static int PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{ {
WaveFormat *format = &file->format; WaveFormat *format = &file->format;
WaveChunk *chunk = &file->chunk; WaveChunk *chunk = &file->chunk;
@@ -1449,8 +1436,7 @@ PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0; return 0;
} }
static WaveRiffSizeHint static WaveRiffSizeHint WaveGetRiffSizeHint()
WaveGetRiffSizeHint()
{ {
const char *hint = SDL_GetHint(SDL_HINT_WAVE_RIFF_CHUNK_SIZE); const char *hint = SDL_GetHint(SDL_HINT_WAVE_RIFF_CHUNK_SIZE);
@@ -1469,8 +1455,7 @@ WaveGetRiffSizeHint()
return RiffSizeNoHint; return RiffSizeNoHint;
} }
static WaveTruncationHint static WaveTruncationHint WaveGetTruncationHint()
WaveGetTruncationHint()
{ {
const char *hint = SDL_GetHint(SDL_HINT_WAVE_TRUNCATION); const char *hint = SDL_GetHint(SDL_HINT_WAVE_TRUNCATION);
@@ -1489,8 +1474,7 @@ WaveGetTruncationHint()
return TruncNoHint; return TruncNoHint;
} }
static WaveFactChunkHint static WaveFactChunkHint WaveGetFactChunkHint()
WaveGetFactChunkHint()
{ {
const char *hint = SDL_GetHint(SDL_HINT_WAVE_FACT_CHUNK); const char *hint = SDL_GetHint(SDL_HINT_WAVE_FACT_CHUNK);
@@ -1509,8 +1493,7 @@ WaveGetFactChunkHint()
return FactNoHint; return FactNoHint;
} }
static void static void WaveFreeChunkData(WaveChunk *chunk)
WaveFreeChunkData(WaveChunk *chunk)
{ {
if (chunk->data != NULL) { if (chunk->data != NULL) {
SDL_free(chunk->data); SDL_free(chunk->data);
@@ -1519,8 +1502,7 @@ WaveFreeChunkData(WaveChunk *chunk)
chunk->size = 0; chunk->size = 0;
} }
static int static int WaveNextChunk(SDL_RWops *src, WaveChunk *chunk)
WaveNextChunk(SDL_RWops *src, WaveChunk *chunk)
{ {
Uint32 chunkheader[2]; Uint32 chunkheader[2];
Sint64 nextposition = chunk->position + chunk->length; Sint64 nextposition = chunk->position + chunk->length;
@@ -1552,8 +1534,7 @@ WaveNextChunk(SDL_RWops *src, WaveChunk *chunk)
return 0; return 0;
} }
static int static int WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t length)
WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t length)
{ {
WaveFreeChunkData(chunk); WaveFreeChunkData(chunk);
@@ -1581,19 +1562,22 @@ WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t length)
return 0; return 0;
} }
static int static int WaveReadChunkData(SDL_RWops *src, WaveChunk *chunk)
WaveReadChunkData(SDL_RWops *src, WaveChunk *chunk)
{ {
return WaveReadPartialChunkData(src, chunk, chunk->length); return WaveReadPartialChunkData(src, chunk, chunk->length);
} }
typedef struct WaveExtensibleGUID { typedef struct WaveExtensibleGUID
{
Uint16 encoding; Uint16 encoding;
Uint8 guid[16]; Uint8 guid[16];
} WaveExtensibleGUID; } WaveExtensibleGUID;
/* Some of the GUIDs that are used by WAVEFORMATEXTENSIBLE. */ /* 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[] = { static WaveExtensibleGUID extensible_guids[] = {
{ PCM_CODE, WAVE_FORMATTAG_GUID(PCM_CODE) }, { PCM_CODE, WAVE_FORMATTAG_GUID(PCM_CODE) },
{ MS_ADPCM_CODE, WAVE_FORMATTAG_GUID(MS_ADPCM_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) } { IMA_ADPCM_CODE, WAVE_FORMATTAG_GUID(IMA_ADPCM_CODE) }
}; };
static Uint16 static Uint16 WaveGetFormatGUIDEncoding(WaveFormat *format)
WaveGetFormatGUIDEncoding(WaveFormat *format)
{ {
size_t i; size_t i;
for (i = 0; i < SDL_arraysize(extensible_guids); i++) { for (i = 0; i < SDL_arraysize(extensible_guids); i++) {
@@ -1615,8 +1598,7 @@ WaveGetFormatGUIDEncoding(WaveFormat *format)
return UNKNOWN_CODE; return UNKNOWN_CODE;
} }
static int static int WaveReadFormat(WaveFile *file)
WaveReadFormat(WaveFile *file)
{ {
WaveChunk *chunk = &file->chunk; WaveChunk *chunk = &file->chunk;
WaveFormat *format = &file->format; WaveFormat *format = &file->format;
@@ -1677,8 +1659,7 @@ WaveReadFormat(WaveFile *file)
return 0; return 0;
} }
static int static int WaveCheckFormat(WaveFile *file, size_t datalength)
WaveCheckFormat(WaveFile *file, size_t datalength)
{ {
WaveFormat *format = &file->format; WaveFormat *format = &file->format;
@@ -1785,8 +1766,7 @@ WaveCheckFormat(WaveFile *file, size_t datalength)
return 0; return 0;
} }
static int static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
{ {
int result; int result;
Uint32 chunkcount = 0; 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 /* Since the WAV memory is allocated in the shared library, it must also
be freed here. (Necessary under Win32, VC++) be freed here. (Necessary under Win32, VC++)
*/ */
void void SDL_FreeWAV(Uint8 *audio_buf)
SDL_FreeWAV(Uint8 *audio_buf)
{ {
SDL_free(audio_buf); SDL_free(audio_buf);
} }
+8 -4
View File
@@ -70,7 +70,8 @@ typedef struct WaveFormat
} WaveFormat; } WaveFormat;
/* Stores information on the fact chunk. */ /* Stores information on the fact chunk. */
typedef struct WaveFact { typedef struct WaveFact
{
/* Represents the state of the fact chunk in the WAVE file. /* Represents the state of the fact chunk in the WAVE file.
* Set to -1 if the fact chunk is invalid. * Set to -1 if the fact chunk is invalid.
* Set to 0 if the fact chunk is not present * Set to 0 if the fact chunk is not present
@@ -101,7 +102,8 @@ typedef struct WaveChunk
} WaveChunk; } WaveChunk;
/* Controls how the size of the RIFF chunk affects the loading of a WAVE file. */ /* Controls how the size of the RIFF chunk affects the loading of a WAVE file. */
typedef enum WaveRiffSizeHint { typedef enum WaveRiffSizeHint
{
RiffSizeNoHint, RiffSizeNoHint,
RiffSizeForce, RiffSizeForce,
RiffSizeIgnoreZero, RiffSizeIgnoreZero,
@@ -110,7 +112,8 @@ typedef enum WaveRiffSizeHint {
} WaveRiffSizeHint; } WaveRiffSizeHint;
/* Controls how a truncated WAVE file is handled. */ /* Controls how a truncated WAVE file is handled. */
typedef enum WaveTruncationHint { typedef enum WaveTruncationHint
{
TruncNoHint, TruncNoHint,
TruncVeryStrict, TruncVeryStrict,
TruncStrict, TruncStrict,
@@ -119,7 +122,8 @@ typedef enum WaveTruncationHint {
} WaveTruncationHint; } WaveTruncationHint;
/* Controls how the fact chunk affects the loading of a WAVE file. */ /* Controls how the fact chunk affects the loading of a WAVE file. */
typedef enum WaveFactChunkHint { typedef enum WaveFactChunkHint
{
FactNoHint, FactNoHint,
FactTruncate, FactTruncate,
FactStrict, FactStrict,
+7 -14
View File
@@ -68,8 +68,7 @@ void aaudio_errorCallback( AAudioStream *stream, void *userData, aaudio_result_t
#define LIB_AAUDIO_SO "libaaudio.so" #define LIB_AAUDIO_SO "libaaudio.so"
static int static int aaudio_OpenDevice(_THIS, const char *devname)
aaudio_OpenDevice(_THIS, const char *devname)
{ {
struct SDL_PrivateAudioData *private; struct SDL_PrivateAudioData *private;
SDL_bool iscapture = this->iscapture; SDL_bool iscapture = this->iscapture;
@@ -165,8 +164,7 @@ aaudio_OpenDevice(_THIS, const char *devname)
return 0; return 0;
} }
static void static void aaudio_CloseDevice(_THIS)
aaudio_CloseDevice(_THIS)
{ {
struct SDL_PrivateAudioData *private = this->hidden; struct SDL_PrivateAudioData *private = this->hidden;
aaudio_result_t res; aaudio_result_t res;
@@ -200,15 +198,13 @@ aaudio_CloseDevice(_THIS)
SDL_free(this->hidden); SDL_free(this->hidden);
} }
static Uint8 * static Uint8 *aaudio_GetDeviceBuf(_THIS)
aaudio_GetDeviceBuf(_THIS)
{ {
struct SDL_PrivateAudioData *private = this->hidden; struct SDL_PrivateAudioData *private = this->hidden;
return private->mixbuf; return private->mixbuf;
} }
static void static void aaudio_PlayDevice(_THIS)
aaudio_PlayDevice(_THIS)
{ {
struct SDL_PrivateAudioData *private = this->hidden; struct SDL_PrivateAudioData *private = this->hidden;
aaudio_result_t res; aaudio_result_t res;
@@ -233,8 +229,7 @@ aaudio_PlayDevice(_THIS)
#endif #endif
} }
static int static int aaudio_CaptureFromDevice(_THIS, void *buffer, int buflen)
aaudio_CaptureFromDevice(_THIS, void *buffer, int buflen)
{ {
struct SDL_PrivateAudioData *private = this->hidden; struct SDL_PrivateAudioData *private = this->hidden;
aaudio_result_t res; aaudio_result_t res;
@@ -248,8 +243,7 @@ aaudio_CaptureFromDevice(_THIS, void *buffer, int buflen)
return res * private->frame_size; return res * private->frame_size;
} }
static void static void aaudio_Deinitialize(void)
aaudio_Deinitialize(void)
{ {
LOGI(__func__); LOGI(__func__);
if (ctx.handle) { if (ctx.handle) {
@@ -267,8 +261,7 @@ aaudio_Deinitialize(void)
LOGI("End AAUDIO %s", SDL_GetError()); LOGI("End AAUDIO %s", SDL_GetError());
} }
static SDL_bool static SDL_bool aaudio_Init(SDL_AudioDriverImpl *impl)
aaudio_Init(SDL_AudioDriverImpl *impl)
{ {
aaudio_result_t res; aaudio_result_t res;
LOGI(__func__); LOGI(__func__);
-1
View File
@@ -47,7 +47,6 @@ void aaudio_ResumeDevices(void);
void aaudio_PauseDevices(void); void aaudio_PauseDevices(void);
SDL_bool aaudio_DetectBrokenPlayState(void); SDL_bool aaudio_DetectBrokenPlayState(void);
#endif /* _SDL_aaudio_h */ #endif /* _SDL_aaudio_h */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
-1
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_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(aaudio_allowed_capture_policy_t, AAudioStream_getAllowedCapturePolicy, (AAudioStream * stream)) /* API 29 */
SDL_PROC_UNUSED(bool, AAudioStream_isPrivacySensitive, (AAudioStream * stream)) /* API 30 */ SDL_PROC_UNUSED(bool, AAudioStream_isPrivacySensitive, (AAudioStream * stream)) /* API 30 */
+70 -100
View File
@@ -43,56 +43,38 @@
#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
#endif #endif
static int (*ALSA_snd_pcm_open) static int (*ALSA_snd_pcm_open)(snd_pcm_t **, const char *, snd_pcm_stream_t, int);
(snd_pcm_t **, const char *, snd_pcm_stream_t, int);
static int (*ALSA_snd_pcm_close)(snd_pcm_t *pcm); static int (*ALSA_snd_pcm_close)(snd_pcm_t *pcm);
static snd_pcm_sframes_t (*ALSA_snd_pcm_writei) static snd_pcm_sframes_t (*ALSA_snd_pcm_writei)(snd_pcm_t *, const void *, snd_pcm_uframes_t);
(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_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_recover)(snd_pcm_t *, int, int);
static int (*ALSA_snd_pcm_prepare)(snd_pcm_t *); static int (*ALSA_snd_pcm_prepare)(snd_pcm_t *);
static int (*ALSA_snd_pcm_drain)(snd_pcm_t *); static int (*ALSA_snd_pcm_drain)(snd_pcm_t *);
static const char *(*ALSA_snd_strerror)(int); static const char *(*ALSA_snd_strerror)(int);
static size_t (*ALSA_snd_pcm_hw_params_sizeof)(void); static size_t (*ALSA_snd_pcm_hw_params_sizeof)(void);
static size_t (*ALSA_snd_pcm_sw_params_sizeof)(void); static size_t (*ALSA_snd_pcm_sw_params_sizeof)(void);
static void (*ALSA_snd_pcm_hw_params_copy) static void (*ALSA_snd_pcm_hw_params_copy)(snd_pcm_hw_params_t *, const snd_pcm_hw_params_t *);
(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_any)(snd_pcm_t *, snd_pcm_hw_params_t *);
static int (*ALSA_snd_pcm_hw_params_set_access) static int (*ALSA_snd_pcm_hw_params_set_access)(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_access_t);
(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_format) static int (*ALSA_snd_pcm_hw_params_set_channels)(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int);
(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_format_t); 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_channels) static int (*ALSA_snd_pcm_hw_params_set_rate_near)(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned 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_channels) static int (*ALSA_snd_pcm_hw_params_get_period_size)(const snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *);
(const snd_pcm_hw_params_t *, unsigned 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_rate_near) static int (*ALSA_snd_pcm_hw_params_set_periods_first)(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
(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_period_size_near) static int (*ALSA_snd_pcm_hw_params_set_buffer_size_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *, snd_pcm_uframes_t *);
(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *); 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_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_hw_params)(snd_pcm_t *, snd_pcm_hw_params_t *);
static int (*ALSA_snd_pcm_sw_params_current)(snd_pcm_t *, static int (*ALSA_snd_pcm_sw_params_current)(snd_pcm_t *,
snd_pcm_sw_params_t *); snd_pcm_sw_params_t *);
static int (*ALSA_snd_pcm_sw_params_set_start_threshold) static int (*ALSA_snd_pcm_sw_params_set_start_threshold)(snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
(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_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_nonblock)(snd_pcm_t *, int);
static int (*ALSA_snd_pcm_wait)(snd_pcm_t *, int); static int (*ALSA_snd_pcm_wait)(snd_pcm_t *, int);
static int (*ALSA_snd_pcm_sw_params_set_avail_min) static int (*ALSA_snd_pcm_sw_params_set_avail_min)(snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
(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_pcm_reset)(snd_pcm_t *);
static int (*ALSA_snd_device_name_hint)(int, const char *, void ***); static int (*ALSA_snd_device_name_hint)(int, const char *, void ***);
static char *(*ALSA_snd_device_name_get_hint)(const void *, const char *); 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 const char *alsa_library = SDL_AUDIO_DRIVER_ALSA_DYNAMIC;
static void *alsa_handle = NULL; static void *alsa_handle = NULL;
static int static int load_alsa_sym(const char *fn, void **addr)
load_alsa_sym(const char *fn, void **addr)
{ {
*addr = SDL_LoadFunction(alsa_handle, fn); *addr = SDL_LoadFunction(alsa_handle, fn);
if (*addr == NULL) { 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. */ /* cast funcs to char* first, to please GCC's strict aliasing rules. */
#define SDL_ALSA_SYM(x) \ #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 #else
#define SDL_ALSA_SYM(x) ALSA_##x = x #define SDL_ALSA_SYM(x) ALSA_##x = x
#endif #endif
static int static int load_alsa_syms(void)
load_alsa_syms(void)
{ {
SDL_ALSA_SYM(snd_pcm_open); SDL_ALSA_SYM(snd_pcm_open);
SDL_ALSA_SYM(snd_pcm_close); SDL_ALSA_SYM(snd_pcm_close);
@@ -180,8 +161,7 @@ load_alsa_syms(void)
#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
static void static void UnloadALSALibrary(void)
UnloadALSALibrary(void)
{ {
if (alsa_handle != NULL) { if (alsa_handle != NULL) {
SDL_UnloadObject(alsa_handle); SDL_UnloadObject(alsa_handle);
@@ -189,8 +169,7 @@ UnloadALSALibrary(void)
} }
} }
static int static int LoadALSALibrary(void)
LoadALSALibrary(void)
{ {
int retval = 0; int retval = 0;
if (alsa_handle == NULL) { if (alsa_handle == NULL) {
@@ -210,13 +189,11 @@ LoadALSALibrary(void)
#else #else
static void static void UnloadALSALibrary(void)
UnloadALSALibrary(void)
{ {
} }
static int static int LoadALSALibrary(void)
LoadALSALibrary(void)
{ {
load_alsa_syms(); load_alsa_syms();
return 0; return 0;
@@ -224,8 +201,7 @@ LoadALSALibrary(void)
#endif /* SDL_AUDIO_DRIVER_ALSA_DYNAMIC */ #endif /* SDL_AUDIO_DRIVER_ALSA_DYNAMIC */
static const char * static const char *get_audio_device(void *handle, const int channels)
get_audio_device(void *handle, const int channels)
{ {
const char *device; const char *device;
@@ -248,10 +224,8 @@ get_audio_device(void *handle, const int channels)
return "default"; return "default";
} }
/* This function waits until it is possible to write a full sound buffer */ /* This function waits until it is possible to write a full sound buffer */
static void static void ALSA_WaitDevice(_THIS)
ALSA_WaitDevice(_THIS)
{ {
#if SDL_ALSA_NON_BLOCKING #if SDL_ALSA_NON_BLOCKING
const snd_pcm_sframes_t needed = (snd_pcm_sframes_t)this->spec.samples; const snd_pcm_sframes_t needed = (snd_pcm_sframes_t)this->spec.samples;
@@ -273,7 +247,6 @@ ALSA_WaitDevice(_THIS)
#endif #endif
} }
/* !!! FIXME: is there a channel swizzler in alsalib instead? */ /* !!! FIXME: is there a channel swizzler in alsalib instead? */
/* /*
* https://bugzilla.libsdl.org/show_bug.cgi?id=110 * 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" * and for Windows DirectX [and CoreAudio], this is FL-FR-C-LFE-RL-RR"
*/ */
#define SWIZ6(T) \ #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; \ T *ptr = (T *)buffer; \
Uint32 i; \ Uint32 i; \
for (i = 0; i < bufferlen; i++, ptr += 6) { \ for (i = 0; i < bufferlen; i++, ptr += 6) { \
T tmp; \ T tmp; \
tmp = ptr[2]; ptr[2] = ptr[4]; ptr[4] = tmp; \ tmp = ptr[2]; \
tmp = ptr[3]; ptr[3] = ptr[5]; ptr[5] = tmp; \ 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: is there a channel swizzler in alsalib instead? */
/* !!! FIXME: this screams for a SIMD shuffle operation. */ /* !!! 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" * and for Windows DirectX [and CoreAudio], this is FL-FR-C-LFE-SL-SR-RL-RR"
*/ */
#define SWIZ8(T) \ #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; \ T *ptr = (T *)buffer; \
Uint32 i; \ Uint32 i; \
for (i = 0; i < bufferlen; i++, ptr += 6) { \ for (i = 0; i < bufferlen; i++, ptr += 6) { \
@@ -332,44 +310,50 @@ CHANNEL_SWIZZLE(SWIZ8)
#undef SWIZ6 #undef SWIZ6
#undef SWIZ8 #undef SWIZ8
/* /*
* Called right before feeding this->hidden->mixbuf to the hardware. Swizzle * Called right before feeding this->hidden->mixbuf to the hardware. Swizzle
* channels from Windows/Mac order to the format alsalib will want. * channels from Windows/Mac order to the format alsalib will want.
*/ */
static void static void swizzle_alsa_channels(_THIS, void *buffer, Uint32 bufferlen)
swizzle_alsa_channels(_THIS, void *buffer, Uint32 bufferlen)
{ {
switch (this->spec.channels) { switch (this->spec.channels) {
#define CHANSWIZ(chans) \ #define CHANSWIZ(chans) \
case chans: \ case chans: \
switch ((this->spec.format & (0xFF))) { \ switch ((this->spec.format & (0xFF))) { \
case 8: swizzle_alsa_channels_##chans##_Uint8(buffer, bufferlen); break; \ case 8: \
case 16: swizzle_alsa_channels_##chans##_Uint16(buffer, bufferlen); break; \ swizzle_alsa_channels_##chans##_Uint8(buffer, bufferlen); \
case 32: swizzle_alsa_channels_##chans##_Uint32(buffer, bufferlen); break; \ break; \
case 64: swizzle_alsa_channels_##chans##_Uint64(buffer, bufferlen); break; \ case 16: \
default: SDL_assert(!"unhandled bitsize"); break; \ 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; return;
CHANSWIZ(6); CHANSWIZ(6);
CHANSWIZ(8); CHANSWIZ(8);
#undef CHANSWIZ #undef CHANSWIZ
default: break; default:
break;
} }
} }
#ifdef SND_CHMAP_API_VERSION #ifdef SND_CHMAP_API_VERSION
/* Some devices have the right channel map, no swizzling necessary */ /* Some devices have the right channel map, no swizzling necessary */
static void static void no_swizzle(_THIS, void *buffer, Uint32 bufferlen)
no_swizzle(_THIS, void *buffer, Uint32 bufferlen)
{ {
} }
#endif /* SND_CHMAP_API_VERSION */ #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 Uint8 *sample_buf = (const Uint8 *)this->hidden->mixbuf;
const int frame_size = ((SDL_AUDIO_BITSIZE(this->spec.format)) / 8) * const int frame_size = ((SDL_AUDIO_BITSIZE(this->spec.format)) / 8) *
@@ -410,14 +394,12 @@ ALSA_PlayDevice(_THIS)
} }
} }
static Uint8 * static Uint8 *ALSA_GetDeviceBuf(_THIS)
ALSA_GetDeviceBuf(_THIS)
{ {
return this->hidden->mixbuf; return this->hidden->mixbuf;
} }
static int static int ALSA_CaptureFromDevice(_THIS, void *buffer, int buflen)
ALSA_CaptureFromDevice(_THIS, void *buffer, int buflen)
{ {
Uint8 *sample_buf = (Uint8 *)buffer; Uint8 *sample_buf = (Uint8 *)buffer;
const int frame_size = ((SDL_AUDIO_BITSIZE(this->spec.format)) / 8) * 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; return (total_frames - frames_left) * frame_size;
} }
static void static void ALSA_FlushCapture(_THIS)
ALSA_FlushCapture(_THIS)
{ {
ALSA_snd_pcm_reset(this->hidden->pcm_handle); ALSA_snd_pcm_reset(this->hidden->pcm_handle);
} }
static void static void ALSA_CloseDevice(_THIS)
ALSA_CloseDevice(_THIS)
{ {
if (this->hidden->pcm_handle) { if (this->hidden->pcm_handle) {
/* Wait for the submitted audio to drain /* Wait for the submitted audio to drain
@@ -481,8 +461,7 @@ ALSA_CloseDevice(_THIS)
SDL_free(this->hidden); SDL_free(this->hidden);
} }
static int static int ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params)
ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params)
{ {
int status; int status;
snd_pcm_hw_params_t *hwparams; snd_pcm_hw_params_t *hwparams;
@@ -537,8 +516,7 @@ ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params)
return 0; return 0;
} }
static int static int ALSA_OpenDevice(_THIS, const char *devname)
ALSA_OpenDevice(_THIS, const char *devname)
{ {
int status = 0; int status = 0;
SDL_bool iscapture = this->iscapture; SDL_bool iscapture = this->iscapture;
@@ -728,8 +706,7 @@ typedef struct ALSA_Device
struct ALSA_Device *next; struct ALSA_Device *next;
} ALSA_Device; } ALSA_Device;
static void static void add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSeen)
add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSeen)
{ {
ALSA_Device *dev = SDL_malloc(sizeof(ALSA_Device)); ALSA_Device *dev = SDL_malloc(sizeof(ALSA_Device));
char *desc; char *desc;
@@ -788,11 +765,9 @@ add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSee
*pSeen = dev; *pSeen = dev;
} }
static ALSA_Device *hotplug_devices = NULL; static ALSA_Device *hotplug_devices = NULL;
static void static void ALSA_HotplugIteration(void)
ALSA_HotplugIteration(void)
{ {
void **hints = NULL; void **hints = NULL;
ALSA_Device *dev; ALSA_Device *dev;
@@ -925,8 +900,7 @@ ALSA_HotplugIteration(void)
static SDL_atomic_t ALSA_hotplug_shutdown; static SDL_atomic_t ALSA_hotplug_shutdown;
static SDL_Thread *ALSA_hotplug_thread; static SDL_Thread *ALSA_hotplug_thread;
static int SDLCALL static int SDLCALL ALSA_HotplugThread(void *arg)
ALSA_HotplugThread(void *arg)
{ {
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW); SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW);
@@ -944,8 +918,7 @@ ALSA_HotplugThread(void *arg)
} }
#endif #endif
static void static void ALSA_DetectDevices(void)
ALSA_DetectDevices(void)
{ {
ALSA_HotplugIteration(); /* run once now before a thread continues to check. */ ALSA_HotplugIteration(); /* run once now before a thread continues to check. */
@@ -956,8 +929,7 @@ ALSA_DetectDevices(void)
#endif #endif
} }
static void static void ALSA_Deinitialize(void)
ALSA_Deinitialize(void)
{ {
ALSA_Device *dev; ALSA_Device *dev;
ALSA_Device *next; ALSA_Device *next;
@@ -982,8 +954,7 @@ ALSA_Deinitialize(void)
UnloadALSALibrary(); UnloadALSALibrary();
} }
static SDL_bool static SDL_bool ALSA_Init(SDL_AudioDriverImpl *impl)
ALSA_Init(SDL_AudioDriverImpl * impl)
{ {
if (LoadALSALibrary() < 0) { if (LoadALSALibrary() < 0) {
return SDL_FALSE; return SDL_FALSE;
@@ -1006,7 +977,6 @@ ALSA_Init(SDL_AudioDriverImpl * impl)
return SDL_TRUE; /* this audio target is available. */ return SDL_TRUE; /* this audio target is available. */
} }
AudioBootStrap ALSA_bootstrap = { AudioBootStrap ALSA_bootstrap = {
"alsa", "ALSA PCM audio", ALSA_Init, SDL_FALSE "alsa", "ALSA PCM audio", ALSA_Init, SDL_FALSE
}; };
+7 -15
View File
@@ -34,8 +34,7 @@
static SDL_AudioDevice *audioDevice = NULL; static SDL_AudioDevice *audioDevice = NULL;
static SDL_AudioDevice *captureDevice = NULL; static SDL_AudioDevice *captureDevice = NULL;
static int static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname)
ANDROIDAUDIO_OpenDevice(_THIS, const char *devname)
{ {
SDL_AudioFormat test_format; SDL_AudioFormat test_format;
SDL_bool iscapture = this->iscapture; SDL_bool iscapture = this->iscapture;
@@ -77,32 +76,27 @@ ANDROIDAUDIO_OpenDevice(_THIS, const char *devname)
return 0; return 0;
} }
static void static void ANDROIDAUDIO_PlayDevice(_THIS)
ANDROIDAUDIO_PlayDevice(_THIS)
{ {
Android_JNI_WriteAudioBuffer(); Android_JNI_WriteAudioBuffer();
} }
static Uint8 * static Uint8 *ANDROIDAUDIO_GetDeviceBuf(_THIS)
ANDROIDAUDIO_GetDeviceBuf(_THIS)
{ {
return Android_JNI_GetAudioBuffer(); return Android_JNI_GetAudioBuffer();
} }
static int static int ANDROIDAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
ANDROIDAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
{ {
return Android_JNI_CaptureAudioBuffer(buffer, buflen); return Android_JNI_CaptureAudioBuffer(buffer, buflen);
} }
static void static void ANDROIDAUDIO_FlushCapture(_THIS)
ANDROIDAUDIO_FlushCapture(_THIS)
{ {
Android_JNI_FlushCapturedAudio(); Android_JNI_FlushCapturedAudio();
} }
static void static void ANDROIDAUDIO_CloseDevice(_THIS)
ANDROIDAUDIO_CloseDevice(_THIS)
{ {
/* At this point SDL_CloseAudioDevice via close_audio_device took care of terminating the audio thread /* 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 so it's safe to terminate the Java side buffer and AudioTrack
@@ -118,8 +112,7 @@ ANDROIDAUDIO_CloseDevice(_THIS)
SDL_free(this->hidden); SDL_free(this->hidden);
} }
static SDL_bool static SDL_bool ANDROIDAUDIO_Init(SDL_AudioDriverImpl *impl)
ANDROIDAUDIO_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = ANDROIDAUDIO_OpenDevice; impl->OpenDevice = ANDROIDAUDIO_OpenDevice;
@@ -203,4 +196,3 @@ void ANDROIDAUDIO_PauseDevices(void) {}
#endif /* SDL_AUDIO_DRIVER_ANDROID */ #endif /* SDL_AUDIO_DRIVER_ANDROID */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
+31 -64
View File
@@ -46,7 +46,6 @@
} }
#endif #endif
#if MACOSX_COREAUDIO #if MACOSX_COREAUDIO
static const AudioObjectPropertyAddress devlist_address = { static const AudioObjectPropertyAddress devlist_address = {
kAudioHardwarePropertyDevices, kAudioHardwarePropertyDevices,
@@ -66,8 +65,7 @@ typedef struct AudioDeviceList
static AudioDeviceList *output_devs = NULL; static AudioDeviceList *output_devs = NULL;
static AudioDeviceList *capture_devs = NULL; static AudioDeviceList *capture_devs = NULL;
static SDL_bool static SDL_bool add_to_internal_dev_list(const int iscapture, AudioDeviceID devId)
add_to_internal_dev_list(const int iscapture, AudioDeviceID devId)
{ {
AudioDeviceList *item = (AudioDeviceList *)SDL_malloc(sizeof(AudioDeviceList)); AudioDeviceList *item = (AudioDeviceList *)SDL_malloc(sizeof(AudioDeviceList));
if (item == NULL) { if (item == NULL) {
@@ -85,16 +83,14 @@ add_to_internal_dev_list(const int iscapture, AudioDeviceID devId)
return SDL_TRUE; return SDL_TRUE;
} }
static void static void addToDevList(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data)
addToDevList(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data)
{ {
if (add_to_internal_dev_list(iscapture, devId)) { if (add_to_internal_dev_list(iscapture, devId)) {
SDL_AddAudioDevice(iscapture, name, spec, (void *)((size_t)devId)); SDL_AddAudioDevice(iscapture, name, spec, (void *)((size_t)devId));
} }
} }
static void static void build_device_list(int iscapture, addDevFn addfn, void *addfndata)
build_device_list(int iscapture, addDevFn addfn, void *addfndata)
{ {
OSStatus result = noErr; OSStatus result = noErr;
UInt32 size = 0; UInt32 size = 0;
@@ -182,8 +178,7 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata)
ptr = (char *)SDL_malloc(len + 1); ptr = (char *)SDL_malloc(len + 1);
usable = ((ptr != NULL) && usable = ((ptr != NULL) &&
(CFStringGetCString (CFStringGetCString(cfstr, ptr, len + 1, kCFStringEncodingUTF8)));
(cfstr, ptr, len + 1, kCFStringEncodingUTF8)));
CFRelease(cfstr); CFRelease(cfstr);
@@ -210,8 +205,7 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata)
} }
} }
static void static void free_audio_device_list(AudioDeviceList **list)
free_audio_device_list(AudioDeviceList **list)
{ {
AudioDeviceList *item = *list; AudioDeviceList *item = *list;
while (item) { while (item) {
@@ -222,15 +216,13 @@ free_audio_device_list(AudioDeviceList **list)
*list = NULL; *list = NULL;
} }
static void static void COREAUDIO_DetectDevices(void)
COREAUDIO_DetectDevices(void)
{ {
build_device_list(SDL_TRUE, addToDevList, NULL); build_device_list(SDL_TRUE, addToDevList, NULL);
build_device_list(SDL_FALSE, addToDevList, NULL); build_device_list(SDL_FALSE, addToDevList, NULL);
} }
static void static void build_device_change_list(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data)
build_device_change_list(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data)
{ {
AudioDeviceList **list = (AudioDeviceList **)data; AudioDeviceList **list = (AudioDeviceList **)data;
AudioDeviceList *item; 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)); SDL_AddAudioDevice(iscapture, name, spec, (void *)((size_t)devId));
} }
static void static void reprocess_device_list(const int iscapture, AudioDeviceList **list)
reprocess_device_list(const int iscapture, AudioDeviceList **list)
{ {
AudioDeviceList *item; AudioDeviceList *item;
AudioDeviceList *prev = NULL; 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. */ /* this is called when the system's list of available audio devices changes. */
static OSStatus static OSStatus device_list_changed(AudioObjectID systemObj, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data)
device_list_changed(AudioObjectID systemObj, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data)
{ {
reprocess_device_list(SDL_TRUE, &capture_devs); reprocess_device_list(SDL_TRUE, &capture_devs);
reprocess_device_list(SDL_FALSE, &output_devs); reprocess_device_list(SDL_FALSE, &output_devs);
@@ -285,7 +275,6 @@ device_list_changed(AudioObjectID systemObj, UInt32 num_addr, const AudioObjectP
} }
#endif #endif
static int open_playback_devices; static int open_playback_devices;
static int open_capture_devices; static int open_capture_devices;
static int num_open_devices; static int num_open_devices;
@@ -337,9 +326,7 @@ static void interruption_begin(_THIS)
static void interruption_end(_THIS) static void interruption_end(_THIS)
{ {
if (this != NULL && this->hidden != NULL && this->hidden->audioQueue != NULL if (this != NULL && this->hidden != NULL && this->hidden->audioQueue != NULL && this->hidden->interrupted && AudioQueueStart(this->hidden->audioQueue, NULL) == AVAudioSessionErrorCodeNone) {
&& this->hidden->interrupted
&& AudioQueueStart(this->hidden->audioQueue, NULL) == AVAudioSessionErrorCodeNone) {
this->hidden->interrupted = SDL_FALSE; this->hidden->interrupted = SDL_FALSE;
} }
} }
@@ -514,10 +501,8 @@ static BOOL update_audio_session(_THIS, SDL_bool open, SDL_bool allow_playandrec
} }
#endif #endif
/* The AudioQueue callback */ /* The AudioQueue callback */
static void static void outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer)
outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer)
{ {
SDL_AudioDevice *this = (SDL_AudioDevice *)inUserData; SDL_AudioDevice *this = (SDL_AudioDevice *)inUserData;
@@ -581,8 +566,7 @@ outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffe
if (len > remaining) { if (len > remaining) {
len = remaining; len = remaining;
} }
SDL_memcpy(ptr, (char *)this->hidden->buffer + SDL_memcpy(ptr, (char *)this->hidden->buffer + this->hidden->bufferOffset, len);
this->hidden->bufferOffset, len);
ptr = ptr + len; ptr = ptr + len;
remaining -= len; remaining -= len;
this->hidden->bufferOffset += len; this->hidden->bufferOffset += len;
@@ -596,8 +580,7 @@ outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffe
SDL_UnlockMutex(this->mixer_lock); SDL_UnlockMutex(this->mixer_lock);
} }
static void static void inputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer,
inputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer,
const AudioTimeStamp *inStartTime, UInt32 inNumberPacketDescriptions, const AudioTimeStamp *inStartTime, UInt32 inNumberPacketDescriptions,
const AudioStreamPacketDescription *inPacketDescs) const AudioStreamPacketDescription *inPacketDescs)
{ {
@@ -634,17 +617,14 @@ inputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer
AudioQueueEnqueueBuffer(this->hidden->audioQueue, inBuffer, 0, NULL); AudioQueueEnqueueBuffer(this->hidden->audioQueue, inBuffer, 0, NULL);
} }
#if MACOSX_COREAUDIO #if MACOSX_COREAUDIO
static const AudioObjectPropertyAddress alive_address = static const AudioObjectPropertyAddress alive_address = {
{
kAudioDevicePropertyDeviceIsAlive, kAudioDevicePropertyDeviceIsAlive,
kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMain kAudioObjectPropertyElementMain
}; };
static OSStatus static OSStatus device_unplugged(AudioObjectID devid, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data)
device_unplugged(AudioObjectID devid, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data)
{ {
SDL_AudioDevice *this = (SDL_AudioDevice *)data; SDL_AudioDevice *this = (SDL_AudioDevice *)data;
SDL_bool dead = SDL_FALSE; 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). */ /* macOS calls this when the default device changed (if we have a default device open). */
static OSStatus static OSStatus default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *inUserData)
default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *inUserData)
{ {
SDL_AudioDevice *this = (SDL_AudioDevice *)inUserData; SDL_AudioDevice *this = (SDL_AudioDevice *)inUserData;
#if DEBUG_COREAUDIO #if DEBUG_COREAUDIO
@@ -685,8 +664,7 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
} }
#endif #endif
static void static void COREAUDIO_CloseDevice(_THIS)
COREAUDIO_CloseDevice(_THIS)
{ {
const SDL_bool iscapture = this->iscapture; const SDL_bool iscapture = this->iscapture;
int i; int i;
@@ -748,8 +726,7 @@ COREAUDIO_CloseDevice(_THIS)
} }
#if MACOSX_COREAUDIO #if MACOSX_COREAUDIO
static int static int prepare_device(_THIS)
prepare_device(_THIS)
{ {
void *handle = this->handle; void *handle = this->handle;
SDL_bool iscapture = this->iscapture; SDL_bool iscapture = this->iscapture;
@@ -768,21 +745,18 @@ prepare_device(_THIS)
if (handle == NULL) { if (handle == NULL) {
size = sizeof(AudioDeviceID); size = sizeof(AudioDeviceID);
addr.mSelector = addr.mSelector =
((iscapture) ? kAudioHardwarePropertyDefaultInputDevice : ((iscapture) ? kAudioHardwarePropertyDefaultInputDevice : kAudioHardwarePropertyDefaultOutputDevice);
kAudioHardwarePropertyDefaultOutputDevice);
result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
0, NULL, &size, &devid); 0, NULL, &size, &devid);
CHECK_RESULT("AudioHardwareGetProperty (default device)"); CHECK_RESULT("AudioHardwareGetProperty (default device)");
} }
addr.mSelector = kAudioDevicePropertyDeviceIsAlive; addr.mSelector = kAudioDevicePropertyDeviceIsAlive;
addr.mScope = iscapture ? kAudioDevicePropertyScopeInput : addr.mScope = iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
kAudioDevicePropertyScopeOutput;
size = sizeof(alive); size = sizeof(alive);
result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &alive); result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &alive);
CHECK_RESULT CHECK_RESULT("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)");
("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)");
if (!alive) { if (!alive) {
SDL_SetError("CoreAudio: requested device exists, but isn't alive."); SDL_SetError("CoreAudio: requested device exists, but isn't alive.");
@@ -803,8 +777,7 @@ prepare_device(_THIS)
return 1; return 1;
} }
static int static int assign_device_to_audioqueue(_THIS)
assign_device_to_audioqueue(_THIS)
{ {
const AudioObjectPropertyAddress prop = { const AudioObjectPropertyAddress prop = {
kAudioDevicePropertyDeviceUID, kAudioDevicePropertyDeviceUID,
@@ -824,8 +797,7 @@ assign_device_to_audioqueue(_THIS)
} }
#endif #endif
static int static int prepare_audioqueue(_THIS)
prepare_audioqueue(_THIS)
{ {
const AudioStreamBasicDescription *strdesc = &this->hidden->strdesc; const AudioStreamBasicDescription *strdesc = &this->hidden->strdesc;
const int iscapture = this->iscapture; const int iscapture = this->iscapture;
@@ -833,7 +805,8 @@ prepare_audioqueue(_THIS)
int i, numAudioBuffers = 2; int i, numAudioBuffers = 2;
AudioChannelLayout layout; AudioChannelLayout layout;
double MINIMUM_AUDIO_BUFFER_TIME_MS; 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); SDL_assert(CFRunLoopGetCurrent() != NULL);
@@ -948,8 +921,7 @@ prepare_audioqueue(_THIS)
return 1; return 1;
} }
static int static int audioqueue_thread(void *arg)
audioqueue_thread(void *arg)
{ {
SDL_AudioDevice *this = (SDL_AudioDevice *)arg; SDL_AudioDevice *this = (SDL_AudioDevice *)arg;
int rc; int rc;
@@ -1025,8 +997,7 @@ audioqueue_thread(void *arg)
return 0; return 0;
} }
static int static int COREAUDIO_OpenDevice(_THIS, const char *devname)
COREAUDIO_OpenDevice(_THIS, const char *devname)
{ {
AudioStreamBasicDescription *strdesc; AudioStreamBasicDescription *strdesc;
SDL_AudioFormat test_format; SDL_AudioFormat test_format;
@@ -1151,8 +1122,7 @@ COREAUDIO_OpenDevice(_THIS, const char *devname)
} }
#if !MACOSX_COREAUDIO #if !MACOSX_COREAUDIO
static int static int COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
{ {
AVAudioSession *session = [AVAudioSession sharedInstance]; AVAudioSession *session = [AVAudioSession sharedInstance];
@@ -1165,8 +1135,7 @@ COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
return 0; return 0;
} }
#else /* MACOSX_COREAUDIO */ #else /* MACOSX_COREAUDIO */
static int static int COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
{ {
AudioDeviceID devid; AudioDeviceID devid;
AudioBufferList *buflist; AudioBufferList *buflist;
@@ -1286,8 +1255,7 @@ COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
} }
#endif /* MACOSX_COREAUDIO */ #endif /* MACOSX_COREAUDIO */
static void static void COREAUDIO_Deinitialize(void)
COREAUDIO_Deinitialize(void)
{ {
#if MACOSX_COREAUDIO #if MACOSX_COREAUDIO
AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &devlist_address, device_list_changed, NULL); AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &devlist_address, device_list_changed, NULL);
@@ -1296,8 +1264,7 @@ COREAUDIO_Deinitialize(void)
#endif #endif
} }
static SDL_bool static SDL_bool COREAUDIO_Init(SDL_AudioDriverImpl *impl)
COREAUDIO_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = COREAUDIO_OpenDevice; impl->OpenDevice = COREAUDIO_OpenDevice;
+24 -46
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_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 const GUID SDL_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = { 0x00000003, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } };
static void static void DSOUND_Unload(void)
DSOUND_Unload(void)
{ {
pDirectSoundCreate8 = NULL; pDirectSoundCreate8 = NULL;
pDirectSoundEnumerateW = NULL; pDirectSoundEnumerateW = NULL;
@@ -68,9 +67,7 @@ DSOUND_Unload(void)
} }
} }
static int DSOUND_Load(void)
static int
DSOUND_Load(void)
{ {
int loaded = 0; int loaded = 0;
@@ -81,9 +78,11 @@ DSOUND_Load(void)
SDL_SetError("DirectSound: failed to load DSOUND.DLL"); SDL_SetError("DirectSound: failed to load DSOUND.DLL");
} else { } else {
/* Now make sure we have DirectX 8 or better... */ /* Now make sure we have DirectX 8 or better... */
#define DSOUNDLOAD(f) { \ #define DSOUNDLOAD(f) \
{ \
p##f = (fn##f)SDL_LoadFunction(DSoundDLL, #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. */ loaded = 1; /* will reset if necessary. */
DSOUNDLOAD(DirectSoundCreate8); DSOUNDLOAD(DirectSoundCreate8);
@@ -104,8 +103,7 @@ DSOUND_Load(void)
return loaded; return loaded;
} }
static int static int SetDSerror(const char *function, int code)
SetDSerror(const char *function, int code)
{ {
const char *error; const char *error;
@@ -151,14 +149,12 @@ SetDSerror(const char *function, int code)
return SDL_SetError("%s: %s (0x%x)", function, error, code); return SDL_SetError("%s: %s (0x%x)", function, error, code);
} }
static void static void DSOUND_FreeDeviceHandle(void *handle)
DSOUND_FreeDeviceHandle(void *handle)
{ {
SDL_free(handle); SDL_free(handle);
} }
static int static int DSOUND_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
DSOUND_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
{ {
#if HAVE_MMDEVICEAPI_H #if HAVE_MMDEVICEAPI_H
if (SupportsIMMDevice) { if (SupportsIMMDevice) {
@@ -168,8 +164,7 @@ DSOUND_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
return SDL_Unsupported(); return SDL_Unsupported();
} }
static BOOL CALLBACK static BOOL CALLBACK FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data)
FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data)
{ {
const int iscapture = (int)((size_t)data); const int iscapture = (int)((size_t)data);
if (guid != NULL) { /* skip default device */ if (guid != NULL) { /* skip default device */
@@ -189,8 +184,7 @@ FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data)
return TRUE; /* keep enumerating. */ return TRUE; /* keep enumerating. */
} }
static void static void DSOUND_DetectDevices(void)
DSOUND_DetectDevices(void)
{ {
#if HAVE_MMDEVICEAPI_H #if HAVE_MMDEVICEAPI_H
if (SupportsIMMDevice) { if (SupportsIMMDevice) {
@@ -204,9 +198,7 @@ DSOUND_DetectDevices(void)
#endif /* HAVE_MMDEVICEAPI_H*/ #endif /* HAVE_MMDEVICEAPI_H*/
} }
static void DSOUND_WaitDevice(_THIS)
static void
DSOUND_WaitDevice(_THIS)
{ {
DWORD status = 0; DWORD status = 0;
DWORD cursor = 0; DWORD cursor = 0;
@@ -263,8 +255,7 @@ DSOUND_WaitDevice(_THIS)
} }
} }
static void static void DSOUND_PlayDevice(_THIS)
DSOUND_PlayDevice(_THIS)
{ {
/* Unlock the buffer, allowing it to play */ /* Unlock the buffer, allowing it to play */
if (this->hidden->locked_buf) { if (this->hidden->locked_buf) {
@@ -274,8 +265,7 @@ DSOUND_PlayDevice(_THIS)
} }
} }
static Uint8 * static Uint8 *DSOUND_GetDeviceBuf(_THIS)
DSOUND_GetDeviceBuf(_THIS)
{ {
DWORD cursor = 0; DWORD cursor = 0;
DWORD junk = 0; DWORD junk = 0;
@@ -322,8 +312,7 @@ DSOUND_GetDeviceBuf(_THIS)
IDirectSoundBuffer_Restore(this->hidden->mixbuf); IDirectSoundBuffer_Restore(this->hidden->mixbuf);
result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor, result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor,
this->spec.size, this->spec.size,
(LPVOID *) & this-> (LPVOID *)&this->hidden->locked_buf, &rawlen, NULL,
hidden->locked_buf, &rawlen, NULL,
&junk, 0); &junk, 0);
} }
if (result != DS_OK) { if (result != DS_OK) {
@@ -333,8 +322,7 @@ DSOUND_GetDeviceBuf(_THIS)
return this->hidden->locked_buf; return this->hidden->locked_buf;
} }
static int static int DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen)
DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen)
{ {
struct SDL_PrivateAudioData *h = this->hidden; struct SDL_PrivateAudioData *h = this->hidden;
DWORD junk, cursor, ptr1len, ptr2len; DWORD junk, cursor, ptr1len, ptr2len;
@@ -377,8 +365,7 @@ DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen)
return ptr1len; return ptr1len;
} }
static void static void DSOUND_FlushCapture(_THIS)
DSOUND_FlushCapture(_THIS)
{ {
struct SDL_PrivateAudioData *h = this->hidden; struct SDL_PrivateAudioData *h = this->hidden;
DWORD junk, cursor; DWORD junk, cursor;
@@ -387,8 +374,7 @@ DSOUND_FlushCapture(_THIS)
} }
} }
static void static void DSOUND_CloseDevice(_THIS)
DSOUND_CloseDevice(_THIS)
{ {
if (this->hidden->mixbuf != NULL) { if (this->hidden->mixbuf != NULL) {
IDirectSoundBuffer_Stop(this->hidden->mixbuf); IDirectSoundBuffer_Stop(this->hidden->mixbuf);
@@ -411,8 +397,7 @@ DSOUND_CloseDevice(_THIS)
number of audio chunks available in the created buffer. This is for number of audio chunks available in the created buffer. This is for
playback devices, not capture. playback devices, not capture.
*/ */
static int static int CreateSecondary(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt)
CreateSecondary(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt)
{ {
LPDIRECTSOUND sndObj = this->hidden->sound; LPDIRECTSOUND sndObj = this->hidden->sound;
LPDIRECTSOUNDBUFFER *sndbuf = &this->hidden->mixbuf; 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 number of audio chunks available in the created buffer. This is for
capture devices, not playback. capture devices, not playback.
*/ */
static int static int CreateCaptureBuffer(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt)
CreateCaptureBuffer(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt)
{ {
LPDIRECTSOUNDCAPTURE capture = this->hidden->capture; LPDIRECTSOUNDCAPTURE capture = this->hidden->capture;
LPDIRECTSOUNDCAPTUREBUFFER *capturebuf = &this->hidden->capturebuf; LPDIRECTSOUNDCAPTUREBUFFER *capturebuf = &this->hidden->capturebuf;
@@ -494,8 +478,7 @@ CreateCaptureBuffer(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt)
return 0; return 0;
} }
static int static int DSOUND_OpenDevice(_THIS, const char *devname)
DSOUND_OpenDevice(_THIS, const char *devname)
{ {
const DWORD numchunks = 8; const DWORD numchunks = 8;
HRESULT result; HRESULT result;
@@ -565,8 +548,7 @@ DSOUND_OpenDevice(_THIS, const char *devname)
} }
wfmt.Samples.wValidBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format); wfmt.Samples.wValidBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
switch (this->spec.channels) switch (this->spec.channels) {
{
case 3: /* 3.0 (or 2.1) */ case 3: /* 3.0 (or 2.1) */
wfmt.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER; wfmt.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER;
break; break;
@@ -626,9 +608,7 @@ DSOUND_OpenDevice(_THIS, const char *devname)
return 0; /* good to go. */ return 0; /* good to go. */
} }
static void DSOUND_Deinitialize(void)
static void
DSOUND_Deinitialize(void)
{ {
#if HAVE_MMDEVICEAPI_H #if HAVE_MMDEVICEAPI_H
if (SupportsIMMDevice) { if (SupportsIMMDevice) {
@@ -639,9 +619,7 @@ DSOUND_Deinitialize(void)
DSOUND_Unload(); DSOUND_Unload();
} }
static SDL_bool DSOUND_Init(SDL_AudioDriverImpl *impl)
static SDL_bool
DSOUND_Init(SDL_AudioDriverImpl * impl)
{ {
if (!DSOUND_Load()) { if (!DSOUND_Load()) {
return SDL_FALSE; return SDL_FALSE;
+10 -22
View File
@@ -40,14 +40,12 @@
#define DISKENVR_IODELAY "SDL_DISKAUDIODELAY" #define DISKENVR_IODELAY "SDL_DISKAUDIODELAY"
/* This function waits until it is possible to write a full sound buffer */ /* This function waits until it is possible to write a full sound buffer */
static void static void DISKAUDIO_WaitDevice(_THIS)
DISKAUDIO_WaitDevice(_THIS)
{ {
SDL_Delay(_this->hidden->io_delay); SDL_Delay(_this->hidden->io_delay);
} }
static void static void DISKAUDIO_PlayDevice(_THIS)
DISKAUDIO_PlayDevice(_THIS)
{ {
const size_t written = SDL_RWwrite(_this->hidden->io, const size_t written = SDL_RWwrite(_this->hidden->io,
_this->hidden->mixbuf, _this->hidden->mixbuf,
@@ -62,14 +60,12 @@ DISKAUDIO_PlayDevice(_THIS)
#endif #endif
} }
static Uint8 * static Uint8 *DISKAUDIO_GetDeviceBuf(_THIS)
DISKAUDIO_GetDeviceBuf(_THIS)
{ {
return _this->hidden->mixbuf; return _this->hidden->mixbuf;
} }
static int static int DISKAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
DISKAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
{ {
struct SDL_PrivateAudioData *h = _this->hidden; struct SDL_PrivateAudioData *h = _this->hidden;
const int origbuflen = buflen; const int origbuflen = buflen;
@@ -92,15 +88,12 @@ DISKAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
return origbuflen; return origbuflen;
} }
static void static void DISKAUDIO_FlushCapture(_THIS)
DISKAUDIO_FlushCapture(_THIS)
{ {
/* no op...we don't advance the file pointer or anything. */ /* 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) { if (_this->hidden->io != NULL) {
SDL_RWclose(_this->hidden->io); SDL_RWclose(_this->hidden->io);
@@ -109,9 +102,7 @@ DISKAUDIO_CloseDevice(_THIS)
SDL_free(_this->hidden); 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) { if (devname == NULL) {
devname = SDL_getenv(iscapture ? DISKENVR_INFILE : DISKENVR_OUTFILE); devname = SDL_getenv(iscapture ? DISKENVR_INFILE : DISKENVR_OUTFILE);
@@ -122,8 +113,7 @@ get_filename(const SDL_bool iscapture, const char *devname)
return devname; return devname;
} }
static int static int DISKAUDIO_OpenDevice(_THIS, const char *devname)
DISKAUDIO_OpenDevice(_THIS, const char *devname)
{ {
void *handle = _this->handle; void *handle = _this->handle;
/* handle != NULL means "user specified the placeholder name on the fake detected device list" */ /* 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; return 0;
} }
static void static void DISKAUDIO_DetectDevices(void)
DISKAUDIO_DetectDevices(void)
{ {
SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *)0x1); SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *)0x1);
SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *)0x2); SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *)0x2);
} }
static SDL_bool static SDL_bool DISKAUDIO_Init(SDL_AudioDriverImpl *impl)
DISKAUDIO_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = DISKAUDIO_OpenDevice; impl->OpenDevice = DISKAUDIO_OpenDevice;
+11 -24
View File
@@ -40,16 +40,12 @@
#include "../SDL_audiodev_c.h" #include "../SDL_audiodev_c.h"
#include "SDL_dspaudio.h" #include "SDL_dspaudio.h"
static void DSP_DetectDevices(void)
static void
DSP_DetectDevices(void)
{ {
SDL_EnumUnixAudioDevices(0, NULL); SDL_EnumUnixAudioDevices(0, NULL);
} }
static void DSP_CloseDevice(_THIS)
static void
DSP_CloseDevice(_THIS)
{ {
if (this->hidden->audio_fd >= 0) { if (this->hidden->audio_fd >= 0) {
close(this->hidden->audio_fd); close(this->hidden->audio_fd);
@@ -58,9 +54,7 @@ DSP_CloseDevice(_THIS)
SDL_free(this->hidden); 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; SDL_bool iscapture = this->iscapture;
const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT); const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
@@ -203,7 +197,8 @@ DSP_OpenDevice(_THIS, const char *devname)
SDL_CalculateAudioSpec(&this->spec); SDL_CalculateAudioSpec(&this->spec);
/* Determine the power of two of the fragment size */ /* 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) { if ((0x01U << frag_spec) != this->spec.size) {
return SDL_SetError("Fragment size must be a power of two"); return SDL_SetError("Fragment size must be a power of two");
} }
@@ -242,9 +237,7 @@ DSP_OpenDevice(_THIS, const char *devname)
return 0; return 0;
} }
static void DSP_PlayDevice(_THIS)
static void
DSP_PlayDevice(_THIS)
{ {
struct SDL_PrivateAudioData *h = this->hidden; struct SDL_PrivateAudioData *h = this->hidden;
if (write(h->audio_fd, h->mixbuf, h->mixlen) == -1) { if (write(h->audio_fd, h->mixbuf, h->mixlen) == -1) {
@@ -256,20 +249,17 @@ DSP_PlayDevice(_THIS)
#endif #endif
} }
static Uint8 * static Uint8 *DSP_GetDeviceBuf(_THIS)
DSP_GetDeviceBuf(_THIS)
{ {
return this->hidden->mixbuf; return this->hidden->mixbuf;
} }
static int static int DSP_CaptureFromDevice(_THIS, void *buffer, int buflen)
DSP_CaptureFromDevice(_THIS, void *buffer, int buflen)
{ {
return (int)read(this->hidden->audio_fd, buffer, buflen); return (int)read(this->hidden->audio_fd, buffer, buflen);
} }
static void static void DSP_FlushCapture(_THIS)
DSP_FlushCapture(_THIS)
{ {
struct SDL_PrivateAudioData *h = this->hidden; struct SDL_PrivateAudioData *h = this->hidden;
audio_buf_info info; audio_buf_info info;
@@ -287,16 +277,14 @@ DSP_FlushCapture(_THIS)
} }
static SDL_bool InitTimeDevicesExist = SDL_FALSE; static SDL_bool InitTimeDevicesExist = SDL_FALSE;
static int static int look_for_devices_test(int fd)
look_for_devices_test(int fd)
{ {
InitTimeDevicesExist = SDL_TRUE; /* note that _something_ exists. */ InitTimeDevicesExist = SDL_TRUE; /* note that _something_ exists. */
/* Don't add to the device list, we're just seeing if any devices exist. */ /* Don't add to the device list, we're just seeing if any devices exist. */
return 0; return 0;
} }
static SDL_bool static SDL_bool DSP_Init(SDL_AudioDriverImpl *impl)
DSP_Init(SDL_AudioDriverImpl * impl)
{ {
InitTimeDevicesExist = SDL_FALSE; InitTimeDevicesExist = SDL_FALSE;
SDL_EnumUnixAudioDevices(0, look_for_devices_test); SDL_EnumUnixAudioDevices(0, look_for_devices_test);
@@ -320,7 +308,6 @@ DSP_Init(SDL_AudioDriverImpl * impl)
return SDL_TRUE; /* this audio target is available. */ return SDL_TRUE; /* this audio target is available. */
} }
AudioBootStrap DSP_bootstrap = { AudioBootStrap DSP_bootstrap = {
"dsp", "OSS /dev/dsp standard audio", DSP_Init, SDL_FALSE "dsp", "OSS /dev/dsp standard audio", DSP_Init, SDL_FALSE
}; };
+4 -6
View File
@@ -25,15 +25,14 @@
#include "../SDL_audio_c.h" #include "../SDL_audio_c.h"
#include "SDL_dummyaudio.h" #include "SDL_dummyaudio.h"
static int static int DUMMYAUDIO_OpenDevice(_THIS, const char *devname)
DUMMYAUDIO_OpenDevice(_THIS, const char *devname)
{ {
_this->hidden = (void *)0x1; /* just something non-NULL */ _this->hidden = (void *)0x1; /* just something non-NULL */
return 0; /* always succeeds. */ return 0; /* always succeeds. */
} }
static int static int DUMMYAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
DUMMYAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
{ {
/* Delay to make this sort of simulate real audio input. */ /* Delay to make this sort of simulate real audio input. */
SDL_Delay((_this->spec.samples * 1000) / _this->spec.freq); SDL_Delay((_this->spec.samples * 1000) / _this->spec.freq);
@@ -43,8 +42,7 @@ DUMMYAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
return buflen; return buflen;
} }
static SDL_bool static SDL_bool DUMMYAUDIO_Init(SDL_AudioDriverImpl *impl)
DUMMYAUDIO_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = DUMMYAUDIO_OpenDevice; impl->OpenDevice = DUMMYAUDIO_OpenDevice;
+22 -15
View File
@@ -32,10 +32,10 @@
!!! FIXME: true always once pthread support becomes widespread. Revisit this code !!! FIXME: true always once pthread support becomes widespread. Revisit this code
!!! FIXME: at some point and see what needs to be done for that! */ !!! FIXME: at some point and see what needs to be done for that! */
static void static void FeedAudioDevice(_THIS, const void *buf, const int buflen)
FeedAudioDevice(_THIS, const void *buf, const int buflen)
{ {
const int framelen = (SDL_AUDIO_BITSIZE(this->spec.format) / 8) * this->spec.channels; const int framelen = (SDL_AUDIO_BITSIZE(this->spec.format) / 8) * this->spec.channels;
/* *INDENT-OFF* */ /* clang-format off */
MAIN_THREAD_EM_ASM({ MAIN_THREAD_EM_ASM({
var SDL3 = Module['SDL3']; var SDL3 = Module['SDL3'];
var numChannels = SDL3.audio.currentOutputBuffer['numberOfChannels']; var numChannels = SDL3.audio.currentOutputBuffer['numberOfChannels'];
@@ -50,10 +50,10 @@ FeedAudioDevice(_THIS, const void *buf, const int buflen)
} }
} }
}, buf, buflen / framelen); }, buf, buflen / framelen);
/* *INDENT-ON* */ /* clang-format on */
} }
static void static void HandleAudioProcess(_THIS)
HandleAudioProcess(_THIS)
{ {
SDL_AudioCallback callback = this->callbackspec.callback; SDL_AudioCallback callback = this->callbackspec.callback;
const int stream_len = this->callbackspec.size; const int stream_len = this->callbackspec.size;
@@ -93,8 +93,7 @@ HandleAudioProcess(_THIS)
FeedAudioDevice(this, this->work_buffer, this->spec.size); FeedAudioDevice(this, this->work_buffer, this->spec.size);
} }
static void static void HandleCaptureProcess(_THIS)
HandleCaptureProcess(_THIS)
{ {
SDL_AudioCallback callback = this->callbackspec.callback; SDL_AudioCallback callback = this->callbackspec.callback;
const int stream_len = this->callbackspec.size; const int stream_len = this->callbackspec.size;
@@ -105,6 +104,7 @@ HandleCaptureProcess(_THIS)
return; return;
} }
/* *INDENT-OFF* */ /* clang-format off */
MAIN_THREAD_EM_ASM({ MAIN_THREAD_EM_ASM({
var SDL3 = Module['SDL3']; var SDL3 = Module['SDL3'];
var numChannels = SDL3.capture.currentCaptureBuffer.numberOfChannels; var numChannels = SDL3.capture.currentCaptureBuffer.numberOfChannels;
@@ -125,6 +125,7 @@ HandleCaptureProcess(_THIS)
} }
} }
}, this->work_buffer, (this->spec.size / sizeof (float)) / this->spec.channels); }, 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. */ /* 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({ MAIN_THREAD_EM_ASM({
var SDL3 = Module['SDL3']; var SDL3 = Module['SDL3'];
if ($0) { if ($0) {
@@ -189,14 +189,14 @@ EMSCRIPTENAUDIO_CloseDevice(_THIS)
SDL3.audioContext = undefined; SDL3.audioContext = undefined;
} }
}, this->iscapture); }, this->iscapture);
/* *INDENT-ON* */ /* clang-format on */
#if 0 /* !!! FIXME: currently not used. Can we move some stuff off the SDL3 namespace? --ryan. */ #if 0 /* !!! FIXME: currently not used. Can we move some stuff off the SDL3 namespace? --ryan. */
SDL_free(this->hidden); SDL_free(this->hidden);
#endif #endif
} }
static int static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
{ {
SDL_AudioFormat test_format; SDL_AudioFormat test_format;
SDL_bool iscapture = this->iscapture; SDL_bool iscapture = this->iscapture;
@@ -204,6 +204,7 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
/* based on parts of library_sdl.js */ /* based on parts of library_sdl.js */
/* *INDENT-OFF* */ /* clang-format off */
/* create context */ /* create context */
result = MAIN_THREAD_EM_ASM_INT({ result = MAIN_THREAD_EM_ASM_INT({
if (typeof(Module['SDL3']) === 'undefined') { if (typeof(Module['SDL3']) === 'undefined') {
@@ -228,6 +229,8 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
} }
return SDL3.audioContext === undefined ? -1 : 0; return SDL3.audioContext === undefined ? -1 : 0;
}, iscapture); }, iscapture);
/* *INDENT-ON* */ /* clang-format on */
if (result < 0) { if (result < 0) {
return SDL_SetError("Web Audio API is not available!"); return SDL_SetError("Web Audio API is not available!");
} }
@@ -267,6 +270,7 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
SDL_CalculateAudioSpec(&this->spec); SDL_CalculateAudioSpec(&this->spec);
/* *INDENT-OFF* */ /* clang-format off */
if (iscapture) { if (iscapture) {
/* The idea is to take the capture media stream, hook it up to an /* The idea is to take the capture media stream, hook it up to an
audio graph where we can pass it through a ScriptProcessorNode 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']); SDL3.audio.scriptProcessorNode['connect'](SDL3.audioContext['destination']);
}, this->spec.channels, this->spec.samples, HandleAudioProcess, this); }, this->spec.channels, this->spec.samples, HandleAudioProcess, this);
} }
/* *INDENT-ON* */ /* clang-format on */
return 0; return 0;
} }
static void static void EMSCRIPTENAUDIO_LockOrUnlockDeviceWithNoMixerLock(SDL_AudioDevice *device)
EMSCRIPTENAUDIO_LockOrUnlockDeviceWithNoMixerLock(SDL_AudioDevice * device)
{ {
} }
static SDL_bool static SDL_bool EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl *impl)
EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl * impl)
{ {
SDL_bool available, capture_available; SDL_bool available, capture_available;
@@ -362,6 +365,7 @@ EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl * impl)
impl->LockDevice = impl->UnlockDevice = EMSCRIPTENAUDIO_LockOrUnlockDeviceWithNoMixerLock; impl->LockDevice = impl->UnlockDevice = EMSCRIPTENAUDIO_LockOrUnlockDeviceWithNoMixerLock;
impl->ProvidesOwnCallbackThread = SDL_TRUE; impl->ProvidesOwnCallbackThread = SDL_TRUE;
/* *INDENT-OFF* */ /* clang-format off */
/* check availability */ /* check availability */
available = MAIN_THREAD_EM_ASM_INT({ available = MAIN_THREAD_EM_ASM_INT({
if (typeof(AudioContext) !== 'undefined') { if (typeof(AudioContext) !== 'undefined') {
@@ -371,11 +375,13 @@ EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl * impl)
} }
return false; return false;
}); });
/* *INDENT-ON* */ /* clang-format on */
if (!available) { if (!available) {
SDL_SetError("No audio context available"); SDL_SetError("No audio context available");
} }
/* *INDENT-OFF* */ /* clang-format off */
capture_available = available && MAIN_THREAD_EM_ASM_INT({ capture_available = available && MAIN_THREAD_EM_ASM_INT({
if ((typeof(navigator.mediaDevices) !== 'undefined') && (typeof(navigator.mediaDevices.getUserMedia) !== 'undefined')) { if ((typeof(navigator.mediaDevices) !== 'undefined') && (typeof(navigator.mediaDevices.getUserMedia) !== 'undefined')) {
return true; return true;
@@ -384,6 +390,7 @@ EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl * impl)
} }
return false; return false;
}); });
/* *INDENT-ON* */ /* clang-format on */
impl->HasCaptureSupport = capture_available ? SDL_TRUE : SDL_FALSE; impl->HasCaptureSupport = capture_available ? SDL_TRUE : SDL_FALSE;
impl->OnlyHasDefaultCaptureDevice = capture_available ? SDL_TRUE : SDL_FALSE; impl->OnlyHasDefaultCaptureDevice = capture_available ? SDL_TRUE : SDL_FALSE;
+7 -14
View File
@@ -41,8 +41,7 @@ extern "C"
/* !!! FIXME: have the callback call the higher level to avoid code dupe. */ /* !!! FIXME: have the callback call the higher level to avoid code dupe. */
/* The Haiku callback for handling the audio buffer */ /* The Haiku callback for handling the audio buffer */
static void static void FillSound(void *device, void *stream, size_t len,
FillSound(void *device, void *stream, size_t len,
const media_raw_audio_format & format) const media_raw_audio_format & format)
{ {
SDL_AudioDevice *audio = (SDL_AudioDevice *) device; SDL_AudioDevice *audio = (SDL_AudioDevice *) device;
@@ -84,8 +83,7 @@ FillSound(void *device, void *stream, size_t len,
SDL_UnlockMutex(audio->mixer_lock); SDL_UnlockMutex(audio->mixer_lock);
} }
static void static void HAIKUAUDIO_CloseDevice(_THIS)
HAIKUAUDIO_CloseDevice(_THIS)
{ {
if (_this->hidden->audio_obj) { if (_this->hidden->audio_obj) {
_this->hidden->audio_obj->Stop(); _this->hidden->audio_obj->Stop();
@@ -99,8 +97,7 @@ static const int sig_list[] = {
SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGWINCH, 0 SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGWINCH, 0
}; };
static inline void static inline void MaskSignals(sigset_t * omask)
MaskSignals(sigset_t * omask)
{ {
sigset_t mask; sigset_t mask;
int i; int i;
@@ -112,15 +109,13 @@ MaskSignals(sigset_t * omask)
sigprocmask(SIG_BLOCK, &mask, omask); sigprocmask(SIG_BLOCK, &mask, omask);
} }
static inline void static inline void UnmaskSignals(sigset_t * omask)
UnmaskSignals(sigset_t * omask)
{ {
sigprocmask(SIG_SETMASK, omask, NULL); sigprocmask(SIG_SETMASK, omask, NULL);
} }
static int static int HAIKUAUDIO_OpenDevice(_THIS, const char *devname)
HAIKUAUDIO_OpenDevice(_THIS, const char *devname)
{ {
media_raw_audio_format format; media_raw_audio_format format;
SDL_AudioFormat test_format; SDL_AudioFormat test_format;
@@ -207,14 +202,12 @@ HAIKUAUDIO_OpenDevice(_THIS, const char *devname)
return 0; return 0;
} }
static void static void HAIKUAUDIO_Deinitialize(void)
HAIKUAUDIO_Deinitialize(void)
{ {
SDL_QuitBeApp(); SDL_QuitBeApp();
} }
static SDL_bool static SDL_bool HAIKUAUDIO_Init(SDL_AudioDriverImpl * impl)
HAIKUAUDIO_Init(SDL_AudioDriverImpl * impl)
{ {
/* Initialize the Be Application, if it's not already started */ /* Initialize the Be Application, if it's not already started */
if (SDL_InitBeApp() < 0) { if (SDL_InitBeApp() < 0) {
+21 -45
View File
@@ -26,7 +26,6 @@
#include "SDL_jackaudio.h" #include "SDL_jackaudio.h"
#include "../../thread/SDL_systhread.h" #include "../../thread/SDL_systhread.h"
static jack_client_t *(*JACK_jack_client_open)(const char *, jack_options_t, jack_status_t *, ...); 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 int (*JACK_jack_client_close)(jack_client_t *);
static void (*JACK_jack_on_shutdown)(jack_client_t *, JackShutdownCallback, void *); 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); static int load_jack_syms(void);
#ifdef SDL_AUDIO_DRIVER_JACK_DYNAMIC #ifdef SDL_AUDIO_DRIVER_JACK_DYNAMIC
static const char *jack_library = SDL_AUDIO_DRIVER_JACK_DYNAMIC; static const char *jack_library = SDL_AUDIO_DRIVER_JACK_DYNAMIC;
static void *jack_handle = NULL; static void *jack_handle = NULL;
/* !!! FIXME: this is copy/pasted in several places now */ /* !!! FIXME: this is copy/pasted in several places now */
static int static int load_jack_sym(const char *fn, void **addr)
load_jack_sym(const char *fn, void **addr)
{ {
*addr = SDL_LoadFunction(jack_handle, fn); *addr = SDL_LoadFunction(jack_handle, fn);
if (*addr == NULL) { 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. */ /* cast funcs to char* first, to please GCC's strict aliasing rules. */
#define SDL_JACK_SYM(x) \ #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 static void UnloadJackLibrary(void)
UnloadJackLibrary(void)
{ {
if (jack_handle != NULL) { if (jack_handle != NULL) {
SDL_UnloadObject(jack_handle); SDL_UnloadObject(jack_handle);
@@ -79,8 +76,7 @@ UnloadJackLibrary(void)
} }
} }
static int static int LoadJackLibrary(void)
LoadJackLibrary(void)
{ {
int retval = 0; int retval = 0;
if (jack_handle == NULL) { if (jack_handle == NULL) {
@@ -102,13 +98,11 @@ LoadJackLibrary(void)
#define SDL_JACK_SYM(x) JACK_##x = x #define SDL_JACK_SYM(x) JACK_##x = x
static void static void UnloadJackLibrary(void)
UnloadJackLibrary(void)
{ {
} }
static int static int LoadJackLibrary(void)
LoadJackLibrary(void)
{ {
load_jack_syms(); load_jack_syms();
return 0; return 0;
@@ -116,9 +110,7 @@ LoadJackLibrary(void)
#endif /* SDL_AUDIO_DRIVER_JACK_DYNAMIC */ #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_open);
SDL_JACK_SYM(jack_client_close); SDL_JACK_SYM(jack_client_close);
@@ -140,9 +132,7 @@ load_jack_syms(void)
return 0; 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_AudioDevice *this = (SDL_AudioDevice *)arg;
SDL_OpenedAudioDeviceDisconnected(this); 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(* JackSampleRateCallback)(jack_nframes_t nframes, void *arg)
// typedef int(* JackBufferSizeCallback)(jack_nframes_t nframes, void *arg) // typedef int(* JackBufferSizeCallback)(jack_nframes_t nframes, void *arg)
static int static int jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg)
jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg)
{ {
SDL_AudioDevice *this = (SDL_AudioDevice *)arg; SDL_AudioDevice *this = (SDL_AudioDevice *)arg;
jack_port_t **ports = this->hidden->sdlports; 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. */ 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 */ /* This function waits until it is possible to write a full sound buffer */
static void static void JACK_WaitDevice(_THIS)
JACK_WaitDevice(_THIS)
{ {
if (SDL_AtomicGet(&this->enabled)) { if (SDL_AtomicGet(&this->enabled)) {
if (SDL_SemWait(this->hidden->iosem) == -1) { if (SDL_SemWait(this->hidden->iosem) == -1) {
@@ -195,15 +182,12 @@ JACK_WaitDevice(_THIS)
} }
} }
static Uint8 * static Uint8 *JACK_GetDeviceBuf(_THIS)
JACK_GetDeviceBuf(_THIS)
{ {
return (Uint8 *)this->hidden->iobuffer; 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; SDL_AudioDevice *this = (SDL_AudioDevice *)arg;
if (SDL_AtomicGet(&this->enabled)) { 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! */ SDL_SemPost(this->hidden->iosem); /* tell SDL thread we're done; new buffer is ready! */
return 0; /* success */ return 0;
} }
static int static int JACK_CaptureFromDevice(_THIS, void *buffer, int buflen)
JACK_CaptureFromDevice(_THIS, void *buffer, int buflen)
{ {
SDL_assert(buflen == this->spec.size); /* we always fill a full buffer. */ 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; return buflen;
} }
static void static void JACK_FlushCapture(_THIS)
JACK_FlushCapture(_THIS)
{ {
SDL_SemWait(this->hidden->iosem); SDL_SemWait(this->hidden->iosem);
} }
static void JACK_CloseDevice(_THIS)
static void
JACK_CloseDevice(_THIS)
{ {
if (this->hidden->client) { if (this->hidden->client) {
JACK_jack_deactivate(this->hidden->client); JACK_jack_deactivate(this->hidden->client);
@@ -276,8 +256,7 @@ JACK_CloseDevice(_THIS)
SDL_free(this->hidden); SDL_free(this->hidden);
} }
static int static int JACK_OpenDevice(_THIS, const char *devname)
JACK_OpenDevice(_THIS, const char *devname)
{ {
/* Note that JACK uses "output" for capture devices (they output audio /* Note that JACK uses "output" for capture devices (they output audio
data to us) and "input" for playback (we input audio data to them). data to us) and "input" for playback (we input audio data to them).
@@ -333,7 +312,6 @@ JACK_OpenDevice(_THIS, const char *devname)
return SDL_SetError("No physical JACK ports available"); 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." */ /* !!! 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. */ /* Jack pretty much demands what it wants. */
@@ -397,14 +375,12 @@ JACK_OpenDevice(_THIS, const char *devname)
return 0; return 0;
} }
static void static void JACK_Deinitialize(void)
JACK_Deinitialize(void)
{ {
UnloadJackLibrary(); UnloadJackLibrary();
} }
static SDL_bool static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl)
JACK_Init(SDL_AudioDriverImpl * impl)
{ {
if (LoadJackLibrary() < 0) { if (LoadJackLibrary() < 0) {
return SDL_FALSE; return SDL_FALSE;
+16 -33
View File
@@ -22,7 +22,6 @@
#ifdef SDL_AUDIO_DRIVER_N3DS #ifdef SDL_AUDIO_DRIVER_N3DS
/* N3DS Audio driver */ /* N3DS Audio driver */
#include "../SDL_sysaudio.h" #include "../SDL_sysaudio.h"
@@ -36,32 +35,27 @@ static SDL_AudioDevice *audio_device;
static void FreePrivateData(_THIS); static void FreePrivateData(_THIS);
static int FindAudioFormat(_THIS); static int FindAudioFormat(_THIS);
static SDL_INLINE void static SDL_INLINE void contextLock(_THIS)
contextLock(_THIS)
{ {
LightLock_Lock(&this->hidden->lock); LightLock_Lock(&this->hidden->lock);
} }
static SDL_INLINE void static SDL_INLINE void contextUnlock(_THIS)
contextUnlock(_THIS)
{ {
LightLock_Unlock(&this->hidden->lock); LightLock_Unlock(&this->hidden->lock);
} }
static void static void N3DSAUD_LockAudio(_THIS)
N3DSAUD_LockAudio(_THIS)
{ {
contextLock(this); contextLock(this);
} }
static void static void N3DSAUD_UnlockAudio(_THIS)
N3DSAUD_UnlockAudio(_THIS)
{ {
contextUnlock(this); contextUnlock(this);
} }
static void static void N3DSAUD_DspHook(DSP_HookType hook)
N3DSAUD_DspHook(DSP_HookType hook)
{ {
if (hook == DSPHOOK_ONCANCEL) { if (hook == DSPHOOK_ONCANCEL) {
contextLock(audio_device); contextLock(audio_device);
@@ -72,8 +66,7 @@ N3DSAUD_DspHook(DSP_HookType hook)
} }
} }
static void static void AudioFrameFinished(void *device)
AudioFrameFinished(void *device)
{ {
bool shouldBroadcast = false; bool shouldBroadcast = false;
unsigned i; unsigned i;
@@ -95,8 +88,7 @@ AudioFrameFinished(void *device)
contextUnlock(this); contextUnlock(this);
} }
static int static int N3DSAUDIO_OpenDevice(_THIS, const char *devname)
N3DSAUDIO_OpenDevice(_THIS, const char *devname)
{ {
Result ndsp_init_res; Result ndsp_init_res;
Uint8 *data_vaddr; Uint8 *data_vaddr;
@@ -186,8 +178,7 @@ N3DSAUDIO_OpenDevice(_THIS, const char *devname)
return 0; return 0;
} }
static int static int N3DSAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
N3DSAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
{ {
/* Delay to make this sort of simulate real audio input. */ /* Delay to make this sort of simulate real audio input. */
SDL_Delay((this->spec.samples * 1000) / this->spec.freq); SDL_Delay((this->spec.samples * 1000) / this->spec.freq);
@@ -197,8 +188,7 @@ N3DSAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
return buflen; return buflen;
} }
static void static void N3DSAUDIO_PlayDevice(_THIS)
N3DSAUDIO_PlayDevice(_THIS)
{ {
size_t nextbuf; size_t nextbuf;
size_t sampleLen; size_t sampleLen;
@@ -224,8 +214,7 @@ N3DSAUDIO_PlayDevice(_THIS)
ndspChnWaveBufAdd(0, &this->hidden->waveBuf[nextbuf]); ndspChnWaveBufAdd(0, &this->hidden->waveBuf[nextbuf]);
} }
static void static void N3DSAUDIO_WaitDevice(_THIS)
N3DSAUDIO_WaitDevice(_THIS)
{ {
contextLock(this); contextLock(this);
while (!this->hidden->isCancelled && while (!this->hidden->isCancelled &&
@@ -235,14 +224,12 @@ N3DSAUDIO_WaitDevice(_THIS)
contextUnlock(this); contextUnlock(this);
} }
static Uint8 * static Uint8 *N3DSAUDIO_GetDeviceBuf(_THIS)
N3DSAUDIO_GetDeviceBuf(_THIS)
{ {
return this->hidden->mixbuf; return this->hidden->mixbuf;
} }
static void static void N3DSAUDIO_CloseDevice(_THIS)
N3DSAUDIO_CloseDevice(_THIS)
{ {
contextLock(this); contextLock(this);
@@ -262,8 +249,7 @@ N3DSAUDIO_CloseDevice(_THIS)
FreePrivateData(this); FreePrivateData(this);
} }
static void static void N3DSAUDIO_ThreadInit(_THIS)
N3DSAUDIO_ThreadInit(_THIS)
{ {
s32 current_priority; s32 current_priority;
svcGetThreadPriority(&current_priority, CUR_THREAD_HANDLE); svcGetThreadPriority(&current_priority, CUR_THREAD_HANDLE);
@@ -273,8 +259,7 @@ N3DSAUDIO_ThreadInit(_THIS)
svcSetThreadPriority(CUR_THREAD_HANDLE, current_priority); svcSetThreadPriority(CUR_THREAD_HANDLE, current_priority);
} }
static SDL_bool static SDL_bool N3DSAUDIO_Init(SDL_AudioDriverImpl *impl)
N3DSAUDIO_Init(SDL_AudioDriverImpl *impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = N3DSAUDIO_OpenDevice; impl->OpenDevice = N3DSAUDIO_OpenDevice;
@@ -304,8 +289,7 @@ AudioBootStrap N3DSAUDIO_bootstrap = {
/** /**
* Cleans up all allocated memory, safe to call with null pointers * Cleans up all allocated memory, safe to call with null pointers
*/ */
static void static void FreePrivateData(_THIS)
FreePrivateData(_THIS)
{ {
if (!this->hidden) { if (!this->hidden) {
return; return;
@@ -324,8 +308,7 @@ FreePrivateData(_THIS)
this->hidden = NULL; this->hidden = NULL;
} }
static int static int FindAudioFormat(_THIS)
FindAudioFormat(_THIS)
{ {
SDL_bool found_valid_format = SDL_FALSE; SDL_bool found_valid_format = SDL_FALSE;
Uint16 test_format = SDL_FirstAudioFormat(this->spec.format); Uint16 test_format = SDL_FirstAudioFormat(this->spec.format);
+11 -24
View File
@@ -43,15 +43,12 @@
/* #define DEBUG_AUDIO */ /* #define DEBUG_AUDIO */
static void static void NETBSDAUDIO_DetectDevices(void)
NETBSDAUDIO_DetectDevices(void)
{ {
SDL_EnumUnixAudioDevices(0, NULL); SDL_EnumUnixAudioDevices(0, NULL);
} }
static void NETBSDAUDIO_Status(_THIS)
static void
NETBSDAUDIO_Status(_THIS)
{ {
#ifdef DEBUG_AUDIO #ifdef DEBUG_AUDIO
/* *INDENT-OFF* */ /* clang-format off */ /* *INDENT-OFF* */ /* clang-format off */
@@ -117,12 +114,11 @@ NETBSDAUDIO_Status(_THIS)
this->spec.format, this->spec.format,
this->spec.size); this->spec.size);
/* *INDENT-ON* */ /* clang-format on */ /* *INDENT-ON* */ /* clang-format on */
#endif /* DEBUG_AUDIO */ #endif /* DEBUG_AUDIO */
} }
static void NETBSDAUDIO_PlayDevice(_THIS)
static void
NETBSDAUDIO_PlayDevice(_THIS)
{ {
struct SDL_PrivateAudioData *h = this->hidden; struct SDL_PrivateAudioData *h = this->hidden;
int written; int written;
@@ -141,15 +137,12 @@ NETBSDAUDIO_PlayDevice(_THIS)
#endif #endif
} }
static Uint8 * static Uint8 *NETBSDAUDIO_GetDeviceBuf(_THIS)
NETBSDAUDIO_GetDeviceBuf(_THIS)
{ {
return this->hidden->mixbuf; 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; Uint8 *buffer = (Uint8 *)_buffer;
int br; int br;
@@ -167,8 +160,7 @@ NETBSDAUDIO_CaptureFromDevice(_THIS, void *_buffer, int buflen)
return 0; return 0;
} }
static void static void NETBSDAUDIO_FlushCapture(_THIS)
NETBSDAUDIO_FlushCapture(_THIS)
{ {
audio_info_t info; audio_info_t info;
size_t remain; size_t remain;
@@ -189,8 +181,7 @@ NETBSDAUDIO_FlushCapture(_THIS)
} }
} }
static void static void NETBSDAUDIO_CloseDevice(_THIS)
NETBSDAUDIO_CloseDevice(_THIS)
{ {
if (this->hidden->audio_fd >= 0) { if (this->hidden->audio_fd >= 0) {
close(this->hidden->audio_fd); close(this->hidden->audio_fd);
@@ -199,8 +190,7 @@ NETBSDAUDIO_CloseDevice(_THIS)
SDL_free(this->hidden); SDL_free(this->hidden);
} }
static int static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
{ {
SDL_bool iscapture = this->iscapture; SDL_bool iscapture = this->iscapture;
SDL_AudioFormat test_format; 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 * Use the device's native sample rate so the kernel doesn't have to
* resample. * resample.
*/ */
this->spec.freq = iscapture ? this->spec.freq = iscapture ? hwinfo.record.sample_rate : hwinfo.play.sample_rate;
hwinfo.record.sample_rate : hwinfo.play.sample_rate;
} }
#endif #endif
@@ -318,8 +307,7 @@ NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
return 0; return 0;
} }
static SDL_bool static SDL_bool NETBSDAUDIO_Init(SDL_AudioDriverImpl *impl)
NETBSDAUDIO_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->DetectDevices = NETBSDAUDIO_DetectDevices; impl->DetectDevices = NETBSDAUDIO_DetectDevices;
@@ -336,7 +324,6 @@ NETBSDAUDIO_Init(SDL_AudioDriverImpl * impl)
return SDL_TRUE; /* this audio target is available. */ return SDL_TRUE; /* this audio target is available. */
} }
AudioBootStrap NETBSDAUDIO_bootstrap = { AudioBootStrap NETBSDAUDIO_bootstrap = {
"netbsd", "NetBSD audio", NETBSDAUDIO_Init, SDL_FALSE "netbsd", "NetBSD audio", NETBSDAUDIO_Init, SDL_FALSE
}; };
+15 -31
View File
@@ -127,8 +127,7 @@ static void openslES_DestroyEngine(void)
} }
} }
static int static int openslES_CreateEngine(void)
openslES_CreateEngine(void)
{ {
const SLInterfaceID ids[1] = { SL_IID_VOLUME }; const SLInterfaceID ids[1] = { SL_IID_VOLUME };
const SLboolean req[1] = { SL_BOOLEAN_FALSE }; const SLboolean req[1] = { SL_BOOLEAN_FALSE };
@@ -182,8 +181,7 @@ error:
} }
/* this callback handler is called every time a buffer finishes recording */ /* this callback handler is called every time a buffer finishes recording */
static void static void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
{ {
struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context; struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context;
@@ -191,8 +189,7 @@ bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
SDL_SemPost(audiodata->playsem); SDL_SemPost(audiodata->playsem);
} }
static void static void openslES_DestroyPCMRecorder(_THIS)
openslES_DestroyPCMRecorder(_THIS)
{ {
struct SDL_PrivateAudioData *audiodata = this->hidden; struct SDL_PrivateAudioData *audiodata = this->hidden;
SLresult result; SLresult result;
@@ -223,8 +220,7 @@ openslES_DestroyPCMRecorder(_THIS)
} }
} }
static int static int openslES_CreatePCMRecorder(_THIS)
openslES_CreatePCMRecorder(_THIS)
{ {
struct SDL_PrivateAudioData *audiodata = this->hidden; struct SDL_PrivateAudioData *audiodata = this->hidden;
SLDataFormat_PCM format_pcm; SLDataFormat_PCM format_pcm;
@@ -362,8 +358,7 @@ failed:
} }
/* this callback handler is called every time a buffer finishes playing */ /* this callback handler is called every time a buffer finishes playing */
static void static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
{ {
struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context; struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context;
@@ -371,8 +366,7 @@ bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
SDL_SemPost(audiodata->playsem); SDL_SemPost(audiodata->playsem);
} }
static void static void openslES_DestroyPCMPlayer(_THIS)
openslES_DestroyPCMPlayer(_THIS)
{ {
struct SDL_PrivateAudioData *audiodata = this->hidden; struct SDL_PrivateAudioData *audiodata = this->hidden;
SLresult result; SLresult result;
@@ -404,8 +398,7 @@ openslES_DestroyPCMPlayer(_THIS)
} }
} }
static int static int openslES_CreatePCMPlayer(_THIS)
openslES_CreatePCMPlayer(_THIS)
{ {
struct SDL_PrivateAudioData *audiodata = this->hidden; struct SDL_PrivateAudioData *audiodata = this->hidden;
SLDataLocator_AndroidSimpleBufferQueue loc_bufq; SLDataLocator_AndroidSimpleBufferQueue loc_bufq;
@@ -465,8 +458,7 @@ openslES_CreatePCMPlayer(_THIS)
format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN; format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
} }
switch (this->spec.channels) switch (this->spec.channels) {
{
case 1: case 1:
format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT; format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT;
break; break;
@@ -595,8 +587,7 @@ failed:
return -1; return -1;
} }
static int static int openslES_OpenDevice(_THIS, const char *devname)
openslES_OpenDevice(_THIS, const char *devname)
{ {
this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, (sizeof *this->hidden)); this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, (sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
@@ -624,12 +615,10 @@ openslES_OpenDevice(_THIS, const char *devname)
} else { } else {
return SDL_SetError("Open device failed!"); return SDL_SetError("Open device failed!");
} }
} }
} }
static void static void openslES_WaitDevice(_THIS)
openslES_WaitDevice(_THIS)
{ {
struct SDL_PrivateAudioData *audiodata = this->hidden; struct SDL_PrivateAudioData *audiodata = this->hidden;
@@ -639,8 +628,7 @@ openslES_WaitDevice(_THIS)
SDL_SemWait(audiodata->playsem); SDL_SemWait(audiodata->playsem);
} }
static void static void openslES_PlayDevice(_THIS)
openslES_PlayDevice(_THIS)
{ {
struct SDL_PrivateAudioData *audiodata = this->hidden; struct SDL_PrivateAudioData *audiodata = this->hidden;
SLresult result; SLresult result;
@@ -674,8 +662,7 @@ openslES_PlayDevice(_THIS)
/* */ /* */
/* okay.. */ /* okay.. */
static Uint8 * static Uint8 *openslES_GetDeviceBuf(_THIS)
openslES_GetDeviceBuf(_THIS)
{ {
struct SDL_PrivateAudioData *audiodata = this->hidden; struct SDL_PrivateAudioData *audiodata = this->hidden;
@@ -683,8 +670,7 @@ openslES_GetDeviceBuf(_THIS)
return audiodata->pmixbuff[audiodata->next_buffer]; return audiodata->pmixbuff[audiodata->next_buffer];
} }
static int static int openslES_CaptureFromDevice(_THIS, void *buffer, int buflen)
openslES_CaptureFromDevice(_THIS, void *buffer, int buflen)
{ {
struct SDL_PrivateAudioData *audiodata = this->hidden; struct SDL_PrivateAudioData *audiodata = this->hidden;
SLresult result; SLresult result;
@@ -711,8 +697,7 @@ openslES_CaptureFromDevice(_THIS, void *buffer, int buflen)
return this->spec.size; return this->spec.size;
} }
static void static void openslES_CloseDevice(_THIS)
openslES_CloseDevice(_THIS)
{ {
/* struct SDL_PrivateAudioData *audiodata = this->hidden; */ /* struct SDL_PrivateAudioData *audiodata = this->hidden; */
@@ -727,8 +712,7 @@ openslES_CloseDevice(_THIS)
SDL_free(this->hidden); SDL_free(this->hidden);
} }
static SDL_bool static SDL_bool openslES_Init(SDL_AudioDriverImpl *impl)
openslES_Init(SDL_AudioDriverImpl * impl)
{ {
LOGI("openslES_Init() called"); LOGI("openslES_Init() called");
+41 -82
View File
@@ -123,8 +123,7 @@ static int pipewire_version_patch;
static const char *pipewire_library = SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC; static const char *pipewire_library = SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC;
static void *pipewire_handle = NULL; static void *pipewire_handle = NULL;
static int static int pipewire_dlsym(const char *fn, void **addr)
pipewire_dlsym(const char *fn, void **addr)
{ {
*addr = SDL_LoadFunction(pipewire_handle, fn); *addr = SDL_LoadFunction(pipewire_handle, fn);
if (*addr == NULL) { if (*addr == NULL) {
@@ -140,8 +139,7 @@ pipewire_dlsym(const char *fn, void **addr)
return -1; \ return -1; \
} }
static int static int load_pipewire_library()
load_pipewire_library()
{ {
if ((pipewire_handle = SDL_LoadObject(pipewire_library))) { if ((pipewire_handle = SDL_LoadObject(pipewire_library))) {
return 0; return 0;
@@ -150,8 +148,7 @@ load_pipewire_library()
return -1; return -1;
} }
static void static void unload_pipewire_library()
unload_pipewire_library()
{ {
if (pipewire_handle) { if (pipewire_handle) {
SDL_UnloadObject(pipewire_handle); SDL_UnloadObject(pipewire_handle);
@@ -163,21 +160,18 @@ unload_pipewire_library()
#define SDL_PIPEWIRE_SYM(x) PIPEWIRE_##x = x #define SDL_PIPEWIRE_SYM(x) PIPEWIRE_##x = x
static int static int load_pipewire_library()
load_pipewire_library()
{ {
return 0; return 0;
} }
static void static void unload_pipewire_library()
unload_pipewire_library()
{ /* Nothing to do */ { /* Nothing to do */
} }
#endif /* SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC */ #endif /* SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC */
static int static int load_pipewire_syms()
load_pipewire_syms()
{ {
SDL_PIPEWIRE_SYM(pw_get_library_version); SDL_PIPEWIRE_SYM(pw_get_library_version);
SDL_PIPEWIRE_SYM(pw_init); 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); (pipewire_version_major > major || pipewire_version_minor > minor || pipewire_version_patch >= patch);
} }
static int static int init_pipewire_library()
init_pipewire_library()
{ {
if (!load_pipewire_library()) { if (!load_pipewire_library()) {
if (!load_pipewire_syms()) { if (!load_pipewire_syms()) {
@@ -242,8 +235,7 @@ init_pipewire_library()
return -1; return -1;
} }
static void static void deinit_pipewire_library()
deinit_pipewire_library()
{ {
PIPEWIRE_pw_deinit(); PIPEWIRE_pw_deinit();
unload_pipewire_library(); unload_pipewire_library();
@@ -304,8 +296,7 @@ static char *pipewire_default_sink_id = NULL;
static char *pipewire_default_source_id = NULL; static char *pipewire_default_source_id = NULL;
/* The active node list */ /* The active node list */
static SDL_bool static SDL_bool io_list_check_add(struct io_node *node)
io_list_check_add(struct io_node *node)
{ {
struct io_node *n; struct io_node *n;
SDL_bool ret = SDL_TRUE; SDL_bool ret = SDL_TRUE;
@@ -330,8 +321,7 @@ dup_found:
return ret; return ret;
} }
static void static void io_list_remove(Uint32 id)
io_list_remove(Uint32 id)
{ {
struct io_node *n, *temp; struct io_node *n, *temp;
@@ -351,8 +341,7 @@ io_list_remove(Uint32 id)
} }
} }
static void static void io_list_sort()
io_list_sort()
{ {
struct io_node *default_sink = NULL, *default_source = NULL; struct io_node *default_sink = NULL, *default_source = NULL;
struct io_node *n, *temp; struct io_node *n, *temp;
@@ -377,8 +366,7 @@ io_list_sort()
} }
} }
static void static void io_list_clear()
io_list_clear()
{ {
struct io_node *n, *temp; struct io_node *n, *temp;
@@ -412,8 +400,7 @@ io_list_get_by_path(char *path)
return NULL; return NULL;
} }
static void static void node_object_destroy(struct node_object *node)
node_object_destroy(struct node_object *node)
{ {
SDL_assert(node); SDL_assert(node);
@@ -425,15 +412,13 @@ node_object_destroy(struct node_object *node)
} }
/* The pending node list */ /* The pending node list */
static void static void pending_list_add(struct node_object *node)
pending_list_add(struct node_object *node)
{ {
SDL_assert(node); SDL_assert(node);
spa_list_append(&hotplug_pending_list, &node->link); spa_list_append(&hotplug_pending_list, &node->link);
} }
static void static void pending_list_remove(Uint32 id)
pending_list_remove(Uint32 id)
{ {
struct node_object *node, *temp; struct node_object *node, *temp;
@@ -444,8 +429,7 @@ pending_list_remove(Uint32 id)
} }
} }
static void static void pending_list_clear()
pending_list_clear()
{ {
struct node_object *node, *temp; struct node_object *node, *temp;
@@ -454,8 +438,7 @@ pending_list_clear()
} }
} }
static void * static void *node_object_new(Uint32 id, const char *type, Uint32 version, const void *funcs, const struct pw_core_events *core_events)
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 pw_proxy *proxy;
struct node_object *node; struct node_object *node;
@@ -484,8 +467,7 @@ node_object_new(Uint32 id, const char *type, Uint32 version, const void *funcs,
} }
/* Core sync points */ /* Core sync points */
static void static void core_events_hotplug_init_callback(void *object, uint32_t id, int seq)
core_events_hotplug_init_callback(void *object, uint32_t id, int seq)
{ {
if (id == PW_ID_CORE && seq == hotplug_init_seq_val) { if (id == PW_ID_CORE && seq == hotplug_init_seq_val) {
/* This core listener is no longer needed. */ /* 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 static void core_events_interface_callback(void *object, uint32_t id, int seq)
core_events_interface_callback(void *object, uint32_t id, int seq)
{ {
struct node_object *node = object; struct node_object *node = object;
struct io_node *io = node->userdata; struct io_node *io = node->userdata;
@@ -516,8 +497,7 @@ core_events_interface_callback(void *object, uint32_t id, int seq)
} }
} }
static void static void core_events_metadata_callback(void *object, uint32_t id, int seq)
core_events_metadata_callback(void *object, uint32_t id, int seq)
{ {
struct node_object *node = object; 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 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 const struct pw_core_events metadata_core_events = { PW_VERSION_CORE_EVENTS, .done = core_events_metadata_callback };
static void static void hotplug_core_sync(struct node_object *node)
hotplug_core_sync(struct node_object *node)
{ {
/* /*
* Node sync events *must* come before the hotplug init sync events or the initial * 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 */ /* Helpers for retrieving values from params */
static SDL_bool static SDL_bool get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max)
get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max)
{ {
const struct spa_pod_prop *prop; const struct spa_pod_prop *prop;
struct spa_pod *value; struct spa_pod *value;
@@ -581,8 +559,7 @@ get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int
return SDL_FALSE; return SDL_FALSE;
} }
static SDL_bool static SDL_bool get_int_param(const struct spa_pod *param, Uint32 key, int *val)
get_int_param(const struct spa_pod *param, Uint32 key, int *val)
{ {
const struct spa_pod_prop *prop; const struct spa_pod_prop *prop;
Sint32 v; Sint32 v;
@@ -601,8 +578,7 @@ get_int_param(const struct spa_pod *param, Uint32 key, int *val)
} }
/* Interface node callbacks */ /* Interface node callbacks */
static void static void node_event_info(void *object, const struct pw_node_info *info)
node_event_info(void *object, const struct pw_node_info *info)
{ {
struct node_object *node = object; struct node_object *node = object;
struct io_node *io = node->userdata; struct io_node *io = node->userdata;
@@ -624,8 +600,7 @@ node_event_info(void *object, const struct pw_node_info *info)
} }
} }
static void static void node_event_param(void *object, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param)
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 node_object *node = object;
struct io_node *io = node->userdata; 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, static const struct pw_node_events interface_node_events = { PW_VERSION_NODE_EVENTS, .info = node_event_info,
.param = node_event_param }; .param = node_event_param };
static char* static char *get_name_from_json(const char *json)
get_name_from_json(const char *json)
{ {
struct spa_json parser[2]; struct spa_json parser[2];
char key[7]; /* "name" */ char key[7]; /* "name" */
@@ -673,8 +647,7 @@ get_name_from_json(const char *json)
} }
/* Metadata node callback */ /* Metadata node callback */
static int static int metadata_property(void *object, Uint32 subject, const char *key, const char *type, const char *value)
metadata_property(void *object, Uint32 subject, const char *key, const char *type, const char *value)
{ {
struct node_object *node = object; 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 }; static const struct pw_metadata_events metadata_node_events = { PW_VERSION_METADATA_EVENTS, .property = metadata_property };
/* Global registry callbacks */ /* Global registry callbacks */
static void static void registry_event_global_callback(void *object, uint32_t id, uint32_t permissions, const char *type, uint32_t version,
registry_event_global_callback(void *object, uint32_t id, uint32_t permissions, const char *type, uint32_t version,
const struct spa_dict *props) const struct spa_dict *props)
{ {
struct node_object *node; struct node_object *node;
@@ -772,8 +744,7 @@ registry_event_global_callback(void *object, uint32_t id, uint32_t permissions,
} }
} }
static void static void registry_event_remove_callback(void *object, uint32_t id)
registry_event_remove_callback(void *object, uint32_t id)
{ {
io_list_remove(id); io_list_remove(id);
pending_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 }; .global_remove = registry_event_remove_callback };
/* The hotplug thread */ /* The hotplug thread */
static int static int hotplug_loop_init()
hotplug_loop_init()
{ {
int res; int res;
@@ -827,8 +797,7 @@ hotplug_loop_init()
return 0; return 0;
} }
static void static void hotplug_loop_destroy()
hotplug_loop_destroy()
{ {
if (hotplug_loop) { if (hotplug_loop) {
PIPEWIRE_pw_thread_loop_stop(hotplug_loop); PIPEWIRE_pw_thread_loop_stop(hotplug_loop);
@@ -870,8 +839,7 @@ hotplug_loop_destroy()
} }
} }
static void static void PIPEWIRE_DetectDevices()
PIPEWIRE_DetectDevices()
{ {
struct io_node *io; 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)) #define COPY_CHANNEL_MAP(c) SDL_memcpy(info->position, PIPEWIRE_channel_map_##c, sizeof(PIPEWIRE_channel_map_##c))
static void static void initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info_raw *info)
initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info_raw *info)
{ {
info->channels = spec->channels; info->channels = spec->channels;
info->rate = spec->freq; info->rate = spec->freq;
@@ -981,8 +948,7 @@ initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info_raw *info)
} }
} }
static void static void output_callback(void *data)
output_callback(void *data)
{ {
struct pw_buffer *pw_buf; struct pw_buffer *pw_buf;
struct spa_buffer *spa_buf; struct spa_buffer *spa_buf;
@@ -1047,8 +1013,7 @@ output_callback(void *data)
PIPEWIRE_pw_stream_queue_buffer(stream, pw_buf); PIPEWIRE_pw_stream_queue_buffer(stream, pw_buf);
} }
static void static void input_callback(void *data)
input_callback(void *data)
{ {
struct pw_buffer *pw_buf; struct pw_buffer *pw_buf;
struct spa_buffer *spa_buf; struct spa_buffer *spa_buf;
@@ -1103,8 +1068,7 @@ input_callback(void *data)
PIPEWIRE_pw_stream_queue_buffer(stream, pw_buf); PIPEWIRE_pw_stream_queue_buffer(stream, pw_buf);
} }
static void static void stream_add_buffer_callback(void *data, struct pw_buffer *buffer)
stream_add_buffer_callback(void *data, struct pw_buffer *buffer)
{ {
_THIS = data; _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); PIPEWIRE_pw_thread_loop_signal(this->hidden->loop, false);
} }
static void static void stream_state_changed_callback(void *data, enum pw_stream_state old, enum pw_stream_state state, const char *error)
stream_state_changed_callback(void *data, enum pw_stream_state old, enum pw_stream_state state, const char *error)
{ {
_THIS = data; _THIS = data;
@@ -1157,8 +1120,7 @@ static const struct pw_stream_events stream_input_events = { PW_VERSION_STREAM_
.add_buffer = stream_add_buffer_callback, .add_buffer = stream_add_buffer_callback,
.process = input_callback }; .process = input_callback };
static int static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
PIPEWIRE_OpenDevice(_THIS, const char *devname)
{ {
/* /*
* NOTE: The PW_STREAM_FLAG_RT_PROCESS flag can be set to call the stream * 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); SDL_free(this->hidden);
} }
static int static int PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
{ {
struct io_node *node; struct io_node *node;
char *target; char *target;
@@ -1380,8 +1341,7 @@ failed:
return ret; return ret;
} }
static void static void PIPEWIRE_Deinitialize()
PIPEWIRE_Deinitialize()
{ {
if (pipewire_initialized) { if (pipewire_initialized) {
hotplug_loop_destroy(); hotplug_loop_destroy();
@@ -1390,8 +1350,7 @@ PIPEWIRE_Deinitialize()
} }
} }
static SDL_bool static SDL_bool PIPEWIRE_Init(SDL_AudioDriverImpl *impl)
PIPEWIRE_Init(SDL_AudioDriverImpl *impl)
{ {
if (!pipewire_initialized) { if (!pipewire_initialized) {
if (init_pipewire_library() < 0) { if (init_pipewire_library() < 0) {
+1 -3
View File
@@ -33,8 +33,7 @@
/* The tag name used by PS2 audio */ /* The tag name used by PS2 audio */
#define PS2AUDIO_DRIVER_NAME "ps2" #define PS2AUDIO_DRIVER_NAME "ps2"
static int static int PS2AUDIO_OpenDevice(_THIS, const char *devname)
PS2AUDIO_OpenDevice(_THIS, const char *devname)
{ {
int i, mixlen; int i, mixlen;
struct audsrv_fmt_t format; struct audsrv_fmt_t format;
@@ -46,7 +45,6 @@ PS2AUDIO_OpenDevice(_THIS, const char *devname)
} }
SDL_zerop(this->hidden); SDL_zerop(this->hidden);
/* These are the native supported audio PS2 configs */ /* These are the native supported audio PS2 configs */
switch (this->spec.freq) { switch (this->spec.freq) {
case 11025: case 11025:
+2 -4
View File
@@ -38,8 +38,7 @@
/* The tag name used by PSP audio */ /* The tag name used by PSP audio */
#define PSPAUDIO_DRIVER_NAME "psp" #define PSPAUDIO_DRIVER_NAME "psp"
static int static int PSPAUDIO_OpenDevice(_THIS, const char *devname)
PSPAUDIO_OpenDevice(_THIS, const char *devname)
{ {
int format, mixlen, i; int format, mixlen, i;
@@ -155,8 +154,7 @@ static void PSPAUDIO_ThreadInit(_THIS)
} }
} }
static SDL_bool static SDL_bool PSPAUDIO_Init(SDL_AudioDriverImpl *impl)
PSPAUDIO_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = PSPAUDIO_OpenDevice; impl->OpenDevice = PSPAUDIO_OpenDevice;
+2 -1
View File
@@ -29,7 +29,8 @@
#define NUM_BUFFERS 2 #define NUM_BUFFERS 2
struct SDL_PrivateAudioData { struct SDL_PrivateAudioData
{
/* The hardware output channel. */ /* The hardware output channel. */
int channel; int channel;
/* The raw allocated mixing buffer. */ /* The raw allocated mixing buffer. */
+40 -74
View File
@@ -45,19 +45,19 @@
/* should we include monitors in the device list? Set at SDL_Init time */ /* should we include monitors in the device list? Set at SDL_Init time */
static SDL_bool include_monitors = SDL_FALSE; static SDL_bool include_monitors = SDL_FALSE;
#if (PA_API_VERSION < 12) #if (PA_API_VERSION < 12)
/** Return non-zero if the passed state is one of the connected states */ /** 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 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 */ /** 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; return x == PA_STREAM_CREATING || x == PA_STREAM_READY;
} }
#endif /* pulseaudio <= 0.9.10 */ #endif /* pulseaudio <= 0.9.10 */
static const char *(*PULSEAUDIO_pa_get_library_version)(void); static const char *(*PULSEAUDIO_pa_get_library_version)(void);
static pa_channel_map *(*PULSEAUDIO_pa_channel_map_init_auto)( static pa_channel_map *(*PULSEAUDIO_pa_channel_map_init_auto)(
pa_channel_map *, unsigned, pa_channel_map_def_t); 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); static int load_pulseaudio_syms(void);
#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC #ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
static const char *pulseaudio_library = SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC; static const char *pulseaudio_library = SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC;
static void *pulseaudio_handle = NULL; static void *pulseaudio_handle = NULL;
static int static int load_pulseaudio_sym(const char *fn, void **addr)
load_pulseaudio_sym(const char *fn, void **addr)
{ {
*addr = SDL_LoadFunction(pulseaudio_handle, fn); *addr = SDL_LoadFunction(pulseaudio_handle, fn);
if (*addr == NULL) { 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. */ /* cast funcs to char* first, to please GCC's strict aliasing rules. */
#define SDL_PULSEAUDIO_SYM(x) \ #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 static void UnloadPulseAudioLibrary(void)
UnloadPulseAudioLibrary(void)
{ {
if (pulseaudio_handle != NULL) { if (pulseaudio_handle != NULL) {
SDL_UnloadObject(pulseaudio_handle); SDL_UnloadObject(pulseaudio_handle);
@@ -143,8 +141,7 @@ UnloadPulseAudioLibrary(void)
} }
} }
static int static int LoadPulseAudioLibrary(void)
LoadPulseAudioLibrary(void)
{ {
int retval = 0; int retval = 0;
if (pulseaudio_handle == NULL) { if (pulseaudio_handle == NULL) {
@@ -166,13 +163,11 @@ LoadPulseAudioLibrary(void)
#define SDL_PULSEAUDIO_SYM(x) PULSEAUDIO_##x = x #define SDL_PULSEAUDIO_SYM(x) PULSEAUDIO_##x = x
static void static void UnloadPulseAudioLibrary(void)
UnloadPulseAudioLibrary(void)
{ {
} }
static int static int LoadPulseAudioLibrary(void)
LoadPulseAudioLibrary(void)
{ {
load_pulseaudio_syms(); load_pulseaudio_syms();
return 0; return 0;
@@ -180,9 +175,7 @@ LoadPulseAudioLibrary(void)
#endif /* SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */ #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_get_library_version);
SDL_PULSEAUDIO_SYM(pa_mainloop_new); SDL_PULSEAUDIO_SYM(pa_mainloop_new);
@@ -225,15 +218,13 @@ load_pulseaudio_syms(void)
return 0; return 0;
} }
static SDL_INLINE int static SDL_INLINE int squashVersion(const int major, const int minor, const int patch)
squashVersion(const int major, const int minor, const int patch)
{ {
return ((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF); return ((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF);
} }
/* Workaround for older pulse: pa_context_new() must have non-NULL appname */ /* Workaround for older pulse: pa_context_new() must have non-NULL appname */
static const char * static const char *getAppName(void)
getAppName(void)
{ {
const char *retval = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME); const char *retval = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME);
if (retval && *retval) { if (retval && *retval) {
@@ -257,8 +248,7 @@ getAppName(void)
return retval; return retval;
} }
static void static void WaitForPulseOperation(pa_mainloop *mainloop, pa_operation *o)
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. */ /* This checks for NO errors currently. Either fix that, check results elsewhere, or do things you don't care about. */
if (mainloop && o) { if (mainloop && o) {
@@ -270,8 +260,7 @@ WaitForPulseOperation(pa_mainloop *mainloop, pa_operation *o)
} }
} }
static void static void DisconnectFromPulseServer(pa_mainloop *mainloop, pa_context *context)
DisconnectFromPulseServer(pa_mainloop *mainloop, pa_context *context)
{ {
if (context) { if (context) {
PULSEAUDIO_pa_context_disconnect(context); PULSEAUDIO_pa_context_disconnect(context);
@@ -282,8 +271,7 @@ DisconnectFromPulseServer(pa_mainloop *mainloop, pa_context *context)
} }
} }
static int static int ConnectToPulseServer_Internal(pa_mainloop **_mainloop, pa_context **_context)
ConnectToPulseServer_Internal(pa_mainloop **_mainloop, pa_context **_context)
{ {
pa_mainloop *mainloop = NULL; pa_mainloop *mainloop = NULL;
pa_context *context = NULL; pa_context *context = NULL;
@@ -334,8 +322,7 @@ ConnectToPulseServer_Internal(pa_mainloop **_mainloop, pa_context **_context)
return 0; /* connected and ready! */ return 0; /* connected and ready! */
} }
static int static int ConnectToPulseServer(pa_mainloop **_mainloop, pa_context **_context)
ConnectToPulseServer(pa_mainloop **_mainloop, pa_context **_context)
{ {
const int retval = ConnectToPulseServer_Internal(_mainloop, _context); const int retval = ConnectToPulseServer_Internal(_mainloop, _context);
if (retval < 0) { if (retval < 0) {
@@ -344,10 +331,8 @@ ConnectToPulseServer(pa_mainloop **_mainloop, pa_context **_context)
return retval; return retval;
} }
/* This function waits until it is possible to write a full sound buffer */ /* This function waits until it is possible to write a full sound buffer */
static void static void PULSEAUDIO_WaitDevice(_THIS)
PULSEAUDIO_WaitDevice(_THIS)
{ {
/* this is a no-op; we wait in PULSEAUDIO_PlayDevice now. */ /* 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; h->bytes_requested += nbytes;
} }
static void static void PULSEAUDIO_PlayDevice(_THIS)
PULSEAUDIO_PlayDevice(_THIS)
{ {
struct SDL_PrivateAudioData *h = this->hidden; struct SDL_PrivateAudioData *h = this->hidden;
int available = h->mixlen; int available = h->mixlen;
@@ -395,15 +379,12 @@ PULSEAUDIO_PlayDevice(_THIS)
/*printf("PULSEAUDIO PLAYDEVICE END! written=%d\n", written);*/ /*printf("PULSEAUDIO PLAYDEVICE END! written=%d\n", written);*/
} }
static Uint8 * static Uint8 *PULSEAUDIO_GetDeviceBuf(_THIS)
PULSEAUDIO_GetDeviceBuf(_THIS)
{ {
return this->hidden->mixbuf; 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; struct SDL_PrivateAudioData *h = this->hidden;
const void *data = NULL; const void *data = NULL;
@@ -437,7 +418,8 @@ PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
/* a new fragment is available! */ /* a new fragment is available! */
PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes); PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes);
SDL_assert(nbytes > 0); 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. */ PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */
} else { } else {
/* store this fragment's data, start feeding it to SDL. */ /* 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? */ return -1; /* not enabled? */
} }
static void static void PULSEAUDIO_FlushCapture(_THIS)
PULSEAUDIO_FlushCapture(_THIS)
{ {
struct SDL_PrivateAudioData *h = this->hidden; struct SDL_PrivateAudioData *h = this->hidden;
const void *data = NULL; const void *data = NULL;
@@ -481,8 +462,7 @@ PULSEAUDIO_FlushCapture(_THIS)
} }
} }
static void static void PULSEAUDIO_CloseDevice(_THIS)
PULSEAUDIO_CloseDevice(_THIS)
{ {
if (this->hidden->stream) { if (this->hidden->stream) {
if (this->hidden->capturebuf != NULL) { if (this->hidden->capturebuf != NULL) {
@@ -498,8 +478,7 @@ PULSEAUDIO_CloseDevice(_THIS)
SDL_free(this->hidden); SDL_free(this->hidden);
} }
static void static void SinkDeviceNameCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
SinkDeviceNameCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
{ {
if (i) { if (i) {
char **devname = (char **)data; char **devname = (char **)data;
@@ -507,8 +486,7 @@ SinkDeviceNameCallback(pa_context *c, const pa_sink_info *i, int is_last, void *
} }
} }
static void static void SourceDeviceNameCallback(pa_context *c, const pa_source_info *i, int is_last, void *data)
SourceDeviceNameCallback(pa_context *c, const pa_source_info *i, int is_last, void *data)
{ {
if (i) { if (i) {
char **devname = (char **)data; char **devname = (char **)data;
@@ -516,8 +494,7 @@ SourceDeviceNameCallback(pa_context *c, const pa_source_info *i, int is_last, vo
} }
} }
static SDL_bool static SDL_bool FindDeviceName(struct SDL_PrivateAudioData *h, const SDL_bool iscapture, void *handle)
FindDeviceName(struct SDL_PrivateAudioData *h, const SDL_bool iscapture, void *handle)
{ {
const uint32_t idx = ((uint32_t)((intptr_t)handle)) - 1; 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; return h->device_name != NULL;
} }
static int static int PULSEAUDIO_OpenDevice(_THIS, const char *devname)
PULSEAUDIO_OpenDevice(_THIS, const char *devname)
{ {
struct SDL_PrivateAudioData *h = NULL; struct SDL_PrivateAudioData *h = NULL;
SDL_AudioFormat test_format; 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. */ /* device handles are device index + 1, cast to void*, so we never pass a NULL. */
static SDL_AudioFormat static SDL_AudioFormat PulseFormatToSDLFormat(pa_sample_format_t format)
PulseFormatToSDLFormat(pa_sample_format_t format)
{ {
switch (format) { switch (format) {
case PA_SAMPLE_U8: case PA_SAMPLE_U8:
@@ -716,8 +691,7 @@ PulseFormatToSDLFormat(pa_sample_format_t format)
} }
/* This is called when PulseAudio adds an output ("sink") device. */ /* This is called when PulseAudio adds an output ("sink") device. */
static void static void SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
{ {
SDL_AudioSpec spec; SDL_AudioSpec spec;
SDL_bool add = (SDL_bool)((intptr_t)data); 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. */ /* This is called when PulseAudio adds a capture ("source") device. */
static void static void SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *data)
SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *data)
{ {
SDL_AudioSpec spec; SDL_AudioSpec spec;
SDL_bool add = (SDL_bool)((intptr_t)data); 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 static void ServerInfoCallback(pa_context *c, const pa_server_info *i, void *data)
ServerInfoCallback(pa_context *c, const pa_server_info *i, void *data)
{ {
if (default_sink_path != NULL) { if (default_sink_path != NULL) {
SDL_free(default_sink_path); 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. */ /* This is called when PulseAudio has a device connected/removed/changed. */
static void static void HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *data)
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 added = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW);
const SDL_bool removed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE); const 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. */ /* this runs as a thread while the Pulse target is initialized to catch hotplug events. */
static int SDLCALL static int SDLCALL HotplugThread(void *data)
HotplugThread(void *data)
{ {
pa_operation *o; pa_operation *o;
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW); SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW);
@@ -832,8 +802,7 @@ HotplugThread(void *data)
return 0; return 0;
} }
static void static void PULSEAUDIO_DetectDevices()
PULSEAUDIO_DetectDevices()
{ {
WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_server_info(hotplug_context, ServerInfoCallback, NULL)); 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))); 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); hotplug_thread = SDL_CreateThreadInternal(HotplugThread, "PulseHotplug", 256 * 1024, NULL);
} }
static int static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
{ {
int i; int i;
int numdevices; int numdevices;
@@ -875,8 +843,7 @@ PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
return SDL_SetError("Could not find default PulseAudio device"); return SDL_SetError("Could not find default PulseAudio device");
} }
static void static void PULSEAUDIO_Deinitialize(void)
PULSEAUDIO_Deinitialize(void)
{ {
if (hotplug_thread) { if (hotplug_thread) {
PULSEAUDIO_pa_mainloop_quit(hotplug_mainloop, 0); PULSEAUDIO_pa_mainloop_quit(hotplug_mainloop, 0);
@@ -908,8 +875,7 @@ PULSEAUDIO_Deinitialize(void)
UnloadPulseAudioLibrary(); UnloadPulseAudioLibrary();
} }
static SDL_bool static SDL_bool PULSEAUDIO_Init(SDL_AudioDriverImpl *impl)
PULSEAUDIO_Init(SDL_AudioDriverImpl * impl)
{ {
if (LoadPulseAudioLibrary() < 0) { if (LoadPulseAudioLibrary() < 0) {
return SDL_FALSE; return SDL_FALSE;
+19 -38
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 const char *sndio_library = SDL_AUDIO_DRIVER_SNDIO_DYNAMIC;
static void *sndio_handle = NULL; static void *sndio_handle = NULL;
static int static int load_sndio_sym(const char *fn, void **addr)
load_sndio_sym(const char *fn, void **addr)
{ {
*addr = SDL_LoadFunction(sndio_handle, fn); *addr = SDL_LoadFunction(sndio_handle, fn);
if (*addr == NULL) { 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. */ /* cast funcs to char* first, to please GCC's strict aliasing rules. */
#define SDL_SNDIO_SYM(x) \ #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 #else
#define SDL_SNDIO_SYM(x) SNDIO_##x = x #define SDL_SNDIO_SYM(x) SNDIO_##x = x
#endif #endif
static int static int load_sndio_syms(void)
load_sndio_syms(void)
{ {
SDL_SNDIO_SYM(sio_open); SDL_SNDIO_SYM(sio_open);
SDL_SNDIO_SYM(sio_close); SDL_SNDIO_SYM(sio_close);
@@ -110,8 +109,7 @@ load_sndio_syms(void)
#ifdef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC #ifdef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC
static void static void UnloadSNDIOLibrary(void)
UnloadSNDIOLibrary(void)
{ {
if (sndio_handle != NULL) { if (sndio_handle != NULL) {
SDL_UnloadObject(sndio_handle); SDL_UnloadObject(sndio_handle);
@@ -119,8 +117,7 @@ UnloadSNDIOLibrary(void)
} }
} }
static int static int LoadSNDIOLibrary(void)
LoadSNDIOLibrary(void)
{ {
int retval = 0; int retval = 0;
if (sndio_handle == NULL) { if (sndio_handle == NULL) {
@@ -140,13 +137,11 @@ LoadSNDIOLibrary(void)
#else #else
static void static void UnloadSNDIOLibrary(void)
UnloadSNDIOLibrary(void)
{ {
} }
static int static int LoadSNDIOLibrary(void)
LoadSNDIOLibrary(void)
{ {
load_sndio_syms(); load_sndio_syms();
return 0; return 0;
@@ -154,17 +149,12 @@ LoadSNDIOLibrary(void)
#endif /* SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */ #endif /* SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */
static void SNDIO_WaitDevice(_THIS)
static void
SNDIO_WaitDevice(_THIS)
{ {
/* no-op; SNDIO_sio_write() blocks if necessary. */ /* no-op; SNDIO_sio_write() blocks if necessary. */
} }
static void static void SNDIO_PlayDevice(_THIS)
SNDIO_PlayDevice(_THIS)
{ {
const int written = SNDIO_sio_write(this->hidden->dev, const int written = SNDIO_sio_write(this->hidden->dev,
this->hidden->mixbuf, this->hidden->mixbuf,
@@ -179,8 +169,7 @@ SNDIO_PlayDevice(_THIS)
#endif #endif
} }
static int static int SNDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
SNDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
{ {
size_t r; size_t r;
int revents; int revents;
@@ -189,8 +178,7 @@ SNDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
/* Emulate a blocking read */ /* Emulate a blocking read */
r = SNDIO_sio_read(this->hidden->dev, buffer, buflen); r = SNDIO_sio_read(this->hidden->dev, buffer, buflen);
while (r == 0 && !SNDIO_sio_eof(this->hidden->dev)) { while (r == 0 && !SNDIO_sio_eof(this->hidden->dev)) {
if ((nfds = SNDIO_sio_pollfd(this->hidden->dev, this->hidden->pfd, POLLIN)) <= 0 if ((nfds = SNDIO_sio_pollfd(this->hidden->dev, this->hidden->pfd, POLLIN)) <= 0 || poll(this->hidden->pfd, nfds, INFTIM) < 0) {
|| poll(this->hidden->pfd, nfds, INFTIM) < 0) {
return -1; return -1;
} }
revents = SNDIO_sio_revents(this->hidden->dev, this->hidden->pfd); revents = SNDIO_sio_revents(this->hidden->dev, this->hidden->pfd);
@@ -204,8 +192,7 @@ SNDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
return (int)r; return (int)r;
} }
static void static void SNDIO_FlushCapture(_THIS)
SNDIO_FlushCapture(_THIS)
{ {
char buf[512]; char buf[512];
@@ -214,14 +201,12 @@ SNDIO_FlushCapture(_THIS)
} }
} }
static Uint8 * static Uint8 *SNDIO_GetDeviceBuf(_THIS)
SNDIO_GetDeviceBuf(_THIS)
{ {
return this->hidden->mixbuf; return this->hidden->mixbuf;
} }
static void static void SNDIO_CloseDevice(_THIS)
SNDIO_CloseDevice(_THIS)
{ {
if (this->hidden->pfd != NULL) { if (this->hidden->pfd != NULL) {
SDL_free(this->hidden->pfd); SDL_free(this->hidden->pfd);
@@ -234,8 +219,7 @@ SNDIO_CloseDevice(_THIS)
SDL_free(this->hidden); SDL_free(this->hidden);
} }
static int static int SNDIO_OpenDevice(_THIS, const char *devname)
SNDIO_OpenDevice(_THIS, const char *devname)
{ {
SDL_AudioFormat test_format; SDL_AudioFormat test_format;
struct sio_par par; struct sio_par par;
@@ -339,21 +323,18 @@ SNDIO_OpenDevice(_THIS, const char *devname)
return 0; return 0;
} }
static void static void SNDIO_Deinitialize(void)
SNDIO_Deinitialize(void)
{ {
UnloadSNDIOLibrary(); UnloadSNDIOLibrary();
} }
static void static void SNDIO_DetectDevices(void)
SNDIO_DetectDevices(void)
{ {
SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *)0x1); SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *)0x1);
SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *)0x2); SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *)0x2);
} }
static SDL_bool static SDL_bool SNDIO_Init(SDL_AudioDriverImpl *impl)
SNDIO_Init(SDL_AudioDriverImpl * impl)
{ {
if (LoadSNDIOLibrary() < 0) { if (LoadSNDIOLibrary() < 0) {
return SDL_FALSE; return SDL_FALSE;
+3 -6
View File
@@ -39,8 +39,7 @@
#define SCE_AUDIO_SAMPLE_ALIGN(s) (((s) + 63) & ~63) #define SCE_AUDIO_SAMPLE_ALIGN(s) (((s) + 63) & ~63)
#define SCE_AUDIO_MAX_VOLUME 0x8000 #define SCE_AUDIO_MAX_VOLUME 0x8000
static int static int VITAAUD_OpenCaptureDevice(_THIS)
VITAAUD_OpenCaptureDevice(_THIS)
{ {
this->spec.freq = 16000; this->spec.freq = 16000;
this->spec.samples = 512; this->spec.samples = 512;
@@ -57,8 +56,7 @@ VITAAUD_OpenCaptureDevice(_THIS)
return 0; return 0;
} }
static int static int VITAAUD_OpenDevice(_THIS, const char *devname)
VITAAUD_OpenDevice(_THIS, const char *devname)
{ {
int format, mixlen, i, port = SCE_AUDIO_OUT_PORT_TYPE_MAIN; int format, mixlen, i, port = SCE_AUDIO_OUT_PORT_TYPE_MAIN;
int vols[2] = { SCE_AUDIO_MAX_VOLUME, SCE_AUDIO_MAX_VOLUME }; int vols[2] = { SCE_AUDIO_MAX_VOLUME, SCE_AUDIO_MAX_VOLUME };
@@ -191,8 +189,7 @@ static void VITAAUD_ThreadInit(_THIS)
} }
} }
static SDL_bool static SDL_bool VITAAUD_Init(SDL_AudioDriverImpl *impl)
VITAAUD_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = VITAAUD_OpenDevice; impl->OpenDevice = VITAAUD_OpenDevice;
+2 -1
View File
@@ -29,7 +29,8 @@
#define NUM_BUFFERS 2 #define NUM_BUFFERS 2
struct SDL_PrivateAudioData { struct SDL_PrivateAudioData
{
/* The hardware input/output port. */ /* The hardware input/output port. */
int port; int port;
/* The raw allocated mixing buffer. */ /* The raw allocated mixing buffer. */
+20 -42
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_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 const IID SDL_IID_IAudioCaptureClient = { 0xc8adbd64, 0xe71e, 0x48a0, { 0xa4, 0xde, 0x18, 0x5c, 0x39, 0x5c, 0xd3, 0x17 } };
static void static void WASAPI_DetectDevices(void)
WASAPI_DetectDevices(void)
{ {
WASAPI_EnumerateEndpoints(); WASAPI_EnumerateEndpoints();
} }
static SDL_INLINE SDL_bool static SDL_INLINE SDL_bool WasapiFailed(_THIS, const HRESULT err)
WasapiFailed(_THIS, const HRESULT err)
{ {
if (err == S_OK) { if (err == S_OK) {
return SDL_FALSE; return SDL_FALSE;
@@ -71,8 +69,7 @@ WasapiFailed(_THIS, const HRESULT err)
return SDL_TRUE; return SDL_TRUE;
} }
static int static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
{ {
/* Since WASAPI requires us to handle all audio conversion, and our /* Since WASAPI requires us to handle all audio conversion, and our
device format might have changed, we might have to add/remove/change device format might have changed, we might have to add/remove/change
@@ -124,11 +121,9 @@ UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
return 0; return 0;
} }
static void ReleaseWasapiDevice(_THIS); static void ReleaseWasapiDevice(_THIS);
static SDL_bool static SDL_bool RecoverWasapiDevice(_THIS)
RecoverWasapiDevice(_THIS)
{ {
ReleaseWasapiDevice(this); /* dump the lost device's handles. */ ReleaseWasapiDevice(this); /* dump the lost device's handles. */
@@ -151,8 +146,7 @@ RecoverWasapiDevice(_THIS)
return SDL_TRUE; /* okay, carry on with new device details! */ return SDL_TRUE; /* okay, carry on with new device details! */
} }
static SDL_bool static SDL_bool RecoverWasapiIfLost(_THIS)
RecoverWasapiIfLost(_THIS)
{ {
const int generation = this->hidden->default_device_generation; const int generation = this->hidden->default_device_generation;
SDL_bool lost = this->hidden->device_lost; SDL_bool lost = this->hidden->device_lost;
@@ -175,8 +169,7 @@ RecoverWasapiIfLost(_THIS)
return lost ? RecoverWasapiDevice(this) : SDL_TRUE; return lost ? RecoverWasapiDevice(this) : SDL_TRUE;
} }
static Uint8 * static Uint8 *WASAPI_GetDeviceBuf(_THIS)
WASAPI_GetDeviceBuf(_THIS)
{ {
/* get an endpoint buffer from WASAPI. */ /* get an endpoint buffer from WASAPI. */
BYTE *buffer = NULL; BYTE *buffer = NULL;
@@ -191,8 +184,7 @@ WASAPI_GetDeviceBuf(_THIS)
return (Uint8 *)buffer; return (Uint8 *)buffer;
} }
static void static void WASAPI_PlayDevice(_THIS)
WASAPI_PlayDevice(_THIS)
{ {
if (this->hidden->render != NULL) { /* definitely activated? */ if (this->hidden->render != NULL) { /* definitely activated? */
/* WasapiFailed() will mark the device for reacquisition or removal elsewhere. */ /* WasapiFailed() will mark the device for reacquisition or removal elsewhere. */
@@ -200,8 +192,7 @@ WASAPI_PlayDevice(_THIS)
} }
} }
static void static void WASAPI_WaitDevice(_THIS)
WASAPI_WaitDevice(_THIS)
{ {
while (RecoverWasapiIfLost(this) && this->hidden->client && this->hidden->event) { while (RecoverWasapiIfLost(this) && this->hidden->client && this->hidden->event) {
DWORD waitResult = WaitForSingleObjectEx(this->hidden->event, 200, FALSE); DWORD waitResult = WaitForSingleObjectEx(this->hidden->event, 200, FALSE);
@@ -228,8 +219,7 @@ WASAPI_WaitDevice(_THIS)
} }
} }
static int static int WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen)
WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen)
{ {
SDL_AudioStream *stream = this->hidden->capturestream; SDL_AudioStream *stream = this->hidden->capturestream;
const int avail = SDL_AudioStreamAvailable(stream); const int avail = SDL_AudioStreamAvailable(stream);
@@ -293,8 +283,7 @@ WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen)
return -1; /* unrecoverable error. */ return -1; /* unrecoverable error. */
} }
static void static void WASAPI_FlushCapture(_THIS)
WASAPI_FlushCapture(_THIS)
{ {
BYTE *ptr = NULL; BYTE *ptr = NULL;
UINT32 frames = 0; UINT32 frames = 0;
@@ -318,8 +307,7 @@ WASAPI_FlushCapture(_THIS)
SDL_AudioStreamClear(this->hidden->capturestream); SDL_AudioStreamClear(this->hidden->capturestream);
} }
static void static void ReleaseWasapiDevice(_THIS)
ReleaseWasapiDevice(_THIS)
{ {
if (this->hidden->client) { if (this->hidden->client) {
IAudioClient_Stop(this->hidden->client); IAudioClient_Stop(this->hidden->client);
@@ -358,20 +346,17 @@ ReleaseWasapiDevice(_THIS)
} }
} }
static void static void WASAPI_CloseDevice(_THIS)
WASAPI_CloseDevice(_THIS)
{ {
WASAPI_UnrefDevice(this); WASAPI_UnrefDevice(this);
} }
void void WASAPI_RefDevice(_THIS)
WASAPI_RefDevice(_THIS)
{ {
SDL_AtomicIncRef(&this->hidden->refcount); SDL_AtomicIncRef(&this->hidden->refcount);
} }
void void WASAPI_UnrefDevice(_THIS)
WASAPI_UnrefDevice(_THIS)
{ {
if (!SDL_AtomicDecRef(&this->hidden->refcount)) { if (!SDL_AtomicDecRef(&this->hidden->refcount)) {
return; return;
@@ -388,8 +373,7 @@ WASAPI_UnrefDevice(_THIS)
} }
/* This is called once a device is activated, possibly asynchronously. */ /* This is called once a device is activated, possibly asynchronously. */
int int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
{ {
/* !!! FIXME: we could request an exclusive mode stream, which is lower latency; /* !!! FIXME: we could request an exclusive mode stream, which is lower latency;
!!! it will write into the kernel's audio buffer directly instead of !!! 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. */ 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; LPCWSTR devid = (LPCWSTR)this->handle;
@@ -579,26 +561,22 @@ WASAPI_OpenDevice(_THIS, const char *devname)
return 0; return 0;
} }
static void static void WASAPI_ThreadInit(_THIS)
WASAPI_ThreadInit(_THIS)
{ {
WASAPI_PlatformThreadInit(this); WASAPI_PlatformThreadInit(this);
} }
static void static void WASAPI_ThreadDeinit(_THIS)
WASAPI_ThreadDeinit(_THIS)
{ {
WASAPI_PlatformThreadDeinit(this); WASAPI_PlatformThreadDeinit(this);
} }
static void static void WASAPI_Deinitialize(void)
WASAPI_Deinitialize(void)
{ {
WASAPI_PlatformDeinit(); WASAPI_PlatformDeinit();
} }
static SDL_bool static SDL_bool WASAPI_Init(SDL_AudioDriverImpl *impl)
WASAPI_Init(SDL_AudioDriverImpl * impl)
{ {
if (WASAPI_PlatformInit() == -1) { if (WASAPI_PlatformInit() == -1) {
return SDL_FALSE; return SDL_FALSE;

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