From 6cb8736fc1c716aeeeece577435c459755a61a6d Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Mon, 8 Jul 2024 18:13:33 +0300 Subject: [PATCH] audio.c: get_audio_args() --- src/audio.c | 9 +++++++++ src/audio.h | 6 +++--- src/game/scenes/ingame.c | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/audio.c b/src/audio.c index b85e1ce..20a1720 100644 --- a/src/audio.c +++ b/src/audio.c @@ -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) { return (t_play_audio_args){ .repeat = false, diff --git a/src/audio.h b/src/audio.h index 5812b2e..10bd4d9 100644 --- a/src/audio.h +++ b/src/audio.h @@ -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 set_audio_args(const char *channel, t_play_audio_args args); - -t_play_audio_args get_audio_args(const char *channel); +/* 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_default_audio_args(void); diff --git a/src/game/scenes/ingame.c b/src/game/scenes/ingame.c index 00cb944..1bea67b 100644 --- a/src/game/scenes/ingame.c +++ b/src/game/scenes/ingame.c @@ -10,6 +10,8 @@ static void ingame_tick(struct state *state) { world_drawdef(scn->world); player_calc(scn->player); + + get_audio_args("soundtrack")->volume -= 0.01f; }