From 5d615fcbf0cc59b84ca664aed20161f4b14f70ae Mon Sep 17 00:00:00 2001 From: driAn Date: Tue, 13 May 2008 19:17:30 +0000 Subject: [PATCH] endianness for ogg vorbis git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1950 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/sound.cpp | 4 ++-- source/src/tools.cpp | 6 ++++++ source/src/tools.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/src/sound.cpp b/source/src/sound.cpp index d0bc4b33..d7fb5a95 100644 --- a/source/src/sound.cpp +++ b/source/src/sound.cpp @@ -118,7 +118,7 @@ struct oggstream int bitstream; while(size < BUFSIZE) { - long bytes = ov_read(&oggfile, pcm + size, BUFSIZE - size, 0, 2, 1, &bitstream); + long bytes = ov_read(&oggfile, pcm + size, BUFSIZE - size, isbigendian(), 2, 1, &bitstream); if(bytes > 0) size += bytes; else if (bytes < 0) return false; else break; // done @@ -242,7 +242,7 @@ struct sbuffer if(!SDL_LoadWAV(file, &wavspec, &wavbuf, &wavlen)) continue; ALenum format; - switch(wavspec.freq) + switch(wavspec.freq) // map format definitions from SDL to OpenAL { case AUDIO_U8: format = AL_FORMAT_STEREO8; break; case AUDIO_S8: format = AL_FORMAT_MONO8; break; diff --git a/source/src/tools.cpp b/source/src/tools.cpp index 59cf8484..f8d912e2 100644 --- a/source/src/tools.cpp +++ b/source/src/tools.cpp @@ -263,3 +263,9 @@ void endianswap(void *memory, int stride, int length) // little endian as stor p[stride-i-1] = t; } } + +bool isbigendian() +{ + long one = 1; + return !(*((char *)(&one))); +} \ No newline at end of file diff --git a/source/src/tools.h b/source/src/tools.h index 042d9436..b9b545af 100644 --- a/source/src/tools.h +++ b/source/src/tools.h @@ -506,6 +506,7 @@ extern bool delfile(const char *path); extern bool cmpb(void *b, int n, enet_uint32 c); extern bool cmpf(char *fn, enet_uint32 c); extern void endianswap(void *, int, int); +extern bool isbigendian(); #endif