From b6b8780cb9abba82d52cd89d96fd0a1982515b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 6 Aug 2026 19:57:06 +0200 Subject: [PATCH] iOS: Remove some dead code - AudioEngine.mm/.h: not in the source list at all, only in the ARC set_source_files_properties list, and written for manual retain/release ([super dealloc]), so it couldn't have compiled under ARC anyway. The actual audio path is iOSCoreAudio.mm. - DisplayManager.mm: empty file, referenced nowhere. - iOSCoreAudioSetDisplayConnected: never called, so g_displayConnected was always false and the external-display branch in UpdateSession unreachable. Also dropped an unused local there. - AppDelegate: the "screen" property was never assigned, so both view controllers were setting their frame from [nil bounds], i.e. CGRectZero. The window sizes the root view anyway. Also removed the stale launchPPSSPP:argv: declaration (it lives on SceneDelegate now), a forward declaration of a PPSSPPViewController protocol that doesn't exist, and an unreachable return. - getView: declared on the base class and implemented identically in both subclasses, called by nobody. - bindDefaultFBO: moved the empty implementation to the base class so it isn't missing there, and dropped the Metal no-op override. - The unused delta/lastTimestamp computation in displayLinkFired. Also fixed the viewWillAppear/viewWillDisappear log messages in the GL view controller, which claimed to resume and pause the display link but don't. The getView and bindDefaultFBO changes clear three -Wincomplete-implementation warnings, and the AppDelegate.h one clears a fourth. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01JZk5y4Fzw811WJoNWZb8Sc --- CMakeLists.txt | 1 - ios/AppDelegate.h | 4 - ios/AppDelegate.mm | 2 - ios/AudioEngine.h | 13 ---- ios/AudioEngine.mm | 149 ------------------------------------ ios/DisplayManager.mm | 0 ios/ViewController.mm | 26 +------ ios/ViewControllerCommon.h | 1 - ios/ViewControllerCommon.mm | 3 + ios/ViewControllerMetal.mm | 11 --- ios/iOSCoreAudio.h | 6 +- ios/iOSCoreAudio.mm | 15 ---- 12 files changed, 7 insertions(+), 224 deletions(-) delete mode 100644 ios/AudioEngine.h delete mode 100644 ios/AudioEngine.mm delete mode 100644 ios/DisplayManager.mm diff --git a/CMakeLists.txt b/CMakeLists.txt index 21442f5016..6e9973b96a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -976,7 +976,6 @@ elseif(IOS AND NOT LIBRETRO) ios/iCade/iCadeReaderView.m ios/main.mm ios/CameraHelper.mm - ios/AudioEngine.mm ios/LocationHelper.mm ios/Controls.mm Core/Util/DarwinFileSystemServices.mm diff --git a/ios/AppDelegate.h b/ios/AppDelegate.h index 4a08b20a37..651d2fe431 100644 --- a/ios/AppDelegate.h +++ b/ios/AppDelegate.h @@ -4,15 +4,11 @@ #include -@protocol PPSSPPViewController; - @interface AppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; -@property (strong, nonatomic) UIScreen *screen; @property (nonatomic, strong) NSDictionary *launchOptions; -- (BOOL)launchPPSSPP:(int)argc argv:(char**)argv; - (void)processFilePath:(NSString *)path; // Exports the game library to a caller app via a URL scheme callback. diff --git a/ios/AppDelegate.mm b/ios/AppDelegate.mm index beab1370e9..6af4f6e2af 100644 --- a/ios/AppDelegate.mm +++ b/ios/AppDelegate.mm @@ -248,8 +248,6 @@ static std::vector GatherGameLibrary() { default: return UIInterfaceOrientationMaskAll; } - - return UIInterfaceOrientationMaskAll; // or at least include Portrait } @end diff --git a/ios/AudioEngine.h b/ios/AudioEngine.h deleted file mode 100644 index 6613513b27..0000000000 --- a/ios/AudioEngine.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// AudioEngine.h -// PPSSPP -// -// Created by rock88 on 15/03/2013. -// Copyright (c) 2013 Homebrew. All rights reserved. -// - -#import - -@interface AudioEngine : NSObject - -@end diff --git a/ios/AudioEngine.mm b/ios/AudioEngine.mm deleted file mode 100644 index 5efd7da3e0..0000000000 --- a/ios/AudioEngine.mm +++ /dev/null @@ -1,149 +0,0 @@ -// -// AudioEngine.mm -// PPSSPP -// -// Created by rock88 on 15/03/2013. -// Copyright (c) 2013 Homebrew. All rights reserved. -// - -#import "AudioEngine.h" -#import -#import -#import -#import - -#import - -static volatile BOOL done = 0; - -#define SAMPLE_SIZE 44100 -static short stream[SAMPLE_SIZE]; - -void NativeMix(short *audio, int numSamples, int sampleRateHz, void *userdata); - -@interface AudioEngine () - -@property (nonatomic,assign) ALCdevice *alcDevice; -@property (nonatomic,assign) ALCcontext *alContext; -@property (nonatomic,assign) ALuint buffer; -@property (nonatomic,assign) ALuint source; - -@end - -@implementation AudioEngine -@synthesize alcDevice,alContext,buffer,source; - -- (id)init -{ - self = [super init]; - if (self) - { - [self audioInit]; - [self audioLoop]; - } - return self; -} - -- (void)dealloc -{ - [self audioShutdown]; - [super dealloc]; -} - -- (void)checkALError -{ - ALenum ErrCode; - std::string Err = "OpenAL error: "; - if ((ErrCode = alGetError()) != AL_NO_ERROR) - { - Err += (char *)alGetString(ErrCode); - printf("%s\n",Err.c_str()); - } -} - -- (void)audioInit -{ - done = 0; - alcDevice = alcOpenDevice(NULL); - - if (alcDevice) - { - NSLog(@"OpenAL device opened: %s",alcGetString(alcDevice, ALC_DEVICE_SPECIFIER)); - } - else - { - NSLog(@"WARNING: could not open OpenAL device"); - return; - } - - alContext = alcCreateContext(alcDevice, NULL); - - if (alContext) - { - alcMakeContextCurrent(alContext); - } - else - { - NSLog(@"ERROR: no OpenAL context"); - return; - } - - alGenSources(1, &source); - alGenBuffers(1, &buffer); -} - -- (void)audioShutdown -{ - done = 1; - alcMakeContextCurrent(NULL); - - if (alContext) - { - alcDestroyContext(alContext); - alContext = NULL; - } - - if (alcDevice) - { - alcCloseDevice(alcDevice); - alcDevice = NULL; - } -} - -- (bool)playing -{ - ALenum state; - alGetSourcei(source, AL_SOURCE_STATE, &state); - return (state == AL_PLAYING); -} - -- (void)audioLoop -{ - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ - const int sampleRateHz = 44100; - while (!done) { - if (![self playing]) { - NativeMix(stream, SAMPLE_SIZE / 2, sampleRateHz, 0); - frames_ready = SAMPLE_SIZE / 2; - } else { - frames_ready = 0; - } - - if (frames_ready > 0) { - const size_t bytes_ready = frames_ready * sizeof(short) * 2; - alSourcei(source, AL_BUFFER, 0); - alBufferData(buffer, AL_FORMAT_STEREO16, stream, bytes_ready, sampleRateHz); - alSourcei(source, AL_BUFFER, buffer); - alSourcePlay(source); - - // TODO: Maybe this could get behind? - usleep((1000000 * frames_ready) / sampleRateHz); - } else { - usleep(100); - } - pthread_yield_np(); - } - }); -} - -@end diff --git a/ios/DisplayManager.mm b/ios/DisplayManager.mm deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 6383d9c08d..82cd2f2c87 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -5,7 +5,6 @@ // Modified by xSacha // Reworked by hrydgard -#import "AppDelegate.h" #import "ViewController.h" #import "iOSCoreAudio.h" @@ -56,7 +55,6 @@ PPSSPPBaseViewController *sharedViewController; @property (nonatomic, strong) EAGLContext *glContext; @property (nonatomic, strong) GLKView *glView; @property (nonatomic, strong) CADisplayLink *displayLink; -@property (nonatomic, assign) NSTimeInterval lastTimestamp; @property (nonatomic, strong) EAGLContext* context; @@ -134,10 +132,6 @@ PPSSPPBaseViewController *sharedViewController; } [self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; - self.lastTimestamp = 0; - - UIScreen* screen = [(AppDelegate*)[UIApplication sharedApplication].delegate screen]; - self.view.frame = [screen bounds]; self.view.multipleTouchEnabled = YES; graphicsContext = new OpenGLGraphicsContext(); @@ -173,14 +167,12 @@ PPSSPPBaseViewController *sharedViewController; - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - // Resume display link unless explicitly paused - INFO_LOG(Log::G3D, "viewWillAppear - resuming display link"); + INFO_LOG(Log::G3D, "viewWillAppear"); } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - // stop rendering while not visible - INFO_LOG(Log::G3D, "viewWillDisappear - pausing display link"); + INFO_LOG(Log::G3D, "viewWillDisappear"); } - (void)dealloc { @@ -205,16 +197,6 @@ PPSSPPBaseViewController *sharedViewController; } - (void)displayLinkFired:(CADisplayLink *)dl { - // compute delta time - NSTimeInterval timestamp = dl.timestamp; - NSTimeInterval delta = 0; - if (self.lastTimestamp > 0) { - delta = timestamp - self.lastTimestamp; - } else { - delta = dl.duration; // fallback - } - self.lastTimestamp = timestamp; - // Ensure context is current before drawing [EAGLContext setCurrentContext:self.glContext]; @@ -286,10 +268,6 @@ PPSSPPBaseViewController *sharedViewController; [(GLKView*)self.glView bindDrawable]; } -- (UIView *)getView { - return [self view]; -} - // Can't consolidate this yet. - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { diff --git a/ios/ViewControllerCommon.h b/ios/ViewControllerCommon.h index 77427673a6..c42e735271 100644 --- a/ios/ViewControllerCommon.h +++ b/ios/ViewControllerCommon.h @@ -20,7 +20,6 @@ - (void)shareText:(NSString *)text; - (void)shutdown; - (void)bindDefaultFBO; -- (UIView *)getView; - (void)startLocation; - (void)stopLocation; - (void)startVideo:(int)width height:(int)height; diff --git a/ios/ViewControllerCommon.mm b/ios/ViewControllerCommon.mm index f32fdf7d64..d5f34e7d3b 100644 --- a/ios/ViewControllerCommon.mm +++ b/ios/ViewControllerCommon.mm @@ -84,6 +84,9 @@ static int GetPickerRequestId(id picker) { return self; } +// Only means anything for the GL backend, which overrides this. +- (void)bindDefaultFBO {} + - (void)shutdown { self.gameController = nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; diff --git a/ios/ViewControllerMetal.mm b/ios/ViewControllerMetal.mm index 671916907d..bf634c197f 100644 --- a/ios/ViewControllerMetal.mm +++ b/ios/ViewControllerMetal.mm @@ -1,4 +1,3 @@ -#import "AppDelegate.h" #import "ViewControllerMetal.h" #import "iOSCoreAudio.h" @@ -193,8 +192,6 @@ static void VulkanRenderLoop(GraphicsContext *graphicsContext, CAMetalLayer *met INFO_LOG(Log::System, "Metal viewDidLoad"); - UIScreen* screen = [(AppDelegate*)[UIApplication sharedApplication].delegate screen]; - self.view.frame = [screen bounds]; self.view.multipleTouchEnabled = YES; // self.view.insetsLayoutMarginsFromSafeArea = NO; // self.view.clipsToBounds = YES; @@ -220,10 +217,6 @@ static void VulkanRenderLoop(GraphicsContext *graphicsContext, CAMetalLayer *met INFO_LOG(Log::G3D, "Detected size: %dx%d", g_display.pixel_xres, g_display.pixel_yres); } -- (UIView *)getView { - return [self view]; -} - - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; INFO_LOG(Log::G3D, "viewWillAppear"); @@ -247,10 +240,6 @@ static void VulkanRenderLoop(GraphicsContext *graphicsContext, CAMetalLayer *met INFO_LOG(Log::G3D, "viewDidDisappear"); } -- (void)bindDefaultFBO { - // Do nothing -} - - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; diff --git a/ios/iOSCoreAudio.h b/ios/iOSCoreAudio.h index 944e0e81dc..62cfa6e186 100644 --- a/ios/iOSCoreAudio.h +++ b/ios/iOSCoreAudio.h @@ -21,7 +21,5 @@ void iOSCoreAudioInit(); void iOSCoreAudioShutdown(); -// Ignore mute switch when connected to external display. -// Also, obey other settings. -void iOSCoreAudioUpdateSession(); -void iOSCoreAudioSetDisplayConnected(bool connected); \ No newline at end of file +// Applies the audio settings (mix with others, respect silent mode) to the session. +void iOSCoreAudioUpdateSession(); \ No newline at end of file diff --git a/ios/iOSCoreAudio.mm b/ios/iOSCoreAudio.mm index e8f7619583..9d8332db7a 100644 --- a/ios/iOSCoreAudio.mm +++ b/ios/iOSCoreAudio.mm @@ -29,18 +29,9 @@ #define SAMPLE_RATE 44100 static AudioComponentInstance audioInstance = nil; -static bool g_displayConnected = false; void iOSCoreAudioUpdateSession() { NSError *error = nil; - if (g_displayConnected) { - INFO_LOG(Log::Audio, "Display connected, setting Playback mode"); - // Special handling when a display is connected. Always exclusive. - // Let's revisit this later. - [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error]; - return; - } - INFO_LOG(Log::Audio, "RespectSilentMode: %d MixWithOthers: %d", g_Config.bAudioRespectSilentMode, g_Config.bAudioMixWithOthers); // Hacky hack to force iOS to re-evaluate. @@ -48,7 +39,6 @@ void iOSCoreAudioUpdateSession() { [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAudioProcessing error:&error]; // Here, we apply the settings. - const bool mixWithOthers = g_Config.bAudioMixWithOthers; if (g_Config.bAudioMixWithOthers) { if (g_Config.bAudioRespectSilentMode) { [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error]; @@ -69,11 +59,6 @@ void iOSCoreAudioUpdateSession() { } } -void iOSCoreAudioSetDisplayConnected(bool connected) { - g_displayConnected = connected; - iOSCoreAudioUpdateSession(); -} - void NativeMix(short *audio, int numSamples, int sampleRateHz, void *userdata); OSStatus iOSCoreAudioCallback(void *inRefCon,