SDL video/event functions in threads

Hello,

I have readen in the SDL documentation the following words “Don’t call SDL
video/event functions from separate threads”. Is it only an advice or is there
serious problems if I call SDL video functions and event functions in differents
threads? Which are these problemes?

Thank you

Sebastien

They are most likely not thread-safe (ie. not stateless). On some
targets it may be okay, but the resulting code would naturally be
unportable.On 5/15/05, sebastien <sebastien_gd at yahoo.fr> wrote:

Hello,

I have readen in the SDL documentation the following words “Don’t call SDL
video/event functions from separate threads”. Is it only an advice or is there
serious problems if I call SDL video functions and event functions in differents
threads? Which are these problemes?

Thank you

Sebastien

Simon Roby <simon.roby gmail.com> writes:

They are most likely not thread-safe (ie. not stateless). On some
targets it may be okay, but the resulting code would naturally be
unportable.

I can use the SDL functions to create thread like SDL_CreateThread.
Moreover , I can use the mutex provided by SDL to synchronize the access to the
variables: SDL_CreateMutex, SDL_MutexP, SDl_MutexV…
So my code will be portable.
So I don’t know which problems can appears… But I am a beginner in the use of
SDL so maybe there is problem that I don’t know

sebastien wrote:

Hello,

I have readen in the SDL documentation the following words “Don’t call SDL
video/event functions from separate threads”. Is it only an advice or is there
serious problems if I call SDL video functions and event functions in differents
threads? Which are these problemes?

On some platforms (Windows, Mac OSX), the video thread must also be the
initial (main) thread.

On most linux platforms, this does not need to be the case.