Crossfire Client, Trunk
cfsndserv.c File Reference
#include "client.h"
#include <SDL.h>
#include <SDL_mixer.h>
#include <glib-object.h>
#include "client-vala.h"
#include "sound.h"
+ Include dependency graph for cfsndserv.c:

Go to the source code of this file.

Data Structures

struct  sound_settings
 

Typedefs

typedef struct sound_settings sound_settings
 

Functions

void cf_play_music (const char *music_name)
 Play a music file. More...
 
void cf_play_music_cb ()
 
void cf_play_sound (gint8 x, gint8 y, guint8 dir, guint8 vol, guint8 type, char const sound[static 1], char const source[static 1])
 Play a sound effect using the SDL_mixer sound system. More...
 
void cf_snd_exit ()
 
int cf_snd_init ()
 Initialize sound server. More...
 
static bool find_music_path (const char *name, char *path, size_t len)
 
static int init_audio ()
 Initialize the sound subsystem. More...
 
static Mix_Chunk * load_chunk (char const name[static 1])
 
static bool music_is_different (char const music[static 1])
 
void set_music_volume ()
 

Variables

static GHashTable * chunk_cache
 
static const int fade_time_ms = 1000
 
static Mix_Music * music = NULL
 
static char * music_playing
 
static sound_settings settings = { 512, 4 }
 
static GHashTable * sounds
 

Typedef Documentation

◆ sound_settings

Function Documentation

◆ cf_play_music()

void cf_play_music ( const char *  music_name)

Play a music file.

Parameters
nameName of the song to play, without file paths or extensions.

Definition at line 213 of file cfsndserv.c.

References cf_play_music_cb(), fade_time_ms, LOG(), LOG_DEBUG, music_is_different(), and music_playing.

Referenced by hide_main_client(), and MusicCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cf_play_music_cb()

void cf_play_music_cb ( )

Definition at line 184 of file cfsndserv.c.

References fade_time_ms, find_music_path(), MAXSOCKBUF, music, music_playing, and set_music_volume().

Referenced by cf_play_music().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cf_play_sound()

void cf_play_sound ( gint8  x,
gint8  y,
guint8  dir,
guint8  vol,
guint8  type,
char const  sound[static 1],
char const  source[static 1] 
)

Play a sound effect using the SDL_mixer sound system.

Parameters
soundThe sound to play.
type0 for normal sounds, 1 for spell_sounds.
xOffset (assumed from player) to play sound used to determine value and left vs. right speaker balance.
yOffset (assumed from player) to play sound used to determine value and left vs. right speaker balance.

Definition at line 134 of file cfsndserv.c.

References load_chunk(), LOG(), LOG_DEBUG, LOG_WARNING, and sounds.

Referenced by Sound2Cmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cf_snd_exit()

void cf_snd_exit ( )

Definition at line 229 of file cfsndserv.c.

References chunk_cache, music, and sounds.

◆ cf_snd_init()

int cf_snd_init ( )

Initialize sound server.

Initialize resource paths, load sound definitions, and ready the sound subsystem.

Returns
Zero on success, anything else on failure.

Definition at line 83 of file cfsndserv.c.

References chunk_cache, init_audio(), and sounds.

Referenced by init_sounds().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find_music_path()

static bool find_music_path ( const char *  name,
char *  path,
size_t  len 
)
static

Definition at line 170 of file cfsndserv.c.

Referenced by cf_play_music_cb().

+ Here is the caller graph for this function:

◆ init_audio()

static int init_audio ( )
static

Initialize the sound subsystem.

Currently, this means calling SDL_Init() and Mix_OpenAudio().

Returns
Zero on success, anything else on failure.

Definition at line 49 of file cfsndserv.c.

References sound_settings::buflen, sound_settings::max_chunk, and settings.

Referenced by cf_snd_init().

+ Here is the caller graph for this function:

◆ load_chunk()

static Mix_Chunk* load_chunk ( char const  name[static 1])
static

Definition at line 106 of file cfsndserv.c.

References chunk_cache, and MAXSOCKBUF.

Referenced by cf_play_sound().

+ Here is the caller graph for this function:

◆ music_is_different()

static bool music_is_different ( char const  music[static 1])
static

Definition at line 161 of file cfsndserv.c.

References music, and music_playing.

Referenced by cf_play_music().

+ Here is the caller graph for this function:

◆ set_music_volume()

void set_music_volume ( )

Definition at line 180 of file cfsndserv.c.

References CONFIG_MUSIC_VOL, MIN, and use_config.

Referenced by cf_play_music_cb(), config_check(), and on_music_volume_changed().

+ Here is the caller graph for this function:

Variable Documentation

◆ chunk_cache

GHashTable* chunk_cache
static

Definition at line 39 of file cfsndserv.c.

Referenced by cf_snd_exit(), cf_snd_init(), and load_chunk().

◆ fade_time_ms

const int fade_time_ms = 1000
static

Definition at line 37 of file cfsndserv.c.

Referenced by cf_play_music(), and cf_play_music_cb().

◆ music

Mix_Music* music = NULL
static

Definition at line 33 of file cfsndserv.c.

Referenced by cf_play_music_cb(), cf_snd_exit(), and music_is_different().

◆ music_playing

char* music_playing
static

Definition at line 34 of file cfsndserv.c.

Referenced by cf_play_music(), cf_play_music_cb(), and music_is_different().

◆ settings

sound_settings settings = { 512, 4 }
static

Definition at line 36 of file cfsndserv.c.

Referenced by init_audio().

◆ sounds

GHashTable* sounds
static

Definition at line 40 of file cfsndserv.c.

Referenced by cf_play_sound(), cf_snd_exit(), and cf_snd_init().