Semantics of SDL_SetVideoMode and the surface it returns

I’m writing an SDL binding. (Thanks to a helpful investigator
off-list, I got an answer to my previous question.) I’m worried about
the semantics of the surface SDL_SetVideoMode returns. Is it safe to
SDL_FreeSurface it? When SDL_SetVideoMode is called again, is it safe
to SDL_FreeSurface the old display surface? Is the old display
surface even still valid?
I need to know because the language the binding is for has garbage
collection, and I’m trying to strip explicit memory allocation and
deallocation from my binding. I need to know whether I need to somehow
fence the SDL_Surface garbage collection method to avoid the display
surface, and whether to flag the old display surface as invalid
whenever the video mode is reset.
-:sigma.SB

The SDL_Surface returned by SDL_SetVideoMode is special.

To quote the SDL wiki
(http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fSetVideoMode):

The surface returned is freed by SDL_Quit and should not be freed by
the caller. Note: This rule includes consecutive calls to
SDL_SetVideoMode (i.e. resize or resolution change) - the pre-existing
surface will be released automatically.On 16/10/2007, Solra Bizna wrote:

I’m writing an SDL binding. (Thanks to a helpful investigator
off-list, I got an answer to my previous question.) I’m worried about
the semantics of the surface SDL_SetVideoMode returns. Is it safe to
SDL_FreeSurface it? When SDL_SetVideoMode is called again, is it safe
to SDL_FreeSurface the old display surface? Is the old display
surface even still valid?
I need to know because the language the binding is for has garbage
collection, and I’m trying to strip explicit memory allocation and
deallocation from my binding. I need to know whether I need to somehow
fence the SDL_Surface garbage collection method to avoid the display
surface, and whether to flag the old display surface as invalid
whenever the video mode is reset.

The SDL_Surface returned by SDL_SetVideoMode is special.

To quote the SDL wiki
(http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fSetVideoMode):

The surface returned is freed by SDL_Quit and should not be freed by
the caller. Note: This rule includes consecutive calls to
SDL_SetVideoMode (i.e. resize or resolution change) - the pre-existing
surface will be released automatically.

Still unclear.
I use SDL_SetVideoMode for resizing. Do I have to use SDL_Quit every time?
It would also disturb the audio output and other things…Am Tuesday, dem 16. Oct 2007 schrieb Brian:


AKFoerster

To resize, call SDL_SetVideoMode again. You do not need to use
SDL_Quit. That is what is meant by “consecutive calls to
SetVideoMode”.

On the subject of disturbing audio output, you can call
SDL_QuitSubSystem (and InitSubSystem) to selectively enable and
disable various SDL subsystems without disabling them all, should you
wish to.On 16/10/2007, list at akfoerster.de wrote:

Still unclear.
I use SDL_SetVideoMode for resizing. Do I have to use SDL_Quit every time?
It would also disturb the audio output and other things…

To resize, call SDL_SetVideoMode again. You do not need to use
SDL_Quit. That is what is meant by “consecutive calls to
SetVideoMode”.

Okay, thank you.

On the other hand, there seem to be problems with consecutive calls to
SetVodeoMode on a Linux framebuffer device… not under X just with the
framebuffer. Is that a known problem? (I use 1.2.11)Am Tuesday, dem 16. Oct 2007 schrieb Brian:


AKFoerster