mac: Rearrange sound toolkit includes and FindAudio.cmake so that sound+music works for OSX

issue1247
Martin Plicht 2014-09-21 21:46:12 +02:00
parent 84cc072405
commit cf474e99aa
9 changed files with 61 additions and 79 deletions

View File

@ -435,6 +435,7 @@ set(OC_CLONK_SOURCES
src/platform/C4MusicSystem.h
src/platform/C4SoundLoaders.cpp
src/platform/C4SoundLoaders.h
src/platform/C4SoundIncludes.h
src/platform/C4SoundSystem.cpp
src/platform/C4SoundSystem.h
src/platform/C4TimeMilliseconds.cpp
@ -1109,7 +1110,7 @@ if(UNIX AND NOT APPLE)
endif()
endif()
set_property(TARGET openclonk APPEND PROPERTY COMPILE_DEFINITIONS GLEW_STATIC)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG)
#set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG)
# This expands some variables in Info.plist as a side-effect. XCode might then
# expand a second time, using the same syntax. Try not to get confused by this!
@ -1314,7 +1315,7 @@ if(USE_X11)
)
endif()
if(USE_COCOA)
TARGET_LINK_LIBRARIES(openclonk "-framework Cocoa -framework AppKit -framework Quartz")
TARGET_LINK_LIBRARIES(openclonk "-framework Cocoa -framework AppKit -framework Quartz -framework OpenAL -framework AudioToolBox")
endif()
if (WIN32)
# CMake is too incompetent to check whether these libraries can be linked to

View File

@ -15,13 +15,13 @@
macro(__FINDAUDIO_FINDOPENAL)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
if(PKG_CONFIG_FOUND AND NOT(APPLE))
pkg_check_modules(OpenAL "openal>=1.15.1")
pkg_check_modules(Alut "freealut>=1.1.0")
pkg_check_modules(OggVorbis "vorbisfile>=1.3.2" "vorbis>=1.3.2" "ogg>=1.3.0")
else()
if(MSVC OR APPLE)
find_path(OpenAL_INCLUDE_DIRS al.h PATH_SUFFIXES include/AL include/OpenAL include)
find_path(OpenAL_INCLUDE_DIRS al.h PATH_SUFFIXES include/AL include/OpenAL include OpenAL)
find_path(Vorbis_INCLUDE_DIRS vorbis/codec.h vorbis/vorbisfile.h PATH_SUFFIXES include)
find_library(Ogg_LIBRARY NAMES libogg_static libogg ogg)
find_library(Vorbis_LIBRARY NAMES libvorbis_static libvorbis vorbis)
@ -34,17 +34,17 @@ macro(__FINDAUDIO_FINDOPENAL)
set(OggVorbis_LIBRARIES ${Vorbisfile_LIBRARY} ${Vorbis_LIBRARY} ${Ogg_LIBRARY})
set(OggVorbis_INCLUDE_DIRS(${Vorbis_INCLUDE_DIRS}))
endif()
endif()
if(MSVC)
find_path(Alut_INCLUDE_DIRS alut.h PATH_SUFFIXES include/AL include/OpenAL include)
find_library(Alut_LIBRARY NAMES alut_static alut)
if(${FIND_LIBRARY_USE_LIB64_PATHS})
find_library(OpenAL_LIBRARY NAMES OpenAL64)
else()
find_library(OpenAL_LIBRARY NAMES OpenAL32)
endif()
if(NOT OpenAL_LIBRARY)
set(OpenAL_FOUND FALSE)
if (MSVC)
if(${FIND_LIBRARY_USE_LIB64_PATHS})
find_library(OpenAL_LIBRARY NAMES OpenAL64)
else()
find_library(OpenAL_LIBRARY NAMES OpenAL32)
endif()
if(NOT OpenAL_LIBRARY)
set(OpenAL_FOUND FALSE)
endif()
endif()
if(Alut_INCLUDE_DIRS AND Alut_LIBRARY)
set(Alut_FOUND TRUE)
@ -73,7 +73,7 @@ else()
__FINDAUDIO_FINDSDLMIXER()
find_package("FMod")
if(OpenAL_FOUND AND (APPLE OR Alut_FOUND) AND OggVorbis_FOUND)
if(OpenAL_FOUND AND Alut_FOUND AND OggVorbis_FOUND)
# Prefer OpenAL
set(Audio_TK "OpenAL")
elseif(SDLMixer_FOUND)
@ -92,14 +92,8 @@ if(Audio_TK STREQUAL "OpenAL")
set(Audio_FOUND TRUE)
set(Audio_LIBRARIES ${OpenAL_LIBRARIES} ${OggVorbis_LIBRARIES})
set(Audio_INCLUDE_DIRS ${OpenAL_INCLUDE_DIRS} ${OggVorbis_INCLUDE_DIRS})
if (NOT APPLE)
# Apple doesn't need freealut
set(Audio_LIBRARIES ${Audio_LIBRARIES} ${Alut_LIBRARIES} ${OpenAL_LIBRARY})
set(Audio_INCLUDE_DIRS ${Audio_INCLUDE_DIRS} ${Alut_INCLUDE_DIRS})
else()
# but it uses the AudioToolBox framework
set(Audio_LIBRARIES ${Audio_LIBRARIES} "-framework OpenAL -framework AudioToolBox")
endif()
set(Audio_LIBRARIES ${Audio_LIBRARIES} ${Alut_LIBRARIES})
set(Audio_INCLUDE_DIRS ${Audio_INCLUDE_DIRS} ${Alut_INCLUDE_DIRS})
endif()
elseif(Audio_TK STREQUAL "SDL_Mixer")
__FINDAUDIO_FINDSDLMIXER()

View File

@ -18,15 +18,9 @@
#ifndef INC_C4MusicFile
#define INC_C4MusicFile
#if AUDIO_TK == AUDIO_TK_FMOD
#include <fmod.h>
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
#define USE_RWOPS
#include <SDL_mixer.h>
#undef USE_RWOPS
#elif AUDIO_TK == AUDIO_TK_OPENAL
#include <C4SoundIncludes.h>
#include <C4SoundLoaders.h>
#endif
/* Base class */
class C4MusicFile

View File

@ -28,19 +28,6 @@
#include <C4Game.h>
#include <C4GraphicsSystem.h>
#if AUDIO_TK == AUDIO_TK_FMOD
#include <fmod_errors.h>
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
#include <SDL.h>
#elif AUDIO_TK == AUDIO_TK_OPENAL && !defined(APPLE)
#ifdef _WIN32
// This is an ugly hack to make FreeALUT not dllimport everything.
#define _XBOX
#endif
#include <alut.h>
#undef _XBOX
#endif
C4MusicSystem::C4MusicSystem():
Songs(NULL),
SongCount(0),

View File

@ -21,11 +21,7 @@
#define INC_C4MusicSystem
#include <C4Group.h>
#if AUDIO_TK == AUDIO_TK_OPENAL
#include <al.h>
#include <alc.h>
#endif
#include <C4SoundIncludes.h>
class C4MusicFileInfoNode;
class C4MusicFile;

View File

@ -0,0 +1,40 @@
// Put all the terrible walls of includes for sound toolkits here
#ifndef INC_C4SoundIncludes
#define INC_C4SoundIncludes
#if AUDIO_TK == AUDIO_TK_FMOD
# include <fmod.h>
typedef FSOUND_SAMPLE* C4SoundHandle;
# include <fmod_errors.h>
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
# define USE_RWOPS
# include <SDL_mixer.h>
# undef USE_RWOPS
typedef struct Mix_Chunk* C4SoundHandle;
# include <SDL.h>
#elif AUDIO_TK == AUDIO_TK_OPENAL
# ifdef __APPLE__
# include <OpenAL/al.h>
# else
# include <al.h>
# endif
typedef ALuint C4SoundHandle;
# ifdef _WIN32
// This is an ugly hack to make FreeALUT not dllimport everything.
# define _XBOX
# endif
# include <alut.h>
# undef _XBOX
# if defined(__APPLE__)
# import <CoreFoundation/CoreFoundation.h>
# import <AudioToolbox/AudioToolbox.h>
# endif
# include <vorbis/codec.h>
# include <vorbis/vorbisfile.h>
# include <ogg/os_types.h>
#else
typedef void* C4SoundHandle;
#endif
#endif

View File

@ -19,20 +19,6 @@
#include <C4Application.h>
#if AUDIO_TK == AUDIO_TK_OPENAL
#if defined(__APPLE__)
#import <CoreFoundation/CoreFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
#else
#ifdef _WIN32
// This is an ugly hack to make FreeALUT not dllimport everything.
#define _XBOX
#endif
#include <alut.h>
#undef _XBOX
#endif
#endif
using namespace C4SoundLoaders;

View File

@ -16,11 +16,6 @@
#ifndef INC_C4SoundLoaders
#define INC_C4SoundLoaders
#if AUDIO_TK == AUDIO_TK_OPENAL
#include <vorbis/codec.h>
#include <vorbis/vorbisfile.h>
#endif
#include <vector>
#include <C4SoundSystem.h>

View File

@ -21,6 +21,7 @@
#define INC_C4SoundSystem
#include <C4Group.h>
#include <C4SoundIncludes.h>
const int32_t
C4MaxSoundName=100,
@ -31,18 +32,6 @@ const int32_t
class C4Object;
class C4SoundInstance;
#if AUDIO_TK == AUDIO_TK_FMOD
#include <fmod.h>
typedef FSOUND_SAMPLE* C4SoundHandle;
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
typedef struct Mix_Chunk* C4SoundHandle;
#elif AUDIO_TK == AUDIO_TK_OPENAL
#include <al.h>
typedef ALuint C4SoundHandle;
#else
typedef void* C4SoundHandle;
#endif
class C4SoundEffect
{
friend class C4SoundInstance;