Skip to content

Commit

Permalink
Server: Sorting out compilation and linkage issues
Browse files Browse the repository at this point in the history
Missing symbols.
  • Loading branch information
skyjake committed Dec 22, 2012
1 parent bf04ee1 commit 8594170
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 26 deletions.
4 changes: 4 additions & 0 deletions doomsday/engine/include/audio/audiodriver.h
Expand Up @@ -23,6 +23,10 @@
#ifndef LIBDENG_AUDIO_DRIVER_H
#define LIBDENG_AUDIO_DRIVER_H

#ifdef __SERVER__
# error "audio" is not available in a SERVER build
#endif

#include <de/str.h>
#include "sys_audiod.h"
#include "sys_audiod_sfx.h"
Expand Down
14 changes: 14 additions & 0 deletions doomsday/engine/include/audio/s_cache.h
Expand Up @@ -29,12 +29,26 @@
#ifndef LIBDENG_SOUND_CACHE_H
#define LIBDENG_SOUND_CACHE_H

#include "sys_audiod_sfx.h"

#ifdef __cplusplus
extern "C" {
#endif

void Sfx_InitCache(void);

void Sfx_ShutdownCache(void);

sfxsample_t* Sfx_Cache(int id);

void Sfx_CacheHit(int id);

uint Sfx_GetSoundLength(int id);

void Sfx_GetCacheInfo(uint* cacheBytes, uint* sampleCount);

#ifdef __cplusplus
} // __cplusplus
#endif

#endif /* LIBDENG_SOUND_CACHE_H */
2 changes: 2 additions & 0 deletions doomsday/engine/include/audio/s_main.h
Expand Up @@ -53,6 +53,8 @@ extern "C" {
extern int showSoundInfo;
extern int soundMinDist, soundMaxDist;
extern int sfxVolume, musVolume;
extern int sfxBits, sfxRate;
extern byte sfxOneSoundPerEmitter;

void S_Register(void);
boolean S_Init(void);
Expand Down
6 changes: 4 additions & 2 deletions doomsday/engine/include/audio/s_sfx.h
Expand Up @@ -30,6 +30,10 @@
#ifndef __DOOMSDAY_SOUND_SFX_H__
#define __DOOMSDAY_SOUND_SFX_H__

#ifdef __SERVER__
# error "audio" is not available in a SERVER build
#endif

#include "sys_audiod.h"
#include "sys_audiod_sfx.h"
#include "de_play.h"
Expand Down Expand Up @@ -62,9 +66,7 @@ typedef struct sfxchannel_s {
extern boolean sfxAvail;
extern float sfxReverbStrength;
extern int sfxMaxCacheKB, sfxMaxCacheTics;
extern int sfxBits, sfxRate;
extern int sfx3D, sfx16Bit, sfxSampleRate;
extern byte sfxOneSoundPerEmitter;

boolean Sfx_Init(void);
void Sfx_Shutdown(void);
Expand Down
12 changes: 7 additions & 5 deletions doomsday/engine/include/de_audio.h
Expand Up @@ -29,14 +29,16 @@
#ifndef __DOOMSDAY_AUDIO__
#define __DOOMSDAY_AUDIO__

#include "audio/audiodriver.h"
#include "audio/audiodriver_music.h"
#ifdef __CLIENT__
# include "audio/audiodriver.h"
# include "audio/audiodriver_music.h"
# include "audio/s_sfx.h"
# include "audio/s_mus.h"
#endif
#include "audio/s_main.h"
#include "audio/s_cache.h"
#include "audio/s_environ.h"
#include "audio/s_sfx.h"
#include "audio/s_mus.h"
#include "audio/s_wav.h"
#include "audio/s_cache.h"
#include "audio/s_logic.h"

#endif
24 changes: 22 additions & 2 deletions doomsday/engine/src/audio/s_cache.c
Expand Up @@ -44,6 +44,11 @@

// MACROS ------------------------------------------------------------------

#ifdef __SERVER__
# define BEGIN_COP
# define END_COP
#endif

// The cached samples are stored in a hash. When a sample is purged, its
// data will stay in the hash (sample lengths needed by the Logical Sound
// Manager).
Expand Down Expand Up @@ -290,13 +295,17 @@ static void resample(void* dst, int dstBytesPer, int dstRate,
*/
static boolean sfxMustUpsampleToSfxRate(void)
{
#ifdef __CLIENT__
int anySampleRateAccepted = 0;

if(AudioDriver_SFX()->Getv)
{
AudioDriver_SFX()->Getv(SFXIP_ANY_SAMPLE_RATE_ACCEPTED, &anySampleRateAccepted);
}
return (anySampleRateAccepted? false : true);
#else
return false;
#endif
}

/**
Expand Down Expand Up @@ -327,11 +336,13 @@ sfxcache_t* Sfx_CacheInsert(int id, const void* data, unsigned int size,
* by sfxRate and sfxBits.
*/

#ifdef __CLIENT__
// The (up)resampling factor.
if(sfxMustUpsampleToSfxRate())
{
rsfactor = MAX_OF(1, sfxRate / rate);
}
#endif

/**
* If the sample is already in the right format, just make a copy of it.
Expand Down Expand Up @@ -365,9 +376,11 @@ sfxcache_t* Sfx_CacheInsert(int id, const void* data, unsigned int size,
if(cached.bytesPer * 8 == sfxBits && cached.rate == sfxRate)
return node; // This will do.

#ifdef __CLIENT__
// Stop all sounds using this sample (we are going to destroy the
// existing sample data).
Sfx_UnloadSoundID(node->sample.id);
#endif

// It's in the wrong format! We'll reuse this node.
M_Free(node->sample.data);
Expand Down Expand Up @@ -411,8 +424,10 @@ void Sfx_Uncache(sfxcache_t* node)

BEGIN_COP;

#ifdef __CLIENT__
// Reset all channels loaded with this sample.
Sfx_UnloadSoundID(node->sample.id);
#endif

hash = Sfx_CacheHash(node->sample.id);

Expand Down Expand Up @@ -459,8 +474,9 @@ void Sfx_PurgeCache(void)
sfxcache_t* it, *next, *lowest;
int i, lowHits = 0, nowTime = Timer_Ticks();

if(!sfxAvail)
return;
#ifdef __CLIENT__
if(!sfxAvail) return;
#endif

// Is it time for a purge?
if(nowTime - lastPurge < PURGE_TIME)
Expand Down Expand Up @@ -497,9 +513,11 @@ void Sfx_PurgeCache(void)
{
for(it = scHash[i].first; it; it = it->next)
{
#ifdef __CLIENT__
// If the sample is playing we won't remove it now.
if(Sfx_CountPlaying(it->sample.id))
continue;
#endif

// This sample could be removed, let's check the hits.
if(!lowest || it->hits < lowHits)
Expand Down Expand Up @@ -702,8 +720,10 @@ sfxsample_t* Sfx_Cache(int id)
sfxcache_t* node;
sfxinfo_t* info;

#ifdef __CLIENT__
if(!id || !sfxAvail)
return NULL;
#endif

// Are we so lucky that the sound is already cached?
if((node = Sfx_GetCached(id)) != NULL)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/src/audio/s_logic.c
Expand Up @@ -145,7 +145,7 @@ void Sfx_DestroyLogical(logicsound_t * node)
void Sfx_StartLogical(int id, mobj_t *origin, boolean isRepeating)
{
logicsound_t *node;
uint length = (isRepeating ? 1 : Sfx_GetSoundLength(id));
uint length = (isRepeating ? 1 : Sfx_GetSoundLength(id));

if(!length)
{
Expand Down

0 comments on commit 8594170

Please sign in to comment.