GNOME Bugzilla – Bug 337795
Dynamic loading of SDL on win32
Last modified: 2006-04-14 18:27:19 UTC
Ekiga should dynamically enable SDL on win32.
Created attachment 63015 [details] [review] Michael Rickmann's solution
MR's patch depends on his patch for #337794.
I don't understand why the patch loads DDRAW.DLL to unload it the next line ; apart from that, it looks good.
Well, I don't understand it either but we are dealing with Windows. The code is from SDL-1.2.9/src/main/win32/SDL_win32_main.c. There it is headed by the comment /* Start up DDHELP.EXE before opening any files, so DDHELP doesn't keep them open. This is a hack.. hopefully it will be fixed someday. DDHELP.EXE starts up the first time DDRAW.DLL is loaded. */ Since we are openening files in Ekiga, at least the schema, I think, it may save us from unexplainable experiences to include these lines of no apparent sense. Regards Michael
I have not seen any advers effects when I do not preload DDRAW.DLL/DDHELP.EXE. So leaving out that quirk is ok at the moment. With SDL_INIT_NOPARACHUTE SDL does not install its own signal handler and does not clean up after a crash. So that flag is useful for debugging only. That line can be left out as well. For SDL_SetModuleHandle I checked the SDL sources. It is not used internally, just stored and can be retrieved with SDL_GetModuleHandle. That is only useful if a DLL uses SDL and has to know the instance of the calling program. Leave out this line too. Remains the "atexit (SDL_Quit);". I would really like to have it but for Linux too. It fits better into real main. Except for the atexit this bug has dissolved. Regards Michael
Doesn't SDL_Init do the atexit magic itself ? Looks like the patch will be very small indeed ;-)
There is no atexit in the SDL sources exept in the test programs and "main" files for win32, qtopia, macos. We have our own WinMain so the linker disregards libSDLmain.a which would have contained the atexit. For Linux there is no apparent, comparable initialization object. SDL_Init clears the error condition, calls SDL_InitSubSystem and installs the signal handler via SDL_InstallParachute. The signal handler is installed "#ifndef NO_SIGNAL_H", catches at best SIGSEGV, SIGBUS, SIGFPE, SIGQUIT and SIGPIPE and calls SDL_Quit(). If you think that that is enough for Linux then we only need an atexit (SDL_Quit); for Windows. Reporting of Posix signals in win32 is restricted to a few, derived from the messaging and for some signals notworking (see signal.h in MingW). Regards Michael
Then we just have an atexit to add ?
Signal handling for Linux is very good so SDL will clean up after anything fatal, and in the program code we use SDL_Quit anyhow. After having read the SDL sources (see above) I think atexit is only needed for Windows. A mini patch follows. Regards Michael
Created attachment 63472 [details] [review] atexit (SDL_Quit) for WIN32
Would it hurt to have it without condition ?
No, you can call SDL_Quit as often as you wish. SDL checks internally wether a subsystem is initialized. If yes it shuts it down and clears an internal flag. The next time that flag is queried, found clear and no action is taken. Regards Michael
Ok, applied :-)