mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
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 <[email protected]> Claude-Session: https://claude.ai/code/session_01JZk5y4Fzw811WJoNWZb8Sc
This commit is contained in:
1 parent
d3012ea1db
commit
b6b8780cb9
12 files changed
+7
-224
No files matched your search
@@ -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
|
||||
|
||||
@@ -4,15 +4,11 @@
|
||||
|
||||
#include <string_view>
|
||||
|
||||
@protocol PPSSPPViewController;
|
||||
|
||||
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
||||
|
||||
@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.
|
||||
|
||||
@@ -248,8 +248,6 @@ static std::vector<std::string> GatherGameLibrary() {
|
||||
default:
|
||||
return UIInterfaceOrientationMaskAll;
|
||||
}
|
||||
|
||||
return UIInterfaceOrientationMaskAll; // or at least include Portrait
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
//
|
||||
// AudioEngine.h
|
||||
// PPSSPP
|
||||
//
|
||||
// Created by rock88 on 15/03/2013.
|
||||
// Copyright (c) 2013 Homebrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface AudioEngine : NSObject
|
||||
|
||||
@end
|
||||
@@ -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 <OpenAL/al.h>
|
||||
#import <OpenAL/alc.h>
|
||||
#import <AudioToolbox/AudioToolbox.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
#import <string>
|
||||
|
||||
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
|
||||
Whitespace-only changes.
+2
-24
@@ -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<UIViewControllerTransitionCoordinator>)coordinator {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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];
|
||||
|
||||
|
||||
+2
-4
@@ -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);
|
||||
// Applies the audio settings (mix with others, respect silent mode) to the session.
|
||||
void iOSCoreAudioUpdateSession();
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user