One last question

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

“Sam” == Sam Lantinga writes:

>> >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 ?

Sam> That is correct.  The big thing on the plate for SDL 0.11
Sam> (which should start development next week) is getting rid of
Sam> the global variables and making SDL reentrant and support
Sam> multiple output devices.

Heh. I didn’t even think of that as an example of the need for
re-entrancy. Maybe I could have saved some typing if I had thought to
mention that first, but sometimes I have a hard time coming up with
real-world examples of why things should be architected properly
because I think real-world examples often lead people astray. The
problem with having to use examples to convince people is that if you
can’t think of the right examples, people may make the wrong decision,
yet with something like re-entrancy, the answer is obvious even if you
can’t think of any examples.

>> 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).

Sam> Yup, I'm not looking forward to it, but it needs to be
Sam> done. :)

Yay!

Sam> 	-Sam Lantinga (slouken at devolution.com)

Sam> Lead Programmer, Loki Entertainment Software -- "Any
Sam> sufficiently advanced bug is indistinguishable from a
Sam> feature" -- Rich Kulawiec

–Cliff
@Clifford_T_Matthews