(iOS Thread) Handle the cases where the retroarch thread ends

This commit is contained in:
meancoot 2013-04-02 21:07:04 -04:00
parent b77567045e
commit 1ab77945da
3 changed files with 28 additions and 17 deletions

View File

@ -14,6 +14,9 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <dispatch/dispatch.h>
#include "../ios/RetroArch/rarch_wrapper.h"
#include "../general.h"
#include "../conf/config_file.h"
#include "../file.h"
@ -22,7 +25,7 @@
#include "../frontend/menu/rgui.h"
#endif
void ios_free_main_wrap(struct rarch_main_wrap* wrap)
static void ios_free_main_wrap(struct rarch_main_wrap* wrap)
{
if (wrap)
{
@ -38,13 +41,15 @@ void ios_free_main_wrap(struct rarch_main_wrap* wrap)
void rarch_main_ios(void* args)
{
rarch_init_msg_queue();
menu_init();
struct rarch_main_wrap* argdata = (struct rarch_main_wrap*)args;
int init_ret = rarch_main_init_wrap(argdata);
ios_free_main_wrap(argdata);
int init_ret;
if ((init_ret = rarch_main_init_wrap((struct rarch_main_wrap*)args))) return;
ios_free_main_wrap(args);
if (init_ret)
{
dispatch_async_f(dispatch_get_main_queue(), (void*)1, ios_rarch_exited);
return;
}
#ifdef HAVE_RGUI
menu_init();
@ -110,4 +115,6 @@ void rarch_main_ios(void* args)
#endif
rarch_main_clear_state();
dispatch_async_f(dispatch_get_main_queue(), 0, ios_rarch_exited);
}

View File

@ -30,7 +30,6 @@
// From frontend/frontend_ios.c
extern void rarch_main_ios(void* args);
extern void ios_free_main_wrap(struct rarch_main_wrap* wrap);
@implementation RetroArch_iOS
{
@ -144,17 +143,17 @@ extern void ios_free_main_wrap(struct rarch_main_wrap* wrap);
config_file_free(conf);
}
#if 0
- (void)closeGame
- (void)rarchExited:(BOOL)successful
{
if (!successful)
{
[RetroArch_iOS displayErrorMessage:@"Failed to load game."];
}
if (_isRunning)
{
_isRunning = false;
rarch_main_deinit();
rarch_deinit_msg_queue();
rarch_main_clear_state();
// Stop bluetooth (might be annoying but forgetting could eat battery of device AND wiimote)
[self stopBluetooth];
@ -163,7 +162,6 @@ extern void ios_free_main_wrap(struct rarch_main_wrap* wrap);
[self popViewControllerAnimated:NO];
}
}
#endif
- (void)refreshConfig
{
@ -285,3 +283,7 @@ extern void ios_free_main_wrap(struct rarch_main_wrap* wrap);
@end
void ios_rarch_exited(void* result)
{
[[RetroArch_iOS get] rarchExited:result ? NO : YES];
}

View File

@ -16,8 +16,10 @@
#ifndef __IOS_RARCH_WRAPPER_H__
#define __IOS_RARCH_WRAPPER_H__
// These functions must only be called in gfx/context/ioseagl_ctx.c
// These functions should only be called as arguments to dispatch_sync
void ios_rarch_exited(void* result);
// These functions must only be called in gfx/context/ioseagl_ctx.c
bool ios_init_game_view();
void ios_destroy_game_view();
void ios_flip_game_view();