[PATCH] Use SDL_Swap* function in SDL_mixer.c

Hello,

Here is a patch to use SDL endianness function to read/write 16 bits
samples when mixing the buffers. It should be faster when
SDL_Swap?E16() functions are assembly optimized in SDL_endian.h–
Patrice Mandin
WWW: http://membres.lycos.fr/pmandin/
Programmeur Linux, Atari
Sp?cialit?: D?veloppement, jeux
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: SDL_mixer.diff
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050207/ef55e405/attachment.txt

Patrice Mandin wrote:

Hello,

Here is a patch to use SDL endianness function to read/write 16 bits
samples when mixing the buffers. It should be faster when
SDL_Swap?E16() functions are assembly optimized in SDL_endian.h

Did you check that it was actually faster ? As I said previously,
SDL_Swap*16 on x86 results in a locking instruction which might execute
a lot slower on smp systems.

Stephane

Le Wed, 09 Feb 2005 13:02:22 +0100
Stephane Marchesin <stephane.marchesin at wanadoo.fr> a ?crit:

Here is a patch to use SDL endianness function to read/write 16 bits
samples when mixing the buffers. It should be faster when
SDL_Swap?E16() functions are assembly optimized in SDL_endian.h

Did you check that it was actually faster ? As I said previously,
SDL_Swap*16 on x86 results in a locking instruction which might
execute a lot slower on smp systems.

I was considering that the assembly optimized SDL_Swap*() macros in
SDL_endian.h were generating better code (and maybe faster on some CPUs,
not all). At least on m68k, the generated code is better, thus faster.–
Patrice Mandin
WWW: http://membres.lycos.fr/pmandin/
Programmeur Linux, Atari
Sp?cialit?: D?veloppement, jeux

Hello,

Here is a patch to use SDL endianness function to read/write 16 bits
samples when mixing the buffers. It should be faster when
SDL_Swap?E16() functions are assembly optimized in SDL_endian.h

There are a couple problems with this patch. First, you can’t increment
src16 within the SDL_Swap16() macro call, since it may be expanded multiple
times. Second, you can’t assume that you’ll get the right value back if you
call SDL_Swap16() on a value that isn’t 16 bits.

See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment