This commit is contained in:
Christoph Oelckers 2016-09-12 21:33:49 +02:00
commit 3778799f92
4 changed files with 43 additions and 6 deletions

View file

@ -281,6 +281,10 @@ if( NOT NO_FMOD )
if( FMOD_INCLUDE_DIR ) if( FMOD_INCLUDE_DIR )
message( STATUS "FMOD include files found at ${FMOD_INCLUDE_DIR}" ) message( STATUS "FMOD include files found at ${FMOD_INCLUDE_DIR}" )
include_directories( "${FMOD_INCLUDE_DIR}" ) include_directories( "${FMOD_INCLUDE_DIR}" )
if( EXISTS "${FMOD_INCLUDE_DIR}/fmod_common.h" )
set( FMOD_STUDIO YES )
endif()
else() else()
message( STATUS "Could not find FMOD include files" ) message( STATUS "Could not find FMOD include files" )
set( NO_FMOD ON ) set( NO_FMOD ON )
@ -1480,7 +1484,16 @@ endif()
if( MSVC ) if( MSVC )
option( ZDOOM_GENERATE_MAPFILE "Generate .map file for debugging." OFF ) option( ZDOOM_GENERATE_MAPFILE "Generate .map file for debugging." OFF )
set( LINKERSTUFF "/MANIFEST:NO /DELAYLOAD:\"fmodex${X64}.dll\"" ) set( LINKERSTUFF "/MANIFEST:NO" )
if( NOT NO_FMOD )
if( FMOD_STUDIO )
set( LINKERSTUFF "${LINKERSTUFF} /DELAYLOAD:\"fmod${X64}.dll\"" )
else()
set( LINKERSTUFF "${LINKERSTUFF} /DELAYLOAD:\"fmodex${X64}.dll\"" )
endif()
endif()
if( ZDOOM_GENERATE_MAPFILE ) if( ZDOOM_GENERATE_MAPFILE )
set( LINKERSTUFF "${LINKERSTUFF} /MAP" ) set( LINKERSTUFF "${LINKERSTUFF} /MAP" )
endif() endif()
@ -1520,17 +1533,23 @@ if( APPLE )
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/posix/osx/zdoom-info.plist" ) MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/posix/osx/zdoom-info.plist" )
if( NOT NO_FMOD ) if( NOT NO_FMOD )
if( FMOD_STUDIO )
set( FMOD_DYLIB libfmod.dylib )
else()
set( FMOD_DYLIB libfmodex.dylib )
endif()
# Fix fmod link so that it can be found in the app bundle. # Fix fmod link so that it can be found in the app bundle.
find_program( OTOOL otool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin" ) find_program( OTOOL otool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin" )
find_program( INSTALL_NAME_TOOL install_name_tool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin" ) find_program( INSTALL_NAME_TOOL install_name_tool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin" )
execute_process( COMMAND "${OTOOL}" -L "${FMOD_LIBRARY}" execute_process( COMMAND "${OTOOL}" -L "${FMOD_LIBRARY}"
COMMAND grep "libfmodex.dylib (compat" COMMAND grep "${FMOD_DYLIB} (compat"
COMMAND head -n1 COMMAND head -n1
COMMAND awk "{print $1}" COMMAND awk "{print $1}"
OUTPUT_VARIABLE FMOD_LINK OUTPUT_VARIABLE FMOD_LINK
OUTPUT_STRIP_TRAILING_WHITESPACE ) OUTPUT_STRIP_TRAILING_WHITESPACE )
add_custom_command( TARGET zdoom POST_BUILD add_custom_command( TARGET zdoom POST_BUILD
COMMAND "${INSTALL_NAME_TOOL}" -change "${FMOD_LINK}" @executable_path/../Frameworks/libfmodex.dylib "$<TARGET_FILE:zdoom>" COMMAND "${INSTALL_NAME_TOOL}" -change "${FMOD_LINK}" @executable_path/../Frameworks/${FMOD_DYLIB} "$<TARGET_FILE:zdoom>"
COMMENT "Relinking FMOD Ex" ) COMMENT "Relinking FMOD Ex" )
endif() endif()
endif() endif()

View file

@ -309,6 +309,11 @@ void FUDMFKeys::Sort()
FUDMFKey *FUDMFKeys::Find(FName key) FUDMFKey *FUDMFKeys::Find(FName key)
{ {
if (!mSorted)
{
mSorted = true;
Sort();
}
int min = 0, max = Size()-1; int min = 0, max = Size()-1;
while (min <= max) while (min <= max)

View file

@ -245,6 +245,7 @@ struct FUDMFKey
class FUDMFKeys : public TArray<FUDMFKey> class FUDMFKeys : public TArray<FUDMFKey>
{ {
bool mSorted = false;
public: public:
void Sort(); void Sort();
FUDMFKey *Find(FName key); FUDMFKey *Find(FName key);

View file

@ -971,6 +971,7 @@ bool FMODSoundRenderer::Init()
#if FMOD_STUDIO #if FMOD_STUDIO
FMOD_ADVANCEDSETTINGS advSettings = {}; FMOD_ADVANCEDSETTINGS advSettings = {};
advSettings.cbSize = sizeof advSettings;
advSettings.resamplerMethod = resampler; advSettings.resamplerMethod = resampler;
result = Sys->setAdvancedSettings(&advSettings); result = Sys->setAdvancedSettings(&advSettings);
if (result != FMOD_OK) if (result != FMOD_OK)
@ -1370,11 +1371,8 @@ void FMODSoundRenderer::PrintStatus()
{ {
FMOD_OUTPUTTYPE output; FMOD_OUTPUTTYPE output;
FMOD_SPEAKERMODE speakermode; FMOD_SPEAKERMODE speakermode;
FMOD_SOUND_FORMAT format;
FMOD_DSP_RESAMPLER resampler;
int driver; int driver;
int samplerate; int samplerate;
int numoutputchannels;
unsigned int bufferlength; unsigned int bufferlength;
int numbuffers; int numbuffers;
@ -1413,6 +1411,9 @@ void FMODSoundRenderer::PrintStatus()
#endif #endif
} }
#if !FMOD_STUDIO #if !FMOD_STUDIO
FMOD_SOUND_FORMAT format;
FMOD_DSP_RESAMPLER resampler;
int numoutputchannels;
if (FMOD_OK == Sys->getSoftwareFormat(&samplerate, &format, &numoutputchannels, NULL, &resampler, NULL)) if (FMOD_OK == Sys->getSoftwareFormat(&samplerate, &format, &numoutputchannels, NULL, &resampler, NULL))
{ {
Printf (TEXTCOLOR_LIGHTBLUE "Software mixer sample rate: " TEXTCOLOR_GREEN "%d\n", samplerate); Printf (TEXTCOLOR_LIGHTBLUE "Software mixer sample rate: " TEXTCOLOR_GREEN "%d\n", samplerate);
@ -2758,6 +2759,16 @@ std::pair<SoundHandle,bool> FMODSoundRenderer::LoadSoundRaw(BYTE *sfxdata, int l
exinfo.defaultfrequency = frequency; exinfo.defaultfrequency = frequency;
switch (bits) switch (bits)
{ {
#if FMOD_STUDIO
case -8:
// Need to convert sample data from signed to unsigned.
for (int i = 0; i < length; i++)
{
sfxdata[i] ^= 0x80;
}
case 8:
#else // !FMOD_STUDIO
case 8: case 8:
// Need to convert sample data from unsigned to signed. // Need to convert sample data from unsigned to signed.
for (int i = 0; i < length; ++i) for (int i = 0; i < length; ++i)
@ -2766,6 +2777,7 @@ std::pair<SoundHandle,bool> FMODSoundRenderer::LoadSoundRaw(BYTE *sfxdata, int l
} }
case -8: case -8:
#endif // FMOD_STUDIO
exinfo.format = FMOD_SOUND_FORMAT_PCM8; exinfo.format = FMOD_SOUND_FORMAT_PCM8;
numsamples = length; numsamples = length;
break; break;