ios: Remove QuartzCore timer and return to manually calling CFRunLoopRunInMode.

This commit is contained in:
meancoot 2013-02-14 22:09:18 -05:00
parent 6a77d72966
commit 994aa01fcb
2 changed files with 24 additions and 11 deletions

View File

@ -84,7 +84,6 @@
96AFAFAD16C1EEE9009DE44C /* sinc.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAEF716C1DC73009DE44C /* sinc.c */; };
96AFAFD416C1FBC0009DE44C /* input_common.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFC916C1FBC0009DE44C /* input_common.c */; };
96AFAFD716C1FBC0009DE44C /* null.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFCD16C1FBC0009DE44C /* null.c */; };
96C6A5D216CDB384009E3280 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96C6A5D116CDB384009E3280 /* QuartzCore.framework */; };
96CF015016C2C0B700ABF9C9 /* overlay.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFCE16C1FBC0009DE44C /* overlay.c */; };
96CF015C16C2F72900ABF9C9 /* ios_input.c in Sources */ = {isa = PBXBuildFile; fileRef = 96CF015B16C2F72900ABF9C9 /* ios_input.c */; };
/* End PBXBuildFile section */
@ -291,7 +290,6 @@
96AFAFD016C1FBC0009DE44C /* sdl_input.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sdl_input.c; sourceTree = "<group>"; };
96AFAFD116C1FBC0009DE44C /* sdl_joypad.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sdl_joypad.c; sourceTree = "<group>"; };
96AFAFD216C1FBC0009DE44C /* x11_input.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = x11_input.c; sourceTree = "<group>"; };
96C6A5D116CDB384009E3280 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
96CF015B16C2F72900ABF9C9 /* ios_input.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ios_input.c; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -300,7 +298,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96C6A5D216CDB384009E3280 /* QuartzCore.framework in Frameworks */,
96366C5916C9ACF500D64A22 /* AudioToolbox.framework in Frameworks */,
96366C5516C9AC3300D64A22 /* CoreAudio.framework in Frameworks */,
96AFAF2216C1DF88009DE44C /* libz.dylib in Frameworks */,
@ -354,7 +351,6 @@
96AFAE2816C1D4EA009DE44C /* Frameworks */ = {
isa = PBXGroup;
children = (
96C6A5D116CDB384009E3280 /* QuartzCore.framework */,
96366C5816C9ACF500D64A22 /* AudioToolbox.framework */,
96366C5416C9AC3300D64A22 /* CoreAudio.framework */,
96AFAE2916C1D4EA009DE44C /* UIKit.framework */,

View File

@ -16,8 +16,10 @@
#import <QuartzCore/QuartzCore.h>
#include "general.h"
#include "rarch_wrapper.h"
static bool _isRunning;
static bool _isPaused;
static float screen_scale;
static int frame_skips = 4;
@ -40,15 +42,23 @@ static bool is_syncing = true;
self.view = [[GLKView alloc] initWithFrame:CGRectMake(0, 0, 640, 480) context:_glContext];
self.view.multipleTouchEnabled = YES;
_timer = [CADisplayLink displayLinkWithTarget:self selector:@selector(iterate)];
[_timer addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
return self;
}
- (void)iterate
{
if (_isRunning) rarch_main_iterate();
while (_isRunning && !_isPaused)
{
_isRunning = rarch_main_iterate();
if (!_isRunning)
{
ios_close_game();
return;
}
else
while(!_isPaused && _isRunning && CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true) == kCFRunLoopRunHandledSource);
}
}
- (void)needsToDie
@ -66,19 +76,23 @@ static bool is_syncing = true;
- (void)pause
{
_timer.paused = true;
_isPaused = true;
}
- (void)resume
{
if (_isRunning) _timer.paused = false;
if (_isPaused)
{
_isPaused = false;
[self performSelector:@selector(iterate) withObject:nil afterDelay:.02f];
}
}
@end
static RAGameView* gameViewer;
void ios_load_game(const char* path)
bool ios_load_game(const char* path)
{
[RASettingsList refreshConfigFile];
@ -94,6 +108,8 @@ void ios_load_game(const char* path)
}
else
_isRunning = false;
return _isRunning;
}
void ios_close_game()
@ -145,6 +161,7 @@ bool ios_init_game_view()
{
gameViewer = [RAGameView new];
[[RetroArch_iOS get] setViewer:gameViewer];
[gameViewer performSelector:@selector(iterate) withObject:nil afterDelay:.02f];
}
return true;