Remove non-functional FMOD support
FossilOrigin-Name: 7e4ba7f32ace858885c5a165b51552a437b61ea85df434b8fbd6be5697b7a7e5
This commit is contained in:
parent
7162807acd
commit
5b200abd87
1 changed files with 3 additions and 84 deletions
87
src/sound.mm
87
src/sound.mm
|
@ -1,15 +1,7 @@
|
||||||
// sound.cpp: uses fmod on windows and sdl_mixer on unix (both had problems on
|
|
||||||
// the other platform)
|
|
||||||
|
|
||||||
#include "cube.h"
|
#include "cube.h"
|
||||||
|
|
||||||
#import "DynamicEntity.h"
|
#import "DynamicEntity.h"
|
||||||
|
|
||||||
// #ifndef _WIN32 // NOTE: fmod not being supported for the moment as it does
|
|
||||||
// not allow stereo pan/vol updating during playback
|
|
||||||
#define USE_MIXER
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
VARP(soundvol, 0, 255, 255);
|
VARP(soundvol, 0, 255, 255);
|
||||||
VARP(musicvol, 0, 128, 255);
|
VARP(musicvol, 0, 128, 255);
|
||||||
bool nosound = false;
|
bool nosound = false;
|
||||||
|
@ -22,17 +14,10 @@ struct soundloc {
|
||||||
bool inuse;
|
bool inuse;
|
||||||
} soundlocs[MAXCHAN];
|
} soundlocs[MAXCHAN];
|
||||||
|
|
||||||
#ifdef USE_MIXER
|
#include <SDL_mixer.h>
|
||||||
# include "SDL_mixer.h"
|
#define MAXVOL MIX_MAX_VOLUME
|
||||||
# define MAXVOL MIX_MAX_VOLUME
|
|
||||||
Mix_Music *mod = NULL;
|
Mix_Music *mod = NULL;
|
||||||
void *stream = NULL;
|
void *stream = NULL;
|
||||||
#else
|
|
||||||
# include "fmod.h"
|
|
||||||
# define MAXVOL 255
|
|
||||||
FMUSIC_MODULE *mod = NULL;
|
|
||||||
FSOUND_STREAM *stream = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
stopsound()
|
stopsound()
|
||||||
|
@ -40,20 +25,12 @@ stopsound()
|
||||||
if (nosound)
|
if (nosound)
|
||||||
return;
|
return;
|
||||||
if (mod) {
|
if (mod) {
|
||||||
#ifdef USE_MIXER
|
|
||||||
Mix_HaltMusic();
|
Mix_HaltMusic();
|
||||||
Mix_FreeMusic(mod);
|
Mix_FreeMusic(mod);
|
||||||
#else
|
|
||||||
FMUSIC_FreeSong(mod);
|
|
||||||
#endif
|
|
||||||
mod = NULL;
|
mod = NULL;
|
||||||
}
|
}
|
||||||
if (stream) {
|
if (stream != NULL)
|
||||||
#ifndef USE_MIXER
|
|
||||||
FSOUND_Stream_Close(stream);
|
|
||||||
#endif
|
|
||||||
stream = NULL;
|
stream = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VAR(soundbufferlen, 128, 1024, 4096);
|
VAR(soundbufferlen, 128, 1024, 4096);
|
||||||
|
@ -62,7 +39,6 @@ void
|
||||||
initsound()
|
initsound()
|
||||||
{
|
{
|
||||||
memset(soundlocs, 0, sizeof(soundloc) * MAXCHAN);
|
memset(soundlocs, 0, sizeof(soundloc) * MAXCHAN);
|
||||||
#ifdef USE_MIXER
|
|
||||||
if (Mix_OpenAudio(SOUNDFREQ, MIX_DEFAULT_FORMAT, 2, soundbufferlen) <
|
if (Mix_OpenAudio(SOUNDFREQ, MIX_DEFAULT_FORMAT, 2, soundbufferlen) <
|
||||||
0) {
|
0) {
|
||||||
conoutf(@"sound init failed (SDL_mixer): %s",
|
conoutf(@"sound init failed (SDL_mixer): %s",
|
||||||
|
@ -70,14 +46,6 @@ initsound()
|
||||||
nosound = true;
|
nosound = true;
|
||||||
}
|
}
|
||||||
Mix_AllocateChannels(MAXCHAN);
|
Mix_AllocateChannels(MAXCHAN);
|
||||||
#else
|
|
||||||
if (FSOUND_GetVersion() < FMOD_VERSION)
|
|
||||||
fatal(@"old FMOD dll");
|
|
||||||
if (!FSOUND_Init(SOUNDFREQ, MAXCHAN, FSOUND_INIT_GLOBALFOCUS)) {
|
|
||||||
conoutf(@"sound init failed (FMOD): %d", FSOUND_GetError());
|
|
||||||
nosound = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -94,39 +62,16 @@ music(OFString *name)
|
||||||
OFIRI *IRI = [Cube.sharedInstance.gameDataIRI
|
OFIRI *IRI = [Cube.sharedInstance.gameDataIRI
|
||||||
IRIByAppendingPathComponent:path];
|
IRIByAppendingPathComponent:path];
|
||||||
|
|
||||||
#ifdef USE_MIXER
|
|
||||||
if ((mod = Mix_LoadMUS(
|
if ((mod = Mix_LoadMUS(
|
||||||
IRI.fileSystemRepresentation.UTF8String)) != NULL) {
|
IRI.fileSystemRepresentation.UTF8String)) != NULL) {
|
||||||
Mix_PlayMusic(mod, -1);
|
Mix_PlayMusic(mod, -1);
|
||||||
Mix_VolumeMusic((musicvol * MAXVOL) / 255);
|
Mix_VolumeMusic((musicvol * MAXVOL) / 255);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if ((mod = FMUSIC_LoadSong(
|
|
||||||
IRI.fileSystemRepresentation.UTF8String)) != NULL) {
|
|
||||||
FMUSIC_PlaySong(mod);
|
|
||||||
FMUSIC_SetMasterVolume(mod, musicvol);
|
|
||||||
} else if (stream = FSOUND_Stream_Open(
|
|
||||||
IRI.fileSystemRepresentation.UTF8String,
|
|
||||||
FSOUND_LOOP_NORMAL, 0, 0)) {
|
|
||||||
int chan = FSOUND_Stream_Play(FSOUND_FREE, stream);
|
|
||||||
if (chan >= 0) {
|
|
||||||
FSOUND_SetVolume(
|
|
||||||
chan, (musicvol * MAXVOL) / 255);
|
|
||||||
FSOUND_SetPaused(chan, false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
conoutf(@"could not play music: %@", IRI.string);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
COMMAND(music, ARG_1STR)
|
COMMAND(music, ARG_1STR)
|
||||||
|
|
||||||
#ifdef USE_MIXER
|
|
||||||
vector<Mix_Chunk *> samples;
|
vector<Mix_Chunk *> samples;
|
||||||
#else
|
|
||||||
vector<FSOUND_SAMPLE *> samples;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static OFMutableArray<OFString *> *snames;
|
static OFMutableArray<OFString *> *snames;
|
||||||
|
|
||||||
|
@ -158,11 +103,7 @@ cleansound()
|
||||||
if (nosound)
|
if (nosound)
|
||||||
return;
|
return;
|
||||||
stopsound();
|
stopsound();
|
||||||
#ifdef USE_MIXER
|
|
||||||
Mix_CloseAudio();
|
Mix_CloseAudio();
|
||||||
#else
|
|
||||||
FSOUND_Close();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VAR(stereo, 0, 1, 1);
|
VAR(stereo, 0, 1, 1);
|
||||||
|
@ -184,13 +125,8 @@ updatechanvol(int chan, const OFVector3D *loc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vol = (vol * MAXVOL) / 255;
|
vol = (vol * MAXVOL) / 255;
|
||||||
#ifdef USE_MIXER
|
|
||||||
Mix_Volume(chan, vol);
|
Mix_Volume(chan, vol);
|
||||||
Mix_SetPanning(chan, 255 - pan, pan);
|
Mix_SetPanning(chan, 255 - pan, pan);
|
||||||
#else
|
|
||||||
FSOUND_SetVolume(chan, vol);
|
|
||||||
FSOUND_SetPan(chan, pan);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -208,11 +144,7 @@ updatevol()
|
||||||
return;
|
return;
|
||||||
loopi(MAXCHAN) if (soundlocs[i].inuse)
|
loopi(MAXCHAN) if (soundlocs[i].inuse)
|
||||||
{
|
{
|
||||||
#ifdef USE_MIXER
|
|
||||||
if (Mix_Playing(i))
|
if (Mix_Playing(i))
|
||||||
#else
|
|
||||||
if (FSOUND_IsPlaying(i))
|
|
||||||
#endif
|
|
||||||
updatechanvol(i, &soundlocs[i].loc);
|
updatechanvol(i, &soundlocs[i].loc);
|
||||||
else
|
else
|
||||||
soundlocs[i].inuse = false;
|
soundlocs[i].inuse = false;
|
||||||
|
@ -254,14 +186,8 @@ playsound(int n, const OFVector3D *loc)
|
||||||
OFIRI *IRI = [Cube.sharedInstance.gameDataIRI
|
OFIRI *IRI = [Cube.sharedInstance.gameDataIRI
|
||||||
IRIByAppendingPathComponent:path];
|
IRIByAppendingPathComponent:path];
|
||||||
|
|
||||||
#ifdef USE_MIXER
|
|
||||||
samples[n] =
|
samples[n] =
|
||||||
Mix_LoadWAV(IRI.fileSystemRepresentation.UTF8String);
|
Mix_LoadWAV(IRI.fileSystemRepresentation.UTF8String);
|
||||||
#else
|
|
||||||
samples[n] = FSOUND_Sample_Load(n,
|
|
||||||
IRI.fileSystemRepresentation.UTF8String, FSOUND_LOOP_OFF, 0,
|
|
||||||
0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!samples[n]) {
|
if (!samples[n]) {
|
||||||
conoutf(@"failed to load sample: %@", IRI.string);
|
conoutf(@"failed to load sample: %@", IRI.string);
|
||||||
|
@ -269,19 +195,12 @@ playsound(int n, const OFVector3D *loc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_MIXER
|
|
||||||
int chan = Mix_PlayChannel(-1, samples[n], 0);
|
int chan = Mix_PlayChannel(-1, samples[n], 0);
|
||||||
#else
|
|
||||||
int chan = FSOUND_PlaySoundEx(FSOUND_FREE, samples[n], NULL, true);
|
|
||||||
#endif
|
|
||||||
if (chan < 0)
|
if (chan < 0)
|
||||||
return;
|
return;
|
||||||
if (loc)
|
if (loc)
|
||||||
newsoundloc(chan, loc);
|
newsoundloc(chan, loc);
|
||||||
updatechanvol(chan, loc);
|
updatechanvol(chan, loc);
|
||||||
#ifndef USE_MIXER
|
|
||||||
FSOUND_SetPaused(chan, false);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue