Skip to content

Commit

Permalink
Serious mangling to make this work with gcc 4.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed May 30, 2005
1 parent 14809cb commit 205d0e3
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 34 deletions.
4 changes: 2 additions & 2 deletions osx/AL_EXT_mp3/al_ext_mp3.c
Expand Up @@ -63,7 +63,7 @@ static int doMp3Decode(MP3Opaque *o, void *outbuf, ALsizei outsize)

// need to decode more from the MP3 stream...
o->outleft = o->outpos = 0;
decodeMP3(&o->mp, NULL, 0, o->outbuf,
decodeMP3(&o->mp, NULL, 0, (char *) o->outbuf,
sizeof (o->outbuf), &o->outleft);
if (o->outleft == 0)
break;
Expand All @@ -82,7 +82,7 @@ static UInt32 __alMixMP3(struct ALcontext_struct *ctx, struct ALbuffer_struct *b
int srcfreq = mpglib_freqs[opaque->mp.fr.sampling_frequency];
int dstfreq = (int) ctx->device->streamFormat.mSampleRate;
ALsizei outsize = samples * sizeof (SInt16) * 2;
SInt16 *outbuf = (UInt16 *) alloca(outsize);
SInt16 *outbuf = (SInt16 *) alloca(outsize);
int decoded = doMp3Decode(opaque, outbuf, outsize);

src->bufferReadIndex = 1; // hack to get this to not reinitialize the buffer in alContext.c.
Expand Down
6 changes: 3 additions & 3 deletions osx/ALut.c
Expand Up @@ -198,11 +198,11 @@ ALUTAPI ALvoid ALUTAPIENTRY alutLoadWAVFile(ALbyte *file,ALenum *format,ALvoid *

if (file)
{
sfFile = (FILE *)fopen(file,"r");
sfFile = (FILE *)fopen((const char *) file,"r");
if(sfFile==NULL) exit(1);
numBytes = sizeof(WAVFileHdr_Struct);
fread(&FileHdr,1,numBytes,sfFile);
SwapWords(&FileHdr.Size);
SwapWords((unsigned int *) &FileHdr.Size);
FileHdr.Size=((FileHdr.Size+1)&~1)-4;
while ((FileHdr.Size!=0))
{
Expand Down Expand Up @@ -309,7 +309,7 @@ ALUTAPI ALvoid ALUTAPIENTRY alutLoadWAVMemory(ALbyte *memory,ALenum *format,ALvo
{
memcpy(&FileHdr,Stream,sizeof(WAVFileHdr_Struct));
Stream+=sizeof(WAVFileHdr_Struct);
SwapWords(&FileHdr.Size);
SwapWords((unsigned int *) &FileHdr.Size);
FileHdr.Size=((FileHdr.Size+1)&~1)-4;
while ((FileHdr.Size!=0)&&(memcpy(&ChunkHdr,Stream,sizeof(WAVChunkHdr_Struct))))
{
Expand Down
6 changes: 3 additions & 3 deletions osx/alContext.c
Expand Up @@ -817,7 +817,7 @@ static ALubyte *__alcDetermineDefaultDeviceName(ALboolean isOutput)
OSStatus error;
UInt32 count;
AudioDeviceID dev;
static char *buf = NULL; // !!! FIXME: Minor memory leak.
static ALubyte *buf = NULL; // !!! FIXME: Minor memory leak.
AudioHardwarePropertyID defDev;

if (buf) return(buf); // !!! FIXME: Can the default change during the lifetime of the system?
Expand Down Expand Up @@ -913,7 +913,7 @@ static ALubyte *__alcDetermineDeviceNameList(ALboolean isOutput)
} // if
} // for

return(buf);
return((ALubyte *) buf);
} // __alcDetermineDeviceNameList
#endif

Expand Down Expand Up @@ -948,7 +948,7 @@ static ALboolean __alcDetermineDeviceID(const ALubyte *deviceName,

// Try to find a device name that matches request...

nameLen = (UInt32) (strlen(deviceName) + 1);
nameLen = (UInt32) (strlen((const char *) deviceName) + 1);
nameBuf = alloca((size_t) nameLen);
if (nameBuf == NULL)
return(AL_FALSE);
Expand Down
14 changes: 7 additions & 7 deletions osx/alExtension.c
Expand Up @@ -48,7 +48,7 @@ static ALboolean extDetectAlwaysTrue(ALvoid)

typedef struct
{
const ALubyte *extName;
const char *extName;
ALboolean (*detect)(ALvoid);
ALboolean isALC;
ALboolean available;
Expand Down Expand Up @@ -127,8 +127,8 @@ const ALubyte *__alCalculateExtensions(ALboolean isALC)
if ((__alExtensionTable[i].isALC) || (!__alExtensionTable[i].available))
continue;
if (__alExtensionsString[0])
strcat(__alExtensionsString, " ");
strcat(__alExtensionsString, __alExtensionTable[i].extName);
strcat((char *) __alExtensionsString, " ");
strcat((char *) __alExtensionsString, __alExtensionTable[i].extName);
} // for
} // if

Expand Down Expand Up @@ -159,16 +159,16 @@ const ALubyte *__alCalculateExtensions(ALboolean isALC)
if ((!__alExtensionTable[i].isALC) || (!__alExtensionTable[i].available))
continue;
if (__alcExtensionsString[0])
strcat(__alcExtensionsString, " ");
strcat(__alcExtensionsString, __alExtensionTable[i].extName);
strcat((char *) __alcExtensionsString, " ");
strcat((char *) __alcExtensionsString, __alExtensionTable[i].extName);
} // for
} // if

return(isALC ? __alcExtensionsString : __alExtensionsString);
} // __alCalculateExtensions


ALboolean __alIsExtensionPresent(const ALbyte *extName, ALboolean isALC)
ALboolean __alIsExtensionPresent(const ALubyte *extName, ALboolean isALC)
{
size_t i;
size_t max = sizeof (__alExtensionTable) / sizeof (__alExtensionItem);
Expand All @@ -179,7 +179,7 @@ ALboolean __alIsExtensionPresent(const ALbyte *extName, ALboolean isALC)
{
if (__alExtensionTable[i].isALC == isALC)
{
if (strcmp(__alExtensionTable[i].extName, extName) == 0)
if (strcmp((const char *) __alExtensionTable[i].extName, (const char *) extName) == 0)
{
if (__alExtensionTable[i].available)
return(AL_TRUE);
Expand Down
2 changes: 1 addition & 1 deletion osx/alInternal.h
Expand Up @@ -431,7 +431,7 @@ ALvoid __alDoVBAP(ALcontext *ctx, ALsource *src, ALvector pos, ALfloat gain);

// Extensions...
const ALubyte *__alCalculateExtensions(ALboolean isALC);
ALboolean __alIsExtensionPresent(const ALbyte *extName, ALboolean isALC);
ALboolean __alIsExtensionPresent(const ALubyte *extName, ALboolean isALC);


#if SUPPORTS_AL_EXT_VECTOR_UNIT
Expand Down
2 changes: 1 addition & 1 deletion osx/alMath.h
Expand Up @@ -35,7 +35,7 @@
// use _more_ Altivec, since we can guarantee your processor has it.

// 4 for Altivec-happiness, but we only need 3.
typedef ALfloat ALvector[4] __attribute__((packed,aligned(16)));
typedef ALfloat ALvector[4] __attribute__((aligned(16)));

#define DIVBY32767 0.000030519f
#define DIVBY127 0.007874016f
Expand Down
52 changes: 35 additions & 17 deletions osx/makefile
Expand Up @@ -12,7 +12,9 @@
#
# Mac users with G4's should set the USE_G4_OPCODES option to "true".
# This will use Altivec in places we wouldn't if we needed to check for
# availability, but the shared library will crash on a G3 or older CPU.
# availability, but the shared library will crash on a G3 or older CPU. We
# set a few generic compiler flags to encourage it to build code tuned for
# the G4, too.
#
# Please note that if you don't set the USE_x_OPCODES makefile options, we'll
# still try to do the right thing, including detecting Altivec support and
Expand All @@ -34,21 +36,35 @@ USE_G4_OPCODES := false
USE_G5_OPCODES := false
USE_CCACHE := true
USE_IBM_COMPILER := false
USE_VBAP := false
SUPPORT_ALC_ENUMERATION_EXT := false
SUPPORT_ALC_EXT_CAPTURE := false
SUPPORT_ALC_EXT_SPEAKER_ATTRS := false
SUPPORT_ALC_ENUMERATION_EXT := true
SUPPORT_ALC_EXT_CAPTURE := true
SUPPORT_AL_EXT_VORBIS := false
SUPPORT_AL_EXT_MP3 := false
SUPPORT_AL_EXT_VECTOR_UNIT := true
SUPPORT_AL_EXT_BUFFER_OFFSET := false
SUPPORT_AL_EXT_FLOAT32 := false
SUPPORT_AL_EXT_BUFFER_OFFSET := true
SUPPORT_AL_EXT_FLOAT32 := true

# ----------------------------------------------------------------------------
# Don't touch this stuff unless you know what you're doing.
# Don't touch anything below this line unless you know what you're doing.

LIB := openal.dylib

# These are broken and/or incomplete experiments. Don't enable.
USE_VBAP := false
SUPPORT_ALC_EXT_SPEAKER_ATTRS := false

ISGCC3 := false
ifeq ($(strip $(USE_IBM_COMPILER)),false)
GCCVERCMDLINE := gcc -v 2>&1 |grep version |perl -w -p -e 's/gcc version (\d)\..*? .*/$$1/'
GCCMAJORVER := $(shell $(GCCVERCMDLINE))
ifeq ($(strip $(GCCMAJORVER)),2)
$(error gcc 2 is not supported. Please upgrade to gcc 3.3 or later.)
endif
ifeq ($(strip $(GCCMAJORVER)),3)
ISGCC3 := true
endif
endif

ifeq ($(strip $(USE_G5_OPCODES)),true)
USE_G4_OPCODES := true
endif
Expand All @@ -67,21 +83,23 @@ ifeq ($(strip $(USE_IBM_COMPILER)),true)
endif
else
COMPILER := gcc
COMPILERFLAGS := -Wall -Werror -faltivec -fasm -force_cpusubtype_ALL -fsigned-chars -fPIC
COMPILERFLAGS := -Wall -faltivec -fasm -force_cpusubtype_ALL -fsigned-chars -fPIC
ifeq ($(strip $(OPTIMIZE)),true)
OPTIMIZATIONS := -O3 -D_NDEBUG=1 -falign-loops=16 -ffast-math -fexpensive-optimizations -fno-math-errno
ifeq ($(strip $(USE_G5_OPCODES)),true)
OPTIMIZATIONS += -mpowerpc-gpopt -mpowerpc64 -mcpu=970 -march=970 -DFORCE_STD_SQRT=1
OPTIMIZATIONS += -mcpu=G5 -mtune=G5 -mpowerpc-gpopt -mpowerpc64 -DFORCE_STD_SQRT=1
endif
ifeq ($(strip $(USE_G4_OPCODES)),true)
ifeq ($(strip $(USE_G5_OPCODES)),false)
OPTIMIZATIONS += -mcpu=G4 -mtune=G4
endif
OPTIMIZATIONS += -maltivec -DFORCE_ALTIVEC=1
endif
OPTIMIZATIONS += -O3 -D_NDEBUG=1 -falign-loops=16 -ffast-math -fexpensive-optimizations -fno-math-errno
else
OPTIMIZATIONS := -O0
endif
endif

ifeq ($(strip $(USE_G4_OPCODES)),true)
OPTIMIZATIONS += -DFORCE_ALTIVEC=1
endif

ifeq ($(strip $(USE_CCACHE)),true)
CC := ccache $(COMPILER)
else
Expand All @@ -92,14 +110,14 @@ CFLAGS := -g -fno-common $(OPTIMIZATIONS) $(COMPILERFLAGS) -D_REENTRANT -c -I../
LDFLAGS := -g -fno-common -dynamiclib -framework CoreAudio -framework CoreServices -compatibility_version 1.0.0 -install_name @executable_path/openal.dylib

SRCS := alContext.c \
alBuffer.c \
alBuffer.c \
alEnvironment.c \
alExtension.c \
alListener.c \
alSoftware.c \
alSource.c \
alState.c \
ALut.c
ALut.c

ifeq ($(strip $(USE_VBAP)),true)
CFLAGS += -DUSE_VBAP=1
Expand Down

0 comments on commit 205d0e3

Please sign in to comment.