sound.cpp File Reference

#include "global.hpp"
#include "events.hpp"
#include "filesystem.hpp"
#include "game_config.hpp"
#include "game_preferences.hpp"
#include "log.hpp"
#include "random.hpp"
#include "sound.hpp"
#include "SDL.h"
#include "SDL_mixer.h"
#include <cassert>
#include <iostream>
#include <map>
#include <list>

Include dependency graph for sound.cpp:

Go to the source code of this file.

Namespaces

namespace  sound

Classes

struct  sound::chunk_load_exception

Defines

#define LOG_AUDIO   LOG_STREAM(info, audio)
#define ERR_AUDIO   LOG_STREAM(err, audio)

Typedefs

typedef std::list
< sound_cache_chunk >
::iterator 
sound_cache_iterator

Functions

static void sound::play_sound_internal (const std::string &files, channel_group group, unsigned int repeats=0, unsigned int distance=0, int id=-1, int loop_ticks=0, int fadein_ticks=0)
static void increment_chunk_usage (Mix_Chunk *mcp)
static void decrement_chunk_usage (Mix_Chunk *mcp)
struct music_track current_track ("")
struct music_track last_track ("")
static bool track_ok (const std::string &name)
static const music_track & choose_track ()
static std::string pick_one (const std::string &files)
static void sound::channel_finished_hook (int channel)
bool sound::init_sound ()
void sound::close_sound ()
void sound::reset_sound ()
void sound::stop_music ()
void sound::stop_sound ()
void sound::stop_bell ()
void sound::stop_UI_sound ()
void sound::play_music_once (const std::string &file)
void sound::play_no_music ()
void sound::play_music ()
static void sound::play_new_music ()
void sound::play_music_repeatedly (const std::string &name)
void sound::play_music_config (const config &music)
void sound::commit_music_changes ()
void sound::write_music_play_list (config &snapshot)
void sound::reposition_sound (int id, unsigned int distance)
bool sound::is_sound_playing (int id)
void sound::stop_sound (int id)
void sound::play_sound_positioned (const std::string &files, int id, int repeats, unsigned int distance)
static Mix_Chunk * sound::load_chunk (const std::string &file, channel_group group)
void sound::play_sound (const std::string &files, channel_group group, unsigned int repeats)
void sound::play_bell (const std::string &files)
void sound::play_timer (const std::string &files, int loop_ticks, int fadein_ticks)
void sound::play_UI_sound (const std::string &files)
void sound::set_music_volume (int vol)
void sound::set_sound_volume (int vol)
void sound::set_bell_volume (int vol)
void sound::set_UI_volume (int vol)

Variables

std::vector< Mix_Chunk * > sound::channel_chunks
std::vector< int > sound::channel_ids
bool mix_ok = false
int music_start_time = 0
unsigned music_refresh = 0
unsigned music_refresh_rate = 20
bool want_new_music = false
int fadingout_time = 5000
bool no_fading = false
const size_t n_of_channels = 16
const size_t bell_channel = 0
const size_t timer_channel = 1
const size_t source_channels = n_of_channels - 8
const size_t source_channel_start = timer_channel + 1
const size_t source_channel_last = source_channel_start + source_channels - 1
const size_t UI_sound_channel = source_channel_last + 1
const size_t n_reserved_channels = UI_sound_channel + 1
unsigned max_cached_chunks = 256
std::map< Mix_Chunk *, int > chunk_usage
std::list< sound_cache_chunk > sound_cache
std::map< std::string,
Mix_Music * > 
music_cache
std::vector< std::string > played_before
std::vector< music_track > current_track_list


Define Documentation

#define ERR_AUDIO   LOG_STREAM(err, audio)

#define LOG_AUDIO   LOG_STREAM(info, audio)


Typedef Documentation

typedef std::list< sound_cache_chunk >::iterator sound_cache_iterator [static]

Definition at line 144 of file sound.cpp.


Function Documentation

static const music_track& choose_track (  )  [static]

Definition at line 257 of file sound.cpp.

References current_track_list, name, and track_ok().

Referenced by sound::commit_music_changes(), and sound::music_thinker::process().

struct music_track @187::current_track ( ""   )  [static, read]

static void decrement_chunk_usage ( Mix_Chunk *  mcp  )  [static]

Definition at line 87 of file sound.cpp.

References chunk_usage.

static void increment_chunk_usage ( Mix_Chunk *  mcp  )  [static]

Definition at line 83 of file sound.cpp.

References chunk_usage.

struct music_track @187::last_track ( ""   )  [static, read]

Referenced by sound::play_new_music().

static std::string pick_one ( const std::string &  files  )  [static]

Definition at line 275 of file sound.cpp.

References utils::split().

Referenced by sound::play_sound_internal().

static bool track_ok ( const std::string &  name  )  [static]

Definition at line 199 of file sound.cpp.

References current_track(), current_track_list, lexical_cast(), and LOG_AUDIO.

Referenced by choose_track().


Variable Documentation

const size_t bell_channel = 0 [static]

Definition at line 61 of file sound.cpp.

Referenced by sound::init_sound(), sound::set_bell_volume(), and sound::set_sound_volume().

std::map< Mix_Chunk*, int > chunk_usage [static]

Definition at line 79 of file sound.cpp.

Referenced by decrement_chunk_usage(), and increment_chunk_usage().

std::vector<music_track> current_track_list [static]

Mix_Chunk* data_

Definition at line 140 of file sound.cpp.

int fadingout_time = 5000 [static]

Definition at line 54 of file sound.cpp.

Referenced by sound::play_music(), and sound::music_thinker::process().

std::string file

Definition at line 113 of file sound.cpp.

Referenced by ai::choose_move().

unsigned max_cached_chunks = 256 [static]

Definition at line 76 of file sound.cpp.

Referenced by sound::load_chunk().

bool mix_ok = false [static]

unsigned int ms_after

Definition at line 156 of file sound.cpp.

unsigned int ms_before

Definition at line 156 of file sound.cpp.

std::map<std::string,Mix_Music*> music_cache [static]

Definition at line 145 of file sound.cpp.

unsigned music_refresh = 0 [static]

Definition at line 51 of file sound.cpp.

Referenced by sound::music_thinker::process().

unsigned music_refresh_rate = 20 [static]

Definition at line 52 of file sound.cpp.

Referenced by sound::music_thinker::process().

int music_start_time = 0 [static]

const size_t n_of_channels = 16 [static]

Definition at line 58 of file sound.cpp.

Referenced by sound::init_sound(), and sound::set_sound_volume().

const size_t n_reserved_channels = UI_sound_channel + 1 [static]

Definition at line 69 of file sound.cpp.

Referenced by sound::init_sound().

std::string name

Definition at line 155 of file sound.cpp.

bool no_fading = false [static]

bool once

Definition at line 157 of file sound.cpp.

std::vector<std::string> played_before [static]

Definition at line 160 of file sound.cpp.

std::list< sound_cache_chunk > sound_cache [static]

Definition at line 143 of file sound.cpp.

Definition at line 67 of file sound.cpp.

Referenced by sound::init_sound().

const size_t source_channel_start = timer_channel + 1 [static]

Definition at line 66 of file sound.cpp.

Referenced by sound::init_sound().

const size_t source_channels = n_of_channels - 8 [static]

Definition at line 65 of file sound.cpp.

const size_t timer_channel = 1 [static]

Definition at line 62 of file sound.cpp.

Referenced by sound::init_sound(), sound::set_bell_volume(), and sound::set_sound_volume().

const size_t UI_sound_channel = source_channel_last + 1 [static]

Definition at line 68 of file sound.cpp.

Referenced by sound::init_sound(), sound::set_sound_volume(), and sound::set_UI_volume().

bool want_new_music = false [static]


Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs