mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Minor cleanup
This commit is contained in:
parent
4f2379a2d3
commit
09e89e9d79
6 changed files with 87 additions and 91 deletions
|
@ -1290,6 +1290,8 @@ elseif(IOS AND NOT LIBRETRO)
|
|||
ios/AppDelegate.h
|
||||
ios/DisplayManager.h
|
||||
ios/DisplayManager.mm
|
||||
ios/Controls.h
|
||||
ios/Controls.mm
|
||||
ios/ViewController.mm
|
||||
ios/ViewController.h
|
||||
ios/iOSCoreAudio.mm
|
||||
|
|
3
ios/Controls.h
Normal file
3
ios/Controls.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
// Code extracted from ViewController.mm, in order to modularize
|
||||
// and share it between multiple view controllers.
|
||||
|
3
ios/Controls.mm
Normal file
3
ios/Controls.mm
Normal file
|
@ -0,0 +1,3 @@
|
|||
#include "Controls.h"
|
||||
|
||||
#include "Common/Log.h"
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <GLKit/GLKit.h>
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1
|
||||
#import <GameController/GameController.h>
|
||||
#endif
|
||||
#import "iCade/iCadeReaderView.h"
|
||||
#import "CameraHelper.h"
|
||||
#import "LocationHelper.h"
|
||||
|
|
|
@ -110,9 +110,7 @@ static LocationHelper *locationHelper;
|
|||
@property (nonatomic, strong) EAGLContext* context;
|
||||
|
||||
//@property (nonatomic) iCadeReaderView* iCadeView;
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1
|
||||
@property (nonatomic) GCController *gameController __attribute__((weak_import));
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
|
@ -139,13 +137,11 @@ static LocationHelper *locationHelper;
|
|||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillTerminate:) name:UIApplicationWillTerminateNotification object:nil];
|
||||
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1
|
||||
if ([GCController class]) // Checking the availability of a GameController framework
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerDidConnect:) name:GCControllerDidConnectNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerDidDisconnect:) name:GCControllerDidDisconnectNotification object:nil];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -170,7 +166,6 @@ extern float g_safeInsetBottom;
|
|||
- (void)viewSafeAreaInsetsDidChange {
|
||||
if (@available(iOS 11.0, *)) {
|
||||
[super viewSafeAreaInsetsDidChange];
|
||||
char safeArea[100];
|
||||
// we use 0.0f instead of safeAreaInsets.bottom because the bottom overlay isn't disturbing (for now)
|
||||
g_safeInsetLeft = self.view.safeAreaInsets.left;
|
||||
g_safeInsetRight = self.view.safeAreaInsets.right;
|
||||
|
@ -225,13 +220,11 @@ extern float g_safeInsetBottom;
|
|||
self.iCadeView.delegate = self;
|
||||
self.iCadeView.active = YES;*/
|
||||
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1
|
||||
if ([GCController class]) {
|
||||
if ([[GCController controllers] count] > 0) {
|
||||
[self setupController:[[GCController controllers] firstObject]];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
cameraHelper = [[CameraHelper alloc] init];
|
||||
[cameraHelper setDelegate:self];
|
||||
|
@ -305,11 +298,9 @@ extern float g_safeInsetBottom;
|
|||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1
|
||||
if ([GCController class]) {
|
||||
self.gameController = nil;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (graphicsContext) {
|
||||
graphicsContext->Shutdown();
|
||||
|
@ -553,10 +544,8 @@ int ToTouchID(UITouch *uiTouch, bool allowAllocate) {
|
|||
key.deviceId = DEVICE_ID_PAD_0;
|
||||
NativeKey(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1
|
||||
- (void)controllerDidConnect:(NSNotification *)note
|
||||
{
|
||||
if (![[GCController controllers] containsObject:self.gameController]) self.gameController = nil;
|
||||
|
|
|
@ -25,10 +25,9 @@
|
|||
#include <AudioToolbox/AudioToolbox.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
|
||||
#define SAMPLE_RATE 44100
|
||||
|
||||
AudioComponentInstance audioInstance = nil;
|
||||
static AudioComponentInstance audioInstance = nil;
|
||||
|
||||
int NativeMix(short *audio, int numSamples, int sampleRate);
|
||||
|
||||
|
@ -77,83 +76,85 @@ void iOSCoreAudioInit()
|
|||
}
|
||||
}
|
||||
|
||||
if (!audioInstance) {
|
||||
OSErr err;
|
||||
|
||||
// first, grab the default output
|
||||
AudioComponentDescription defaultOutputDescription;
|
||||
defaultOutputDescription.componentType = kAudioUnitType_Output;
|
||||
defaultOutputDescription.componentSubType = kAudioUnitSubType_RemoteIO;
|
||||
defaultOutputDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
|
||||
defaultOutputDescription.componentFlags = 0;
|
||||
defaultOutputDescription.componentFlagsMask = 0;
|
||||
AudioComponent defaultOutput = AudioComponentFindNext(NULL, &defaultOutputDescription);
|
||||
|
||||
// create our instance
|
||||
err = AudioComponentInstanceNew(defaultOutput, &audioInstance);
|
||||
if (err != noErr) {
|
||||
audioInstance = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
// create our callback so we can give it the audio data
|
||||
AURenderCallbackStruct input;
|
||||
input.inputProc = iOSCoreAudioCallback;
|
||||
input.inputProcRefCon = NULL;
|
||||
err = AudioUnitSetProperty(audioInstance,
|
||||
kAudioUnitProperty_SetRenderCallback,
|
||||
kAudioUnitScope_Input,
|
||||
0,
|
||||
&input,
|
||||
sizeof(input));
|
||||
if (err != noErr) {
|
||||
AudioComponentInstanceDispose(audioInstance);
|
||||
audioInstance = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
// setup the audio format we'll be using (stereo pcm)
|
||||
AudioStreamBasicDescription streamFormat;
|
||||
memset(&streamFormat, 0, sizeof(streamFormat));
|
||||
streamFormat.mSampleRate = SAMPLE_RATE;
|
||||
streamFormat.mFormatID = kAudioFormatLinearPCM;
|
||||
streamFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
|
||||
streamFormat.mBitsPerChannel = sizeof(short) * 8;
|
||||
streamFormat.mChannelsPerFrame = 2;
|
||||
streamFormat.mFramesPerPacket = 1;
|
||||
streamFormat.mBytesPerFrame = (streamFormat.mBitsPerChannel / 8) * streamFormat.mChannelsPerFrame;
|
||||
streamFormat.mBytesPerPacket = streamFormat.mBytesPerFrame * streamFormat.mFramesPerPacket;
|
||||
err = AudioUnitSetProperty(audioInstance,
|
||||
kAudioUnitProperty_StreamFormat,
|
||||
kAudioUnitScope_Input,
|
||||
0,
|
||||
&streamFormat,
|
||||
sizeof(AudioStreamBasicDescription));
|
||||
if (err != noErr) {
|
||||
AudioComponentInstanceDispose(audioInstance);
|
||||
audioInstance = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
// k, all setup, so init
|
||||
err = AudioUnitInitialize(audioInstance);
|
||||
if (err != noErr) {
|
||||
AudioComponentInstanceDispose(audioInstance);
|
||||
audioInstance = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
// finally start playback
|
||||
err = AudioOutputUnitStart(audioInstance);
|
||||
if (err != noErr) {
|
||||
AudioUnitUninitialize(audioInstance);
|
||||
AudioComponentInstanceDispose(audioInstance);
|
||||
audioInstance = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
// we're good to go
|
||||
if (audioInstance) {
|
||||
// Already running
|
||||
return;
|
||||
}
|
||||
OSErr err;
|
||||
|
||||
// first, grab the default output
|
||||
AudioComponentDescription defaultOutputDescription;
|
||||
defaultOutputDescription.componentType = kAudioUnitType_Output;
|
||||
defaultOutputDescription.componentSubType = kAudioUnitSubType_RemoteIO;
|
||||
defaultOutputDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
|
||||
defaultOutputDescription.componentFlags = 0;
|
||||
defaultOutputDescription.componentFlagsMask = 0;
|
||||
AudioComponent defaultOutput = AudioComponentFindNext(NULL, &defaultOutputDescription);
|
||||
|
||||
// create our instance
|
||||
err = AudioComponentInstanceNew(defaultOutput, &audioInstance);
|
||||
if (err != noErr) {
|
||||
audioInstance = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
// create our callback so we can give it the audio data
|
||||
AURenderCallbackStruct input;
|
||||
input.inputProc = iOSCoreAudioCallback;
|
||||
input.inputProcRefCon = NULL;
|
||||
err = AudioUnitSetProperty(audioInstance,
|
||||
kAudioUnitProperty_SetRenderCallback,
|
||||
kAudioUnitScope_Input,
|
||||
0,
|
||||
&input,
|
||||
sizeof(input));
|
||||
if (err != noErr) {
|
||||
AudioComponentInstanceDispose(audioInstance);
|
||||
audioInstance = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
// setup the audio format we'll be using (stereo pcm)
|
||||
AudioStreamBasicDescription streamFormat;
|
||||
memset(&streamFormat, 0, sizeof(streamFormat));
|
||||
streamFormat.mSampleRate = SAMPLE_RATE;
|
||||
streamFormat.mFormatID = kAudioFormatLinearPCM;
|
||||
streamFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
|
||||
streamFormat.mBitsPerChannel = sizeof(short) * 8;
|
||||
streamFormat.mChannelsPerFrame = 2;
|
||||
streamFormat.mFramesPerPacket = 1;
|
||||
streamFormat.mBytesPerFrame = (streamFormat.mBitsPerChannel / 8) * streamFormat.mChannelsPerFrame;
|
||||
streamFormat.mBytesPerPacket = streamFormat.mBytesPerFrame * streamFormat.mFramesPerPacket;
|
||||
err = AudioUnitSetProperty(audioInstance,
|
||||
kAudioUnitProperty_StreamFormat,
|
||||
kAudioUnitScope_Input,
|
||||
0,
|
||||
&streamFormat,
|
||||
sizeof(AudioStreamBasicDescription));
|
||||
if (err != noErr) {
|
||||
AudioComponentInstanceDispose(audioInstance);
|
||||
audioInstance = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
// k, all setup, so init
|
||||
err = AudioUnitInitialize(audioInstance);
|
||||
if (err != noErr) {
|
||||
AudioComponentInstanceDispose(audioInstance);
|
||||
audioInstance = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
// finally start playback
|
||||
err = AudioOutputUnitStart(audioInstance);
|
||||
if (err != noErr) {
|
||||
AudioUnitUninitialize(audioInstance);
|
||||
AudioComponentInstanceDispose(audioInstance);
|
||||
audioInstance = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
// we're good to go
|
||||
}
|
||||
|
||||
void iOSCoreAudioShutdown()
|
||||
|
|
Loading…
Add table
Reference in a new issue