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

Go to the source code of this file.

Namespaces

 sound
 Audio output for sound and music.
 

Macros

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

Functions

static void increment_chunk_usage (Mix_Chunk *mcp)
 
static void decrement_chunk_usage (Mix_Chunk *mcp)
 
void sound::flush_cache ()
 
utils::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)
 
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, const std::chrono::milliseconds &loop_ticks, const std::chrono::milliseconds &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)
 

Variables

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

◆ DBG_AUDIO

#define DBG_AUDIO   LOG_STREAM(debug, log_audio)

Definition at line 33 of file sound.cpp.

◆ ERR_AUDIO

#define ERR_AUDIO   LOG_STREAM(err, log_audio)

Definition at line 35 of file sound.cpp.

◆ LOG_AUDIO

#define LOG_AUDIO   LOG_STREAM(info, log_audio)

Definition at line 34 of file sound.cpp.

Function Documentation

◆ choose_track()

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

◆ decrement_chunk_usage()

static void decrement_chunk_usage ( Mix_Chunk *  mcp)
static

Definition at line 91 of file sound.cpp.

◆ increment_chunk_usage()

static void increment_chunk_usage ( Mix_Chunk *  mcp)
static

Definition at line 86 of file sound.cpp.

◆ pick_one()

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

◆ track_ok()

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

Definition at line 269 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"  )
static