The Battle for Wesnoth  1.19.7+dev
Classes | Namespaces | Macros | Functions | Variables
lua_audio.cpp File Reference
#include "lua_audio.hpp"
#include "log.hpp"
#include "preferences/preferences.hpp"
#include "resources.hpp"
#include "scripting/lua_common.hpp"
#include "scripting/push_check.hpp"
#include "sound.hpp"
#include "sound_music_track.hpp"
#include "soundsource.hpp"
#include <set>
#include <utility>
Include dependency graph for lua_audio.cpp:

Go to the source code of this file.

Classes

class  lua_music_track
 
class  lua_sound_source
 

Namespaces

 lua_audio
 

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 lua_music_trackpush_track (lua_State *L, int i)
 
static lua_music_trackpush_track (lua_State *L, std::shared_ptr< sound::music_track > new_track)
 
static lua_music_trackget_track (lua_State *L, int i)
 
static lua_sound_sourcepush_source (lua_State *L, const soundsource::sourcespec &spec)
 
static lua_sound_sourceget_source (lua_State *L, int i)
 
static int impl_track_collect (lua_State *L)
 Destroys a lua_music_track object before it is collected (__gc metamethod). More...
 
static int impl_music_get (lua_State *L)
 
static int impl_music_set (lua_State *L)
 
static int impl_music_len (lua_State *L)
 
static int intf_music_play (lua_State *L)
 
static int intf_music_next (lua_State *)
 
static int intf_music_add (lua_State *L)
 
static int intf_music_clear (lua_State *)
 
static int intf_music_remove (lua_State *L)
 
static int intf_music_commit (lua_State *)
 
static int impl_track_get (lua_State *L)
 
static int impl_track_set (lua_State *L)
 
static int impl_track_eq (lua_State *L)
 
static int impl_sndsrc_get (lua_State *L)
 Get an existing sound source Key: The sound source ID. More...
 
static int impl_sndsrc_set (lua_State *L)
 Adds or removes a sound source by its ID Key: sound source ID Value: Table containing keyword arguments, existing sound source userdata, or nil to delete. More...
 
static int impl_source_collect (lua_State *L)
 
static int impl_source_get (lua_State *L)
 
static int impl_source_set (lua_State *L)
 
static int impl_source_eq (lua_State *L)
 
static int impl_audio_get (lua_State *L)
 Gets the current sound volume. More...
 
static int impl_audio_set (lua_State *L)
 Sets the current sound volume. More...
 
std::string lua_audio::register_table (lua_State *L)
 

Variables

static lg::log_domain log_audio ("audio")
 
static const char * Track = "music track"
 
static const char * Source = "sound source"
 

Macro Definition Documentation

◆ DBG_AUDIO

#define DBG_AUDIO   LOG_STREAM(debug, log_audio)

Definition at line 29 of file lua_audio.cpp.

◆ ERR_AUDIO

#define ERR_AUDIO   LOG_STREAM(err, log_audio)

Definition at line 31 of file lua_audio.cpp.

◆ LOG_AUDIO

#define LOG_AUDIO   LOG_STREAM(info, log_audio)

Definition at line 30 of file lua_audio.cpp.

Function Documentation

◆ get_source()

static lua_sound_source& get_source ( lua_State *  L,
int  i 
)
static

Definition at line 99 of file lua_audio.cpp.

References i, and Source.

Referenced by impl_sndsrc_set(), impl_source_collect(), impl_source_eq(), impl_source_get(), and impl_source_set().

◆ get_track()

static lua_music_track* get_track ( lua_State *  L,
int  i 
)
static

Definition at line 70 of file lua_audio.cpp.

References i, and Track.

Referenced by impl_music_set(), impl_track_collect(), impl_track_eq(), impl_track_get(), and impl_track_set().

◆ impl_audio_get()

static int impl_audio_get ( lua_State *  L)
static

Gets the current sound volume.

  • Return: Current volume

Definition at line 478 of file lua_audio.cpp.

References prefs::get(), sound::get_sound_volume(), and prefs::sound_volume().

Referenced by lua_audio::register_table().

◆ impl_audio_set()

static int impl_audio_set ( lua_State *  L)
static

Sets the current sound volume.

  • Arg: New volume to set

Definition at line 491 of file lua_audio.cpp.

References prefs::get(), sound::set_sound_volume(), and prefs::sound_volume().

Referenced by lua_audio::register_table().

◆ impl_music_get()

static int impl_music_get ( lua_State *  L)
static

◆ impl_music_len()

static int impl_music_len ( lua_State *  L)
static

Definition at line 193 of file lua_audio.cpp.

References sound::get_num_tracks().

Referenced by lua_audio::register_table().

◆ impl_music_set()

static int impl_music_set ( lua_State *  L)
static

◆ impl_sndsrc_get()

static int impl_sndsrc_get ( lua_State *  L)
static

Get an existing sound source Key: The sound source ID.

Definition at line 342 of file lua_audio.cpp.

References utils::contains(), cursor::get(), push_source(), and resources::soundsources.

Referenced by lua_audio::register_table().

◆ impl_sndsrc_set()

static int impl_sndsrc_set ( lua_State *  L)
static

Adds or removes a sound source by its ID Key: sound source ID Value: Table containing keyword arguments, existing sound source userdata, or nil to delete.

Definition at line 359 of file lua_audio.cpp.

References soundsource::manager::add(), get_source(), id, luaW_toconfig(), soundsource::manager::remove(), resources::soundsources, src, and soundsource::manager::update().

Referenced by lua_audio::register_table().

◆ impl_source_collect()

static int impl_source_collect ( lua_State *  L)
static

Definition at line 379 of file lua_audio.cpp.

References get_source().

Referenced by lua_audio::register_table().

◆ impl_source_eq()

static int impl_source_eq ( lua_State *  L)
static

◆ impl_source_get()

static int impl_source_get ( lua_State *  L)
static

◆ impl_source_set()

static int impl_source_set ( lua_State *  L)
static

◆ impl_track_collect()

static int impl_track_collect ( lua_State *  L)
static

Destroys a lua_music_track object before it is collected (__gc metamethod).

Definition at line 106 of file lua_audio.cpp.

References get_track().

Referenced by lua_audio::register_table().

◆ impl_track_eq()

static int impl_track_eq ( lua_State *  L)
static

Definition at line 315 of file lua_audio.cpp.

References b, get_track(), and lua_music_track::valid().

Referenced by lua_audio::register_table().

◆ impl_track_get()

static int impl_track_get ( lua_State *  L)
static

◆ impl_track_set()

static int impl_track_set ( lua_State *  L)
static

◆ intf_music_add()

static int intf_music_add ( lua_State *  L)
static

Definition at line 211 of file lua_audio.cpp.

References i, utf8::index(), luaW_toboolean(), and sound::play_music_config().

Referenced by lua_audio::register_table().

◆ intf_music_clear()

static int intf_music_clear ( lua_State *  )
static

Definition at line 247 of file lua_audio.cpp.

References sound::empty_playlist().

Referenced by lua_audio::register_table().

◆ intf_music_commit()

static int intf_music_commit ( lua_State *  )
static

Definition at line 264 of file lua_audio.cpp.

References sound::commit_music_changes().

Referenced by lua_audio::register_table().

◆ intf_music_next()

static int intf_music_next ( lua_State *  )
static

Definition at line 203 of file lua_audio.cpp.

References sound::get_num_tracks(), n, and sound::play_track().

Referenced by lua_audio::register_table().

◆ intf_music_play()

static int intf_music_play ( lua_State *  L)
static

Definition at line 198 of file lua_audio.cpp.

References sound::play_music_once().

Referenced by lua_audio::register_table().

◆ intf_music_remove()

static int intf_music_remove ( lua_State *  L)
static

Definition at line 252 of file lua_audio.cpp.

References i, and sound::remove_track().

Referenced by lua_audio::register_table().

◆ push_source()

static lua_sound_source& push_source ( lua_State *  L,
const soundsource::sourcespec spec 
)
static

Definition at line 93 of file lua_audio.cpp.

References Source, and src.

Referenced by impl_sndsrc_get().

◆ push_track() [1/2]

static lua_music_track* push_track ( lua_State *  L,
int  i 
)
static

Definition at line 58 of file lua_audio.cpp.

References i, and Track.

Referenced by impl_music_get().

◆ push_track() [2/2]

static lua_music_track* push_track ( lua_State *  L,
std::shared_ptr< sound::music_track new_track 
)
static

Definition at line 64 of file lua_audio.cpp.

References Track.

Variable Documentation

◆ log_audio

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

◆ Source

const char* Source = "sound source"
static

Definition at line 34 of file lua_audio.cpp.

Referenced by get_source(), push_source(), and lua_audio::register_table().

◆ Track

const char* Track = "music track"
static

Definition at line 33 of file lua_audio.cpp.

Referenced by get_track(), push_track(), and lua_audio::register_table().