mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-30 10:29:30 +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
|
// WARNING : this needs to happen on the GL thread only
|
||||||
LOG("width:%d height:%d", width, height);
|
LOG("width:%d height:%d", width, height);
|
||||||
_video_setRenderThread(pthread_self()); // Assume Android knows what it's doing ;-P
|
_video_setRenderThread(pthread_self()); // Assume Android knows what it's doing ;-P
|
||||||
video_shutdown();
|
video_shutdown(false);
|
||||||
video_reshape(width, height);
|
video_reshape(width, height);
|
||||||
video_init();
|
video_init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1166,7 +1166,7 @@ void _video_setRenderThread(pthread_t id) {
|
||||||
render_thread_id = id;
|
render_thread_id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void video_shutdown(void) {
|
void video_shutdown(bool emulatorShuttingDown) {
|
||||||
|
|
||||||
#if MOBILE_DEVICE
|
#if MOBILE_DEVICE
|
||||||
// WARNING : shutdown should occur on the render thread. Platform code (iOS, Android) should ensure this is called
|
// 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);
|
assert(pthread_self() == render_thread_id);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
video_backend->shutdown();
|
video_backend->shutdown(emulatorShuttingDown);
|
||||||
render_thread_id = 0;
|
render_thread_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1277,7 +1277,7 @@ void c_interface_parameters()
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
LOG("Back to Linux, w00t!\n");
|
LOG("Back to Linux, w00t!\n");
|
||||||
#endif
|
#endif
|
||||||
video_shutdown();
|
video_shutdown(false); // soft quit video_main_loop()
|
||||||
c_interface_exit(ch);
|
c_interface_exit(ch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3551,7 +3551,6 @@ void init_lex (char *str, int size) {
|
||||||
buffer = yy_scan_buffer(str,size);
|
buffer = yy_scan_buffer(str,size);
|
||||||
|
|
||||||
if (!buffer) { /* oops */
|
if (!buffer) { /* oops */
|
||||||
video_shutdown();
|
|
||||||
printf("lex buffer not big enough\n");
|
printf("lex buffer not big enough\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -987,7 +987,6 @@ void init_lex (char *str, int size) {
|
||||||
buffer = yy_scan_buffer(str, size);
|
buffer = yy_scan_buffer(str, size);
|
||||||
|
|
||||||
if (!buffer) { /* oops */
|
if (!buffer) { /* oops */
|
||||||
video_shutdown();
|
|
||||||
printf("lex buffer not big enough\n");
|
printf("lex buffer not big enough\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,7 @@ void emulator_start(void) {
|
||||||
void emulator_shutdown(void) {
|
void emulator_shutdown(void) {
|
||||||
disk6_eject(0);
|
disk6_eject(0);
|
||||||
disk6_eject(1);
|
disk6_eject(1);
|
||||||
video_shutdown();
|
video_shutdown(/*emulatorShuttingDown:*/true);
|
||||||
timing_stopCPU();
|
timing_stopCPU();
|
||||||
_shutdown_threads();
|
_shutdown_threads();
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,14 +156,14 @@ static void glnode_setupNodes(void *ctx) {
|
||||||
LOG("END glnode_setupNodes ...");
|
LOG("END glnode_setupNodes ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void glnode_shutdownNodes(void) {
|
static void glnode_shutdownNodes(bool emulatorShuttingDown) {
|
||||||
LOG("BEGIN glnode_shutdownNodes ...");
|
LOG("BEGIN glnode_shutdownNodes ...");
|
||||||
|
|
||||||
#if USE_GLUT
|
#if USE_GLUT
|
||||||
LOG("Waiting for GLUT mainloop to finish ...");
|
if (glut_in_main_loop) {
|
||||||
|
assert(!emulatorShuttingDown);
|
||||||
glutLeaveMainLoop();
|
glutLeaveMainLoop();
|
||||||
while (glut_in_main_loop) {
|
return;
|
||||||
usleep(40);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -172,6 +172,19 @@ static void glnode_shutdownNodes(void) {
|
||||||
p->node.shutdown();
|
p->node.shutdown();
|
||||||
p = p->last;
|
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 ...");
|
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)))
|
__attribute__((constructor(CTOR_PRIORITY_LATE)))
|
||||||
static void _init_glnode_manager(void) {
|
static void _init_glnode_manager(void) {
|
||||||
LOG("Initializing GLNode manager subsystem");
|
LOG("Initializing GLNode manager subsystem");
|
||||||
|
|
|
@ -23,7 +23,7 @@ typedef struct video_backend_s {
|
||||||
void (*main_loop)(void);
|
void (*main_loop)(void);
|
||||||
void (*reshape)(int width, int height);
|
void (*reshape)(int width, int height);
|
||||||
void (*render)(void);
|
void (*render)(void);
|
||||||
void (*shutdown)(void);
|
void (*shutdown)(bool emulatorShuttingDown);
|
||||||
|
|
||||||
// touch HUD functions
|
// touch HUD functions
|
||||||
void (*animation_showTouchKeyboard)(void);
|
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
|
* Shutdown video system. Should only be called on the render thread (unless render thread is in emulator-managed main
|
||||||
* video loop).
|
* 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.
|
* 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
|
// Detach from X server
|
||||||
if (!XShmDetach(display, &xshminfo))
|
if (!XShmDetach(display, &xshminfo))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"XShmDetach() failed in video_shutdown()\n");
|
fprintf(stderr,"XShmDetach() failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
XDestroyImage(image);
|
XDestroyImage(image);
|
||||||
|
@ -863,7 +863,7 @@ static void xdriver_init(void *context) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdriver_shutdown(void) {
|
static void xdriver_shutdown(bool emulatorShuttingDown) {
|
||||||
_destroy_image();
|
_destroy_image();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user