mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-12 06:29:58 +00:00
Refactor video_shutdown() to appease Valgrind
- This likely breaks Darwin ports ... will fix soon[ish]
This commit is contained in:
parent
edaae0bc89
commit
5fec80a33a
@ -198,7 +198,7 @@ void Java_org_deadc0de_apple2ix_Apple2View_nativeGraphicsInitialized(JNIEnv *env
|
||||
// WARNING : this needs to happen on the GL thread only
|
||||
LOG("width:%d height:%d", width, height);
|
||||
_video_setRenderThread(pthread_self()); // Assume Android knows what it's doing ;-P
|
||||
video_shutdown();
|
||||
video_shutdown(false);
|
||||
video_reshape(width, height);
|
||||
video_init();
|
||||
}
|
||||
|
@ -1166,7 +1166,7 @@ void _video_setRenderThread(pthread_t id) {
|
||||
render_thread_id = id;
|
||||
}
|
||||
|
||||
void video_shutdown(void) {
|
||||
void video_shutdown(bool emulatorShuttingDown) {
|
||||
|
||||
#if MOBILE_DEVICE
|
||||
// WARNING : shutdown should occur on the render thread. Platform code (iOS, Android) should ensure this is called
|
||||
@ -1174,7 +1174,7 @@ void video_shutdown(void) {
|
||||
assert(pthread_self() == render_thread_id);
|
||||
#endif
|
||||
|
||||
video_backend->shutdown();
|
||||
video_backend->shutdown(emulatorShuttingDown);
|
||||
render_thread_id = 0;
|
||||
}
|
||||
|
||||
|
@ -1277,7 +1277,7 @@ void c_interface_parameters()
|
||||
#ifdef __linux__
|
||||
LOG("Back to Linux, w00t!\n");
|
||||
#endif
|
||||
video_shutdown();
|
||||
video_shutdown(false); // soft quit video_main_loop()
|
||||
c_interface_exit(ch);
|
||||
return;
|
||||
}
|
||||
|
@ -3551,7 +3551,6 @@ void init_lex (char *str, int size) {
|
||||
buffer = yy_scan_buffer(str,size);
|
||||
|
||||
if (!buffer) { /* oops */
|
||||
video_shutdown();
|
||||
printf("lex buffer not big enough\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -987,7 +987,6 @@ void init_lex (char *str, int size) {
|
||||
buffer = yy_scan_buffer(str, size);
|
||||
|
||||
if (!buffer) { /* oops */
|
||||
video_shutdown();
|
||||
printf("lex buffer not big enough\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ void emulator_start(void) {
|
||||
void emulator_shutdown(void) {
|
||||
disk6_eject(0);
|
||||
disk6_eject(1);
|
||||
video_shutdown();
|
||||
video_shutdown(/*emulatorShuttingDown:*/true);
|
||||
timing_stopCPU();
|
||||
_shutdown_threads();
|
||||
}
|
||||
|
@ -156,14 +156,14 @@ static void glnode_setupNodes(void *ctx) {
|
||||
LOG("END glnode_setupNodes ...");
|
||||
}
|
||||
|
||||
static void glnode_shutdownNodes(void) {
|
||||
static void glnode_shutdownNodes(bool emulatorShuttingDown) {
|
||||
LOG("BEGIN glnode_shutdownNodes ...");
|
||||
|
||||
#if USE_GLUT
|
||||
LOG("Waiting for GLUT mainloop to finish ...");
|
||||
glutLeaveMainLoop();
|
||||
while (glut_in_main_loop) {
|
||||
usleep(40);
|
||||
if (glut_in_main_loop) {
|
||||
assert(!emulatorShuttingDown);
|
||||
glutLeaveMainLoop();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -172,6 +172,19 @@ static void glnode_shutdownNodes(void) {
|
||||
p->node.shutdown();
|
||||
p = p->last;
|
||||
}
|
||||
|
||||
if (emulatorShuttingDown) {
|
||||
// clean up to make Valgrind happy ...
|
||||
p = head;
|
||||
while (p) {
|
||||
glnode_array_node_s *next = p->next;
|
||||
FREE(p);
|
||||
p = next;
|
||||
}
|
||||
head=NULL;
|
||||
tail=NULL;
|
||||
}
|
||||
|
||||
LOG("END glnode_shutdownNodes ...");
|
||||
}
|
||||
|
||||
@ -224,21 +237,6 @@ static void glnode_mainLoop(void) {
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
__attribute__((destructor(255)))
|
||||
static void _destroy_glnodes(void) {
|
||||
LOG("...");
|
||||
|
||||
glnode_array_node_s *p = head;
|
||||
while (p) {
|
||||
glnode_array_node_s *next = p->next;
|
||||
FREE(p);
|
||||
p = next;
|
||||
}
|
||||
|
||||
head=NULL;
|
||||
tail=NULL;
|
||||
}
|
||||
|
||||
__attribute__((constructor(CTOR_PRIORITY_LATE)))
|
||||
static void _init_glnode_manager(void) {
|
||||
LOG("Initializing GLNode manager subsystem");
|
||||
|
@ -23,7 +23,7 @@ typedef struct video_backend_s {
|
||||
void (*main_loop)(void);
|
||||
void (*reshape)(int width, int height);
|
||||
void (*render)(void);
|
||||
void (*shutdown)(void);
|
||||
void (*shutdown)(bool emulatorShuttingDown);
|
||||
|
||||
// touch HUD functions
|
||||
void (*animation_showTouchKeyboard)(void);
|
||||
@ -79,7 +79,7 @@ void video_main_loop(void);
|
||||
* Shutdown video system. Should only be called on the render thread (unless render thread is in emulator-managed main
|
||||
* video loop).
|
||||
*/
|
||||
void video_shutdown(void);
|
||||
void video_shutdown(bool emulatorShuttingDown);
|
||||
|
||||
/*
|
||||
* Begin a render pass (only for non-emulator-managed main video). This should only be called on the render thread.
|
||||
|
@ -500,7 +500,7 @@ static void _destroy_image() {
|
||||
// Detach from X server
|
||||
if (!XShmDetach(display, &xshminfo))
|
||||
{
|
||||
fprintf(stderr,"XShmDetach() failed in video_shutdown()\n");
|
||||
fprintf(stderr,"XShmDetach() failed\n");
|
||||
}
|
||||
|
||||
XDestroyImage(image);
|
||||
@ -863,7 +863,7 @@ static void xdriver_init(void *context) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static void xdriver_shutdown(void) {
|
||||
static void xdriver_shutdown(bool emulatorShuttingDown) {
|
||||
_destroy_image();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user