Clean exit on OS X. Minor changes.
This commit is contained in:
parent
45d4abb64d
commit
20de593a88
|
@ -497,7 +497,9 @@ bool rend_init()
|
|||
void rend_term()
|
||||
{
|
||||
renderer_enabled = false;
|
||||
#if !defined(TARGET_NO_THREADS)
|
||||
rs.Set();
|
||||
#endif
|
||||
|
||||
if (fCheckFrames)
|
||||
fclose(fCheckFrames);
|
||||
|
|
|
@ -225,6 +225,8 @@ void dc_term()
|
|||
SaveSettings();
|
||||
#endif
|
||||
SaveRomFiles(get_writable_data_path("/data/"));
|
||||
|
||||
TermAudio();
|
||||
}
|
||||
|
||||
void dc_stop()
|
||||
|
|
|
@ -15,15 +15,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
|
||||
|
||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||
// Insert code here to initialize your application
|
||||
emu_main();
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ aNotification: Notification) {
|
||||
// Insert code here to tear down your application
|
||||
emu_dc_stop()
|
||||
}
|
||||
|
||||
|
||||
|
||||
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import Cocoa
|
||||
|
||||
class EmuGLView: NSOpenGLView {
|
||||
class EmuGLView: NSOpenGLView , NSWindowDelegate {
|
||||
|
||||
override var acceptsFirstResponder: Bool {
|
||||
return true;
|
||||
|
@ -71,4 +71,12 @@ class EmuGLView: NSOpenGLView {
|
|||
emu_key_input(e.characters!, 0);
|
||||
}
|
||||
|
||||
override func viewDidMoveToWindow() {
|
||||
super.viewDidMoveToWindow()
|
||||
self.window!.delegate = self
|
||||
}
|
||||
|
||||
func windowWillClose(_ notification: Notification) {
|
||||
emu_dc_stop()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#define emulator_osx_osx_main_Bridging_Header_h
|
||||
|
||||
void emu_main();
|
||||
void emu_dc_stop();
|
||||
int emu_single_frame(int w, int h);
|
||||
void emu_gles_init();
|
||||
void emu_key_input(const char* key, int state);
|
||||
|
|
|
@ -90,6 +90,8 @@ void gl_swap() {
|
|||
|
||||
int dc_init(int argc,wchar* argv[]);
|
||||
void dc_run();
|
||||
void dc_term();
|
||||
void dc_stop();
|
||||
|
||||
bool has_init = false;
|
||||
void* emuthread(void*) {
|
||||
|
@ -115,9 +117,18 @@ void* emuthread(void*) {
|
|||
|
||||
dc_run();
|
||||
|
||||
has_init = false;
|
||||
|
||||
dc_term();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void emu_dc_stop()
|
||||
{
|
||||
dc_stop();
|
||||
}
|
||||
|
||||
pthread_t emu_thread;
|
||||
extern "C" void emu_main() {
|
||||
pthread_create(&emu_thread, 0, &emuthread, 0);
|
||||
|
|
Loading…
Reference in New Issue