Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 61409 Details for
Bug 96407
Freecraft SDLCD address space leak
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Makes freecraft use one sdl thread for SDLCD CDRomCheck
freecraft-030311-one_sdl_thread.patch (text/plain), 5.75 KB, created by
qube99
on 2005-06-17 12:47:25 UTC
(
hide
)
Description:
Makes freecraft use one sdl thread for SDLCD CDRomCheck
Filename:
MIME Type:
Creator:
qube99
Created:
2005-06-17 12:47:25 UTC
Size:
5.75 KB
patch
obsolete
>diff -ur freecraft-030311-old/src/clone/clone.c freecraft-030311/src/clone/clone.c >--- freecraft-030311-old/src/clone/clone.c 2003-03-05 13:31:28.000000000 -0500 >+++ freecraft-030311/src/clone/clone.c 2005-06-16 23:58:00.000000000 -0500 >@@ -191,6 +191,7 @@ > > #ifdef USE_SDL > #include "SDL.h" >+#include "SDL_thread.h" > #endif > > #ifdef __MINGW32__ >@@ -225,6 +226,12 @@ > extern SCM CclUnits(void); > #endif > >+#ifdef USE_SDLCD >+extern global SDL_mutex *cdromcheck_mutex; >+extern global SDL_cond *cdromcheck_cond; >+extern global int cdromcheck_done; >+#endif >+ > /*---------------------------------------------------------------------------- > -- Variables > ----------------------------------------------------------------------------*/ >@@ -1537,8 +1544,25 @@ > InitCcl(); // init CCL and load configurations! > LoadCcl(); > >+#ifdef USE_SDLCD >+ cdromcheck_mutex = SDL_CreateMutex(); >+ cdromcheck_cond = SDL_CreateCond(); >+ cdromcheck_done = 0; >+ SDL_CreateThread(CDRomCheck, NULL); >+#endif >+ > main1(argc,argv); > >+#ifdef USE_SDLCD >+ SDL_mutexP(cdromcheck_mutex); >+ cdromcheck_done = 1; >+ SDL_CondSignal(cdromcheck_cond); >+ SDL_mutexV(cdromcheck_mutex); >+ /* Let the SDL CDRomCheck do the clean-up, since it's the last to access >+ * the cond and mutex >+ */ >+#endif >+ > return 0; > } > >diff -ur freecraft-030311-old/src/clone/mainloop.c freecraft-030311/src/clone/mainloop.c >--- freecraft-030311-old/src/clone/mainloop.c 2003-03-04 12:11:07.000000000 -0500 >+++ freecraft-030311/src/clone/mainloop.c 2005-06-16 23:58:00.000000000 -0500 >@@ -69,6 +69,12 @@ > #include "SDL_thread.h" > #endif > >+#ifdef USE_SDLCD >+extern global SDL_mutex *cdromcheck_mutex; >+extern global SDL_cond *cdromcheck_cond; >+extern global int cdromcheck_done; >+#endif >+ > //---------------------------------------------------------------------------- > // Variables > //---------------------------------------------------------------------------- >@@ -726,7 +732,9 @@ > case 0: // Check cd-rom > #if defined(USE_SDLCD) > if ( !(GameCycle%4) ) { // every 2nd second >- SDL_CreateThread(CDRomCheck, NULL); >+ SDL_mutexP(cdromcheck_mutex); >+ SDL_CondSignal(cdromcheck_cond); >+ SDL_mutexV(cdromcheck_mutex); > } > #elif defined(USE_LIBCDA) || defined(USE_CDDA) > CDRomCheck(NULL); >@@ -735,7 +743,6 @@ > } > #endif > } >- > UpdateMessages(); // update messages > > // >@@ -822,6 +829,7 @@ > } > } > >+ > // > // Game over > // >diff -ur freecraft-030311-old/src/sound/sound_server.c freecraft-030311/src/sound/sound_server.c >--- freecraft-030311-old/src/sound/sound_server.c 2003-02-17 00:34:38.000000000 -0500 >+++ freecraft-030311/src/sound/sound_server.c 2005-06-16 23:58:00.000000000 -0500 >@@ -81,6 +81,7 @@ > > #if defined(USE_SDLCD) > #include "SDL.h" >+#include "SDL_thread.h" > #elif defined(USE_LIBCDA) > #include "libcda.h" > #elif defined(USE_CDDA) >@@ -108,6 +109,12 @@ > -- Variables > ----------------------------------------------------------------------------*/ > >+#ifdef USE_SDLCD >+global SDL_mutex *cdromcheck_mutex; // Make the CDRomCheck thread once >+global SDL_cond *cdromcheck_cond; // and use these three variables to >+global int cdromcheck_done = 0; // interact with it. >+#endif >+ > global int SoundFildes = -1; /// audio file descriptor > global int PlayingMusic; /// flag true if playing music > global int CallbackMusic; /// flag true callback ccl if stops >@@ -230,40 +237,50 @@ > global int CDRomCheck(void *unused __attribute__ ((unused))) > { > #if defined(USE_SDLCD) >- if (CDMode != CDModeOff && CDMode != CDModeStopped >- && SDL_CDStatus(CDRom) == 1) { >- DebugLevel0Fn("Playing new track\n"); >- if (CDMode == CDModeAll) { >- PlayCDRom(CDModeAll); >- } else if (CDMode == CDModeRandom) { >- PlayCDRom(CDModeRandom); >- } >- } >+ SDL_mutexP(cdromcheck_mutex); >+ while (!cdromcheck_done) >+ { >+ SDL_CondWait(cdromcheck_cond, cdromcheck_mutex); >+ if (CDMode != CDModeOff && CDMode != CDModeStopped >+ && SDL_CDStatus(CDRom) == 1) { >+ DebugLevel0Fn("Playing new track\n"); >+ if (CDMode == CDModeAll) { >+ PlayCDRom(CDModeAll); >+ } else if (CDMode == CDModeRandom) { >+ PlayCDRom(CDModeRandom); >+ } >+ } > #elif defined(USE_LIBCDA) >- if (CDMode != CDModeOff && CDMode != CDModeStopped >- && !cd_current_track() && CDMode != CDModeDefined) { >- DebugLevel0Fn("Playing new track\n"); >- PlayCDRom(CDMode); >- } else if (CDMode != CDModeOff && CDMode != CDModeStopped) { >- if (CDMode == CDModeDefined) { >- PlayCDRom(CDMode); >- } >- DebugLevel0Fn("get track\n"); >- CDTrack = cd_current_track() + 1; >- if (CDTrack > NumCDTracks) { >- CDTrack = 1; >- } >- } >+ if (CDMode != CDModeOff && CDMode != CDModeStopped >+ && !cd_current_track() && CDMode != CDModeDefined) { >+ DebugLevel0Fn("Playing new track\n"); >+ PlayCDRom(CDMode); >+ } else if (CDMode != CDModeOff && CDMode != CDModeStopped) { >+ if (CDMode == CDModeDefined) { >+ PlayCDRom(CDMode); >+ } >+ DebugLevel0Fn("get track\n"); >+ CDTrack = cd_current_track() + 1; >+ if (CDTrack > NumCDTracks) { >+ CDTrack = 1; >+ } >+ } > #elif defined(USE_CDDA) >- if (CDMode != CDModeOff && CDMode != CDModeStopped >- && !PlayingMusic) { >- DebugLevel0Fn("Playing new track\n"); >- if (CDMode == CDModeAll) { >- PlayCDRom(CDModeAll); >- } else if (CDMode == CDModeRandom) { >- PlayCDRom(CDModeRandom); >- } >+ if (CDMode != CDModeOff && CDMode != CDModeStopped >+ && !PlayingMusic) { >+ DebugLevel0Fn("Playing new track\n"); >+ if (CDMode == CDModeAll) { >+ PlayCDRom(CDModeAll); >+ } else if (CDMode == CDModeRandom) { >+ PlayCDRom(CDModeRandom); >+ } >+ } >+#endif >+#if defined(USE_SDLCD) > } >+ SDL_mutexV(cdromcheck_mutex); >+ SDL_DestroyCond(cdromcheck_cond); >+ SDL_DestroyMutex(cdromcheck_mutex); > #endif > return 0; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 96407
: 61409 |
61886