From b89f6120374929b2cc2f91cb1422dc48d992a355 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Wed, 12 Nov 2025 17:45:00 +0200
Subject: [PATCH 32/32] Audio: Let plugin.play() to know if track is music or
 sfx

See RM #1734

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/audio.c      | 21 +++++++++++----------
 client/audio.h      |  5 ++++-
 client/audio_none.c |  4 +++-
 client/audio_sdl.c  |  2 +-
 4 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/client/audio.c b/client/audio.c
index fefbab277f..ddf82076c9 100644
--- a/client/audio.c
+++ b/client/audio.c
@@ -68,7 +68,7 @@ static struct mfcb_data
 
 static int audio_play_tag(struct section_file *sfile,
                           const char *tag, bool repeat,
-                          int exclude, bool keep_old_style);
+                          int exclude, enum keep_style keep_old_style);
 
 static void audio_shutdown_atexit(void);
 
@@ -417,7 +417,7 @@ static void music_finished_callback(void)
 
   if (usage_enabled) {
     current_track = audio_play_tag(mfcb.sfile, mfcb.tag, TRUE, current_track,
-                                   FALSE);
+                                   KS_CHANGE);
   }
 }
 
@@ -427,7 +427,7 @@ static void music_finished_callback(void)
 **************************************************************************/
 static int audio_play_tag(struct section_file *sfile,
                           const char *tag, bool repeat, int exclude,
-                          bool keep_old_style)
+                          enum keep_style keep_old_style)
 {
   const char *soundfile;
   const char *fullpath = NULL;
@@ -479,7 +479,7 @@ static int audio_play_tag(struct section_file *sfile,
     }
 
     if (repeat) {
-      if (!keep_old_style) {
+      if (keep_old_style != KS_KEEP) {
         mfcb.sfile = sfile;
         mfcb.tag = tag;
       }
@@ -500,7 +500,8 @@ static int audio_play_tag(struct section_file *sfile,
     }
   }
 
-  if (!plugins[selected_plugin].play(tag, fullpath, repeat, cb)) {
+  if (!plugins[selected_plugin].play(tag, fullpath, repeat,
+                                     keep_old_style != KS_SND_EFFECT, cb)) {
     return -1;
   }
 
@@ -512,14 +513,14 @@ static int audio_play_tag(struct section_file *sfile,
 **************************************************************************/
 static bool audio_play_sound_tag(const char *tag, bool repeat)
 {
-  return (audio_play_tag(ss_tagfile, tag, repeat, -1, FALSE) >= 0);
+  return (audio_play_tag(ss_tagfile, tag, repeat, -1, KS_SND_EFFECT) >= 0);
 }
 
 /**********************************************************************//**
   Play tag from music set
 **************************************************************************/
 static int audio_play_music_tag(const char *tag, bool repeat,
-                                bool keep_old_style)
+                                enum keep_style keep_old_style)
 {
   return audio_play_tag(ms_tagfile, tag, repeat, -1, keep_old_style);
 }
@@ -554,7 +555,7 @@ void audio_play_sound(const char *const tag, const char *const alt_tag,
   music.
 **************************************************************************/
 static void real_audio_play_music(const char *const tag, char *const alt_tag,
-                                  bool keep_old_style)
+                                  enum keep_style keep_old_style)
 {
   char *pretty_alt_tag = alt_tag ? alt_tag : "(null)";
 
@@ -582,7 +583,7 @@ void audio_play_music(const char *const tag, char *const alt_tag,
 {
   current_usage = usage;
 
-  real_audio_play_music(tag, alt_tag, FALSE);
+  real_audio_play_music(tag, alt_tag, KS_CHANGE);
 }
 
 /**********************************************************************//**
@@ -599,7 +600,7 @@ void audio_play_track(const char *const tag, char *const alt_tag)
     audio_stop();
   }
 
-  real_audio_play_music(tag, alt_tag, TRUE);
+  real_audio_play_music(tag, alt_tag, KS_KEEP);
 }
 
 /**********************************************************************//**
diff --git a/client/audio.h b/client/audio.h
index 0852f5d314..2b668e1f50 100644
--- a/client/audio.h
+++ b/client/audio.h
@@ -38,13 +38,16 @@ struct audio_plugin {
   double (*get_volume) (void);
   void (*set_volume) (double volume);
   bool (*play) (const char *const tag, const char *const path, bool repeat,
-                audio_finished_callback cb);
+                bool music, audio_finished_callback cb);
   void (*pause)(void);
   void (*resume)(void);
 };
 
 enum music_usage { MU_MENU, MU_INGAME };
 
+/* Sound effects do not have style. */
+enum keep_style { KS_SND_EFFECT, KS_KEEP, KS_CHANGE };
+
 struct strvec;
 struct option;
 const struct strvec *get_soundplugin_list(const struct option *poption);
diff --git a/client/audio_none.c b/client/audio_none.c
index 86dd0fc75a..fc9acf6937 100644
--- a/client/audio_none.c
+++ b/client/audio_none.c
@@ -52,12 +52,14 @@ static void none_audio_wait(void)
   Play sound sample
 **************************************************************************/
 static bool none_audio_play(const char *const tag, const char *const fullpath,
-                            bool repeat, audio_finished_callback cb)
+                            bool repeat, bool music,
+                            audio_finished_callback cb)
 {
   if (strcmp(tag, "e_turn_bell") == 0) {
     sound_bell();
     return TRUE;
   }
+
   return FALSE;
 }
 
diff --git a/client/audio_sdl.c b/client/audio_sdl.c
index 2e3de97755..46ed556872 100644
--- a/client/audio_sdl.c
+++ b/client/audio_sdl.c
@@ -79,7 +79,7 @@ static double sdl_audio_get_volume(void)
   Play sound
 **************************************************************************/
 static bool sdl_audio_play(const char *const tag, const char *const fullpath,
-                           bool repeat, audio_finished_callback cb)
+                           bool repeat, bool music, audio_finished_callback cb)
 {
   int i, j;
   Mix_Chunk *wave = NULL;
-- 
2.51.0

