Skip to content

Commit

Permalink
Mac: Basic init of dsFMOD
Browse files Browse the repository at this point in the history
The FMOD Ex shared library is bundled inside the dsFMOD.bundle.
The plugin is now loaded successfully.
  • Loading branch information
skyjake committed Dec 1, 2011
1 parent 65c3f79 commit 8d74cf9
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 18 deletions.
1 change: 1 addition & 0 deletions doomsday/build/mac/bundleapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ $CP plugins/jdoom/jDoom.bundle $BUILDDIR/jDoom.bundle
$CP plugins/jheretic/jHeretic.bundle $BUILDDIR/jHeretic.bundle
$CP plugins/jhexen/jHexen.bundle $BUILDDIR/jHexen.bundle
$CP plugins/jdoom64/jDoom64.bundle $BUILDDIR/jDoom64.bundle
$CP plugins/fmod/dsFMOD.bundle $BUILDDIR/dsFMOD.bundle

echo "Bundling done."
13 changes: 12 additions & 1 deletion doomsday/config.pri
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ DENG_WIN_PRODUCTS_DIR = $$PWD/../distrib/products

include(versions.pri)

# Build Options --------------------------------------------------------------
# Macros ---------------------------------------------------------------------

defineTest(echo) {
!win32 {
Expand All @@ -51,6 +51,17 @@ defineTest(echo) {
}
}

defineTest(doPostLink) {
isEmpty(QMAKE_POST_LINK) {
QMAKE_POST_LINK = $$1
} else {
QMAKE_POST_LINK = $$QMAKE_POST_LINK && $$1
}
export(QMAKE_POST_LINK)
}

# Build Options --------------------------------------------------------------

# Configure for Debug/Release build.
CONFIG(debug, debug|release) {
echo(Debug build.)
Expand Down
6 changes: 5 additions & 1 deletion doomsday/engine/engine.pro
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,11 @@ startupgfx.files = \
macx {
# Since qmake is unable to copy directories as bundle data, let's copy
# the frameworks manually.
QMAKE_POST_LINK = "rm -rf $${OUT_PWD}/doomsday.app/Contents/Frameworks && mkdir $${OUT_PWD}/doomsday.app/Contents/Frameworks && cp -fRp $${SDL_FRAMEWORK_DIR}/SDL.framework $${OUT_PWD}/doomsday.app/Contents/Frameworks/ && cp -fRp $${SDL_FRAMEWORK_DIR}/SDL_mixer.framework $${OUT_PWD}/doomsday.app/Contents/Frameworks/ && cp -fRp $${SDL_FRAMEWORK_DIR}/SDL_net.framework $${OUT_PWD}/doomsday.app/Contents/Frameworks/"
doPostLink("rm -rf \"$${OUT_PWD}/doomsday.app/Contents/Frameworks\"")
doPostLink("mkdir \"$${OUT_PWD}/doomsday.app/Contents/Frameworks\"")
doPostLink("cp -fRp \"$${SDL_FRAMEWORK_DIR}/SDL.framework\" \"$${OUT_PWD}/doomsday.app/Contents/Frameworks/\"")
doPostLink("cp -fRp \"$${SDL_FRAMEWORK_DIR}/SDL_mixer.framework\" \"$${OUT_PWD}/doomsday.app/Contents/Frameworks/\"")
doPostLink("cp -fRp \"$${SDL_FRAMEWORK_DIR}/SDL_net.framework\" \"$${OUT_PWD}/doomsday.app/Contents/Frameworks/\"")

RES_PATH = Contents/Resources
res.files = \
Expand Down
10 changes: 10 additions & 0 deletions doomsday/engine/portable/src/s_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ boolean S_InitDriver(audiodriver_e drvid)
break;
#endif

case AUDIOD_FMOD:
Con_Printf("FMOD Ex\n");
if(!(audioDriver = Sys_LoadAudioDriver("fmod")))
return false;
break;

case AUDIOD_OPENAL:
Con_Printf("OpenAL\n");
if(!(audioDriver = Sys_LoadAudioDriver("openal")))
Expand Down Expand Up @@ -166,6 +172,10 @@ boolean S_Init(void)
{
ok = S_InitDriver(AUDIOD_DUMMY);
}
else if(ArgExists("-fmod"))
{
ok = S_InitDriver(AUDIOD_FMOD);
}
else if(ArgExists("-oal"))
{
ok = S_InitDriver(AUDIOD_OPENAL);
Expand Down
23 changes: 13 additions & 10 deletions doomsday/engine/portable/src/s_mus.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,38 +125,41 @@ boolean Mus_Init(void)
if(isDedicated || ArgExists("-nomusic"))
return true;

iMusic = NULL;
iCD = NULL;

// Use the external music playback facilities, if available.
if(audioDriver == &audiod_dummy)
{
iMusic = NULL;
iCD = NULL;
// Nothing to do.
}
#ifndef DENG_DISABLE_SDLMIXER
else if(audioDriver == &audiod_sdlmixer)
{
iMusic = (audiointerface_music_t*) &audiod_sdlmixer_music;
iCD = NULL;
}
#endif
else
{
iMusic = (audiodExternalIMusic.gen.Init ? &audiodExternalIMusic : 0);
iCD = (audiodExternalICD.gen.Init ? &audiodExternalICD : 0);
// Use the external interface.
iMusic = (audiodExternalIMusic.gen.Init? &audiodExternalIMusic : 0);
iCD = (audiodExternalICD.gen.Init? &audiodExternalICD : 0);
}

#ifdef MACOSX
// On the Mac, just use QuickTime for the music and be done with it.
iMusic = &audiodQuickTimeMusic;
if(!iMusic)
{
// On the Mac, use QuickTime as the fallback for music.
iMusic = &audiodQuickTimeMusic;
}
#endif

// Initialize the chosen interfaces.
for(i = 0; i < NUM_INTERFACES; ++i)
{
if(*interfaces[i].ip && !(*interfaces[i].ip)->Init())
{
Con_Message("Mus_Init: Failed to initialize %s interface.\n",
interfaces[i].name);

Con_Message("Mus_Init: Failed to initialize %s interface.\n", interfaces[i].name);
*interfaces[i].ip = NULL;
}
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/s_sfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ boolean Sfx_Init(void)
#endif
else
{
iSFX = (audiodExternalISFX.gen.Init ?
iSFX = (audiodExternalISFX.gen.Init?
(audiointerface_sfx_generic_t*) &audiodExternalISFX : 0);
}

Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/sys_audiod_dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ static boolean inited;
// CODE --------------------------------------------------------------------

/**
* Init DirectSound, start playing the primary buffer. Returns true
* if successful.
* Initialization of the sound driver.
* @return @c true if successful.
*/
int DS_DummyInit(void)
{
Expand Down
6 changes: 6 additions & 0 deletions doomsday/plugins/fmod/fmod.pro
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ win32 {
INSTALLS += target
target.path = $$DENG_LIB_DIR
}

macx {
doPostLink("cp -f \"$$FMOD_DIR/api/lib/libfmodex.dylib\" dsFMOD.bundle/")
doPostLink("install_name_tool -id @executable_path/../../../dsFMOD.bundle/libfmodex.dylib dsFMOD.bundle/libfmodex.dylib")
doPostLink("install_name_tool -change ./libfmodex.dylib @executable_path/../../../dsFMOD.bundle/libfmodex.dylib dsFMOD.bundle/dsfmod")
}
17 changes: 17 additions & 0 deletions doomsday/plugins/fmod/include/driver_fmod.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,31 @@
#ifndef __DSFMOD_DRIVER_H__
#define __DSFMOD_DRIVER_H__

#include <fmod.h>
#include <fmod.hpp>
#include <fmod_errors.h>

#ifdef __cplusplus
extern "C" {
#endif

int DS_Init(void);
void DS_Shutdown(void);
void DS_Event(int type);

#ifdef __cplusplus
}
#endif

#ifdef _DEBUG
# define ERRCHECK(result) \
if(result != FMOD_OK) { \
printf("FMOD error at %s, line %i: (%d) %s\n", __FILE__, __LINE__, result, FMOD_ErrorString(result)); \
}
#else
# define ERRCHECK(result)
#endif

#include "fmod_sfx.h"
#include "fmod_music.h"
#include "fmod_cd.h"
Expand Down
63 changes: 60 additions & 3 deletions doomsday/plugins/fmod/src/driver_fmod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,64 @@
*/

#include "driver_fmod.h"
#include "sys_audiod_sfx.h"
#include <stdio.h>
#include <fmod.h>
#include <fmod_errors.h>
#include <fmod.hpp>

// DS_Init
// DS_Shutdown
// DS_Event
FMOD::System* system = 0;

/**
* Initialize the FMOD Ex sound driver.
*/
int DS_Init(void)
{
if(system)
{
return true; // Already initialized.
}

// Create the FMOD audio system.
FMOD_RESULT result;
if((result = FMOD::System_Create(&system)) != FMOD_OK)
{
printf("DS_Init: FMOD::System_Create failed: (%d) %s\n", result, FMOD_ErrorString(result));
system = 0;
return false;
}

// Initialize FMOD.
if((result = system->init(50, FMOD_INIT_NORMAL, 0)) != FMOD_OK)
{
printf("DS_Init: FMOD init failed: (%d) %s\n", result, FMOD_ErrorString(result));
system->release();
system = 0;
return false;
}
return true;
}

/**
* Shut everything down.
*/
void DS_Shutdown(void)
{
system->release();
system = 0;
}

/**
* The Event function is called to tell the driver about certain critical
* events like the beginning and end of an update cycle.
*/
void DS_Event(int type)
{
if(!system) return;

if(type == SFXEV_END)
{
// End of frame, do an update.
system->update();
}
}

0 comments on commit 8d74cf9

Please sign in to comment.