The Battle for Wesnoth  1.19.0-dev
Classes | Namespaces | Macros | Functions | Variables
sound.cpp File Reference
#include "sound.hpp"
#include "filesystem.hpp"
#include "log.hpp"
#include "preferences/game.hpp"
#include "random.hpp"
#include "serialization/string_utils.hpp"
#include "sound_music_track.hpp"
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <list>
#include <string>
Include dependency graph for sound.cpp:

Go to the source code of this file.


struct  sound::chunk_load_exception


 Audio output for sound and music.


#define DBG_AUDIO   LOG_STREAM(debug, log_audio)
#define LOG_AUDIO   LOG_STREAM(info, log_audio)
#define ERR_AUDIO   LOG_STREAM(err, log_audio)


static void increment_chunk_usage (Mix_Chunk *mcp)
static void decrement_chunk_usage (Mix_Chunk *mcp)
void sound::flush_cache ()
std::optional< unsigned int > sound::get_current_track_index ()
std::shared_ptr< music_track > sound::get_current_track ()
std::shared_ptr< music_track > sound::get_previous_music_track ()
void sound::set_previous_track (std::shared_ptr< music_track > track)
unsigned int sound::get_num_tracks ()
std::shared_ptr< music_track > sound::get_track (unsigned int i)
void sound::set_track (unsigned int i, const std::shared_ptr< music_track > &to)
void sound::remove_track (unsigned int i)
static bool track_ok (const std::string &id)
static std::shared_ptr< sound::music_trackchoose_track ()
static std::string pick_one (const std::string &files)
static void sound::channel_finished_hook (int channel)
std::string sound::current_driver ()
std::vector< std::string > sound::enumerate_drivers ()
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::empty_playlist ()
void sound::play_music ()
void sound::play_track (unsigned int i)
static void sound::play_new_music ()
void sound::play_music_repeatedly (const std::string &id)
void sound::play_music_config (const config &music_node, bool allow_interrupt_current_track, int i)
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)
static Mix_Chunk * sound::load_chunk (const std::string &file, channel_group group)
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)
void sound::play_sound (const std::string &files, channel_group group, unsigned int repeats)
void sound::play_sound_positioned (const std::string &files, int id, int repeats, unsigned int distance)
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)
int sound::get_music_volume ()
void sound::set_music_volume (int vol)
int sound::get_sound_volume ()
void sound::set_sound_volume (int vol)
void sound::set_bell_volume (int vol)
void sound::set_UI_volume (int vol)


static lg::log_domain log_audio ("audio")
static std::vector< Mix_Chunk * > sound::channel_chunks
static std::vector< int > sound::channel_ids

Macro Definition Documentation


#define DBG_AUDIO   LOG_STREAM(debug, log_audio)

Definition at line 31 of file sound.cpp.


#define ERR_AUDIO   LOG_STREAM(err, log_audio)

Definition at line 33 of file sound.cpp.


#define LOG_AUDIO   LOG_STREAM(info, log_audio)

Definition at line 32 of file sound.cpp.

Function Documentation

◆ choose_track()

static std::shared_ptr<sound::music_track> choose_track ( )

◆ decrement_chunk_usage()

static void decrement_chunk_usage ( Mix_Chunk *  mcp)

Definition at line 88 of file sound.cpp.

◆ increment_chunk_usage()

static void increment_chunk_usage ( Mix_Chunk *  mcp)

Definition at line 83 of file sound.cpp.

◆ pick_one()

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

◆ track_ok()

static bool track_ok ( const std::string &  id)

Definition at line 266 of file sound.cpp.

References i, id, and LOG_AUDIO.

Referenced by choose_track().

Variable Documentation

◆ log_audio

lg::log_domain log_audio("audio") ( "audio"  )