audio.c: get_audio_args()

This commit is contained in:
veclavtalica 2024-07-08 18:13:33 +03:00
parent e6ba50ab82
commit 6cb8736fc1
3 changed files with 14 additions and 3 deletions

View File

@ -190,6 +190,15 @@ void play_audio_ex(const char *path, const char *channel, t_play_audio_args args
} }
t_play_audio_args *get_audio_args(const char *channel) {
struct audio_channel_pair *pair = shgetp_null(ctx.audio_channels, channel);
if (!pair)
return NULL;
return &pair->value.args;
}
t_play_audio_args get_default_audio_args(void) { t_play_audio_args get_default_audio_args(void) {
return (t_play_audio_args){ return (t_play_audio_args){
.repeat = false, .repeat = false,

View File

@ -27,9 +27,9 @@ void play_audio(const char *path, const char *channel);
void play_audio_ex(const char *path, const char *channel, t_play_audio_args args); void play_audio_ex(const char *path, const char *channel, t_play_audio_args args);
void set_audio_args(const char *channel, t_play_audio_args args); /* could be used for modifying args */
/* warn: is only valid if no other calls to audio are made */
t_play_audio_args get_audio_args(const char *channel); t_play_audio_args *get_audio_args(const char *channel);
t_play_audio_args get_default_audio_args(void); t_play_audio_args get_default_audio_args(void);

View File

@ -10,6 +10,8 @@ static void ingame_tick(struct state *state) {
world_drawdef(scn->world); world_drawdef(scn->world);
player_calc(scn->player); player_calc(scn->player);
get_audio_args("soundtrack")->volume -= 0.01f;
} }