one last question

Tristan Savatier tristan at mpegtv.com
Tue Aug 3 04:11:29 PDT 1999


>From looking at the SDL code, it looks like it is impossible
to use SDL to play video in two windows, from two different
threads, because SDL uses global variables and is fundammentally
not reentrant.

Is that correct ?

I found many static buffers and globals that are modified by
SDL routines with no lock or mutex, and that alone
would be a big problem if several threads were to
use SDL for displaying in different windows.

Note that I understand the reason: SDL was designed
for accelerated hardware access (and there is only one
hardware display, in general), and that the fact that
it can be used to display in windows was not seen
as the important point of the design. Still, that's a
pitty... It does not cost much to make code reentrant and
to access all non-constant globals through a pointer.
I know, I had to do that for MpegTV.  It was painful
and took me about a week, but I am happy I did it
(i.e. made all the mtvp code reentrant).

-t



More information about the SDL mailing list