The Battle for Wesnoth  1.17.0-dev
Classes | Namespaces | Macros | Functions | Variables
lua_audio.cpp File Reference
#include "lua_audio.hpp"
#include "log.hpp"
#include "lua/lua.h"
#include "lua/lauxlib.h"
#include "scripting/lua_common.hpp"
#include "scripting/push_check.hpp"
#include "sound.hpp"
#include "sound_music_track.hpp"
#include "preferences/general.hpp"
#include "resources.hpp"
#include "soundsource.hpp"
#include <set>
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

◆ get_track()

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

◆ 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 sound::get_sound_volume(), lua_pushnumber(), luaL_checkstring, and preferences::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 f, lua_rawset(), lua_tonumber, luaL_argerror(), luaL_checkstring, sound::set_sound_volume(), and preferences::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(), and lua_pushinteger().

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 gui2::contains(), luaL_checkstring, 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, lua_isnil, luaL_checkstring, luaW_toconfig(), soundsource::manager::remove(), resources::soundsources, 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 a, b, get_track(), lua_pushboolean(), 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

◆ 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 luaL_checkstring, and 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, lua_gettop(), luaL_checkinteger(), 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 luaL_setmetatable(), and Source.

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 lua_music_track::lua_music_track(), luaL_setmetatable(), 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 lua_music_track::lua_music_track(), luaL_setmetatable(), and Track.

Variable Documentation

◆ log_audio

lg::log_domain log_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().