mirror of
				https://github.com/libsdl-org/SDL.git
				synced 2025-10-26 12:27:44 +00:00 
			
		
		
		
	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
(cherry picked from commit 5750bcb174)
			
			
This commit is contained in:
		| @@ -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
									
								
								build-scripts/clang-format-src.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										32
									
								
								build-scripts/clang-format-src.sh
									
									
									
									
									
										Executable 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!" | ||||||
							
								
								
									
										35
									
								
								src/SDL.c
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								src/SDL.c
									
									
									
									
									
								
							| @@ -110,7 +110,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; | ||||||
| @@ -121,8 +120,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)); | ||||||
| @@ -132,8 +130,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)) { | ||||||
| @@ -142,8 +139,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)); | ||||||
| @@ -151,8 +147,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; | ||||||
| @@ -164,14 +160,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; | ||||||
|  |  | ||||||
| @@ -350,14 +344,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) |  | ||||||
| { | { | ||||||
| #if defined(__OS2__) | #if defined(__OS2__) | ||||||
| #if SDL_THREAD_OS2 | #if SDL_THREAD_OS2 | ||||||
| @@ -481,8 +473,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; | ||||||
|  |  | ||||||
| @@ -516,13 +507,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); | ||||||
|   | |||||||
| @@ -48,8 +48,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 | ||||||
| @@ -65,12 +64,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); | ||||||
| @@ -78,7 +75,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 | ||||||
| @@ -96,13 +92,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) | ||||||
| @@ -132,7 +128,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. */ | ||||||
| @@ -142,7 +137,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; | ||||||
| @@ -153,8 +147,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; | ||||||
| @@ -257,6 +250,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' + | ||||||
| @@ -267,12 +261,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) { | ||||||
| @@ -330,7 +326,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) | ||||||
| @@ -371,7 +366,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?! */ | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -379,8 +375,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; | ||||||
| @@ -405,7 +400,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 | ||||||
|   | |||||||
| @@ -40,8 +40,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; | ||||||
| @@ -50,7 +49,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 * | ||||||
| @@ -83,8 +81,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); | ||||||
| @@ -93,8 +90,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; | ||||||
| @@ -136,8 +132,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; | ||||||
|  |  | ||||||
| @@ -169,9 +164,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; | ||||||
| @@ -335,4 +328,3 @@ SDL_ReserveSpaceInDataQueue(SDL_DataQueue *queue, const size_t len) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* vi: set ts=4 sw=4 expandtab: */ | /* vi: set ts=4 sw=4 expandtab: */ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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: */ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -25,8 +25,7 @@ | |||||||
| #include "SDL_error.h" | #include "SDL_error.h" | ||||||
| #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) { | ||||||
| @@ -52,7 +51,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); | ||||||
| @@ -70,15 +68,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: | ||||||
| @@ -97,8 +93,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]; | ||||||
|  |  | ||||||
| @@ -113,7 +108,6 @@ main(int argc, char *argv[]) | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| char * | char * | ||||||
| SDL_GetErrorMsg(char *errstr, int maxlen) | SDL_GetErrorMsg(char *errstr, int maxlen) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -24,17 +24,18 @@ | |||||||
| #include "SDL_error.h" | #include "SDL_error.h" | ||||||
| #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; | ||||||
| @@ -129,8 +130,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; | ||||||
| @@ -197,8 +197,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; | ||||||
| @@ -259,8 +258,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; | ||||||
|   | |||||||
| @@ -37,7 +37,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" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -24,8 +24,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)); | ||||||
|  |  | ||||||
| @@ -40,8 +39,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; | ||||||
|  |  | ||||||
| @@ -62,8 +60,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; | ||||||
|  |  | ||||||
| @@ -78,8 +75,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; | ||||||
|   | |||||||
| @@ -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); | ||||||
|   | |||||||
| @@ -41,7 +41,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 | ||||||
|  |  | ||||||
| @@ -105,8 +104,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. */ | ||||||
| @@ -114,8 +112,7 @@ SDL_LogInit(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_LogQuit(void) | ||||||
| SDL_LogQuit(void) |  | ||||||
| { | { | ||||||
|     SDL_LogResetPriorities(); |     SDL_LogResetPriorities(); | ||||||
|     if (log_function_mutex) { |     if (log_function_mutex) { | ||||||
| @@ -124,8 +121,7 @@ SDL_LogQuit(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_LogSetAllPriority(SDL_LogPriority priority) | ||||||
| SDL_LogSetAllPriority(SDL_LogPriority priority) |  | ||||||
| { | { | ||||||
|     SDL_LogLevel *entry; |     SDL_LogLevel *entry; | ||||||
|  |  | ||||||
| @@ -137,8 +133,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; | ||||||
|  |  | ||||||
| @@ -181,8 +176,7 @@ SDL_LogGetPriority(int category) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_LogResetPriorities(void) | ||||||
| SDL_LogResetPriorities(void) |  | ||||||
| { | { | ||||||
|     SDL_LogLevel *entry; |     SDL_LogLevel *entry; | ||||||
|  |  | ||||||
| @@ -198,8 +192,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; | ||||||
|  |  | ||||||
| @@ -208,8 +201,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; | ||||||
|  |  | ||||||
| @@ -218,8 +210,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; | ||||||
|  |  | ||||||
| @@ -228,8 +219,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; | ||||||
|  |  | ||||||
| @@ -238,8 +228,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; | ||||||
|  |  | ||||||
| @@ -248,8 +237,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; | ||||||
|  |  | ||||||
| @@ -258,8 +246,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; | ||||||
|  |  | ||||||
| @@ -268,8 +255,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; | ||||||
|  |  | ||||||
| @@ -279,8 +265,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]; | ||||||
| @@ -292,8 +277,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]; | ||||||
| @@ -376,8 +360,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__) | ||||||
| @@ -504,8 +487,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; | ||||||
| @@ -515,8 +497,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; | ||||||
|   | |||||||
| @@ -50,6 +50,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 | ||||||
| @@ -74,7 +75,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 | ||||||
| @@ -106,16 +109,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); | ||||||
|  |  | ||||||
| @@ -123,7 +124,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) | ||||||
| { | { | ||||||
| @@ -185,8 +185,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)); | ||||||
| @@ -226,8 +225,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)); | ||||||
| @@ -250,8 +248,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); | ||||||
| @@ -299,14 +296,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(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -48,6 +48,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); | ||||||
| @@ -57,6 +58,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 | ||||||
| @@ -104,28 +106,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(__MACOSX__) || defined(__IPHONEOS__) | #elif defined(__MACOSX__) || defined(__IPHONEOS__) | ||||||
| @@ -150,7 +160,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. | ||||||
| @@ -158,8 +170,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? */ | ||||||
| @@ -174,8 +185,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); | ||||||
|   | |||||||
| @@ -132,7 +132,6 @@ static const AudioBootStrap *const bootstrap[] = { | |||||||
|     NULL |     NULL | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
| #ifdef HAVE_LIBSAMPLERATE_H | #ifdef HAVE_LIBSAMPLERATE_H | ||||||
| #ifdef SDL_LIBSAMPLERATE_DYNAMIC | #ifdef SDL_LIBSAMPLERATE_DYNAMIC | ||||||
| static void *SRC_lib = NULL; | static void *SRC_lib = NULL; | ||||||
| @@ -146,8 +145,7 @@ SRC_STATE* (*SRC_src_delete)(SRC_STATE *state) = NULL; | |||||||
| const char *(*SRC_src_strerror)(int error) = NULL; | const char *(*SRC_src_strerror)(int error) = NULL; | ||||||
| int (*SRC_src_simple)(SRC_DATA *data, int converter_type, int channels) = NULL; | int (*SRC_src_simple)(SRC_DATA *data, int converter_type, int channels) = NULL; | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool LoadLibSampleRate(void) | ||||||
| LoadLibSampleRate(void) |  | ||||||
| { | { | ||||||
|     const char *hint = SDL_GetHint(SDL_HINT_AUDIO_RESAMPLING_MODE); |     const char *hint = SDL_GetHint(SDL_HINT_AUDIO_RESAMPLING_MODE); | ||||||
|  |  | ||||||
| @@ -174,12 +172,14 @@ LoadLibSampleRate(void) | |||||||
|         return SDL_FALSE; |         return SDL_FALSE; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /* *INDENT-OFF* */ /* clang-format off */ | ||||||
|     SRC_src_new = (SRC_STATE* (*)(int converter_type, int channels, int *error))SDL_LoadFunction(SRC_lib, "src_new"); |     SRC_src_new = (SRC_STATE* (*)(int converter_type, int channels, int *error))SDL_LoadFunction(SRC_lib, "src_new"); | ||||||
|     SRC_src_process = (int (*)(SRC_STATE *state, SRC_DATA *data))SDL_LoadFunction(SRC_lib, "src_process"); |     SRC_src_process = (int (*)(SRC_STATE *state, SRC_DATA *data))SDL_LoadFunction(SRC_lib, "src_process"); | ||||||
|     SRC_src_reset = (int(*)(SRC_STATE *state))SDL_LoadFunction(SRC_lib, "src_reset"); |     SRC_src_reset = (int(*)(SRC_STATE *state))SDL_LoadFunction(SRC_lib, "src_reset"); | ||||||
|     SRC_src_delete = (SRC_STATE* (*)(SRC_STATE *state))SDL_LoadFunction(SRC_lib, "src_delete"); |     SRC_src_delete = (SRC_STATE* (*)(SRC_STATE *state))SDL_LoadFunction(SRC_lib, "src_delete"); | ||||||
|     SRC_src_strerror = (const char* (*)(int error))SDL_LoadFunction(SRC_lib, "src_strerror"); |     SRC_src_strerror = (const char* (*)(int error))SDL_LoadFunction(SRC_lib, "src_strerror"); | ||||||
|     SRC_src_simple = (int(*)(SRC_DATA *data, int converter_type, int channels))SDL_LoadFunction(SRC_lib, "src_simple"); |     SRC_src_simple = (int(*)(SRC_DATA *data, int converter_type, int channels))SDL_LoadFunction(SRC_lib, "src_simple"); | ||||||
|  | /* *INDENT-ON* */ /* clang-format on */ | ||||||
|  |  | ||||||
|     if (!SRC_src_new || !SRC_src_process || !SRC_src_reset || !SRC_src_delete || !SRC_src_strerror || !SRC_src_simple) { |     if (!SRC_src_new || !SRC_src_process || !SRC_src_reset || !SRC_src_delete || !SRC_src_strerror || !SRC_src_simple) { | ||||||
|         SDL_UnloadObject(SRC_lib); |         SDL_UnloadObject(SRC_lib); | ||||||
| @@ -199,8 +199,7 @@ LoadLibSampleRate(void) | |||||||
|     return SDL_TRUE; |     return SDL_TRUE; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void UnloadLibSampleRate(void) | ||||||
| UnloadLibSampleRate(void) |  | ||||||
| { | { | ||||||
| #ifdef SDL_LIBSAMPLERATE_DYNAMIC | #ifdef SDL_LIBSAMPLERATE_DYNAMIC | ||||||
|     if (SRC_lib != NULL) { |     if (SRC_lib != NULL) { | ||||||
| @@ -218,8 +217,7 @@ UnloadLibSampleRate(void) | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| static SDL_AudioDevice * | static SDL_AudioDevice *get_audio_device(SDL_AudioDeviceID id) | ||||||
| get_audio_device(SDL_AudioDeviceID id) |  | ||||||
| { | { | ||||||
|     id--; |     id--; | ||||||
|     if ((id >= SDL_arraysize(open_devices)) || (open_devices[id] == NULL)) { |     if ((id >= SDL_arraysize(open_devices)) || (open_devices[id] == NULL)) { | ||||||
| @@ -230,10 +228,8 @@ get_audio_device(SDL_AudioDeviceID id) | |||||||
|     return open_devices[id]; |     return open_devices[id]; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* stubs for audio drivers that don't need a specific entry point... */ | /* stubs for audio drivers that don't need a specific entry point... */ | ||||||
| static void | static void SDL_AudioDetectDevices_Default(void) | ||||||
| SDL_AudioDetectDevices_Default(void) |  | ||||||
| { | { | ||||||
|     /* you have to write your own implementation if these assertions fail. */ |     /* you have to write your own implementation if these assertions fail. */ | ||||||
|     SDL_assert(current_audio.impl.OnlyHasDefaultOutputDevice); |     SDL_assert(current_audio.impl.OnlyHasDefaultOutputDevice); | ||||||
| @@ -245,67 +241,54 @@ SDL_AudioDetectDevices_Default(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_AudioThreadInit_Default(_THIS) | ||||||
| SDL_AudioThreadInit_Default(_THIS) |  | ||||||
| { /* no-op. */ | { /* no-op. */ | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_AudioThreadDeinit_Default(_THIS) | ||||||
| SDL_AudioThreadDeinit_Default(_THIS) |  | ||||||
| { /* no-op. */ | { /* no-op. */ | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_AudioWaitDevice_Default(_THIS) | ||||||
| SDL_AudioWaitDevice_Default(_THIS) |  | ||||||
| { /* no-op. */ | { /* no-op. */ | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_AudioPlayDevice_Default(_THIS) | ||||||
| SDL_AudioPlayDevice_Default(_THIS) |  | ||||||
| { /* no-op. */ | { /* no-op. */ | ||||||
| } | } | ||||||
|  |  | ||||||
| static Uint8 * | static Uint8 *SDL_AudioGetDeviceBuf_Default(_THIS) | ||||||
| SDL_AudioGetDeviceBuf_Default(_THIS) |  | ||||||
| { | { | ||||||
|     return NULL; |     return NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_AudioCaptureFromDevice_Default(_THIS, void *buffer, int buflen) | ||||||
| SDL_AudioCaptureFromDevice_Default(_THIS, void *buffer, int buflen) |  | ||||||
| { | { | ||||||
|     return -1; /* just fail immediately. */ |     return -1; /* just fail immediately. */ | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_AudioFlushCapture_Default(_THIS) | ||||||
| SDL_AudioFlushCapture_Default(_THIS) |  | ||||||
| { /* no-op. */ | { /* no-op. */ | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_AudioCloseDevice_Default(_THIS) | ||||||
| SDL_AudioCloseDevice_Default(_THIS) |  | ||||||
| { /* no-op. */ | { /* no-op. */ | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_AudioDeinitialize_Default(void) | ||||||
| SDL_AudioDeinitialize_Default(void) |  | ||||||
| { /* no-op. */ | { /* no-op. */ | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_AudioFreeDeviceHandle_Default(void *handle) | ||||||
| SDL_AudioFreeDeviceHandle_Default(void *handle) |  | ||||||
| { /* no-op. */ | { /* no-op. */ | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static int SDL_AudioOpenDevice_Default(_THIS, const char *devname) | ||||||
| static int |  | ||||||
| SDL_AudioOpenDevice_Default(_THIS, const char *devname) |  | ||||||
| { | { | ||||||
|     return SDL_Unsupported(); |     return SDL_Unsupported(); | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_INLINE SDL_bool | static SDL_INLINE SDL_bool is_in_audio_device_thread(SDL_AudioDevice *device) | ||||||
| is_in_audio_device_thread(SDL_AudioDevice * device) |  | ||||||
| { | { | ||||||
|     /* The device thread locks the same mutex, but not through the public API. |     /* The device thread locks the same mutex, but not through the public API. | ||||||
|        This check is in case the application, in the audio callback, |        This check is in case the application, in the audio callback, | ||||||
| @@ -318,31 +301,27 @@ is_in_audio_device_thread(SDL_AudioDevice * device) | |||||||
|     return SDL_FALSE; |     return SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_AudioLockDevice_Default(SDL_AudioDevice *device) | ||||||
| SDL_AudioLockDevice_Default(SDL_AudioDevice * device) |  | ||||||
| { | { | ||||||
|     if (!is_in_audio_device_thread(device)) { |     if (!is_in_audio_device_thread(device)) { | ||||||
|         SDL_LockMutex(device->mixer_lock); |         SDL_LockMutex(device->mixer_lock); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_AudioUnlockDevice_Default(SDL_AudioDevice *device) | ||||||
| SDL_AudioUnlockDevice_Default(SDL_AudioDevice * device) |  | ||||||
| { | { | ||||||
|     if (!is_in_audio_device_thread(device)) { |     if (!is_in_audio_device_thread(device)) { | ||||||
|         SDL_UnlockMutex(device->mixer_lock); |         SDL_UnlockMutex(device->mixer_lock); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void finish_audio_entry_points_init(void) | ||||||
| finish_audio_entry_points_init(void) |  | ||||||
| { | { | ||||||
|     /* |     /* | ||||||
|      * Fill in stub functions for unused driver entry points. This lets us |      * Fill in stub functions for unused driver entry points. This lets us | ||||||
|      *  blindly call them without having to check for validity first. |      *  blindly call them without having to check for validity first. | ||||||
|      */ |      */ | ||||||
|  |  | ||||||
|  |  | ||||||
| #define FILL_STUB(x)                                   \ | #define FILL_STUB(x)                                   \ | ||||||
|     if (current_audio.impl.x == NULL) {                \ |     if (current_audio.impl.x == NULL) {                \ | ||||||
|         current_audio.impl.x = SDL_Audio##x##_Default; \ |         current_audio.impl.x = SDL_Audio##x##_Default; \ | ||||||
| @@ -364,11 +343,9 @@ finish_audio_entry_points_init(void) | |||||||
| #undef FILL_STUB | #undef FILL_STUB | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* device hotplug support... */ | /* device hotplug support... */ | ||||||
|  |  | ||||||
| static int | static int add_audio_device(const char *name, SDL_AudioSpec *spec, void *handle, SDL_AudioDeviceItem **devices, int *devCount) | ||||||
| add_audio_device(const char *name, SDL_AudioSpec *spec, void *handle, SDL_AudioDeviceItem **devices, int *devCount) |  | ||||||
| { | { | ||||||
|     int retval = -1; |     int retval = -1; | ||||||
|     SDL_AudioDeviceItem *item; |     SDL_AudioDeviceItem *item; | ||||||
| @@ -431,21 +408,18 @@ add_audio_device(const char *name, SDL_AudioSpec *spec, void *handle, SDL_AudioD | |||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_INLINE int | static SDL_INLINE int add_capture_device(const char *name, SDL_AudioSpec *spec, void *handle) | ||||||
| add_capture_device(const char *name, SDL_AudioSpec *spec, void *handle) |  | ||||||
| { | { | ||||||
|     SDL_assert(current_audio.impl.HasCaptureSupport); |     SDL_assert(current_audio.impl.HasCaptureSupport); | ||||||
|     return add_audio_device(name, spec, handle, ¤t_audio.inputDevices, ¤t_audio.inputDeviceCount); |     return add_audio_device(name, spec, handle, ¤t_audio.inputDevices, ¤t_audio.inputDeviceCount); | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_INLINE int | static SDL_INLINE int add_output_device(const char *name, SDL_AudioSpec *spec, void *handle) | ||||||
| add_output_device(const char *name, SDL_AudioSpec *spec, void *handle) |  | ||||||
| { | { | ||||||
|     return add_audio_device(name, spec, handle, ¤t_audio.outputDevices, ¤t_audio.outputDeviceCount); |     return add_audio_device(name, spec, handle, ¤t_audio.outputDevices, ¤t_audio.outputDeviceCount); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void free_device_list(SDL_AudioDeviceItem **devices, int *devCount) | ||||||
| free_device_list(SDL_AudioDeviceItem **devices, int *devCount) |  | ||||||
| { | { | ||||||
|     SDL_AudioDeviceItem *item, *next; |     SDL_AudioDeviceItem *item, *next; | ||||||
|     for (item = *devices; item != NULL; item = next) { |     for (item = *devices; item != NULL; item = next) { | ||||||
| @@ -464,10 +438,8 @@ free_device_list(SDL_AudioDeviceItem **devices, int *devCount) | |||||||
|     *devCount = 0; |     *devCount = 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* The audio backends call this when a new device is plugged in. */ | /* The audio backends call this when a new device is plugged in. */ | ||||||
| void | void SDL_AddAudioDevice(const SDL_bool iscapture, const char *name, SDL_AudioSpec *spec, void *handle) | ||||||
| SDL_AddAudioDevice(const SDL_bool iscapture, const char *name, SDL_AudioSpec *spec, void *handle) |  | ||||||
| { | { | ||||||
|     const int device_index = iscapture ? add_capture_device(name, spec, handle) : add_output_device(name, spec, handle); |     const int device_index = iscapture ? add_capture_device(name, spec, handle) : add_output_device(name, spec, handle); | ||||||
|     if (device_index != -1) { |     if (device_index != -1) { | ||||||
| @@ -513,8 +485,7 @@ void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_bool *removedFlag) | ||||||
| mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_bool *removedFlag) |  | ||||||
| { | { | ||||||
|     SDL_AudioDeviceItem *item; |     SDL_AudioDeviceItem *item; | ||||||
|     SDL_assert(handle != NULL); |     SDL_assert(handle != NULL); | ||||||
| @@ -528,8 +499,7 @@ mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_bool *remove | |||||||
| } | } | ||||||
|  |  | ||||||
| /* The audio backends call this when a device is removed from the system. */ | /* The audio backends call this when a device is removed from the system. */ | ||||||
| void | void SDL_RemoveAudioDevice(const SDL_bool iscapture, void *handle) | ||||||
| SDL_RemoveAudioDevice(const SDL_bool iscapture, void *handle) |  | ||||||
| { | { | ||||||
|     int device_index; |     int device_index; | ||||||
|     SDL_AudioDevice *device = NULL; |     SDL_AudioDevice *device = NULL; | ||||||
| @@ -572,12 +542,9 @@ SDL_RemoveAudioDevice(const SDL_bool iscapture, void *handle) | |||||||
|     current_audio.impl.FreeDeviceHandle(handle); |     current_audio.impl.FreeDeviceHandle(handle); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| /* buffer queueing support... */ | /* buffer queueing support... */ | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_BufferQueueDrainCallback(void *userdata, Uint8 *stream, int len) | ||||||
| SDL_BufferQueueDrainCallback(void *userdata, Uint8 *stream, int len) |  | ||||||
| { | { | ||||||
|     /* this function always holds the mixer lock before being called. */ |     /* this function always holds the mixer lock before being called. */ | ||||||
|     SDL_AudioDevice *device = (SDL_AudioDevice *)userdata; |     SDL_AudioDevice *device = (SDL_AudioDevice *)userdata; | ||||||
| @@ -597,8 +564,7 @@ SDL_BufferQueueDrainCallback(void *userdata, Uint8 *stream, int len) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_BufferQueueFillCallback(void *userdata, Uint8 *stream, int len) | ||||||
| SDL_BufferQueueFillCallback(void *userdata, Uint8 *stream, int len) |  | ||||||
| { | { | ||||||
|     /* this function always holds the mixer lock before being called. */ |     /* this function always holds the mixer lock before being called. */ | ||||||
|     SDL_AudioDevice *device = (SDL_AudioDevice *)userdata; |     SDL_AudioDevice *device = (SDL_AudioDevice *)userdata; | ||||||
| @@ -613,8 +579,7 @@ SDL_BufferQueueFillCallback(void *userdata, Uint8 *stream, int len) | |||||||
|     SDL_WriteToDataQueue(device->buffer_queue, stream, len); |     SDL_WriteToDataQueue(device->buffer_queue, stream, len); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_QueueAudio(SDL_AudioDeviceID devid, const void *data, Uint32 len) | ||||||
| SDL_QueueAudio(SDL_AudioDeviceID devid, const void *data, Uint32 len) |  | ||||||
| { | { | ||||||
|     SDL_AudioDevice *device = get_audio_device(devid); |     SDL_AudioDevice *device = get_audio_device(devid); | ||||||
|     int rc = 0; |     int rc = 0; | ||||||
| @@ -667,8 +632,7 @@ SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid) | |||||||
|  |  | ||||||
|     /* Nothing to do unless we're set up for queueing. */ |     /* Nothing to do unless we're set up for queueing. */ | ||||||
|     if (device->callbackspec.callback == SDL_BufferQueueDrainCallback || |     if (device->callbackspec.callback == SDL_BufferQueueDrainCallback || | ||||||
|         device->callbackspec.callback == SDL_BufferQueueFillCallback) |         device->callbackspec.callback == SDL_BufferQueueFillCallback) { | ||||||
|     { |  | ||||||
|         current_audio.impl.LockDevice(device); |         current_audio.impl.LockDevice(device); | ||||||
|         retval = (Uint32)SDL_CountDataQueue(device->buffer_queue); |         retval = (Uint32)SDL_CountDataQueue(device->buffer_queue); | ||||||
|         current_audio.impl.UnlockDevice(device); |         current_audio.impl.UnlockDevice(device); | ||||||
| @@ -677,8 +641,7 @@ SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid) | |||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_ClearQueuedAudio(SDL_AudioDeviceID devid) | ||||||
| SDL_ClearQueuedAudio(SDL_AudioDeviceID devid) |  | ||||||
| { | { | ||||||
|     SDL_AudioDevice *device = get_audio_device(devid); |     SDL_AudioDevice *device = get_audio_device(devid); | ||||||
|  |  | ||||||
| @@ -695,10 +658,8 @@ SDL_ClearQueuedAudio(SDL_AudioDeviceID devid) | |||||||
|     current_audio.impl.UnlockDevice(device); |     current_audio.impl.UnlockDevice(device); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* The general mixing thread function */ | /* The general mixing thread function */ | ||||||
| static int SDLCALL | static int SDLCALL SDL_RunAudio(void *devicep) | ||||||
| SDL_RunAudio(void *devicep) |  | ||||||
| { | { | ||||||
|     SDL_AudioDevice *device = (SDL_AudioDevice *)devicep; |     SDL_AudioDevice *device = (SDL_AudioDevice *)devicep; | ||||||
|     void *udata = device->callbackspec.userdata; |     void *udata = device->callbackspec.userdata; | ||||||
| @@ -797,8 +758,7 @@ SDL_RunAudio(void *devicep) | |||||||
|  |  | ||||||
| /* !!! FIXME: this needs to deal with device spec changes. */ | /* !!! FIXME: this needs to deal with device spec changes. */ | ||||||
| /* The general capture thread function */ | /* The general capture thread function */ | ||||||
| static int SDLCALL | static int SDLCALL SDL_CaptureAudio(void *devicep) | ||||||
| SDL_CaptureAudio(void *devicep) |  | ||||||
| { | { | ||||||
|     SDL_AudioDevice *device = (SDL_AudioDevice *)devicep; |     SDL_AudioDevice *device = (SDL_AudioDevice *)devicep; | ||||||
|     const int silence = (int)device->spec.silence; |     const int silence = (int)device->spec.silence; | ||||||
| @@ -908,11 +868,11 @@ SDL_CaptureAudio(void *devicep) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static SDL_AudioFormat SDL_ParseAudioFormat(const char *string) | ||||||
| static SDL_AudioFormat |  | ||||||
| SDL_ParseAudioFormat(const char *string) |  | ||||||
| { | { | ||||||
| #define CHECK_FMT_STRING(x) if (SDL_strcmp(string, #x) == 0) return AUDIO_##x | #define CHECK_FMT_STRING(x)          \ | ||||||
|  |     if (SDL_strcmp(string, #x) == 0) \ | ||||||
|  |     return AUDIO_##x | ||||||
|     CHECK_FMT_STRING(U8); |     CHECK_FMT_STRING(U8); | ||||||
|     CHECK_FMT_STRING(S8); |     CHECK_FMT_STRING(S8); | ||||||
|     CHECK_FMT_STRING(U16LSB); |     CHECK_FMT_STRING(U16LSB); | ||||||
| @@ -935,8 +895,7 @@ SDL_ParseAudioFormat(const char *string) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_GetNumAudioDrivers(void) | ||||||
| SDL_GetNumAudioDrivers(void) |  | ||||||
| { | { | ||||||
|     return SDL_arraysize(bootstrap) - 1; |     return SDL_arraysize(bootstrap) - 1; | ||||||
| } | } | ||||||
| @@ -950,8 +909,7 @@ SDL_GetAudioDriver(int index) | |||||||
|     return NULL; |     return NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_AudioInit(const char *driver_name) | ||||||
| SDL_AudioInit(const char *driver_name) |  | ||||||
| { | { | ||||||
|     int i; |     int i; | ||||||
|     SDL_bool initialized = SDL_FALSE, tried_to_init = SDL_FALSE; |     SDL_bool initialized = SDL_FALSE, tried_to_init = SDL_FALSE; | ||||||
| @@ -1057,8 +1015,7 @@ SDL_GetCurrentAudioDriver() | |||||||
| } | } | ||||||
|  |  | ||||||
| /* Clean out devices that we've removed but had to keep around for stability. */ | /* Clean out devices that we've removed but had to keep around for stability. */ | ||||||
| static void | static void clean_out_device_list(SDL_AudioDeviceItem **devices, int *devCount, SDL_bool *removedFlag) | ||||||
| clean_out_device_list(SDL_AudioDeviceItem **devices, int *devCount, SDL_bool *removedFlag) |  | ||||||
| { | { | ||||||
|     SDL_AudioDeviceItem *item = *devices; |     SDL_AudioDeviceItem *item = *devices; | ||||||
|     SDL_AudioDeviceItem *prev = NULL; |     SDL_AudioDeviceItem *prev = NULL; | ||||||
| @@ -1089,9 +1046,7 @@ clean_out_device_list(SDL_AudioDeviceItem **devices, int *devCount, SDL_bool *re | |||||||
|     *removedFlag = SDL_FALSE; |     *removedFlag = SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | int SDL_GetNumAudioDevices(int iscapture) | ||||||
| int |  | ||||||
| SDL_GetNumAudioDevices(int iscapture) |  | ||||||
| { | { | ||||||
|     int retval = 0; |     int retval = 0; | ||||||
|  |  | ||||||
| @@ -1114,7 +1069,6 @@ SDL_GetNumAudioDevices(int iscapture) | |||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| const char * | const char * | ||||||
| SDL_GetAudioDeviceName(int index, int iscapture) | SDL_GetAudioDeviceName(int index, int iscapture) | ||||||
| { | { | ||||||
| @@ -1145,9 +1099,7 @@ SDL_GetAudioDeviceName(int index, int iscapture) | |||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | int SDL_GetAudioDeviceSpec(int index, int iscapture, SDL_AudioSpec *spec) | ||||||
| int |  | ||||||
| SDL_GetAudioDeviceSpec(int index, int iscapture, SDL_AudioSpec *spec) |  | ||||||
| { | { | ||||||
|     SDL_AudioDeviceItem *item; |     SDL_AudioDeviceItem *item; | ||||||
|     int i, retval; |     int i, retval; | ||||||
| @@ -1178,9 +1130,7 @@ SDL_GetAudioDeviceSpec(int index, int iscapture, SDL_AudioSpec *spec) | |||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | int SDL_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) | ||||||
| int |  | ||||||
| SDL_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) |  | ||||||
| { | { | ||||||
|     if (spec == NULL) { |     if (spec == NULL) { | ||||||
|         return SDL_InvalidParamError("spec"); |         return SDL_InvalidParamError("spec"); | ||||||
| @@ -1196,9 +1146,7 @@ SDL_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) | |||||||
|     return current_audio.impl.GetDefaultAudioInfo(name, spec, iscapture); |     return current_audio.impl.GetDefaultAudioInfo(name, spec, iscapture); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static void close_audio_device(SDL_AudioDevice *device) | ||||||
| static void |  | ||||||
| close_audio_device(SDL_AudioDevice * device) |  | ||||||
| { | { | ||||||
|     if (!device) { |     if (!device) { | ||||||
|         return; |         return; | ||||||
| @@ -1239,14 +1187,12 @@ close_audio_device(SDL_AudioDevice * device) | |||||||
|     SDL_free(device); |     SDL_free(device); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Sanity check desired AudioSpec for SDL_OpenAudio() in (orig). |  * Sanity check desired AudioSpec for SDL_OpenAudio() in (orig). | ||||||
|  *  Fills in a sanitized copy in (prepared). |  *  Fills in a sanitized copy in (prepared). | ||||||
|  *  Returns non-zero if okay, zero on fatal parameters in (orig). |  *  Returns non-zero if okay, zero on fatal parameters in (orig). | ||||||
|  */ |  */ | ||||||
| static int | static int prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared) | ||||||
| prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared) |  | ||||||
| { | { | ||||||
|     SDL_copyp(prepared, orig); |     SDL_copyp(prepared, orig); | ||||||
|  |  | ||||||
| @@ -1294,8 +1240,7 @@ prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared) | |||||||
|     return 1; |     return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_AudioDeviceID | static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, | ||||||
| open_audio_device(const char *devname, int iscapture, |  | ||||||
|                                            const SDL_AudioSpec *desired, SDL_AudioSpec *obtained, |                                            const SDL_AudioSpec *desired, SDL_AudioSpec *obtained, | ||||||
|                                            int allowed_changes, int min_id) |                                            int allowed_changes, int min_id) | ||||||
| { | { | ||||||
| @@ -1558,9 +1503,7 @@ open_audio_device(const char *devname, int iscapture, | |||||||
|     return device->id; |     return device->id; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) | ||||||
| int |  | ||||||
| SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained) |  | ||||||
| { | { | ||||||
|     SDL_AudioDeviceID id = 0; |     SDL_AudioDeviceID id = 0; | ||||||
|  |  | ||||||
| @@ -1618,15 +1561,13 @@ SDL_GetAudioDeviceStatus(SDL_AudioDeviceID devid) | |||||||
|     return status; |     return status; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| SDL_AudioStatus | SDL_AudioStatus | ||||||
| SDL_GetAudioStatus(void) | SDL_GetAudioStatus(void) | ||||||
| { | { | ||||||
|     return SDL_GetAudioDeviceStatus(1); |     return SDL_GetAudioDeviceStatus(1); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on) | ||||||
| SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on) |  | ||||||
| { | { | ||||||
|     SDL_AudioDevice *device = get_audio_device(devid); |     SDL_AudioDevice *device = get_audio_device(devid); | ||||||
|     if (device) { |     if (device) { | ||||||
| @@ -1636,15 +1577,12 @@ SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_PauseAudio(int pause_on) | ||||||
| SDL_PauseAudio(int pause_on) |  | ||||||
| { | { | ||||||
|     SDL_PauseAudioDevice(1, pause_on); |     SDL_PauseAudioDevice(1, pause_on); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void SDL_LockAudioDevice(SDL_AudioDeviceID devid) | ||||||
| void |  | ||||||
| SDL_LockAudioDevice(SDL_AudioDeviceID devid) |  | ||||||
| { | { | ||||||
|     /* Obtain a lock on the mixing buffers */ |     /* Obtain a lock on the mixing buffers */ | ||||||
|     SDL_AudioDevice *device = get_audio_device(devid); |     SDL_AudioDevice *device = get_audio_device(devid); | ||||||
| @@ -1653,14 +1591,12 @@ SDL_LockAudioDevice(SDL_AudioDeviceID devid) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_LockAudio(void) | ||||||
| SDL_LockAudio(void) |  | ||||||
| { | { | ||||||
|     SDL_LockAudioDevice(1); |     SDL_LockAudioDevice(1); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_UnlockAudioDevice(SDL_AudioDeviceID devid) | ||||||
| SDL_UnlockAudioDevice(SDL_AudioDeviceID devid) |  | ||||||
| { | { | ||||||
|     /* Obtain a lock on the mixing buffers */ |     /* Obtain a lock on the mixing buffers */ | ||||||
|     SDL_AudioDevice *device = get_audio_device(devid); |     SDL_AudioDevice *device = get_audio_device(devid); | ||||||
| @@ -1669,26 +1605,22 @@ SDL_UnlockAudioDevice(SDL_AudioDeviceID devid) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_UnlockAudio(void) | ||||||
| SDL_UnlockAudio(void) |  | ||||||
| { | { | ||||||
|     SDL_UnlockAudioDevice(1); |     SDL_UnlockAudioDevice(1); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_CloseAudioDevice(SDL_AudioDeviceID devid) | ||||||
| SDL_CloseAudioDevice(SDL_AudioDeviceID devid) |  | ||||||
| { | { | ||||||
|     close_audio_device(get_audio_device(devid)); |     close_audio_device(get_audio_device(devid)); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_CloseAudio(void) | ||||||
| SDL_CloseAudio(void) |  | ||||||
| { | { | ||||||
|     SDL_CloseAudioDevice(1); |     SDL_CloseAudioDevice(1); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_AudioQuit(void) | ||||||
| SDL_AudioQuit(void) |  | ||||||
| { | { | ||||||
|     SDL_AudioDeviceID i; |     SDL_AudioDeviceID i; | ||||||
|  |  | ||||||
| @@ -1763,8 +1695,7 @@ SDL_NextAudioFormat(void) | |||||||
|     return format_list[format_idx][format_idx_sub++]; |     return format_list[format_idx][format_idx_sub++]; | ||||||
| } | } | ||||||
|  |  | ||||||
| Uint8 | Uint8 SDL_SilenceValueForFormat(const SDL_AudioFormat format) | ||||||
| SDL_SilenceValueForFormat(const SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     switch (format) { |     switch (format) { | ||||||
|     /* !!! FIXME: 0x80 isn't perfect for U16, but we can't fit 0x8000 in a |     /* !!! FIXME: 0x80 isn't perfect for U16, but we can't fit 0x8000 in a | ||||||
| @@ -1775,14 +1706,14 @@ SDL_SilenceValueForFormat(const SDL_AudioFormat format) | |||||||
|     case AUDIO_U8: |     case AUDIO_U8: | ||||||
|         return 0x80; |         return 0x80; | ||||||
|  |  | ||||||
|         default: break; |     default: | ||||||
|  |         break; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return 0x00; |     return 0x00; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_CalculateAudioSpec(SDL_AudioSpec *spec) | ||||||
| SDL_CalculateAudioSpec(SDL_AudioSpec * spec) |  | ||||||
| { | { | ||||||
|     spec->silence = SDL_SilenceValueForFormat(spec->format); |     spec->silence = SDL_SilenceValueForFormat(spec->format); | ||||||
|     spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8; |     spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8; | ||||||
| @@ -1790,13 +1721,11 @@ SDL_CalculateAudioSpec(SDL_AudioSpec * spec) | |||||||
|     spec->size *= spec->samples; |     spec->size *= spec->samples; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Moved here from SDL_mixer.c, since it relies on internals of an opened |  * Moved here from SDL_mixer.c, since it relies on internals of an opened | ||||||
|  *  audio device (and is deprecated, by the way!). |  *  audio device (and is deprecated, by the way!). | ||||||
|  */ |  */ | ||||||
| void | void SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume) | ||||||
| SDL_MixAudio(Uint8 * dst, const Uint8 * src, Uint32 len, int volume) |  | ||||||
| { | { | ||||||
|     /* Mix the user-level audio format */ |     /* Mix the user-level audio format */ | ||||||
|     SDL_AudioDevice *device = get_audio_device(1); |     SDL_AudioDevice *device = get_audio_device(1); | ||||||
|   | |||||||
| @@ -21,8 +21,7 @@ | |||||||
|  |  | ||||||
| /* DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_channel_conversion.c */ | /* DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_channel_conversion.c */ | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertMonoToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertMonoToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 2))) - 2; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 2))) - 2; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
| @@ -44,8 +43,7 @@ SDL_ConvertMonoToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertMonoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertMonoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 3))) - 3; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 3))) - 3; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
| @@ -68,8 +66,7 @@ SDL_ConvertMonoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertMonoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertMonoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 4))) - 4; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 4))) - 4; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
| @@ -93,8 +90,7 @@ SDL_ConvertMonoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertMonoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertMonoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 5))) - 5; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 5))) - 5; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
| @@ -119,8 +115,7 @@ SDL_ConvertMonoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertMonoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertMonoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 6))) - 6; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 6))) - 6; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
| @@ -146,8 +141,7 @@ SDL_ConvertMonoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertMonoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertMonoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 7))) - 7; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 7))) - 7; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
| @@ -174,8 +168,7 @@ SDL_ConvertMonoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertMonoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertMonoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 8))) - 8; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 1) * 8))) - 8; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
| @@ -203,8 +196,7 @@ SDL_ConvertMonoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertStereoToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertStereoToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -223,8 +215,7 @@ SDL_ConvertStereoToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertStereoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertStereoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 3))) - 3; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 3))) - 3; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; | ||||||
| @@ -246,8 +237,7 @@ SDL_ConvertStereoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertStereoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertStereoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 4))) - 4; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 4))) - 4; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; | ||||||
| @@ -270,8 +260,7 @@ SDL_ConvertStereoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertStereoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertStereoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 5))) - 5; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 5))) - 5; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; | ||||||
| @@ -295,8 +284,7 @@ SDL_ConvertStereoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertStereoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertStereoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 6))) - 6; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 6))) - 6; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; | ||||||
| @@ -321,8 +309,7 @@ SDL_ConvertStereoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertStereoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertStereoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 7))) - 7; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 7))) - 7; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; | ||||||
| @@ -348,8 +335,7 @@ SDL_ConvertStereoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertStereoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertStereoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 8))) - 8; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 2) * 8))) - 8; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 2; | ||||||
| @@ -376,8 +362,7 @@ SDL_ConvertStereoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert21ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert21ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -396,8 +381,7 @@ SDL_Convert21ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert21ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert21ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -418,8 +402,7 @@ SDL_Convert21ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert21ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert21ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 4))) - 4; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 4))) - 4; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; | ||||||
| @@ -443,8 +426,7 @@ SDL_Convert21ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert21To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert21To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 5))) - 5; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 5))) - 5; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; | ||||||
| @@ -468,8 +450,7 @@ SDL_Convert21To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert21To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert21To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 6))) - 6; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 6))) - 6; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; | ||||||
| @@ -494,8 +475,7 @@ SDL_Convert21To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert21To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert21To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 7))) - 7; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 7))) - 7; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; | ||||||
| @@ -521,8 +501,7 @@ SDL_Convert21To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert21To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert21To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 8))) - 8; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 3) * 8))) - 8; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 3; | ||||||
| @@ -549,8 +528,7 @@ SDL_Convert21To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertQuadToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertQuadToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -569,8 +547,7 @@ SDL_ConvertQuadToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertQuadToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertQuadToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -592,8 +569,7 @@ SDL_ConvertQuadToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertQuadTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertQuadTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -616,8 +592,7 @@ SDL_ConvertQuadTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertQuadTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertQuadTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 4) * 5))) - 5; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 4) * 5))) - 5; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; | ||||||
| @@ -641,8 +616,7 @@ SDL_ConvertQuadTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertQuadTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertQuadTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 4) * 6))) - 6; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 4) * 6))) - 6; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; | ||||||
| @@ -667,8 +641,7 @@ SDL_ConvertQuadTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertQuadTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertQuadTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 4) * 7))) - 7; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 4) * 7))) - 7; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; | ||||||
| @@ -696,8 +669,7 @@ SDL_ConvertQuadTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertQuadTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertQuadTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 4) * 8))) - 8; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 4) * 8))) - 8; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; | ||||||
| @@ -724,8 +696,7 @@ SDL_ConvertQuadTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert41ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert41ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -744,8 +715,7 @@ SDL_Convert41ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert41ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert41ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -768,8 +738,7 @@ SDL_Convert41ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert41To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert41To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -792,8 +761,7 @@ SDL_Convert41To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert41ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert41ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -816,8 +784,7 @@ SDL_Convert41ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert41To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert41To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 5) * 6))) - 6; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 5) * 6))) - 6; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 5; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 5; | ||||||
| @@ -842,8 +809,7 @@ SDL_Convert41To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert41To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert41To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 5) * 7))) - 7; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 5) * 7))) - 7; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 5; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 5; | ||||||
| @@ -871,8 +837,7 @@ SDL_Convert41To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert41To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert41To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 5) * 8))) - 8; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 5) * 8))) - 8; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 5; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 5; | ||||||
| @@ -899,8 +864,7 @@ SDL_Convert41To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert51ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert51ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -919,8 +883,7 @@ SDL_Convert51ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert51ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert51ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -944,8 +907,7 @@ SDL_Convert51ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert51To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert51To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -969,8 +931,7 @@ SDL_Convert51To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert51ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert51ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -994,8 +955,7 @@ SDL_Convert51ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert51To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert51To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -1019,8 +979,7 @@ SDL_Convert51To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert51To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert51To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 6) * 7))) - 7; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 6) * 7))) - 7; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 6; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 6; | ||||||
| @@ -1048,8 +1007,7 @@ SDL_Convert51To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert51To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert51To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 6) * 8))) - 8; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 6) * 8))) - 8; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 6; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 6; | ||||||
| @@ -1076,8 +1034,7 @@ SDL_Convert51To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert61ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert61ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -1096,8 +1053,7 @@ SDL_Convert61ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert61ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert61ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -1122,8 +1078,7 @@ SDL_Convert61ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert61To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert61To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -1148,8 +1103,7 @@ SDL_Convert61To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert61ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert61ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -1176,8 +1130,7 @@ SDL_Convert61ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert61To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert61To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -1204,8 +1157,7 @@ SDL_Convert61To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert61To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert61To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -1232,8 +1184,7 @@ SDL_Convert61To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert61To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert61To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 7) * 8))) - 8; |     float *dst = ((float *)(cvt->buf + ((cvt->len_cvt / 7) * 8))) - 8; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 7; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 7; | ||||||
| @@ -1261,8 +1212,7 @@ SDL_Convert61To71(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert71ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert71ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -1281,8 +1231,7 @@ SDL_Convert71ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert71ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert71ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -1308,8 +1257,7 @@ SDL_Convert71ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert71To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert71To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -1335,8 +1283,7 @@ SDL_Convert71To21(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert71ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert71ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -1362,8 +1309,7 @@ SDL_Convert71ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert71To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert71To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -1389,8 +1335,7 @@ SDL_Convert71To41(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert71To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert71To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -1416,8 +1361,7 @@ SDL_Convert71To51(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert71To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert71To61(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
|     const float *src = dst; |     const float *src = dst; | ||||||
| @@ -1456,4 +1400,3 @@ static const SDL_AudioFilter channel_converters[8][8] = {   /* [from][to] */ | |||||||
| }; | }; | ||||||
|  |  | ||||||
| /* vi: set ts=4 sw=4 expandtab: */ | /* vi: set ts=4 sw=4 expandtab: */ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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: */ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -95,8 +95,7 @@ | |||||||
|  |  | ||||||
| #if HAVE_SSE3_INTRINSICS | #if HAVE_SSE3_INTRINSICS | ||||||
| /* Convert from stereo to mono. Average left and right. */ | /* Convert from stereo to mono. Average left and right. */ | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT * cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const __m128 divby2 = _mm_set1_ps(0.5f); |     const __m128 divby2 = _mm_set1_ps(0.5f); | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
| @@ -111,13 +110,17 @@ SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT * cvt, SDL_AudioFormat format) | |||||||
|        aligned it'll be just as fast on modern processors */ |        aligned it'll be just as fast on modern processors */ | ||||||
|     while (i >= 4) { /* 4 * float32 */ |     while (i >= 4) { /* 4 * float32 */ | ||||||
|         _mm_storeu_ps(dst, _mm_mul_ps(_mm_hadd_ps(_mm_loadu_ps(src), _mm_loadu_ps(src + 4)), divby2)); |         _mm_storeu_ps(dst, _mm_mul_ps(_mm_hadd_ps(_mm_loadu_ps(src), _mm_loadu_ps(src + 4)), divby2)); | ||||||
|         i -= 4; src += 8; dst += 4; |         i -= 4; | ||||||
|  |         src += 8; | ||||||
|  |         dst += 4; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* Finish off any leftovers with scalar operations. */ |     /* Finish off any leftovers with scalar operations. */ | ||||||
|     while (i) { |     while (i) { | ||||||
|         *dst = (src[0] + src[1]) * 0.5f; |         *dst = (src[0] + src[1]) * 0.5f; | ||||||
|         dst++; i--; src += 2; |         dst++; | ||||||
|  |         i--; | ||||||
|  |         src += 2; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt /= 2; |     cvt->len_cvt /= 2; | ||||||
| @@ -129,8 +132,7 @@ SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT * cvt, SDL_AudioFormat format) | |||||||
|  |  | ||||||
| #if HAVE_SSE_INTRINSICS | #if HAVE_SSE_INTRINSICS | ||||||
| /* Convert from mono to stereo. Duplicate to stereo left and right. */ | /* Convert from mono to stereo. Duplicate to stereo left and right. */ | ||||||
| static void SDLCALL | static void SDLCALL SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT * cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     float *dst = ((float *)(cvt->buf + (cvt->len_cvt * 2))) - 8; |     float *dst = ((float *)(cvt->buf + (cvt->len_cvt * 2))) - 8; | ||||||
|     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; |     const float *src = ((const float *)(cvt->buf + cvt->len_cvt)) - 4; | ||||||
| @@ -147,16 +149,21 @@ SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT * cvt, SDL_AudioFormat format) | |||||||
|         const __m128 input = _mm_loadu_ps(src);                /* A B C D */ |         const __m128 input = _mm_loadu_ps(src);                /* A B C D */ | ||||||
|         _mm_storeu_ps(dst, _mm_unpacklo_ps(input, input));     /* A A B B */ |         _mm_storeu_ps(dst, _mm_unpacklo_ps(input, input));     /* A A B B */ | ||||||
|         _mm_storeu_ps(dst + 4, _mm_unpackhi_ps(input, input)); /* C C D D */ |         _mm_storeu_ps(dst + 4, _mm_unpackhi_ps(input, input)); /* C C D D */ | ||||||
|         i -= 4; src -= 4; dst -= 8; |         i -= 4; | ||||||
|  |         src -= 4; | ||||||
|  |         dst -= 8; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* Finish off any leftovers with scalar operations. */ |     /* Finish off any leftovers with scalar operations. */ | ||||||
|     src += 3; dst += 6;  /* adjust for smaller buffers. */ |     src += 3; | ||||||
|  |     dst += 6;   /* adjust for smaller buffers. */ | ||||||
|     while (i) { /* convert backwards, since output is growing in-place. */ |     while (i) { /* convert backwards, since output is growing in-place. */ | ||||||
|         const float srcFC = src[0]; |         const float srcFC = src[0]; | ||||||
|         dst[1] /* FR */ = srcFC; |         dst[1] /* FR */ = srcFC; | ||||||
|         dst[0] /* FL */ = srcFC; |         dst[0] /* FL */ = srcFC; | ||||||
|         i--; src--; dst -= 2; |         i--; | ||||||
|  |         src--; | ||||||
|  |         dst -= 2; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt *= 2; |     cvt->len_cvt *= 2; | ||||||
| @@ -166,19 +173,15 @@ SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT * cvt, SDL_AudioFormat format) | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Include the autogenerated channel converters... */ | /* Include the autogenerated channel converters... */ | ||||||
| #include "SDL_audio_channel_converters.h" | #include "SDL_audio_channel_converters.h" | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| /* SDL's resampler uses a "bandlimited interpolation" algorithm: | /* SDL's resampler uses a "bandlimited interpolation" algorithm: | ||||||
|      https://ccrma.stanford.edu/~jos/resample/ */ |      https://ccrma.stanford.edu/~jos/resample/ */ | ||||||
|  |  | ||||||
| #include "SDL_audio_resampler_filter.h" | #include "SDL_audio_resampler_filter.h" | ||||||
|  |  | ||||||
| static int | static int ResamplerPadding(const int inrate, const int outrate) | ||||||
| ResamplerPadding(const int inrate, const int outrate) |  | ||||||
| { | { | ||||||
|     if (inrate == outrate) { |     if (inrate == outrate) { | ||||||
|         return 0; |         return 0; | ||||||
| @@ -190,8 +193,7 @@ ResamplerPadding(const int inrate, const int outrate) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* lpadding and rpadding are expected to be buffers of (ResamplePadding(inrate, outrate) * chans * sizeof (float)) bytes. */ | /* lpadding and rpadding are expected to be buffers of (ResamplePadding(inrate, outrate) * chans * sizeof (float)) bytes. */ | ||||||
| static int | static int SDL_ResampleAudio(const int chans, const int inrate, const int outrate, | ||||||
| SDL_ResampleAudio(const int chans, const int inrate, const int outrate, |  | ||||||
|                              const float *lpadding, const float *rpadding, |                              const float *lpadding, const float *rpadding, | ||||||
|                              const float *inbuf, const int inbuflen, |                              const float *inbuf, const int inbuflen, | ||||||
|                              float *outbuf, const int outbuflen) |                              float *outbuf, const int outbuflen) | ||||||
| @@ -252,8 +254,7 @@ SDL_ResampleAudio(const int chans, const int inrate, const int outrate, | |||||||
|     return outframes * chans * sizeof(float); |     return outframes * chans * sizeof(float); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_ConvertAudio(SDL_AudioCVT *cvt) | ||||||
| SDL_ConvertAudio(SDL_AudioCVT * cvt) |  | ||||||
| { | { | ||||||
|     /* !!! FIXME: (cvt) should be const; stack-copy it here. */ |     /* !!! FIXME: (cvt) should be const; stack-copy it here. */ | ||||||
|     /* !!! FIXME: (actually, we can't...len_cvt needs to be updated. Grr.) */ |     /* !!! FIXME: (actually, we can't...len_cvt needs to be updated. Grr.) */ | ||||||
| @@ -275,8 +276,7 @@ SDL_ConvertAudio(SDL_AudioCVT * cvt) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
| #if DEBUG_CONVERT | #if DEBUG_CONVERT | ||||||
|     SDL_Log("SDL_AUDIO_CONVERT: Converting byte order\n"); |     SDL_Log("SDL_AUDIO_CONVERT: Converting byte order\n"); | ||||||
| @@ -284,7 +284,8 @@ SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|  |  | ||||||
|     switch (SDL_AUDIO_BITSIZE(format)) { |     switch (SDL_AUDIO_BITSIZE(format)) { | ||||||
| #define CASESWAP(b)                                            \ | #define CASESWAP(b)                                            \ | ||||||
|             case b: { \ |     case b:                                                    \ | ||||||
|  |     {                                                          \ | ||||||
|         Uint##b *ptr = (Uint##b *)cvt->buf;                    \ |         Uint##b *ptr = (Uint##b *)cvt->buf;                    \ | ||||||
|         int i;                                                 \ |         int i;                                                 \ | ||||||
|         for (i = cvt->len_cvt / sizeof(*ptr); i; --i, ++ptr) { \ |         for (i = cvt->len_cvt / sizeof(*ptr); i; --i, ++ptr) { \ | ||||||
| @@ -299,7 +300,9 @@ SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|  |  | ||||||
| #undef CASESWAP | #undef CASESWAP | ||||||
|  |  | ||||||
|         default: SDL_assert(!"unhandled byteswap datatype!"); break; |     default: | ||||||
|  |         SDL_assert(!"unhandled byteswap datatype!"); | ||||||
|  |         break; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (cvt->filters[++cvt->filter_index]) { |     if (cvt->filters[++cvt->filter_index]) { | ||||||
| @@ -313,8 +316,7 @@ SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_AddAudioCVTFilter(SDL_AudioCVT *cvt, const SDL_AudioFilter filter) | ||||||
| SDL_AddAudioCVTFilter(SDL_AudioCVT *cvt, const SDL_AudioFilter filter) |  | ||||||
| { | { | ||||||
|     if (cvt->filter_index >= SDL_AUDIOCVT_MAX_FILTERS) { |     if (cvt->filter_index >= SDL_AUDIOCVT_MAX_FILTERS) { | ||||||
|         return SDL_SetError("Too many filters needed for conversion, exceeded maximum of %d", SDL_AUDIOCVT_MAX_FILTERS); |         return SDL_SetError("Too many filters needed for conversion, exceeded maximum of %d", SDL_AUDIOCVT_MAX_FILTERS); | ||||||
| @@ -325,8 +327,7 @@ SDL_AddAudioCVTFilter(SDL_AudioCVT *cvt, const SDL_AudioFilter filter) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat src_fmt) | ||||||
| SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat src_fmt) |  | ||||||
| { | { | ||||||
|     int retval = 0; /* 0 == no conversion necessary. */ |     int retval = 0; /* 0 == no conversion necessary. */ | ||||||
|  |  | ||||||
| @@ -343,12 +344,24 @@ SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat src_fmt) | |||||||
|         SDL_AudioFilter filter = NULL; |         SDL_AudioFilter filter = NULL; | ||||||
|  |  | ||||||
|         switch (src_fmt & ~SDL_AUDIO_MASK_ENDIAN) { |         switch (src_fmt & ~SDL_AUDIO_MASK_ENDIAN) { | ||||||
|             case AUDIO_S8: filter = SDL_Convert_S8_to_F32; break; |         case AUDIO_S8: | ||||||
|             case AUDIO_U8: filter = SDL_Convert_U8_to_F32; break; |             filter = SDL_Convert_S8_to_F32; | ||||||
|             case AUDIO_S16: filter = SDL_Convert_S16_to_F32; break; |             break; | ||||||
|             case AUDIO_U16: filter = SDL_Convert_U16_to_F32; break; |         case AUDIO_U8: | ||||||
|             case AUDIO_S32: filter = SDL_Convert_S32_to_F32; break; |             filter = SDL_Convert_U8_to_F32; | ||||||
|             default: SDL_assert(!"Unexpected audio format!"); break; |             break; | ||||||
|  |         case AUDIO_S16: | ||||||
|  |             filter = SDL_Convert_S16_to_F32; | ||||||
|  |             break; | ||||||
|  |         case AUDIO_U16: | ||||||
|  |             filter = SDL_Convert_U16_to_F32; | ||||||
|  |             break; | ||||||
|  |         case AUDIO_S32: | ||||||
|  |             filter = SDL_Convert_S32_to_F32; | ||||||
|  |             break; | ||||||
|  |         default: | ||||||
|  |             SDL_assert(!"Unexpected audio format!"); | ||||||
|  |             break; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!filter) { |         if (!filter) { | ||||||
| @@ -372,8 +385,7 @@ SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat src_fmt) | |||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat dst_fmt) | ||||||
| SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat dst_fmt) |  | ||||||
| { | { | ||||||
|     int retval = 0; /* 0 == no conversion necessary. */ |     int retval = 0; /* 0 == no conversion necessary. */ | ||||||
|  |  | ||||||
| @@ -382,12 +394,24 @@ SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat dst_fmt) | |||||||
|         const Uint16 src_bitsize = 32; |         const Uint16 src_bitsize = 32; | ||||||
|         SDL_AudioFilter filter = NULL; |         SDL_AudioFilter filter = NULL; | ||||||
|         switch (dst_fmt & ~SDL_AUDIO_MASK_ENDIAN) { |         switch (dst_fmt & ~SDL_AUDIO_MASK_ENDIAN) { | ||||||
|             case AUDIO_S8: filter = SDL_Convert_F32_to_S8; break; |         case AUDIO_S8: | ||||||
|             case AUDIO_U8: filter = SDL_Convert_F32_to_U8; break; |             filter = SDL_Convert_F32_to_S8; | ||||||
|             case AUDIO_S16: filter = SDL_Convert_F32_to_S16; break; |             break; | ||||||
|             case AUDIO_U16: filter = SDL_Convert_F32_to_U16; break; |         case AUDIO_U8: | ||||||
|             case AUDIO_S32: filter = SDL_Convert_F32_to_S32; break; |             filter = SDL_Convert_F32_to_U8; | ||||||
|             default: SDL_assert(!"Unexpected audio format!"); break; |             break; | ||||||
|  |         case AUDIO_S16: | ||||||
|  |             filter = SDL_Convert_F32_to_S16; | ||||||
|  |             break; | ||||||
|  |         case AUDIO_U16: | ||||||
|  |             filter = SDL_Convert_F32_to_U16; | ||||||
|  |             break; | ||||||
|  |         case AUDIO_S32: | ||||||
|  |             filter = SDL_Convert_F32_to_S32; | ||||||
|  |             break; | ||||||
|  |         default: | ||||||
|  |             SDL_assert(!"Unexpected audio format!"); | ||||||
|  |             break; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!filter) { |         if (!filter) { | ||||||
| @@ -420,8 +444,7 @@ SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat dst_fmt) | |||||||
|  |  | ||||||
| #ifdef HAVE_LIBSAMPLERATE_H | #ifdef HAVE_LIBSAMPLERATE_H | ||||||
|  |  | ||||||
| static void | static void SDL_ResampleCVT_SRC(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format) | ||||||
| SDL_ResampleCVT_SRC(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     const int srclen = cvt->len_cvt; |     const int srclen = cvt->len_cvt; | ||||||
| @@ -460,8 +483,7 @@ SDL_ResampleCVT_SRC(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat fo | |||||||
|  |  | ||||||
| #endif /* HAVE_LIBSAMPLERATE_H */ | #endif /* HAVE_LIBSAMPLERATE_H */ | ||||||
|  |  | ||||||
| static void | static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format) | ||||||
| SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     /* !!! FIXME in 2.1: there are ten slots in the filter list, and the theoretical maximum we use is six (seven with NULL terminator). |     /* !!! FIXME in 2.1: there are ten slots in the filter list, and the theoretical maximum we use is six (seven with NULL terminator). | ||||||
|        !!! FIXME in 2.1:   We need to store data for this resampler, because the cvt structure doesn't store the original sample rates, |        !!! FIXME in 2.1:   We need to store data for this resampler, because the cvt structure doesn't store the original sample rates, | ||||||
| @@ -510,7 +532,8 @@ SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format | |||||||
|    !!! FIXME:  vs arbitrary. When we rev the ABI, clean this up. */ |    !!! FIXME:  vs arbitrary. When we rev the ABI, clean this up. */ | ||||||
| #define RESAMPLER_FUNCS(chans)                                              \ | #define RESAMPLER_FUNCS(chans)                                              \ | ||||||
|     static void SDLCALL                                                     \ |     static void SDLCALL                                                     \ | ||||||
|     SDL_ResampleCVT_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) { \ |         SDL_ResampleCVT_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) \ | ||||||
|  |     {                                                                       \ | ||||||
|         SDL_ResampleCVT(cvt, chans, format);                                \ |         SDL_ResampleCVT(cvt, chans, format);                                \ | ||||||
|     } |     } | ||||||
| RESAMPLER_FUNCS(1) | RESAMPLER_FUNCS(1) | ||||||
| @@ -523,7 +546,8 @@ RESAMPLER_FUNCS(8) | |||||||
| #ifdef HAVE_LIBSAMPLERATE_H | #ifdef HAVE_LIBSAMPLERATE_H | ||||||
| #define RESAMPLER_FUNCS(chans)                                                  \ | #define RESAMPLER_FUNCS(chans)                                                  \ | ||||||
|     static void SDLCALL                                                         \ |     static void SDLCALL                                                         \ | ||||||
|     SDL_ResampleCVT_SRC_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) { \ |         SDL_ResampleCVT_SRC_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) \ | ||||||
|  |     {                                                                           \ | ||||||
|         SDL_ResampleCVT_SRC(cvt, chans, format);                                \ |         SDL_ResampleCVT_SRC(cvt, chans, format);                                \ | ||||||
|     } |     } | ||||||
| RESAMPLER_FUNCS(1) | RESAMPLER_FUNCS(1) | ||||||
| @@ -534,36 +558,46 @@ RESAMPLER_FUNCS(8) | |||||||
| #undef RESAMPLER_FUNCS | #undef RESAMPLER_FUNCS | ||||||
| #endif /* HAVE_LIBSAMPLERATE_H */ | #endif /* HAVE_LIBSAMPLERATE_H */ | ||||||
|  |  | ||||||
| static SDL_AudioFilter | static SDL_AudioFilter ChooseCVTResampler(const int dst_channels) | ||||||
| ChooseCVTResampler(const int dst_channels) |  | ||||||
| { | { | ||||||
| #ifdef HAVE_LIBSAMPLERATE_H | #ifdef HAVE_LIBSAMPLERATE_H | ||||||
|     if (SRC_available) { |     if (SRC_available) { | ||||||
|         switch (dst_channels) { |         switch (dst_channels) { | ||||||
|             case 1: return SDL_ResampleCVT_SRC_c1; |         case 1: | ||||||
|             case 2: return SDL_ResampleCVT_SRC_c2; |             return SDL_ResampleCVT_SRC_c1; | ||||||
|             case 4: return SDL_ResampleCVT_SRC_c4; |         case 2: | ||||||
|             case 6: return SDL_ResampleCVT_SRC_c6; |             return SDL_ResampleCVT_SRC_c2; | ||||||
|             case 8: return SDL_ResampleCVT_SRC_c8; |         case 4: | ||||||
|             default: break; |             return SDL_ResampleCVT_SRC_c4; | ||||||
|  |         case 6: | ||||||
|  |             return SDL_ResampleCVT_SRC_c6; | ||||||
|  |         case 8: | ||||||
|  |             return SDL_ResampleCVT_SRC_c8; | ||||||
|  |         default: | ||||||
|  |             break; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| #endif /* HAVE_LIBSAMPLERATE_H */ | #endif /* HAVE_LIBSAMPLERATE_H */ | ||||||
|  |  | ||||||
|     switch (dst_channels) { |     switch (dst_channels) { | ||||||
|         case 1: return SDL_ResampleCVT_c1; |     case 1: | ||||||
|         case 2: return SDL_ResampleCVT_c2; |         return SDL_ResampleCVT_c1; | ||||||
|         case 4: return SDL_ResampleCVT_c4; |     case 2: | ||||||
|         case 6: return SDL_ResampleCVT_c6; |         return SDL_ResampleCVT_c2; | ||||||
|         case 8: return SDL_ResampleCVT_c8; |     case 4: | ||||||
|         default: break; |         return SDL_ResampleCVT_c4; | ||||||
|  |     case 6: | ||||||
|  |         return SDL_ResampleCVT_c6; | ||||||
|  |     case 8: | ||||||
|  |         return SDL_ResampleCVT_c8; | ||||||
|  |     default: | ||||||
|  |         break; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return NULL; |     return NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_BuildAudioResampleCVT(SDL_AudioCVT *cvt, const int dst_channels, | ||||||
| SDL_BuildAudioResampleCVT(SDL_AudioCVT * cvt, const int dst_channels, |  | ||||||
|                                      const int src_rate, const int dst_rate) |                                      const int src_rate, const int dst_rate) | ||||||
| { | { | ||||||
|     SDL_AudioFilter filter; |     SDL_AudioFilter filter; | ||||||
| @@ -607,8 +641,7 @@ SDL_BuildAudioResampleCVT(SDL_AudioCVT * cvt, const int dst_channels, | |||||||
|     return 1; /* added a converter. */ |     return 1; /* added a converter. */ | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool SDL_SupportedAudioFormat(const SDL_AudioFormat fmt) | ||||||
| SDL_SupportedAudioFormat(const SDL_AudioFormat fmt) |  | ||||||
| { | { | ||||||
|     switch (fmt) { |     switch (fmt) { | ||||||
|     case AUDIO_U8: |     case AUDIO_U8: | ||||||
| @@ -630,20 +663,17 @@ SDL_SupportedAudioFormat(const SDL_AudioFormat fmt) | |||||||
|     return SDL_FALSE; /* unsupported. */ |     return SDL_FALSE; /* unsupported. */ | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool SDL_SupportedChannelCount(const int channels) | ||||||
| SDL_SupportedChannelCount(const int channels) |  | ||||||
| { | { | ||||||
|     return ((channels >= 1) && (channels <= 8)) ? SDL_TRUE : SDL_FALSE; |     return ((channels >= 1) && (channels <= 8)) ? SDL_TRUE : SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Creates a set of audio filters to convert from one format to another. | /* Creates a set of audio filters to convert from one format to another. | ||||||
|    Returns 0 if no conversion is needed, 1 if the audio filter is set up, |    Returns 0 if no conversion is needed, 1 if the audio filter is set up, | ||||||
|    or -1 if an error like invalid parameter, unsupported format, etc. occurred. |    or -1 if an error like invalid parameter, unsupported format, etc. occurred. | ||||||
| */ | */ | ||||||
|  |  | ||||||
| int | int SDL_BuildAudioCVT(SDL_AudioCVT *cvt, | ||||||
| SDL_BuildAudioCVT(SDL_AudioCVT * cvt, |  | ||||||
|                       SDL_AudioFormat src_fmt, Uint8 src_channels, int src_rate, |                       SDL_AudioFormat src_fmt, Uint8 src_channels, int src_rate, | ||||||
|                       SDL_AudioFormat dst_fmt, Uint8 dst_channels, int dst_rate) |                       SDL_AudioFormat dst_fmt, Uint8 dst_channels, int dst_rate) | ||||||
| { | { | ||||||
| @@ -738,7 +768,6 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt, | |||||||
|         return -1; /* shouldn't happen, but just in case... */ |         return -1; /* shouldn't happen, but just in case... */ | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     /* Channel conversion */ |     /* Channel conversion */ | ||||||
|  |  | ||||||
|     /* SDL_SupportedChannelCount should have caught these asserts, or we added a new format and forgot to update the table. */ |     /* SDL_SupportedChannelCount should have caught these asserts, or we added a new format and forgot to update the table. */ | ||||||
| @@ -754,15 +783,23 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt, | |||||||
|         if (channel_converter == SDL_ConvertStereoToMono) { |         if (channel_converter == SDL_ConvertStereoToMono) { | ||||||
|             SDL_AudioFilter filter = NULL; |             SDL_AudioFilter filter = NULL; | ||||||
| #if HAVE_SSE3_INTRINSICS | #if HAVE_SSE3_INTRINSICS | ||||||
|             if (!filter && SDL_HasSSE3()) { filter = SDL_ConvertStereoToMono_SSE3; } |             if (!filter && SDL_HasSSE3()) { | ||||||
|  |                 filter = SDL_ConvertStereoToMono_SSE3; | ||||||
|  |             } | ||||||
| #endif | #endif | ||||||
|             if (filter) { channel_converter = filter; } |             if (filter) { | ||||||
|  |                 channel_converter = filter; | ||||||
|  |             } | ||||||
|         } else if (channel_converter == SDL_ConvertMonoToStereo) { |         } else if (channel_converter == SDL_ConvertMonoToStereo) { | ||||||
|             SDL_AudioFilter filter = NULL; |             SDL_AudioFilter filter = NULL; | ||||||
| #if HAVE_SSE_INTRINSICS | #if HAVE_SSE_INTRINSICS | ||||||
|             if (!filter && SDL_HasSSE()) { filter = SDL_ConvertMonoToStereo_SSE; } |             if (!filter && SDL_HasSSE()) { | ||||||
|  |                 filter = SDL_ConvertMonoToStereo_SSE; | ||||||
|  |             } | ||||||
| #endif | #endif | ||||||
|             if (filter) { channel_converter = filter; } |             if (filter) { | ||||||
|  |                 channel_converter = filter; | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (SDL_AddAudioCVTFilter(cvt, channel_converter) < 0) { |         if (SDL_AddAudioCVTFilter(cvt, channel_converter) < 0) { | ||||||
| @@ -825,8 +862,7 @@ struct _SDL_AudioStream | |||||||
|     SDL_CleanupAudioStreamResamplerFunc cleanup_resampler_func; |     SDL_CleanupAudioStreamResamplerFunc cleanup_resampler_func; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| static Uint8 * | static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen) | ||||||
| EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen) |  | ||||||
| { | { | ||||||
|     Uint8 *ptr; |     Uint8 *ptr; | ||||||
|     size_t offset; |     size_t offset; | ||||||
| @@ -849,8 +885,7 @@ EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen) | |||||||
| } | } | ||||||
|  |  | ||||||
| #ifdef HAVE_LIBSAMPLERATE_H | #ifdef HAVE_LIBSAMPLERATE_H | ||||||
| static int | static int SDL_ResampleAudioStream_SRC(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen) | ||||||
| SDL_ResampleAudioStream_SRC(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen) |  | ||||||
| { | { | ||||||
|     const float *inbuf = (const float *)_inbuf; |     const float *inbuf = (const float *)_inbuf; | ||||||
|     float *outbuf = (float *)_outbuf; |     float *outbuf = (float *)_outbuf; | ||||||
| @@ -883,14 +918,12 @@ SDL_ResampleAudioStream_SRC(SDL_AudioStream *stream, const void *_inbuf, const i | |||||||
|     return data.output_frames_gen * (sizeof(float) * stream->pre_resample_channels); |     return data.output_frames_gen * (sizeof(float) * stream->pre_resample_channels); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_ResetAudioStreamResampler_SRC(SDL_AudioStream *stream) | ||||||
| SDL_ResetAudioStreamResampler_SRC(SDL_AudioStream *stream) |  | ||||||
| { | { | ||||||
|     SRC_src_reset((SRC_STATE *)stream->resampler_state); |     SRC_src_reset((SRC_STATE *)stream->resampler_state); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_CleanupAudioStreamResampler_SRC(SDL_AudioStream *stream) | ||||||
| SDL_CleanupAudioStreamResampler_SRC(SDL_AudioStream *stream) |  | ||||||
| { | { | ||||||
|     SRC_STATE *state = (SRC_STATE *)stream->resampler_state; |     SRC_STATE *state = (SRC_STATE *)stream->resampler_state; | ||||||
|     if (state) { |     if (state) { | ||||||
| @@ -903,8 +936,7 @@ SDL_CleanupAudioStreamResampler_SRC(SDL_AudioStream *stream) | |||||||
|     stream->cleanup_resampler_func = NULL; |     stream->cleanup_resampler_func = NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool SetupLibSampleRateResampling(SDL_AudioStream *stream) | ||||||
| SetupLibSampleRateResampling(SDL_AudioStream *stream) |  | ||||||
| { | { | ||||||
|     int result = 0; |     int result = 0; | ||||||
|     SRC_STATE *state = NULL; |     SRC_STATE *state = NULL; | ||||||
| @@ -930,9 +962,7 @@ SetupLibSampleRateResampling(SDL_AudioStream *stream) | |||||||
| } | } | ||||||
| #endif /* HAVE_LIBSAMPLERATE_H */ | #endif /* HAVE_LIBSAMPLERATE_H */ | ||||||
|  |  | ||||||
|  | static int SDL_ResampleAudioStream(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen) | ||||||
| static int |  | ||||||
| SDL_ResampleAudioStream(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen) |  | ||||||
| { | { | ||||||
|     const Uint8 *inbufend = ((const Uint8 *)_inbuf) + inbuflen; |     const Uint8 *inbufend = ((const Uint8 *)_inbuf) + inbuflen; | ||||||
|     const float *inbuf = (const float *)_inbuf; |     const float *inbuf = (const float *)_inbuf; | ||||||
| @@ -956,16 +986,14 @@ SDL_ResampleAudioStream(SDL_AudioStream *stream, const void *_inbuf, const int i | |||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_ResetAudioStreamResampler(SDL_AudioStream *stream) | ||||||
| SDL_ResetAudioStreamResampler(SDL_AudioStream *stream) |  | ||||||
| { | { | ||||||
|     /* set all the padding to silence. */ |     /* set all the padding to silence. */ | ||||||
|     const int len = stream->resampler_padding_samples; |     const int len = stream->resampler_padding_samples; | ||||||
|     SDL_memset(stream->resampler_state, '\0', len * sizeof(float)); |     SDL_memset(stream->resampler_state, '\0', len * sizeof(float)); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_CleanupAudioStreamResampler(SDL_AudioStream *stream) | ||||||
| SDL_CleanupAudioStreamResampler(SDL_AudioStream *stream) |  | ||||||
| { | { | ||||||
|     SDL_free(stream->resampler_state); |     SDL_free(stream->resampler_state); | ||||||
| } | } | ||||||
| @@ -1073,8 +1101,7 @@ SDL_NewAudioStream(const SDL_AudioFormat src_format, | |||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, int *maxputbytes) | ||||||
| SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, int *maxputbytes) |  | ||||||
| { | { | ||||||
|     int buflen = len; |     int buflen = len; | ||||||
|     int workbuflen; |     int workbuflen; | ||||||
| @@ -1203,8 +1230,7 @@ SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, in | |||||||
|     return buflen ? SDL_WriteToDataQueue(stream->queue, resamplebuf, buflen) : 0; |     return buflen ? SDL_WriteToDataQueue(stream->queue, resamplebuf, buflen) : 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len) | ||||||
| SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len) |  | ||||||
| { | { | ||||||
|     /* !!! FIXME: several converters can take advantage of SIMD, but only |     /* !!! FIXME: several converters can take advantage of SIMD, but only | ||||||
|        !!! FIXME:  if the data is aligned to 16 bytes. EnsureStreamBufferSize() |        !!! FIXME:  if the data is aligned to 16 bytes. EnsureStreamBufferSize() | ||||||
| @@ -1325,8 +1351,7 @@ int SDL_AudioStreamFlush(SDL_AudioStream *stream) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* get converted/resampled data from the stream */ | /* get converted/resampled data from the stream */ | ||||||
| int | int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len) | ||||||
| SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len) |  | ||||||
| { | { | ||||||
| #if DEBUG_AUDIOSTREAM | #if DEBUG_AUDIOSTREAM | ||||||
|     SDL_Log("AUDIOSTREAM: want to get %d converted bytes\n", len); |     SDL_Log("AUDIOSTREAM: want to get %d converted bytes\n", len); | ||||||
| @@ -1349,14 +1374,12 @@ SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* number of converted/resampled bytes available */ | /* number of converted/resampled bytes available */ | ||||||
| int | int SDL_AudioStreamAvailable(SDL_AudioStream *stream) | ||||||
| SDL_AudioStreamAvailable(SDL_AudioStream *stream) |  | ||||||
| { | { | ||||||
|     return stream ? (int)SDL_CountDataQueue(stream->queue) : 0; |     return stream ? (int)SDL_CountDataQueue(stream->queue) : 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_AudioStreamClear(SDL_AudioStream *stream) | ||||||
| SDL_AudioStreamClear(SDL_AudioStream *stream) |  | ||||||
| { | { | ||||||
|     if (stream == NULL) { |     if (stream == NULL) { | ||||||
|         SDL_InvalidParamError("stream"); |         SDL_InvalidParamError("stream"); | ||||||
| @@ -1371,8 +1394,7 @@ SDL_AudioStreamClear(SDL_AudioStream *stream) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* dispose of a stream */ | /* dispose of a stream */ | ||||||
| void | void SDL_FreeAudioStream(SDL_AudioStream *stream) | ||||||
| SDL_FreeAudioStream(SDL_AudioStream *stream) |  | ||||||
| { | { | ||||||
|     if (stream) { |     if (stream) { | ||||||
|         if (stream->cleanup_resampler_func) { |         if (stream->cleanup_resampler_func) { | ||||||
|   | |||||||
| @@ -46,8 +46,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))) { | ||||||
| @@ -71,14 +70,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; | ||||||
| @@ -97,9 +94,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; | ||||||
| @@ -119,8 +114,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); | ||||||
|   | |||||||
| @@ -59,15 +59,12 @@ SDL_AudioFilter SDL_Convert_F32_to_S16 = NULL; | |||||||
| SDL_AudioFilter SDL_Convert_F32_to_U16 = NULL; | SDL_AudioFilter SDL_Convert_F32_to_U16 = NULL; | ||||||
| SDL_AudioFilter SDL_Convert_F32_to_S32 = NULL; | SDL_AudioFilter SDL_Convert_F32_to_S32 = NULL; | ||||||
|  |  | ||||||
|  |  | ||||||
| #define DIVBY128     0.0078125f | #define DIVBY128     0.0078125f | ||||||
| #define DIVBY32768   0.000030517578125f | #define DIVBY32768   0.000030517578125f | ||||||
| #define DIVBY8388607 0.00000011920930376163766f | #define DIVBY8388607 0.00000011920930376163766f | ||||||
|  |  | ||||||
|  |  | ||||||
| #if NEED_SCALAR_CONVERTER_FALLBACKS | #if NEED_SCALAR_CONVERTER_FALLBACKS | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_S8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_S8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1; |     const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
|     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; |     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; | ||||||
| @@ -85,8 +82,7 @@ SDL_Convert_S8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_U8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_U8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Uint8 *src = ((const Uint8 *)(cvt->buf + cvt->len_cvt)) - 1; |     const Uint8 *src = ((const Uint8 *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
|     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; |     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; | ||||||
| @@ -104,8 +100,7 @@ SDL_Convert_U8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_S16_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_S16_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Sint16 *src = ((const Sint16 *)(cvt->buf + cvt->len_cvt)) - 1; |     const Sint16 *src = ((const Sint16 *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
|     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; |     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; | ||||||
| @@ -123,8 +118,7 @@ SDL_Convert_S16_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_U16_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_U16_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Uint16 *src = ((const Uint16 *)(cvt->buf + cvt->len_cvt)) - 1; |     const Uint16 *src = ((const Uint16 *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
|     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; |     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; | ||||||
| @@ -142,8 +136,7 @@ SDL_Convert_U16_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_S32_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_S32_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Sint32 *src = (const Sint32 *)cvt->buf; |     const Sint32 *src = (const Sint32 *)cvt->buf; | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
| @@ -160,8 +153,7 @@ SDL_Convert_S32_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_S8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_S8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Sint8 *dst = (Sint8 *)cvt->buf; |     Sint8 *dst = (Sint8 *)cvt->buf; | ||||||
| @@ -186,8 +178,7 @@ SDL_Convert_F32_to_S8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_U8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_U8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Uint8 *dst = (Uint8 *)cvt->buf; |     Uint8 *dst = (Uint8 *)cvt->buf; | ||||||
| @@ -212,8 +203,7 @@ SDL_Convert_F32_to_U8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_S16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_S16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Sint16 *dst = (Sint16 *)cvt->buf; |     Sint16 *dst = (Sint16 *)cvt->buf; | ||||||
| @@ -238,8 +228,7 @@ SDL_Convert_F32_to_S16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_U16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_U16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Uint16 *dst = (Uint16 *)cvt->buf; |     Uint16 *dst = (Uint16 *)cvt->buf; | ||||||
| @@ -264,8 +253,7 @@ SDL_Convert_F32_to_U16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_S32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_S32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Sint32 *dst = (Sint32 *)cvt->buf; |     Sint32 *dst = (Sint32 *)cvt->buf; | ||||||
| @@ -290,10 +278,8 @@ SDL_Convert_F32_to_S32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| #if HAVE_SSE2_INTRINSICS | #if HAVE_SSE2_INTRINSICS | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1; |     const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
|     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; |     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; | ||||||
| @@ -306,7 +292,8 @@ SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         *dst = ((float)*src) * DIVBY128; |         *dst = ((float)*src) * DIVBY128; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src -= 15; dst -= 15;  /* adjust to read SSE blocks from the start. */ |     src -= 15; | ||||||
|  |     dst -= 15; /* adjust to read SSE blocks from the start. */ | ||||||
|     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); |     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); | ||||||
|  |  | ||||||
|     /* Make sure src is aligned too. */ |     /* Make sure src is aligned too. */ | ||||||
| @@ -331,18 +318,23 @@ SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             _mm_store_ps(dst + 4, _mm_unpackhi_ps(floats1, floats2)); |             _mm_store_ps(dst + 4, _mm_unpackhi_ps(floats1, floats2)); | ||||||
|             _mm_store_ps(dst + 8, _mm_unpacklo_ps(floats3, floats4)); |             _mm_store_ps(dst + 8, _mm_unpacklo_ps(floats3, floats4)); | ||||||
|             _mm_store_ps(dst + 12, _mm_unpackhi_ps(floats3, floats4)); |             _mm_store_ps(dst + 12, _mm_unpackhi_ps(floats3, floats4)); | ||||||
|             i -= 16; mmsrc--; dst -= 16; |             i -= 16; | ||||||
|  |             mmsrc--; | ||||||
|  |             dst -= 16; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         src = (const Sint8 *)mmsrc; |         src = (const Sint8 *)mmsrc; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src += 15; dst += 15;  /* adjust for any scalar finishing. */ |     src += 15; | ||||||
|  |     dst += 15; /* adjust for any scalar finishing. */ | ||||||
|  |  | ||||||
|     /* Finish off any leftovers with scalar operations. */ |     /* Finish off any leftovers with scalar operations. */ | ||||||
|     while (i) { |     while (i) { | ||||||
|         *dst = ((float)*src) * DIVBY128; |         *dst = ((float)*src) * DIVBY128; | ||||||
|         i--; src--; dst--; |         i--; | ||||||
|  |         src--; | ||||||
|  |         dst--; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt *= 4; |     cvt->len_cvt *= 4; | ||||||
| @@ -351,8 +343,7 @@ SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_U8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_U8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Uint8 *src = ((const Uint8 *)(cvt->buf + cvt->len_cvt)) - 1; |     const Uint8 *src = ((const Uint8 *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
|     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; |     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; | ||||||
| @@ -365,7 +356,8 @@ SDL_Convert_U8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         *dst = (((float)*src) * DIVBY128) - 1.0f; |         *dst = (((float)*src) * DIVBY128) - 1.0f; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src -= 15; dst -= 15;  /* adjust to read SSE blocks from the start. */ |     src -= 15; | ||||||
|  |     dst -= 15; /* adjust to read SSE blocks from the start. */ | ||||||
|     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); |     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); | ||||||
|  |  | ||||||
|     /* Make sure src is aligned too. */ |     /* Make sure src is aligned too. */ | ||||||
| @@ -392,18 +384,23 @@ SDL_Convert_U8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             _mm_store_ps(dst + 4, _mm_unpackhi_ps(floats1, floats2)); |             _mm_store_ps(dst + 4, _mm_unpackhi_ps(floats1, floats2)); | ||||||
|             _mm_store_ps(dst + 8, _mm_unpacklo_ps(floats3, floats4)); |             _mm_store_ps(dst + 8, _mm_unpacklo_ps(floats3, floats4)); | ||||||
|             _mm_store_ps(dst + 12, _mm_unpackhi_ps(floats3, floats4)); |             _mm_store_ps(dst + 12, _mm_unpackhi_ps(floats3, floats4)); | ||||||
|             i -= 16; mmsrc--; dst -= 16; |             i -= 16; | ||||||
|  |             mmsrc--; | ||||||
|  |             dst -= 16; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         src = (const Uint8 *)mmsrc; |         src = (const Uint8 *)mmsrc; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src += 15; dst += 15;  /* adjust for any scalar finishing. */ |     src += 15; | ||||||
|  |     dst += 15; /* adjust for any scalar finishing. */ | ||||||
|  |  | ||||||
|     /* Finish off any leftovers with scalar operations. */ |     /* Finish off any leftovers with scalar operations. */ | ||||||
|     while (i) { |     while (i) { | ||||||
|         *dst = (((float)*src) * DIVBY128) - 1.0f; |         *dst = (((float)*src) * DIVBY128) - 1.0f; | ||||||
|         i--; src--; dst--; |         i--; | ||||||
|  |         src--; | ||||||
|  |         dst--; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt *= 4; |     cvt->len_cvt *= 4; | ||||||
| @@ -412,8 +409,7 @@ SDL_Convert_U8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_S16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_S16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Sint16 *src = ((const Sint16 *)(cvt->buf + cvt->len_cvt)) - 1; |     const Sint16 *src = ((const Sint16 *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
|     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; |     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; | ||||||
| @@ -426,7 +422,8 @@ SDL_Convert_S16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         *dst = ((float)*src) * DIVBY32768; |         *dst = ((float)*src) * DIVBY32768; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src -= 7; dst -= 7;  /* adjust to read SSE blocks from the start. */ |     src -= 7; | ||||||
|  |     dst -= 7; /* adjust to read SSE blocks from the start. */ | ||||||
|     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); |     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); | ||||||
|  |  | ||||||
|     /* Make sure src is aligned too. */ |     /* Make sure src is aligned too. */ | ||||||
| @@ -442,16 +439,21 @@ SDL_Convert_S16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             /* Interleave these back into the right order, convert to float, multiply, store. */ |             /* Interleave these back into the right order, convert to float, multiply, store. */ | ||||||
|             _mm_store_ps(dst, _mm_mul_ps(_mm_cvtepi32_ps(_mm_unpacklo_epi32(a, b)), divby32768)); |             _mm_store_ps(dst, _mm_mul_ps(_mm_cvtepi32_ps(_mm_unpacklo_epi32(a, b)), divby32768)); | ||||||
|             _mm_store_ps(dst + 4, _mm_mul_ps(_mm_cvtepi32_ps(_mm_unpackhi_epi32(a, b)), divby32768)); |             _mm_store_ps(dst + 4, _mm_mul_ps(_mm_cvtepi32_ps(_mm_unpackhi_epi32(a, b)), divby32768)); | ||||||
|             i -= 8; src -= 8; dst -= 8; |             i -= 8; | ||||||
|  |             src -= 8; | ||||||
|  |             dst -= 8; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src += 7; dst += 7;  /* adjust for any scalar finishing. */ |     src += 7; | ||||||
|  |     dst += 7; /* adjust for any scalar finishing. */ | ||||||
|  |  | ||||||
|     /* Finish off any leftovers with scalar operations. */ |     /* Finish off any leftovers with scalar operations. */ | ||||||
|     while (i) { |     while (i) { | ||||||
|         *dst = ((float)*src) * DIVBY32768; |         *dst = ((float)*src) * DIVBY32768; | ||||||
|         i--; src--; dst--; |         i--; | ||||||
|  |         src--; | ||||||
|  |         dst--; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt *= 2; |     cvt->len_cvt *= 2; | ||||||
| @@ -460,8 +462,7 @@ SDL_Convert_S16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_U16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_U16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Uint16 *src = ((const Uint16 *)(cvt->buf + cvt->len_cvt)) - 1; |     const Uint16 *src = ((const Uint16 *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
|     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; |     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; | ||||||
| @@ -474,7 +475,8 @@ SDL_Convert_U16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         *dst = (((float)*src) * DIVBY32768) - 1.0f; |         *dst = (((float)*src) * DIVBY32768) - 1.0f; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src -= 7; dst -= 7;  /* adjust to read SSE blocks from the start. */ |     src -= 7; | ||||||
|  |     dst -= 7; /* adjust to read SSE blocks from the start. */ | ||||||
|     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); |     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); | ||||||
|  |  | ||||||
|     /* Make sure src is aligned too. */ |     /* Make sure src is aligned too. */ | ||||||
| @@ -491,16 +493,21 @@ SDL_Convert_U16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             /* Interleave these back into the right order, convert to float, multiply, store. */ |             /* Interleave these back into the right order, convert to float, multiply, store. */ | ||||||
|             _mm_store_ps(dst, _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(_mm_unpacklo_epi32(a, b)), divby32768), minus1)); |             _mm_store_ps(dst, _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(_mm_unpacklo_epi32(a, b)), divby32768), minus1)); | ||||||
|             _mm_store_ps(dst + 4, _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(_mm_unpackhi_epi32(a, b)), divby32768), minus1)); |             _mm_store_ps(dst + 4, _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(_mm_unpackhi_epi32(a, b)), divby32768), minus1)); | ||||||
|             i -= 8; src -= 8; dst -= 8; |             i -= 8; | ||||||
|  |             src -= 8; | ||||||
|  |             dst -= 8; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src += 7; dst += 7;  /* adjust for any scalar finishing. */ |     src += 7; | ||||||
|  |     dst += 7; /* adjust for any scalar finishing. */ | ||||||
|  |  | ||||||
|     /* Finish off any leftovers with scalar operations. */ |     /* Finish off any leftovers with scalar operations. */ | ||||||
|     while (i) { |     while (i) { | ||||||
|         *dst = (((float)*src) * DIVBY32768) - 1.0f; |         *dst = (((float)*src) * DIVBY32768) - 1.0f; | ||||||
|         i--; src--; dst--; |         i--; | ||||||
|  |         src--; | ||||||
|  |         dst--; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt *= 2; |     cvt->len_cvt *= 2; | ||||||
| @@ -509,8 +516,7 @@ SDL_Convert_U16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_S32_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_S32_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Sint32 *src = (const Sint32 *)cvt->buf; |     const Sint32 *src = (const Sint32 *)cvt->buf; | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
| @@ -533,7 +539,9 @@ SDL_Convert_S32_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         while (i >= 4) { /* 4 * sint32 */ |         while (i >= 4) { /* 4 * sint32 */ | ||||||
|             /* shift out lowest bits so int fits in a float32. Small precision loss, but much faster. */ |             /* shift out lowest bits so int fits in a float32. Small precision loss, but much faster. */ | ||||||
|             _mm_store_ps(dst, _mm_mul_ps(_mm_cvtepi32_ps(_mm_srai_epi32(_mm_load_si128(mmsrc), 8)), divby8388607)); |             _mm_store_ps(dst, _mm_mul_ps(_mm_cvtepi32_ps(_mm_srai_epi32(_mm_load_si128(mmsrc), 8)), divby8388607)); | ||||||
|             i -= 4; mmsrc++; dst += 4; |             i -= 4; | ||||||
|  |             mmsrc++; | ||||||
|  |             dst += 4; | ||||||
|         } |         } | ||||||
|         src = (const Sint32 *)mmsrc; |         src = (const Sint32 *)mmsrc; | ||||||
|     } |     } | ||||||
| @@ -541,7 +549,9 @@ SDL_Convert_S32_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     /* Finish off any leftovers with scalar operations. */ |     /* Finish off any leftovers with scalar operations. */ | ||||||
|     while (i) { |     while (i) { | ||||||
|         *dst = ((float)(*src >> 8)) * DIVBY8388607; |         *dst = ((float)(*src >> 8)) * DIVBY8388607; | ||||||
|         i--; src++; dst++; |         i--; | ||||||
|  |         src++; | ||||||
|  |         dst++; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (cvt->filters[++cvt->filter_index]) { |     if (cvt->filters[++cvt->filter_index]) { | ||||||
| @@ -549,8 +559,7 @@ SDL_Convert_S32_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_S8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_S8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Sint8 *dst = (Sint8 *)cvt->buf; |     Sint8 *dst = (Sint8 *)cvt->buf; | ||||||
| @@ -585,7 +594,9 @@ SDL_Convert_F32_to_S8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             const __m128i ints3 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 8)), one), mulby127));  /* load 4 floats, clamp, convert to sint32 */ |             const __m128i ints3 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 8)), one), mulby127));  /* load 4 floats, clamp, convert to sint32 */ | ||||||
|             const __m128i ints4 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 12)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ |             const __m128i ints4 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 12)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ | ||||||
|             _mm_store_si128(mmdst, _mm_packs_epi16(_mm_packs_epi32(ints1, ints2), _mm_packs_epi32(ints3, ints4)));                   /* pack down, store out. */ |             _mm_store_si128(mmdst, _mm_packs_epi16(_mm_packs_epi32(ints1, ints2), _mm_packs_epi32(ints3, ints4)));                   /* pack down, store out. */ | ||||||
|             i -= 16; src += 16; mmdst++; |             i -= 16; | ||||||
|  |             src += 16; | ||||||
|  |             mmdst++; | ||||||
|         } |         } | ||||||
|         dst = (Sint8 *)mmdst; |         dst = (Sint8 *)mmdst; | ||||||
|     } |     } | ||||||
| @@ -600,7 +611,9 @@ SDL_Convert_F32_to_S8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         } else { |         } else { | ||||||
|             *dst = (Sint8)(sample * 127.0f); |             *dst = (Sint8)(sample * 127.0f); | ||||||
|         } |         } | ||||||
|         i--; src++; dst++; |         i--; | ||||||
|  |         src++; | ||||||
|  |         dst++; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt /= 4; |     cvt->len_cvt /= 4; | ||||||
| @@ -609,8 +622,7 @@ SDL_Convert_F32_to_S8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_U8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_U8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Uint8 *dst = cvt->buf; |     Uint8 *dst = cvt->buf; | ||||||
| @@ -645,7 +657,9 @@ SDL_Convert_F32_to_U8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             const __m128i ints3 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 8)), one), one), mulby127));  /* load 4 floats, clamp, convert to sint32 */ |             const __m128i ints3 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 8)), one), one), mulby127));  /* load 4 floats, clamp, convert to sint32 */ | ||||||
|             const __m128i ints4 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 12)), one), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ |             const __m128i ints4 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 12)), one), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ | ||||||
|             _mm_store_si128(mmdst, _mm_packus_epi16(_mm_packs_epi32(ints1, ints2), _mm_packs_epi32(ints3, ints4)));                                   /* pack down, store out. */ |             _mm_store_si128(mmdst, _mm_packus_epi16(_mm_packs_epi32(ints1, ints2), _mm_packs_epi32(ints3, ints4)));                                   /* pack down, store out. */ | ||||||
|             i -= 16; src += 16; mmdst++; |             i -= 16; | ||||||
|  |             src += 16; | ||||||
|  |             mmdst++; | ||||||
|         } |         } | ||||||
|         dst = (Uint8 *)mmdst; |         dst = (Uint8 *)mmdst; | ||||||
|     } |     } | ||||||
| @@ -660,7 +674,9 @@ SDL_Convert_F32_to_U8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         } else { |         } else { | ||||||
|             *dst = (Uint8)((sample + 1.0f) * 127.0f); |             *dst = (Uint8)((sample + 1.0f) * 127.0f); | ||||||
|         } |         } | ||||||
|         i--; src++; dst++; |         i--; | ||||||
|  |         src++; | ||||||
|  |         dst++; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt /= 4; |     cvt->len_cvt /= 4; | ||||||
| @@ -669,8 +685,7 @@ SDL_Convert_F32_to_U8_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_S16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_S16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Sint16 *dst = (Sint16 *)cvt->buf; |     Sint16 *dst = (Sint16 *)cvt->buf; | ||||||
| @@ -703,7 +718,9 @@ SDL_Convert_F32_to_S16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby32767));     /* load 4 floats, clamp, convert to sint32 */ |             const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby32767));     /* load 4 floats, clamp, convert to sint32 */ | ||||||
|             const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 4)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ |             const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 4)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ | ||||||
|             _mm_store_si128(mmdst, _mm_packs_epi32(ints1, ints2));                                                                    /* pack to sint16, store out. */ |             _mm_store_si128(mmdst, _mm_packs_epi32(ints1, ints2));                                                                    /* pack to sint16, store out. */ | ||||||
|             i -= 8; src += 8; mmdst++; |             i -= 8; | ||||||
|  |             src += 8; | ||||||
|  |             mmdst++; | ||||||
|         } |         } | ||||||
|         dst = (Sint16 *)mmdst; |         dst = (Sint16 *)mmdst; | ||||||
|     } |     } | ||||||
| @@ -718,7 +735,9 @@ SDL_Convert_F32_to_S16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         } else { |         } else { | ||||||
|             *dst = (Sint16)(sample * 32767.0f); |             *dst = (Sint16)(sample * 32767.0f); | ||||||
|         } |         } | ||||||
|         i--; src++; dst++; |         i--; | ||||||
|  |         src++; | ||||||
|  |         dst++; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt /= 2; |     cvt->len_cvt /= 2; | ||||||
| @@ -727,8 +746,7 @@ SDL_Convert_F32_to_S16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_U16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_U16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Uint16 *dst = (Uint16 *)cvt->buf; |     Uint16 *dst = (Uint16 *)cvt->buf; | ||||||
| @@ -769,7 +787,9 @@ SDL_Convert_F32_to_U16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby32767));     /* load 4 floats, clamp, convert to sint32 */ |             const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby32767));     /* load 4 floats, clamp, convert to sint32 */ | ||||||
|             const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 4)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ |             const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 4)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ | ||||||
|             _mm_store_si128(mmdst, _mm_xor_si128(_mm_packs_epi32(ints1, ints2), topbit));                                             /* pack to sint16, xor top bit, store out. */ |             _mm_store_si128(mmdst, _mm_xor_si128(_mm_packs_epi32(ints1, ints2), topbit));                                             /* pack to sint16, xor top bit, store out. */ | ||||||
|             i -= 8; src += 8; mmdst++; |             i -= 8; | ||||||
|  |             src += 8; | ||||||
|  |             mmdst++; | ||||||
|         } |         } | ||||||
|         dst = (Uint16 *)mmdst; |         dst = (Uint16 *)mmdst; | ||||||
|     } |     } | ||||||
| @@ -784,7 +804,9 @@ SDL_Convert_F32_to_U16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         } else { |         } else { | ||||||
|             *dst = (Uint16)((sample + 1.0f) * 32767.0f); |             *dst = (Uint16)((sample + 1.0f) * 32767.0f); | ||||||
|         } |         } | ||||||
|         i--; src++; dst++; |         i--; | ||||||
|  |         src++; | ||||||
|  |         dst++; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt /= 2; |     cvt->len_cvt /= 2; | ||||||
| @@ -793,8 +815,7 @@ SDL_Convert_F32_to_U16_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_S32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_S32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Sint32 *dst = (Sint32 *)cvt->buf; |     Sint32 *dst = (Sint32 *)cvt->buf; | ||||||
| @@ -825,7 +846,9 @@ SDL_Convert_F32_to_S32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         __m128i *mmdst = (__m128i *)dst; |         __m128i *mmdst = (__m128i *)dst; | ||||||
|         while (i >= 4) {                                                                                                                                 /* 4 * float32 */ |         while (i >= 4) {                                                                                                                                 /* 4 * float32 */ | ||||||
|             _mm_store_si128(mmdst, _mm_slli_epi32(_mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby8388607)), 8)); /* load 4 floats, clamp, convert to sint32 */ |             _mm_store_si128(mmdst, _mm_slli_epi32(_mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby8388607)), 8)); /* load 4 floats, clamp, convert to sint32 */ | ||||||
|             i -= 4; src += 4; mmdst++; |             i -= 4; | ||||||
|  |             src += 4; | ||||||
|  |             mmdst++; | ||||||
|         } |         } | ||||||
|         dst = (Sint32 *)mmdst; |         dst = (Sint32 *)mmdst; | ||||||
|     } |     } | ||||||
| @@ -840,7 +863,9 @@ SDL_Convert_F32_to_S32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         } else { |         } else { | ||||||
|             *dst = ((Sint32)(sample * 8388607.0f)) << 8; |             *dst = ((Sint32)(sample * 8388607.0f)) << 8; | ||||||
|         } |         } | ||||||
|         i--; src++; dst++; |         i--; | ||||||
|  |         src++; | ||||||
|  |         dst++; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (cvt->filters[++cvt->filter_index]) { |     if (cvt->filters[++cvt->filter_index]) { | ||||||
| @@ -849,10 +874,8 @@ SDL_Convert_F32_to_S32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| #if HAVE_NEON_INTRINSICS | #if HAVE_NEON_INTRINSICS | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_S8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_S8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1; |     const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
|     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; |     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; | ||||||
| @@ -865,7 +888,8 @@ SDL_Convert_S8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         *dst = ((float)*src) * DIVBY128; |         *dst = ((float)*src) * DIVBY128; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src -= 15; dst -= 15;  /* adjust to read NEON blocks from the start. */ |     src -= 15; | ||||||
|  |     dst -= 15; /* adjust to read NEON blocks from the start. */ | ||||||
|     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); |     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); | ||||||
|  |  | ||||||
|     /* Make sure src is aligned too. */ |     /* Make sure src is aligned too. */ | ||||||
| @@ -882,18 +906,23 @@ SDL_Convert_S8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             vst1q_f32(dst + 4, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_high_s16(int16lo))), divby128)); |             vst1q_f32(dst + 4, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_high_s16(int16lo))), divby128)); | ||||||
|             vst1q_f32(dst + 8, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_low_s16(int16hi))), divby128)); |             vst1q_f32(dst + 8, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_low_s16(int16hi))), divby128)); | ||||||
|             vst1q_f32(dst + 12, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_high_s16(int16hi))), divby128)); |             vst1q_f32(dst + 12, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_high_s16(int16hi))), divby128)); | ||||||
|             i -= 16; mmsrc -= 16; dst -= 16; |             i -= 16; | ||||||
|  |             mmsrc -= 16; | ||||||
|  |             dst -= 16; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         src = (const Sint8 *)mmsrc; |         src = (const Sint8 *)mmsrc; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src += 15; dst += 15;  /* adjust for any scalar finishing. */ |     src += 15; | ||||||
|  |     dst += 15; /* adjust for any scalar finishing. */ | ||||||
|  |  | ||||||
|     /* Finish off any leftovers with scalar operations. */ |     /* Finish off any leftovers with scalar operations. */ | ||||||
|     while (i) { |     while (i) { | ||||||
|         *dst = ((float)*src) * DIVBY128; |         *dst = ((float)*src) * DIVBY128; | ||||||
|         i--; src--; dst--; |         i--; | ||||||
|  |         src--; | ||||||
|  |         dst--; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt *= 4; |     cvt->len_cvt *= 4; | ||||||
| @@ -902,8 +931,7 @@ SDL_Convert_S8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_U8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_U8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Uint8 *src = ((const Uint8 *)(cvt->buf + cvt->len_cvt)) - 1; |     const Uint8 *src = ((const Uint8 *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
|     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; |     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; | ||||||
| @@ -916,7 +944,8 @@ SDL_Convert_U8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         *dst = (((float)*src) * DIVBY128) - 1.0f; |         *dst = (((float)*src) * DIVBY128) - 1.0f; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src -= 15; dst -= 15;  /* adjust to read NEON blocks from the start. */ |     src -= 15; | ||||||
|  |     dst -= 15; /* adjust to read NEON blocks from the start. */ | ||||||
|     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); |     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); | ||||||
|  |  | ||||||
|     /* Make sure src is aligned too. */ |     /* Make sure src is aligned too. */ | ||||||
| @@ -934,18 +963,23 @@ SDL_Convert_U8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             vst1q_f32(dst + 4, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uint16lo))), divby128)); |             vst1q_f32(dst + 4, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uint16lo))), divby128)); | ||||||
|             vst1q_f32(dst + 8, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_low_u16(uint16hi))), divby128)); |             vst1q_f32(dst + 8, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_low_u16(uint16hi))), divby128)); | ||||||
|             vst1q_f32(dst + 12, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uint16hi))), divby128)); |             vst1q_f32(dst + 12, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uint16hi))), divby128)); | ||||||
|             i -= 16; mmsrc -= 16; dst -= 16; |             i -= 16; | ||||||
|  |             mmsrc -= 16; | ||||||
|  |             dst -= 16; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         src = (const Uint8 *)mmsrc; |         src = (const Uint8 *)mmsrc; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src += 15; dst += 15;  /* adjust for any scalar finishing. */ |     src += 15; | ||||||
|  |     dst += 15; /* adjust for any scalar finishing. */ | ||||||
|  |  | ||||||
|     /* Finish off any leftovers with scalar operations. */ |     /* Finish off any leftovers with scalar operations. */ | ||||||
|     while (i) { |     while (i) { | ||||||
|         *dst = (((float)*src) * DIVBY128) - 1.0f; |         *dst = (((float)*src) * DIVBY128) - 1.0f; | ||||||
|         i--; src--; dst--; |         i--; | ||||||
|  |         src--; | ||||||
|  |         dst--; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt *= 4; |     cvt->len_cvt *= 4; | ||||||
| @@ -954,8 +988,7 @@ SDL_Convert_U8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_S16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_S16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Sint16 *src = ((const Sint16 *)(cvt->buf + cvt->len_cvt)) - 1; |     const Sint16 *src = ((const Sint16 *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
|     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; |     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; | ||||||
| @@ -968,7 +1001,8 @@ SDL_Convert_S16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         *dst = ((float)*src) * DIVBY32768; |         *dst = ((float)*src) * DIVBY32768; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src -= 7; dst -= 7;  /* adjust to read NEON blocks from the start. */ |     src -= 7; | ||||||
|  |     dst -= 7; /* adjust to read NEON blocks from the start. */ | ||||||
|     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); |     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); | ||||||
|  |  | ||||||
|     /* Make sure src is aligned too. */ |     /* Make sure src is aligned too. */ | ||||||
| @@ -980,16 +1014,21 @@ SDL_Convert_S16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             /* split int16 to two int32, then convert to float, then multiply to normalize, store. */ |             /* split int16 to two int32, then convert to float, then multiply to normalize, store. */ | ||||||
|             vst1q_f32(dst, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_low_s16(ints))), divby32768)); |             vst1q_f32(dst, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_low_s16(ints))), divby32768)); | ||||||
|             vst1q_f32(dst + 4, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_high_s16(ints))), divby32768)); |             vst1q_f32(dst + 4, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_high_s16(ints))), divby32768)); | ||||||
|             i -= 8; src -= 8; dst -= 8; |             i -= 8; | ||||||
|  |             src -= 8; | ||||||
|  |             dst -= 8; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src += 7; dst += 7;  /* adjust for any scalar finishing. */ |     src += 7; | ||||||
|  |     dst += 7; /* adjust for any scalar finishing. */ | ||||||
|  |  | ||||||
|     /* Finish off any leftovers with scalar operations. */ |     /* Finish off any leftovers with scalar operations. */ | ||||||
|     while (i) { |     while (i) { | ||||||
|         *dst = ((float)*src) * DIVBY32768; |         *dst = ((float)*src) * DIVBY32768; | ||||||
|         i--; src--; dst--; |         i--; | ||||||
|  |         src--; | ||||||
|  |         dst--; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt *= 2; |     cvt->len_cvt *= 2; | ||||||
| @@ -998,8 +1037,7 @@ SDL_Convert_S16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_U16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_U16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Uint16 *src = ((const Uint16 *)(cvt->buf + cvt->len_cvt)) - 1; |     const Uint16 *src = ((const Uint16 *)(cvt->buf + cvt->len_cvt)) - 1; | ||||||
|     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; |     float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; | ||||||
| @@ -1012,7 +1050,8 @@ SDL_Convert_U16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         *dst = (((float)*src) * DIVBY32768) - 1.0f; |         *dst = (((float)*src) * DIVBY32768) - 1.0f; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src -= 7; dst -= 7;  /* adjust to read NEON blocks from the start. */ |     src -= 7; | ||||||
|  |     dst -= 7; /* adjust to read NEON blocks from the start. */ | ||||||
|     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); |     SDL_assert(!i || ((((size_t)dst) & 15) == 0)); | ||||||
|  |  | ||||||
|     /* Make sure src is aligned too. */ |     /* Make sure src is aligned too. */ | ||||||
| @@ -1025,16 +1064,21 @@ SDL_Convert_U16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             /* split uint16 to two int32, then convert to float, then multiply to normalize, subtract for sign, store. */ |             /* split uint16 to two int32, then convert to float, then multiply to normalize, subtract for sign, store. */ | ||||||
|             vst1q_f32(dst, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_low_u16(uints))), divby32768)); |             vst1q_f32(dst, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_low_u16(uints))), divby32768)); | ||||||
|             vst1q_f32(dst + 4, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uints))), divby32768)); |             vst1q_f32(dst + 4, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uints))), divby32768)); | ||||||
|             i -= 8; src -= 8; dst -= 8; |             i -= 8; | ||||||
|  |             src -= 8; | ||||||
|  |             dst -= 8; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     src += 7; dst += 7;  /* adjust for any scalar finishing. */ |     src += 7; | ||||||
|  |     dst += 7; /* adjust for any scalar finishing. */ | ||||||
|  |  | ||||||
|     /* Finish off any leftovers with scalar operations. */ |     /* Finish off any leftovers with scalar operations. */ | ||||||
|     while (i) { |     while (i) { | ||||||
|         *dst = (((float)*src) * DIVBY32768) - 1.0f; |         *dst = (((float)*src) * DIVBY32768) - 1.0f; | ||||||
|         i--; src--; dst--; |         i--; | ||||||
|  |         src--; | ||||||
|  |         dst--; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt *= 2; |     cvt->len_cvt *= 2; | ||||||
| @@ -1043,8 +1087,7 @@ SDL_Convert_U16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_S32_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_S32_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const Sint32 *src = (const Sint32 *)cvt->buf; |     const Sint32 *src = (const Sint32 *)cvt->buf; | ||||||
|     float *dst = (float *)cvt->buf; |     float *dst = (float *)cvt->buf; | ||||||
| @@ -1067,7 +1110,9 @@ SDL_Convert_S32_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         while (i >= 4) { /* 4 * sint32 */ |         while (i >= 4) { /* 4 * sint32 */ | ||||||
|             /* shift out lowest bits so int fits in a float32. Small precision loss, but much faster. */ |             /* shift out lowest bits so int fits in a float32. Small precision loss, but much faster. */ | ||||||
|             vst1q_f32(dst, vmulq_f32(vcvtq_f32_s32(vshrq_n_s32(vld1q_s32(mmsrc), 8)), divby8388607)); |             vst1q_f32(dst, vmulq_f32(vcvtq_f32_s32(vshrq_n_s32(vld1q_s32(mmsrc), 8)), divby8388607)); | ||||||
|             i -= 4; mmsrc += 4; dst += 4; |             i -= 4; | ||||||
|  |             mmsrc += 4; | ||||||
|  |             dst += 4; | ||||||
|         } |         } | ||||||
|         src = (const Sint32 *)mmsrc; |         src = (const Sint32 *)mmsrc; | ||||||
|     } |     } | ||||||
| @@ -1075,7 +1120,9 @@ SDL_Convert_S32_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     /* Finish off any leftovers with scalar operations. */ |     /* Finish off any leftovers with scalar operations. */ | ||||||
|     while (i) { |     while (i) { | ||||||
|         *dst = ((float)(*src >> 8)) * DIVBY8388607; |         *dst = ((float)(*src >> 8)) * DIVBY8388607; | ||||||
|         i--; src++; dst++; |         i--; | ||||||
|  |         src++; | ||||||
|  |         dst++; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (cvt->filters[++cvt->filter_index]) { |     if (cvt->filters[++cvt->filter_index]) { | ||||||
| @@ -1083,8 +1130,7 @@ SDL_Convert_S32_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_S8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_S8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Sint8 *dst = (Sint8 *)cvt->buf; |     Sint8 *dst = (Sint8 *)cvt->buf; | ||||||
| @@ -1121,7 +1167,9 @@ SDL_Convert_F32_to_S8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             const int8x8_t i8lo = vmovn_s16(vcombine_s16(vmovn_s32(ints1), vmovn_s32(ints2)));                                  /* narrow to sint16, combine, narrow to sint8 */ |             const int8x8_t i8lo = vmovn_s16(vcombine_s16(vmovn_s32(ints1), vmovn_s32(ints2)));                                  /* narrow to sint16, combine, narrow to sint8 */ | ||||||
|             const int8x8_t i8hi = vmovn_s16(vcombine_s16(vmovn_s32(ints3), vmovn_s32(ints4)));                                  /* narrow to sint16, combine, narrow to sint8 */ |             const int8x8_t i8hi = vmovn_s16(vcombine_s16(vmovn_s32(ints3), vmovn_s32(ints4)));                                  /* narrow to sint16, combine, narrow to sint8 */ | ||||||
|             vst1q_s8(mmdst, vcombine_s8(i8lo, i8hi));                                                                           /* combine to int8x16_t, store out */ |             vst1q_s8(mmdst, vcombine_s8(i8lo, i8hi));                                                                           /* combine to int8x16_t, store out */ | ||||||
|             i -= 16; src += 16; mmdst += 16; |             i -= 16; | ||||||
|  |             src += 16; | ||||||
|  |             mmdst += 16; | ||||||
|         } |         } | ||||||
|         dst = (Sint8 *)mmdst; |         dst = (Sint8 *)mmdst; | ||||||
|     } |     } | ||||||
| @@ -1136,7 +1184,9 @@ SDL_Convert_F32_to_S8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         } else { |         } else { | ||||||
|             *dst = (Sint8)(sample * 127.0f); |             *dst = (Sint8)(sample * 127.0f); | ||||||
|         } |         } | ||||||
|         i--; src++; dst++; |         i--; | ||||||
|  |         src++; | ||||||
|  |         dst++; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt /= 4; |     cvt->len_cvt /= 4; | ||||||
| @@ -1145,8 +1195,7 @@ SDL_Convert_F32_to_S8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_U8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_U8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Uint8 *dst = (Uint8 *)cvt->buf; |     Uint8 *dst = (Uint8 *)cvt->buf; | ||||||
| @@ -1183,7 +1232,9 @@ SDL_Convert_F32_to_U8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             const uint8x8_t ui8lo = vmovn_u16(vcombine_u16(vmovn_u32(uints1), vmovn_u32(uints2)));                                                /* narrow to uint16, combine, narrow to uint8 */ |             const uint8x8_t ui8lo = vmovn_u16(vcombine_u16(vmovn_u32(uints1), vmovn_u32(uints2)));                                                /* narrow to uint16, combine, narrow to uint8 */ | ||||||
|             const uint8x8_t ui8hi = vmovn_u16(vcombine_u16(vmovn_u32(uints3), vmovn_u32(uints4)));                                                /* narrow to uint16, combine, narrow to uint8 */ |             const uint8x8_t ui8hi = vmovn_u16(vcombine_u16(vmovn_u32(uints3), vmovn_u32(uints4)));                                                /* narrow to uint16, combine, narrow to uint8 */ | ||||||
|             vst1q_u8(mmdst, vcombine_u8(ui8lo, ui8hi));                                                                                           /* combine to uint8x16_t, store out */ |             vst1q_u8(mmdst, vcombine_u8(ui8lo, ui8hi));                                                                                           /* combine to uint8x16_t, store out */ | ||||||
|             i -= 16; src += 16; mmdst += 16; |             i -= 16; | ||||||
|  |             src += 16; | ||||||
|  |             mmdst += 16; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         dst = (Uint8 *)mmdst; |         dst = (Uint8 *)mmdst; | ||||||
| @@ -1199,7 +1250,9 @@ SDL_Convert_F32_to_U8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         } else { |         } else { | ||||||
|             *dst = (Uint8)((sample + 1.0f) * 127.0f); |             *dst = (Uint8)((sample + 1.0f) * 127.0f); | ||||||
|         } |         } | ||||||
|         i--; src++; dst++; |         i--; | ||||||
|  |         src++; | ||||||
|  |         dst++; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt /= 4; |     cvt->len_cvt /= 4; | ||||||
| @@ -1208,8 +1261,7 @@ SDL_Convert_F32_to_U8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_S16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_S16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Sint16 *dst = (Sint16 *)cvt->buf; |     Sint16 *dst = (Sint16 *)cvt->buf; | ||||||
| @@ -1242,7 +1294,9 @@ SDL_Convert_F32_to_S16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             const int32x4_t ints1 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), mulby32767));     /* load 4 floats, clamp, convert to sint32 */ |             const int32x4_t ints1 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), mulby32767));     /* load 4 floats, clamp, convert to sint32 */ | ||||||
|             const int32x4_t ints2 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 4)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ |             const int32x4_t ints2 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 4)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ | ||||||
|             vst1q_s16(mmdst, vcombine_s16(vmovn_s32(ints1), vmovn_s32(ints2)));                                                  /* narrow to sint16, combine, store out. */ |             vst1q_s16(mmdst, vcombine_s16(vmovn_s32(ints1), vmovn_s32(ints2)));                                                  /* narrow to sint16, combine, store out. */ | ||||||
|             i -= 8; src += 8; mmdst += 8; |             i -= 8; | ||||||
|  |             src += 8; | ||||||
|  |             mmdst += 8; | ||||||
|         } |         } | ||||||
|         dst = (Sint16 *)mmdst; |         dst = (Sint16 *)mmdst; | ||||||
|     } |     } | ||||||
| @@ -1257,7 +1311,9 @@ SDL_Convert_F32_to_S16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         } else { |         } else { | ||||||
|             *dst = (Sint16)(sample * 32767.0f); |             *dst = (Sint16)(sample * 32767.0f); | ||||||
|         } |         } | ||||||
|         i--; src++; dst++; |         i--; | ||||||
|  |         src++; | ||||||
|  |         dst++; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt /= 2; |     cvt->len_cvt /= 2; | ||||||
| @@ -1266,8 +1322,7 @@ SDL_Convert_F32_to_S16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_U16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_U16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Uint16 *dst = (Uint16 *)cvt->buf; |     Uint16 *dst = (Uint16 *)cvt->buf; | ||||||
| @@ -1300,7 +1355,9 @@ SDL_Convert_F32_to_U16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|             const uint32x4_t uints1 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), one), mulby32767));     /* load 4 floats, clamp, convert to uint32 */ |             const uint32x4_t uints1 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), one), mulby32767));     /* load 4 floats, clamp, convert to uint32 */ | ||||||
|             const uint32x4_t uints2 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 4)), one), one), mulby32767)); /* load 4 floats, clamp, convert to uint32 */ |             const uint32x4_t uints2 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 4)), one), one), mulby32767)); /* load 4 floats, clamp, convert to uint32 */ | ||||||
|             vst1q_u16(mmdst, vcombine_u16(vmovn_u32(uints1), vmovn_u32(uints2)));                                                                  /* narrow to uint16, combine, store out. */ |             vst1q_u16(mmdst, vcombine_u16(vmovn_u32(uints1), vmovn_u32(uints2)));                                                                  /* narrow to uint16, combine, store out. */ | ||||||
|             i -= 8; src += 8; mmdst += 8; |             i -= 8; | ||||||
|  |             src += 8; | ||||||
|  |             mmdst += 8; | ||||||
|         } |         } | ||||||
|         dst = (Uint16 *)mmdst; |         dst = (Uint16 *)mmdst; | ||||||
|     } |     } | ||||||
| @@ -1315,7 +1372,9 @@ SDL_Convert_F32_to_U16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         } else { |         } else { | ||||||
|             *dst = (Uint16)((sample + 1.0f) * 32767.0f); |             *dst = (Uint16)((sample + 1.0f) * 32767.0f); | ||||||
|         } |         } | ||||||
|         i--; src++; dst++; |         i--; | ||||||
|  |         src++; | ||||||
|  |         dst++; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     cvt->len_cvt /= 2; |     cvt->len_cvt /= 2; | ||||||
| @@ -1324,8 +1383,7 @@ SDL_Convert_F32_to_U16_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_Convert_F32_to_S32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | ||||||
| SDL_Convert_F32_to_S32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) |  | ||||||
| { | { | ||||||
|     const float *src = (const float *)cvt->buf; |     const float *src = (const float *)cvt->buf; | ||||||
|     Sint32 *dst = (Sint32 *)cvt->buf; |     Sint32 *dst = (Sint32 *)cvt->buf; | ||||||
| @@ -1356,7 +1414,9 @@ SDL_Convert_F32_to_S32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         int32_t *mmdst = (int32_t *)dst; |         int32_t *mmdst = (int32_t *)dst; | ||||||
|         while (i >= 4) { /* 4 * float32 */ |         while (i >= 4) { /* 4 * float32 */ | ||||||
|             vst1q_s32(mmdst, vshlq_n_s32(vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), mulby8388607)), 8)); |             vst1q_s32(mmdst, vshlq_n_s32(vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), mulby8388607)), 8)); | ||||||
|             i -= 4; src += 4; mmdst += 4; |             i -= 4; | ||||||
|  |             src += 4; | ||||||
|  |             mmdst += 4; | ||||||
|         } |         } | ||||||
|         dst = (Sint32 *)mmdst; |         dst = (Sint32 *)mmdst; | ||||||
|     } |     } | ||||||
| @@ -1371,7 +1431,9 @@ SDL_Convert_F32_to_S32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
|         } else { |         } else { | ||||||
|             *dst = ((Sint32)(sample * 8388607.0f)) << 8; |             *dst = ((Sint32)(sample * 8388607.0f)) << 8; | ||||||
|         } |         } | ||||||
|         i--; src++; dst++; |         i--; | ||||||
|  |         src++; | ||||||
|  |         dst++; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (cvt->filters[++cvt->filter_index]) { |     if (cvt->filters[++cvt->filter_index]) { | ||||||
| @@ -1380,8 +1442,6 @@ SDL_Convert_F32_to_S32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| void SDL_ChooseAudioConverters(void) | void SDL_ChooseAudioConverters(void) | ||||||
| { | { | ||||||
|     static SDL_bool converters_chosen = SDL_FALSE; |     static SDL_bool converters_chosen = SDL_FALSE; | ||||||
|   | |||||||
| @@ -85,9 +85,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) { | ||||||
| @@ -107,8 +105,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format, | |||||||
|             ++dst; |             ++dst; | ||||||
|             ++src; |             ++src; | ||||||
|         } |         } | ||||||
|         } |     } break; | ||||||
|         break; |  | ||||||
|  |  | ||||||
|     case AUDIO_S8: |     case AUDIO_S8: | ||||||
|     { |     { | ||||||
| @@ -133,8 +130,7 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format, | |||||||
|             ++dst8; |             ++dst8; | ||||||
|             ++src8; |             ++src8; | ||||||
|         } |         } | ||||||
|         } |     } break; | ||||||
|         break; |  | ||||||
|  |  | ||||||
|     case AUDIO_S16LSB: |     case AUDIO_S16LSB: | ||||||
|     { |     { | ||||||
| @@ -158,8 +154,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: | ||||||
|     { |     { | ||||||
| @@ -183,8 +178,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: | ||||||
|     { |     { | ||||||
| @@ -209,8 +203,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: | ||||||
|     { |     { | ||||||
| @@ -235,8 +228,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: | ||||||
|     { |     { | ||||||
| @@ -261,8 +253,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: | ||||||
|     { |     { | ||||||
| @@ -287,8 +278,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: | ||||||
|     { |     { | ||||||
| @@ -316,8 +306,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: | ||||||
|     { |     { | ||||||
| @@ -345,8 +334,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"); | ||||||
|   | |||||||
| @@ -91,7 +91,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; | ||||||
| @@ -102,7 +101,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 | ||||||
| { | { | ||||||
|     /* * * */ |     /* * * */ | ||||||
| @@ -125,7 +123,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 | ||||||
| { | { | ||||||
|   | |||||||
| @@ -43,8 +43,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; | ||||||
| @@ -66,21 +65,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; | ||||||
| @@ -102,8 +104,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"; | ||||||
| @@ -137,9 +138,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) { | ||||||
| @@ -226,8 +232,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" | ||||||
| @@ -317,8 +322,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) { | ||||||
| @@ -331,8 +335,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; | ||||||
| @@ -371,8 +374,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; | ||||||
| @@ -490,8 +492,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; | ||||||
| @@ -527,8 +528,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; | ||||||
| @@ -588,8 +588,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; | ||||||
| @@ -636,8 +635,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; | ||||||
| @@ -736,8 +734,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; | ||||||
| @@ -790,8 +787,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; | ||||||
| @@ -856,8 +852,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; | ||||||
| @@ -926,8 +921,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; | ||||||
| @@ -966,8 +960,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; | ||||||
| @@ -1036,8 +1029,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; | ||||||
| @@ -1140,8 +1132,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; | ||||||
|  |  | ||||||
| @@ -1169,8 +1160,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] = { | ||||||
| @@ -1312,8 +1302,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; | ||||||
|  |  | ||||||
| @@ -1356,8 +1345,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; | ||||||
| @@ -1408,8 +1396,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; | ||||||
| @@ -1451,8 +1438,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); | ||||||
|  |  | ||||||
| @@ -1471,8 +1457,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); | ||||||
|  |  | ||||||
| @@ -1491,8 +1476,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); | ||||||
|  |  | ||||||
| @@ -1511,8 +1495,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); | ||||||
| @@ -1521,8 +1504,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; | ||||||
| @@ -1554,8 +1536,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); | ||||||
|  |  | ||||||
| @@ -1583,19 +1564,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) }, | ||||||
| @@ -1605,8 +1589,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++) { | ||||||
| @@ -1617,8 +1600,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; | ||||||
| @@ -1679,8 +1661,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; | ||||||
|  |  | ||||||
| @@ -1787,8 +1768,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; | ||||||
| @@ -2150,8 +2130,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); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -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, | ||||||
|   | |||||||
| @@ -70,8 +70,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; | ||||||
| @@ -167,8 +166,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; | ||||||
| @@ -202,15 +200,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; | ||||||
| @@ -235,8 +231,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; | ||||||
| @@ -250,8 +245,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) { | ||||||
| @@ -269,8 +263,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__); | ||||||
|   | |||||||
| @@ -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: */ | ||||||
|   | |||||||
| @@ -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 */ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -46,56 +46,38 @@ | |||||||
| #include "SDL_loadso.h" | #include "SDL_loadso.h" | ||||||
| #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 *); | ||||||
| @@ -113,8 +95,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) { | ||||||
| @@ -127,13 +108,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); | ||||||
| @@ -183,8 +164,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); | ||||||
| @@ -192,8 +172,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) { | ||||||
| @@ -213,13 +192,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; | ||||||
| @@ -227,8 +204,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; | ||||||
|  |  | ||||||
| @@ -251,10 +227,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; | ||||||
| @@ -276,7 +250,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 | ||||||
| @@ -284,17 +257,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. */ | ||||||
| /* | /* | ||||||
| @@ -303,7 +280,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) {                               \ | ||||||
| @@ -335,44 +313,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) * | ||||||
| @@ -413,14 +397,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) * | ||||||
| @@ -462,14 +444,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 | ||||||
| @@ -484,8 +464,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; | ||||||
| @@ -540,8 +519,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; | ||||||
| @@ -731,8 +709,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; | ||||||
| @@ -791,11 +768,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; | ||||||
| @@ -928,8 +903,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); | ||||||
|  |  | ||||||
| @@ -947,8 +921,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. */ | ||||||
|  |  | ||||||
| @@ -959,8 +932,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; | ||||||
| @@ -985,8 +957,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; | ||||||
| @@ -1009,7 +980,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 | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -35,8 +35,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; | ||||||
| @@ -78,32 +77,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 | ||||||
| @@ -119,8 +113,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; | ||||||
| @@ -204,4 +197,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: */ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -48,7 +48,6 @@ | |||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| #if MACOSX_COREAUDIO | #if MACOSX_COREAUDIO | ||||||
| static const AudioObjectPropertyAddress devlist_address = { | static const AudioObjectPropertyAddress devlist_address = { | ||||||
|     kAudioHardwarePropertyDevices, |     kAudioHardwarePropertyDevices, | ||||||
| @@ -68,8 +67,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) { | ||||||
| @@ -87,16 +85,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; | ||||||
| @@ -184,8 +180,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); | ||||||
|  |  | ||||||
| @@ -212,8 +207,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) { | ||||||
| @@ -224,15 +218,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; | ||||||
| @@ -247,8 +239,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; | ||||||
| @@ -278,8 +269,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); | ||||||
| @@ -287,7 +277,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; | ||||||
| @@ -339,9 +328,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; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -516,10 +503,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; | ||||||
|  |  | ||||||
| @@ -583,8 +568,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; | ||||||
| @@ -598,8 +582,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) | ||||||
| { | { | ||||||
| @@ -636,17 +619,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; | ||||||
| @@ -675,8 +655,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 | ||||||
| @@ -687,8 +666,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; | ||||||
| @@ -750,8 +728,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; | ||||||
| @@ -770,21 +747,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."); | ||||||
| @@ -805,8 +779,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, | ||||||
| @@ -826,8 +799,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; | ||||||
| @@ -835,7 +807,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); | ||||||
|  |  | ||||||
| @@ -950,8 +923,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; | ||||||
| @@ -1027,8 +999,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; | ||||||
| @@ -1153,8 +1124,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]; | ||||||
|  |  | ||||||
| @@ -1167,8 +1137,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; | ||||||
| @@ -1288,8 +1257,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); | ||||||
| @@ -1298,8 +1266,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; | ||||||
|   | |||||||
| @@ -57,8 +57,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; | ||||||
| @@ -71,9 +70,7 @@ DSOUND_Unload(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static int DSOUND_Load(void) | ||||||
| static int |  | ||||||
| DSOUND_Load(void) |  | ||||||
| { | { | ||||||
|     int loaded = 0; |     int loaded = 0; | ||||||
|  |  | ||||||
| @@ -84,9 +81,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); | ||||||
| @@ -107,8 +106,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; | ||||||
|  |  | ||||||
| @@ -154,14 +152,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) { | ||||||
| @@ -171,8 +167,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 */ | ||||||
| @@ -192,8 +187,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) { | ||||||
| @@ -207,9 +201,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; | ||||||
| @@ -266,8 +258,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) { | ||||||
| @@ -277,8 +268,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; | ||||||
| @@ -325,8 +315,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) { | ||||||
| @@ -336,8 +325,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; | ||||||
| @@ -380,8 +368,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; | ||||||
| @@ -390,8 +377,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); | ||||||
| @@ -414,8 +400,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; | ||||||
| @@ -457,8 +442,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; | ||||||
| @@ -497,8 +481,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; | ||||||
| @@ -568,8 +551,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; | ||||||
| @@ -629,9 +611,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) { | ||||||
| @@ -642,9 +622,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; | ||||||
|   | |||||||
| @@ -43,14 +43,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, | ||||||
| @@ -65,14 +63,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; | ||||||
| @@ -95,15 +91,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); | ||||||
| @@ -112,9 +105,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); | ||||||
| @@ -125,8 +116,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" */ | ||||||
| @@ -172,15 +162,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; | ||||||
|   | |||||||
| @@ -42,16 +42,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); | ||||||
| @@ -60,9 +56,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); | ||||||
| @@ -205,7 +199,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"); | ||||||
|     } |     } | ||||||
| @@ -244,9 +239,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) { | ||||||
| @@ -258,20 +251,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; | ||||||
| @@ -289,16 +279,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); | ||||||
| @@ -322,7 +310,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 | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -27,15 +27,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); | ||||||
| @@ -45,8 +44,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; | ||||||
|   | |||||||
| @@ -33,10 +33,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 SDL2 = Module['SDL2']; |         var SDL2 = Module['SDL2']; | ||||||
|         var numChannels = SDL2.audio.currentOutputBuffer['numberOfChannels']; |         var numChannels = SDL2.audio.currentOutputBuffer['numberOfChannels']; | ||||||
| @@ -51,10 +51,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; | ||||||
| @@ -94,8 +94,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; | ||||||
| @@ -106,6 +105,7 @@ HandleCaptureProcess(_THIS) | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /* *INDENT-OFF* */ /* clang-format off */ | ||||||
|     MAIN_THREAD_EM_ASM({ |     MAIN_THREAD_EM_ASM({ | ||||||
|         var SDL2 = Module['SDL2']; |         var SDL2 = Module['SDL2']; | ||||||
|         var numChannels = SDL2.capture.currentCaptureBuffer.numberOfChannels; |         var numChannels = SDL2.capture.currentCaptureBuffer.numberOfChannels; | ||||||
| @@ -126,6 +126,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. */ | ||||||
|  |  | ||||||
| @@ -148,10 +149,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 SDL2 = Module['SDL2']; |         var SDL2 = Module['SDL2']; | ||||||
|         if ($0) { |         if ($0) { | ||||||
| @@ -190,14 +190,14 @@ EMSCRIPTENAUDIO_CloseDevice(_THIS) | |||||||
|             SDL2.audioContext = undefined; |             SDL2.audioContext = undefined; | ||||||
|         } |         } | ||||||
|     }, this->iscapture); |     }, this->iscapture); | ||||||
|  | /* *INDENT-ON* */ /* clang-format on */ | ||||||
|  |  | ||||||
| #if 0  /* !!! FIXME: currently not used. Can we move some stuff off the SDL2 namespace? --ryan. */ | #if 0  /* !!! FIXME: currently not used. Can we move some stuff off the SDL2 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; | ||||||
| @@ -205,6 +205,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['SDL2']) === 'undefined') { |         if(typeof(Module['SDL2']) === 'undefined') { | ||||||
| @@ -229,6 +230,8 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname) | |||||||
|         } |         } | ||||||
|         return SDL2.audioContext === undefined ? -1 : 0; |         return SDL2.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!"); | ||||||
|     } |     } | ||||||
| @@ -268,6 +271,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 | ||||||
| @@ -339,17 +343,16 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname) | |||||||
|             SDL2.audio.scriptProcessorNode['connect'](SDL2.audioContext['destination']); |             SDL2.audio.scriptProcessorNode['connect'](SDL2.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; | ||||||
|  |  | ||||||
| @@ -363,6 +366,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') { | ||||||
| @@ -372,11 +376,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; | ||||||
| @@ -385,6 +391,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; | ||||||
|   | |||||||
| @@ -42,8 +42,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; | ||||||
| @@ -85,8 +84,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(); | ||||||
| @@ -100,8 +98,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; | ||||||
| @@ -113,15 +110,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; | ||||||
| @@ -208,14 +203,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) { | ||||||
|   | |||||||
| @@ -29,7 +29,6 @@ | |||||||
| #include "SDL_loadso.h" | #include "SDL_loadso.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 *); | ||||||
| @@ -50,15 +49,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) { | ||||||
| @@ -71,10 +68,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); | ||||||
| @@ -82,8 +79,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) { | ||||||
| @@ -105,13 +101,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; | ||||||
| @@ -119,9 +113,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); | ||||||
| @@ -143,9 +135,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); | ||||||
| @@ -156,8 +146,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; | ||||||
| @@ -183,13 +172,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) { | ||||||
| @@ -198,15 +185,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)) { | ||||||
| @@ -229,11 +213,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. */ | ||||||
|  |  | ||||||
| @@ -246,15 +229,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); | ||||||
| @@ -279,8 +259,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). | ||||||
| @@ -336,7 +315,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. */ | ||||||
| @@ -400,14 +378,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; | ||||||
|   | |||||||
| @@ -38,32 +38,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); | ||||||
| @@ -74,8 +69,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; | ||||||
| @@ -97,8 +91,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; | ||||||
| @@ -188,8 +181,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); | ||||||
| @@ -199,8 +191,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; | ||||||
| @@ -226,8 +217,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 && | ||||||
| @@ -237,14 +227,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); | ||||||
|  |  | ||||||
| @@ -264,8 +252,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(¤t_priority, CUR_THREAD_HANDLE); |     svcGetThreadPriority(¤t_priority, CUR_THREAD_HANDLE); | ||||||
| @@ -275,8 +262,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; | ||||||
| @@ -306,8 +292,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; | ||||||
| @@ -326,8 +311,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); | ||||||
|   | |||||||
| @@ -45,15 +45,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 */ | ||||||
| @@ -119,12 +116,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; | ||||||
| @@ -143,15 +139,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; | ||||||
| @@ -169,8 +162,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; | ||||||
| @@ -191,8 +183,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); | ||||||
| @@ -201,8 +192,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; | ||||||
| @@ -241,8 +231,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 | ||||||
|  |  | ||||||
| @@ -320,8 +309,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; | ||||||
| @@ -338,7 +326,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 | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -128,8 +128,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 }; | ||||||
| @@ -183,8 +182,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; | ||||||
|  |  | ||||||
| @@ -192,8 +190,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; | ||||||
| @@ -224,8 +221,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; | ||||||
| @@ -363,8 +359,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; | ||||||
|  |  | ||||||
| @@ -372,8 +367,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; | ||||||
| @@ -405,8 +399,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; | ||||||
| @@ -466,8 +459,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; | ||||||
| @@ -596,8 +588,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) { | ||||||
| @@ -625,12 +616,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; | ||||||
|  |  | ||||||
| @@ -640,8 +629,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; | ||||||
| @@ -675,8 +663,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; | ||||||
|  |  | ||||||
| @@ -684,8 +671,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; | ||||||
| @@ -712,8 +698,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; */ | ||||||
|  |  | ||||||
| @@ -728,8 +713,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"); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -126,8 +126,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) { | ||||||
| @@ -143,8 +142,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; | ||||||
| @@ -153,8 +151,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); | ||||||
| @@ -166,21 +163,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); | ||||||
| @@ -222,8 +216,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()) { | ||||||
| @@ -245,8 +238,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(); | ||||||
| @@ -307,8 +299,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; | ||||||
| @@ -333,8 +324,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; | ||||||
|  |  | ||||||
| @@ -354,8 +344,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; | ||||||
| @@ -380,8 +369,7 @@ io_list_sort() | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void io_list_clear() | ||||||
| io_list_clear() |  | ||||||
| { | { | ||||||
|     struct io_node *n, *temp; |     struct io_node *n, *temp; | ||||||
|  |  | ||||||
| @@ -415,8 +403,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); | ||||||
|  |  | ||||||
| @@ -428,15 +415,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; | ||||||
|  |  | ||||||
| @@ -447,8 +432,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; | ||||||
|  |  | ||||||
| @@ -457,8 +441,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; | ||||||
| @@ -487,8 +470,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. */ | ||||||
| @@ -500,8 +482,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; | ||||||
| @@ -519,8 +500,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; | ||||||
|  |  | ||||||
| @@ -533,8 +513,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 | ||||||
| @@ -550,8 +529,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; | ||||||
| @@ -584,8 +562,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; | ||||||
| @@ -604,8 +581,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; | ||||||
| @@ -627,8 +603,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; | ||||||
| @@ -653,8 +628,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" */ | ||||||
| @@ -676,8 +650,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; | ||||||
|  |  | ||||||
| @@ -703,8 +676,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; | ||||||
| @@ -775,8 +747,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); | ||||||
| @@ -786,8 +757,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; | ||||||
|  |  | ||||||
| @@ -830,8 +800,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); | ||||||
| @@ -873,8 +842,7 @@ hotplug_loop_destroy() | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void PIPEWIRE_DetectDevices() | ||||||
| PIPEWIRE_DetectDevices() |  | ||||||
| { | { | ||||||
|     struct io_node *io; |     struct io_node *io; | ||||||
|  |  | ||||||
| @@ -916,8 +884,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; | ||||||
| @@ -984,8 +951,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; | ||||||
| @@ -1050,8 +1016,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; | ||||||
| @@ -1106,8 +1071,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; | ||||||
|  |  | ||||||
| @@ -1137,8 +1101,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; | ||||||
|  |  | ||||||
| @@ -1160,8 +1123,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 | ||||||
| @@ -1344,8 +1306,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; | ||||||
| @@ -1383,8 +1344,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(); | ||||||
| @@ -1393,8 +1353,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) { | ||||||
|   | |||||||
| @@ -35,8 +35,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; | ||||||
| @@ -48,7 +47,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: | ||||||
|   | |||||||
| @@ -41,8 +41,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; | ||||||
|  |  | ||||||
| @@ -158,8 +157,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; | ||||||
|   | |||||||
| @@ -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. */ | ||||||
|   | |||||||
| @@ -49,19 +49,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); | ||||||
| @@ -116,14 +116,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) { | ||||||
| @@ -136,10 +134,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); | ||||||
| @@ -147,8 +145,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) { | ||||||
| @@ -170,13 +167,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; | ||||||
| @@ -184,9 +179,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); | ||||||
| @@ -229,15 +222,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) { | ||||||
| @@ -261,8 +252,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) { | ||||||
| @@ -274,8 +264,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); | ||||||
| @@ -286,8 +275,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; | ||||||
| @@ -338,8 +326,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) { | ||||||
| @@ -348,10 +335,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. */ | ||||||
| } | } | ||||||
| @@ -363,8 +348,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; | ||||||
| @@ -399,15 +383,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; | ||||||
| @@ -441,7 +422,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. */ | ||||||
| @@ -454,8 +436,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; | ||||||
| @@ -485,8 +466,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) { | ||||||
| @@ -502,8 +482,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; | ||||||
| @@ -511,8 +490,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; | ||||||
| @@ -520,8 +498,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; | ||||||
|  |  | ||||||
| @@ -542,8 +519,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; | ||||||
| @@ -696,8 +672,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: | ||||||
| @@ -720,8 +695,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); | ||||||
| @@ -749,8 +723,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); | ||||||
| @@ -780,8 +753,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); | ||||||
| @@ -794,8 +766,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); | ||||||
| @@ -824,8 +795,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); | ||||||
| @@ -836,8 +806,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))); | ||||||
| @@ -847,8 +816,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; | ||||||
| @@ -879,8 +847,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); | ||||||
| @@ -912,8 +879,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; | ||||||
|   | |||||||
| @@ -70,8 +70,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) { | ||||||
| @@ -84,13 +83,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); | ||||||
| @@ -112,8 +111,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); | ||||||
| @@ -121,8 +119,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) { | ||||||
| @@ -142,13 +139,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; | ||||||
| @@ -156,17 +151,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, | ||||||
| @@ -181,8 +171,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; | ||||||
| @@ -191,8 +180,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); | ||||||
| @@ -206,8 +194,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]; | ||||||
|  |  | ||||||
| @@ -216,14 +203,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); | ||||||
| @@ -236,8 +221,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; | ||||||
| @@ -341,21 +325,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; | ||||||
|   | |||||||
| @@ -42,8 +42,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; | ||||||
| @@ -60,8 +59,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 }; | ||||||
| @@ -194,8 +192,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; | ||||||
|   | |||||||
| @@ -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. */ | ||||||
|   | |||||||
| @@ -49,14 +49,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; | ||||||
| @@ -73,8 +71,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 | ||||||
| @@ -126,11 +123,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. */ | ||||||
|  |  | ||||||
| @@ -153,8 +148,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; | ||||||
| @@ -177,8 +171,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; | ||||||
| @@ -193,8 +186,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. */ | ||||||
| @@ -202,8 +194,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); | ||||||
| @@ -230,8 +221,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); | ||||||
| @@ -295,8 +285,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; | ||||||
| @@ -320,8 +309,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); | ||||||
| @@ -360,20 +348,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; | ||||||
| @@ -390,8 +375,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 | ||||||
| @@ -541,9 +525,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; | ||||||
|  |  | ||||||
| @@ -581,26 +563,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; | ||||||
|   | |||||||
| @@ -49,8 +49,7 @@ static pfnAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics = NUL | |||||||
| /* Some GUIDs we need to know without linking to libraries that aren't available before Vista. */ | /* Some GUIDs we need to know without linking to libraries that aren't available before Vista. */ | ||||||
| static const IID SDL_IID_IAudioClient = { 0x1cb9ad4c, 0xdbfa, 0x4c32, { 0xb1, 0x78, 0xc2, 0xf5, 0x68, 0xa7, 0x03, 0xb2 } }; | static const IID SDL_IID_IAudioClient = { 0x1cb9ad4c, 0xdbfa, 0x4c32, { 0xb1, 0x78, 0xc2, 0xf5, 0x68, 0xa7, 0x03, 0xb2 } }; | ||||||
|  |  | ||||||
| int | int WASAPI_PlatformInit(void) | ||||||
| WASAPI_PlatformInit(void) |  | ||||||
| { | { | ||||||
|     if (SDL_IMMDevice_Init() < 0) { |     if (SDL_IMMDevice_Init() < 0) { | ||||||
|         return -1; /* This is set by SDL_IMMDevice_Init */ |         return -1; /* This is set by SDL_IMMDevice_Init */ | ||||||
| @@ -65,8 +64,7 @@ WASAPI_PlatformInit(void) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WASAPI_PlatformDeinit(void) | ||||||
| WASAPI_PlatformDeinit(void) |  | ||||||
| { | { | ||||||
|     if (libavrt) { |     if (libavrt) { | ||||||
|         FreeLibrary(libavrt); |         FreeLibrary(libavrt); | ||||||
| @@ -79,8 +77,7 @@ WASAPI_PlatformDeinit(void) | |||||||
|     SDL_IMMDevice_Quit(); |     SDL_IMMDevice_Quit(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WASAPI_PlatformThreadInit(_THIS) | ||||||
| WASAPI_PlatformThreadInit(_THIS) |  | ||||||
| { | { | ||||||
|     /* this thread uses COM. */ |     /* this thread uses COM. */ | ||||||
|     if (SUCCEEDED(WIN_CoInitialize())) { /* can't report errors, hope it worked! */ |     if (SUCCEEDED(WIN_CoInitialize())) { /* can't report errors, hope it worked! */ | ||||||
| @@ -94,8 +91,7 @@ WASAPI_PlatformThreadInit(_THIS) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WASAPI_PlatformThreadDeinit(_THIS) | ||||||
| WASAPI_PlatformThreadDeinit(_THIS) |  | ||||||
| { | { | ||||||
|     /* Set this thread back to normal priority. */ |     /* Set this thread back to normal priority. */ | ||||||
|     if (this->hidden->task && pAvRevertMmThreadCharacteristics) { |     if (this->hidden->task && pAvRevertMmThreadCharacteristics) { | ||||||
| @@ -109,8 +105,7 @@ WASAPI_PlatformThreadDeinit(_THIS) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) | ||||||
| WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) |  | ||||||
| { | { | ||||||
|     IMMDevice *device = NULL; |     IMMDevice *device = NULL; | ||||||
|     HRESULT ret; |     HRESULT ret; | ||||||
| @@ -137,20 +132,17 @@ WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) | |||||||
|     return 0; /* good to go. */ |     return 0; /* good to go. */ | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WASAPI_EnumerateEndpoints(void) | ||||||
| WASAPI_EnumerateEndpoints(void) |  | ||||||
| { | { | ||||||
|     SDL_IMMDevice_EnumerateEndpoints(SDL_FALSE); |     SDL_IMMDevice_EnumerateEndpoints(SDL_FALSE); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int WASAPI_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) | ||||||
| WASAPI_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) |  | ||||||
| { | { | ||||||
|     return SDL_IMMDevice_GetDefaultAudioInfo(name, spec, iscapture); |     return SDL_IMMDevice_GetDefaultAudioInfo(name, spec, iscapture); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WASAPI_PlatformDeleteActivationHandler(void *handler) | ||||||
| WASAPI_PlatformDeleteActivationHandler(void *handler) |  | ||||||
| { | { | ||||||
|     /* not asynchronous. */ |     /* not asynchronous. */ | ||||||
|     SDL_assert(!"This function should have only been called on WinRT."); |     SDL_assert(!"This function should have only been called on WinRT."); | ||||||
| @@ -159,4 +151,3 @@ WASAPI_PlatformDeleteActivationHandler(void *handler) | |||||||
| #endif /* SDL_AUDIO_DRIVER_WASAPI && !defined(__WINRT__) */ | #endif /* SDL_AUDIO_DRIVER_WASAPI && !defined(__WINRT__) */ | ||||||
|  |  | ||||||
| /* vi: set ts=4 sw=4 expandtab: */ | /* vi: set ts=4 sw=4 expandtab: */ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -95,14 +95,12 @@ private: | |||||||
| }; | }; | ||||||
|  |  | ||||||
| SDL_WasapiDeviceEventHandler::SDL_WasapiDeviceEventHandler(const SDL_bool _iscapture) | SDL_WasapiDeviceEventHandler::SDL_WasapiDeviceEventHandler(const SDL_bool _iscapture) | ||||||
|     : iscapture(_iscapture) |     : iscapture(_iscapture), completed(SDL_CreateSemaphore(0)) | ||||||
|     , completed(SDL_CreateSemaphore(0)) |  | ||||||
| { | { | ||||||
|     if (!completed) |     if (!completed) | ||||||
|         return; // uhoh. |         return; // uhoh. | ||||||
|  |  | ||||||
|     Platform::String^ selector = _iscapture ? MediaDevice::GetAudioCaptureSelector() : |     Platform::String ^ selector = _iscapture ? MediaDevice::GetAudioCaptureSelector() : MediaDevice::GetAudioRenderSelector(); | ||||||
|                                               MediaDevice::GetAudioRenderSelector(); |  | ||||||
|     Platform::Collections::Vector<Platform::String ^> properties; |     Platform::Collections::Vector<Platform::String ^> properties; | ||||||
|     properties.Append(SDL_PKEY_AudioEngine_DeviceFormat); |     properties.Append(SDL_PKEY_AudioEngine_DeviceFormat); | ||||||
|     watcher = DeviceInformation::CreateWatcher(selector, properties.GetView()); |     watcher = DeviceInformation::CreateWatcher(selector, properties.GetView()); | ||||||
| @@ -144,8 +142,7 @@ SDL_WasapiDeviceEventHandler::~SDL_WasapiDeviceEventHandler() | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_WasapiDeviceEventHandler::OnDeviceAdded(DeviceWatcher ^ sender, DeviceInformation ^ info) | ||||||
| SDL_WasapiDeviceEventHandler::OnDeviceAdded(DeviceWatcher^ sender, DeviceInformation^ info) |  | ||||||
| { | { | ||||||
|     SDL_assert(sender == this->watcher); |     SDL_assert(sender == this->watcher); | ||||||
|     char *utf8dev = WIN_StringToUTF8(info->Name->Data()); |     char *utf8dev = WIN_StringToUTF8(info->Name->Data()); | ||||||
| @@ -166,41 +163,35 @@ SDL_WasapiDeviceEventHandler::OnDeviceAdded(DeviceWatcher^ sender, DeviceInforma | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_WasapiDeviceEventHandler::OnDeviceRemoved(DeviceWatcher ^ sender, DeviceInformationUpdate ^ info) | ||||||
| SDL_WasapiDeviceEventHandler::OnDeviceRemoved(DeviceWatcher^ sender, DeviceInformationUpdate^ info) |  | ||||||
| { | { | ||||||
|     SDL_assert(sender == this->watcher); |     SDL_assert(sender == this->watcher); | ||||||
|     WASAPI_RemoveDevice(this->iscapture, info->Id->Data()); |     WASAPI_RemoveDevice(this->iscapture, info->Id->Data()); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_WasapiDeviceEventHandler::OnDeviceUpdated(DeviceWatcher ^ sender, DeviceInformationUpdate ^ args) | ||||||
| SDL_WasapiDeviceEventHandler::OnDeviceUpdated(DeviceWatcher^ sender, DeviceInformationUpdate^ args) |  | ||||||
| { | { | ||||||
|     SDL_assert(sender == this->watcher); |     SDL_assert(sender == this->watcher); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_WasapiDeviceEventHandler::OnEnumerationCompleted(DeviceWatcher ^ sender, Platform::Object ^ args) | ||||||
| SDL_WasapiDeviceEventHandler::OnEnumerationCompleted(DeviceWatcher^ sender, Platform::Object^ args) |  | ||||||
| { | { | ||||||
|     SDL_assert(sender == this->watcher); |     SDL_assert(sender == this->watcher); | ||||||
|     SDL_SemPost(this->completed); |     SDL_SemPost(this->completed); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_WasapiDeviceEventHandler::OnDefaultRenderDeviceChanged(Platform::Object ^ sender, DefaultAudioRenderDeviceChangedEventArgs ^ args) | ||||||
| SDL_WasapiDeviceEventHandler::OnDefaultRenderDeviceChanged(Platform::Object^ sender, DefaultAudioRenderDeviceChangedEventArgs^ args) |  | ||||||
| { | { | ||||||
|     SDL_assert(this->iscapture); |     SDL_assert(this->iscapture); | ||||||
|     SDL_AtomicAdd(&SDL_IMMDevice_DefaultPlaybackGeneration, 1); |     SDL_AtomicAdd(&SDL_IMMDevice_DefaultPlaybackGeneration, 1); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_WasapiDeviceEventHandler::OnDefaultCaptureDeviceChanged(Platform::Object ^ sender, DefaultAudioCaptureDeviceChangedEventArgs ^ args) | ||||||
| SDL_WasapiDeviceEventHandler::OnDefaultCaptureDeviceChanged(Platform::Object^ sender, DefaultAudioCaptureDeviceChangedEventArgs^ args) |  | ||||||
| { | { | ||||||
|     SDL_assert(!this->iscapture); |     SDL_assert(!this->iscapture); | ||||||
|     SDL_AtomicAdd(&SDL_IMMDevice_DefaultCaptureGeneration, 1); |     SDL_AtomicAdd(&SDL_IMMDevice_DefaultCaptureGeneration, 1); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| static SDL_WasapiDeviceEventHandler *playback_device_event_handler; | static SDL_WasapiDeviceEventHandler *playback_device_event_handler; | ||||||
| static SDL_WasapiDeviceEventHandler *capture_device_event_handler; | static SDL_WasapiDeviceEventHandler *capture_device_event_handler; | ||||||
|  |  | ||||||
| @@ -243,7 +234,8 @@ void WASAPI_EnumerateEndpoints(void) | |||||||
| struct SDL_WasapiActivationHandler : public RuntimeClass<RuntimeClassFlags<ClassicCom>, FtmBase, IActivateAudioInterfaceCompletionHandler> | struct SDL_WasapiActivationHandler : public RuntimeClass<RuntimeClassFlags<ClassicCom>, FtmBase, IActivateAudioInterfaceCompletionHandler> | ||||||
| { | { | ||||||
|     SDL_WasapiActivationHandler() : device(nullptr) {} |     SDL_WasapiActivationHandler() : device(nullptr) {} | ||||||
|     STDMETHOD(ActivateCompleted)(IActivateAudioInterfaceAsyncOperation *operation); |     STDMETHOD(ActivateCompleted) | ||||||
|  |     (IActivateAudioInterfaceAsyncOperation *operation); | ||||||
|     SDL_AudioDevice *device; |     SDL_AudioDevice *device; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @@ -256,20 +248,17 @@ SDL_WasapiActivationHandler::ActivateCompleted(IActivateAudioInterfaceAsyncOpera | |||||||
|     return S_OK; |     return S_OK; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WASAPI_PlatformDeleteActivationHandler(void *handler) | ||||||
| WASAPI_PlatformDeleteActivationHandler(void *handler) |  | ||||||
| { | { | ||||||
|     ((SDL_WasapiActivationHandler *)handler)->Release(); |     ((SDL_WasapiActivationHandler *)handler)->Release(); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int WASAPI_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) | ||||||
| WASAPI_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) |  | ||||||
| { | { | ||||||
|     return SDL_Unsupported(); |     return SDL_Unsupported(); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) | ||||||
| WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) |  | ||||||
| { | { | ||||||
|     LPCWSTR devid = _this->hidden->devid; |     LPCWSTR devid = _this->hidden->devid; | ||||||
|     Platform::String ^ defdevid; |     Platform::String ^ defdevid; | ||||||
| @@ -339,14 +328,12 @@ WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WASAPI_PlatformThreadInit(_THIS) | ||||||
| WASAPI_PlatformThreadInit(_THIS) |  | ||||||
| { | { | ||||||
|     // !!! FIXME: set this thread to "Pro Audio" priority. |     // !!! FIXME: set this thread to "Pro Audio" priority. | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WASAPI_PlatformThreadDeinit(_THIS) | ||||||
| WASAPI_PlatformThreadDeinit(_THIS) |  | ||||||
| { | { | ||||||
|     // !!! FIXME: set this thread to "Pro Audio" priority. |     // !!! FIXME: set this thread to "Pro Audio" priority. | ||||||
| } | } | ||||||
| @@ -378,8 +365,7 @@ WaveFormatToSDLFormat(WAVEFORMATEX *waveformat) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void WASAPI_RemoveDevice(const SDL_bool iscapture, LPCWSTR devid) | ||||||
| WASAPI_RemoveDevice(const SDL_bool iscapture, LPCWSTR devid) |  | ||||||
| { | { | ||||||
|     DevIdList *i; |     DevIdList *i; | ||||||
|     DevIdList *next; |     DevIdList *next; | ||||||
| @@ -401,8 +387,7 @@ WASAPI_RemoveDevice(const SDL_bool iscapture, LPCWSTR devid) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid) | ||||||
| WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid) |  | ||||||
| { | { | ||||||
|     DevIdList *devidlist; |     DevIdList *devidlist; | ||||||
|     SDL_AudioSpec spec; |     SDL_AudioSpec spec; | ||||||
|   | |||||||
| @@ -274,7 +274,6 @@ static JNINativeMethod SDLControllerManager_tab[] = { | |||||||
|     { "nativeRemoveHaptic", "(I)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic) } |     { "nativeRemoveHaptic", "(I)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic) } | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Uncomment this to log messages entering and exiting methods in this file */ | /* Uncomment this to log messages entering and exiting methods in this file */ | ||||||
| /* #define DEBUG_JNI */ | /* #define DEBUG_JNI */ | ||||||
|  |  | ||||||
| @@ -285,7 +284,6 @@ static void checkJNIReady(void); | |||||||
| *******************************************************************************/ | *******************************************************************************/ | ||||||
| #include <jni.h> | #include <jni.h> | ||||||
|  |  | ||||||
|  |  | ||||||
| /******************************************************************************* | /******************************************************************************* | ||||||
|                                Globals |                                Globals | ||||||
| *******************************************************************************/ | *******************************************************************************/ | ||||||
| @@ -396,8 +394,8 @@ static jobject javaAssetManagerRef = 0; | |||||||
|  */ |  */ | ||||||
|  |  | ||||||
| /* Set local storage value */ | /* Set local storage value */ | ||||||
| static int | static int Android_JNI_SetEnv(JNIEnv *env) | ||||||
| Android_JNI_SetEnv(JNIEnv *env) { | { | ||||||
|     int status = pthread_setspecific(mThreadKey, env); |     int status = pthread_setspecific(mThreadKey, env); | ||||||
|     if (status < 0) { |     if (status < 0) { | ||||||
|         __android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed pthread_setspecific() in Android_JNI_SetEnv() (err=%d)", status); |         __android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed pthread_setspecific() in Android_JNI_SetEnv() (err=%d)", status); | ||||||
| @@ -466,8 +464,7 @@ int Android_JNI_SetupThread(void) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* Destructor called for each thread where mThreadKey is not NULL */ | /* Destructor called for each thread where mThreadKey is not NULL */ | ||||||
| static void | static void Android_JNI_ThreadDestroyed(void *value) | ||||||
| Android_JNI_ThreadDestroyed(void *value) |  | ||||||
| { | { | ||||||
|     /* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */ |     /* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */ | ||||||
|     JNIEnv *env = (JNIEnv *)value; |     JNIEnv *env = (JNIEnv *)value; | ||||||
| @@ -478,8 +475,7 @@ Android_JNI_ThreadDestroyed(void *value) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* Creation of local storage mThreadKey */ | /* Creation of local storage mThreadKey */ | ||||||
| static void | static void Android_JNI_CreateKey(void) | ||||||
| Android_JNI_CreateKey(void) |  | ||||||
| { | { | ||||||
|     int status = pthread_key_create(&mThreadKey, Android_JNI_ThreadDestroyed); |     int status = pthread_key_create(&mThreadKey, Android_JNI_ThreadDestroyed); | ||||||
|     if (status < 0) { |     if (status < 0) { | ||||||
| @@ -487,8 +483,7 @@ Android_JNI_CreateKey(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void Android_JNI_CreateKey_once(void) | ||||||
| Android_JNI_CreateKey_once(void) |  | ||||||
| { | { | ||||||
|     int status = pthread_once(&key_once, Android_JNI_CreateKey); |     int status = pthread_once(&key_once, Android_JNI_CreateKey); | ||||||
|     if (status < 0) { |     if (status < 0) { | ||||||
| @@ -496,8 +491,7 @@ Android_JNI_CreateKey_once(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void register_methods(JNIEnv *env, const char *classname, JNINativeMethod *methods, int nb) | ||||||
| register_methods(JNIEnv *env, const char *classname, JNINativeMethod *methods, int nb) |  | ||||||
| { | { | ||||||
|     jclass clazz = (*env)->FindClass(env, classname); |     jclass clazz = (*env)->FindClass(env, classname); | ||||||
|     if (clazz == NULL || (*env)->RegisterNatives(env, clazz, methods, nb) < 0) { |     if (clazz == NULL || (*env)->RegisterNatives(env, clazz, methods, nb) < 0) { | ||||||
| @@ -575,7 +569,6 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl | |||||||
|         __android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_ActivityMutex mutex"); |         __android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_ActivityMutex mutex"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     Android_PauseSem = SDL_CreateSemaphore(0); |     Android_PauseSem = SDL_CreateSemaphore(0); | ||||||
|     if (Android_PauseSem == NULL) { |     if (Android_PauseSem == NULL) { | ||||||
|         __android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_PauseSem semaphore"); |         __android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_PauseSem semaphore"); | ||||||
| @@ -784,7 +777,6 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls, | |||||||
|             } |             } | ||||||
|             argv[argc] = NULL; |             argv[argc] = NULL; | ||||||
|  |  | ||||||
|  |  | ||||||
|             /* Run the application. */ |             /* Run the application. */ | ||||||
|             status = SDL_main(argc, argv); |             status = SDL_main(argc, argv); | ||||||
|  |  | ||||||
| @@ -828,16 +820,19 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)( | |||||||
| } | } | ||||||
|  |  | ||||||
| /* Lock / Unlock Mutex */ | /* Lock / Unlock Mutex */ | ||||||
| void Android_ActivityMutex_Lock() { | void Android_ActivityMutex_Lock() | ||||||
|  | { | ||||||
|     SDL_LockMutex(Android_ActivityMutex); |     SDL_LockMutex(Android_ActivityMutex); | ||||||
| } | } | ||||||
|  |  | ||||||
| void Android_ActivityMutex_Unlock() { | void Android_ActivityMutex_Unlock() | ||||||
|  | { | ||||||
|     SDL_UnlockMutex(Android_ActivityMutex); |     SDL_UnlockMutex(Android_ActivityMutex); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Lock the Mutex when the Activity is in its 'Running' state */ | /* Lock the Mutex when the Activity is in its 'Running' state */ | ||||||
| void Android_ActivityMutex_Lock_Running() { | void Android_ActivityMutex_Lock_Running() | ||||||
|  | { | ||||||
|     int pauseSignaled = 0; |     int pauseSignaled = 0; | ||||||
|     int resumeSignaled = 0; |     int resumeSignaled = 0; | ||||||
|  |  | ||||||
| @@ -948,7 +943,6 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)( | |||||||
|     Android_OnHat(device_id, hat_id, x, y); |     Android_OnHat(device_id, hat_id, x, y); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)( | JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)( | ||||||
|     JNIEnv *env, jclass jcls, |     JNIEnv *env, jclass jcls, | ||||||
|     jint device_id, jstring device_name, jstring device_desc, |     jint device_id, jstring device_name, jstring device_desc, | ||||||
| @@ -1110,7 +1104,6 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)( | |||||||
|     SDL_StopTextInput(); |     SDL_StopTextInput(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Touch */ | /* Touch */ | ||||||
| JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)( | JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)( | ||||||
|     JNIEnv *env, jclass jcls, |     JNIEnv *env, jclass jcls, | ||||||
| @@ -1169,7 +1162,6 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeLocaleChanged)( | |||||||
|     SDL_SendAppEvent(SDL_LOCALECHANGED); |     SDL_SendAppEvent(SDL_LOCALECHANGED); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Send Quit event to "SDLThread" thread */ | /* Send Quit event to "SDLThread" thread */ | ||||||
| JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)( | JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)( | ||||||
|     JNIEnv *env, jclass cls) |     JNIEnv *env, jclass cls) | ||||||
| @@ -1313,7 +1305,6 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)( | |||||||
|  |  | ||||||
|     (*env)->ReleaseStringUTFChars(env, name, utfname); |     (*env)->ReleaseStringUTFChars(env, name, utfname); | ||||||
|     (*env)->ReleaseStringUTFChars(env, value, utfvalue); |     (*env)->ReleaseStringUTFChars(env, value, utfvalue); | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| /******************************************************************************* | /******************************************************************************* | ||||||
| @@ -1509,8 +1500,7 @@ int Android_JNI_OpenAudioDevice(int iscapture, SDL_AudioSpec *spec) | |||||||
|             jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal); |             jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal); | ||||||
|             (*env)->DeleteLocalRef(env, audioBufferLocal); |             (*env)->DeleteLocalRef(env, audioBufferLocal); | ||||||
|         } |         } | ||||||
|         } |     } break; | ||||||
|         break; |  | ||||||
|     case ENCODING_PCM_16BIT: |     case ENCODING_PCM_16BIT: | ||||||
|     { |     { | ||||||
|         jshortArray audioBufferLocal = (*env)->NewShortArray(env, spec->samples * spec->channels); |         jshortArray audioBufferLocal = (*env)->NewShortArray(env, spec->samples * spec->channels); | ||||||
| @@ -1518,8 +1508,7 @@ int Android_JNI_OpenAudioDevice(int iscapture, SDL_AudioSpec *spec) | |||||||
|             jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal); |             jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal); | ||||||
|             (*env)->DeleteLocalRef(env, audioBufferLocal); |             (*env)->DeleteLocalRef(env, audioBufferLocal); | ||||||
|         } |         } | ||||||
|         } |     } break; | ||||||
|         break; |  | ||||||
|     case ENCODING_PCM_FLOAT: |     case ENCODING_PCM_FLOAT: | ||||||
|     { |     { | ||||||
|         jfloatArray audioBufferLocal = (*env)->NewFloatArray(env, spec->samples * spec->channels); |         jfloatArray audioBufferLocal = (*env)->NewFloatArray(env, spec->samples * spec->channels); | ||||||
| @@ -1527,8 +1516,7 @@ int Android_JNI_OpenAudioDevice(int iscapture, SDL_AudioSpec *spec) | |||||||
|             jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal); |             jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal); | ||||||
|             (*env)->DeleteLocalRef(env, audioBufferLocal); |             (*env)->DeleteLocalRef(env, audioBufferLocal); | ||||||
|         } |         } | ||||||
|         } |     } break; | ||||||
|         break; |  | ||||||
|     default: |     default: | ||||||
|         return SDL_SetError("Unexpected audio format from Java: %d\n", audioformat); |         return SDL_SetError("Unexpected audio format from Java: %d\n", audioformat); | ||||||
|     } |     } | ||||||
| @@ -1586,7 +1574,6 @@ int Android_JNI_GetDisplayDPI(float *ddpi, float *xdpi, float *ydpi) | |||||||
|     float nativeYdpi = (*env)->GetFloatField(env, jDisplayObj, fidYdpi); |     float nativeYdpi = (*env)->GetFloatField(env, jDisplayObj, fidYdpi); | ||||||
|     int nativeDdpi = (*env)->GetIntField(env, jDisplayObj, fidDdpi); |     int nativeDdpi = (*env)->GetIntField(env, jDisplayObj, fidDdpi); | ||||||
|  |  | ||||||
|  |  | ||||||
|     (*env)->DeleteLocalRef(env, jDisplayObj); |     (*env)->DeleteLocalRef(env, jDisplayObj); | ||||||
|     (*env)->DeleteLocalRef(env, jDisplayClass); |     (*env)->DeleteLocalRef(env, jDisplayClass); | ||||||
|  |  | ||||||
| @@ -1795,7 +1782,8 @@ static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent) | |||||||
|     return SDL_FALSE; |     return SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void Internal_Android_Create_AssetManager() { | static void Internal_Android_Create_AssetManager() | ||||||
|  | { | ||||||
|  |  | ||||||
|     struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); |     struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); | ||||||
|     JNIEnv *env = Android_JNI_GetEnv(); |     JNIEnv *env = Android_JNI_GetEnv(); | ||||||
| @@ -1833,7 +1821,8 @@ static void Internal_Android_Create_AssetManager() { | |||||||
|     LocalReferenceHolder_Cleanup(&refs); |     LocalReferenceHolder_Cleanup(&refs); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void Internal_Android_Destroy_AssetManager() { | static void Internal_Android_Destroy_AssetManager() | ||||||
|  | { | ||||||
|     JNIEnv *env = Android_JNI_GetEnv(); |     JNIEnv *env = Android_JNI_GetEnv(); | ||||||
|  |  | ||||||
|     if (asset_manager) { |     if (asset_manager) { | ||||||
| @@ -1861,7 +1850,6 @@ int Android_JNI_FileOpen(SDL_RWops *ctx, | |||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     ctx->hidden.androidio.asset = (void *)asset; |     ctx->hidden.androidio.asset = (void *)asset; | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
| @@ -1970,7 +1958,6 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco | |||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     /* context = SDLActivity.getContext(); */ |     /* context = SDLActivity.getContext(); */ | ||||||
|     context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); |     context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); | ||||||
|  |  | ||||||
| @@ -2069,7 +2056,8 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco | |||||||
| } | } | ||||||
|  |  | ||||||
| /* Add all touch devices */ | /* Add all touch devices */ | ||||||
| void Android_JNI_InitTouch() { | void Android_JNI_InitTouch() | ||||||
|  | { | ||||||
|     JNIEnv *env = Android_JNI_GetEnv(); |     JNIEnv *env = Android_JNI_GetEnv(); | ||||||
|     (*env)->CallStaticVoidMethod(env, mActivityClass, midInitTouch); |     (*env)->CallStaticVoidMethod(env, mActivityClass, midInitTouch); | ||||||
| } | } | ||||||
| @@ -2101,7 +2089,6 @@ void Android_JNI_HapticStop(int device_id) | |||||||
| /* See SDLActivity.java for constants. */ | /* See SDLActivity.java for constants. */ | ||||||
| #define COMMAND_SET_KEEP_SCREEN_ON 5 | #define COMMAND_SET_KEEP_SCREEN_ON 5 | ||||||
|  |  | ||||||
|  |  | ||||||
| int SDL_AndroidSendMessage(Uint32 command, int param) | int SDL_AndroidSendMessage(Uint32 command, int param) | ||||||
| { | { | ||||||
|     if (command >= 0x8000) { |     if (command >= 0x8000) { | ||||||
| @@ -2149,7 +2136,6 @@ SDL_bool Android_JNI_IsScreenKeyboardShown(void) | |||||||
|     return is_shown; |     return is_shown; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) | int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) | ||||||
| { | { | ||||||
|     JNIEnv *env; |     JNIEnv *env; | ||||||
| @@ -2613,8 +2599,7 @@ int Android_JNI_GetLocale(char *buf, size_t buflen) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int Android_JNI_OpenURL(const char *url) | ||||||
| Android_JNI_OpenURL(const char *url) |  | ||||||
| { | { | ||||||
|     JNIEnv *env = Android_JNI_GetEnv(); |     JNIEnv *env = Android_JNI_GetEnv(); | ||||||
|     jstring jurl = (*env)->NewStringUTF(env, url); |     jstring jurl = (*env)->NewStringUTF(env, url); | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| #include <sys/kbio.h> | #include <sys/kbio.h> | ||||||
|  |  | ||||||
|  | /* *INDENT-OFF* */ /* clang-format off */ | ||||||
| /* | /* | ||||||
|  * Automatically generated from /usr/share/vt/keymaps/us.acc.kbd. |  * Automatically generated from /usr/share/vt/keymaps/us.acc.kbd. | ||||||
|  * DO NOT EDIT! |  * DO NOT EDIT! | ||||||
| @@ -163,3 +164,4 @@ static accentmap_t accentmap_default_us_acc = { 11, { | |||||||
|     { 0x00 },  |     { 0x00 },  | ||||||
| } }; | } }; | ||||||
|  |  | ||||||
|  | /* *INDENT-ON* */ /* clang-format on */ | ||||||
|   | |||||||
| @@ -77,8 +77,7 @@ static int kbd_cleanup_atexit_installed = 0; | |||||||
|  |  | ||||||
| static struct sigaction old_sigaction[NSIG]; | static struct sigaction old_sigaction[NSIG]; | ||||||
|  |  | ||||||
| static int fatal_signals[] = | static int fatal_signals[] = { | ||||||
| { |  | ||||||
|     /* Handlers for SIGTERM and SIGINT are installed in SDL_QuitInit. */ |     /* Handlers for SIGTERM and SIGINT are installed in SDL_QuitInit. */ | ||||||
|     SIGHUP, SIGQUIT, SIGILL, SIGABRT, |     SIGHUP, SIGQUIT, SIGILL, SIGABRT, | ||||||
|     SIGFPE, SIGSEGV, SIGPIPE, SIGBUS, |     SIGFPE, SIGSEGV, SIGPIPE, SIGBUS, | ||||||
| @@ -103,8 +102,7 @@ static void kbd_cleanup(void) | |||||||
|     ioctl(kbd->console_fd, CONS_MOUSECTL, &mData); |     ioctl(kbd->console_fd, CONS_MOUSECTL, &mData); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_EVDEV_kbd_reraise_signal(int sig) | ||||||
| SDL_EVDEV_kbd_reraise_signal(int sig) |  | ||||||
| { | { | ||||||
|     raise(sig); |     raise(sig); | ||||||
| } | } | ||||||
| @@ -289,14 +287,14 @@ SDL_EVDEV_kbd_init(void) | |||||||
|                 kbd_register_emerg_cleanup(kbd); |                 kbd_register_emerg_cleanup(kbd); | ||||||
|             } |             } | ||||||
|             SDL_free(devicePath); |             SDL_free(devicePath); | ||||||
|         } else kbd->keyboard_fd = kbd->console_fd; |         } else | ||||||
|  |             kbd->keyboard_fd = kbd->console_fd; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return kbd; |     return kbd; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) | ||||||
| SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) |  | ||||||
| { | { | ||||||
|     struct mouse_info mData; |     struct mouse_info mData; | ||||||
|  |  | ||||||
| @@ -471,8 +469,7 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_ | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int down) | ||||||
| SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int down) |  | ||||||
| { | { | ||||||
|     keymap_t key_map; |     keymap_t key_map; | ||||||
|     struct keyent_t keysym; |     struct keyent_t keysym; | ||||||
|   | |||||||
| @@ -47,8 +47,7 @@ SDL_GDKGetTaskQueue(XTaskQueueHandle * outTaskQueue) | |||||||
|  |  | ||||||
|         hr = XTaskQueueCreate(XTaskQueueDispatchMode::ThreadPool, |         hr = XTaskQueueCreate(XTaskQueueDispatchMode::ThreadPool, | ||||||
|                               XTaskQueueDispatchMode::Manual, |                               XTaskQueueDispatchMode::Manual, | ||||||
|             &GDK_GlobalTaskQueue |                               &GDK_GlobalTaskQueue); | ||||||
|             ); |  | ||||||
|         if (FAILED(hr)) { |         if (FAILED(hr)) { | ||||||
|             return SDL_SetError("[GDK] Could not create global task queue"); |             return SDL_SetError("[GDK] Could not create global task queue"); | ||||||
|         } |         } | ||||||
| @@ -158,8 +157,7 @@ SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved) | |||||||
|             SDL_SetError("[GDK] Unable to create plmSuspendComplete event"); |             SDL_SetError("[GDK] Unable to create plmSuspendComplete event"); | ||||||
|             return -1; |             return -1; | ||||||
|         } |         } | ||||||
|         auto rascn = [](BOOLEAN quiesced, PVOID context) |         auto rascn = [](BOOLEAN quiesced, PVOID context) { | ||||||
|         { |  | ||||||
|             SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppStateChangeNotification handler"); |             SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppStateChangeNotification handler"); | ||||||
|             if (quiesced) { |             if (quiesced) { | ||||||
|                 ResetEvent(plmSuspendComplete); |                 ResetEvent(plmSuspendComplete); | ||||||
| @@ -214,7 +212,8 @@ SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved) | |||||||
| } | } | ||||||
|  |  | ||||||
| extern "C" DECLSPEC void | extern "C" DECLSPEC void | ||||||
| SDL_GDKSuspendComplete() { | SDL_GDKSuspendComplete() | ||||||
|  | { | ||||||
|     if (plmSuspendComplete) { |     if (plmSuspendComplete) { | ||||||
|         SetEvent(plmSuspendComplete); |         SetEvent(plmSuspendComplete); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -34,11 +34,11 @@ static char *inhibit_handle = NULL; | |||||||
| static unsigned int screensaver_cookie = 0; | static unsigned int screensaver_cookie = 0; | ||||||
| static SDL_DBusContext dbus; | static SDL_DBusContext dbus; | ||||||
|  |  | ||||||
| static int | static int LoadDBUSSyms(void) | ||||||
| LoadDBUSSyms(void) |  | ||||||
| { | { | ||||||
| #define SDL_DBUS_SYM2(x, y)                            \ | #define SDL_DBUS_SYM2(x, y)                            \ | ||||||
|         if (!(dbus.x = SDL_LoadFunction(dbus_handle, #y))) return -1 |     if (!(dbus.x = SDL_LoadFunction(dbus_handle, #y))) \ | ||||||
|  |     return -1 | ||||||
|  |  | ||||||
| #define SDL_DBUS_SYM(x) \ | #define SDL_DBUS_SYM(x) \ | ||||||
|     SDL_DBUS_SYM2(x, dbus_##x) |     SDL_DBUS_SYM2(x, dbus_##x) | ||||||
| @@ -89,8 +89,7 @@ LoadDBUSSyms(void) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void UnloadDBUSLibrary(void) | ||||||
| UnloadDBUSLibrary(void) |  | ||||||
| { | { | ||||||
|     if (dbus_handle != NULL) { |     if (dbus_handle != NULL) { | ||||||
|         SDL_UnloadObject(dbus_handle); |         SDL_UnloadObject(dbus_handle); | ||||||
| @@ -98,8 +97,7 @@ UnloadDBUSLibrary(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int LoadDBUSLibrary(void) | ||||||
| LoadDBUSLibrary(void) |  | ||||||
| { | { | ||||||
|     int retval = 0; |     int retval = 0; | ||||||
|     if (dbus_handle == NULL) { |     if (dbus_handle == NULL) { | ||||||
| @@ -118,12 +116,10 @@ LoadDBUSLibrary(void) | |||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| static SDL_SpinLock spinlock_dbus_init = 0; | static SDL_SpinLock spinlock_dbus_init = 0; | ||||||
|  |  | ||||||
| /* you must hold spinlock_dbus_init before calling this! */ | /* you must hold spinlock_dbus_init before calling this! */ | ||||||
| static void | static void SDL_DBus_Init_Spinlocked(void) | ||||||
| SDL_DBus_Init_Spinlocked(void) |  | ||||||
| { | { | ||||||
|     static SDL_bool is_dbus_available = SDL_TRUE; |     static SDL_bool is_dbus_available = SDL_TRUE; | ||||||
|     if (!is_dbus_available) { |     if (!is_dbus_available) { | ||||||
| @@ -135,7 +131,7 @@ SDL_DBus_Init_Spinlocked(void) | |||||||
|  |  | ||||||
|         if (LoadDBUSLibrary() == -1) { |         if (LoadDBUSLibrary() == -1) { | ||||||
|             is_dbus_available = SDL_FALSE; /* can't load at all? Don't keep trying. */ |             is_dbus_available = SDL_FALSE; /* can't load at all? Don't keep trying. */ | ||||||
|             return;  /* oh well */ |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!dbus.threads_init_default()) { |         if (!dbus.threads_init_default()) { | ||||||
| @@ -165,16 +161,14 @@ SDL_DBus_Init_Spinlocked(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_DBus_Init(void) | ||||||
| SDL_DBus_Init(void) |  | ||||||
| { | { | ||||||
|     SDL_AtomicLock(&spinlock_dbus_init); /* make sure two threads can't init at same time, since this can happen before SDL_Init. */ |     SDL_AtomicLock(&spinlock_dbus_init); /* make sure two threads can't init at same time, since this can happen before SDL_Init. */ | ||||||
|     SDL_DBus_Init_Spinlocked(); |     SDL_DBus_Init_Spinlocked(); | ||||||
|     SDL_AtomicUnlock(&spinlock_dbus_init); |     SDL_AtomicUnlock(&spinlock_dbus_init); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_DBus_Quit(void) | ||||||
| SDL_DBus_Quit(void) |  | ||||||
| { | { | ||||||
|     if (dbus.system_conn) { |     if (dbus.system_conn) { | ||||||
|         dbus.connection_close(dbus.system_conn); |         dbus.connection_close(dbus.system_conn); | ||||||
| @@ -208,8 +202,7 @@ SDL_DBus_GetContext(void) | |||||||
|     return (dbus_handle && dbus.session_conn) ? &dbus : NULL; |     return (dbus_handle && dbus.session_conn) ? &dbus : NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap) | ||||||
| SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap) |  | ||||||
| { | { | ||||||
|     SDL_bool retval = SDL_FALSE; |     SDL_bool retval = SDL_FALSE; | ||||||
|  |  | ||||||
| @@ -226,9 +219,15 @@ SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char * | |||||||
|                     /* skip any input args, get to output args. */ |                     /* skip any input args, get to output args. */ | ||||||
|                     while ((firstarg = va_arg(ap_reply, int)) != DBUS_TYPE_INVALID) { |                     while ((firstarg = va_arg(ap_reply, int)) != DBUS_TYPE_INVALID) { | ||||||
|                         /* we assume D-Bus already validated all this. */ |                         /* we assume D-Bus already validated all this. */ | ||||||
|                         { void *dumpptr = va_arg(ap_reply, void*); (void) dumpptr; } |                         { | ||||||
|  |                             void *dumpptr = va_arg(ap_reply, void *); | ||||||
|  |                             (void)dumpptr; | ||||||
|  |                         } | ||||||
|                         if (firstarg == DBUS_TYPE_ARRAY) { |                         if (firstarg == DBUS_TYPE_ARRAY) { | ||||||
|                             { const int dumpint = va_arg(ap_reply, int); (void) dumpint; } |                             { | ||||||
|  |                                 const int dumpint = va_arg(ap_reply, int); | ||||||
|  |                                 (void)dumpint; | ||||||
|  |                             } | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                     firstarg = va_arg(ap_reply, int); |                     firstarg = va_arg(ap_reply, int); | ||||||
| @@ -268,8 +267,7 @@ SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, c | |||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap) | ||||||
| SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap) |  | ||||||
| { | { | ||||||
|     SDL_bool retval = SDL_FALSE; |     SDL_bool retval = SDL_FALSE; | ||||||
|  |  | ||||||
| @@ -291,8 +289,7 @@ SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *node, const ch | |||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *msg, const int expectedtype, void *result) | ||||||
| SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *msg, const int expectedtype, void *result) |  | ||||||
| { | { | ||||||
|     SDL_bool retval = SDL_FALSE; |     SDL_bool retval = SDL_FALSE; | ||||||
|  |  | ||||||
| @@ -363,9 +360,7 @@ SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface | |||||||
|     return SDL_DBus_QueryPropertyOnConnection(dbus.session_conn, node, path, interface, property, expectedtype, result); |     return SDL_DBus_QueryPropertyOnConnection(dbus.session_conn, node, path, interface, property, expectedtype, result); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void SDL_DBus_ScreensaverTickle(void) | ||||||
| void |  | ||||||
| SDL_DBus_ScreensaverTickle(void) |  | ||||||
| { | { | ||||||
|     if (screensaver_cookie == 0 && inhibit_handle == NULL) { /* no need to tickle if we're inhibiting. */ |     if (screensaver_cookie == 0 && inhibit_handle == NULL) { /* no need to tickle if we're inhibiting. */ | ||||||
|         /* org.gnome.ScreenSaver is the legacy interface, but it'll either do nothing or just be a second harmless tickle on newer systems, so we leave it for now. */ |         /* org.gnome.ScreenSaver is the legacy interface, but it'll either do nothing or just be a second harmless tickle on newer systems, so we leave it for now. */ | ||||||
| @@ -374,8 +369,7 @@ SDL_DBus_ScreensaverTickle(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool SDL_DBus_AppendDictWithKeyValue(DBusMessageIter *iterInit, const char *key, const char *value) | ||||||
| SDL_DBus_AppendDictWithKeyValue(DBusMessageIter *iterInit, const char *key, const char *value) |  | ||||||
| { | { | ||||||
|     DBusMessageIter iterDict, iterEntry, iterValue; |     DBusMessageIter iterDict, iterEntry, iterValue; | ||||||
|  |  | ||||||
| @@ -399,9 +393,7 @@ SDL_DBus_AppendDictWithKeyValue(DBusMessageIter *iterInit, const char *key, cons | |||||||
|         goto failed; |         goto failed; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (!dbus.message_iter_close_container(&iterEntry, &iterValue) |     if (!dbus.message_iter_close_container(&iterEntry, &iterValue) || !dbus.message_iter_close_container(&iterDict, &iterEntry) || !dbus.message_iter_close_container(iterInit, &iterDict)) { | ||||||
|         || !dbus.message_iter_close_container(&iterDict, &iterEntry) |  | ||||||
|         || !dbus.message_iter_close_container(iterInit, &iterDict)) { |  | ||||||
|         goto failed; |         goto failed; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -419,8 +411,7 @@ SDL_DBus_ScreensaverInhibit(SDL_bool inhibit) | |||||||
| { | { | ||||||
|     const char *default_inhibit_reason = "Playing a game"; |     const char *default_inhibit_reason = "Playing a game"; | ||||||
|  |  | ||||||
|     if ( (inhibit && (screensaver_cookie != 0 || inhibit_handle != NULL)) |     if ((inhibit && (screensaver_cookie != 0 || inhibit_handle != NULL)) || (!inhibit && (screensaver_cookie == 0 && inhibit_handle == NULL))) { | ||||||
|         || (!inhibit && (screensaver_cookie == 0 && inhibit_handle == NULL)) ) { |  | ||||||
|         return SDL_TRUE; |         return SDL_TRUE; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -29,8 +29,8 @@ | |||||||
| #include "SDL_stdinc.h" | #include "SDL_stdinc.h" | ||||||
| #include <dbus/dbus.h> | #include <dbus/dbus.h> | ||||||
|  |  | ||||||
|  | typedef struct SDL_DBusContext | ||||||
| typedef struct SDL_DBusContext { | { | ||||||
|     DBusConnection *session_conn; |     DBusConnection *session_conn; | ||||||
|     DBusConnection *system_conn; |     DBusConnection *system_conn; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -74,7 +74,8 @@ typedef struct SDL_evdevlist_item | |||||||
|        keyboard, touchpad, etc.). Also there's probably some things in here we |        keyboard, touchpad, etc.). Also there's probably some things in here we | ||||||
|        can pull out to the SDL_evdevlist_item i.e. name */ |        can pull out to the SDL_evdevlist_item i.e. name */ | ||||||
|     SDL_bool is_touchscreen; |     SDL_bool is_touchscreen; | ||||||
|     struct { |     struct | ||||||
|  |     { | ||||||
|         char *name; |         char *name; | ||||||
|  |  | ||||||
|         int min_x, max_x, range_x; |         int min_x, max_x, range_x; | ||||||
| @@ -83,8 +84,10 @@ typedef struct SDL_evdevlist_item | |||||||
|  |  | ||||||
|         int max_slots; |         int max_slots; | ||||||
|         int current_slot; |         int current_slot; | ||||||
|         struct { |         struct | ||||||
|             enum { |         { | ||||||
|  |             enum | ||||||
|  |             { | ||||||
|                 EVDEV_TOUCH_SLOTDELTA_NONE = 0, |                 EVDEV_TOUCH_SLOTDELTA_NONE = 0, | ||||||
|                 EVDEV_TOUCH_SLOTDELTA_DOWN, |                 EVDEV_TOUCH_SLOTDELTA_DOWN, | ||||||
|                 EVDEV_TOUCH_SLOTDELTA_UP, |                 EVDEV_TOUCH_SLOTDELTA_UP, | ||||||
| @@ -140,16 +143,13 @@ static Uint8 EVDEV_MouseButtons[] = { | |||||||
|     SDL_BUTTON_X2 + 3  /*  BTN_TASK        0x117 */ |     SDL_BUTTON_X2 + 3  /*  BTN_TASK        0x117 */ | ||||||
| }; | }; | ||||||
|  |  | ||||||
| static int | static int SDL_EVDEV_SetRelativeMouseMode(SDL_bool enabled) | ||||||
| SDL_EVDEV_SetRelativeMouseMode(SDL_bool enabled) |  | ||||||
| { | { | ||||||
|     /* Mice already send relative events through this interface */ |     /* Mice already send relative events through this interface */ | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | int SDL_EVDEV_Init(void) | ||||||
| int |  | ||||||
| SDL_EVDEV_Init(void) |  | ||||||
| { | { | ||||||
|     if (_this == NULL) { |     if (_this == NULL) { | ||||||
|         _this = (SDL_EVDEV_PrivateData *)SDL_calloc(1, sizeof(*_this)); |         _this = (SDL_EVDEV_PrivateData *)SDL_calloc(1, sizeof(*_this)); | ||||||
| @@ -211,8 +211,7 @@ SDL_EVDEV_Init(void) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_EVDEV_Quit(void) | ||||||
| SDL_EVDEV_Quit(void) |  | ||||||
| { | { | ||||||
|     if (_this == NULL) { |     if (_this == NULL) { | ||||||
|         return; |         return; | ||||||
| @@ -271,8 +270,7 @@ static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_cl | |||||||
| } | } | ||||||
| #endif /* SDL_USE_LIBUDEV */ | #endif /* SDL_USE_LIBUDEV */ | ||||||
|  |  | ||||||
| void  | void SDL_EVDEV_Poll(void) | ||||||
| SDL_EVDEV_Poll(void) |  | ||||||
| { | { | ||||||
|     struct input_event events[32]; |     struct input_event events[32]; | ||||||
|     int i, j, len; |     int i, j, len; | ||||||
| @@ -522,8 +520,7 @@ SDL_EVDEV_Poll(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_Scancode | static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode) | ||||||
| SDL_EVDEV_translate_keycode(int keycode) |  | ||||||
| { | { | ||||||
|     SDL_Scancode scancode = SDL_GetScancodeFromTable(SDL_SCANCODE_TABLE_LINUX, keycode); |     SDL_Scancode scancode = SDL_GetScancodeFromTable(SDL_SCANCODE_TABLE_LINUX, keycode); | ||||||
|  |  | ||||||
| @@ -536,7 +533,8 @@ SDL_EVDEV_translate_keycode(int keycode) | |||||||
|         if (keycode != BTN_TOUCH) { |         if (keycode != BTN_TOUCH) { | ||||||
|             SDL_Log("The key you just pressed is not recognized by SDL. To help " |             SDL_Log("The key you just pressed is not recognized by SDL. To help " | ||||||
|                     "get this fixed, please report this to the SDL forums/mailing list " |                     "get this fixed, please report this to the SDL forums/mailing list " | ||||||
|                 "<https://discourse.libsdl.org/> EVDEV KeyCode %d", keycode); |                     "<https://discourse.libsdl.org/> EVDEV KeyCode %d", | ||||||
|  |                     keycode); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| #endif /* DEBUG_SCANCODES */ | #endif /* DEBUG_SCANCODES */ | ||||||
| @@ -544,8 +542,7 @@ SDL_EVDEV_translate_keycode(int keycode) | |||||||
|     return scancode; |     return scancode; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class) | ||||||
| SDL_EVDEV_init_touchscreen(SDL_evdevlist_item* item, int udev_class) |  | ||||||
| { | { | ||||||
|     int ret, i; |     int ret, i; | ||||||
|     unsigned long xreq, yreq; |     unsigned long xreq, yreq; | ||||||
| @@ -646,8 +643,8 @@ SDL_EVDEV_init_touchscreen(SDL_evdevlist_item* item, int udev_class) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_EVDEV_destroy_touchscreen(SDL_evdevlist_item *item) | ||||||
| SDL_EVDEV_destroy_touchscreen(SDL_evdevlist_item* item) { | { | ||||||
|     if (!item->is_touchscreen) { |     if (!item->is_touchscreen) { | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| @@ -658,8 +655,7 @@ SDL_EVDEV_destroy_touchscreen(SDL_evdevlist_item* item) { | |||||||
|     SDL_free(item->touchscreen_data); |     SDL_free(item->touchscreen_data); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item) | ||||||
| SDL_EVDEV_sync_device(SDL_evdevlist_item *item)  |  | ||||||
| { | { | ||||||
| #ifdef EVIOCGMTSLOTS | #ifdef EVIOCGMTSLOTS | ||||||
|     int i, ret; |     int i, ret; | ||||||
| @@ -784,8 +780,7 @@ SDL_EVDEV_sync_device(SDL_evdevlist_item *item) | |||||||
| #endif /* EVIOCGMTSLOTS */ | #endif /* EVIOCGMTSLOTS */ | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_EVDEV_device_added(const char *dev_path, int udev_class) | ||||||
| SDL_EVDEV_device_added(const char *dev_path, int udev_class) |  | ||||||
| { | { | ||||||
|     int ret; |     int ret; | ||||||
|     SDL_evdevlist_item *item; |     SDL_evdevlist_item *item; | ||||||
| @@ -846,8 +841,7 @@ SDL_EVDEV_device_added(const char *dev_path, int udev_class) | |||||||
|     return _this->num_devices++; |     return _this->num_devices++; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_EVDEV_device_removed(const char *dev_path) | ||||||
| SDL_EVDEV_device_removed(const char *dev_path) |  | ||||||
| { | { | ||||||
|     SDL_evdevlist_item *item; |     SDL_evdevlist_item *item; | ||||||
|     SDL_evdevlist_item *prev = NULL; |     SDL_evdevlist_item *prev = NULL; | ||||||
| @@ -879,7 +873,6 @@ SDL_EVDEV_device_removed(const char *dev_path) | |||||||
|     return -1; |     return -1; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| #endif /* SDL_INPUT_LINUXEV */ | #endif /* SDL_INPUT_LINUXEV */ | ||||||
|  |  | ||||||
| /* vi: set ts=4 sw=4 expandtab: */ | /* vi: set ts=4 sw=4 expandtab: */ | ||||||
|   | |||||||
| @@ -23,7 +23,6 @@ | |||||||
|  |  | ||||||
| #include "SDL_evdev_capabilities.h" | #include "SDL_evdev_capabilities.h" | ||||||
|  |  | ||||||
|  |  | ||||||
| #if HAVE_LINUX_INPUT_H | #if HAVE_LINUX_INPUT_H | ||||||
|  |  | ||||||
| /* missing defines in older Linux kernel headers */ | /* missing defines in older Linux kernel headers */ | ||||||
| @@ -43,7 +42,8 @@ SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)], | |||||||
|                            unsigned long bitmask_key[NBITS(KEY_MAX)], |                            unsigned long bitmask_key[NBITS(KEY_MAX)], | ||||||
|                            unsigned long bitmask_rel[NBITS(REL_MAX)]) |                            unsigned long bitmask_rel[NBITS(REL_MAX)]) | ||||||
| { | { | ||||||
|     struct range { |     struct range | ||||||
|  |     { | ||||||
|         unsigned start; |         unsigned start; | ||||||
|         unsigned end; |         unsigned end; | ||||||
|     }; |     }; | ||||||
|   | |||||||
| @@ -70,8 +70,7 @@ static void fn_caps_on(SDL_EVDEV_keyboard_state *kbd); | |||||||
| static void fn_num(SDL_EVDEV_keyboard_state *kbd); | static void fn_num(SDL_EVDEV_keyboard_state *kbd); | ||||||
| static void fn_compose(SDL_EVDEV_keyboard_state *kbd); | static void fn_compose(SDL_EVDEV_keyboard_state *kbd); | ||||||
|  |  | ||||||
| static fn_handler_fn *fn_handler[] = | static fn_handler_fn *fn_handler[] = { | ||||||
| { |  | ||||||
|     NULL, fn_enter, NULL, NULL, |     NULL, fn_enter, NULL, NULL, | ||||||
|     NULL, NULL, NULL, fn_caps_toggle, |     NULL, NULL, NULL, fn_caps_toggle, | ||||||
|     fn_num, NULL, NULL, NULL, |     fn_num, NULL, NULL, NULL, | ||||||
| @@ -79,7 +78,6 @@ static fn_handler_fn *fn_handler[] = | |||||||
|     NULL, NULL, NULL, fn_num |     NULL, NULL, NULL, fn_num | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Keyboard State |  * Keyboard State | ||||||
|  */ |  */ | ||||||
| @@ -200,8 +198,7 @@ static int kbd_cleanup_atexit_installed = 0; | |||||||
|  |  | ||||||
| static struct sigaction old_sigaction[NSIG]; | static struct sigaction old_sigaction[NSIG]; | ||||||
|  |  | ||||||
| static int fatal_signals[] = | static int fatal_signals[] = { | ||||||
| { |  | ||||||
|     /* Handlers for SIGTERM and SIGINT are installed in SDL_QuitInit. */ |     /* Handlers for SIGTERM and SIGINT are installed in SDL_QuitInit. */ | ||||||
|     SIGHUP, SIGQUIT, SIGILL, SIGABRT, |     SIGHUP, SIGQUIT, SIGILL, SIGABRT, | ||||||
|     SIGFPE, SIGSEGV, SIGPIPE, SIGBUS, |     SIGFPE, SIGSEGV, SIGPIPE, SIGBUS, | ||||||
| @@ -219,8 +216,7 @@ static void kbd_cleanup(void) | |||||||
|     ioctl(kbd->console_fd, KDSKBMODE, kbd->old_kbd_mode); |     ioctl(kbd->console_fd, KDSKBMODE, kbd->old_kbd_mode); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_EVDEV_kbd_reraise_signal(int sig) | ||||||
| SDL_EVDEV_kbd_reraise_signal(int sig) |  | ||||||
| { | { | ||||||
|     raise(sig); |     raise(sig); | ||||||
| } | } | ||||||
| @@ -411,8 +407,7 @@ SDL_EVDEV_kbd_init(void) | |||||||
|     return kbd; |     return kbd; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) | ||||||
| SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) |  | ||||||
| { | { | ||||||
|     if (kbd == NULL) { |     if (kbd == NULL) { | ||||||
|         return; |         return; | ||||||
| @@ -768,8 +763,7 @@ static void k_brl(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_fl | |||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int down) | ||||||
| SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int down) |  | ||||||
| { | { | ||||||
|     unsigned char shift_final; |     unsigned char shift_final; | ||||||
|     unsigned char type; |     unsigned char type; | ||||||
| @@ -841,13 +835,11 @@ SDL_EVDEV_kbd_init(void) | |||||||
|     return NULL; |     return NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down) | ||||||
| SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down) |  | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state) | ||||||
| SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state) |  | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,6 +19,8 @@ | |||||||
|   3. This notice may not be removed or altered from any source distribution. |   3. This notice may not be removed or altered from any source distribution. | ||||||
| */ | */ | ||||||
|  |  | ||||||
|  | /* *INDENT-OFF* */ /* clang-format off */ | ||||||
|  |  | ||||||
| static unsigned short default_key_map_0[NR_KEYS] = { | static unsigned short default_key_map_0[NR_KEYS] = { | ||||||
|     0xf200, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036,  |     0xf200, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036,  | ||||||
|     0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009,  |     0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009,  | ||||||
| @@ -4374,6 +4376,8 @@ static unsigned short default_key_map_127[NR_KEYS] = { | |||||||
| }; | }; | ||||||
| #endif /* INCLUDE_EXTENDED_KEYMAP */ | #endif /* INCLUDE_EXTENDED_KEYMAP */ | ||||||
|  |  | ||||||
|  | /* *INDENT-ON* */ /* clang-format on */ | ||||||
|  |  | ||||||
| static unsigned short *default_key_maps[MAX_NR_KEYMAPS] = { | static unsigned short *default_key_maps[MAX_NR_KEYMAPS] = { | ||||||
|     default_key_map_0, |     default_key_map_0, | ||||||
|     default_key_map_1, |     default_key_map_1, | ||||||
|   | |||||||
| @@ -55,8 +55,7 @@ typedef struct _FcitxClient | |||||||
|  |  | ||||||
| static FcitxClient fcitx_client; | static FcitxClient fcitx_client; | ||||||
|  |  | ||||||
| static char* | static char *GetAppName() | ||||||
| GetAppName() |  | ||||||
| { | { | ||||||
| #if defined(__LINUX__) || defined(__FREEBSD__) | #if defined(__LINUX__) || defined(__FREEBSD__) | ||||||
|     char *spot; |     char *spot; | ||||||
| @@ -167,8 +166,7 @@ Fcitx_GetPreeditString(SDL_DBusContext *dbus, | |||||||
|     return text_bytes; |     return text_bytes; | ||||||
| } | } | ||||||
|  |  | ||||||
| static Sint32 | static Sint32 Fcitx_GetPreeditCursorByte(SDL_DBusContext *dbus, DBusMessage *msg) | ||||||
| Fcitx_GetPreeditCursorByte(SDL_DBusContext *dbus, DBusMessage *msg) |  | ||||||
| { | { | ||||||
|     Sint32 byte = -1; |     Sint32 byte = -1; | ||||||
|     DBusMessageIter iter; |     DBusMessageIter iter; | ||||||
| @@ -186,8 +184,7 @@ Fcitx_GetPreeditCursorByte(SDL_DBusContext *dbus, DBusMessage *msg) | |||||||
|     return byte; |     return byte; | ||||||
| } | } | ||||||
|  |  | ||||||
| static DBusHandlerResult | static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data) | ||||||
| DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data) |  | ||||||
| { | { | ||||||
|     SDL_DBusContext *dbus = (SDL_DBusContext *)data; |     SDL_DBusContext *dbus = (SDL_DBusContext *)data; | ||||||
|  |  | ||||||
| @@ -250,8 +247,7 @@ DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data) | |||||||
|     return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |     return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void FcitxClientICCallMethod(FcitxClient *client, const char *method) | ||||||
| FcitxClientICCallMethod(FcitxClient *client, const char *method) |  | ||||||
| { | { | ||||||
|     if (!client->ic_path) { |     if (!client->ic_path) { | ||||||
|         return; |         return; | ||||||
| @@ -259,8 +255,7 @@ FcitxClientICCallMethod(FcitxClient *client, const char *method) | |||||||
|     SDL_DBus_CallVoidMethod(FCITX_DBUS_SERVICE, client->ic_path, FCITX_IC_DBUS_INTERFACE, method, DBUS_TYPE_INVALID); |     SDL_DBus_CallVoidMethod(FCITX_DBUS_SERVICE, client->ic_path, FCITX_IC_DBUS_INTERFACE, method, DBUS_TYPE_INVALID); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL Fcitx_SetCapabilities(void *data, | ||||||
| Fcitx_SetCapabilities(void *data, |  | ||||||
|                                           const char *name, |                                           const char *name, | ||||||
|                                           const char *old_val, |                                           const char *old_val, | ||||||
|                                           const char *internal_editing) |                                           const char *internal_editing) | ||||||
| @@ -279,8 +274,8 @@ Fcitx_SetCapabilities(void *data, | |||||||
|     SDL_DBus_CallVoidMethod(FCITX_DBUS_SERVICE, client->ic_path, FCITX_IC_DBUS_INTERFACE, "SetCapability", DBUS_TYPE_UINT64, &caps, DBUS_TYPE_INVALID); |     SDL_DBus_CallVoidMethod(FCITX_DBUS_SERVICE, client->ic_path, FCITX_IC_DBUS_INTERFACE, "SetCapability", DBUS_TYPE_UINT64, &caps, DBUS_TYPE_INVALID); | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appname, char **ic_path) | ||||||
| FcitxCreateInputContext(SDL_DBusContext* dbus, const char *appname, char **ic_path) { | { | ||||||
|     const char *program = "program"; |     const char *program = "program"; | ||||||
|     SDL_bool retval = SDL_FALSE; |     SDL_bool retval = SDL_FALSE; | ||||||
|     if (dbus->session_conn) { |     if (dbus->session_conn) { | ||||||
| @@ -308,8 +303,7 @@ FcitxCreateInputContext(SDL_DBusContext* dbus, const char *appname, char **ic_pa | |||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool FcitxClientCreateIC(FcitxClient *client) | ||||||
| FcitxClientCreateIC(FcitxClient *client) |  | ||||||
| { | { | ||||||
|     char *appname = GetAppName(); |     char *appname = GetAppName(); | ||||||
|     char *ic_path = NULL; |     char *ic_path = NULL; | ||||||
| @@ -341,8 +335,7 @@ FcitxClientCreateIC(FcitxClient *client) | |||||||
|     return SDL_FALSE; |     return SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
| static Uint32 | static Uint32 Fcitx_ModState(void) | ||||||
| Fcitx_ModState(void) |  | ||||||
| { | { | ||||||
|     Uint32 fcitx_mods = 0; |     Uint32 fcitx_mods = 0; | ||||||
|     SDL_Keymod sdl_mods = SDL_GetModState(); |     SDL_Keymod sdl_mods = SDL_GetModState(); | ||||||
| @@ -388,8 +381,7 @@ SDL_Fcitx_Init() | |||||||
|     return FcitxClientCreateIC(&fcitx_client); |     return FcitxClientCreateIC(&fcitx_client); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_Fcitx_Quit() | ||||||
| SDL_Fcitx_Quit() |  | ||||||
| { | { | ||||||
|     FcitxClientICCallMethod(&fcitx_client, "DestroyIC"); |     FcitxClientICCallMethod(&fcitx_client, "DestroyIC"); | ||||||
|     if (fcitx_client.ic_path) { |     if (fcitx_client.ic_path) { | ||||||
| @@ -398,8 +390,7 @@ SDL_Fcitx_Quit() | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_Fcitx_SetFocus(SDL_bool focused) | ||||||
| SDL_Fcitx_SetFocus(SDL_bool focused) |  | ||||||
| { | { | ||||||
|     if (focused) { |     if (focused) { | ||||||
|         FcitxClientICCallMethod(&fcitx_client, "FocusIn"); |         FcitxClientICCallMethod(&fcitx_client, "FocusIn"); | ||||||
| @@ -408,8 +399,7 @@ SDL_Fcitx_SetFocus(SDL_bool focused) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_Fcitx_Reset(void) | ||||||
| SDL_Fcitx_Reset(void) |  | ||||||
| { | { | ||||||
|     FcitxClientICCallMethod(&fcitx_client, "Reset"); |     FcitxClientICCallMethod(&fcitx_client, "Reset"); | ||||||
|     FcitxClientICCallMethod(&fcitx_client, "CloseIC"); |     FcitxClientICCallMethod(&fcitx_client, "CloseIC"); | ||||||
| @@ -439,8 +429,7 @@ SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state) | |||||||
|     return SDL_FALSE; |     return SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect) | ||||||
| SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect) |  | ||||||
| { | { | ||||||
|     SDL_Window *focused_win = NULL; |     SDL_Window *focused_win = NULL; | ||||||
|     SDL_SysWMinfo info; |     SDL_SysWMinfo info; | ||||||
| @@ -490,8 +479,7 @@ SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect) | |||||||
|                             DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, DBUS_TYPE_INT32, &cursor->w, DBUS_TYPE_INT32, &cursor->h, DBUS_TYPE_INVALID); |                             DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, DBUS_TYPE_INT32, &cursor->w, DBUS_TYPE_INT32, &cursor->h, DBUS_TYPE_INVALID); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_Fcitx_PumpEvents(void) | ||||||
| SDL_Fcitx_PumpEvents(void) |  | ||||||
| { | { | ||||||
|     SDL_DBusContext *dbus = fcitx_client.dbus; |     SDL_DBusContext *dbus = fcitx_client.dbus; | ||||||
|     DBusConnection *conn = dbus->session_conn; |     DBusConnection *conn = dbus->session_conn; | ||||||
|   | |||||||
| @@ -57,9 +57,7 @@ static SDL_bool ibus_is_portal_interface = SDL_FALSE; | |||||||
| static char *ibus_addr_file = NULL; | static char *ibus_addr_file = NULL; | ||||||
| static int inotify_fd = -1, inotify_wd = -1; | static int inotify_fd = -1, inotify_wd = -1; | ||||||
|  |  | ||||||
|  | static Uint32 IBus_ModState(void) | ||||||
| static Uint32 |  | ||||||
| IBus_ModState(void) |  | ||||||
| { | { | ||||||
|     Uint32 ibus_mods = 0; |     Uint32 ibus_mods = 0; | ||||||
|     SDL_Keymod sdl_mods = SDL_GetModState(); |     SDL_Keymod sdl_mods = SDL_GetModState(); | ||||||
| @@ -93,8 +91,7 @@ IBus_ModState(void) | |||||||
|     return ibus_mods; |     return ibus_mods; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus, | ||||||
| IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus, |  | ||||||
|                                   DBusMessageIter *inside, const char *struct_id, size_t id_size) |                                   DBusMessageIter *inside, const char *struct_id, size_t id_size) | ||||||
| { | { | ||||||
|     DBusMessageIter sub; |     DBusMessageIter sub; | ||||||
| @@ -121,8 +118,7 @@ IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext * | |||||||
|     return SDL_TRUE; |     return SDL_TRUE; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus, | ||||||
| IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus, |  | ||||||
|                                            Uint32 *start_pos, Uint32 *end_pos) |                                            Uint32 *start_pos, Uint32 *end_pos) | ||||||
| { | { | ||||||
|     DBusMessageIter sub1, sub2, array; |     DBusMessageIter sub1, sub2, array; | ||||||
| @@ -186,8 +182,7 @@ IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter *iter, SDL_DBus | |||||||
|     return SDL_FALSE; |     return SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
| static const char * | static const char *IBus_GetVariantText(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus) | ||||||
| IBus_GetVariantText(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus) |  | ||||||
| { | { | ||||||
|     /* The text we need is nested weirdly, use dbus-monitor to see the structure better */ |     /* The text we need is nested weirdly, use dbus-monitor to see the structure better */ | ||||||
|     const char *text = NULL; |     const char *text = NULL; | ||||||
| @@ -208,8 +203,7 @@ IBus_GetVariantText(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext | |||||||
|     return text; |     return text; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool IBus_GetVariantCursorPos(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus, | ||||||
| IBus_GetVariantCursorPos(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus, |  | ||||||
|                                          Uint32 *pos) |                                          Uint32 *pos) | ||||||
| { | { | ||||||
|     dbus->message_iter_next(iter); |     dbus->message_iter_next(iter); | ||||||
| @@ -223,8 +217,7 @@ IBus_GetVariantCursorPos(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusCo | |||||||
|     return SDL_TRUE; |     return SDL_TRUE; | ||||||
| } | } | ||||||
|  |  | ||||||
| static DBusHandlerResult | static DBusHandlerResult IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data) | ||||||
| IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data) |  | ||||||
| { | { | ||||||
|     SDL_DBusContext *dbus = (SDL_DBusContext *)user_data; |     SDL_DBusContext *dbus = (SDL_DBusContext *)user_data; | ||||||
|  |  | ||||||
| @@ -306,8 +299,7 @@ IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data) | |||||||
|     return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |     return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | ||||||
| } | } | ||||||
|  |  | ||||||
| static char * | static char *IBus_ReadAddressFromFile(const char *file_path) | ||||||
| IBus_ReadAddressFromFile(const char *file_path) |  | ||||||
| { | { | ||||||
|     char addr_buf[1024]; |     char addr_buf[1024]; | ||||||
|     SDL_bool success = SDL_FALSE; |     SDL_bool success = SDL_FALSE; | ||||||
| @@ -341,8 +333,7 @@ IBus_ReadAddressFromFile(const char *file_path) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static char * | static char *IBus_GetDBusAddressFilename(void) | ||||||
| IBus_GetDBusAddressFilename(void) |  | ||||||
| { | { | ||||||
|     SDL_DBusContext *dbus; |     SDL_DBusContext *dbus; | ||||||
|     const char *disp_env; |     const char *disp_env; | ||||||
| @@ -432,8 +423,7 @@ IBus_GetDBusAddressFilename(void) | |||||||
|  |  | ||||||
| static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus); | static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus); | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL IBus_SetCapabilities(void *data, const char *name, const char *old_val, | ||||||
| IBus_SetCapabilities(void *data, const char *name, const char *old_val, |  | ||||||
|                                          const char *internal_editing) |                                          const char *internal_editing) | ||||||
| { | { | ||||||
|     SDL_DBusContext *dbus = SDL_DBus_GetContext(); |     SDL_DBusContext *dbus = SDL_DBus_GetContext(); | ||||||
| @@ -449,9 +439,7 @@ IBus_SetCapabilities(void *data, const char *name, const char *old_val, | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr) | ||||||
| static SDL_bool |  | ||||||
| IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr) |  | ||||||
| { | { | ||||||
|     const char *client_name = "SDL2_Application"; |     const char *client_name = "SDL2_Application"; | ||||||
|     const char *path = NULL; |     const char *path = NULL; | ||||||
| @@ -515,8 +503,7 @@ IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr) | |||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus) | ||||||
| IBus_CheckConnection(SDL_DBusContext *dbus) |  | ||||||
| { | { | ||||||
|     if (dbus == NULL) { |     if (dbus == NULL) { | ||||||
|         return SDL_FALSE; |         return SDL_FALSE; | ||||||
| @@ -621,8 +608,7 @@ SDL_IBus_Init(void) | |||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_IBus_Quit(void) | ||||||
| SDL_IBus_Quit(void) |  | ||||||
| { | { | ||||||
|     SDL_DBusContext *dbus; |     SDL_DBusContext *dbus; | ||||||
|  |  | ||||||
| @@ -662,8 +648,7 @@ SDL_IBus_Quit(void) | |||||||
|     SDL_memset(&ibus_cursor_rect, 0, sizeof(ibus_cursor_rect)); |     SDL_memset(&ibus_cursor_rect, 0, sizeof(ibus_cursor_rect)); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void IBus_SimpleMessage(const char *method) | ||||||
| IBus_SimpleMessage(const char *method) |  | ||||||
| { | { | ||||||
|     SDL_DBusContext *dbus = SDL_DBus_GetContext(); |     SDL_DBusContext *dbus = SDL_DBus_GetContext(); | ||||||
|  |  | ||||||
| @@ -672,15 +657,13 @@ IBus_SimpleMessage(const char *method) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_IBus_SetFocus(SDL_bool focused) | ||||||
| SDL_IBus_SetFocus(SDL_bool focused) |  | ||||||
| { | { | ||||||
|     const char *method = focused ? "FocusIn" : "FocusOut"; |     const char *method = focused ? "FocusIn" : "FocusOut"; | ||||||
|     IBus_SimpleMessage(method); |     IBus_SimpleMessage(method); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_IBus_Reset(void) | ||||||
| SDL_IBus_Reset(void) |  | ||||||
| { | { | ||||||
|     IBus_SimpleMessage("Reset"); |     IBus_SimpleMessage("Reset"); | ||||||
| } | } | ||||||
| @@ -691,7 +674,6 @@ SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state) | |||||||
|     Uint32 result = 0; |     Uint32 result = 0; | ||||||
|     SDL_DBusContext *dbus = SDL_DBus_GetContext(); |     SDL_DBusContext *dbus = SDL_DBus_GetContext(); | ||||||
|  |  | ||||||
|  |  | ||||||
|     if (IBus_CheckConnection(dbus)) { |     if (IBus_CheckConnection(dbus)) { | ||||||
|         Uint32 mods = IBus_ModState(); |         Uint32 mods = IBus_ModState(); | ||||||
|         Uint32 ibus_keycode = keycode - 8; |         Uint32 ibus_keycode = keycode - 8; | ||||||
| @@ -710,8 +692,7 @@ SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state) | |||||||
|     return result ? SDL_TRUE : SDL_FALSE; |     return result ? SDL_TRUE : SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_IBus_UpdateTextRect(const SDL_Rect *rect) | ||||||
| SDL_IBus_UpdateTextRect(const SDL_Rect *rect) |  | ||||||
| { | { | ||||||
|     SDL_Window *focused_win; |     SDL_Window *focused_win; | ||||||
|     SDL_SysWMinfo info; |     SDL_SysWMinfo info; | ||||||
| @@ -758,8 +739,7 @@ SDL_IBus_UpdateTextRect(const SDL_Rect *rect) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_IBus_PumpEvents(void) | ||||||
| SDL_IBus_PumpEvents(void) |  | ||||||
| { | { | ||||||
|     SDL_DBusContext *dbus = SDL_DBus_GetContext(); |     SDL_DBusContext *dbus = SDL_DBus_GetContext(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -40,8 +40,7 @@ static _SDL_IME_ProcessKeyEvent SDL_IME_ProcessKeyEvent_Real = NULL; | |||||||
| static _SDL_IME_UpdateTextRect SDL_IME_UpdateTextRect_Real = NULL; | static _SDL_IME_UpdateTextRect SDL_IME_UpdateTextRect_Real = NULL; | ||||||
| static _SDL_IME_PumpEvents SDL_IME_PumpEvents_Real = NULL; | static _SDL_IME_PumpEvents SDL_IME_PumpEvents_Real = NULL; | ||||||
|  |  | ||||||
| static void | static void InitIME() | ||||||
| InitIME() |  | ||||||
| { | { | ||||||
|     static SDL_bool inited = SDL_FALSE; |     static SDL_bool inited = SDL_FALSE; | ||||||
| #ifdef HAVE_FCITX | #ifdef HAVE_FCITX | ||||||
| @@ -107,24 +106,21 @@ SDL_IME_Init(void) | |||||||
|     return SDL_FALSE; |     return SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_IME_Quit(void) | ||||||
| SDL_IME_Quit(void) |  | ||||||
| { | { | ||||||
|     if (SDL_IME_Quit_Real) { |     if (SDL_IME_Quit_Real) { | ||||||
|         SDL_IME_Quit_Real(); |         SDL_IME_Quit_Real(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_IME_SetFocus(SDL_bool focused) | ||||||
| SDL_IME_SetFocus(SDL_bool focused) |  | ||||||
| { | { | ||||||
|     if (SDL_IME_SetFocus_Real) { |     if (SDL_IME_SetFocus_Real) { | ||||||
|         SDL_IME_SetFocus_Real(focused); |         SDL_IME_SetFocus_Real(focused); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_IME_Reset(void) | ||||||
| SDL_IME_Reset(void) |  | ||||||
| { | { | ||||||
|     if (SDL_IME_Reset_Real) { |     if (SDL_IME_Reset_Real) { | ||||||
|         SDL_IME_Reset_Real(); |         SDL_IME_Reset_Real(); | ||||||
| @@ -141,16 +137,14 @@ SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state) | |||||||
|     return SDL_FALSE; |     return SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_IME_UpdateTextRect(const SDL_Rect *rect) | ||||||
| SDL_IME_UpdateTextRect(const SDL_Rect *rect) |  | ||||||
| { | { | ||||||
|     if (SDL_IME_UpdateTextRect_Real) { |     if (SDL_IME_UpdateTextRect_Real) { | ||||||
|         SDL_IME_UpdateTextRect_Real(rect); |         SDL_IME_UpdateTextRect_Real(rect); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_IME_PumpEvents() | ||||||
| SDL_IME_PumpEvents() |  | ||||||
| { | { | ||||||
|     if (SDL_IME_PumpEvents_Real) { |     if (SDL_IME_PumpEvents_Real) { | ||||||
|         SDL_IME_PumpEvents_Real(); |         SDL_IME_PumpEvents_Real(); | ||||||
|   | |||||||
| @@ -33,9 +33,7 @@ SDL_Sandbox SDL_DetectSandbox(void) | |||||||
|  |  | ||||||
|     /* For Snap, we check multiple variables because they might be set for |     /* For Snap, we check multiple variables because they might be set for | ||||||
|      * unrelated reasons. This is the same thing WebKitGTK does. */ |      * unrelated reasons. This is the same thing WebKitGTK does. */ | ||||||
|     if (SDL_getenv("SNAP") != NULL |     if (SDL_getenv("SNAP") != NULL && SDL_getenv("SNAP_NAME") != NULL && SDL_getenv("SNAP_REVISION") != NULL) { | ||||||
|         && SDL_getenv("SNAP_NAME") != NULL |  | ||||||
|         && SDL_getenv("SNAP_REVISION") != NULL) { |  | ||||||
|         return SDL_SANDBOX_SNAP; |         return SDL_SANDBOX_SNAP; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -72,16 +72,14 @@ static Sint64 rtkit_max_rttime_usec = 200000; | |||||||
|  *  - The desktop portal exists and supports the realtime interface. |  *  - The desktop portal exists and supports the realtime interface. | ||||||
|  *  - The realtime interface is new enough to have the required bug fixes applied. |  *  - The realtime interface is new enough to have the required bug fixes applied. | ||||||
|  */ |  */ | ||||||
| static SDL_bool | static SDL_bool realtime_portal_supported(DBusConnection *conn) | ||||||
| realtime_portal_supported(DBusConnection *conn) |  | ||||||
| { | { | ||||||
|     Sint64 res; |     Sint64 res; | ||||||
|     return SDL_DBus_QueryPropertyOnConnection(conn, XDG_PORTAL_DBUS_NODE, XDG_PORTAL_DBUS_PATH, XDG_PORTAL_DBUS_INTERFACE, |     return SDL_DBus_QueryPropertyOnConnection(conn, XDG_PORTAL_DBUS_NODE, XDG_PORTAL_DBUS_PATH, XDG_PORTAL_DBUS_INTERFACE, | ||||||
|                                               "RTTimeUSecMax", DBUS_TYPE_INT64, &res); |                                               "RTTimeUSecMax", DBUS_TYPE_INT64, &res); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void set_rtkit_interface() | ||||||
| set_rtkit_interface() |  | ||||||
| { | { | ||||||
|     SDL_DBusContext *dbus = SDL_DBus_GetContext(); |     SDL_DBusContext *dbus = SDL_DBus_GetContext(); | ||||||
|  |  | ||||||
| @@ -99,8 +97,7 @@ set_rtkit_interface() | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static DBusConnection* | static DBusConnection *get_rtkit_dbus_connection() | ||||||
| get_rtkit_dbus_connection() |  | ||||||
| { | { | ||||||
|     SDL_DBusContext *dbus = SDL_DBus_GetContext(); |     SDL_DBusContext *dbus = SDL_DBus_GetContext(); | ||||||
|  |  | ||||||
| @@ -111,8 +108,7 @@ get_rtkit_dbus_connection() | |||||||
|     return NULL; |     return NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void rtkit_initialize() | ||||||
| rtkit_initialize() |  | ||||||
| { | { | ||||||
|     DBusConnection *dbus_conn; |     DBusConnection *dbus_conn; | ||||||
|  |  | ||||||
| @@ -138,8 +134,7 @@ rtkit_initialize() | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool rtkit_initialize_realtime_thread() | ||||||
| rtkit_initialize_realtime_thread() |  | ||||||
| { | { | ||||||
|     // Following is an excerpt from rtkit README that outlines the requirements |     // Following is an excerpt from rtkit README that outlines the requirements | ||||||
|     // a thread must meet before making rtkit requests: |     // a thread must meet before making rtkit requests: | ||||||
| @@ -198,8 +193,7 @@ rtkit_initialize_realtime_thread() | |||||||
|     return SDL_TRUE; |     return SDL_TRUE; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool rtkit_setpriority_nice(pid_t thread, int nice_level) | ||||||
| rtkit_setpriority_nice(pid_t thread, int nice_level) |  | ||||||
| { | { | ||||||
|     DBusConnection *dbus_conn; |     DBusConnection *dbus_conn; | ||||||
|     Uint64 pid = (Uint64)getpid(); |     Uint64 pid = (Uint64)getpid(); | ||||||
| @@ -222,8 +216,7 @@ rtkit_setpriority_nice(pid_t thread, int nice_level) | |||||||
|     return SDL_TRUE; |     return SDL_TRUE; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool rtkit_setpriority_realtime(pid_t thread, int rt_priority) | ||||||
| rtkit_setpriority_realtime(pid_t thread, int rt_priority) |  | ||||||
| { | { | ||||||
|     DBusConnection *dbus_conn; |     DBusConnection *dbus_conn; | ||||||
|     Uint64 pid = (Uint64)getpid(); |     Uint64 pid = (Uint64)getpid(); | ||||||
| @@ -261,8 +254,7 @@ rtkit_setpriority_realtime(pid_t thread, int rt_priority) | |||||||
| #endif /* threads */ | #endif /* threads */ | ||||||
|  |  | ||||||
| /* this is a public symbol, so it has to exist even if threads are disabled. */ | /* this is a public symbol, so it has to exist even if threads are disabled. */ | ||||||
| int | int SDL_LinuxSetThreadPriority(Sint64 threadID, int priority) | ||||||
| SDL_LinuxSetThreadPriority(Sint64 threadID, int priority) |  | ||||||
| { | { | ||||||
| #if SDL_THREADS_DISABLED | #if SDL_THREADS_DISABLED | ||||||
|     return SDL_Unsupported(); |     return SDL_Unsupported(); | ||||||
| @@ -294,8 +286,7 @@ SDL_LinuxSetThreadPriority(Sint64 threadID, int priority) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* this is a public symbol, so it has to exist even if threads are disabled. */ | /* this is a public symbol, so it has to exist even if threads are disabled. */ | ||||||
| int | int SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy) | ||||||
| SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy) |  | ||||||
| { | { | ||||||
| #if SDL_THREADS_DISABLED | #if SDL_THREADS_DISABLED | ||||||
|     return SDL_Unsupported(); |     return SDL_Unsupported(); | ||||||
|   | |||||||
| @@ -49,8 +49,7 @@ static int SDL_UDEV_load_syms(void); | |||||||
| static SDL_bool SDL_UDEV_hotplug_update_available(void); | static SDL_bool SDL_UDEV_hotplug_update_available(void); | ||||||
| static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev); | static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev); | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr) | ||||||
| SDL_UDEV_load_sym(const char *fn, void **addr) |  | ||||||
| { | { | ||||||
|     *addr = SDL_LoadFunction(_this->udev_handle, fn); |     *addr = SDL_LoadFunction(_this->udev_handle, fn); | ||||||
|     if (*addr == NULL) { |     if (*addr == NULL) { | ||||||
| @@ -61,12 +60,12 @@ SDL_UDEV_load_sym(const char *fn, void **addr) | |||||||
|     return SDL_TRUE; |     return SDL_TRUE; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_UDEV_load_syms(void) | ||||||
| SDL_UDEV_load_syms(void) |  | ||||||
| { | { | ||||||
| /* 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_UDEV_SYM(x)                                          \ | #define SDL_UDEV_SYM(x)                                          \ | ||||||
|         if (!SDL_UDEV_load_sym(#x, (void **) (char *) & _this->syms.x)) return -1 |     if (!SDL_UDEV_load_sym(#x, (void **)(char *)&_this->syms.x)) \ | ||||||
|  |     return -1 | ||||||
|  |  | ||||||
|     SDL_UDEV_SYM(udev_device_get_action); |     SDL_UDEV_SYM(udev_device_get_action); | ||||||
|     SDL_UDEV_SYM(udev_device_get_devnode); |     SDL_UDEV_SYM(udev_device_get_devnode); | ||||||
| @@ -99,8 +98,7 @@ SDL_UDEV_load_syms(void) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool SDL_UDEV_hotplug_update_available(void) | ||||||
| SDL_UDEV_hotplug_update_available(void) |  | ||||||
| { | { | ||||||
|     if (_this->udev_mon != NULL) { |     if (_this->udev_mon != NULL) { | ||||||
|         const int fd = _this->syms.udev_monitor_get_fd(_this->udev_mon); |         const int fd = _this->syms.udev_monitor_get_fd(_this->udev_mon); | ||||||
| @@ -111,9 +109,7 @@ SDL_UDEV_hotplug_update_available(void) | |||||||
|     return SDL_FALSE; |     return SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | int SDL_UDEV_Init(void) | ||||||
| int |  | ||||||
| SDL_UDEV_Init(void) |  | ||||||
| { | { | ||||||
|     int retval = 0; |     int retval = 0; | ||||||
|  |  | ||||||
| @@ -151,7 +147,6 @@ SDL_UDEV_Init(void) | |||||||
|  |  | ||||||
|         /* Do an initial scan of existing devices */ |         /* Do an initial scan of existing devices */ | ||||||
|         SDL_UDEV_Scan(); |         SDL_UDEV_Scan(); | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     _this->ref_count += 1; |     _this->ref_count += 1; | ||||||
| @@ -159,8 +154,7 @@ SDL_UDEV_Init(void) | |||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_UDEV_Quit(void) | ||||||
| SDL_UDEV_Quit(void) |  | ||||||
| { | { | ||||||
|     SDL_UDEV_CallbackList *item; |     SDL_UDEV_CallbackList *item; | ||||||
|  |  | ||||||
| @@ -194,8 +188,7 @@ SDL_UDEV_Quit(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_UDEV_Scan(void) | ||||||
| SDL_UDEV_Scan(void) |  | ||||||
| { | { | ||||||
|     struct udev_enumerate *enumerate = NULL; |     struct udev_enumerate *enumerate = NULL; | ||||||
|     struct udev_list_entry *devs = NULL; |     struct udev_list_entry *devs = NULL; | ||||||
| @@ -283,11 +276,7 @@ SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product | |||||||
|     return found; |     return found; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void SDL_UDEV_UnloadLibrary(void) | ||||||
|  |  | ||||||
|  |  | ||||||
| void |  | ||||||
| SDL_UDEV_UnloadLibrary(void) |  | ||||||
| { | { | ||||||
|     if (_this == NULL) { |     if (_this == NULL) { | ||||||
|         return; |         return; | ||||||
| @@ -299,8 +288,7 @@ SDL_UDEV_UnloadLibrary(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_UDEV_LoadLibrary(void) | ||||||
| SDL_UDEV_LoadLibrary(void) |  | ||||||
| { | { | ||||||
|     int retval = 0, i; |     int retval = 0, i; | ||||||
|  |  | ||||||
| @@ -378,8 +366,7 @@ static void get_caps(struct udev_device *dev, struct udev_device *pdev, const ch | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int guess_device_class(struct udev_device *dev) | ||||||
| guess_device_class(struct udev_device *dev) |  | ||||||
| { | { | ||||||
|     struct udev_device *pdev; |     struct udev_device *pdev; | ||||||
|     unsigned long bitmask_ev[NBITS(EV_MAX)]; |     unsigned long bitmask_ev[NBITS(EV_MAX)]; | ||||||
| @@ -408,8 +395,7 @@ guess_device_class(struct udev_device *dev) | |||||||
|                                       &bitmask_rel[0]); |                                       &bitmask_rel[0]); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) | ||||||
| device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) |  | ||||||
| { | { | ||||||
|     const char *subsystem; |     const char *subsystem; | ||||||
|     const char *val = NULL; |     const char *val = NULL; | ||||||
| @@ -488,8 +474,7 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_UDEV_Poll(void) | ||||||
| SDL_UDEV_Poll(void) |  | ||||||
| { | { | ||||||
|     struct udev_device *dev = NULL; |     struct udev_device *dev = NULL; | ||||||
|     const char *action = NULL; |     const char *action = NULL; | ||||||
| @@ -517,8 +502,7 @@ SDL_UDEV_Poll(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb) | ||||||
| SDL_UDEV_AddCallback(SDL_UDEV_Callback cb) |  | ||||||
| { | { | ||||||
|     SDL_UDEV_CallbackList *item; |     SDL_UDEV_CallbackList *item; | ||||||
|     item = (SDL_UDEV_CallbackList *)SDL_calloc(1, sizeof(SDL_UDEV_CallbackList)); |     item = (SDL_UDEV_CallbackList *)SDL_calloc(1, sizeof(SDL_UDEV_CallbackList)); | ||||||
| @@ -538,8 +522,7 @@ SDL_UDEV_AddCallback(SDL_UDEV_Callback cb) | |||||||
|     return 1; |     return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb) | ||||||
| SDL_UDEV_DelCallback(SDL_UDEV_Callback cb) |  | ||||||
| { | { | ||||||
|     SDL_UDEV_CallbackList *item; |     SDL_UDEV_CallbackList *item; | ||||||
|     SDL_UDEV_CallbackList *prev = NULL; |     SDL_UDEV_CallbackList *prev = NULL; | ||||||
| @@ -578,8 +561,7 @@ SDL_UDEV_GetUdevSyms(void) | |||||||
|     return &_this->syms; |     return &_this->syms; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_UDEV_ReleaseUdevSyms(void) | ||||||
| SDL_UDEV_ReleaseUdevSyms(void) |  | ||||||
| { | { | ||||||
|     SDL_UDEV_Quit(); |     SDL_UDEV_Quit(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -48,12 +48,14 @@ typedef enum | |||||||
|  |  | ||||||
| typedef void (*SDL_UDEV_Callback)(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); | typedef void (*SDL_UDEV_Callback)(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); | ||||||
|  |  | ||||||
| typedef struct SDL_UDEV_CallbackList { | typedef struct SDL_UDEV_CallbackList | ||||||
|  | { | ||||||
|     SDL_UDEV_Callback callback; |     SDL_UDEV_Callback callback; | ||||||
|     struct SDL_UDEV_CallbackList *next; |     struct SDL_UDEV_CallbackList *next; | ||||||
| } SDL_UDEV_CallbackList; | } SDL_UDEV_CallbackList; | ||||||
|  |  | ||||||
| typedef struct SDL_UDEV_Symbols { | typedef struct SDL_UDEV_Symbols | ||||||
|  | { | ||||||
|     const char *(*udev_device_get_action)(struct udev_device *); |     const char *(*udev_device_get_action)(struct udev_device *); | ||||||
|     const char *(*udev_device_get_devnode)(struct udev_device *); |     const char *(*udev_device_get_devnode)(struct udev_device *); | ||||||
|     const char *(*udev_device_get_subsystem)(struct udev_device *); |     const char *(*udev_device_get_subsystem)(struct udev_device *); | ||||||
| @@ -107,7 +109,6 @@ extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb); | |||||||
| extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void); | extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void); | ||||||
| extern void SDL_UDEV_ReleaseUdevSyms(void); | extern void SDL_UDEV_ReleaseUdevSyms(void); | ||||||
|  |  | ||||||
|  |  | ||||||
| #endif /* HAVE_LIBUDEV_H && HAVE_LINUX_INPUT_H */ | #endif /* HAVE_LIBUDEV_H && HAVE_LINUX_INPUT_H */ | ||||||
|  |  | ||||||
| #endif /* SDL_udev_h_ */ | #endif /* SDL_udev_h_ */ | ||||||
|   | |||||||
| @@ -19,9 +19,7 @@ | |||||||
|   3. This notice may not be removed or altered from any source distribution. |   3. This notice may not be removed or altered from any source distribution. | ||||||
| */ | */ | ||||||
|  |  | ||||||
|  |  | ||||||
| void SDL_WSCONS_Init(); | void SDL_WSCONS_Init(); | ||||||
| void SDL_WSCONS_Quit(); | void SDL_WSCONS_Quit(); | ||||||
|  |  | ||||||
| void SDL_WSCONS_PumpEvents(); | void SDL_WSCONS_PumpEvents(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -44,7 +44,12 @@ | |||||||
| #define KS_Cmd_ScrollFwd  KS_Cmd_ScrollFastDown | #define KS_Cmd_ScrollFwd  KS_Cmd_ScrollFastDown | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #define RETIFIOCTLERR(x) if (x == -1) { free(input); input = NULL; return NULL;} | #define RETIFIOCTLERR(x) \ | ||||||
|  |     if (x == -1) {       \ | ||||||
|  |         free(input);     \ | ||||||
|  |         input = NULL;    \ | ||||||
|  |         return NULL;     \ | ||||||
|  |     } | ||||||
|  |  | ||||||
| typedef struct SDL_WSCONS_mouse_input_data SDL_WSCONS_mouse_input_data; | typedef struct SDL_WSCONS_mouse_input_data SDL_WSCONS_mouse_input_data; | ||||||
| extern SDL_WSCONS_mouse_input_data *SDL_WSCONS_Init_Mouse(); | extern SDL_WSCONS_mouse_input_data *SDL_WSCONS_Init_Mouse(); | ||||||
| @@ -89,7 +94,8 @@ static const unsigned char latin1_to_upper[256] = { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| /* Compose table courtesy of /usr/src/sys/dev/wscons/wskbdutil.c */ | /* Compose table courtesy of /usr/src/sys/dev/wscons/wskbdutil.c */ | ||||||
| static struct SDL_wscons_compose_tab_s { | static struct SDL_wscons_compose_tab_s | ||||||
|  | { | ||||||
|     keysym_t elem[2]; |     keysym_t elem[2]; | ||||||
|     keysym_t result; |     keysym_t result; | ||||||
| } compose_tab[] = { | } compose_tab[] = { | ||||||
| @@ -243,7 +249,8 @@ static keysym_t ksym_upcase(keysym_t ksym) | |||||||
|  |  | ||||||
|     return ksym; |     return ksym; | ||||||
| } | } | ||||||
| static struct wscons_keycode_to_SDL { | static struct wscons_keycode_to_SDL | ||||||
|  | { | ||||||
|     keysym_t sourcekey; |     keysym_t sourcekey; | ||||||
|     SDL_Scancode targetKey; |     SDL_Scancode targetKey; | ||||||
| } conversion_table[] = { | } conversion_table[] = { | ||||||
| @@ -382,7 +389,8 @@ static struct wscons_keycode_to_SDL { | |||||||
|     { KS_backslash, SDL_SCANCODE_BACKSLASH } |     { KS_backslash, SDL_SCANCODE_BACKSLASH } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| typedef struct { | typedef struct | ||||||
|  | { | ||||||
|     int fd; |     int fd; | ||||||
|     struct wskbd_map_data keymap; |     struct wskbd_map_data keymap; | ||||||
|     int ledstate; |     int ledstate; | ||||||
| @@ -547,11 +555,13 @@ static void Translate_to_keycode(SDL_WSCONS_input_data* input, int type, keysym_ | |||||||
|  |  | ||||||
|     /* Check command first, then group[0]*/ |     /* Check command first, then group[0]*/ | ||||||
|     switch (keyDesc.command) { |     switch (keyDesc.command) { | ||||||
|     case KS_Cmd_ScrollBack: { |     case KS_Cmd_ScrollBack: | ||||||
|  |     { | ||||||
|         SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_SCANCODE_PAGEUP); |         SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_SCANCODE_PAGEUP); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     case KS_Cmd_ScrollFwd: { |     case KS_Cmd_ScrollFwd: | ||||||
|  |     { | ||||||
|         SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_SCANCODE_PAGEDOWN); |         SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_SCANCODE_PAGEDOWN); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| @@ -563,7 +573,6 @@ static void Translate_to_keycode(SDL_WSCONS_input_data* input, int type, keysym_ | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_SCANCODE_UNKNOWN); |     SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_SCANCODE_UNKNOWN); | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static void updateKeyboard(SDL_WSCONS_input_data *input) | static void updateKeyboard(SDL_WSCONS_input_data *input) | ||||||
| @@ -582,9 +591,11 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|         for (i = 0; i < n; i++) { |         for (i = 0; i < n; i++) { | ||||||
|             type = events[i].type; |             type = events[i].type; | ||||||
|             switch (type) { |             switch (type) { | ||||||
|             case WSCONS_EVENT_KEY_DOWN: { |             case WSCONS_EVENT_KEY_DOWN: | ||||||
|  |             { | ||||||
|                 switch (input->keymap.map[events[i].value].group1[0]) { |                 switch (input->keymap.map[events[i].value].group1[0]) { | ||||||
|                 case KS_Hold_Screen: { |                 case KS_Hold_Screen: | ||||||
|  |                 { | ||||||
|                     if (input->lockheldstate[0] >= 1) { |                     if (input->lockheldstate[0] >= 1) { | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
| @@ -593,7 +604,8 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                     input->lockheldstate[0] = 1; |                     input->lockheldstate[0] = 1; | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Num_Lock: { |                 case KS_Num_Lock: | ||||||
|  |                 { | ||||||
|                     if (input->lockheldstate[1] >= 1) { |                     if (input->lockheldstate[1] >= 1) { | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
| @@ -602,7 +614,8 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                     input->lockheldstate[1] = 1; |                     input->lockheldstate[1] = 1; | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Caps_Lock: { |                 case KS_Caps_Lock: | ||||||
|  |                 { | ||||||
|                     if (input->lockheldstate[2] >= 1) { |                     if (input->lockheldstate[2] >= 1) { | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
| @@ -612,7 +625,8 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
| #ifndef __NetBSD__ | #ifndef __NetBSD__ | ||||||
|                 case KS_Mode_Lock: { |                 case KS_Mode_Lock: | ||||||
|  |                 { | ||||||
|                     if (input->lockheldstate[3] >= 1) { |                     if (input->lockheldstate[3] >= 1) { | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
| @@ -622,7 +636,8 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
| #endif | #endif | ||||||
|                 case KS_Shift_Lock: { |                 case KS_Shift_Lock: | ||||||
|  |                 { | ||||||
|                     if (input->lockheldstate[4] >= 1) { |                     if (input->lockheldstate[4] >= 1) { | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
| @@ -631,7 +646,8 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                     input->lockheldstate[4] = 1; |                     input->lockheldstate[4] = 1; | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Shift_L: { |                 case KS_Shift_L: | ||||||
|  |                 { | ||||||
|                     if (input->shiftheldstate[0]) { |                     if (input->shiftheldstate[0]) { | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
| @@ -639,7 +655,8 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                     input->shiftheldstate[0] = 1; |                     input->shiftheldstate[0] = 1; | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Shift_R: { |                 case KS_Shift_R: | ||||||
|  |                 { | ||||||
|                     if (input->shiftheldstate[1]) { |                     if (input->shiftheldstate[1]) { | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
| @@ -647,7 +664,8 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                     input->shiftheldstate[1] = 1; |                     input->shiftheldstate[1] = 1; | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Alt_L: { |                 case KS_Alt_L: | ||||||
|  |                 { | ||||||
|                     if (input->shiftheldstate[2]) { |                     if (input->shiftheldstate[2]) { | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
| @@ -655,7 +673,8 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                     input->shiftheldstate[2] = 1; |                     input->shiftheldstate[2] = 1; | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Alt_R: { |                 case KS_Alt_R: | ||||||
|  |                 { | ||||||
|                     if (input->shiftheldstate[3]) { |                     if (input->shiftheldstate[3]) { | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
| @@ -663,7 +682,8 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                     input->shiftheldstate[3] = 1; |                     input->shiftheldstate[3] = 1; | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Control_L: { |                 case KS_Control_L: | ||||||
|  |                 { | ||||||
|                     if (input->shiftheldstate[4]) { |                     if (input->shiftheldstate[4]) { | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
| @@ -671,7 +691,8 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                     input->shiftheldstate[4] = 1; |                     input->shiftheldstate[4] = 1; | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Control_R: { |                 case KS_Control_R: | ||||||
|  |                 { | ||||||
|                     if (input->shiftheldstate[5]) { |                     if (input->shiftheldstate[5]) { | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
| @@ -679,7 +700,8 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                     input->shiftheldstate[5] = 1; |                     input->shiftheldstate[5] = 1; | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Mode_switch: { |                 case KS_Mode_switch: | ||||||
|  |                 { | ||||||
|                     if (input->shiftheldstate[6]) { |                     if (input->shiftheldstate[6]) { | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
| @@ -688,85 +710,92 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 } |                 } | ||||||
|             } |             } break; | ||||||
|             break; |             case WSCONS_EVENT_KEY_UP: | ||||||
|             case WSCONS_EVENT_KEY_UP: { |             { | ||||||
|                 switch (input->keymap.map[events[i].value].group1[0]) { |                 switch (input->keymap.map[events[i].value].group1[0]) { | ||||||
|                 case KS_Hold_Screen: { |                 case KS_Hold_Screen: | ||||||
|  |                 { | ||||||
|                     if (input->lockheldstate[0]) { |                     if (input->lockheldstate[0]) { | ||||||
|                         input->lockheldstate[0] = 0; |                         input->lockheldstate[0] = 0; | ||||||
|                     } |                     } | ||||||
|                 } |                 } break; | ||||||
|                 break; |                 case KS_Num_Lock: | ||||||
|                 case KS_Num_Lock: { |                 { | ||||||
|                     if (input->lockheldstate[1]) { |                     if (input->lockheldstate[1]) { | ||||||
|                         input->lockheldstate[1] = 0; |                         input->lockheldstate[1] = 0; | ||||||
|                     } |                     } | ||||||
|                 } |                 } break; | ||||||
|                 break; |                 case KS_Caps_Lock: | ||||||
|                 case KS_Caps_Lock: { |                 { | ||||||
|                     if (input->lockheldstate[2]) { |                     if (input->lockheldstate[2]) { | ||||||
|                         input->lockheldstate[2] = 0; |                         input->lockheldstate[2] = 0; | ||||||
|                     } |                     } | ||||||
|                 } |                 } break; | ||||||
|                 break; |  | ||||||
| #ifndef __NetBSD__ | #ifndef __NetBSD__ | ||||||
|                 case KS_Mode_Lock: { |                 case KS_Mode_Lock: | ||||||
|  |                 { | ||||||
|                     if (input->lockheldstate[3]) { |                     if (input->lockheldstate[3]) { | ||||||
|                         input->lockheldstate[3] = 0; |                         input->lockheldstate[3] = 0; | ||||||
|                     } |                     } | ||||||
|                 } |                 } break; | ||||||
|                 break; |  | ||||||
| #endif | #endif | ||||||
|                 case KS_Shift_Lock: { |                 case KS_Shift_Lock: | ||||||
|  |                 { | ||||||
|                     if (input->lockheldstate[4]) { |                     if (input->lockheldstate[4]) { | ||||||
|                         input->lockheldstate[4] = 0; |                         input->lockheldstate[4] = 0; | ||||||
|                     } |                     } | ||||||
|                 } |                 } break; | ||||||
|                 break; |                 case KS_Shift_L: | ||||||
|                 case KS_Shift_L: { |                 { | ||||||
|                     input->shiftheldstate[0] = 0; |                     input->shiftheldstate[0] = 0; | ||||||
|                     if (input->shiftstate[0]) { |                     if (input->shiftstate[0]) { | ||||||
|                         input->shiftstate[0]--; |                         input->shiftstate[0]--; | ||||||
|                     } |                     } | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Shift_R: { |                 case KS_Shift_R: | ||||||
|  |                 { | ||||||
|                     input->shiftheldstate[1] = 0; |                     input->shiftheldstate[1] = 0; | ||||||
|                     if (input->shiftstate[0]) { |                     if (input->shiftstate[0]) { | ||||||
|                         input->shiftstate[0]--; |                         input->shiftstate[0]--; | ||||||
|                     } |                     } | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Alt_L: { |                 case KS_Alt_L: | ||||||
|  |                 { | ||||||
|                     input->shiftheldstate[2] = 0; |                     input->shiftheldstate[2] = 0; | ||||||
|                     if (input->shiftstate[1]) { |                     if (input->shiftstate[1]) { | ||||||
|                         input->shiftstate[1]--; |                         input->shiftstate[1]--; | ||||||
|                     } |                     } | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Alt_R: { |                 case KS_Alt_R: | ||||||
|  |                 { | ||||||
|                     input->shiftheldstate[3] = 0; |                     input->shiftheldstate[3] = 0; | ||||||
|                     if (input->shiftstate[1]) { |                     if (input->shiftstate[1]) { | ||||||
|                         input->shiftstate[1]--; |                         input->shiftstate[1]--; | ||||||
|                     } |                     } | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Control_L: { |                 case KS_Control_L: | ||||||
|  |                 { | ||||||
|                     input->shiftheldstate[4] = 0; |                     input->shiftheldstate[4] = 0; | ||||||
|                     if (input->shiftstate[2]) { |                     if (input->shiftstate[2]) { | ||||||
|                         input->shiftstate[2]--; |                         input->shiftstate[2]--; | ||||||
|                     } |                     } | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Control_R: { |                 case KS_Control_R: | ||||||
|  |                 { | ||||||
|                     input->shiftheldstate[5] = 0; |                     input->shiftheldstate[5] = 0; | ||||||
|                     if (input->shiftstate[2]) { |                     if (input->shiftstate[2]) { | ||||||
|                         input->shiftstate[2]--; |                         input->shiftstate[2]--; | ||||||
|                     } |                     } | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case KS_Mode_switch: { |                 case KS_Mode_switch: | ||||||
|  |                 { | ||||||
|                     input->shiftheldstate[6] = 0; |                     input->shiftheldstate[6] = 0; | ||||||
|                     if (input->shiftstate[3]) { |                     if (input->shiftstate[3]) { | ||||||
|                         input->shiftstate[3]--; |                         input->shiftstate[3]--; | ||||||
| @@ -774,8 +803,7 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 } |                 } | ||||||
|             } |             } break; | ||||||
|             break; |  | ||||||
|             case WSCONS_EVENT_ALL_KEYS_UP: |             case WSCONS_EVENT_ALL_KEYS_UP: | ||||||
|                 for (i = 0; i < SDL_NUM_SCANCODES; i++) { |                 for (i = 0; i < SDL_NUM_SCANCODES; i++) { | ||||||
|                     SDL_SendKeyboardKey(SDL_RELEASED, i); |                     SDL_SendKeyboardKey(SDL_RELEASED, i); | ||||||
| @@ -832,7 +860,8 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                     input->composelen = 1; |                     input->composelen = 1; | ||||||
|                     input->composebuffer[0] = ksym; |                     input->composebuffer[0] = ksym; | ||||||
|                     input->composebuffer[1] = 0; |                     input->composebuffer[1] = 0; | ||||||
|                 } else result = ksym; |                 } else | ||||||
|  |                     result = ksym; | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|             if (result == KS_voidSymbol) { |             if (result == KS_voidSymbol) { | ||||||
| @@ -854,15 +883,13 @@ static void updateKeyboard(SDL_WSCONS_input_data* input) | |||||||
|                         input->ledstate &= ~WSKBD_LED_COMPOSE; |                         input->ledstate &= ~WSKBD_LED_COMPOSE; | ||||||
|                         ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); |                         ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); | ||||||
|                         for (acc_i = 0; acc_i < SDL_arraysize(compose_tab); acc_i++) { |                         for (acc_i = 0; acc_i < SDL_arraysize(compose_tab); acc_i++) { | ||||||
|                             if ((compose_tab[acc_i].elem[0] == input->composebuffer[0] |                             if ((compose_tab[acc_i].elem[0] == input->composebuffer[0] && compose_tab[acc_i].elem[1] == input->composebuffer[1]) || (compose_tab[acc_i].elem[0] == input->composebuffer[1] && compose_tab[acc_i].elem[1] == input->composebuffer[0])) { | ||||||
|                                     && compose_tab[acc_i].elem[1] == input->composebuffer[1]) |  | ||||||
|                                     || (compose_tab[acc_i].elem[0] == input->composebuffer[1] |  | ||||||
|                                         && compose_tab[acc_i].elem[1] == input->composebuffer[0])) { |  | ||||||
|                                 result = compose_tab[acc_i].result; |                                 result = compose_tab[acc_i].result; | ||||||
|                                 break; |                                 break; | ||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
|                     } else continue; |                     } else | ||||||
|  |                         continue; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -46,7 +46,10 @@ SDL_WSCONS_mouse_input_data* SDL_WSCONS_Init_Mouse() | |||||||
|         return NULL; |         return NULL; | ||||||
|     } |     } | ||||||
|     mouseInputData->fd = open("/dev/wsmouse", O_RDWR | O_NONBLOCK | O_CLOEXEC); |     mouseInputData->fd = open("/dev/wsmouse", O_RDWR | O_NONBLOCK | O_CLOEXEC); | ||||||
|     if (mouseInputData->fd == -1) {free(mouseInputData); return NULL; } |     if (mouseInputData->fd == -1) { | ||||||
|  |         free(mouseInputData); | ||||||
|  |         return NULL; | ||||||
|  |     } | ||||||
| #ifdef WSMOUSEIO_SETMODE | #ifdef WSMOUSEIO_SETMODE | ||||||
|     ioctl(mouseInputData->fd, WSMOUSEIO_SETMODE, WSMOUSE_COMPAT); |     ioctl(mouseInputData->fd, WSMOUSEIO_SETMODE, WSMOUSE_COMPAT); | ||||||
| #endif | #endif | ||||||
| @@ -67,12 +70,10 @@ void updateMouse(SDL_WSCONS_mouse_input_data* inputData) | |||||||
|         n /= sizeof(struct wscons_event); |         n /= sizeof(struct wscons_event); | ||||||
|         for (i = 0; i < n; i++) { |         for (i = 0; i < n; i++) { | ||||||
|             type = events[i].type; |             type = events[i].type; | ||||||
|             switch(type) |             switch (type) { | ||||||
|             { |  | ||||||
|             case WSCONS_EVENT_MOUSE_DOWN: |             case WSCONS_EVENT_MOUSE_DOWN: | ||||||
|             { |             { | ||||||
|                     switch (events[i].value) |                 switch (events[i].value) { | ||||||
|                     { |  | ||||||
|                 case 0: /* Left Mouse Button. */ |                 case 0: /* Left Mouse Button. */ | ||||||
|                     SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_BUTTON_LEFT); |                     SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_BUTTON_LEFT); | ||||||
|                     break; |                     break; | ||||||
| @@ -83,12 +84,10 @@ void updateMouse(SDL_WSCONS_mouse_input_data* inputData) | |||||||
|                     SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_BUTTON_RIGHT); |                     SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_BUTTON_RIGHT); | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 } |             } break; | ||||||
|                 break; |  | ||||||
|             case WSCONS_EVENT_MOUSE_UP: |             case WSCONS_EVENT_MOUSE_UP: | ||||||
|             { |             { | ||||||
|                     switch (events[i].value) |                 switch (events[i].value) { | ||||||
|                     { |  | ||||||
|                 case 0: /* Left Mouse Button. */ |                 case 0: /* Left Mouse Button. */ | ||||||
|                     SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_BUTTON_LEFT); |                     SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_BUTTON_LEFT); | ||||||
|                     break; |                     break; | ||||||
| @@ -99,8 +98,7 @@ void updateMouse(SDL_WSCONS_mouse_input_data* inputData) | |||||||
|                     SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_BUTTON_RIGHT); |                     SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_BUTTON_RIGHT); | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 } |             } break; | ||||||
|                 break; |  | ||||||
|             case WSCONS_EVENT_MOUSE_DELTA_X: |             case WSCONS_EVENT_MOUSE_DELTA_X: | ||||||
|             { |             { | ||||||
|                 SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, events[i].value, 0); |                 SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, events[i].value, 0); | ||||||
|   | |||||||
| @@ -32,17 +32,14 @@ | |||||||
| #endif | #endif | ||||||
| #include <errno.h> | #include <errno.h> | ||||||
|  |  | ||||||
|  | int SDL_IOReady(int fd, int flags, int timeoutMS) | ||||||
| int |  | ||||||
| SDL_IOReady(int fd, int flags, int timeoutMS) |  | ||||||
| { | { | ||||||
|     int result; |     int result; | ||||||
|  |  | ||||||
|     SDL_assert(flags & (SDL_IOR_READ | SDL_IOR_WRITE)); |     SDL_assert(flags & (SDL_IOR_READ | SDL_IOR_WRITE)); | ||||||
|  |  | ||||||
|     /* Note: We don't bother to account for elapsed time if we get EINTR */ |     /* Note: We don't bother to account for elapsed time if we get EINTR */ | ||||||
|     do |     do { | ||||||
|     { |  | ||||||
| #ifdef HAVE_POLL | #ifdef HAVE_POLL | ||||||
|         struct pollfd info; |         struct pollfd info; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -103,7 +103,10 @@ | |||||||
| #ifdef HAVE_DINPUT_H | #ifdef HAVE_DINPUT_H | ||||||
| #include <dinput.h> | #include <dinput.h> | ||||||
| #else | #else | ||||||
| typedef struct { int unused; } DIDEVICEINSTANCE; | typedef struct | ||||||
|  | { | ||||||
|  |     int unused; | ||||||
|  | } DIDEVICEINSTANCE; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #endif /* SDL_directx_h_ */ | #endif /* SDL_directx_h_ */ | ||||||
|   | |||||||
| @@ -24,7 +24,6 @@ | |||||||
|  |  | ||||||
| #include "SDL_hid.h" | #include "SDL_hid.h" | ||||||
|  |  | ||||||
|  |  | ||||||
| HidD_GetString_t SDL_HidD_GetManufacturerString; | HidD_GetString_t SDL_HidD_GetManufacturerString; | ||||||
| HidD_GetString_t SDL_HidD_GetProductString; | HidD_GetString_t SDL_HidD_GetProductString; | ||||||
| HidP_GetCaps_t SDL_HidP_GetCaps; | HidP_GetCaps_t SDL_HidP_GetCaps; | ||||||
| @@ -36,9 +35,7 @@ HidP_GetData_t SDL_HidP_GetData; | |||||||
| static HMODULE s_pHIDDLL = 0; | static HMODULE s_pHIDDLL = 0; | ||||||
| static int s_HIDDLLRefCount = 0; | static int s_HIDDLLRefCount = 0; | ||||||
|  |  | ||||||
|  | int WIN_LoadHIDDLL(void) | ||||||
| int |  | ||||||
| WIN_LoadHIDDLL(void) |  | ||||||
| { | { | ||||||
|     if (s_pHIDDLL) { |     if (s_pHIDDLL) { | ||||||
|         SDL_assert(s_HIDDLLRefCount > 0); |         SDL_assert(s_HIDDLLRefCount > 0); | ||||||
| @@ -71,8 +68,7 @@ WIN_LoadHIDDLL(void) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WIN_UnloadHIDDLL(void) | ||||||
| WIN_UnloadHIDDLL(void) |  | ||||||
| { | { | ||||||
|     if (s_pHIDDLL) { |     if (s_pHIDDLL) { | ||||||
|         SDL_assert(s_HIDDLLRefCount > 0); |         SDL_assert(s_HIDDLLRefCount > 0); | ||||||
|   | |||||||
| @@ -39,13 +39,15 @@ typedef struct _HIDD_ATTRIBUTES | |||||||
|     USHORT VersionNumber; |     USHORT VersionNumber; | ||||||
| } HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES; | } HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES; | ||||||
|  |  | ||||||
| typedef enum { | typedef enum | ||||||
|  | { | ||||||
|     HidP_Input = 0, |     HidP_Input = 0, | ||||||
|     HidP_Output = 1, |     HidP_Output = 1, | ||||||
|     HidP_Feature = 2 |     HidP_Feature = 2 | ||||||
| } HIDP_REPORT_TYPE; | } HIDP_REPORT_TYPE; | ||||||
|  |  | ||||||
| typedef struct { | typedef struct | ||||||
|  | { | ||||||
|     USAGE UsagePage; |     USAGE UsagePage; | ||||||
|     UCHAR ReportID; |     UCHAR ReportID; | ||||||
|     BOOLEAN IsAlias; |     BOOLEAN IsAlias; | ||||||
| @@ -58,8 +60,10 @@ typedef struct { | |||||||
|     BOOLEAN IsDesignatorRange; |     BOOLEAN IsDesignatorRange; | ||||||
|     BOOLEAN IsAbsolute; |     BOOLEAN IsAbsolute; | ||||||
|     ULONG Reserved[10]; |     ULONG Reserved[10]; | ||||||
|     union { |     union | ||||||
|         struct { |     { | ||||||
|  |         struct | ||||||
|  |         { | ||||||
|             USAGE UsageMin; |             USAGE UsageMin; | ||||||
|             USAGE UsageMax; |             USAGE UsageMax; | ||||||
|             USHORT StringMin; |             USHORT StringMin; | ||||||
| @@ -69,7 +73,8 @@ typedef struct { | |||||||
|             USHORT DataIndexMin; |             USHORT DataIndexMin; | ||||||
|             USHORT DataIndexMax; |             USHORT DataIndexMax; | ||||||
|         } Range; |         } Range; | ||||||
|         struct { |         struct | ||||||
|  |         { | ||||||
|             USAGE Usage; |             USAGE Usage; | ||||||
|             USAGE Reserved1; |             USAGE Reserved1; | ||||||
|             USHORT StringIndex; |             USHORT StringIndex; | ||||||
| @@ -82,7 +87,8 @@ typedef struct { | |||||||
|     }; |     }; | ||||||
| } HIDP_BUTTON_CAPS, *PHIDP_BUTTON_CAPS; | } HIDP_BUTTON_CAPS, *PHIDP_BUTTON_CAPS; | ||||||
|  |  | ||||||
| typedef struct { | typedef struct | ||||||
|  | { | ||||||
|     USAGE UsagePage; |     USAGE UsagePage; | ||||||
|     UCHAR ReportID; |     UCHAR ReportID; | ||||||
|     BOOLEAN IsAlias; |     BOOLEAN IsAlias; | ||||||
| @@ -105,8 +111,10 @@ typedef struct { | |||||||
|     LONG LogicalMax; |     LONG LogicalMax; | ||||||
|     LONG PhysicalMin; |     LONG PhysicalMin; | ||||||
|     LONG PhysicalMax; |     LONG PhysicalMax; | ||||||
|     union { |     union | ||||||
|         struct { |     { | ||||||
|  |         struct | ||||||
|  |         { | ||||||
|             USAGE UsageMin; |             USAGE UsageMin; | ||||||
|             USAGE UsageMax; |             USAGE UsageMax; | ||||||
|             USHORT StringMin; |             USHORT StringMin; | ||||||
| @@ -116,7 +124,8 @@ typedef struct { | |||||||
|             USHORT DataIndexMin; |             USHORT DataIndexMin; | ||||||
|             USHORT DataIndexMax; |             USHORT DataIndexMax; | ||||||
|         } Range; |         } Range; | ||||||
|         struct { |         struct | ||||||
|  |         { | ||||||
|             USAGE Usage; |             USAGE Usage; | ||||||
|             USAGE Reserved1; |             USAGE Reserved1; | ||||||
|             USHORT StringIndex; |             USHORT StringIndex; | ||||||
| @@ -129,7 +138,8 @@ typedef struct { | |||||||
|     }; |     }; | ||||||
| } HIDP_VALUE_CAPS, *PHIDP_VALUE_CAPS; | } HIDP_VALUE_CAPS, *PHIDP_VALUE_CAPS; | ||||||
|  |  | ||||||
| typedef struct { | typedef struct | ||||||
|  | { | ||||||
|     USAGE Usage; |     USAGE Usage; | ||||||
|     USAGE UsagePage; |     USAGE UsagePage; | ||||||
|     USHORT InputReportByteLength; |     USHORT InputReportByteLength; | ||||||
| @@ -148,10 +158,12 @@ typedef struct { | |||||||
|     USHORT NumberFeatureDataIndices; |     USHORT NumberFeatureDataIndices; | ||||||
| } HIDP_CAPS, *PHIDP_CAPS; | } HIDP_CAPS, *PHIDP_CAPS; | ||||||
|  |  | ||||||
| typedef struct { | typedef struct | ||||||
|  | { | ||||||
|     USHORT DataIndex; |     USHORT DataIndex; | ||||||
|     USHORT Reserved; |     USHORT Reserved; | ||||||
|     union { |     union | ||||||
|  |     { | ||||||
|         ULONG RawValue; |         ULONG RawValue; | ||||||
|         BOOLEAN On; |         BOOLEAN On; | ||||||
|     }; |     }; | ||||||
| @@ -178,7 +190,6 @@ typedef struct { | |||||||
| #define HIDP_STATUS_REPORT_DOES_NOT_EXIST   HIDP_ERROR_CODES(0xC, 0x0010) | #define HIDP_STATUS_REPORT_DOES_NOT_EXIST   HIDP_ERROR_CODES(0xC, 0x0010) | ||||||
| #define HIDP_STATUS_NOT_IMPLEMENTED         HIDP_ERROR_CODES(0xC, 0x0020) | #define HIDP_STATUS_NOT_IMPLEMENTED         HIDP_ERROR_CODES(0xC, 0x0020) | ||||||
|  |  | ||||||
|  |  | ||||||
| extern int WIN_LoadHIDDLL(void); | extern int WIN_LoadHIDDLL(void); | ||||||
| extern void WIN_UnloadHIDDLL(void); | extern void WIN_UnloadHIDDLL(void); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -39,6 +39,7 @@ static IMMDeviceEnumerator *enumerator = NULL; | |||||||
| #define PropVariantInit(p) SDL_zerop(p) | #define PropVariantInit(p) SDL_zerop(p) | ||||||
|  |  | ||||||
| /* Some GUIDs we need to know without linking to libraries that aren't available before Vista. */ | /* Some GUIDs we need to know without linking to libraries that aren't available before Vista. */ | ||||||
|  | /* *INDENT-OFF* */ /* clang-format off */ | ||||||
| static const CLSID SDL_CLSID_MMDeviceEnumerator = { 0xbcde0395, 0xe52f, 0x467c,{ 0x8e, 0x3d, 0xc4, 0x57, 0x92, 0x91, 0x69, 0x2e } }; | static const CLSID SDL_CLSID_MMDeviceEnumerator = { 0xbcde0395, 0xe52f, 0x467c,{ 0x8e, 0x3d, 0xc4, 0x57, 0x92, 0x91, 0x69, 0x2e } }; | ||||||
| static const IID SDL_IID_IMMDeviceEnumerator = { 0xa95664d2, 0x9614, 0x4f35,{ 0xa7, 0x46, 0xde, 0x8d, 0xb6, 0x36, 0x17, 0xe6 } }; | static const IID SDL_IID_IMMDeviceEnumerator = { 0xa95664d2, 0x9614, 0x4f35,{ 0xa7, 0x46, 0xde, 0x8d, 0xb6, 0x36, 0x17, 0xe6 } }; | ||||||
| static const IID SDL_IID_IMMNotificationClient = { 0x7991eec9, 0x7e89, 0x4d85,{ 0x83, 0x90, 0x6c, 0x70, 0x3c, 0xec, 0x60, 0xc0 } }; | static const IID SDL_IID_IMMNotificationClient = { 0x7991eec9, 0x7e89, 0x4d85,{ 0x83, 0x90, 0x6c, 0x70, 0x3c, 0xec, 0x60, 0xc0 } }; | ||||||
| @@ -48,13 +49,13 @@ static const PROPERTYKEY SDL_PKEY_AudioEngine_DeviceFormat = { { 0xf19f064d, 0x8 | |||||||
| static const PROPERTYKEY SDL_PKEY_AudioEndpoint_GUID = { { 0x1da5d803, 0xd492, 0x4edd,{ 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, } }, 4 }; | static const PROPERTYKEY SDL_PKEY_AudioEndpoint_GUID = { { 0x1da5d803, 0xd492, 0x4edd,{ 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, } }, 4 }; | ||||||
| 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 } }; | ||||||
|  | /* *INDENT-ON* */ /* clang-format on */ | ||||||
|  |  | ||||||
| /* these increment as default devices change. Opened default devices pick up changes in their threads. */ | /* these increment as default devices change. Opened default devices pick up changes in their threads. */ | ||||||
| SDL_atomic_t SDL_IMMDevice_DefaultPlaybackGeneration; | SDL_atomic_t SDL_IMMDevice_DefaultPlaybackGeneration; | ||||||
| SDL_atomic_t SDL_IMMDevice_DefaultCaptureGeneration; | SDL_atomic_t SDL_IMMDevice_DefaultCaptureGeneration; | ||||||
|  |  | ||||||
| static void | static void GetMMDeviceInfo(IMMDevice *device, char **utf8dev, WAVEFORMATEXTENSIBLE *fmt, GUID *guid) | ||||||
| GetMMDeviceInfo(IMMDevice *device, char **utf8dev, WAVEFORMATEXTENSIBLE *fmt, GUID *guid) |  | ||||||
| { | { | ||||||
|     /* PKEY_Device_FriendlyName gives you "Speakers (SoundBlaster Pro)" which drives me nuts. I'd rather it be |     /* PKEY_Device_FriendlyName gives you "Speakers (SoundBlaster Pro)" which drives me nuts. I'd rather it be | ||||||
|        "SoundBlaster Pro (Speakers)" but I guess that's developers vs users. Windows uses the FriendlyName in |        "SoundBlaster Pro (Speakers)" but I guess that's developers vs users. Windows uses the FriendlyName in | ||||||
| @@ -91,8 +92,7 @@ typedef struct DevIdList | |||||||
|  |  | ||||||
| static DevIdList *deviceid_list = NULL; | static DevIdList *deviceid_list = NULL; | ||||||
|  |  | ||||||
| static void | static void SDL_IMMDevice_Remove(const SDL_bool iscapture, LPCWSTR devid, SDL_bool useguid) | ||||||
| SDL_IMMDevice_Remove(const SDL_bool iscapture, LPCWSTR devid, SDL_bool useguid) |  | ||||||
| { | { | ||||||
|     DevIdList *i; |     DevIdList *i; | ||||||
|     DevIdList *next; |     DevIdList *next; | ||||||
| @@ -114,8 +114,7 @@ SDL_IMMDevice_Remove(const SDL_bool iscapture, LPCWSTR devid, SDL_bool useguid) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_IMMDevice_Add(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid, GUID *dsoundguid, SDL_bool useguid) | ||||||
| SDL_IMMDevice_Add(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid, GUID *dsoundguid, SDL_bool useguid) |  | ||||||
| { | { | ||||||
|     DevIdList *devidlist; |     DevIdList *devidlist; | ||||||
|     SDL_AudioSpec spec; |     SDL_AudioSpec spec; | ||||||
| @@ -185,8 +184,7 @@ typedef struct SDLMMNotificationClient | |||||||
|     SDL_bool useguid; |     SDL_bool useguid; | ||||||
| } SDLMMNotificationClient; | } SDLMMNotificationClient; | ||||||
|  |  | ||||||
| static HRESULT STDMETHODCALLTYPE | static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_QueryInterface(IMMNotificationClient *this, REFIID iid, void **ppv) | ||||||
| SDLMMNotificationClient_QueryInterface(IMMNotificationClient *this, REFIID iid, void **ppv) |  | ||||||
| { | { | ||||||
|     if ((WIN_IsEqualIID(iid, &IID_IUnknown)) || (WIN_IsEqualIID(iid, &SDL_IID_IMMNotificationClient))) { |     if ((WIN_IsEqualIID(iid, &IID_IUnknown)) || (WIN_IsEqualIID(iid, &SDL_IID_IMMNotificationClient))) { | ||||||
|         *ppv = this; |         *ppv = this; | ||||||
| @@ -198,15 +196,13 @@ SDLMMNotificationClient_QueryInterface(IMMNotificationClient *this, REFIID iid, | |||||||
|     return E_NOINTERFACE; |     return E_NOINTERFACE; | ||||||
| } | } | ||||||
|  |  | ||||||
| static ULONG STDMETHODCALLTYPE | static ULONG STDMETHODCALLTYPE SDLMMNotificationClient_AddRef(IMMNotificationClient *ithis) | ||||||
| SDLMMNotificationClient_AddRef(IMMNotificationClient *ithis) |  | ||||||
| { | { | ||||||
|     SDLMMNotificationClient *this = (SDLMMNotificationClient *)ithis; |     SDLMMNotificationClient *this = (SDLMMNotificationClient *)ithis; | ||||||
|     return (ULONG)(SDL_AtomicIncRef(&this->refcount) + 1); |     return (ULONG)(SDL_AtomicIncRef(&this->refcount) + 1); | ||||||
| } | } | ||||||
|  |  | ||||||
| static ULONG STDMETHODCALLTYPE | static ULONG STDMETHODCALLTYPE SDLMMNotificationClient_Release(IMMNotificationClient *ithis) | ||||||
| SDLMMNotificationClient_Release(IMMNotificationClient *ithis) |  | ||||||
| { | { | ||||||
|     /* this is a static object; we don't ever free it. */ |     /* this is a static object; we don't ever free it. */ | ||||||
|     SDLMMNotificationClient *this = (SDLMMNotificationClient *)ithis; |     SDLMMNotificationClient *this = (SDLMMNotificationClient *)ithis; | ||||||
| @@ -219,8 +215,7 @@ SDLMMNotificationClient_Release(IMMNotificationClient *ithis) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* These are the entry points called when WASAPI device endpoints change. */ | /* These are the entry points called when WASAPI device endpoints change. */ | ||||||
| static HRESULT STDMETHODCALLTYPE | static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDefaultDeviceChanged(IMMNotificationClient *ithis, EDataFlow flow, ERole role, LPCWSTR pwstrDeviceId) | ||||||
| SDLMMNotificationClient_OnDefaultDeviceChanged(IMMNotificationClient *ithis, EDataFlow flow, ERole role, LPCWSTR pwstrDeviceId) |  | ||||||
| { | { | ||||||
|     if (role != SDL_IMMDevice_role) { |     if (role != SDL_IMMDevice_role) { | ||||||
|         return S_OK; /* ignore it. */ |         return S_OK; /* ignore it. */ | ||||||
| @@ -249,8 +244,7 @@ SDLMMNotificationClient_OnDefaultDeviceChanged(IMMNotificationClient *ithis, EDa | |||||||
|     return S_OK; |     return S_OK; | ||||||
| } | } | ||||||
|  |  | ||||||
| static HRESULT STDMETHODCALLTYPE | static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDeviceAdded(IMMNotificationClient *ithis, LPCWSTR pwstrDeviceId) | ||||||
| SDLMMNotificationClient_OnDeviceAdded(IMMNotificationClient *ithis, LPCWSTR pwstrDeviceId) |  | ||||||
| { | { | ||||||
|     /* we ignore this; devices added here then progress to ACTIVE, if appropriate, in |     /* we ignore this; devices added here then progress to ACTIVE, if appropriate, in | ||||||
|        OnDeviceStateChange, making that a better place to deal with device adds. More |        OnDeviceStateChange, making that a better place to deal with device adds. More | ||||||
| @@ -260,15 +254,13 @@ SDLMMNotificationClient_OnDeviceAdded(IMMNotificationClient *ithis, LPCWSTR pwst | |||||||
|     return S_OK; |     return S_OK; | ||||||
| } | } | ||||||
|  |  | ||||||
| static HRESULT STDMETHODCALLTYPE | static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDeviceRemoved(IMMNotificationClient *ithis, LPCWSTR pwstrDeviceId) | ||||||
| SDLMMNotificationClient_OnDeviceRemoved(IMMNotificationClient *ithis, LPCWSTR pwstrDeviceId) |  | ||||||
| { | { | ||||||
|     /* See notes in OnDeviceAdded handler about why we ignore this. */ |     /* See notes in OnDeviceAdded handler about why we ignore this. */ | ||||||
|     return S_OK; |     return S_OK; | ||||||
| } | } | ||||||
|  |  | ||||||
| static HRESULT STDMETHODCALLTYPE | static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDeviceStateChanged(IMMNotificationClient *ithis, LPCWSTR pwstrDeviceId, DWORD dwNewState) | ||||||
| SDLMMNotificationClient_OnDeviceStateChanged(IMMNotificationClient *ithis, LPCWSTR pwstrDeviceId, DWORD dwNewState) |  | ||||||
| { | { | ||||||
|     IMMDevice *device = NULL; |     IMMDevice *device = NULL; | ||||||
|  |  | ||||||
| @@ -300,8 +292,7 @@ SDLMMNotificationClient_OnDeviceStateChanged(IMMNotificationClient *ithis, LPCWS | |||||||
|     return S_OK; |     return S_OK; | ||||||
| } | } | ||||||
|  |  | ||||||
| static HRESULT STDMETHODCALLTYPE | static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnPropertyValueChanged(IMMNotificationClient *this, LPCWSTR pwstrDeviceId, const PROPERTYKEY key) | ||||||
| SDLMMNotificationClient_OnPropertyValueChanged(IMMNotificationClient *this, LPCWSTR pwstrDeviceId, const PROPERTYKEY key) |  | ||||||
| { | { | ||||||
|     return S_OK; /* we don't care about these. */ |     return S_OK; /* we don't care about these. */ | ||||||
| } | } | ||||||
| @@ -319,8 +310,7 @@ static const IMMNotificationClientVtbl notification_client_vtbl = { | |||||||
|  |  | ||||||
| static SDLMMNotificationClient notification_client = { ¬ification_client_vtbl, { 1 } }; | static SDLMMNotificationClient notification_client = { ¬ification_client_vtbl, { 1 } }; | ||||||
|  |  | ||||||
| int | int SDL_IMMDevice_Init(void) | ||||||
| SDL_IMMDevice_Init(void) |  | ||||||
| { | { | ||||||
|     HRESULT ret; |     HRESULT ret; | ||||||
|  |  | ||||||
| @@ -344,8 +334,7 @@ SDL_IMMDevice_Init(void) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_IMMDevice_Quit(void) | ||||||
| SDL_IMMDevice_Quit(void) |  | ||||||
| { | { | ||||||
|     DevIdList *devidlist; |     DevIdList *devidlist; | ||||||
|     DevIdList *next; |     DevIdList *next; | ||||||
| @@ -366,8 +355,7 @@ SDL_IMMDevice_Quit(void) | |||||||
|     deviceid_list = NULL; |     deviceid_list = NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_IMMDevice_Get(LPCWSTR devid, IMMDevice **device, SDL_bool iscapture) | ||||||
| SDL_IMMDevice_Get(LPCWSTR devid, IMMDevice **device, SDL_bool iscapture) |  | ||||||
| { | { | ||||||
|     HRESULT ret; |     HRESULT ret; | ||||||
|  |  | ||||||
| @@ -422,8 +410,7 @@ static int SDLCALL sort_endpoints(const void *_a, const void *_b) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void EnumerateEndpointsForFlow(const SDL_bool iscapture) | ||||||
| EnumerateEndpointsForFlow(const SDL_bool iscapture) |  | ||||||
| { | { | ||||||
|     IMMDeviceCollection *collection = NULL; |     IMMDeviceCollection *collection = NULL; | ||||||
|     EndpointItem *items; |     EndpointItem *items; | ||||||
| @@ -474,8 +461,7 @@ EnumerateEndpointsForFlow(const SDL_bool iscapture) | |||||||
|     IMMDeviceCollection_Release(collection); |     IMMDeviceCollection_Release(collection); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_IMMDevice_EnumerateEndpoints(SDL_bool useguid) | ||||||
| SDL_IMMDevice_EnumerateEndpoints(SDL_bool useguid) |  | ||||||
| { | { | ||||||
|     notification_client.useguid = useguid; |     notification_client.useguid = useguid; | ||||||
|  |  | ||||||
| @@ -486,8 +472,7 @@ SDL_IMMDevice_EnumerateEndpoints(SDL_bool useguid) | |||||||
|     IMMDeviceEnumerator_RegisterEndpointNotificationCallback(enumerator, (IMMNotificationClient *)¬ification_client); |     IMMDeviceEnumerator_RegisterEndpointNotificationCallback(enumerator, (IMMNotificationClient *)¬ification_client); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_IMMDevice_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) | ||||||
| SDL_IMMDevice_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) |  | ||||||
| { | { | ||||||
|     WAVEFORMATEXTENSIBLE fmt; |     WAVEFORMATEXTENSIBLE fmt; | ||||||
|     IMMDevice *device = NULL; |     IMMDevice *device = NULL; | ||||||
|   | |||||||
| @@ -30,7 +30,8 @@ | |||||||
| #if defined(HAVE_ROAPI_H) | #if defined(HAVE_ROAPI_H) | ||||||
| #include <roapi.h> /* For RoInitialize/RoUninitialize (Win32 only) */ | #include <roapi.h> /* For RoInitialize/RoUninitialize (Win32 only) */ | ||||||
| #else | #else | ||||||
| typedef enum RO_INIT_TYPE { | typedef enum RO_INIT_TYPE | ||||||
|  | { | ||||||
|     RO_INIT_SINGLETHREADED = 0, |     RO_INIT_SINGLETHREADED = 0, | ||||||
|     RO_INIT_MULTITHREADED = 1 |     RO_INIT_MULTITHREADED = 1 | ||||||
| } RO_INIT_TYPE; | } RO_INIT_TYPE; | ||||||
| @@ -50,10 +51,8 @@ typedef enum RO_INIT_TYPE { | |||||||
| #define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 | #define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Sets an error message based on an HRESULT */ | /* Sets an error message based on an HRESULT */ | ||||||
| int | int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr) | ||||||
| WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr) |  | ||||||
| { | { | ||||||
|     TCHAR buffer[1024]; |     TCHAR buffer[1024]; | ||||||
|     char *message; |     char *message; | ||||||
| @@ -76,8 +75,7 @@ WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* Sets an error message based on GetLastError() */ | /* Sets an error message based on GetLastError() */ | ||||||
| int | int WIN_SetError(const char *prefix) | ||||||
| WIN_SetError(const char *prefix) |  | ||||||
| { | { | ||||||
|     return WIN_SetErrorFromHRESULT(prefix, GetLastError()); |     return WIN_SetErrorFromHRESULT(prefix, GetLastError()); | ||||||
| } | } | ||||||
| @@ -116,8 +114,7 @@ WIN_CoInitialize(void) | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WIN_CoUninitialize(void) | ||||||
| WIN_CoUninitialize(void) |  | ||||||
| { | { | ||||||
| #ifndef __WINRT__ | #ifndef __WINRT__ | ||||||
|     CoUninitialize(); |     CoUninitialize(); | ||||||
| @@ -171,8 +168,7 @@ WIN_RoInitialize(void) | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WIN_RoUninitialize(void) | ||||||
| WIN_RoUninitialize(void) |  | ||||||
| { | { | ||||||
| #ifndef __WINRT__ | #ifndef __WINRT__ | ||||||
|     typedef void(WINAPI * RoUninitialize_t)(void); |     typedef void(WINAPI * RoUninitialize_t)(void); | ||||||
| @@ -184,8 +180,7 @@ WIN_RoUninitialize(void) | |||||||
| } | } | ||||||
|  |  | ||||||
| #if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) | #if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) | ||||||
| static BOOL | static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) | ||||||
| IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) |  | ||||||
| { | { | ||||||
|     OSVERSIONINFOEXW osvi; |     OSVERSIONINFOEXW osvi; | ||||||
|     DWORDLONG const dwlConditionMask = VerSetConditionMask( |     DWORDLONG const dwlConditionMask = VerSetConditionMask( | ||||||
| @@ -312,20 +307,17 @@ WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) | |||||||
| #endif /* if __WINRT__ / else */ | #endif /* if __WINRT__ / else */ | ||||||
| } | } | ||||||
|  |  | ||||||
| BOOL | BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b) | ||||||
| WIN_IsEqualGUID(const GUID * a, const GUID * b) |  | ||||||
| { | { | ||||||
|     return SDL_memcmp(a, b, sizeof(*a)) == 0; |     return SDL_memcmp(a, b, sizeof(*a)) == 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| BOOL | BOOL WIN_IsEqualIID(REFIID a, REFIID b) | ||||||
| WIN_IsEqualIID(REFIID a, REFIID b) |  | ||||||
| { | { | ||||||
|     return SDL_memcmp(a, b, sizeof(*a)) == 0; |     return SDL_memcmp(a, b, sizeof(*a)) == 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect) | ||||||
| WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect) |  | ||||||
| { | { | ||||||
|     sdlrect->x = winrect->left; |     sdlrect->x = winrect->left; | ||||||
|     sdlrect->w = (winrect->right - winrect->left) + 1; |     sdlrect->w = (winrect->right - winrect->left) + 1; | ||||||
| @@ -333,8 +325,7 @@ WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect) | |||||||
|     sdlrect->h = (winrect->bottom - winrect->top) + 1; |     sdlrect->h = (winrect->bottom - winrect->top) + 1; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect) | ||||||
| WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect) |  | ||||||
| { | { | ||||||
|     winrect->left = sdlrect->x; |     winrect->left = sdlrect->x; | ||||||
|     winrect->right = sdlrect->x + sdlrect->w - 1; |     winrect->right = sdlrect->x + sdlrect->w - 1; | ||||||
| @@ -344,15 +335,13 @@ WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect) | |||||||
|  |  | ||||||
| #endif /* defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) */ | #endif /* defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) */ | ||||||
|  |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Public APIs |  * Public APIs | ||||||
|  */ |  */ | ||||||
| #if !defined(SDL_VIDEO_DRIVER_WINDOWS) | #if !defined(SDL_VIDEO_DRIVER_WINDOWS) | ||||||
|  |  | ||||||
| #if defined(__WIN32__) || defined(__GDK__) | #if defined(__WIN32__) || defined(__GDK__) | ||||||
| int | int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) | ||||||
| SDL_RegisterApp(const char *name, Uint32 style, void *hInst) |  | ||||||
| { | { | ||||||
|     (void)name; |     (void)name; | ||||||
|     (void)style; |     (void)style; | ||||||
| @@ -360,8 +349,7 @@ SDL_RegisterApp(const char *name, Uint32 style, void *hInst) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_UnregisterApp(void) | ||||||
| SDL_UnregisterApp(void) |  | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -371,8 +359,7 @@ void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata) | |||||||
| #endif /* __WIN32__ || __GDK__ */ | #endif /* __WIN32__ || __GDK__ */ | ||||||
|  |  | ||||||
| #if defined(__WIN32__) || defined(__WINGDK__) | #if defined(__WIN32__) || defined(__WINGDK__) | ||||||
| int | int SDL_Direct3D9GetAdapterIndex(int displayIndex) | ||||||
| SDL_Direct3D9GetAdapterIndex(int displayIndex) |  | ||||||
| { | { | ||||||
|     (void)displayIndex; |     (void)displayIndex; | ||||||
|     return 0; /* D3DADAPTER_DEFAULT */ |     return 0; /* D3DADAPTER_DEFAULT */ | ||||||
|   | |||||||
| @@ -36,11 +36,9 @@ DWORD SDL_XInputVersion = 0; | |||||||
| static HANDLE s_pXInputDLL = 0; | static HANDLE s_pXInputDLL = 0; | ||||||
| static int s_XInputDLLRefCount = 0; | static int s_XInputDLLRefCount = 0; | ||||||
|  |  | ||||||
|  |  | ||||||
| #if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) | #if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) | ||||||
|  |  | ||||||
| int | int WIN_LoadXInputDLL(void) | ||||||
| WIN_LoadXInputDLL(void) |  | ||||||
| { | { | ||||||
|     /* Getting handles to system dlls (via LoadLibrary and its variants) is not |     /* Getting handles to system dlls (via LoadLibrary and its variants) is not | ||||||
|      * supported on WinRT, thus, pointers to XInput's functions can't be |      * supported on WinRT, thus, pointers to XInput's functions can't be | ||||||
| @@ -65,15 +63,13 @@ WIN_LoadXInputDLL(void) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WIN_UnloadXInputDLL(void) | ||||||
| WIN_UnloadXInputDLL(void) |  | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
| #else /* !(defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)) */ | #else /* !(defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)) */ | ||||||
|  |  | ||||||
| int | int WIN_LoadXInputDLL(void) | ||||||
| WIN_LoadXInputDLL(void) |  | ||||||
| { | { | ||||||
|     DWORD version = 0; |     DWORD version = 0; | ||||||
|  |  | ||||||
| @@ -124,8 +120,7 @@ WIN_LoadXInputDLL(void) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void WIN_UnloadXInputDLL(void) | ||||||
| WIN_UnloadXInputDLL(void) |  | ||||||
| { | { | ||||||
|     if (s_pXInputDLL) { |     if (s_pXInputDLL) { | ||||||
|         SDL_assert(s_XInputDLLRefCount > 0); |         SDL_assert(s_XInputDLLRefCount > 0); | ||||||
|   | |||||||
| @@ -222,31 +222,26 @@ typedef struct | |||||||
| #endif /* HAVE_XINPUT_H */ | #endif /* HAVE_XINPUT_H */ | ||||||
|  |  | ||||||
| /* Forward decl's for XInput API's we load dynamically and use if available */ | /* Forward decl's for XInput API's we load dynamically and use if available */ | ||||||
| typedef DWORD (WINAPI *XInputGetState_t) | typedef DWORD(WINAPI *XInputGetState_t)( | ||||||
|     ( |  | ||||||
|     DWORD dwUserIndex,      /* [in] Index of the gamer associated with the device */ |     DWORD dwUserIndex,      /* [in] Index of the gamer associated with the device */ | ||||||
|     XINPUT_STATE_EX *pState /* [out] Receives the current state */ |     XINPUT_STATE_EX *pState /* [out] Receives the current state */ | ||||||
| ); | ); | ||||||
|  |  | ||||||
| typedef DWORD (WINAPI *XInputSetState_t) | typedef DWORD(WINAPI *XInputSetState_t)( | ||||||
|     ( |  | ||||||
|     DWORD dwUserIndex,           /* [in] Index of the gamer associated with the device */ |     DWORD dwUserIndex,           /* [in] Index of the gamer associated with the device */ | ||||||
|     XINPUT_VIBRATION *pVibration /* [in, out] The vibration information to send to the controller */ |     XINPUT_VIBRATION *pVibration /* [in, out] The vibration information to send to the controller */ | ||||||
| ); | ); | ||||||
|  |  | ||||||
| typedef DWORD (WINAPI *XInputGetCapabilities_t) | typedef DWORD(WINAPI *XInputGetCapabilities_t)( | ||||||
|     ( |  | ||||||
|     DWORD dwUserIndex,                 /* [in] Index of the gamer associated with the device */ |     DWORD dwUserIndex,                 /* [in] Index of the gamer associated with the device */ | ||||||
|     DWORD dwFlags,                     /* [in] Input flags that identify the device type */ |     DWORD dwFlags,                     /* [in] Input flags that identify the device type */ | ||||||
|     XINPUT_CAPABILITIES *pCapabilities /* [out] Receives the capabilities */ |     XINPUT_CAPABILITIES *pCapabilities /* [out] Receives the capabilities */ | ||||||
| ); | ); | ||||||
|  |  | ||||||
| typedef DWORD (WINAPI *XInputGetBatteryInformation_t) | typedef DWORD(WINAPI *XInputGetBatteryInformation_t)( | ||||||
|     ( |  | ||||||
|     DWORD dwUserIndex, |     DWORD dwUserIndex, | ||||||
|     BYTE devType, |     BYTE devType, | ||||||
|     XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation |     XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation); | ||||||
|     ); |  | ||||||
|  |  | ||||||
| extern int WIN_LoadXInputDLL(void); | extern int WIN_LoadXInputDLL(void); | ||||||
| extern void WIN_UnloadXInputDLL(void); | extern void WIN_UnloadXInputDLL(void); | ||||||
|   | |||||||
| @@ -42,7 +42,6 @@ SDL_WinRTRunApp(SDL_main_func mainFunction, void * xamlBackgroundPanel) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| extern "C" DECLSPEC SDL_WinRT_DeviceFamily | extern "C" DECLSPEC SDL_WinRT_DeviceFamily | ||||||
| SDL_WinRTGetDeviceFamily() | SDL_WinRTGetDeviceFamily() | ||||||
| { | { | ||||||
|   | |||||||
| @@ -26,7 +26,6 @@ | |||||||
| #include <sstream> | #include <sstream> | ||||||
| using namespace std; | using namespace std; | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Windows includes */ | /* Windows includes */ | ||||||
| #include "ppltasks.h" | #include "ppltasks.h" | ||||||
| using namespace concurrency; | using namespace concurrency; | ||||||
| @@ -44,7 +43,6 @@ using namespace Windows::UI::Input; | |||||||
| using namespace Windows::Phone::UI::Input; | using namespace Windows::Phone::UI::Input; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| /* SDL includes */ | /* SDL includes */ | ||||||
| extern "C" { | extern "C" { | ||||||
| #include "SDL_events.h" | #include "SDL_events.h" | ||||||
| @@ -74,14 +72,12 @@ extern "C" { | |||||||
| extern "C" void D3D11_Trim(SDL_Renderer *); | extern "C" void D3D11_Trim(SDL_Renderer *); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| // Compile-time debugging options: | // Compile-time debugging options: | ||||||
| // To enable, uncomment; to disable, comment them out. | // To enable, uncomment; to disable, comment them out. | ||||||
| //#define LOG_POINTER_EVENTS 1 | //#define LOG_POINTER_EVENTS 1 | ||||||
| //#define LOG_WINDOW_EVENTS 1 | //#define LOG_WINDOW_EVENTS 1 | ||||||
| //#define LOG_ORIENTATION_EVENTS 1 | //#define LOG_ORIENTATION_EVENTS 1 | ||||||
|  |  | ||||||
|  |  | ||||||
| // HACK, DLudwig: record a reference to the global, WinRT 'app'/view. | // HACK, DLudwig: record a reference to the global, WinRT 'app'/view. | ||||||
| // SDL/WinRT will use this throughout its code. | // SDL/WinRT will use this throughout its code. | ||||||
| // | // | ||||||
| @@ -118,8 +114,7 @@ int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **)) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identifying thing into WINRT_ProcessWindowSizeChange() | ||||||
| WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identifying thing into WINRT_ProcessWindowSizeChange() |  | ||||||
| { | { | ||||||
|     CoreWindow ^ coreWindow = CoreWindow::GetForCurrentThread(); |     CoreWindow ^ coreWindow = CoreWindow::GetForCurrentThread(); | ||||||
|     if (coreWindow) { |     if (coreWindow) { | ||||||
| @@ -145,7 +140,8 @@ WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identifying thing in | |||||||
|             const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation); |             const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation); | ||||||
|             switch (currentOrientation) { |             switch (currentOrientation) { | ||||||
|             case DisplayOrientations::Landscape: |             case DisplayOrientations::Landscape: | ||||||
|                 case DisplayOrientations::LandscapeFlipped: { |             case DisplayOrientations::LandscapeFlipped: | ||||||
|  |             { | ||||||
|                 int tmp = w; |                 int tmp = w; | ||||||
|                 w = h; |                 w = h; | ||||||
|                 h = tmp; |                 h = tmp; | ||||||
| @@ -170,8 +166,7 @@ WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identifying thing in | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| SDL_WinRTApp::SDL_WinRTApp() : | SDL_WinRTApp::SDL_WinRTApp() : m_windowClosed(false), | ||||||
|     m_windowClosed(false), |  | ||||||
|                                m_windowVisible(true) |                                m_windowVisible(true) | ||||||
| { | { | ||||||
| } | } | ||||||
| @@ -198,8 +193,7 @@ void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView) | |||||||
|     */ |     */ | ||||||
|     Windows::Gaming::Input::Gamepad::GamepadAdded += |     Windows::Gaming::Input::Gamepad::GamepadAdded += | ||||||
|         ref new Windows::Foundation::EventHandler<Windows::Gaming::Input::Gamepad ^>( |         ref new Windows::Foundation::EventHandler<Windows::Gaming::Input::Gamepad ^>( | ||||||
|             this, &SDL_WinRTApp::OnGamepadAdded |             this, &SDL_WinRTApp::OnGamepadAdded); | ||||||
|         ); |  | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -252,7 +246,6 @@ void SDL_WinRTApp::OnOrientationChanged(Object^ sender) | |||||||
|         SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_SIZE_CHANGED, w, h); |         SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_SIZE_CHANGED, w, h); | ||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void SDL_WinRTApp::SetWindow(CoreWindow ^ window) | void SDL_WinRTApp::SetWindow(CoreWindow ^ window) | ||||||
| @@ -340,8 +333,7 @@ void SDL_WinRTApp::SetWindow(CoreWindow^ window) | |||||||
|     // to be done for network-enabled apps, as per Windows Store requirements. |     // to be done for network-enabled apps, as per Windows Store requirements. | ||||||
|     using namespace Windows::UI::ApplicationSettings; |     using namespace Windows::UI::ApplicationSettings; | ||||||
|     SettingsPane::GetForCurrentView()->CommandsRequested += |     SettingsPane::GetForCurrentView()->CommandsRequested += | ||||||
|         ref new TypedEventHandler<SettingsPane^, SettingsPaneCommandsRequestedEventArgs^> |         ref new TypedEventHandler<SettingsPane ^, SettingsPaneCommandsRequestedEventArgs ^>(this, &SDL_WinRTApp::OnSettingsPaneCommandsRequested); | ||||||
|             (this, &SDL_WinRTApp::OnSettingsPaneCommandsRequested); |  | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -624,8 +616,7 @@ void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ a | |||||||
|     SDL_SendAppEvent(SDL_APP_WILLENTERBACKGROUND); |     SDL_SendAppEvent(SDL_APP_WILLENTERBACKGROUND); | ||||||
|  |  | ||||||
|     SuspendingDeferral ^ deferral = args->SuspendingOperation->GetDeferral(); |     SuspendingDeferral ^ deferral = args->SuspendingOperation->GetDeferral(); | ||||||
|     create_task([this, deferral]() |     create_task([this, deferral]() { | ||||||
|     { |  | ||||||
|         // Send an app did-enter-background event immediately to observers. |         // Send an app did-enter-background event immediately to observers. | ||||||
|         // CoreDispatcher::ProcessEvents, which is the backbone on which |         // CoreDispatcher::ProcessEvents, which is the backbone on which | ||||||
|         // SDL_WinRTApp::PumpEvents is built, will not return to its caller |         // SDL_WinRTApp::PumpEvents is built, will not return to its caller | ||||||
| @@ -665,8 +656,7 @@ void SDL_WinRTApp::OnExiting(Platform::Object^ sender, Platform::Object^ args) | |||||||
|     SDL_SendAppEvent(SDL_APP_TERMINATING); |     SDL_SendAppEvent(SDL_APP_TERMINATING); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void WINRT_LogPointerEvent(const char *header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint) | ||||||
| WINRT_LogPointerEvent(const char * header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint) |  | ||||||
| { | { | ||||||
|     Uint8 button, pressed; |     Uint8 button, pressed; | ||||||
|     Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint; |     Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint; | ||||||
|   | |||||||
| @@ -36,7 +36,8 @@ public: | |||||||
|  |  | ||||||
|     internal : |     internal : | ||||||
|         // SDL-specific methods |         // SDL-specific methods | ||||||
|     void PumpEvents(); |         void | ||||||
|  |         PumpEvents(); | ||||||
|  |  | ||||||
|   protected: |   protected: | ||||||
|     bool ShouldWaitForAppResumeEvents(); |     bool ShouldWaitForAppResumeEvents(); | ||||||
|   | |||||||
| @@ -27,7 +27,6 @@ | |||||||
| #include <windows.ui.xaml.media.dxinterop.h> | #include <windows.ui.xaml.media.dxinterop.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| /* SDL includes */ | /* SDL includes */ | ||||||
| #include "../../SDL_internal.h" | #include "../../SDL_internal.h" | ||||||
| #include "SDL.h" | #include "SDL.h" | ||||||
| @@ -36,70 +35,58 @@ | |||||||
| #include "SDL_winrtapp_common.h" | #include "SDL_winrtapp_common.h" | ||||||
| #include "SDL_winrtapp_xaml.h" | #include "SDL_winrtapp_xaml.h" | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| /* SDL-internal globals: */ | /* SDL-internal globals: */ | ||||||
| SDL_bool WINRT_XAMLWasEnabled = SDL_FALSE; | SDL_bool WINRT_XAMLWasEnabled = SDL_FALSE; | ||||||
|  |  | ||||||
| #if WINAPI_FAMILY == WINAPI_FAMILY_APP | #if WINAPI_FAMILY == WINAPI_FAMILY_APP | ||||||
| extern "C" | extern "C" ISwapChainBackgroundPanelNative *WINRT_GlobalSwapChainBackgroundPanelNative = NULL; | ||||||
| ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative = NULL; |  | ||||||
| static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken; | static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Input event handlers (XAML) |  * Input event handlers (XAML) | ||||||
|  */ |  */ | ||||||
| #if WINAPI_FAMILY == WINAPI_FAMILY_APP | #if WINAPI_FAMILY == WINAPI_FAMILY_APP | ||||||
|  |  | ||||||
| static void | static void WINRT_OnPointerPressedViaXAML(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ args) | ||||||
| WINRT_OnPointerPressedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) |  | ||||||
| { | { | ||||||
|     WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); |     WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void WINRT_OnPointerMovedViaXAML(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ args) | ||||||
| WINRT_OnPointerMovedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) |  | ||||||
| { | { | ||||||
|     WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); |     WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void WINRT_OnPointerReleasedViaXAML(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ args) | ||||||
| WINRT_OnPointerReleasedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) |  | ||||||
| { | { | ||||||
|     WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); |     WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void WINRT_OnPointerWheelChangedViaXAML(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ args) | ||||||
| WINRT_OnPointerWheelChangedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) |  | ||||||
| { | { | ||||||
|     WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); |     WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); | ||||||
| } | } | ||||||
|  |  | ||||||
| #endif // WINAPI_FAMILY == WINAPI_FAMILY_APP | #endif // WINAPI_FAMILY == WINAPI_FAMILY_APP | ||||||
|  |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * XAML-to-SDL Rendering Callback |  * XAML-to-SDL Rendering Callback | ||||||
|  */ |  */ | ||||||
| #if WINAPI_FAMILY == WINAPI_FAMILY_APP | #if WINAPI_FAMILY == WINAPI_FAMILY_APP | ||||||
|  |  | ||||||
| static void | static void WINRT_OnRenderViaXAML(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args) | ||||||
| WINRT_OnRenderViaXAML(_In_ Platform::Object^ sender, _In_ Platform::Object^ args) |  | ||||||
| { | { | ||||||
|     WINRT_CycleXAMLThread(); |     WINRT_CycleXAMLThread(); | ||||||
| } | } | ||||||
|  |  | ||||||
| #endif // WINAPI_FAMILY == WINAPI_FAMILY_APP | #endif // WINAPI_FAMILY == WINAPI_FAMILY_APP | ||||||
|  |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * SDL + XAML Initialization |  * SDL + XAML Initialization | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| int | int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable) | ||||||
| SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void * backgroundPanelAsIInspectable) |  | ||||||
| { | { | ||||||
| #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP | #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP | ||||||
|     return SDL_SetError("XAML support is not yet available in Windows Phone."); |     return SDL_SetError("XAML support is not yet available in Windows Phone."); | ||||||
|   | |||||||
| @@ -128,15 +128,13 @@ | |||||||
|    the idea is borrowed from the libmpeg2 library - thanks! |    the idea is borrowed from the libmpeg2 library - thanks! | ||||||
|  */ |  */ | ||||||
| static jmp_buf jmpbuf; | static jmp_buf jmpbuf; | ||||||
| static void | static void illegal_instruction(int sig) | ||||||
| illegal_instruction(int sig) |  | ||||||
| { | { | ||||||
|     longjmp(jmpbuf, 1); |     longjmp(jmpbuf, 1); | ||||||
| } | } | ||||||
| #endif /* HAVE_SETJMP */ | #endif /* HAVE_SETJMP */ | ||||||
|  |  | ||||||
| static int | static int CPU_haveCPUID(void) | ||||||
| CPU_haveCPUID(void) |  | ||||||
| { | { | ||||||
|     int has_CPUID = 0; |     int has_CPUID = 0; | ||||||
|  |  | ||||||
| @@ -240,8 +238,9 @@ done: | |||||||
|         "        xorl %%ecx,%%ecx   \n"      \ |         "        xorl %%ecx,%%ecx   \n"      \ | ||||||
|         "        cpuid              \n"      \ |         "        cpuid              \n"      \ | ||||||
|         "        movl %%ebx, %%esi  \n"      \ |         "        movl %%ebx, %%esi  \n"      \ | ||||||
| "        popl %%ebx         \n" : \ |         "        popl %%ebx         \n"      \ | ||||||
|             "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (func)) |         : "=a"(a), "=S"(b), "=c"(c), "=d"(d) \ | ||||||
|  |         : "a"(func)) | ||||||
| #elif (defined(__GNUC__) || defined(__llvm__)) && defined(__x86_64__) | #elif (defined(__GNUC__) || defined(__llvm__)) && defined(__x86_64__) | ||||||
| #define cpuid(func, a, b, c, d)              \ | #define cpuid(func, a, b, c, d)              \ | ||||||
|     __asm__ __volatile__(                    \ |     __asm__ __volatile__(                    \ | ||||||
| @@ -249,8 +248,9 @@ done: | |||||||
|         "        xorq %%rcx,%%rcx   \n"      \ |         "        xorq %%rcx,%%rcx   \n"      \ | ||||||
|         "        cpuid              \n"      \ |         "        cpuid              \n"      \ | ||||||
|         "        movq %%rbx, %%rsi  \n"      \ |         "        movq %%rbx, %%rsi  \n"      \ | ||||||
| "        popq %%rbx         \n" : \ |         "        popq %%rbx         \n"      \ | ||||||
|             "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (func)) |         : "=a"(a), "=S"(b), "=c"(c), "=d"(d) \ | ||||||
|  |         : "a"(func)) | ||||||
| #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) | #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) | ||||||
| #define cpuid(func, a, b, c, d) \ | #define cpuid(func, a, b, c, d) \ | ||||||
|     __asm { \ |     __asm { \ | ||||||
| @@ -274,7 +274,13 @@ done: | |||||||
|     } |     } | ||||||
| #else | #else | ||||||
| #define cpuid(func, a, b, c, d) \ | #define cpuid(func, a, b, c, d) \ | ||||||
|     do { a = b = c = d = 0; (void) a; (void) b; (void) c; (void) d; } while (0) |     do {                        \ | ||||||
|  |         a = b = c = d = 0;      \ | ||||||
|  |         (void)a;                \ | ||||||
|  |         (void)b;                \ | ||||||
|  |         (void)c;                \ | ||||||
|  |         (void)d;                \ | ||||||
|  |     } while (0) | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| static int CPU_CPUIDFeatures[4]; | static int CPU_CPUIDFeatures[4]; | ||||||
| @@ -282,8 +288,7 @@ static int CPU_CPUIDMaxFunction = 0; | |||||||
| static SDL_bool CPU_OSSavesYMM = SDL_FALSE; | static SDL_bool CPU_OSSavesYMM = SDL_FALSE; | ||||||
| static SDL_bool CPU_OSSavesZMM = SDL_FALSE; | static SDL_bool CPU_OSSavesZMM = SDL_FALSE; | ||||||
|  |  | ||||||
| static void | static void CPU_calcCPUIDFeatures(void) | ||||||
| CPU_calcCPUIDFeatures(void) |  | ||||||
| { | { | ||||||
|     static SDL_bool checked = SDL_FALSE; |     static SDL_bool checked = SDL_FALSE; | ||||||
|     if (!checked) { |     if (!checked) { | ||||||
| @@ -303,7 +308,10 @@ CPU_calcCPUIDFeatures(void) | |||||||
|                 if (c & 0x08000000) { |                 if (c & 0x08000000) { | ||||||
|                     /* Call xgetbv to see if YMM (etc) register state is saved */ |                     /* Call xgetbv to see if YMM (etc) register state is saved */ | ||||||
| #if (defined(__GNUC__) || defined(__llvm__)) && (defined(__i386__) || defined(__x86_64__)) | #if (defined(__GNUC__) || defined(__llvm__)) && (defined(__i386__) || defined(__x86_64__)) | ||||||
|                     __asm__(".byte 0x0f, 0x01, 0xd0" : "=a" (a) : "c" (0) : "%edx"); |                     __asm__(".byte 0x0f, 0x01, 0xd0" | ||||||
|  |                             : "=a"(a) | ||||||
|  |                             : "c"(0) | ||||||
|  |                             : "%edx"); | ||||||
| #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) && (_MSC_FULL_VER >= 160040219) /* VS2010 SP1 */ | #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) && (_MSC_FULL_VER >= 160040219) /* VS2010 SP1 */ | ||||||
|                     a = (int)_xgetbv(0); |                     a = (int)_xgetbv(0); | ||||||
| #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) | #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) | ||||||
| @@ -322,8 +330,7 @@ CPU_calcCPUIDFeatures(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int CPU_haveAltiVec(void) | ||||||
| CPU_haveAltiVec(void) |  | ||||||
| { | { | ||||||
|     volatile int altivec = 0; |     volatile int altivec = 0; | ||||||
| #ifndef SDL_CPUINFO_DISABLED | #ifndef SDL_CPUINFO_DISABLED | ||||||
| @@ -348,7 +355,8 @@ CPU_haveAltiVec(void) | |||||||
|     void (*handler)(int sig); |     void (*handler)(int sig); | ||||||
|     handler = signal(SIGILL, illegal_instruction); |     handler = signal(SIGILL, illegal_instruction); | ||||||
|     if (setjmp(jmpbuf) == 0) { |     if (setjmp(jmpbuf) == 0) { | ||||||
|         asm volatile ("mtspr 256, %0\n\t" "vand %%v0, %%v0, %%v0"::"r" (-1)); |         asm volatile("mtspr 256, %0\n\t" | ||||||
|  |                      "vand %%v0, %%v0, %%v0" ::"r"(-1)); | ||||||
|         altivec = 1; |         altivec = 1; | ||||||
|     } |     } | ||||||
|     signal(SIGILL, handler); |     signal(SIGILL, handler); | ||||||
| @@ -358,22 +366,19 @@ CPU_haveAltiVec(void) | |||||||
| } | } | ||||||
|  |  | ||||||
| #if (defined(__ARM_ARCH) && (__ARM_ARCH >= 6)) || defined(__aarch64__) | #if (defined(__ARM_ARCH) && (__ARM_ARCH >= 6)) || defined(__aarch64__) | ||||||
| static int | static int CPU_haveARMSIMD(void) | ||||||
| CPU_haveARMSIMD(void) |  | ||||||
| { | { | ||||||
|     return 1; |     return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
| #elif !defined(__arm__) | #elif !defined(__arm__) | ||||||
| static int | static int CPU_haveARMSIMD(void) | ||||||
| CPU_haveARMSIMD(void) |  | ||||||
| { | { | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| #elif defined(__LINUX__) | #elif defined(__LINUX__) | ||||||
| static int | static int CPU_haveARMSIMD(void) | ||||||
| CPU_haveARMSIMD(void) |  | ||||||
| { | { | ||||||
|     int arm_simd = 0; |     int arm_simd = 0; | ||||||
|     int fd; |     int fd; | ||||||
| @@ -396,8 +401,7 @@ CPU_haveARMSIMD(void) | |||||||
| } | } | ||||||
|  |  | ||||||
| #elif defined(__RISCOS__) | #elif defined(__RISCOS__) | ||||||
| static int | static int CPU_haveARMSIMD(void) | ||||||
| CPU_haveARMSIMD(void) |  | ||||||
| { | { | ||||||
|     _kernel_swi_regs regs; |     _kernel_swi_regs regs; | ||||||
|     regs.r[0] = 0; |     regs.r[0] = 0; | ||||||
| @@ -419,8 +423,7 @@ CPU_haveARMSIMD(void) | |||||||
| } | } | ||||||
|  |  | ||||||
| #else | #else | ||||||
| static int | static int CPU_haveARMSIMD(void) | ||||||
| CPU_haveARMSIMD(void) |  | ||||||
| { | { | ||||||
| #warning SDL_HasARMSIMD is not implemented for this ARM platform. Write me. | #warning SDL_HasARMSIMD is not implemented for this ARM platform. Write me. | ||||||
|     return 0; |     return 0; | ||||||
| @@ -428,8 +431,7 @@ CPU_haveARMSIMD(void) | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if defined(__LINUX__) && defined(__arm__) && !defined(HAVE_GETAUXVAL) | #if defined(__LINUX__) && defined(__arm__) && !defined(HAVE_GETAUXVAL) | ||||||
| static int | static int readProcAuxvForNeon(void) | ||||||
| readProcAuxvForNeon(void) |  | ||||||
| { | { | ||||||
|     int neon = 0; |     int neon = 0; | ||||||
|     int fd; |     int fd; | ||||||
| @@ -449,8 +451,7 @@ readProcAuxvForNeon(void) | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| static int | static int CPU_haveNEON(void) | ||||||
| CPU_haveNEON(void) |  | ||||||
| { | { | ||||||
| /* The way you detect NEON is a privileged instruction on ARM, so you have | /* The way you detect NEON is a privileged instruction on ARM, so you have | ||||||
|    query the OS kernel in a platform-specific way. :/ */ |    query the OS kernel in a platform-specific way. :/ */ | ||||||
| @@ -521,16 +522,14 @@ CPU_haveNEON(void) | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int CPU_readCPUCFG(void) | ||||||
| CPU_readCPUCFG(void) |  | ||||||
| { | { | ||||||
|     uint32_t cfg2 = 0; |     uint32_t cfg2 = 0; | ||||||
| #if defined __loongarch__ | #if defined __loongarch__ | ||||||
|     __asm__ volatile( |     __asm__ volatile( | ||||||
|         "cpucfg %0, %1 \n\t" |         "cpucfg %0, %1 \n\t" | ||||||
|         : "+&r"(cfg2) |         : "+&r"(cfg2) | ||||||
|         : "r"(CPU_CFG2) |         : "r"(CPU_CFG2)); | ||||||
|     ); |  | ||||||
| #endif | #endif | ||||||
|     return cfg2; |     return cfg2; | ||||||
| } | } | ||||||
| @@ -549,8 +548,7 @@ CPU_have3DNow(void) | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
| #else | #else | ||||||
| static int | static int CPU_have3DNow(void) | ||||||
| CPU_have3DNow(void) |  | ||||||
| { | { | ||||||
|     if (CPU_CPUIDMaxFunction > 0) { /* that is, do we have CPUID at all? */ |     if (CPU_CPUIDMaxFunction > 0) { /* that is, do we have CPUID at all? */ | ||||||
|         int a, b, c, d; |         int a, b, c, d; | ||||||
| @@ -623,12 +621,14 @@ CPU_haveAVX2(void) | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
| #else | #else | ||||||
| static int | static int CPU_haveAVX2(void) | ||||||
| CPU_haveAVX2(void) |  | ||||||
| { | { | ||||||
|     if (CPU_OSSavesYMM && (CPU_CPUIDMaxFunction >= 7)) { |     if (CPU_OSSavesYMM && (CPU_CPUIDMaxFunction >= 7)) { | ||||||
|         int a, b, c, d; |         int a, b, c, d; | ||||||
|         (void) a; (void) b; (void) c; (void) d;  /* compiler warnings... */ |         (void)a; | ||||||
|  |         (void)b; | ||||||
|  |         (void)c; | ||||||
|  |         (void)d; /* compiler warnings... */ | ||||||
|         cpuid(7, a, b, c, d); |         cpuid(7, a, b, c, d); | ||||||
|         return b & 0x00000020; |         return b & 0x00000020; | ||||||
|     } |     } | ||||||
| @@ -643,12 +643,14 @@ CPU_haveAVX512F(void) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
| #else | #else | ||||||
| static int | static int CPU_haveAVX512F(void) | ||||||
| CPU_haveAVX512F(void) |  | ||||||
| { | { | ||||||
|     if (CPU_OSSavesZMM && (CPU_CPUIDMaxFunction >= 7)) { |     if (CPU_OSSavesZMM && (CPU_CPUIDMaxFunction >= 7)) { | ||||||
|         int a, b, c, d; |         int a, b, c, d; | ||||||
|         (void) a; (void) b; (void) c; (void) d;  /* compiler warnings... */ |         (void)a; | ||||||
|  |         (void)b; | ||||||
|  |         (void)c; | ||||||
|  |         (void)d; /* compiler warnings... */ | ||||||
|         cpuid(7, a, b, c, d); |         cpuid(7, a, b, c, d); | ||||||
|         return b & 0x00010000; |         return b & 0x00010000; | ||||||
|     } |     } | ||||||
| @@ -658,8 +660,7 @@ CPU_haveAVX512F(void) | |||||||
|  |  | ||||||
| static int SDL_CPUCount = 0; | static int SDL_CPUCount = 0; | ||||||
|  |  | ||||||
| int | int SDL_GetCPUCount(void) | ||||||
| SDL_GetCPUCount(void) |  | ||||||
| { | { | ||||||
|     if (!SDL_CPUCount) { |     if (!SDL_CPUCount) { | ||||||
| #ifndef SDL_CPUINFO_DISABLED | #ifndef SDL_CPUINFO_DISABLED | ||||||
| @@ -708,8 +709,7 @@ SDL_GetCPUType(void) | |||||||
| } | } | ||||||
| #else | #else | ||||||
| /* Oh, such a sweet sweet trick, just not very useful. :) */ | /* Oh, such a sweet sweet trick, just not very useful. :) */ | ||||||
| static const char * | static const char *SDL_GetCPUType(void) | ||||||
| SDL_GetCPUType(void) |  | ||||||
| { | { | ||||||
|     static char SDL_CPUType[13]; |     static char SDL_CPUType[13]; | ||||||
|  |  | ||||||
| @@ -721,19 +721,28 @@ SDL_GetCPUType(void) | |||||||
|             int a, b, c, d; |             int a, b, c, d; | ||||||
|             cpuid(0x00000000, a, b, c, d); |             cpuid(0x00000000, a, b, c, d); | ||||||
|             (void)a; |             (void)a; | ||||||
|             SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; |             SDL_CPUType[i++] = (char)(b & 0xff); | ||||||
|             SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; |             b >>= 8; | ||||||
|             SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; |             SDL_CPUType[i++] = (char)(b & 0xff); | ||||||
|  |             b >>= 8; | ||||||
|  |             SDL_CPUType[i++] = (char)(b & 0xff); | ||||||
|  |             b >>= 8; | ||||||
|             SDL_CPUType[i++] = (char)(b & 0xff); |             SDL_CPUType[i++] = (char)(b & 0xff); | ||||||
|  |  | ||||||
|             SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; |             SDL_CPUType[i++] = (char)(d & 0xff); | ||||||
|             SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; |             d >>= 8; | ||||||
|             SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; |             SDL_CPUType[i++] = (char)(d & 0xff); | ||||||
|  |             d >>= 8; | ||||||
|  |             SDL_CPUType[i++] = (char)(d & 0xff); | ||||||
|  |             d >>= 8; | ||||||
|             SDL_CPUType[i++] = (char)(d & 0xff); |             SDL_CPUType[i++] = (char)(d & 0xff); | ||||||
|  |  | ||||||
|             SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; |             SDL_CPUType[i++] = (char)(c & 0xff); | ||||||
|             SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; |             c >>= 8; | ||||||
|             SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; |             SDL_CPUType[i++] = (char)(c & 0xff); | ||||||
|  |             c >>= 8; | ||||||
|  |             SDL_CPUType[i++] = (char)(c & 0xff); | ||||||
|  |             c >>= 8; | ||||||
|             SDL_CPUType[i++] = (char)(c & 0xff); |             SDL_CPUType[i++] = (char)(c & 0xff); | ||||||
|         } |         } | ||||||
|         if (!SDL_CPUType[0]) { |         if (!SDL_CPUType[0]) { | ||||||
| @@ -744,7 +753,6 @@ SDL_GetCPUType(void) | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| #ifdef TEST_MAIN /* !!! FIXME: only used for test at the moment. */ | #ifdef TEST_MAIN /* !!! FIXME: only used for test at the moment. */ | ||||||
| #if defined(__e2k__) | #if defined(__e2k__) | ||||||
| inline const char * | inline const char * | ||||||
| @@ -757,8 +765,7 @@ SDL_GetCPUName(void) | |||||||
|     return SDL_CPUName; |     return SDL_CPUName; | ||||||
| } | } | ||||||
| #else | #else | ||||||
| static const char * | static const char *SDL_GetCPUName(void) | ||||||
| SDL_GetCPUName(void) |  | ||||||
| { | { | ||||||
|     static char SDL_CPUName[48]; |     static char SDL_CPUName[48]; | ||||||
|  |  | ||||||
| @@ -771,56 +778,104 @@ SDL_GetCPUName(void) | |||||||
|             cpuid(0x80000000, a, b, c, d); |             cpuid(0x80000000, a, b, c, d); | ||||||
|             if (a >= 0x80000004) { |             if (a >= 0x80000004) { | ||||||
|                 cpuid(0x80000002, a, b, c, d); |                 cpuid(0x80000002, a, b, c, d); | ||||||
|                 SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; |                 SDL_CPUName[i++] = (char)(a & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; |                 a >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; |                 SDL_CPUName[i++] = (char)(a & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; |                 a >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; |                 SDL_CPUName[i++] = (char)(a & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; |                 a >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; |                 SDL_CPUName[i++] = (char)(a & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; |                 a >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; |                 SDL_CPUName[i++] = (char)(b & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; |                 b >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; |                 SDL_CPUName[i++] = (char)(b & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; |                 b >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; |                 SDL_CPUName[i++] = (char)(b & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; |                 b >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; |                 SDL_CPUName[i++] = (char)(b & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; |                 b >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(c & 0xff); | ||||||
|  |                 c >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(c & 0xff); | ||||||
|  |                 c >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(c & 0xff); | ||||||
|  |                 c >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(c & 0xff); | ||||||
|  |                 c >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(d & 0xff); | ||||||
|  |                 d >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(d & 0xff); | ||||||
|  |                 d >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(d & 0xff); | ||||||
|  |                 d >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(d & 0xff); | ||||||
|  |                 d >>= 8; | ||||||
|                 cpuid(0x80000003, a, b, c, d); |                 cpuid(0x80000003, a, b, c, d); | ||||||
|                 SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; |                 SDL_CPUName[i++] = (char)(a & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; |                 a >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; |                 SDL_CPUName[i++] = (char)(a & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; |                 a >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; |                 SDL_CPUName[i++] = (char)(a & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; |                 a >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; |                 SDL_CPUName[i++] = (char)(a & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; |                 a >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; |                 SDL_CPUName[i++] = (char)(b & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; |                 b >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; |                 SDL_CPUName[i++] = (char)(b & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; |                 b >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; |                 SDL_CPUName[i++] = (char)(b & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; |                 b >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; |                 SDL_CPUName[i++] = (char)(b & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; |                 b >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(c & 0xff); | ||||||
|  |                 c >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(c & 0xff); | ||||||
|  |                 c >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(c & 0xff); | ||||||
|  |                 c >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(c & 0xff); | ||||||
|  |                 c >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(d & 0xff); | ||||||
|  |                 d >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(d & 0xff); | ||||||
|  |                 d >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(d & 0xff); | ||||||
|  |                 d >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(d & 0xff); | ||||||
|  |                 d >>= 8; | ||||||
|                 cpuid(0x80000004, a, b, c, d); |                 cpuid(0x80000004, a, b, c, d); | ||||||
|                 SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; |                 SDL_CPUName[i++] = (char)(a & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; |                 a >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; |                 SDL_CPUName[i++] = (char)(a & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; |                 a >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; |                 SDL_CPUName[i++] = (char)(a & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; |                 a >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; |                 SDL_CPUName[i++] = (char)(a & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; |                 a >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; |                 SDL_CPUName[i++] = (char)(b & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; |                 b >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; |                 SDL_CPUName[i++] = (char)(b & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; |                 b >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; |                 SDL_CPUName[i++] = (char)(b & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; |                 b >>= 8; | ||||||
|                 SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; |                 SDL_CPUName[i++] = (char)(b & 0xff); | ||||||
|                 SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; |                 b >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(c & 0xff); | ||||||
|  |                 c >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(c & 0xff); | ||||||
|  |                 c >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(c & 0xff); | ||||||
|  |                 c >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(c & 0xff); | ||||||
|  |                 c >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(d & 0xff); | ||||||
|  |                 d >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(d & 0xff); | ||||||
|  |                 d >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(d & 0xff); | ||||||
|  |                 d >>= 8; | ||||||
|  |                 SDL_CPUName[i++] = (char)(d & 0xff); | ||||||
|  |                 d >>= 8; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         if (!SDL_CPUName[0]) { |         if (!SDL_CPUName[0]) { | ||||||
| @@ -832,12 +887,14 @@ SDL_GetCPUName(void) | |||||||
| #endif | #endif | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| int | int SDL_GetCPUCacheLineSize(void) | ||||||
| SDL_GetCPUCacheLineSize(void) |  | ||||||
| { | { | ||||||
|     const char *cpuType = SDL_GetCPUType(); |     const char *cpuType = SDL_GetCPUType(); | ||||||
|     int a, b, c, d; |     int a, b, c, d; | ||||||
|     (void) a; (void) b; (void) c; (void) d; |     (void)a; | ||||||
|  |     (void)b; | ||||||
|  |     (void)c; | ||||||
|  |     (void)d; | ||||||
|     if (SDL_strcmp(cpuType, "GenuineIntel") == 0 || SDL_strcmp(cpuType, "CentaurHauls") == 0 || SDL_strcmp(cpuType, "  Shanghai  ") == 0) { |     if (SDL_strcmp(cpuType, "GenuineIntel") == 0 || SDL_strcmp(cpuType, "CentaurHauls") == 0 || SDL_strcmp(cpuType, "  Shanghai  ") == 0) { | ||||||
|         cpuid(0x00000001, a, b, c, d); |         cpuid(0x00000001, a, b, c, d); | ||||||
|         return ((b >> 8) & 0xff) * 8; |         return ((b >> 8) & 0xff) * 8; | ||||||
| @@ -853,8 +910,7 @@ SDL_GetCPUCacheLineSize(void) | |||||||
| static Uint32 SDL_CPUFeatures = 0xFFFFFFFF; | static Uint32 SDL_CPUFeatures = 0xFFFFFFFF; | ||||||
| static Uint32 SDL_SIMDAlignment = 0xFFFFFFFF; | static Uint32 SDL_SIMDAlignment = 0xFFFFFFFF; | ||||||
|  |  | ||||||
| static Uint32 | static Uint32 SDL_GetCPUFeatures(void) | ||||||
| SDL_GetCPUFeatures(void) |  | ||||||
| { | { | ||||||
|     if (SDL_CPUFeatures == 0xFFFFFFFF) { |     if (SDL_CPUFeatures == 0xFFFFFFFF) { | ||||||
|         CPU_calcCPUIDFeatures(); |         CPU_calcCPUIDFeatures(); | ||||||
| @@ -1026,8 +1082,7 @@ SDL_HasLASX(void) | |||||||
|  |  | ||||||
| static int SDL_SystemRAM = 0; | static int SDL_SystemRAM = 0; | ||||||
|  |  | ||||||
| int | int SDL_GetSystemRAM(void) | ||||||
| SDL_GetSystemRAM(void) |  | ||||||
| { | { | ||||||
|     if (!SDL_SystemRAM) { |     if (!SDL_SystemRAM) { | ||||||
| #ifndef SDL_CPUINFO_DISABLED | #ifndef SDL_CPUINFO_DISABLED | ||||||
| @@ -1099,7 +1154,6 @@ SDL_GetSystemRAM(void) | |||||||
|     return SDL_SystemRAM; |     return SDL_SystemRAM; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| size_t | size_t | ||||||
| SDL_SIMDGetAlignment(void) | SDL_SIMDGetAlignment(void) | ||||||
| { | { | ||||||
| @@ -1188,21 +1242,18 @@ SDL_SIMDRealloc(void *mem, const size_t len) | |||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_SIMDFree(void *ptr) | ||||||
| SDL_SIMDFree(void *ptr) |  | ||||||
| { | { | ||||||
|     if (ptr) { |     if (ptr) { | ||||||
|         SDL_free(*(((void **)ptr) - 1)); |         SDL_free(*(((void **)ptr) - 1)); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| #ifdef TEST_MAIN | #ifdef TEST_MAIN | ||||||
|  |  | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
|  |  | ||||||
| int | int main() | ||||||
| main() |  | ||||||
| { | { | ||||||
|     printf("CPU count: %d\n", SDL_GetCPUCount()); |     printf("CPU count: %d\n", SDL_GetCPUCount()); | ||||||
|     printf("CPU type: %s\n", SDL_GetCPUType()); |     printf("CPU type: %s\n", SDL_GetCPUType()); | ||||||
|   | |||||||
| @@ -55,7 +55,6 @@ static void SDL_InitDynamicAPI(void); | |||||||
| /* BE CAREFUL CALLING ANY SDL CODE IN HERE, IT WILL BLOW UP. | /* BE CAREFUL CALLING ANY SDL CODE IN HERE, IT WILL BLOW UP. | ||||||
|    Even self-contained stuff might call SDL_Error and break everything. */ |    Even self-contained stuff might call SDL_Error and break everything. */ | ||||||
|  |  | ||||||
|  |  | ||||||
| /* behold, the macro salsa! */ | /* behold, the macro salsa! */ | ||||||
|  |  | ||||||
| /* !!! FIXME: ...disabled...until we write it.  :) */ | /* !!! FIXME: ...disabled...until we write it.  :) */ | ||||||
| @@ -64,17 +63,22 @@ static void SDL_InitDynamicAPI(void); | |||||||
| #if DISABLE_JUMP_MAGIC | #if DISABLE_JUMP_MAGIC | ||||||
| /* Can't use the macro for varargs nonsense. This is atrocious. */ | /* Can't use the macro for varargs nonsense. This is atrocious. */ | ||||||
| #define SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, logname, prio)                                     \ | #define SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, logname, prio)                                     \ | ||||||
|     _static void SDLCALL SDL_Log##logname##name(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ |     _static void SDLCALL SDL_Log##logname##name(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \ | ||||||
|         va_list ap; initcall; va_start(ap, fmt); \ |     {                                                                                                        \ | ||||||
|  |         va_list ap;                                                                                          \ | ||||||
|  |         initcall;                                                                                            \ | ||||||
|  |         va_start(ap, fmt);                                                                                   \ | ||||||
|         jump_table.SDL_LogMessageV(category, SDL_LOG_PRIORITY_##prio, fmt, ap);                              \ |         jump_table.SDL_LogMessageV(category, SDL_LOG_PRIORITY_##prio, fmt, ap);                              \ | ||||||
|         va_end(ap);                                                                                          \ |         va_end(ap);                                                                                          \ | ||||||
|     } |     } | ||||||
|  |  | ||||||
| #define SDL_DYNAPI_VARARGS(_static, name, initcall)                                                                                       \ | #define SDL_DYNAPI_VARARGS(_static, name, initcall)                                                                                       \ | ||||||
|     _static int SDLCALL SDL_SetError##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ |     _static int SDLCALL SDL_SetError##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)                                                 \ | ||||||
|  |     {                                                                                                                                     \ | ||||||
|         char buf[128], *str = buf;                                                                                                        \ |         char buf[128], *str = buf;                                                                                                        \ | ||||||
|         int result;                                                                                                                       \ |         int result;                                                                                                                       \ | ||||||
|         va_list ap; initcall; \ |         va_list ap;                                                                                                                       \ | ||||||
|  |         initcall;                                                                                                                         \ | ||||||
|         va_start(ap, fmt);                                                                                                                \ |         va_start(ap, fmt);                                                                                                                \ | ||||||
|         result = jump_table.SDL_vsnprintf(buf, sizeof(buf), fmt, ap);                                                                     \ |         result = jump_table.SDL_vsnprintf(buf, sizeof(buf), fmt, ap);                                                                     \ | ||||||
|         va_end(ap);                                                                                                                       \ |         va_end(ap);                                                                                                                       \ | ||||||
| @@ -95,31 +99,49 @@ static void SDL_InitDynamicAPI(void); | |||||||
|         }                                                                                                                                 \ |         }                                                                                                                                 \ | ||||||
|         return result;                                                                                                                    \ |         return result;                                                                                                                    \ | ||||||
|     }                                                                                                                                     \ |     }                                                                                                                                     \ | ||||||
|     _static int SDLCALL SDL_sscanf##name(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...) { \ |     _static int SDLCALL SDL_sscanf##name(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...)                                   \ | ||||||
|         int retval; va_list ap; initcall; va_start(ap, fmt); \ |     {                                                                                                                                     \ | ||||||
|  |         int retval;                                                                                                                       \ | ||||||
|  |         va_list ap;                                                                                                                       \ | ||||||
|  |         initcall;                                                                                                                         \ | ||||||
|  |         va_start(ap, fmt);                                                                                                                \ | ||||||
|         retval = jump_table.SDL_vsscanf(buf, fmt, ap);                                                                                    \ |         retval = jump_table.SDL_vsscanf(buf, fmt, ap);                                                                                    \ | ||||||
|         va_end(ap);                                                                                                                       \ |         va_end(ap);                                                                                                                       \ | ||||||
|         return retval;                                                                                                                    \ |         return retval;                                                                                                                    \ | ||||||
|     }                                                                                                                                     \ |     }                                                                                                                                     \ | ||||||
|     _static int SDLCALL SDL_snprintf##name(SDL_OUT_Z_CAP(maxlen) char *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ |     _static int SDLCALL SDL_snprintf##name(SDL_OUT_Z_CAP(maxlen) char *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \ | ||||||
|         int retval; va_list ap; initcall; va_start(ap, fmt); \ |     {                                                                                                                                     \ | ||||||
|  |         int retval;                                                                                                                       \ | ||||||
|  |         va_list ap;                                                                                                                       \ | ||||||
|  |         initcall;                                                                                                                         \ | ||||||
|  |         va_start(ap, fmt);                                                                                                                \ | ||||||
|         retval = jump_table.SDL_vsnprintf(buf, maxlen, fmt, ap);                                                                          \ |         retval = jump_table.SDL_vsnprintf(buf, maxlen, fmt, ap);                                                                          \ | ||||||
|         va_end(ap);                                                                                                                       \ |         va_end(ap);                                                                                                                       \ | ||||||
|         return retval;                                                                                                                    \ |         return retval;                                                                                                                    \ | ||||||
|     }                                                                                                                                     \ |     }                                                                                                                                     \ | ||||||
|     _static int SDLCALL SDL_asprintf##name(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ |     _static int SDLCALL SDL_asprintf##name(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)                                    \ | ||||||
|         int retval; va_list ap; initcall; va_start(ap, fmt); \ |     {                                                                                                                                     \ | ||||||
|  |         int retval;                                                                                                                       \ | ||||||
|  |         va_list ap;                                                                                                                       \ | ||||||
|  |         initcall;                                                                                                                         \ | ||||||
|  |         va_start(ap, fmt);                                                                                                                \ | ||||||
|         retval = jump_table.SDL_vasprintf(strp, fmt, ap);                                                                                 \ |         retval = jump_table.SDL_vasprintf(strp, fmt, ap);                                                                                 \ | ||||||
|         va_end(ap);                                                                                                                       \ |         va_end(ap);                                                                                                                       \ | ||||||
|         return retval;                                                                                                                    \ |         return retval;                                                                                                                    \ | ||||||
|     }                                                                                                                                     \ |     }                                                                                                                                     \ | ||||||
|     _static void SDLCALL SDL_Log##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ |     _static void SDLCALL SDL_Log##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)                                                     \ | ||||||
|         va_list ap; initcall; va_start(ap, fmt); \ |     {                                                                                                                                     \ | ||||||
|  |         va_list ap;                                                                                                                       \ | ||||||
|  |         initcall;                                                                                                                         \ | ||||||
|  |         va_start(ap, fmt);                                                                                                                \ | ||||||
|         jump_table.SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap);                                         \ |         jump_table.SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap);                                         \ | ||||||
|         va_end(ap);                                                                                                                       \ |         va_end(ap);                                                                                                                       \ | ||||||
|     }                                                                                                                                     \ |     }                                                                                                                                     \ | ||||||
|     _static void SDLCALL SDL_LogMessage##name(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ |     _static void SDLCALL SDL_LogMessage##name(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)      \ | ||||||
|         va_list ap; initcall; va_start(ap, fmt); \ |     {                                                                                                                                     \ | ||||||
|  |         va_list ap;                                                                                                                       \ | ||||||
|  |         initcall;                                                                                                                         \ | ||||||
|  |         va_start(ap, fmt);                                                                                                                \ | ||||||
|         jump_table.SDL_LogMessageV(category, priority, fmt, ap);                                                                          \ |         jump_table.SDL_LogMessageV(category, priority, fmt, ap);                                                                          \ | ||||||
|         va_end(ap);                                                                                                                       \ |         va_end(ap);                                                                                                                       \ | ||||||
|     }                                                                                                                                     \ |     }                                                                                                                                     \ | ||||||
| @@ -131,7 +153,6 @@ static void SDL_InitDynamicAPI(void); | |||||||
|     SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Critical, CRITICAL) |     SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Critical, CRITICAL) | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Typedefs for function pointers for jump table, and predeclare funcs */ | /* Typedefs for function pointers for jump table, and predeclare funcs */ | ||||||
| /* The DEFAULT funcs will init jump table and then call real function. */ | /* The DEFAULT funcs will init jump table and then call real function. */ | ||||||
| /* The REAL funcs are the actual functions, name-mangled to not clash. */ | /* The REAL funcs are the actual functions, name-mangled to not clash. */ | ||||||
| @@ -143,7 +164,8 @@ static void SDL_InitDynamicAPI(void); | |||||||
| #undef SDL_DYNAPI_PROC | #undef SDL_DYNAPI_PROC | ||||||
|  |  | ||||||
| /* The jump table! */ | /* The jump table! */ | ||||||
| typedef struct { | typedef struct | ||||||
|  | { | ||||||
| #define SDL_DYNAPI_PROC(rc, fn, params, args, ret) SDL_DYNAPIFN_##fn fn; | #define SDL_DYNAPI_PROC(rc, fn, params, args, ret) SDL_DYNAPIFN_##fn fn; | ||||||
| #include "SDL_dynapi_procs.h" | #include "SDL_dynapi_procs.h" | ||||||
| #undef SDL_DYNAPI_PROC | #undef SDL_DYNAPI_PROC | ||||||
| @@ -164,7 +186,8 @@ static SDL_DYNAPI_jump_table jump_table = { | |||||||
| /* Default functions init the function table then call right thing. */ | /* Default functions init the function table then call right thing. */ | ||||||
| #if DISABLE_JUMP_MAGIC | #if DISABLE_JUMP_MAGIC | ||||||
| #define SDL_DYNAPI_PROC(rc, fn, params, args, ret) \ | #define SDL_DYNAPI_PROC(rc, fn, params, args, ret) \ | ||||||
|     static rc SDLCALL fn##_DEFAULT params { \ |     static rc SDLCALL fn##_DEFAULT params          \ | ||||||
|  |     {                                              \ | ||||||
|         SDL_InitDynamicAPI();                      \ |         SDL_InitDynamicAPI();                      \ | ||||||
|         ret jump_table.fn args;                    \ |         ret jump_table.fn args;                    \ | ||||||
|     } |     } | ||||||
| @@ -194,8 +217,9 @@ SDL_DYNAPI_VARARGS(,,) | |||||||
|  |  | ||||||
| #define ENABLE_SDL_CALL_LOGGING 0 | #define ENABLE_SDL_CALL_LOGGING 0 | ||||||
| #if ENABLE_SDL_CALL_LOGGING | #if ENABLE_SDL_CALL_LOGGING | ||||||
| static int SDLCALL SDL_SetError_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { | static int SDLCALL SDL_SetError_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) | ||||||
|     char buf[512]; /* !!! FIXME: dynamic allocation */ \ | { | ||||||
|  |     char buf[512]; /* !!! FIXME: dynamic allocation */ | ||||||
|     va_list ap; |     va_list ap; | ||||||
|     SDL_Log_REAL("SDL2CALL SDL_SetError"); |     SDL_Log_REAL("SDL2CALL SDL_SetError"); | ||||||
|     va_start(ap, fmt); |     va_start(ap, fmt); | ||||||
| @@ -203,7 +227,8 @@ static int SDLCALL SDL_SetError_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char | |||||||
|     va_end(ap); |     va_end(ap); | ||||||
|     return SDL_SetError_REAL("%s", buf); |     return SDL_SetError_REAL("%s", buf); | ||||||
| } | } | ||||||
| static int SDLCALL SDL_sscanf_LOGSDLCALLS(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...) { | static int SDLCALL SDL_sscanf_LOGSDLCALLS(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...) | ||||||
|  | { | ||||||
|     int retval; |     int retval; | ||||||
|     va_list ap; |     va_list ap; | ||||||
|     SDL_Log_REAL("SDL2CALL SDL_sscanf"); |     SDL_Log_REAL("SDL2CALL SDL_sscanf"); | ||||||
| @@ -212,7 +237,8 @@ static int SDLCALL SDL_sscanf_LOGSDLCALLS(const char *buf, SDL_SCANF_FORMAT_STRI | |||||||
|     va_end(ap); |     va_end(ap); | ||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
| static int SDLCALL SDL_snprintf_LOGSDLCALLS(SDL_OUT_Z_CAP(maxlen) char *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { | static int SDLCALL SDL_snprintf_LOGSDLCALLS(SDL_OUT_Z_CAP(maxlen) char *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) | ||||||
|  | { | ||||||
|     int retval; |     int retval; | ||||||
|     va_list ap; |     va_list ap; | ||||||
|     SDL_Log_REAL("SDL2CALL SDL_snprintf"); |     SDL_Log_REAL("SDL2CALL SDL_snprintf"); | ||||||
| @@ -221,7 +247,8 @@ static int SDLCALL SDL_snprintf_LOGSDLCALLS(SDL_OUT_Z_CAP(maxlen) char *buf, siz | |||||||
|     va_end(ap); |     va_end(ap); | ||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
| static int SDLCALL SDL_asprintf_LOGSDLCALLS(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { | static int SDLCALL SDL_asprintf_LOGSDLCALLS(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) | ||||||
|  | { | ||||||
|     int retval; |     int retval; | ||||||
|     va_list ap; |     va_list ap; | ||||||
|     SDL_Log_REAL("SDL2CALL SDL_asprintf"); |     SDL_Log_REAL("SDL2CALL SDL_asprintf"); | ||||||
| @@ -230,14 +257,16 @@ static int SDLCALL SDL_asprintf_LOGSDLCALLS(char **strp, SDL_PRINTF_FORMAT_STRIN | |||||||
|     va_end(ap); |     va_end(ap); | ||||||
|     return retval; |     return retval; | ||||||
| } | } | ||||||
| static void SDLCALL SDL_Log_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { | static void SDLCALL SDL_Log_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) | ||||||
|  | { | ||||||
|     va_list ap; |     va_list ap; | ||||||
|     SDL_Log_REAL("SDL2CALL SDL_Log"); |     SDL_Log_REAL("SDL2CALL SDL_Log"); | ||||||
|     va_start(ap, fmt); |     va_start(ap, fmt); | ||||||
|     SDL_LogMessageV_REAL(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); \ |     SDL_LogMessageV_REAL(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); | ||||||
|     va_end(ap); |     va_end(ap); | ||||||
| } | } | ||||||
| static void SDLCALL SDL_LogMessage_LOGSDLCALLS(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { | static void SDLCALL SDL_LogMessage_LOGSDLCALLS(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) | ||||||
|  | { | ||||||
|     va_list ap; |     va_list ap; | ||||||
|     SDL_Log_REAL("SDL2CALL SDL_LogMessage"); |     SDL_Log_REAL("SDL2CALL SDL_LogMessage"); | ||||||
|     va_start(ap, fmt); |     va_start(ap, fmt); | ||||||
| @@ -267,8 +296,7 @@ SDL_DYNAPI_VARARGS_LOGFN_LOGSDLCALLS(Critical, CRITICAL) | |||||||
|  |  | ||||||
| /* we make this a static function so we can call the correct one without the | /* we make this a static function so we can call the correct one without the | ||||||
|    system's dynamic linker resolving to the wrong version of this. */ |    system's dynamic linker resolving to the wrong version of this. */ | ||||||
| static Sint32 | static Sint32 initialize_jumptable(Uint32 apiver, void *table, Uint32 tablesize) | ||||||
| initialize_jumptable(Uint32 apiver, void *table, Uint32 tablesize) |  | ||||||
| { | { | ||||||
|     SDL_DYNAPI_jump_table *output_jump_table = (SDL_DYNAPI_jump_table *)table; |     SDL_DYNAPI_jump_table *output_jump_table = (SDL_DYNAPI_jump_table *)table; | ||||||
|  |  | ||||||
| @@ -310,7 +338,6 @@ initialize_jumptable(Uint32 apiver, void *table, Uint32 tablesize) | |||||||
|     return 0; /* success! */ |     return 0; /* success! */ | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Here's the exported entry point that fills in the jump table. */ | /* Here's the exported entry point that fills in the jump table. */ | ||||||
| /*  Use specific types when an "int" might suffice to keep this sane. */ | /*  Use specific types when an "int" might suffice to keep this sane. */ | ||||||
| typedef Sint32(SDLCALL *SDL_DYNAPI_ENTRYFN)(Uint32 apiver, void *table, Uint32 tablesize); | typedef Sint32(SDLCALL *SDL_DYNAPI_ENTRYFN)(Uint32 apiver, void *table, Uint32 tablesize); | ||||||
| @@ -322,7 +349,6 @@ SDL_DYNAPI_entry(Uint32 apiver, void *table, Uint32 tablesize) | |||||||
|     return initialize_jumptable(apiver, table, tablesize); |     return initialize_jumptable(apiver, table, tablesize); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Obviously we can't use SDL_LoadObject() to load SDL.  :)  */ | /* Obviously we can't use SDL_LoadObject() to load SDL.  :)  */ | ||||||
| /* Also obviously, we never close the loaded library. */ | /* Also obviously, we never close the loaded library. */ | ||||||
| #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) | #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) | ||||||
| @@ -376,7 +402,6 @@ static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym) | |||||||
| #error Please define your platform. | #error Please define your platform. | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| static void dynapi_warn(const char *msg) | static void dynapi_warn(const char *msg) | ||||||
| { | { | ||||||
|     const char *caption = "SDL Dynamic API Failure!"; |     const char *caption = "SDL Dynamic API Failure!"; | ||||||
| @@ -398,9 +423,7 @@ void SDL_ExitProcess(int exitcode); | |||||||
| #endif | #endif | ||||||
| SDL_NORETURN void SDL_ExitProcess(int exitcode); | SDL_NORETURN void SDL_ExitProcess(int exitcode); | ||||||
|  |  | ||||||
|  | static void SDL_InitDynamicAPILocked(void) | ||||||
| static void |  | ||||||
| SDL_InitDynamicAPILocked(void) |  | ||||||
| { | { | ||||||
|     const char *libname = SDL_getenv_REAL(SDL_DYNAMIC_API_ENVVAR); |     const char *libname = SDL_getenv_REAL(SDL_DYNAMIC_API_ENVVAR); | ||||||
|     SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */ |     SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */ | ||||||
| @@ -435,8 +458,7 @@ SDL_InitDynamicAPILocked(void) | |||||||
|     /* we intentionally never close the newly-loaded lib, of course. */ |     /* we intentionally never close the newly-loaded lib, of course. */ | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_InitDynamicAPI(void) | ||||||
| SDL_InitDynamicAPI(void) |  | ||||||
| { | { | ||||||
|     /* So the theory is that every function in the jump table defaults to |     /* So the theory is that every function in the jump table defaults to | ||||||
|      *  calling this function, and then replaces itself with a version that |      *  calling this function, and then replaces itself with a version that | ||||||
|   | |||||||
| @@ -26,9 +26,7 @@ | |||||||
| #include "SDL_events_c.h" | #include "SDL_events_c.h" | ||||||
| #include "SDL_clipboardevents_c.h" | #include "SDL_clipboardevents_c.h" | ||||||
|  |  | ||||||
|  | int SDL_SendClipboardUpdate(void) | ||||||
| int |  | ||||||
| SDL_SendClipboardUpdate(void) |  | ||||||
| { | { | ||||||
|     int posted; |     int posted; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -25,9 +25,7 @@ | |||||||
| #include "SDL_events.h" | #include "SDL_events.h" | ||||||
| #include "SDL_events_c.h" | #include "SDL_events_c.h" | ||||||
|  |  | ||||||
|  | int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1) | ||||||
| int |  | ||||||
| SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1) |  | ||||||
| { | { | ||||||
|     int posted; |     int posted; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -28,9 +28,7 @@ | |||||||
|  |  | ||||||
| #include "../video/SDL_sysvideo.h" /* for SDL_Window internals. */ | #include "../video/SDL_sysvideo.h" /* for SDL_Window internals. */ | ||||||
|  |  | ||||||
|  | static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *data) | ||||||
| static int |  | ||||||
| SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *data) |  | ||||||
| { | { | ||||||
|     static SDL_bool app_is_dropping = SDL_FALSE; |     static SDL_bool app_is_dropping = SDL_FALSE; | ||||||
|     int posted = 0; |     int posted = 0; | ||||||
| @@ -76,23 +74,19 @@ SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *data) | |||||||
|     return posted; |     return posted; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendDropFile(SDL_Window *window, const char *file) | ||||||
| SDL_SendDropFile(SDL_Window *window, const char *file) |  | ||||||
| { | { | ||||||
|     return SDL_SendDrop(window, SDL_DROPFILE, file); |     return SDL_SendDrop(window, SDL_DROPFILE, file); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendDropText(SDL_Window *window, const char *text) | ||||||
| SDL_SendDropText(SDL_Window *window, const char *text) |  | ||||||
| { | { | ||||||
|     return SDL_SendDrop(window, SDL_DROPTEXT, text); |     return SDL_SendDrop(window, SDL_DROPTEXT, text); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendDropComplete(SDL_Window *window) | ||||||
| SDL_SendDropComplete(SDL_Window *window) |  | ||||||
| { | { | ||||||
|     return SDL_SendDrop(window, SDL_DROPCOMPLETE, NULL); |     return SDL_SendDrop(window, SDL_DROPCOMPLETE, NULL); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* vi: set ts=4 sw=4 expandtab: */ | /* vi: set ts=4 sw=4 expandtab: */ | ||||||
|   | |||||||
| @@ -47,7 +47,8 @@ | |||||||
| /* Determines how often we wake to call SDL_PumpEvents() in SDL_WaitEventTimeout_Device() */ | /* Determines how often we wake to call SDL_PumpEvents() in SDL_WaitEventTimeout_Device() */ | ||||||
| #define PERIODIC_POLL_INTERVAL_MS 3000 | #define PERIODIC_POLL_INTERVAL_MS 3000 | ||||||
|  |  | ||||||
| typedef struct SDL_EventWatcher { | typedef struct SDL_EventWatcher | ||||||
|  | { | ||||||
|     SDL_EventFilter callback; |     SDL_EventFilter callback; | ||||||
|     void *userdata; |     void *userdata; | ||||||
|     SDL_bool removed; |     SDL_bool removed; | ||||||
| @@ -61,7 +62,8 @@ static SDL_bool SDL_event_watchers_dispatching = SDL_FALSE; | |||||||
| static SDL_bool SDL_event_watchers_removed = SDL_FALSE; | static SDL_bool SDL_event_watchers_removed = SDL_FALSE; | ||||||
| static SDL_atomic_t SDL_sentinel_pending; | static SDL_atomic_t SDL_sentinel_pending; | ||||||
|  |  | ||||||
| typedef struct { | typedef struct | ||||||
|  | { | ||||||
|     Uint32 bits[8]; |     Uint32 bits[8]; | ||||||
| } SDL_DisabledEventBlock; | } SDL_DisabledEventBlock; | ||||||
|  |  | ||||||
| @@ -96,13 +98,11 @@ static struct | |||||||
|     SDL_SysWMEntry *wmmsg_free; |     SDL_SysWMEntry *wmmsg_free; | ||||||
| } SDL_EventQ = { NULL, SDL_FALSE, { 0 }, 0, NULL, NULL, NULL, NULL, NULL }; | } SDL_EventQ = { NULL, SDL_FALSE, { 0 }, 0, NULL, NULL, NULL, NULL, NULL }; | ||||||
|  |  | ||||||
|  |  | ||||||
| #if !SDL_JOYSTICK_DISABLED | #if !SDL_JOYSTICK_DISABLED | ||||||
|  |  | ||||||
| static SDL_bool SDL_update_joysticks = SDL_TRUE; | static SDL_bool SDL_update_joysticks = SDL_TRUE; | ||||||
|  |  | ||||||
| static void | static void SDL_CalculateShouldUpdateJoysticks(SDL_bool hint_value) | ||||||
| SDL_CalculateShouldUpdateJoysticks(SDL_bool hint_value) |  | ||||||
| { | { | ||||||
|     if (hint_value && |     if (hint_value && | ||||||
|         (!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] || SDL_JoystickEventState(SDL_QUERY))) { |         (!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] || SDL_JoystickEventState(SDL_QUERY))) { | ||||||
| @@ -112,21 +112,18 @@ SDL_CalculateShouldUpdateJoysticks(SDL_bool hint_value) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_AutoUpdateJoysticksChanged(void *userdata, const char *name, const char *oldValue, const char *hint) | ||||||
| SDL_AutoUpdateJoysticksChanged(void *userdata, const char *name, const char *oldValue, const char *hint) |  | ||||||
| { | { | ||||||
|     SDL_CalculateShouldUpdateJoysticks(SDL_GetStringBoolean(hint, SDL_TRUE)); |     SDL_CalculateShouldUpdateJoysticks(SDL_GetStringBoolean(hint, SDL_TRUE)); | ||||||
| } | } | ||||||
|  |  | ||||||
| #endif /* !SDL_JOYSTICK_DISABLED */ | #endif /* !SDL_JOYSTICK_DISABLED */ | ||||||
|  |  | ||||||
|  |  | ||||||
| #if !SDL_SENSOR_DISABLED | #if !SDL_SENSOR_DISABLED | ||||||
|  |  | ||||||
| static SDL_bool SDL_update_sensors = SDL_TRUE; | static SDL_bool SDL_update_sensors = SDL_TRUE; | ||||||
|  |  | ||||||
| static void | static void SDL_CalculateShouldUpdateSensors(SDL_bool hint_value) | ||||||
| SDL_CalculateShouldUpdateSensors(SDL_bool hint_value) |  | ||||||
| { | { | ||||||
|     if (hint_value && |     if (hint_value && | ||||||
|         !SDL_disabled_events[SDL_SENSORUPDATE >> 8]) { |         !SDL_disabled_events[SDL_SENSORUPDATE >> 8]) { | ||||||
| @@ -136,16 +133,14 @@ SDL_CalculateShouldUpdateSensors(SDL_bool hint_value) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_AutoUpdateSensorsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) | ||||||
| SDL_AutoUpdateSensorsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) |  | ||||||
| { | { | ||||||
|     SDL_CalculateShouldUpdateSensors(SDL_GetStringBoolean(hint, SDL_TRUE)); |     SDL_CalculateShouldUpdateSensors(SDL_GetStringBoolean(hint, SDL_TRUE)); | ||||||
| } | } | ||||||
|  |  | ||||||
| #endif /* !SDL_SENSOR_DISABLED */ | #endif /* !SDL_SENSOR_DISABLED */ | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_PollSentinelChanged(void *userdata, const char *name, const char *oldValue, const char *hint) | ||||||
| SDL_PollSentinelChanged(void *userdata, const char *name, const char *oldValue, const char *hint) |  | ||||||
| { | { | ||||||
|     (void)SDL_EventState(SDL_POLLSENTINEL, SDL_GetStringBoolean(hint, SDL_TRUE) ? SDL_ENABLE : SDL_DISABLE); |     (void)SDL_EventState(SDL_POLLSENTINEL, SDL_GetStringBoolean(hint, SDL_TRUE) ? SDL_ENABLE : SDL_DISABLE); | ||||||
| } | } | ||||||
| @@ -159,14 +154,12 @@ SDL_PollSentinelChanged(void *userdata, const char *name, const char *oldValue, | |||||||
|  */ |  */ | ||||||
| static int SDL_EventLoggingVerbosity = 0; | static int SDL_EventLoggingVerbosity = 0; | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_EventLoggingChanged(void *userdata, const char *name, const char *oldValue, const char *hint) | ||||||
| SDL_EventLoggingChanged(void *userdata, const char *name, const char *oldValue, const char *hint) |  | ||||||
| { | { | ||||||
|     SDL_EventLoggingVerbosity = (hint && *hint) ? SDL_clamp(SDL_atoi(hint), 0, 3) : 0; |     SDL_EventLoggingVerbosity = (hint && *hint) ? SDL_clamp(SDL_atoi(hint), 0, 3) : 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_LogEvent(const SDL_Event *event) | ||||||
| SDL_LogEvent(const SDL_Event *event) |  | ||||||
| { | { | ||||||
|     char name[32]; |     char name[32]; | ||||||
|     char details[128]; |     char details[128]; | ||||||
| @@ -208,42 +201,73 @@ SDL_LogEvent(const SDL_Event *event) | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     switch (event->type) { |     switch (event->type) { | ||||||
|         #define SDL_EVENT_CASE(x) case x: SDL_strlcpy(name, #x, sizeof (name)); | #define SDL_EVENT_CASE(x) \ | ||||||
|         SDL_EVENT_CASE(SDL_FIRSTEVENT) SDL_strlcpy(details, " (THIS IS PROBABLY A BUG!)", sizeof (details)); break; |     case x:               \ | ||||||
|         SDL_EVENT_CASE(SDL_QUIT) SDL_snprintf(details, sizeof (details), " (timestamp=%u)", (uint) event->quit.timestamp); break; |         SDL_strlcpy(name, #x, sizeof(name)); | ||||||
|         SDL_EVENT_CASE(SDL_APP_TERMINATING) break; |         SDL_EVENT_CASE(SDL_FIRSTEVENT) | ||||||
|         SDL_EVENT_CASE(SDL_APP_LOWMEMORY) break; |         SDL_strlcpy(details, " (THIS IS PROBABLY A BUG!)", sizeof(details)); | ||||||
|         SDL_EVENT_CASE(SDL_APP_WILLENTERBACKGROUND) break; |         break; | ||||||
|         SDL_EVENT_CASE(SDL_APP_DIDENTERBACKGROUND) break; |         SDL_EVENT_CASE(SDL_QUIT) | ||||||
|         SDL_EVENT_CASE(SDL_APP_WILLENTERFOREGROUND) break; |         SDL_snprintf(details, sizeof(details), " (timestamp=%u)", (uint)event->quit.timestamp); | ||||||
|         SDL_EVENT_CASE(SDL_APP_DIDENTERFOREGROUND) break; |         break; | ||||||
|         SDL_EVENT_CASE(SDL_LOCALECHANGED) break; |         SDL_EVENT_CASE(SDL_APP_TERMINATING) | ||||||
|         SDL_EVENT_CASE(SDL_KEYMAPCHANGED) break; |         break; | ||||||
|         SDL_EVENT_CASE(SDL_CLIPBOARDUPDATE) break; |         SDL_EVENT_CASE(SDL_APP_LOWMEMORY) | ||||||
|         SDL_EVENT_CASE(SDL_RENDER_TARGETS_RESET) break; |         break; | ||||||
|         SDL_EVENT_CASE(SDL_RENDER_DEVICE_RESET) break; |         SDL_EVENT_CASE(SDL_APP_WILLENTERBACKGROUND) | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_APP_DIDENTERBACKGROUND) | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_APP_WILLENTERFOREGROUND) | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_APP_DIDENTERFOREGROUND) | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_LOCALECHANGED) | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_KEYMAPCHANGED) | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_CLIPBOARDUPDATE) | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_RENDER_TARGETS_RESET) | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_RENDER_DEVICE_RESET) | ||||||
|  |         break; | ||||||
|  |  | ||||||
|         SDL_EVENT_CASE(SDL_DISPLAYEVENT) { |         SDL_EVENT_CASE(SDL_DISPLAYEVENT) | ||||||
|  |         { | ||||||
|             char name2[64]; |             char name2[64]; | ||||||
|             switch (event->display.event) { |             switch (event->display.event) { | ||||||
|                 case SDL_DISPLAYEVENT_NONE: SDL_strlcpy(name2, "SDL_DISPLAYEVENT_NONE (THIS IS PROBABLY A BUG!)", sizeof(name2)); break; |             case SDL_DISPLAYEVENT_NONE: | ||||||
|                 #define SDL_DISPLAYEVENT_CASE(x) case x: SDL_strlcpy(name2, #x, sizeof (name2)); break |                 SDL_strlcpy(name2, "SDL_DISPLAYEVENT_NONE (THIS IS PROBABLY A BUG!)", sizeof(name2)); | ||||||
|  |                 break; | ||||||
|  | #define SDL_DISPLAYEVENT_CASE(x)               \ | ||||||
|  |     case x:                                    \ | ||||||
|  |         SDL_strlcpy(name2, #x, sizeof(name2)); \ | ||||||
|  |         break | ||||||
|                 SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_ORIENTATION); |                 SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_ORIENTATION); | ||||||
|                 SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_CONNECTED); |                 SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_CONNECTED); | ||||||
|                 SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_DISCONNECTED); |                 SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_DISCONNECTED); | ||||||
| #undef SDL_DISPLAYEVENT_CASE | #undef SDL_DISPLAYEVENT_CASE | ||||||
|                 default: SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2)); break; |             default: | ||||||
|  |                 SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2)); | ||||||
|  |                 break; | ||||||
|             } |             } | ||||||
|             SDL_snprintf(details, sizeof(details), " (timestamp=%u display=%u event=%s data1=%d)", |             SDL_snprintf(details, sizeof(details), " (timestamp=%u display=%u event=%s data1=%d)", | ||||||
|                          (uint)event->display.timestamp, (uint)event->display.display, name2, (int)event->display.data1); |                          (uint)event->display.timestamp, (uint)event->display.display, name2, (int)event->display.data1); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         SDL_EVENT_CASE(SDL_WINDOWEVENT) { |         SDL_EVENT_CASE(SDL_WINDOWEVENT) | ||||||
|  |         { | ||||||
|             char name2[64]; |             char name2[64]; | ||||||
|             switch (event->window.event) { |             switch (event->window.event) { | ||||||
|                 case SDL_WINDOWEVENT_NONE: SDL_strlcpy(name2, "SDL_WINDOWEVENT_NONE (THIS IS PROBABLY A BUG!)", sizeof (name2)); break; |             case SDL_WINDOWEVENT_NONE: | ||||||
|                 #define SDL_WINDOWEVENT_CASE(x) case x: SDL_strlcpy(name2, #x, sizeof (name2)); break |                 SDL_strlcpy(name2, "SDL_WINDOWEVENT_NONE (THIS IS PROBABLY A BUG!)", sizeof(name2)); | ||||||
|  |                 break; | ||||||
|  | #define SDL_WINDOWEVENT_CASE(x)                \ | ||||||
|  |     case x:                                    \ | ||||||
|  |         SDL_strlcpy(name2, #x, sizeof(name2)); \ | ||||||
|  |         break | ||||||
|                 SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_SHOWN); |                 SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_SHOWN); | ||||||
|                 SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_HIDDEN); |                 SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_HIDDEN); | ||||||
|                 SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_EXPOSED); |                 SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_EXPOSED); | ||||||
| @@ -263,7 +287,9 @@ SDL_LogEvent(const SDL_Event *event) | |||||||
|                 SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_ICCPROF_CHANGED); |                 SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_ICCPROF_CHANGED); | ||||||
|                 SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_DISPLAY_CHANGED); |                 SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_DISPLAY_CHANGED); | ||||||
| #undef SDL_WINDOWEVENT_CASE | #undef SDL_WINDOWEVENT_CASE | ||||||
|                 default: SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof (name2)); break; |             default: | ||||||
|  |                 SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2)); | ||||||
|  |                 break; | ||||||
|             } |             } | ||||||
|             SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u event=%s data1=%d data2=%d)", |             SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u event=%s data1=%d data2=%d)", | ||||||
|                          (uint)event->window.timestamp, (uint)event->window.windowID, name2, (int)event->window.data1, (int)event->window.data2); |                          (uint)event->window.timestamp, (uint)event->window.windowID, name2, (int)event->window.data1, (int)event->window.data2); | ||||||
| @@ -283,8 +309,12 @@ SDL_LogEvent(const SDL_Event *event) | |||||||
|                  (uint)event->key.keysym.scancode,                                                                         \ |                  (uint)event->key.keysym.scancode,                                                                         \ | ||||||
|                  (uint)event->key.keysym.sym,                                                                              \ |                  (uint)event->key.keysym.sym,                                                                              \ | ||||||
|                  (uint)event->key.keysym.mod) |                  (uint)event->key.keysym.mod) | ||||||
|         SDL_EVENT_CASE(SDL_KEYDOWN) PRINT_KEY_EVENT(event); break; |         SDL_EVENT_CASE(SDL_KEYDOWN) | ||||||
|         SDL_EVENT_CASE(SDL_KEYUP) PRINT_KEY_EVENT(event); break; |         PRINT_KEY_EVENT(event); | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_KEYUP) | ||||||
|  |         PRINT_KEY_EVENT(event); | ||||||
|  |         break; | ||||||
| #undef PRINT_KEY_EVENT | #undef PRINT_KEY_EVENT | ||||||
|  |  | ||||||
|         SDL_EVENT_CASE(SDL_TEXTEDITING) |         SDL_EVENT_CASE(SDL_TEXTEDITING) | ||||||
| @@ -297,7 +327,6 @@ SDL_LogEvent(const SDL_Event *event) | |||||||
|         SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u text='%s')", (uint)event->text.timestamp, (uint)event->text.windowID, event->text.text); |         SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u text='%s')", (uint)event->text.timestamp, (uint)event->text.windowID, event->text.text); | ||||||
|         break; |         break; | ||||||
|  |  | ||||||
|  |  | ||||||
|         SDL_EVENT_CASE(SDL_MOUSEMOTION) |         SDL_EVENT_CASE(SDL_MOUSEMOTION) | ||||||
|         SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u state=%u x=%d y=%d xrel=%d yrel=%d)", |         SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u state=%u x=%d y=%d xrel=%d yrel=%d)", | ||||||
|                      (uint)event->motion.timestamp, (uint)event->motion.windowID, |                      (uint)event->motion.timestamp, (uint)event->motion.windowID, | ||||||
| @@ -312,11 +341,14 @@ SDL_LogEvent(const SDL_Event *event) | |||||||
|                  (uint)event->button.which, (uint)event->button.button,                                                   \ |                  (uint)event->button.which, (uint)event->button.button,                                                   \ | ||||||
|                  event->button.state == SDL_PRESSED ? "pressed" : "released",                                             \ |                  event->button.state == SDL_PRESSED ? "pressed" : "released",                                             \ | ||||||
|                  (uint)event->button.clicks, (int)event->button.x, (int)event->button.y) |                  (uint)event->button.clicks, (int)event->button.x, (int)event->button.y) | ||||||
|         SDL_EVENT_CASE(SDL_MOUSEBUTTONDOWN) PRINT_MBUTTON_EVENT(event); break; |         SDL_EVENT_CASE(SDL_MOUSEBUTTONDOWN) | ||||||
|         SDL_EVENT_CASE(SDL_MOUSEBUTTONUP) PRINT_MBUTTON_EVENT(event); break; |         PRINT_MBUTTON_EVENT(event); | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_MOUSEBUTTONUP) | ||||||
|  |         PRINT_MBUTTON_EVENT(event); | ||||||
|  |         break; | ||||||
| #undef PRINT_MBUTTON_EVENT | #undef PRINT_MBUTTON_EVENT | ||||||
|  |  | ||||||
|  |  | ||||||
|         SDL_EVENT_CASE(SDL_MOUSEWHEEL) |         SDL_EVENT_CASE(SDL_MOUSEWHEEL) | ||||||
|         SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u x=%d y=%d preciseX=%f preciseY=%f direction=%s)", |         SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u x=%d y=%d preciseX=%f preciseY=%f direction=%s)", | ||||||
|                      (uint)event->wheel.timestamp, (uint)event->wheel.windowID, |                      (uint)event->wheel.timestamp, (uint)event->wheel.windowID, | ||||||
| @@ -347,13 +379,21 @@ SDL_LogEvent(const SDL_Event *event) | |||||||
|     SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \ |     SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \ | ||||||
|                  (uint)event->jbutton.timestamp, (int)event->jbutton.which,               \ |                  (uint)event->jbutton.timestamp, (int)event->jbutton.which,               \ | ||||||
|                  (uint)event->jbutton.button, event->jbutton.state == SDL_PRESSED ? "pressed" : "released") |                  (uint)event->jbutton.button, event->jbutton.state == SDL_PRESSED ? "pressed" : "released") | ||||||
|         SDL_EVENT_CASE(SDL_JOYBUTTONDOWN) PRINT_JBUTTON_EVENT(event); break; |         SDL_EVENT_CASE(SDL_JOYBUTTONDOWN) | ||||||
|         SDL_EVENT_CASE(SDL_JOYBUTTONUP) PRINT_JBUTTON_EVENT(event); break; |         PRINT_JBUTTON_EVENT(event); | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_JOYBUTTONUP) | ||||||
|  |         PRINT_JBUTTON_EVENT(event); | ||||||
|  |         break; | ||||||
| #undef PRINT_JBUTTON_EVENT | #undef PRINT_JBUTTON_EVENT | ||||||
|  |  | ||||||
| #define PRINT_JOYDEV_EVENT(event) SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d)", (uint)event->jdevice.timestamp, (int)event->jdevice.which) | #define PRINT_JOYDEV_EVENT(event) SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d)", (uint)event->jdevice.timestamp, (int)event->jdevice.which) | ||||||
|         SDL_EVENT_CASE(SDL_JOYDEVICEADDED) PRINT_JOYDEV_EVENT(event); break; |         SDL_EVENT_CASE(SDL_JOYDEVICEADDED) | ||||||
|         SDL_EVENT_CASE(SDL_JOYDEVICEREMOVED) PRINT_JOYDEV_EVENT(event); break; |         PRINT_JOYDEV_EVENT(event); | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_JOYDEVICEREMOVED) | ||||||
|  |         PRINT_JOYDEV_EVENT(event); | ||||||
|  |         break; | ||||||
| #undef PRINT_JOYDEV_EVENT | #undef PRINT_JOYDEV_EVENT | ||||||
|  |  | ||||||
|         SDL_EVENT_CASE(SDL_CONTROLLERAXISMOTION) |         SDL_EVENT_CASE(SDL_CONTROLLERAXISMOTION) | ||||||
| @@ -366,14 +406,24 @@ SDL_LogEvent(const SDL_Event *event) | |||||||
|     SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \ |     SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \ | ||||||
|                  (uint)event->cbutton.timestamp, (int)event->cbutton.which,               \ |                  (uint)event->cbutton.timestamp, (int)event->cbutton.which,               \ | ||||||
|                  (uint)event->cbutton.button, event->cbutton.state == SDL_PRESSED ? "pressed" : "released") |                  (uint)event->cbutton.button, event->cbutton.state == SDL_PRESSED ? "pressed" : "released") | ||||||
|         SDL_EVENT_CASE(SDL_CONTROLLERBUTTONDOWN) PRINT_CBUTTON_EVENT(event); break; |         SDL_EVENT_CASE(SDL_CONTROLLERBUTTONDOWN) | ||||||
|         SDL_EVENT_CASE(SDL_CONTROLLERBUTTONUP) PRINT_CBUTTON_EVENT(event); break; |         PRINT_CBUTTON_EVENT(event); | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_CONTROLLERBUTTONUP) | ||||||
|  |         PRINT_CBUTTON_EVENT(event); | ||||||
|  |         break; | ||||||
| #undef PRINT_CBUTTON_EVENT | #undef PRINT_CBUTTON_EVENT | ||||||
|  |  | ||||||
| #define PRINT_CONTROLLERDEV_EVENT(event) SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d)", (uint)event->cdevice.timestamp, (int)event->cdevice.which) | #define PRINT_CONTROLLERDEV_EVENT(event) SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d)", (uint)event->cdevice.timestamp, (int)event->cdevice.which) | ||||||
|         SDL_EVENT_CASE(SDL_CONTROLLERDEVICEADDED) PRINT_CONTROLLERDEV_EVENT(event); break; |         SDL_EVENT_CASE(SDL_CONTROLLERDEVICEADDED) | ||||||
|         SDL_EVENT_CASE(SDL_CONTROLLERDEVICEREMOVED) PRINT_CONTROLLERDEV_EVENT(event); break; |         PRINT_CONTROLLERDEV_EVENT(event); | ||||||
|         SDL_EVENT_CASE(SDL_CONTROLLERDEVICEREMAPPED) PRINT_CONTROLLERDEV_EVENT(event); break; |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_CONTROLLERDEVICEREMOVED) | ||||||
|  |         PRINT_CONTROLLERDEV_EVENT(event); | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_CONTROLLERDEVICEREMAPPED) | ||||||
|  |         PRINT_CONTROLLERDEV_EVENT(event); | ||||||
|  |         break; | ||||||
| #undef PRINT_CONTROLLERDEV_EVENT | #undef PRINT_CONTROLLERDEV_EVENT | ||||||
|  |  | ||||||
| #define PRINT_CTOUCHPAD_EVENT(event)                                                                               \ | #define PRINT_CTOUCHPAD_EVENT(event)                                                                               \ | ||||||
| @@ -381,14 +431,20 @@ SDL_LogEvent(const SDL_Event *event) | |||||||
|                  (uint)event->ctouchpad.timestamp, (int)event->ctouchpad.which,                                    \ |                  (uint)event->ctouchpad.timestamp, (int)event->ctouchpad.which,                                    \ | ||||||
|                  (int)event->ctouchpad.touchpad, (int)event->ctouchpad.finger,                                     \ |                  (int)event->ctouchpad.touchpad, (int)event->ctouchpad.finger,                                     \ | ||||||
|                  event->ctouchpad.x, event->ctouchpad.y, event->ctouchpad.pressure) |                  event->ctouchpad.x, event->ctouchpad.y, event->ctouchpad.pressure) | ||||||
|         SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADDOWN) PRINT_CTOUCHPAD_EVENT(event); break; |         SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADDOWN) | ||||||
|         SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADUP) PRINT_CTOUCHPAD_EVENT(event); break; |         PRINT_CTOUCHPAD_EVENT(event); | ||||||
|         SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADMOTION) PRINT_CTOUCHPAD_EVENT(event); break; |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADUP) | ||||||
|  |         PRINT_CTOUCHPAD_EVENT(event); | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADMOTION) | ||||||
|  |         PRINT_CTOUCHPAD_EVENT(event); | ||||||
|  |         break; | ||||||
| #undef PRINT_CTOUCHPAD_EVENT | #undef PRINT_CTOUCHPAD_EVENT | ||||||
|  |  | ||||||
|         SDL_EVENT_CASE(SDL_CONTROLLERSENSORUPDATE) |         SDL_EVENT_CASE(SDL_CONTROLLERSENSORUPDATE) | ||||||
|             SDL_snprintf(details, sizeof (details), " (timestamp=%u which=%d sensor=%d data[0]=%f data[1]=%f data[2]=%f)", \ |         SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d sensor=%d data[0]=%f data[1]=%f data[2]=%f)", | ||||||
|                 (uint) event->csensor.timestamp, (int) event->csensor.which, (int) event->csensor.sensor, \ |                      (uint)event->csensor.timestamp, (int)event->csensor.which, (int)event->csensor.sensor, | ||||||
|                      event->csensor.data[0], event->csensor.data[1], event->csensor.data[2]); |                      event->csensor.data[0], event->csensor.data[1], event->csensor.data[2]); | ||||||
|         break; |         break; | ||||||
|  |  | ||||||
| @@ -397,9 +453,15 @@ SDL_LogEvent(const SDL_Event *event) | |||||||
|                  (uint)event->tfinger.timestamp, (long long)event->tfinger.touchId,                                                              \ |                  (uint)event->tfinger.timestamp, (long long)event->tfinger.touchId,                                                              \ | ||||||
|                  (long long)event->tfinger.fingerId, event->tfinger.x, event->tfinger.y,                                                         \ |                  (long long)event->tfinger.fingerId, event->tfinger.x, event->tfinger.y,                                                         \ | ||||||
|                  event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure) |                  event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure) | ||||||
|         SDL_EVENT_CASE(SDL_FINGERDOWN) PRINT_FINGER_EVENT(event); break; |         SDL_EVENT_CASE(SDL_FINGERDOWN) | ||||||
|         SDL_EVENT_CASE(SDL_FINGERUP) PRINT_FINGER_EVENT(event); break; |         PRINT_FINGER_EVENT(event); | ||||||
|         SDL_EVENT_CASE(SDL_FINGERMOTION) PRINT_FINGER_EVENT(event); break; |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_FINGERUP) | ||||||
|  |         PRINT_FINGER_EVENT(event); | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_FINGERMOTION) | ||||||
|  |         PRINT_FINGER_EVENT(event); | ||||||
|  |         break; | ||||||
| #undef PRINT_FINGER_EVENT | #undef PRINT_FINGER_EVENT | ||||||
|  |  | ||||||
| #define PRINT_DOLLAR_EVENT(event)                                                                                                                \ | #define PRINT_DOLLAR_EVENT(event)                                                                                                                \ | ||||||
| @@ -407,8 +469,12 @@ SDL_LogEvent(const SDL_Event *event) | |||||||
|                  (uint)event->dgesture.timestamp, (long long)event->dgesture.touchId,                                                            \ |                  (uint)event->dgesture.timestamp, (long long)event->dgesture.touchId,                                                            \ | ||||||
|                  (long long)event->dgesture.gestureId, (uint)event->dgesture.numFingers,                                                         \ |                  (long long)event->dgesture.gestureId, (uint)event->dgesture.numFingers,                                                         \ | ||||||
|                  event->dgesture.error, event->dgesture.x, event->dgesture.y) |                  event->dgesture.error, event->dgesture.x, event->dgesture.y) | ||||||
|         SDL_EVENT_CASE(SDL_DOLLARGESTURE) PRINT_DOLLAR_EVENT(event); break; |         SDL_EVENT_CASE(SDL_DOLLARGESTURE) | ||||||
|         SDL_EVENT_CASE(SDL_DOLLARRECORD) PRINT_DOLLAR_EVENT(event); break; |         PRINT_DOLLAR_EVENT(event); | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_DOLLARRECORD) | ||||||
|  |         PRINT_DOLLAR_EVENT(event); | ||||||
|  |         break; | ||||||
| #undef PRINT_DOLLAR_EVENT | #undef PRINT_DOLLAR_EVENT | ||||||
|  |  | ||||||
|         SDL_EVENT_CASE(SDL_MULTIGESTURE) |         SDL_EVENT_CASE(SDL_MULTIGESTURE) | ||||||
| @@ -419,21 +485,33 @@ SDL_LogEvent(const SDL_Event *event) | |||||||
|         break; |         break; | ||||||
|  |  | ||||||
| #define PRINT_DROP_EVENT(event) SDL_snprintf(details, sizeof(details), " (file='%s' timestamp=%u windowid=%u)", event->drop.file, (uint)event->drop.timestamp, (uint)event->drop.windowID) | #define PRINT_DROP_EVENT(event) SDL_snprintf(details, sizeof(details), " (file='%s' timestamp=%u windowid=%u)", event->drop.file, (uint)event->drop.timestamp, (uint)event->drop.windowID) | ||||||
|         SDL_EVENT_CASE(SDL_DROPFILE) PRINT_DROP_EVENT(event); break; |         SDL_EVENT_CASE(SDL_DROPFILE) | ||||||
|         SDL_EVENT_CASE(SDL_DROPTEXT) PRINT_DROP_EVENT(event); break; |         PRINT_DROP_EVENT(event); | ||||||
|         SDL_EVENT_CASE(SDL_DROPBEGIN) PRINT_DROP_EVENT(event); break; |         break; | ||||||
|         SDL_EVENT_CASE(SDL_DROPCOMPLETE) PRINT_DROP_EVENT(event); break; |         SDL_EVENT_CASE(SDL_DROPTEXT) | ||||||
|  |         PRINT_DROP_EVENT(event); | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_DROPBEGIN) | ||||||
|  |         PRINT_DROP_EVENT(event); | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_DROPCOMPLETE) | ||||||
|  |         PRINT_DROP_EVENT(event); | ||||||
|  |         break; | ||||||
| #undef PRINT_DROP_EVENT | #undef PRINT_DROP_EVENT | ||||||
|  |  | ||||||
| #define PRINT_AUDIODEV_EVENT(event) SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%u iscapture=%s)", (uint)event->adevice.timestamp, (uint)event->adevice.which, event->adevice.iscapture ? "true" : "false") | #define PRINT_AUDIODEV_EVENT(event) SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%u iscapture=%s)", (uint)event->adevice.timestamp, (uint)event->adevice.which, event->adevice.iscapture ? "true" : "false") | ||||||
|         SDL_EVENT_CASE(SDL_AUDIODEVICEADDED) PRINT_AUDIODEV_EVENT(event); break; |         SDL_EVENT_CASE(SDL_AUDIODEVICEADDED) | ||||||
|         SDL_EVENT_CASE(SDL_AUDIODEVICEREMOVED) PRINT_AUDIODEV_EVENT(event); break; |         PRINT_AUDIODEV_EVENT(event); | ||||||
|  |         break; | ||||||
|  |         SDL_EVENT_CASE(SDL_AUDIODEVICEREMOVED) | ||||||
|  |         PRINT_AUDIODEV_EVENT(event); | ||||||
|  |         break; | ||||||
| #undef PRINT_AUDIODEV_EVENT | #undef PRINT_AUDIODEV_EVENT | ||||||
|  |  | ||||||
|         SDL_EVENT_CASE(SDL_SENSORUPDATE) |         SDL_EVENT_CASE(SDL_SENSORUPDATE) | ||||||
|             SDL_snprintf(details, sizeof (details), " (timestamp=%u which=%d data[0]=%f data[1]=%f data[2]=%f data[3]=%f data[4]=%f data[5]=%f)", \ |         SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d data[0]=%f data[1]=%f data[2]=%f data[3]=%f data[4]=%f data[5]=%f)", | ||||||
|                 (uint) event->sensor.timestamp, (int) event->sensor.which, \ |                      (uint)event->sensor.timestamp, (int)event->sensor.which, | ||||||
|                 event->sensor.data[0], event->sensor.data[1], event->sensor.data[2], \ |                      event->sensor.data[0], event->sensor.data[1], event->sensor.data[2], | ||||||
|                      event->sensor.data[3], event->sensor.data[4], event->sensor.data[5]); |                      event->sensor.data[3], event->sensor.data[4], event->sensor.data[5]); | ||||||
|         break; |         break; | ||||||
|  |  | ||||||
| @@ -458,12 +536,9 @@ SDL_LogEvent(const SDL_Event *event) | |||||||
| #undef uint | #undef uint | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Public functions */ | /* Public functions */ | ||||||
|  |  | ||||||
| void | void SDL_StopEventLoop(void) | ||||||
| SDL_StopEventLoop(void) |  | ||||||
| { | { | ||||||
|     const char *report = SDL_GetHint("SDL_EVENT_QUEUE_STATISTICS"); |     const char *report = SDL_GetHint("SDL_EVENT_QUEUE_STATISTICS"); | ||||||
|     int i; |     int i; | ||||||
| @@ -537,8 +612,7 @@ SDL_StopEventLoop(void) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* This function (and associated calls) may be called more than once */ | /* This function (and associated calls) may be called more than once */ | ||||||
| int | int SDL_StartEventLoop(void) | ||||||
| SDL_StartEventLoop(void) |  | ||||||
| { | { | ||||||
|     /* We'll leave the event queue alone, since we might have gotten |     /* We'll leave the event queue alone, since we might have gotten | ||||||
|        some important events at launch (like SDL_DROPFILE) |        some important events at launch (like SDL_DROPFILE) | ||||||
| @@ -581,10 +655,8 @@ SDL_StartEventLoop(void) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Add an event to the event queue -- called with the queue locked */ | /* Add an event to the event queue -- called with the queue locked */ | ||||||
| static int | static int SDL_AddEvent(SDL_Event *event) | ||||||
| SDL_AddEvent(SDL_Event * event) |  | ||||||
| { | { | ||||||
|     SDL_EventEntry *entry; |     SDL_EventEntry *entry; | ||||||
|     const int initial_count = SDL_AtomicGet(&SDL_EventQ.count); |     const int initial_count = SDL_AtomicGet(&SDL_EventQ.count); | ||||||
| @@ -639,8 +711,7 @@ SDL_AddEvent(SDL_Event * event) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* Remove an event from the queue -- called with the queue locked */ | /* Remove an event from the queue -- called with the queue locked */ | ||||||
| static void | static void SDL_CutEvent(SDL_EventEntry *entry) | ||||||
| SDL_CutEvent(SDL_EventEntry *entry) |  | ||||||
| { | { | ||||||
|     if (entry->prev) { |     if (entry->prev) { | ||||||
|         entry->prev->next = entry->next; |         entry->prev->next = entry->next; | ||||||
| @@ -668,8 +739,7 @@ SDL_CutEvent(SDL_EventEntry *entry) | |||||||
|     SDL_AtomicAdd(&SDL_EventQ.count, -1); |     SDL_AtomicAdd(&SDL_EventQ.count, -1); | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_SendWakeupEvent() | ||||||
| SDL_SendWakeupEvent() |  | ||||||
| { | { | ||||||
|     SDL_VideoDevice *_this = SDL_GetVideoDevice(); |     SDL_VideoDevice *_this = SDL_GetVideoDevice(); | ||||||
|     if (_this == NULL || !_this->SendWakeupEvent) { |     if (_this == NULL || !_this->SendWakeupEvent) { | ||||||
| @@ -690,8 +760,7 @@ SDL_SendWakeupEvent() | |||||||
| } | } | ||||||
|  |  | ||||||
| /* Lock the event queue, take a peep at it, and unlock it */ | /* Lock the event queue, take a peep at it, and unlock it */ | ||||||
| static int | static int SDL_PeepEventsInternal(SDL_Event *events, int numevents, SDL_eventaction action, | ||||||
| SDL_PeepEventsInternal(SDL_Event * events, int numevents, SDL_eventaction action, |  | ||||||
|                                   Uint32 minType, Uint32 maxType, SDL_bool include_sentinel) |                                   Uint32 minType, Uint32 maxType, SDL_bool include_sentinel) | ||||||
| { | { | ||||||
|     int i, used, sentinels_expected = 0; |     int i, used, sentinels_expected = 0; | ||||||
| @@ -789,8 +858,7 @@ SDL_PeepEventsInternal(SDL_Event * events, int numevents, SDL_eventaction action | |||||||
|  |  | ||||||
|     return used; |     return used; | ||||||
| } | } | ||||||
| int | int SDL_PeepEvents(SDL_Event *events, int numevents, SDL_eventaction action, | ||||||
| SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action, |  | ||||||
|                    Uint32 minType, Uint32 maxType) |                    Uint32 minType, Uint32 maxType) | ||||||
| { | { | ||||||
|     return SDL_PeepEventsInternal(events, numevents, action, minType, maxType, SDL_FALSE); |     return SDL_PeepEventsInternal(events, numevents, action, minType, maxType, SDL_FALSE); | ||||||
| @@ -808,14 +876,12 @@ SDL_HasEvents(Uint32 minType, Uint32 maxType) | |||||||
|     return SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, minType, maxType) > 0; |     return SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, minType, maxType) > 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_FlushEvent(Uint32 type) | ||||||
| SDL_FlushEvent(Uint32 type) |  | ||||||
| { | { | ||||||
|     SDL_FlushEvents(type, type); |     SDL_FlushEvents(type, type); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_FlushEvents(Uint32 minType, Uint32 maxType) | ||||||
| SDL_FlushEvents(Uint32 minType, Uint32 maxType) |  | ||||||
| { | { | ||||||
|     SDL_EventEntry *entry, *next; |     SDL_EventEntry *entry, *next; | ||||||
|     Uint32 type; |     Uint32 type; | ||||||
| @@ -854,8 +920,7 @@ SDL_FlushEvents(Uint32 minType, Uint32 maxType) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* Run the system dependent event loops */ | /* Run the system dependent event loops */ | ||||||
| static void | static void SDL_PumpEventsInternal(SDL_bool push_sentinel) | ||||||
| SDL_PumpEventsInternal(SDL_bool push_sentinel) |  | ||||||
| { | { | ||||||
|     SDL_VideoDevice *_this = SDL_GetVideoDevice(); |     SDL_VideoDevice *_this = SDL_GetVideoDevice(); | ||||||
|  |  | ||||||
| @@ -892,22 +957,20 @@ SDL_PumpEventsInternal(SDL_bool push_sentinel) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_PumpEvents() | ||||||
| SDL_PumpEvents() |  | ||||||
| { | { | ||||||
|     SDL_PumpEventsInternal(SDL_FALSE); |     SDL_PumpEventsInternal(SDL_FALSE); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Public functions */ | /* Public functions */ | ||||||
|  |  | ||||||
| int | int SDL_PollEvent(SDL_Event *event) | ||||||
| SDL_PollEvent(SDL_Event * event) |  | ||||||
| { | { | ||||||
|     return SDL_WaitEventTimeout(event, 0); |     return SDL_WaitEventTimeout(event, 0); | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool SDL_events_need_periodic_poll() | ||||||
| SDL_events_need_periodic_poll() { | { | ||||||
|     SDL_bool need_periodic_poll = SDL_FALSE; |     SDL_bool need_periodic_poll = SDL_FALSE; | ||||||
|  |  | ||||||
| #if !SDL_JOYSTICK_DISABLED | #if !SDL_JOYSTICK_DISABLED | ||||||
| @@ -923,8 +986,7 @@ SDL_events_need_periodic_poll() { | |||||||
|     return need_periodic_poll; |     return need_periodic_poll; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Event *event, Uint32 start, int timeout) | ||||||
| SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Event * event, Uint32 start, int timeout) |  | ||||||
| { | { | ||||||
|     int loop_timeout = timeout; |     int loop_timeout = timeout; | ||||||
|     SDL_bool need_periodic_poll = SDL_events_need_periodic_poll(); |     SDL_bool need_periodic_poll = SDL_events_need_periodic_poll(); | ||||||
| @@ -995,8 +1057,8 @@ SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Event * event, | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool SDL_events_need_polling() | ||||||
| SDL_events_need_polling() { | { | ||||||
|     SDL_bool need_polling = SDL_FALSE; |     SDL_bool need_polling = SDL_FALSE; | ||||||
|  |  | ||||||
| #if !SDL_JOYSTICK_DISABLED | #if !SDL_JOYSTICK_DISABLED | ||||||
| @@ -1014,8 +1076,7 @@ SDL_events_need_polling() { | |||||||
|     return need_polling; |     return need_polling; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_Window * | static SDL_Window *SDL_find_active_window(SDL_VideoDevice *_this) | ||||||
| SDL_find_active_window(SDL_VideoDevice * _this) |  | ||||||
| { | { | ||||||
|     SDL_Window *window; |     SDL_Window *window; | ||||||
|     for (window = _this->windows; window; window = window->next) { |     for (window = _this->windows; window; window = window->next) { | ||||||
| @@ -1026,14 +1087,12 @@ SDL_find_active_window(SDL_VideoDevice * _this) | |||||||
|     return NULL; |     return NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_WaitEvent(SDL_Event *event) | ||||||
| SDL_WaitEvent(SDL_Event * event) |  | ||||||
| { | { | ||||||
|     return SDL_WaitEventTimeout(event, -1); |     return SDL_WaitEventTimeout(event, -1); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_WaitEventTimeout(SDL_Event *event, int timeout) | ||||||
| SDL_WaitEventTimeout(SDL_Event * event, int timeout) |  | ||||||
| { | { | ||||||
|     SDL_VideoDevice *_this = SDL_GetVideoDevice(); |     SDL_VideoDevice *_this = SDL_GetVideoDevice(); | ||||||
|     SDL_Window *wakeup_window; |     SDL_Window *wakeup_window; | ||||||
| @@ -1122,8 +1181,7 @@ SDL_WaitEventTimeout(SDL_Event * event, int timeout) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_PushEvent(SDL_Event *event) | ||||||
| SDL_PushEvent(SDL_Event * event) |  | ||||||
| { | { | ||||||
|     event->common.timestamp = SDL_GetTicks(); |     event->common.timestamp = SDL_GetTicks(); | ||||||
|  |  | ||||||
| @@ -1176,8 +1234,7 @@ SDL_PushEvent(SDL_Event * event) | |||||||
|     return 1; |     return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_SetEventFilter(SDL_EventFilter filter, void *userdata) | ||||||
| SDL_SetEventFilter(SDL_EventFilter filter, void *userdata) |  | ||||||
| { | { | ||||||
|     if (SDL_event_watchers_lock == NULL || SDL_LockMutex(SDL_event_watchers_lock) == 0) { |     if (SDL_event_watchers_lock == NULL || SDL_LockMutex(SDL_event_watchers_lock) == 0) { | ||||||
|         /* Set filter and discard pending events */ |         /* Set filter and discard pending events */ | ||||||
| @@ -1215,8 +1272,7 @@ SDL_GetEventFilter(SDL_EventFilter * filter, void **userdata) | |||||||
|     return event_ok.callback ? SDL_TRUE : SDL_FALSE; |     return event_ok.callback ? SDL_TRUE : SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_AddEventWatch(SDL_EventFilter filter, void *userdata) | ||||||
| SDL_AddEventWatch(SDL_EventFilter filter, void *userdata) |  | ||||||
| { | { | ||||||
|     if (SDL_event_watchers_lock == NULL || SDL_LockMutex(SDL_event_watchers_lock) == 0) { |     if (SDL_event_watchers_lock == NULL || SDL_LockMutex(SDL_event_watchers_lock) == 0) { | ||||||
|         SDL_EventWatcher *event_watchers; |         SDL_EventWatcher *event_watchers; | ||||||
| @@ -1239,8 +1295,7 @@ SDL_AddEventWatch(SDL_EventFilter filter, void *userdata) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_DelEventWatch(SDL_EventFilter filter, void *userdata) | ||||||
| SDL_DelEventWatch(SDL_EventFilter filter, void *userdata) |  | ||||||
| { | { | ||||||
|     if (SDL_event_watchers_lock == NULL || SDL_LockMutex(SDL_event_watchers_lock) == 0) { |     if (SDL_event_watchers_lock == NULL || SDL_LockMutex(SDL_event_watchers_lock) == 0) { | ||||||
|         int i; |         int i; | ||||||
| @@ -1266,8 +1321,7 @@ SDL_DelEventWatch(SDL_EventFilter filter, void *userdata) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_FilterEvents(SDL_EventFilter filter, void *userdata) | ||||||
| SDL_FilterEvents(SDL_EventFilter filter, void *userdata) |  | ||||||
| { | { | ||||||
|     if (!SDL_EventQ.lock || SDL_LockMutex(SDL_EventQ.lock) == 0) { |     if (!SDL_EventQ.lock || SDL_LockMutex(SDL_EventQ.lock) == 0) { | ||||||
|         SDL_EventEntry *entry, *next; |         SDL_EventEntry *entry, *next; | ||||||
| @@ -1283,8 +1337,7 @@ SDL_FilterEvents(SDL_EventFilter filter, void *userdata) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| Uint8 | Uint8 SDL_EventState(Uint32 type, int state) | ||||||
| SDL_EventState(Uint32 type, int state) |  | ||||||
| { | { | ||||||
|     const SDL_bool isde = (state == SDL_DISABLE) || (state == SDL_ENABLE); |     const SDL_bool isde = (state == SDL_DISABLE) || (state == SDL_ENABLE); | ||||||
|     Uint8 current_state; |     Uint8 current_state; | ||||||
| @@ -1344,8 +1397,7 @@ SDL_RegisterEvents(int numevents) | |||||||
|     return event_base; |     return event_base; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendAppEvent(SDL_EventType eventType) | ||||||
| SDL_SendAppEvent(SDL_EventType eventType) |  | ||||||
| { | { | ||||||
|     int posted; |     int posted; | ||||||
|  |  | ||||||
| @@ -1358,8 +1410,7 @@ SDL_SendAppEvent(SDL_EventType eventType) | |||||||
|     return posted; |     return posted; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendSysWMEvent(SDL_SysWMmsg *message) | ||||||
| SDL_SendSysWMEvent(SDL_SysWMmsg * message) |  | ||||||
| { | { | ||||||
|     int posted; |     int posted; | ||||||
|  |  | ||||||
| @@ -1375,20 +1426,17 @@ SDL_SendSysWMEvent(SDL_SysWMmsg * message) | |||||||
|     return posted; |     return posted; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendKeymapChangedEvent(void) | ||||||
| SDL_SendKeymapChangedEvent(void) |  | ||||||
| { | { | ||||||
|     return SDL_SendAppEvent(SDL_KEYMAPCHANGED); |     return SDL_SendAppEvent(SDL_KEYMAPCHANGED); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendLocaleChangedEvent(void) | ||||||
| SDL_SendLocaleChangedEvent(void) |  | ||||||
| { | { | ||||||
|     return SDL_SendAppEvent(SDL_LOCALECHANGED); |     return SDL_SendAppEvent(SDL_LOCALECHANGED); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_EventsInit(void) | ||||||
| SDL_EventsInit(void) |  | ||||||
| { | { | ||||||
| #if !SDL_JOYSTICK_DISABLED | #if !SDL_JOYSTICK_DISABLED | ||||||
|     SDL_AddHintCallback(SDL_HINT_AUTO_UPDATE_JOYSTICKS, SDL_AutoUpdateJoysticksChanged, NULL); |     SDL_AddHintCallback(SDL_HINT_AUTO_UPDATE_JOYSTICKS, SDL_AutoUpdateJoysticksChanged, NULL); | ||||||
| @@ -1408,8 +1456,7 @@ SDL_EventsInit(void) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_EventsQuit(void) | ||||||
| SDL_EventsQuit(void) |  | ||||||
| { | { | ||||||
|     SDL_QuitQuit(); |     SDL_QuitQuit(); | ||||||
|     SDL_StopEventLoop(); |     SDL_StopEventLoop(); | ||||||
|   | |||||||
| @@ -45,23 +45,27 @@ | |||||||
| #define PHI        0.618033989 | #define PHI        0.618033989 | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| typedef struct { | typedef struct | ||||||
|  | { | ||||||
|     float x, y; |     float x, y; | ||||||
| } SDL_FloatPoint; | } SDL_FloatPoint; | ||||||
|  |  | ||||||
| typedef struct { | typedef struct | ||||||
|  | { | ||||||
|     float length; |     float length; | ||||||
|  |  | ||||||
|     int numPoints; |     int numPoints; | ||||||
|     SDL_FloatPoint p[MAXPATHSIZE]; |     SDL_FloatPoint p[MAXPATHSIZE]; | ||||||
| } SDL_DollarPath; | } SDL_DollarPath; | ||||||
|  |  | ||||||
| typedef struct { | typedef struct | ||||||
|  | { | ||||||
|     SDL_FloatPoint path[DOLLARNPOINTS]; |     SDL_FloatPoint path[DOLLARNPOINTS]; | ||||||
|     unsigned long hash; |     unsigned long hash; | ||||||
| } SDL_DollarTemplate; | } SDL_DollarTemplate; | ||||||
|  |  | ||||||
| typedef struct { | typedef struct | ||||||
|  | { | ||||||
|     SDL_TouchID id; |     SDL_TouchID id; | ||||||
|     SDL_FloatPoint centroid; |     SDL_FloatPoint centroid; | ||||||
|     SDL_DollarPath dollarPath; |     SDL_DollarPath dollarPath; | ||||||
| @@ -123,7 +127,6 @@ static unsigned long SDL_HashDollar(SDL_FloatPoint* points) | |||||||
|     return hash; |     return hash; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst) | static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst) | ||||||
| { | { | ||||||
|     if (dst == NULL) { |     if (dst == NULL) { | ||||||
| @@ -158,7 +161,6 @@ static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst) | |||||||
|     return 1; |     return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| int SDL_SaveAllDollarTemplates(SDL_RWops *dst) | int SDL_SaveAllDollarTemplates(SDL_RWops *dst) | ||||||
| { | { | ||||||
|     int i, j, rtrn = 0; |     int i, j, rtrn = 0; | ||||||
| @@ -288,7 +290,6 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) | |||||||
|     return loaded; |     return loaded; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| #if defined(ENABLE_DOLLAR) | #if defined(ENABLE_DOLLAR) | ||||||
| static float dollarDifference(SDL_FloatPoint *points, SDL_FloatPoint *templ, float ang) | static float dollarDifference(SDL_FloatPoint *points, SDL_FloatPoint *templ, float ang) | ||||||
| { | { | ||||||
| @@ -303,7 +304,6 @@ static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float | |||||||
|                                  (p.y - templ[i].y) * (p.y - templ[i].y))); |                                  (p.y - templ[i].y) * (p.y - templ[i].y))); | ||||||
|     } |     } | ||||||
|     return dist / DOLLARNPOINTS; |     return dist / DOLLARNPOINTS; | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static float bestDollarDifference(SDL_FloatPoint *points, SDL_FloatPoint *templ) | static float bestDollarDifference(SDL_FloatPoint *points, SDL_FloatPoint *templ) | ||||||
| @@ -369,7 +369,8 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points, SD | |||||||
|     interval = length / (DOLLARNPOINTS - 1); |     interval = length / (DOLLARNPOINTS - 1); | ||||||
|     dist = interval; |     dist = interval; | ||||||
|  |  | ||||||
|     centroid.x = 0;centroid.y = 0; |     centroid.x = 0; | ||||||
|  |     centroid.y = 0; | ||||||
|  |  | ||||||
|     /* printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); */ |     /* printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); */ | ||||||
|     for (i = 1; i < path->numPoints; i++) { |     for (i = 1; i < path->numPoints; i++) { | ||||||
| @@ -420,7 +421,6 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points, SD | |||||||
|         points[i].y = (float)((px - centroid.x) * SDL_sin(ang) + |         points[i].y = (float)((px - centroid.x) * SDL_sin(ang) + | ||||||
|                               (py - centroid.y) * SDL_cos(ang) + centroid.y); |                               (py - centroid.y) * SDL_cos(ang) + centroid.y); | ||||||
|  |  | ||||||
|  |  | ||||||
|         if (points[i].x < xmin) { |         if (points[i].x < xmin) { | ||||||
|             xmin = points[i].x; |             xmin = points[i].x; | ||||||
|         } |         } | ||||||
| @@ -460,7 +460,10 @@ static float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_Gestu | |||||||
|     *bestTempl = -1; |     *bestTempl = -1; | ||||||
|     for (i = 0; i < touch->numDollarTemplates; i++) { |     for (i = 0; i < touch->numDollarTemplates; i++) { | ||||||
|         float diff = bestDollarDifference(points, touch->dollarTemplate[i].path); |         float diff = bestDollarDifference(points, touch->dollarTemplate[i].path); | ||||||
|         if (diff < bestDiff) {bestDiff = diff; *bestTempl = i;} |         if (diff < bestDiff) { | ||||||
|  |             bestDiff = diff; | ||||||
|  |             *bestTempl = i; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|     return bestDiff; |     return bestDiff; | ||||||
| } | } | ||||||
| @@ -565,7 +568,6 @@ static void SDL_SendDollarRecord(SDL_GestureTouch* touch,SDL_GestureID gestureId | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| void SDL_GestureProcessEvent(SDL_Event *event) | void SDL_GestureProcessEvent(SDL_Event *event) | ||||||
| { | { | ||||||
|     float x, y; |     float x, y; | ||||||
| @@ -637,9 +639,11 @@ void SDL_GestureProcessEvent(SDL_Event* event) | |||||||
|             /* inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; */ |             /* inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; */ | ||||||
|             if (inTouch->numDownFingers > 0) { |             if (inTouch->numDownFingers > 0) { | ||||||
|                 inTouch->centroid.x = (inTouch->centroid.x * (inTouch->numDownFingers + 1) - |                 inTouch->centroid.x = (inTouch->centroid.x * (inTouch->numDownFingers + 1) - | ||||||
|                                        x)/inTouch->numDownFingers; |                                        x) / | ||||||
|  |                                       inTouch->numDownFingers; | ||||||
|                 inTouch->centroid.y = (inTouch->centroid.y * (inTouch->numDownFingers + 1) - |                 inTouch->centroid.y = (inTouch->centroid.y * (inTouch->numDownFingers + 1) - | ||||||
|                                        y)/inTouch->numDownFingers; |                                        y) / | ||||||
|  |                                       inTouch->numDownFingers; | ||||||
|             } |             } | ||||||
|         } else if (event->type == SDL_FINGERMOTION) { |         } else if (event->type == SDL_FINGERMOTION) { | ||||||
|             float dx = event->tfinger.dx; |             float dx = event->tfinger.dx; | ||||||
| @@ -692,7 +696,6 @@ void SDL_GestureProcessEvent(SDL_Event* event) | |||||||
|                     dtheta = 0; |                     dtheta = 0; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|  |  | ||||||
|                 /* inTouch->gestureLast[j].dDist = dDist; |                 /* inTouch->gestureLast[j].dDist = dDist; | ||||||
|                 inTouch->gestureLast[j].dtheta = dtheta; |                 inTouch->gestureLast[j].dtheta = dtheta; | ||||||
|  |  | ||||||
| @@ -718,9 +721,11 @@ void SDL_GestureProcessEvent(SDL_Event* event) | |||||||
|  |  | ||||||
|             inTouch->numDownFingers++; |             inTouch->numDownFingers++; | ||||||
|             inTouch->centroid.x = (inTouch->centroid.x * (inTouch->numDownFingers - 1) + |             inTouch->centroid.x = (inTouch->centroid.x * (inTouch->numDownFingers - 1) + | ||||||
|                                    x)/inTouch->numDownFingers; |                                    x) / | ||||||
|  |                                   inTouch->numDownFingers; | ||||||
|             inTouch->centroid.y = (inTouch->centroid.y * (inTouch->numDownFingers - 1) + |             inTouch->centroid.y = (inTouch->centroid.y * (inTouch->numDownFingers - 1) + | ||||||
|                                    y)/inTouch->numDownFingers; |                                    y) / | ||||||
|  |                                   inTouch->numDownFingers; | ||||||
|             /* printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y, |             /* printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y, | ||||||
|                  inTouch->centroid.x,inTouch->centroid.y); */ |                  inTouch->centroid.x,inTouch->centroid.y); */ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -29,7 +29,6 @@ | |||||||
| #include "../video/SDL_sysvideo.h" | #include "../video/SDL_sysvideo.h" | ||||||
| #include "scancodes_ascii.h" | #include "scancodes_ascii.h" | ||||||
|  |  | ||||||
|  |  | ||||||
| /* #define DEBUG_KEYBOARD */ | /* #define DEBUG_KEYBOARD */ | ||||||
|  |  | ||||||
| /* Global keyboard information */ | /* Global keyboard information */ | ||||||
| @@ -668,16 +667,14 @@ SDL_UCS4ToUTF8(Uint32 ch, char *dst) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* Public functions */ | /* Public functions */ | ||||||
| int | int SDL_KeyboardInit(void) | ||||||
| SDL_KeyboardInit(void) |  | ||||||
| { | { | ||||||
|     /* Set the default keymap */ |     /* Set the default keymap */ | ||||||
|     SDL_SetKeymap(0, SDL_default_keymap, SDL_NUM_SCANCODES, SDL_FALSE); |     SDL_SetKeymap(0, SDL_default_keymap, SDL_NUM_SCANCODES, SDL_FALSE); | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_ResetKeyboard(void) | ||||||
| SDL_ResetKeyboard(void) |  | ||||||
| { | { | ||||||
|     SDL_Keyboard *keyboard = &SDL_keyboard; |     SDL_Keyboard *keyboard = &SDL_keyboard; | ||||||
|     SDL_Scancode scancode; |     SDL_Scancode scancode; | ||||||
| @@ -692,14 +689,12 @@ SDL_ResetKeyboard(void) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_GetDefaultKeymap(SDL_Keycode *keymap) | ||||||
| SDL_GetDefaultKeymap(SDL_Keycode * keymap) |  | ||||||
| { | { | ||||||
|     SDL_memcpy(keymap, SDL_default_keymap, sizeof(SDL_default_keymap)); |     SDL_memcpy(keymap, SDL_default_keymap, sizeof(SDL_default_keymap)); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_SetKeymap(int start, const SDL_Keycode *keys, int length, SDL_bool send_event) | ||||||
| SDL_SetKeymap(int start, const SDL_Keycode * keys, int length, SDL_bool send_event) |  | ||||||
| { | { | ||||||
|     SDL_Keyboard *keyboard = &SDL_keyboard; |     SDL_Keyboard *keyboard = &SDL_keyboard; | ||||||
|     SDL_Scancode scancode; |     SDL_Scancode scancode; | ||||||
| @@ -732,8 +727,7 @@ SDL_SetKeymap(int start, const SDL_Keycode * keys, int length, SDL_bool send_eve | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_SetScancodeName(SDL_Scancode scancode, const char *name) | ||||||
| SDL_SetScancodeName(SDL_Scancode scancode, const char *name) |  | ||||||
| { | { | ||||||
|     if (scancode >= SDL_NUM_SCANCODES) { |     if (scancode >= SDL_NUM_SCANCODES) { | ||||||
|         return; |         return; | ||||||
| @@ -749,8 +743,7 @@ SDL_GetKeyboardFocus(void) | |||||||
|     return keyboard->focus; |     return keyboard->focus; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_SetKeyboardFocus(SDL_Window *window) | ||||||
| SDL_SetKeyboardFocus(SDL_Window * window) |  | ||||||
| { | { | ||||||
|     SDL_Keyboard *keyboard = &SDL_keyboard; |     SDL_Keyboard *keyboard = &SDL_keyboard; | ||||||
|  |  | ||||||
| @@ -799,8 +792,7 @@ SDL_SetKeyboardFocus(SDL_Window * window) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_SendKeyboardKeyInternal(Uint8 source, Uint8 state, SDL_Scancode scancode, SDL_Keycode keycode) | ||||||
| SDL_SendKeyboardKeyInternal(Uint8 source, Uint8 state, SDL_Scancode scancode, SDL_Keycode keycode) |  | ||||||
| { | { | ||||||
|     SDL_Keyboard *keyboard = &SDL_keyboard; |     SDL_Keyboard *keyboard = &SDL_keyboard; | ||||||
|     int posted; |     int posted; | ||||||
| @@ -942,8 +934,7 @@ SDL_SendKeyboardKeyInternal(Uint8 source, Uint8 state, SDL_Scancode scancode, SD | |||||||
|     return posted; |     return posted; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendKeyboardUnicodeKey(Uint32 ch) | ||||||
| SDL_SendKeyboardUnicodeKey(Uint32 ch) |  | ||||||
| { | { | ||||||
|     SDL_Scancode code = SDL_SCANCODE_UNKNOWN; |     SDL_Scancode code = SDL_SCANCODE_UNKNOWN; | ||||||
|     uint16_t mod = 0; |     uint16_t mod = 0; | ||||||
| @@ -969,26 +960,22 @@ SDL_SendKeyboardUnicodeKey(Uint32 ch) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode) | ||||||
| SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode) |  | ||||||
| { | { | ||||||
|     return SDL_SendKeyboardKeyInternal(KEYBOARD_HARDWARE, state, scancode, SDLK_UNKNOWN); |     return SDL_SendKeyboardKeyInternal(KEYBOARD_HARDWARE, state, scancode, SDLK_UNKNOWN); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendKeyboardKeyAndKeycode(Uint8 state, SDL_Scancode scancode, SDL_Keycode keycode) | ||||||
| SDL_SendKeyboardKeyAndKeycode(Uint8 state, SDL_Scancode scancode, SDL_Keycode keycode) |  | ||||||
| { | { | ||||||
|     return SDL_SendKeyboardKeyInternal(KEYBOARD_HARDWARE, state, scancode, keycode); |     return SDL_SendKeyboardKeyInternal(KEYBOARD_HARDWARE, state, scancode, keycode); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendKeyboardKeyAutoRelease(SDL_Scancode scancode) | ||||||
| SDL_SendKeyboardKeyAutoRelease(SDL_Scancode scancode) |  | ||||||
| { | { | ||||||
|     return SDL_SendKeyboardKeyInternal(KEYBOARD_AUTORELEASE, SDL_PRESSED, scancode, SDLK_UNKNOWN); |     return SDL_SendKeyboardKeyInternal(KEYBOARD_AUTORELEASE, SDL_PRESSED, scancode, SDLK_UNKNOWN); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_ReleaseAutoReleaseKeys(void) | ||||||
| SDL_ReleaseAutoReleaseKeys(void) |  | ||||||
| { | { | ||||||
|     SDL_Keyboard *keyboard = &SDL_keyboard; |     SDL_Keyboard *keyboard = &SDL_keyboard; | ||||||
|     SDL_Scancode scancode; |     SDL_Scancode scancode; | ||||||
| @@ -1017,8 +1004,7 @@ SDL_HardwareKeyboardKeyPressed(void) | |||||||
|     return SDL_FALSE; |     return SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendKeyboardText(const char *text) | ||||||
| SDL_SendKeyboardText(const char *text) |  | ||||||
| { | { | ||||||
|     SDL_Keyboard *keyboard = &SDL_keyboard; |     SDL_Keyboard *keyboard = &SDL_keyboard; | ||||||
|     int posted; |     int posted; | ||||||
| @@ -1048,8 +1034,7 @@ SDL_SendKeyboardText(const char *text) | |||||||
|     return posted; |     return posted; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendEditingText(const char *text, int start, int length) | ||||||
| SDL_SendEditingText(const char *text, int start, int length) |  | ||||||
| { | { | ||||||
|     SDL_Keyboard *keyboard = &SDL_keyboard; |     SDL_Keyboard *keyboard = &SDL_keyboard; | ||||||
|     int posted; |     int posted; | ||||||
| @@ -1079,8 +1064,7 @@ SDL_SendEditingText(const char *text, int start, int length) | |||||||
|     return posted; |     return posted; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_KeyboardQuit(void) | ||||||
| SDL_KeyboardQuit(void) |  | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -1103,8 +1087,7 @@ SDL_GetModState(void) | |||||||
|     return (SDL_Keymod)keyboard->modstate; |     return (SDL_Keymod)keyboard->modstate; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_SetModState(SDL_Keymod modstate) | ||||||
| SDL_SetModState(SDL_Keymod modstate) |  | ||||||
| { | { | ||||||
|     SDL_Keyboard *keyboard = &SDL_keyboard; |     SDL_Keyboard *keyboard = &SDL_keyboard; | ||||||
|  |  | ||||||
| @@ -1112,8 +1095,7 @@ SDL_SetModState(SDL_Keymod modstate) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* Note that SDL_ToggleModState() is not a public API. SDL_SetModState() is. */ | /* Note that SDL_ToggleModState() is not a public API. SDL_SetModState() is. */ | ||||||
| void | void SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle) | ||||||
| SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle) |  | ||||||
| { | { | ||||||
|     SDL_Keyboard *keyboard = &SDL_keyboard; |     SDL_Keyboard *keyboard = &SDL_keyboard; | ||||||
|     if (toggle) { |     if (toggle) { | ||||||
| @@ -1123,7 +1105,6 @@ SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| SDL_Keycode | SDL_Keycode | ||||||
| SDL_GetKeyFromScancode(SDL_Scancode scancode) | SDL_GetKeyFromScancode(SDL_Scancode scancode) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -44,11 +44,9 @@ static SDL_Mouse SDL_mouse; | |||||||
| /* for mapping mouse events to touch */ | /* for mapping mouse events to touch */ | ||||||
| static SDL_bool track_mouse_down = SDL_FALSE; | static SDL_bool track_mouse_down = SDL_FALSE; | ||||||
|  |  | ||||||
| static int | static int SDL_PrivateSendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y); | ||||||
| SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y); |  | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_MouseDoubleClickTimeChanged(void *userdata, const char *name, const char *oldValue, const char *hint) | ||||||
| SDL_MouseDoubleClickTimeChanged(void *userdata, const char *name, const char *oldValue, const char *hint) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = (SDL_Mouse *)userdata; |     SDL_Mouse *mouse = (SDL_Mouse *)userdata; | ||||||
|  |  | ||||||
| @@ -65,8 +63,7 @@ SDL_MouseDoubleClickTimeChanged(void *userdata, const char *name, const char *ol | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_MouseDoubleClickRadiusChanged(void *userdata, const char *name, const char *oldValue, const char *hint) | ||||||
| SDL_MouseDoubleClickRadiusChanged(void *userdata, const char *name, const char *oldValue, const char *hint) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = (SDL_Mouse *)userdata; |     SDL_Mouse *mouse = (SDL_Mouse *)userdata; | ||||||
|  |  | ||||||
| @@ -77,8 +74,7 @@ SDL_MouseDoubleClickRadiusChanged(void *userdata, const char *name, const char * | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_MouseNormalSpeedScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) | ||||||
| SDL_MouseNormalSpeedScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = (SDL_Mouse *)userdata; |     SDL_Mouse *mouse = (SDL_Mouse *)userdata; | ||||||
|  |  | ||||||
| @@ -91,8 +87,7 @@ SDL_MouseNormalSpeedScaleChanged(void *userdata, const char *name, const char *o | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_MouseRelativeSpeedScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) | ||||||
| SDL_MouseRelativeSpeedScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = (SDL_Mouse *)userdata; |     SDL_Mouse *mouse = (SDL_Mouse *)userdata; | ||||||
|  |  | ||||||
| @@ -105,16 +100,14 @@ SDL_MouseRelativeSpeedScaleChanged(void *userdata, const char *name, const char | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_MouseRelativeSystemScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) | ||||||
| SDL_MouseRelativeSystemScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = (SDL_Mouse *)userdata; |     SDL_Mouse *mouse = (SDL_Mouse *)userdata; | ||||||
|  |  | ||||||
|     mouse->enable_relative_system_scale = SDL_GetStringBoolean(hint, SDL_FALSE); |     mouse->enable_relative_system_scale = SDL_GetStringBoolean(hint, SDL_FALSE); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_TouchMouseEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) | ||||||
| SDL_TouchMouseEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = (SDL_Mouse *)userdata; |     SDL_Mouse *mouse = (SDL_Mouse *)userdata; | ||||||
|  |  | ||||||
| @@ -122,8 +115,7 @@ SDL_TouchMouseEventsChanged(void *userdata, const char *name, const char *oldVal | |||||||
| } | } | ||||||
|  |  | ||||||
| #if defined(__vita__) | #if defined(__vita__) | ||||||
| static void SDLCALL | static void SDLCALL SDL_VitaTouchMouseDeviceChanged(void *userdata, const char *name, const char *oldValue, const char *hint) | ||||||
| SDL_VitaTouchMouseDeviceChanged(void *userdata, const char *name, const char *oldValue, const char *hint) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = (SDL_Mouse *)userdata; |     SDL_Mouse *mouse = (SDL_Mouse *)userdata; | ||||||
|     if (hint) { |     if (hint) { | ||||||
| @@ -143,8 +135,7 @@ SDL_VitaTouchMouseDeviceChanged(void *userdata, const char *name, const char *ol | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_MouseTouchEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) | ||||||
| SDL_MouseTouchEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = (SDL_Mouse *)userdata; |     SDL_Mouse *mouse = (SDL_Mouse *)userdata; | ||||||
|     SDL_bool default_value; |     SDL_bool default_value; | ||||||
| @@ -161,8 +152,7 @@ SDL_MouseTouchEventsChanged(void *userdata, const char *name, const char *oldVal | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_MouseAutoCaptureChanged(void *userdata, const char *name, const char *oldValue, const char *hint) | ||||||
| SDL_MouseAutoCaptureChanged(void *userdata, const char *name, const char *oldValue, const char *hint) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = (SDL_Mouse *)userdata; |     SDL_Mouse *mouse = (SDL_Mouse *)userdata; | ||||||
|     SDL_bool auto_capture = SDL_GetStringBoolean(hint, SDL_TRUE); |     SDL_bool auto_capture = SDL_GetStringBoolean(hint, SDL_TRUE); | ||||||
| @@ -173,8 +163,7 @@ SDL_MouseAutoCaptureChanged(void *userdata, const char *name, const char *oldVal | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static void SDLCALL | static void SDLCALL SDL_MouseRelativeWarpMotionChanged(void *userdata, const char *name, const char *oldValue, const char *hint) | ||||||
| SDL_MouseRelativeWarpMotionChanged(void *userdata, const char *name, const char *oldValue, const char *hint) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = (SDL_Mouse *)userdata; |     SDL_Mouse *mouse = (SDL_Mouse *)userdata; | ||||||
|  |  | ||||||
| @@ -182,8 +171,7 @@ SDL_MouseRelativeWarpMotionChanged(void *userdata, const char *name, const char | |||||||
| } | } | ||||||
|  |  | ||||||
| /* Public functions */ | /* Public functions */ | ||||||
| int | int SDL_MouseInit(void) | ||||||
| SDL_MouseInit(void) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|  |  | ||||||
| @@ -228,8 +216,7 @@ SDL_MouseInit(void) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_SetDefaultCursor(SDL_Cursor *cursor) | ||||||
| SDL_SetDefaultCursor(SDL_Cursor * cursor) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|  |  | ||||||
| @@ -290,8 +277,7 @@ SDL_ResetMouse(void) | |||||||
| } | } | ||||||
| #endif /* 0 */ | #endif /* 0 */ | ||||||
|  |  | ||||||
| void | void SDL_SetMouseFocus(SDL_Window *window) | ||||||
| SDL_SetMouseFocus(SDL_Window * window) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|  |  | ||||||
| @@ -328,8 +314,7 @@ SDL_SetMouseFocus(SDL_Window * window) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* Check to see if we need to synthesize focus events */ | /* Check to see if we need to synthesize focus events */ | ||||||
| static SDL_bool | static SDL_bool SDL_UpdateMouseFocus(SDL_Window *window, int x, int y, Uint32 buttonstate, SDL_bool send_mouse_motion) | ||||||
| SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate, SDL_bool send_mouse_motion) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|     SDL_bool inWindow = SDL_TRUE; |     SDL_bool inWindow = SDL_TRUE; | ||||||
| @@ -367,8 +352,7 @@ SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate, SDL_ | |||||||
|     return SDL_TRUE; |     return SDL_TRUE; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y) | ||||||
| SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y) |  | ||||||
| { | { | ||||||
|     if (window && !relative) { |     if (window && !relative) { | ||||||
|         SDL_Mouse *mouse = SDL_GetMouse(); |         SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
| @@ -380,8 +364,7 @@ SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int | |||||||
|     return SDL_PrivateSendMouseMotion(window, mouseID, relative, x, y); |     return SDL_PrivateSendMouseMotion(window, mouseID, relative, x, y); | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int GetScaledMouseDelta(float scale, int value, float *accum) | ||||||
| GetScaledMouseDelta(float scale, int value, float *accum) |  | ||||||
| { | { | ||||||
|     if (value && scale != 1.0f) { |     if (value && scale != 1.0f) { | ||||||
|         if ((value > 0) != (*accum > 0)) { |         if ((value > 0) != (*accum > 0)) { | ||||||
| @@ -398,8 +381,7 @@ GetScaledMouseDelta(float scale, int value, float *accum) | |||||||
|     return value; |     return value; | ||||||
| } | } | ||||||
|  |  | ||||||
| static float | static float CalculateSystemScale(SDL_Mouse *mouse, int *x, int *y) | ||||||
| CalculateSystemScale(SDL_Mouse *mouse, int *x, int *y) |  | ||||||
| { | { | ||||||
|     int i; |     int i; | ||||||
|     int n = mouse->num_system_scale_values; |     int n = mouse->num_system_scale_values; | ||||||
| @@ -430,8 +412,7 @@ CalculateSystemScale(SDL_Mouse *mouse, int *x, int *y) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* You can set either a single scale, or a set of {speed, scale} values in ascending order */ | /* You can set either a single scale, or a set of {speed, scale} values in ascending order */ | ||||||
| int | int SDL_SetMouseSystemScale(int num_values, const float *values) | ||||||
| SDL_SetMouseSystemScale(int num_values, const float *values) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|     float *v; |     float *v; | ||||||
| @@ -472,8 +453,7 @@ SDL_SetMouseSystemScale(int num_values, const float *values) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void GetScaledMouseDeltas(SDL_Mouse *mouse, int *x, int *y) | ||||||
| GetScaledMouseDeltas(SDL_Mouse *mouse, int *x, int *y) |  | ||||||
| { | { | ||||||
|     if (mouse->relative_mode) { |     if (mouse->relative_mode) { | ||||||
|         if (mouse->enable_relative_speed_scale) { |         if (mouse->enable_relative_speed_scale) { | ||||||
| @@ -492,8 +472,7 @@ GetScaledMouseDeltas(SDL_Mouse *mouse, int *x, int *y) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_PrivateSendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y) | ||||||
| SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|     int posted; |     int posted; | ||||||
| @@ -698,8 +677,7 @@ static SDL_MouseClickState *GetMouseClickState(SDL_Mouse *mouse, Uint8 button) | |||||||
|     return &mouse->clickstate[button]; |     return &mouse->clickstate[button]; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_PrivateSendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks) | ||||||
| SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|     int posted; |     int posted; | ||||||
| @@ -814,21 +792,18 @@ SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state | |||||||
|     return posted; |     return posted; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendMouseButtonClicks(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks) | ||||||
| SDL_SendMouseButtonClicks(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks) |  | ||||||
| { | { | ||||||
|     clicks = SDL_max(clicks, 0); |     clicks = SDL_max(clicks, 0); | ||||||
|     return SDL_PrivateSendMouseButton(window, mouseID, state, button, clicks); |     return SDL_PrivateSendMouseButton(window, mouseID, state, button, clicks); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button) | ||||||
| SDL_SendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button) |  | ||||||
| { | { | ||||||
|     return SDL_PrivateSendMouseButton(window, mouseID, state, button, -1); |     return SDL_PrivateSendMouseButton(window, mouseID, state, button, -1); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction) | ||||||
| SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|     int posted; |     int posted; | ||||||
| @@ -899,8 +874,7 @@ SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, S | |||||||
|     return posted; |     return posted; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_MouseQuit(void) | ||||||
| SDL_MouseQuit(void) |  | ||||||
| { | { | ||||||
|     SDL_Cursor *cursor, *next; |     SDL_Cursor *cursor, *next; | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
| @@ -1020,8 +994,7 @@ SDL_GetGlobalMouseState(int *x, int *y) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_relative_mode) | ||||||
| SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_relative_mode) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|  |  | ||||||
| @@ -1066,14 +1039,12 @@ SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_r | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_WarpMouseInWindow(SDL_Window *window, int x, int y) | ||||||
| SDL_WarpMouseInWindow(SDL_Window * window, int x, int y) |  | ||||||
| { | { | ||||||
|     SDL_PerformWarpMouseInWindow(window, x, y, SDL_FALSE); |     SDL_PerformWarpMouseInWindow(window, x, y, SDL_FALSE); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_WarpMouseGlobal(int x, int y) | ||||||
| SDL_WarpMouseGlobal(int x, int y) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|  |  | ||||||
| @@ -1084,8 +1055,7 @@ SDL_WarpMouseGlobal(int x, int y) | |||||||
|     return SDL_Unsupported(); |     return SDL_Unsupported(); | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool | static SDL_bool ShouldUseRelativeModeWarp(SDL_Mouse *mouse) | ||||||
| ShouldUseRelativeModeWarp(SDL_Mouse *mouse) |  | ||||||
| { | { | ||||||
|     if (!mouse->WarpMouse) { |     if (!mouse->WarpMouse) { | ||||||
|         /* Need this functionality for relative mode warp implementation */ |         /* Need this functionality for relative mode warp implementation */ | ||||||
| @@ -1095,8 +1065,7 @@ ShouldUseRelativeModeWarp(SDL_Mouse *mouse) | |||||||
|     return SDL_GetHintBoolean(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, SDL_FALSE); |     return SDL_GetHintBoolean(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, SDL_FALSE); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SetRelativeMouseMode(SDL_bool enabled) | ||||||
| SDL_SetRelativeMouseMode(SDL_bool enabled) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|     SDL_Window *focusWindow = SDL_GetKeyboardFocus(); |     SDL_Window *focusWindow = SDL_GetKeyboardFocus(); | ||||||
| @@ -1166,8 +1135,7 @@ SDL_GetRelativeMouseMode() | |||||||
|     return mouse->relative_mode; |     return mouse->relative_mode; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_UpdateMouseCapture(SDL_bool force_release) | ||||||
| SDL_UpdateMouseCapture(SDL_bool force_release) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|     SDL_Window *capture_window = NULL; |     SDL_Window *capture_window = NULL; | ||||||
| @@ -1218,8 +1186,7 @@ SDL_UpdateMouseCapture(SDL_bool force_release) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_CaptureMouse(SDL_bool enabled) | ||||||
| SDL_CaptureMouse(SDL_bool enabled) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|  |  | ||||||
| @@ -1362,8 +1329,7 @@ SDL_CreateSystemCursor(SDL_SystemCursor id) | |||||||
|    if this is desired for any reason.  This is used when setting |    if this is desired for any reason.  This is used when setting | ||||||
|    the video mode and when the SDL window gains the mouse focus. |    the video mode and when the SDL window gains the mouse focus. | ||||||
|  */ |  */ | ||||||
| void | void SDL_SetCursor(SDL_Cursor *cursor) | ||||||
| SDL_SetCursor(SDL_Cursor * cursor) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|  |  | ||||||
| @@ -1424,8 +1390,7 @@ SDL_GetDefaultCursor(void) | |||||||
|     return mouse->def_cursor; |     return mouse->def_cursor; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_FreeCursor(SDL_Cursor *cursor) | ||||||
| SDL_FreeCursor(SDL_Cursor * cursor) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|     SDL_Cursor *curr, *prev; |     SDL_Cursor *curr, *prev; | ||||||
| @@ -1458,8 +1423,7 @@ SDL_FreeCursor(SDL_Cursor * cursor) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_ShowCursor(int toggle) | ||||||
| SDL_ShowCursor(int toggle) |  | ||||||
| { | { | ||||||
|     SDL_Mouse *mouse = SDL_GetMouse(); |     SDL_Mouse *mouse = SDL_GetMouse(); | ||||||
|     SDL_bool shown; |     SDL_bool shown; | ||||||
|   | |||||||
| @@ -130,7 +130,6 @@ typedef struct | |||||||
|     void *driverdata; |     void *driverdata; | ||||||
| } SDL_Mouse; | } SDL_Mouse; | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Initialize the mouse subsystem */ | /* Initialize the mouse subsystem */ | ||||||
| extern int SDL_MouseInit(void); | extern int SDL_MouseInit(void); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -47,8 +47,7 @@ static SDL_bool send_backgrounding_pending = SDL_FALSE; | |||||||
| static SDL_bool send_foregrounding_pending = SDL_FALSE; | static SDL_bool send_foregrounding_pending = SDL_FALSE; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| static void | static void SDL_HandleSIG(int sig) | ||||||
| SDL_HandleSIG(int sig) |  | ||||||
| { | { | ||||||
|     /* Reset the signal handler */ |     /* Reset the signal handler */ | ||||||
|     signal(sig, SDL_HandleSIG); |     signal(sig, SDL_HandleSIG); | ||||||
| @@ -72,8 +71,7 @@ SDL_HandleSIG(int sig) | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_EventSignal_Init(const int sig) | ||||||
| SDL_EventSignal_Init(const int sig) |  | ||||||
| { | { | ||||||
| #ifdef HAVE_SIGACTION | #ifdef HAVE_SIGACTION | ||||||
|     struct sigaction action; |     struct sigaction action; | ||||||
| @@ -95,8 +93,7 @@ SDL_EventSignal_Init(const int sig) | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_EventSignal_Quit(const int sig) | ||||||
| SDL_EventSignal_Quit(const int sig) |  | ||||||
| { | { | ||||||
| #ifdef HAVE_SIGACTION | #ifdef HAVE_SIGACTION | ||||||
|     struct sigaction action; |     struct sigaction action; | ||||||
| @@ -114,8 +111,7 @@ SDL_EventSignal_Quit(const int sig) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* Public functions */ | /* Public functions */ | ||||||
| static int | static int SDL_QuitInit_Internal(void) | ||||||
| SDL_QuitInit_Internal(void) |  | ||||||
| { | { | ||||||
|     /* Both SIGINT and SIGTERM are translated into quit interrupts */ |     /* Both SIGINT and SIGTERM are translated into quit interrupts */ | ||||||
|     /* and SDL can be built to simulate iOS/Android semantics with arbitrary signals. */ |     /* and SDL can be built to simulate iOS/Android semantics with arbitrary signals. */ | ||||||
| @@ -134,8 +130,7 @@ SDL_QuitInit_Internal(void) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void SDL_QuitQuit_Internal(void) | ||||||
| SDL_QuitQuit_Internal(void) |  | ||||||
| { | { | ||||||
|     SDL_EventSignal_Quit(SIGINT); |     SDL_EventSignal_Quit(SIGINT); | ||||||
|     SDL_EventSignal_Quit(SIGTERM); |     SDL_EventSignal_Quit(SIGTERM); | ||||||
| @@ -150,8 +145,7 @@ SDL_QuitQuit_Internal(void) | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| int | int SDL_QuitInit(void) | ||||||
| SDL_QuitInit(void) |  | ||||||
| { | { | ||||||
| #ifdef HAVE_SIGNAL_SUPPORT | #ifdef HAVE_SIGNAL_SUPPORT | ||||||
|     if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) { |     if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) { | ||||||
| @@ -161,8 +155,7 @@ SDL_QuitInit(void) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_QuitQuit(void) | ||||||
| SDL_QuitQuit(void) |  | ||||||
| { | { | ||||||
| #ifdef HAVE_SIGNAL_SUPPORT | #ifdef HAVE_SIGNAL_SUPPORT | ||||||
|     if (!disable_signals) { |     if (!disable_signals) { | ||||||
| @@ -171,8 +164,7 @@ SDL_QuitQuit(void) | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_SendPendingSignalEvents(void) | ||||||
| SDL_SendPendingSignalEvents(void) |  | ||||||
| { | { | ||||||
| #ifdef HAVE_SIGNAL_SUPPORT | #ifdef HAVE_SIGNAL_SUPPORT | ||||||
|     if (send_quit_pending) { |     if (send_quit_pending) { | ||||||
| @@ -197,8 +189,7 @@ SDL_SendPendingSignalEvents(void) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* This function returns 1 if it's okay to close the application window */ | /* This function returns 1 if it's okay to close the application window */ | ||||||
| int | int SDL_SendQuit(void) | ||||||
| SDL_SendQuit(void) |  | ||||||
| { | { | ||||||
| #ifdef HAVE_SIGNAL_SUPPORT | #ifdef HAVE_SIGNAL_SUPPORT | ||||||
|     send_quit_pending = SDL_FALSE; |     send_quit_pending = SDL_FALSE; | ||||||
|   | |||||||
| @@ -26,7 +26,6 @@ | |||||||
| #include "SDL_events_c.h" | #include "SDL_events_c.h" | ||||||
| #include "../video/SDL_sysvideo.h" | #include "../video/SDL_sysvideo.h" | ||||||
|  |  | ||||||
|  |  | ||||||
| static int SDL_num_touch = 0; | static int SDL_num_touch = 0; | ||||||
| static SDL_Touch **SDL_touchDevices = NULL; | static SDL_Touch **SDL_touchDevices = NULL; | ||||||
|  |  | ||||||
| @@ -41,14 +40,12 @@ static SDL_TouchID  track_touchid; | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| /* Public functions */ | /* Public functions */ | ||||||
| int | int SDL_TouchInit(void) | ||||||
| SDL_TouchInit(void) |  | ||||||
| { | { | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_GetNumTouchDevices(void) | ||||||
| SDL_GetNumTouchDevices(void) |  | ||||||
| { | { | ||||||
|     return SDL_num_touch; |     return SDL_num_touch; | ||||||
| } | } | ||||||
| @@ -73,8 +70,7 @@ SDL_GetTouchName(int index) | |||||||
|     return SDL_touchDevices[index]->name; |     return SDL_touchDevices[index]->name; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_GetTouchIndex(SDL_TouchID id) | ||||||
| SDL_GetTouchIndex(SDL_TouchID id) |  | ||||||
| { | { | ||||||
|     int index; |     int index; | ||||||
|     SDL_Touch *touch; |     SDL_Touch *touch; | ||||||
| @@ -114,8 +110,7 @@ SDL_GetTouchDeviceType(SDL_TouchID id) | |||||||
|     return SDL_TOUCH_DEVICE_INVALID; |     return SDL_TOUCH_DEVICE_INVALID; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_GetFingerIndex(const SDL_Touch *touch, SDL_FingerID fingerid) | ||||||
| SDL_GetFingerIndex(const SDL_Touch * touch, SDL_FingerID fingerid) |  | ||||||
| { | { | ||||||
|     int index; |     int index; | ||||||
|     for (index = 0; index < touch->num_fingers; ++index) { |     for (index = 0; index < touch->num_fingers; ++index) { | ||||||
| @@ -126,8 +121,7 @@ SDL_GetFingerIndex(const SDL_Touch * touch, SDL_FingerID fingerid) | |||||||
|     return -1; |     return -1; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_Finger * | static SDL_Finger *SDL_GetFinger(const SDL_Touch *touch, SDL_FingerID id) | ||||||
| SDL_GetFinger(const SDL_Touch * touch, SDL_FingerID id) |  | ||||||
| { | { | ||||||
|     int index = SDL_GetFingerIndex(touch, id); |     int index = SDL_GetFingerIndex(touch, id); | ||||||
|     if (index < 0 || index >= touch->num_fingers) { |     if (index < 0 || index >= touch->num_fingers) { | ||||||
| @@ -136,8 +130,7 @@ SDL_GetFinger(const SDL_Touch * touch, SDL_FingerID id) | |||||||
|     return touch->fingers[index]; |     return touch->fingers[index]; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_GetNumTouchFingers(SDL_TouchID touchID) | ||||||
| SDL_GetNumTouchFingers(SDL_TouchID touchID) |  | ||||||
| { | { | ||||||
|     SDL_Touch *touch = SDL_GetTouch(touchID); |     SDL_Touch *touch = SDL_GetTouch(touchID); | ||||||
|     if (touch) { |     if (touch) { | ||||||
| @@ -160,8 +153,7 @@ SDL_GetTouchFinger(SDL_TouchID touchID, int index) | |||||||
|     return touch->fingers[index]; |     return touch->fingers[index]; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name) | ||||||
| SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name) |  | ||||||
| { | { | ||||||
|     SDL_Touch **touchDevices; |     SDL_Touch **touchDevices; | ||||||
|     int index; |     int index; | ||||||
| @@ -204,8 +196,7 @@ SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name) | |||||||
|     return index; |     return index; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float pressure) | ||||||
| SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float pressure) |  | ||||||
| { | { | ||||||
|     SDL_Finger *finger; |     SDL_Finger *finger; | ||||||
|  |  | ||||||
| @@ -231,8 +222,7 @@ SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float p | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int | static int SDL_DelFinger(SDL_Touch *touch, SDL_FingerID fingerid) | ||||||
| SDL_DelFinger(SDL_Touch* touch, SDL_FingerID fingerid) |  | ||||||
| { | { | ||||||
|     SDL_Finger *temp; |     SDL_Finger *temp; | ||||||
|  |  | ||||||
| @@ -248,8 +238,7 @@ SDL_DelFinger(SDL_Touch* touch, SDL_FingerID fingerid) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, | ||||||
| SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window, |  | ||||||
|                   SDL_bool down, float x, float y, float pressure) |                   SDL_bool down, float x, float y, float pressure) | ||||||
| { | { | ||||||
|     int posted; |     int posted; | ||||||
| @@ -376,8 +365,7 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window, | |||||||
|     return posted; |     return posted; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, | ||||||
| SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window, |  | ||||||
|                         float x, float y, float pressure) |                         float x, float y, float pressure) | ||||||
| { | { | ||||||
|     SDL_Touch *touch; |     SDL_Touch *touch; | ||||||
| @@ -469,8 +457,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window, | |||||||
|     return posted; |     return posted; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_DelTouch(SDL_TouchID id) | ||||||
| SDL_DelTouch(SDL_TouchID id) |  | ||||||
| { | { | ||||||
|     int i, index; |     int i, index; | ||||||
|     SDL_Touch *touch; |     SDL_Touch *touch; | ||||||
| @@ -500,8 +487,7 @@ SDL_DelTouch(SDL_TouchID id) | |||||||
|     SDL_GestureDelTouch(id); |     SDL_GestureDelTouch(id); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_TouchQuit(void) | ||||||
| SDL_TouchQuit(void) |  | ||||||
| { | { | ||||||
|     int i; |     int i; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -34,7 +34,6 @@ typedef struct SDL_Touch | |||||||
|     char *name; |     char *name; | ||||||
| } SDL_Touch; | } SDL_Touch; | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Initialize the touch subsystem */ | /* Initialize the touch subsystem */ | ||||||
| extern int SDL_TouchInit(void); | extern int SDL_TouchInit(void); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -33,8 +33,7 @@ typedef struct RemovePendingSizeChangedAndResizedEvents_Data | |||||||
|     SDL_bool saw_resized; |     SDL_bool saw_resized; | ||||||
| } RemovePendingSizeChangedAndResizedEvents_Data; | } RemovePendingSizeChangedAndResizedEvents_Data; | ||||||
|  |  | ||||||
| static int SDLCALL | static int SDLCALL RemovePendingSizeChangedAndResizedEvents(void *_userdata, SDL_Event *event) | ||||||
| RemovePendingSizeChangedAndResizedEvents(void *_userdata, SDL_Event *event) |  | ||||||
| { | { | ||||||
|     RemovePendingSizeChangedAndResizedEvents_Data *userdata = (RemovePendingSizeChangedAndResizedEvents_Data *)_userdata; |     RemovePendingSizeChangedAndResizedEvents_Data *userdata = (RemovePendingSizeChangedAndResizedEvents_Data *)_userdata; | ||||||
|     const SDL_Event *new_event = userdata->new_event; |     const SDL_Event *new_event = userdata->new_event; | ||||||
| @@ -54,8 +53,7 @@ RemovePendingSizeChangedAndResizedEvents(void *_userdata, SDL_Event *event) | |||||||
|     return 1; |     return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int SDLCALL | static int SDLCALL RemovePendingMoveEvents(void *userdata, SDL_Event *event) | ||||||
| RemovePendingMoveEvents(void * userdata, SDL_Event *event) |  | ||||||
| { | { | ||||||
|     SDL_Event *new_event = (SDL_Event *)userdata; |     SDL_Event *new_event = (SDL_Event *)userdata; | ||||||
|  |  | ||||||
| @@ -68,8 +66,7 @@ RemovePendingMoveEvents(void * userdata, SDL_Event *event) | |||||||
|     return 1; |     return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int SDLCALL | static int SDLCALL RemovePendingExposedEvents(void *userdata, SDL_Event *event) | ||||||
| RemovePendingExposedEvents(void * userdata, SDL_Event *event) |  | ||||||
| { | { | ||||||
|     SDL_Event *new_event = (SDL_Event *)userdata; |     SDL_Event *new_event = (SDL_Event *)userdata; | ||||||
|  |  | ||||||
| @@ -82,8 +79,7 @@ RemovePendingExposedEvents(void * userdata, SDL_Event *event) | |||||||
|     return 1; |     return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, | ||||||
| SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, |  | ||||||
|                         int data2) |                         int data2) | ||||||
| { | { | ||||||
|     int posted; |     int posted; | ||||||
|   | |||||||
| @@ -76,8 +76,7 @@ | |||||||
|  |  | ||||||
| #define READAHEAD_BUFFER_SIZE 1024 | #define READAHEAD_BUFFER_SIZE 1024 | ||||||
|  |  | ||||||
| static int SDLCALL | static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, const char *mode) | ||||||
| windows_file_open(SDL_RWops * context, const char *filename, const char *mode) |  | ||||||
| { | { | ||||||
| #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) | #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) | ||||||
|     UINT old_error_mode; |     UINT old_error_mode; | ||||||
| @@ -105,11 +104,9 @@ windows_file_open(SDL_RWops * context, const char *filename, const char *mode) | |||||||
|  |  | ||||||
|     must_exist = (SDL_strchr(mode, 'r') != NULL) ? OPEN_EXISTING : 0; |     must_exist = (SDL_strchr(mode, 'r') != NULL) ? OPEN_EXISTING : 0; | ||||||
|     truncate = (SDL_strchr(mode, 'w') != NULL) ? CREATE_ALWAYS : 0; |     truncate = (SDL_strchr(mode, 'w') != NULL) ? CREATE_ALWAYS : 0; | ||||||
|     r_right = (SDL_strchr(mode, '+') != NULL |     r_right = (SDL_strchr(mode, '+') != NULL || must_exist) ? GENERIC_READ : 0; | ||||||
|                || must_exist) ? GENERIC_READ : 0; |  | ||||||
|     a_mode = (SDL_strchr(mode, 'a') != NULL) ? OPEN_ALWAYS : 0; |     a_mode = (SDL_strchr(mode, 'a') != NULL) ? OPEN_ALWAYS : 0; | ||||||
|     w_right = (a_mode || SDL_strchr(mode, '+') |     w_right = (a_mode || SDL_strchr(mode, '+') || truncate) ? GENERIC_WRITE : 0; | ||||||
|                || truncate) ? GENERIC_WRITE : 0; |  | ||||||
|  |  | ||||||
|     if (!r_right && !w_right) { |     if (!r_right && !w_right) { | ||||||
|         return -1; /* inconsistent mode */ |         return -1; /* inconsistent mode */ | ||||||
| @@ -153,8 +150,7 @@ windows_file_open(SDL_RWops * context, const char *filename, const char *mode) | |||||||
|     return 0; /* ok */ |     return 0; /* ok */ | ||||||
| } | } | ||||||
|  |  | ||||||
| static Sint64 SDLCALL | static Sint64 SDLCALL windows_file_size(SDL_RWops *context) | ||||||
| windows_file_size(SDL_RWops * context) |  | ||||||
| { | { | ||||||
|     LARGE_INTEGER size; |     LARGE_INTEGER size; | ||||||
|  |  | ||||||
| @@ -169,8 +165,7 @@ windows_file_size(SDL_RWops * context) | |||||||
|     return size.QuadPart; |     return size.QuadPart; | ||||||
| } | } | ||||||
|  |  | ||||||
| static Sint64 SDLCALL | static Sint64 SDLCALL windows_file_seek(SDL_RWops *context, Sint64 offset, int whence) | ||||||
| windows_file_seek(SDL_RWops * context, Sint64 offset, int whence) |  | ||||||
| { | { | ||||||
|     DWORD windowswhence; |     DWORD windowswhence; | ||||||
|     LARGE_INTEGER windowsoffset; |     LARGE_INTEGER windowsoffset; | ||||||
| @@ -238,8 +233,7 @@ windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (total_need < READAHEAD_BUFFER_SIZE) { |     if (total_need < READAHEAD_BUFFER_SIZE) { | ||||||
|         if (!ReadFile |         if (!ReadFile(context->hidden.windowsio.h, context->hidden.windowsio.buffer.data, | ||||||
|             (context->hidden.windowsio.h, context->hidden.windowsio.buffer.data, |  | ||||||
|                       READAHEAD_BUFFER_SIZE, &byte_read, NULL)) { |                       READAHEAD_BUFFER_SIZE, &byte_read, NULL)) { | ||||||
|             SDL_Error(SDL_EFREAD); |             SDL_Error(SDL_EFREAD); | ||||||
|             return 0; |             return 0; | ||||||
| @@ -250,8 +244,7 @@ windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) | |||||||
|         context->hidden.windowsio.buffer.left = byte_read - read_ahead; |         context->hidden.windowsio.buffer.left = byte_read - read_ahead; | ||||||
|         total_read += read_ahead; |         total_read += read_ahead; | ||||||
|     } else { |     } else { | ||||||
|         if (!ReadFile |         if (!ReadFile(context->hidden.windowsio.h, ptr, (DWORD)total_need, &byte_read, NULL)) { | ||||||
|             (context->hidden.windowsio.h, ptr, (DWORD)total_need, &byte_read, NULL)) { |  | ||||||
|             SDL_Error(SDL_EFREAD); |             SDL_Error(SDL_EFREAD); | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
| @@ -291,8 +284,7 @@ windows_file_write(SDL_RWops * context, const void *ptr, size_t size, | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (!WriteFile |     if (!WriteFile(context->hidden.windowsio.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) { | ||||||
|         (context->hidden.windowsio.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) { |  | ||||||
|         SDL_Error(SDL_EFWRITE); |         SDL_Error(SDL_EFWRITE); | ||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
| @@ -301,8 +293,7 @@ windows_file_write(SDL_RWops * context, const void *ptr, size_t size, | |||||||
|     return nwritten; |     return nwritten; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int SDLCALL | static int SDLCALL windows_file_close(SDL_RWops *context) | ||||||
| windows_file_close(SDL_RWops * context) |  | ||||||
| { | { | ||||||
|  |  | ||||||
|     if (context) { |     if (context) { | ||||||
| @@ -373,8 +364,7 @@ stdio_size(SDL_RWops * context) | |||||||
|     return size; |     return size; | ||||||
| } | } | ||||||
|  |  | ||||||
| static Sint64 SDLCALL | static Sint64 SDLCALL stdio_seek(SDL_RWops *context, Sint64 offset, int whence) | ||||||
| stdio_seek(SDL_RWops * context, Sint64 offset, int whence) |  | ||||||
| { | { | ||||||
|     int stdiowhence; |     int stdiowhence; | ||||||
|  |  | ||||||
| @@ -432,8 +422,7 @@ stdio_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) | |||||||
|     return nwrote; |     return nwrote; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int SDLCALL | static int SDLCALL stdio_close(SDL_RWops *context) | ||||||
| stdio_close(SDL_RWops * context) |  | ||||||
| { | { | ||||||
|     int status = 0; |     int status = 0; | ||||||
|     if (context) { |     if (context) { | ||||||
| @@ -451,14 +440,12 @@ stdio_close(SDL_RWops * context) | |||||||
|  |  | ||||||
| /* Functions to read/write memory pointers */ | /* Functions to read/write memory pointers */ | ||||||
|  |  | ||||||
| static Sint64 SDLCALL | static Sint64 SDLCALL mem_size(SDL_RWops *context) | ||||||
| mem_size(SDL_RWops * context) |  | ||||||
| { | { | ||||||
|     return (Sint64)(context->hidden.mem.stop - context->hidden.mem.base); |     return (Sint64)(context->hidden.mem.stop - context->hidden.mem.base); | ||||||
| } | } | ||||||
|  |  | ||||||
| static Sint64 SDLCALL | static Sint64 SDLCALL mem_seek(SDL_RWops *context, Sint64 offset, int whence) | ||||||
| mem_seek(SDL_RWops * context, Sint64 offset, int whence) |  | ||||||
| { | { | ||||||
|     Uint8 *newpos; |     Uint8 *newpos; | ||||||
|  |  | ||||||
| @@ -525,8 +512,7 @@ mem_writeconst(SDL_RWops * context, const void *ptr, size_t size, size_t num) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int SDLCALL | static int SDLCALL mem_close(SDL_RWops *context) | ||||||
| mem_close(SDL_RWops * context) |  | ||||||
| { | { | ||||||
|     if (context) { |     if (context) { | ||||||
|         SDL_FreeRW(context); |         SDL_FreeRW(context); | ||||||
| @@ -534,7 +520,6 @@ mem_close(SDL_RWops * context) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Functions to create SDL_RWops structures from various data sources */ | /* Functions to create SDL_RWops structures from various data sources */ | ||||||
|  |  | ||||||
| SDL_RWops * | SDL_RWops * | ||||||
| @@ -728,8 +713,7 @@ SDL_AllocRW(void) | |||||||
|     return area; |     return area; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void SDL_FreeRW(SDL_RWops *area) | ||||||
| SDL_FreeRW(SDL_RWops * area) |  | ||||||
| { | { | ||||||
|     SDL_free(area); |     SDL_free(area); | ||||||
| } | } | ||||||
| @@ -823,16 +807,14 @@ SDL_RWwrite(SDL_RWops *context, const void *ptr, size_t size, size_t num) | |||||||
|     return context->write(context, ptr, size, num); |     return context->write(context, ptr, size, num); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int SDL_RWclose(SDL_RWops *context) | ||||||
| SDL_RWclose(SDL_RWops *context) |  | ||||||
| { | { | ||||||
|     return context->close(context); |     return context->close(context); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Functions for dynamically reading and writing endian-specific values */ | /* Functions for dynamically reading and writing endian-specific values */ | ||||||
|  |  | ||||||
| Uint8 | Uint8 SDL_ReadU8(SDL_RWops *src) | ||||||
| SDL_ReadU8(SDL_RWops * src) |  | ||||||
| { | { | ||||||
|     Uint8 value = 0; |     Uint8 value = 0; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -33,8 +33,8 @@ | |||||||
|  Also, note the bundle layouts are different for iPhone and Mac. |  Also, note the bundle layouts are different for iPhone and Mac. | ||||||
| */ | */ | ||||||
| FILE *SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode) | FILE *SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode) | ||||||
| { @autoreleasepool |  | ||||||
| { | { | ||||||
|  |     @autoreleasepool { | ||||||
|         FILE *fp = NULL; |         FILE *fp = NULL; | ||||||
|         NSFileManager *file_manager; |         NSFileManager *file_manager; | ||||||
|         NSString *resource_path; |         NSString *resource_path; | ||||||
| @@ -59,7 +59,8 @@ FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode) | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         return fp; |         return fp; | ||||||
| }} |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| #endif /* __APPLE__ */ | #endif /* __APPLE__ */ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -35,8 +35,8 @@ | |||||||
|  |  | ||||||
| char * | char * | ||||||
| SDL_GetBasePath(void) | SDL_GetBasePath(void) | ||||||
| { @autoreleasepool |  | ||||||
| { | { | ||||||
|  |     @autoreleasepool { | ||||||
|         NSBundle *bundle = [NSBundle mainBundle]; |         NSBundle *bundle = [NSBundle mainBundle]; | ||||||
|         const char *baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String]; |         const char *baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String]; | ||||||
|         const char *base = NULL; |         const char *base = NULL; | ||||||
| @@ -65,12 +65,13 @@ SDL_GetBasePath(void) | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         return retval; |         return retval; | ||||||
| }} |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| char * | char * | ||||||
| SDL_GetPrefPath(const char *org, const char *app) | SDL_GetPrefPath(const char *org, const char *app) | ||||||
| { @autoreleasepool |  | ||||||
| { | { | ||||||
|  |     @autoreleasepool { | ||||||
|         char *retval = NULL; |         char *retval = NULL; | ||||||
|         NSArray *array; |         NSArray *array; | ||||||
|  |  | ||||||
| @@ -95,8 +96,7 @@ SDL_GetPrefPath(const char *org, const char *app) | |||||||
|          */ |          */ | ||||||
|         { |         { | ||||||
|             static SDL_bool shown = SDL_FALSE; |             static SDL_bool shown = SDL_FALSE; | ||||||
|         if (!shown) |             if (!shown) { | ||||||
|         { |  | ||||||
|                 shown = SDL_TRUE; |                 shown = SDL_TRUE; | ||||||
|                 SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "tvOS does not have persistent local storage! Use iCloud storage if you want your data to persist between sessions.\n"); |                 SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "tvOS does not have persistent local storage! Use iCloud storage if you want your data to persist between sessions.\n"); | ||||||
|             } |             } | ||||||
| @@ -133,7 +133,8 @@ SDL_GetPrefPath(const char *org, const char *app) | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         return retval; |         return retval; | ||||||
| }} |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| #endif /* SDL_FILESYSTEM_COCOA */ | #endif /* SDL_FILESYSTEM_COCOA */ | ||||||
|  |  | ||||||
|   | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user
	 Sam Lantinga
					Sam Lantinga