From f868d0416773aa381d2aec22a2446dbcb639a86e Mon Sep 17 00:00:00 2001 From: barracuda156 Date: Fri, 21 Jul 2023 09:10:18 +0800 Subject: [PATCH] Fixes for PowerPC diff --git include/SDL_config_macosx.h include/SDL_config_macosx.h index d7ad6cc71..736c1043d 100644 --- include/SDL_config_macosx.h +++ include/SDL_config_macosx.h --- include/SDL_config_macosx.h.orig 2023-07-02 01:04:05.000000000 +0800 +++ include/SDL_config_macosx.h 2023-07-23 05:28:30.000000000 +0800 @@ -49,7 +49,7 @@ #define HAVE_STDIO_H 1 #define HAVE_STRING_H 1 #define HAVE_SYS_TYPES_H 1 -#define HAVE_LIBUNWIND_H 1 +#define HAVE_LIBUNWIND_H 0 /* C library functions */ #define HAVE_DLOPEN 1 @@ -270,7 +270,7 @@ #define SDL_FILESYSTEM_COCOA 1 /* Enable assembly routines */ -#ifdef __ppc__ +#ifdef __POWERPC__ #define SDL_ALTIVEC_BLITTERS 1 #endif diff --git include/SDL_platform.h include/SDL_platform.h index d2a7e052d..3127d8cf0 100644 --- include/SDL_platform.h +++ include/SDL_platform.h @@ -108,9 +108,9 @@ /* if not compiling for iOS */ #undef __MACOSX__ #define __MACOSX__ 1 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 -# error SDL for Mac OS X only supports deploying on 10.7 and above. -#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1070 */ +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 +# error SDL for Mac OS X only supports deploying on 10.4 and above. +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1040 */ #endif /* TARGET_OS_IPHONE */ #endif /* defined(__APPLE__) */ diff --git src/audio/coreaudio/SDL_coreaudio.m src/audio/coreaudio/SDL_coreaudio.m index 974fe8681..600e51bfd 100644 --- src/audio/coreaudio/SDL_coreaudio.m +++ src/audio/coreaudio/SDL_coreaudio.m @@ -31,6 +31,11 @@ #include "SDL_coreaudio.h" #include "../../thread/SDL_systhread.h" +#include "AvailabilityMacros.h" +#ifndef MAC_OS_VERSION_12_0 +#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster +#endif + #define DEBUG_COREAUDIO 0 #if DEBUG_COREAUDIO @@ -371,7 +376,7 @@ static void interruption_end(_THIS) static BOOL update_audio_session(_THIS, SDL_bool open, SDL_bool allow_playandrecord) { - @autoreleasepool { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; AVAudioSession *session = [AVAudioSession sharedInstance]; NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; @@ -504,8 +509,8 @@ static BOOL update_audio_session(_THIS, SDL_bool open, SDL_bool allow_playandrec listener.device = NULL; } } - } + [pool release]; return YES; } #endif @@ -1043,7 +1048,7 @@ static int COREAUDIO_OpenDevice(_THIS, const char *devname) } /* Stop CoreAudio from doing expensive audio rate conversion */ - @autoreleasepool { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; AVAudioSession *session = [AVAudioSession sharedInstance]; [session setPreferredSampleRate:this->spec.freq error:nil]; this->spec.freq = (int)session.sampleRate; @@ -1058,7 +1063,7 @@ static int COREAUDIO_OpenDevice(_THIS, const char *devname) #else /* Calling setPreferredOutputNumberOfChannels seems to break audio output on iOS */ #endif /* TARGET_OS_TV */ - } + [pool release]; #endif /* Setup a AudioStreamBasicDescription with the requested format */ diff --git src/file/cocoa/SDL_rwopsbundlesupport.m src/file/cocoa/SDL_rwopsbundlesupport.m index 8d6ec7047..b234681d3 100644 --- src/file/cocoa/SDL_rwopsbundlesupport.m +++ src/file/cocoa/SDL_rwopsbundlesupport.m @@ -34,7 +34,7 @@ */ FILE *SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode) { - @autoreleasepool { + NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init]; FILE *fp = NULL; NSFileManager *file_manager; NSString *resource_path; @@ -58,8 +58,8 @@ FILE *SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode) fp = fopen(file, mode); } + [autorelease_pool drain]; return fp; - } } #endif /* __APPLE__ */ diff --git src/filesystem/cocoa/SDL_sysfilesystem.m src/filesystem/cocoa/SDL_sysfilesystem.m index 94ee7830e..822ced47c 100644 --- src/filesystem/cocoa/SDL_sysfilesystem.m +++ src/filesystem/cocoa/SDL_sysfilesystem.m @@ -35,7 +35,7 @@ char *SDL_GetBasePath(void) { - @autoreleasepool { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSBundle *bundle = [NSBundle mainBundle]; const char *baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String]; const char *base = NULL; @@ -63,13 +63,13 @@ char *SDL_GetBasePath(void) } } + [pool release]; return retval; - } } char *SDL_GetPrefPath(const char *org, const char *app) { - @autoreleasepool { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; char *retval = NULL; NSArray *array; @@ -130,8 +130,8 @@ char *SDL_GetPrefPath(const char *org, const char *app) } } + [pool release]; return retval; - } } #endif /* SDL_FILESYSTEM_COCOA */ diff --git src/hidapi/ios/hid.m src/hidapi/ios/hid.m index 8ebfdbe72..c1e2e2295 100644 --- src/hidapi/ios/hid.m +++ src/hidapi/ios/hid.m @@ -834,7 +834,8 @@ int HID_API_EXPORT hid_set_nonblocking(hid_device *dev, int nonblock) } struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, unsigned short product_id) -{ @autoreleasepool { +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; struct hid_device_info *root = NULL; const char *hint = SDL_GetHint(SDL_HINT_HIDAPI_IGNORE_DEVICES); @@ -884,8 +885,9 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, device_info->manufacturer_string = wcsdup( L"Valve Corporation" ); } } + [pool release]; return root; -}} +} int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen) { diff --git src/locale/macosx/SDL_syslocale.m src/locale/macosx/SDL_syslocale.m index 3a0e5db9e..b79b55456 100644 --- src/locale/macosx/SDL_syslocale.m +++ src/locale/macosx/SDL_syslocale.m @@ -26,7 +26,7 @@ void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { - @autoreleasepool { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSArray *languages = NSLocale.preferredLanguages; size_t numlangs = 0; size_t i; @@ -71,7 +71,7 @@ void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) buflen--; } } - } + [pool release]; } /* vi: set ts=4 sw=4 expandtab: */ diff --git src/misc/macosx/SDL_sysurl.m src/misc/macosx/SDL_sysurl.m index 657c8f520..369e5dd48 100644 --- src/misc/macosx/SDL_sysurl.m +++ src/misc/macosx/SDL_sysurl.m @@ -25,12 +25,12 @@ int SDL_SYS_OpenURL(const char *url) { - @autoreleasepool { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; CFURLRef cfurl = CFURLCreateWithBytes(NULL, (const UInt8 *)url, SDL_strlen(url), kCFStringEncodingUTF8, NULL); OSStatus status = LSOpenCFURLRef(cfurl, NULL); CFRelease(cfurl); + [pool release]; return status == noErr ? 0 : -1; - } } /* vi: set ts=4 sw=4 expandtab: */ diff --git src/power/uikit/SDL_syspower.m src/power/uikit/SDL_syspower.m index 5b9076b57..fe6aa70e5 100644 --- src/power/uikit/SDL_syspower.m +++ src/power/uikit/SDL_syspower.m @@ -59,7 +59,7 @@ SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percen *seconds = -1; *percent = -1; #else /* TARGET_OS_TV */ - @autoreleasepool { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; UIDevice *uidev = [UIDevice currentDevice]; if (!SDL_UIKitLastPowerInfoQuery) { @@ -97,9 +97,9 @@ SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percen const float level = uidev.batteryLevel; *percent = ((level < 0.0f) ? -1 : ((int)((level * 100) + 0.5f))); - } #endif /* TARGET_OS_TV */ + [pool release]; return SDL_TRUE; /* always the definitive answer on iOS. */ }