diff options
-rw-r--r-- | intern/SoundSystem/Makefile | 10 | ||||
-rw-r--r-- | intern/SoundSystem/SND_DependKludge.h | 14 | ||||
-rw-r--r-- | intern/SoundSystem/intern/SND_Utils.cpp | 7 | ||||
-rw-r--r-- | intern/SoundSystem/openal/SND_OpenALDevice.cpp | 32 | ||||
-rw-r--r-- | intern/SoundSystem/openal/SND_OpenALDevice.h | 3 | ||||
-rw-r--r-- | source/Makefile | 4 | ||||
-rw-r--r-- | source/nan_link.mk | 3 |
7 files changed, 46 insertions, 27 deletions
diff --git a/intern/SoundSystem/Makefile b/intern/SoundSystem/Makefile index 9714e49da36..20e37c26a33 100644 --- a/intern/SoundSystem/Makefile +++ b/intern/SoundSystem/Makefile @@ -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 diff --git a/intern/SoundSystem/SND_DependKludge.h b/intern/SoundSystem/SND_DependKludge.h index d5d8dd27972..15db3da9cd2 100644 --- a/intern/SoundSystem/SND_DependKludge.h +++ b/intern/SoundSystem/SND_DependKludge.h @@ -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 diff --git a/intern/SoundSystem/intern/SND_Utils.cpp b/intern/SoundSystem/intern/SND_Utils.cpp index 1048e701611..a919ffad609 100644 --- a/intern/SoundSystem/intern/SND_Utils.cpp +++ b/intern/SoundSystem/intern/SND_Utils.cpp @@ -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)) diff --git a/intern/SoundSystem/openal/SND_OpenALDevice.cpp b/intern/SoundSystem/openal/SND_OpenALDevice.cpp index 6016b1b2355..199e791dd64 100644 --- a/intern/SoundSystem/openal/SND_OpenALDevice.cpp +++ b/intern/SoundSystem/openal/SND_OpenALDevice.cpp @@ -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 } diff --git a/intern/SoundSystem/openal/SND_OpenALDevice.h b/intern/SoundSystem/openal/SND_OpenALDevice.h index f204d2d0371..4f20580c2f3 100644 --- a/intern/SoundSystem/openal/SND_OpenALDevice.h +++ b/intern/SoundSystem/openal/SND_OpenALDevice.h @@ -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 diff --git a/source/Makefile b/source/Makefile index 3fb82d4033e..20322946ab7 100644 --- a/source/Makefile +++ b/source/Makefile @@ -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) diff --git a/source/nan_link.mk b/source/nan_link.mk index fd117f6e4f7..7f741ffad20 100644 --- a/source/nan_link.mk +++ b/source/nan_link.mk @@ -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 |