X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=snd_mem.c;h=d0671eb8740fb88ef143148178beb8500933442f;hp=f735a38ddc4c64a6b1566fd831fac8809fc952f8;hb=1e1dbc1c5b89ae4ab8cdd9b32dc6413c67f5dd84;hpb=ff46d6ff516fda192c5adc55a5c9b82007545bd2 diff --git a/snd_mem.c b/snd_mem.c index f735a38d..d0671eb8 100644 --- a/snd_mem.c +++ b/snd_mem.c @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" -#include "ogg.h" +#include "snd_ogg.h" /* @@ -56,7 +56,7 @@ void ResampleSfx (sfxcache_t *sc, qbyte *data, char *name) ((signed char *)sc->data)[i] = ((unsigned char *)data)[i] - 128; else //if (sc->width == 2) // 16bit for (i = 0;i < srclength;i++) - ((short *)sc->data)[i] = LittleShort (((short *)data)[i]); + ((short *)sc->data)[i] = ((short *)data)[i]; } else { @@ -74,8 +74,8 @@ void ResampleSfx (sfxcache_t *sc, qbyte *data, char *name) fracstep <<= 1; for (i=0 ; iwidth = info.width; sc->stereo = info.channels == 2; +#if BYTE_ORDER != LITTLE_ENDIAN + // We must convert the WAV data from little endian + // to the machine endianess before resampling it + if (info.width == 2) + { + int i; + short* ptr; + + len = info.samples * info.channels; + ptr = (short*)(data + info.dataofs); + for (i = 0; i < len; i++) + ptr[i] = LittleShort (ptr[i]); + } +#endif + ResampleSfx(sc, data + info.dataofs, s->name); Mem_Free(data); @@ -336,30 +351,30 @@ WAV loading */ -qbyte *data_p; -qbyte *iff_end; -qbyte *last_chunk; -qbyte *iff_data; -int iff_chunk_len; +static qbyte *data_p; +static qbyte *iff_end; +static qbyte *last_chunk; +static qbyte *iff_data; +static int iff_chunk_len; short GetLittleShort(void) { - short val = 0; - val = *data_p; - val = val + (*(data_p+1)<<8); + short val; + + val = BuffLittleShort (data_p); data_p += 2; + return val; } int GetLittleLong(void) { int val = 0; - val = *data_p; - val = val + (*(data_p+1)<<8); - val = val + (*(data_p+2)<<16); - val = val + (*(data_p+3)<<24); + + val = BuffLittleLong (data_p); data_p += 4; + return val; }