Add clean exit patch for x11 and 64-bit architecture

This commit is contained in:
Flyinghead 2018-04-27 16:54:15 +02:00
parent 35d3bd98d4
commit 64a8ac1dd5
5 changed files with 53 additions and 5 deletions

View File

@ -225,6 +225,7 @@ void os_DoEvents()
{
#if defined(SUPPORT_X11)
input_x11_handle();
event_x11_handle();
#endif
}
@ -430,6 +431,10 @@ std::vector<string> find_system_data_dirs()
}
#if HOST_OS==OS_LINUX
#if defined(SUPPORT_X11)
void x11_gl_context_destroy();
void x11_window_destroy();
#endif
void dc_term();
void rend_terminate();
void ngen_terminate();
@ -508,6 +513,12 @@ int main(int argc, wchar* argv[])
}
}
#endif
#if defined(SUPPORT_X11)
/* Close the GL context */
x11_gl_context_destroy();
/* Destroy the window */
x11_window_destroy();
#endif
#endif
return 0;

View File

@ -39,6 +39,7 @@ void* x11_glc;
bool x11_fullscreen = false;
void* x11_vis;
Atom wmDeleteMessage;
enum
{
@ -64,6 +65,22 @@ void x11_window_set_fullscreen(bool fullscreen)
XSendEvent((Display*)x11_disp, DefaultRootWindow((Display*)x11_disp), False, SubstructureNotifyMask, &xev);
}
void start_shutdown(void);
void event_x11_handle()
{
XEvent event;
while(XPending((Display *)x11_disp)) {
XNextEvent((Display *)x11_disp, &event);
if (event.type == ClientMessage &&
event.xclient.data.l[0] == wmDeleteMessage) {
start_shutdown();
}
}
}
void input_x11_handle()
{
if (x11_win && x11_keyboard_input)
@ -79,7 +96,7 @@ void input_x11_handle()
case KeyRelease:
if (e.type == KeyRelease && e.xkey.keycode == 9) // ESC button
{
die("death by escape key");
start_shutdown();
}
#if FEAT_HAS_NIXPROF
else if (e.type == KeyRelease && e.xkey.keycode == 76) // F10 button
@ -255,6 +272,9 @@ void x11_window_create()
x11Window = XCreateWindow(x11Display, RootWindow(x11Display, x11Screen), (ndcid%3)*640, (ndcid/3)*480, x11_width, x11_height,
0, depth, InputOutput, x11Visual->visual, ui32Mask, &sWA);
wmDeleteMessage = XInternAtom(x11Display, "WM_DELETE_WINDOW", False);
XSetWMProtocols(x11Display, x11Window, &wmDeleteMessage, 1);
if(x11_fullscreen)
{
@ -320,6 +340,12 @@ void x11_window_set_text(const char* text)
}
}
void x11_gl_context_destroy()
{
glXMakeCurrent((Display*)x11_disp, None, NULL);
glXDestroyContext((Display*)x11_disp, x11_glc);
}
void x11_window_destroy()
{
// close XWindow

View File

@ -2,6 +2,7 @@
extern void* x11_glc;
extern void input_x11_init();
extern void event_x11_handle();
extern void input_x11_handle();
extern void x11_window_create();
extern void x11_window_set_text(const char* text);

View File

@ -88,7 +88,7 @@ static void alsa_init()
}
else
printf("ALSA: period size set to %d\n", frames);
frames = (44100 * settings.omx.Audio_Latency / 1000 / frames + 1) * frames;
frames = (44100 * 100 /* settings.omx.Audio_Latency */ / 1000 / frames + 1) * frames;
rc=snd_pcm_hw_params_set_buffer_size_near(handle, params, &frames);
if (rc < 0)
{

View File

@ -38,13 +38,15 @@ void ngen_FailedToFindBlock_internal() {
void(*ngen_FailedToFindBlock)() = &ngen_FailedToFindBlock_internal;
unsigned int ngen_required = true;
void ngen_mainloop(void* v_cntx)
{
Sh4RCB* ctx = (Sh4RCB*)((u8*)v_cntx - sizeof(Sh4RCB));
cycle_counter = 0;
for (;;) {
do {
cycle_counter = SH4_TIMESLICE;
do {
DynarecCodeEntryPtr rcb = bm_GetCode(ctx->cntx.pc);
@ -54,9 +56,17 @@ void ngen_mainloop(void* v_cntx)
if (UpdateSystem()) {
rdv_DoInterrupts_pc(ctx->cntx.pc);
}
}
} while (ngen_required);
}
#if HOST_OS==OS_LINUX
void ngen_terminate()
{
ngen_required = false;
printf("ngen thread stopped\n");
}
#endif
void ngen_init()
{
}
@ -474,4 +484,4 @@ void ngen_CC_Finish(shil_opcode* op)
{
}
#endif
#endif