enable openal support for os x and linux-powerpc

as there is a conflict between openal and sdl (when compiled with cdrom
support), i had to disable support for cd playing using sdl on os x
for the time being.
This commit is contained in:
Stefan Gartner 2004-04-14 13:00:36 +00:00
parent 7dc152b01a
commit 837da93f19
7 changed files with 46 additions and 27 deletions

@ -44,16 +44,14 @@ ifneq ($(NAN_NO_OPENAL),true)
DIRS += fmod
DIRS += openal sdl
endif
#ifeq ($(OS),darwin)
# DIRS += fmod
#endif
ifeq ($(OS),darwin)
DIRS += openal
endif
ifeq ($(OS),freebsd)
DIRS += openal
endif
ifeq ($(OS),$(findstring $(OS), "linux"))
ifeq ($(CPU),i386)
DIRS += openal sdl
endif
DIRS += openal sdl
endif
else
CPPFLAGS += -DNO_SOUND

@ -38,18 +38,10 @@
#ifndef NO_SOUND
# if defined (_WIN32) && !defined(FREE_WINDOWS)
#define USE_OPENAL
#elif defined (__linux__)
# if defined (__i386__)
# define USE_OPENAL
# endif
#elif defined (__FreeBSD__)
#if defined (_WIN32) && !defined(FREE_WINDOWS)
# define USE_OPENAL
#elif defined (__linux__) || (__FreeBSD__) || defined(__APPLE__)
# define USE_OPENAL
/*
#elif defined (__APPLE__)
# define USE_FMOD
*/
#else
# ifdef USE_OPENAL
# undef USE_OPENAL

@ -73,7 +73,7 @@ typedef enum
SND_endianLittle
} SND_TEndian;
#ifdef __APPLE__
#ifdef __BIG_ENDIAN__
const SND_TEndian SND_fEndian = SND_endianBig;
#else
const SND_TEndian SND_fEndian = SND_endianLittle;
@ -339,6 +339,8 @@ unsigned int SND_GetHeaderSize(void* sample)
if (CheckSample(sample))
{
memcpy(&chunklength, ((char*)sample) + offset, 4);
/* This was endian unsafe. See top of the file for the define. */
if (SND_fEndian == SND_endianBig) SWITCH_INT(chunklength);
offset = offset + chunklength + 4;
memcpy(data, ((char*)sample) + offset, 4);
@ -392,10 +394,11 @@ void SND_GetSampleInfo(signed char* sample, SND_WaveSlot* waveslot)
if (CheckSample(sample))
{
memcpy(&fileheader, sample, sizeof(WavFileHeader));
fileheader.size = SND_GetHeaderSize(sample);
sample += sizeof(WavFileHeader);
fileheader.size = ((fileheader.size+1) & ~1) - 4;
while ((fileheader.size != 0) && (memcpy(&chunkheader, sample, sizeof(WavChunkHeader))))
while ((fileheader.size > 0) && (memcpy(&chunkheader, sample, sizeof(WavChunkHeader))))
{
sample += sizeof(WavChunkHeader);
if (!memcmp(chunkheader.id, "fmt ", 4))

@ -40,7 +40,9 @@
#endif //WIN32
#include "SND_OpenALDevice.h"
#ifndef __APPLE__
#include "SND_SDLCDDevice.h"
#endif
#include "SoundDefines.h"
#include "SND_Utils.h"
@ -276,8 +278,9 @@ SND_OpenALDevice::SND_OpenALDevice()
{
m_wavecache = new SND_WaveCache();
}
#ifndef __APPLE__
m_cdrom = new SND_SDLCDDevice();
#endif
}
void SND_OpenALDevice::UseCD(void) const
@ -316,9 +319,10 @@ SND_OpenALDevice::~SND_OpenALDevice()
this->StopCD();
SND_CDObject::DisposeSystem();
}
#ifndef __APPLE__
if (m_cdrom)
delete m_cdrom;
#endif
}
@ -366,7 +370,7 @@ SND_WaveSlot* SND_OpenALDevice::LoadSample(const STR_String& name,
bitrate = SND_GetBitRate(memlocation);
/* load the sample into openal */
#ifdef OUDE_OPENAL
#if defined(OUDE_OPENAL) || defined (__APPLE__)
alutLoadWAVMemory((char*)memlocation, &sampleformat, &data, &numberofsamples, &samplerate); // openal_2.12
#else
alutLoadWAVMemory((signed char*)memlocation, &sampleformat, &data, &numberofsamples, &samplerate, &loop);// openal_2.14+
@ -377,7 +381,9 @@ SND_WaveSlot* SND_OpenALDevice::LoadSample(const STR_String& name,
/* or from file? */
else
{
#ifdef WIN32
#ifdef __APPLE__
alutLoadWAVFile((signed char*)samplename.Ptr(), &sampleformat, &data, &numberofsamples, &samplerate);
#elif defined(WIN32)
alutLoadWAVFile((signed char*)samplename.Ptr(), &sampleformat, &data, &numberofsamples, &samplerate, &loop);
#else
alutLoadWAV((char*)samplename.Ptr(), &data,
@ -456,7 +462,9 @@ void SND_OpenALDevice::SetListenerRollOffFactor(MT_Scalar rollofffactor) const
void SND_OpenALDevice::NextFrame() const
{
// CD
#ifndef __APPLE__
m_cdrom->NextFrame();
#endif
// not needed by openal
}
@ -509,8 +517,12 @@ int SND_OpenALDevice::GetPlayState(int id)
int alstate = 0;
int result = 0;
#ifdef __APPLE__
alGetSourcei(m_sources[id], AL_SOURCE_STATE, &alstate);
#else
alGetSourceiv(m_sources[id], AL_SOURCE_STATE, &alstate);
#endif
switch(alstate)
{
case AL_INITIAL:
@ -690,31 +702,41 @@ void SND_OpenALDevice::SetObjectTransform(int id,
void SND_OpenALDevice::PlayCD(int track) const
{
#ifndef __APPLE__
m_cdrom->PlayCD(track);
#endif
}
void SND_OpenALDevice::PauseCD(bool pause) const
{
#ifndef __APPLE__
m_cdrom->PauseCD(pause);
#endif
}
void SND_OpenALDevice::StopCD() const
{
#ifndef __APPLE__
SND_CDObject* pCD = SND_CDObject::Instance();
if (pCD && pCD->GetUsed())
{
m_cdrom->StopCD();
}
#endif
}
void SND_OpenALDevice::SetCDPlaymode(int playmode) const
{
#ifndef __APPLE__
m_cdrom->SetCDPlaymode(playmode);
#endif
}
void SND_OpenALDevice::SetCDGain(MT_Scalar gain) const
{
#ifndef __APPLE__
m_cdrom->SetCDGain(gain);
#endif
}

@ -100,8 +100,9 @@ private:
unsigned int m_sources[NUM_SOURCES];
bool m_buffersinitialized;
bool m_sourcesinitialized;
#ifndef __APPLE__
class SND_SDLCDDevice* m_cdrom;
#endif
};
#endif //SND_OPENALDEVICE

@ -376,7 +376,7 @@ ifeq ($(NAN_NO_OPENAL), true)
NAN_SND_LIBS += $(SOUNDSYSTEM)
else
ifeq ($(OS),$(findstring $(OS), "freebsd linux windows"))
ifeq ($(CPU),i386)
ifeq ($(CPU),$(findstring $(CPU), "i386 powerpc"))
ifeq ($(OS),freebsd)
NAN_SND_LIBS = $(SOUNDSYSTEM)
NAN_SND_LIBS += $(DUMMYSOUND)
@ -410,6 +410,8 @@ else
ifeq ($(OS),darwin)
NAN_SND_LIBS = $(SOUNDSYSTEM)
NAN_SND_LIBS += $(DUMMYSOUND)
NAN_SND_LIBS += $(OPENALSOUND)
NAN_SND_LIBS += $(NAN_OPENAL)/lib/libopenal.a
NAN_SND_LIBS += $(SOUNDSYSTEM)
else
NAN_SND_LIBS = $(SOUNDSYSTEM)

@ -58,7 +58,8 @@ endif
ifeq ($(OS),darwin)
LLIBS += -lGLU -lGL
LLIBS += -lz -framework Carbon -framework AGL
LLIBS += -framework QuickTime
LLIBS += -framework QuickTime -framework CoreAudio
LLIBS += -framework AudioUnit -framework AudioToolbox
LDFLAGS += -L/System/Library/Frameworks/OpenGL.framework/Libraries
DBG_LDFLAGS += -L/System/Library/Frameworks/OpenGL.framework/Libraries
endif