[SDL] clean video quit

David Olofson david at olofson.net
Wed Mar 16 07:19:36 PST 2005


On Wednesday 16 March 2005 15.07, shu wrote:
> Hi
> 
> I am writing a looping program that calls up a new video (mpegs) to
> an SDL surface upon each iteration of the loop  I am currently just
> testing it, and I cant find a good way to cleanly quit out of the
> video and the program. 
> 
> If I try to use Ctrl+C while the video is playing it just freezes
> up.  Can someone please recommend a good way to close the mpeg,
> clean up the surface and free up the memory?

You need to catch the CTRL+C signal, so it doesn't just try to abort 
your application without cleaning up.

You can use signal() from signal.h to wire signals to callback 
functions - but DO NOT try to clean up and exit from whithin the 
context of such a callback! That will most definitely cause all h*ll 
to break lose, regardless of platform. Just set a flag, post an SDL 
event or something, and have the main loop respond to that by 
cleaning up and exiting.


//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
|  Free/Open Source audio engine for games and multimedia.  |
| MIDI, modular synthesis, real time effects, scripting,... |
`-----------------------------------> http://audiality.org -'
   --- http://olofson.net --- http://www.reologica.se ---




More information about the SDL mailing list