From 5fc30c5393fab3c943da236e31eef5793ab9ca22 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Mon, 24 Aug 2026 03:44:50 +0300
Subject: [PATCH 55/55] audio*.[ch]: Replace NULL with nullptr

See RM #2163

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/audio.c     | 66 +++++++++++++++++++++++-----------------------
 client/audio.h     |  4 +--
 client/audio_sdl.c | 28 ++++++++++----------
 3 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/client/audio.c b/client/audio.c
index 198fee470b..bf2390ab6c 100644
--- a/client/audio.c
+++ b/client/audio.c
@@ -41,16 +41,16 @@
 
 #include "audio.h"
 
-#define MAX_NUM_PLUGINS		2
-#define SNDSPEC_SUFFIX		".soundspec"
+#define MAX_NUM_PLUGINS         2
+#define SNDSPEC_SUFFIX          ".soundspec"
 #define MUSICSPEC_SUFFIX        ".musicspec"
 
 #define SOUNDSPEC_CAPSTR "+Freeciv-soundset-3.4-Devel-2026.Aug.05"
 #define MUSICSPEC_CAPSTR "+Freeciv-3.2-musicspec"
 
 /* Keep them open throughout */
-static struct section_file *ss_tagfile = NULL;
-static struct section_file *ms_tagfile = NULL;
+static struct section_file *ss_tagfile = nullptr;
+static struct section_file *ms_tagfile = nullptr;
 
 static struct audio_plugin plugins[MAX_NUM_PLUGINS];
 static int num_plugins_used = 0;
@@ -79,9 +79,9 @@ static void audio_shutdown_atexit(void);
 **************************************************************************/
 const struct strvec *get_soundplugin_list(const struct option *poption)
 {
-  static struct strvec *plugin_list = NULL;
+  static struct strvec *plugin_list = nullptr;
 
-  if (NULL == plugin_list) {
+  if (plugin_list == nullptr) {
     int i;
 
     plugin_list = strvec_new();
@@ -98,12 +98,12 @@ const struct strvec *get_soundplugin_list(const struct option *poption)
   Returns a static string vector of audiosets of given type available
   on the system by searching all data directories for files matching
   suffix.
-  The list is NULL-terminated.
+  The list is nullptr-terminated.
 **************************************************************************/
 static const struct strvec *get_audio_speclist(const char *suffix,
                                                struct strvec **audio_list)
 {
-  if (NULL == *audio_list) {
+  if (*audio_list == nullptr) {
     *audio_list = fileinfolist(get_data_dirs(), suffix);
   }
 
@@ -115,7 +115,7 @@ static const struct strvec *get_audio_speclist(const char *suffix,
 **************************************************************************/
 const struct strvec *get_soundset_list(const struct option *poption)
 {
-  static struct strvec *sound_list = NULL;
+  static struct strvec *sound_list = nullptr;
 
   return get_audio_speclist(SNDSPEC_SUFFIX, &sound_list);
 }
@@ -125,7 +125,7 @@ const struct strvec *get_soundset_list(const struct option *poption)
 **************************************************************************/
 const struct strvec *get_musicset_list(const struct option *poption)
 {
-  static struct strvec *music_list = NULL;
+  static struct strvec *music_list = nullptr;
 
   return get_audio_speclist(MUSICSPEC_SUFFIX, &music_list);
 }
@@ -198,7 +198,7 @@ void audio_init(void)
 }
 
 /**********************************************************************//**
-  Returns the filename for the given audio set. Returns NULL if
+  Returns the filename for the given audio set. Returns nullptr if
   set couldn't be found. Caller has to free the return value.
 **************************************************************************/
 static const char *audiospec_fullname(const char *audioset_name,
@@ -219,8 +219,8 @@ static const char *audiospec_fullname(const char *audioset_name,
   }
 
   if (strcmp(audioset_name, audioset_default) == 0) {
-    /* avoid endless recursion */
-    return NULL;
+    /* Avoid endless recursion */
+    return nullptr;
   }
 
   /* Marked for translation, as user may see this when
@@ -244,7 +244,7 @@ static bool check_audiofile_capstr(struct section_file *sfile,
   const char *file_capstr;
 
   file_capstr = secfile_lookup_str(sfile, "%s", opt_path);
-  if (NULL == file_capstr) {
+  if (file_capstr == nullptr) {
     log_fatal("Audio spec-file \"%s\" doesn't have capability string.",
               filename);
     exit(EXIT_FAILURE);
@@ -283,9 +283,9 @@ void audio_real_init(const char *const soundset_name,
   if (strcmp(preferred_plugin_name, "none") == 0) {
     /* We explicitly choose none plugin, silently skip the code below */
     log_verbose("Proceeding with sound support disabled.");
-    ss_tagfile = NULL;
+    ss_tagfile = nullptr;
     musicspec_close(ms_tagfile);
-    ms_tagfile = NULL;
+    ms_tagfile = nullptr;
 
     return;
   }
@@ -295,9 +295,9 @@ void audio_real_init(const char *const soundset_name,
     log_normal(_("Proceeding with sound support disabled."));
     log_normal(_("For sound support, install SDL2_mixer"));
     log_normal("https://github.com/libsdl-org/SDL_mixer");
-    ss_tagfile = NULL;
+    ss_tagfile = nullptr;
     musicspec_close(ms_tagfile);
-    ms_tagfile = NULL;
+    ms_tagfile = nullptr;
 
     return;
   }
@@ -320,9 +320,9 @@ void audio_real_init(const char *const soundset_name,
     log_normal(_("Get sound sets from <%s>."),
                "https://www.freeciv.org/wiki/Sounds");
     log_normal(_("Proceeding with sound support disabled."));
-    ss_tagfile = NULL;
+    ss_tagfile = nullptr;
     musicspec_close(ms_tagfile);
-    ms_tagfile = NULL;
+    ms_tagfile = nullptr;
 
     return;
   }
@@ -430,8 +430,8 @@ static int audio_play_tag(struct section_file *sfile,
                           enum keep_style keep_old_style)
 {
   const char *soundfile;
-  const char *fullpath = NULL;
-  audio_finished_callback cb = NULL;
+  const char *fullpath = nullptr;
+  audio_finished_callback cb = nullptr;
   int ret = 0;
 
   if (!tag || strcmp(tag, "-") == 0) {
@@ -440,7 +440,7 @@ static int audio_play_tag(struct section_file *sfile,
 
   if (sfile) {
     soundfile = secfile_lookup_str(sfile, "files.%s", tag);
-    if (soundfile == NULL) {
+    if (soundfile == nullptr) {
       const char *files[MAX_ALT_AUDIO_FILES];
       int excluded = -1;
       int i;
@@ -450,13 +450,13 @@ static int audio_play_tag(struct section_file *sfile,
       for (i = 0; i < MAX_ALT_AUDIO_FILES; i++) {
         const char *ftmp = secfile_lookup_str(sfile, "files.%s_%d", tag, i);
 
-        if (ftmp == NULL) {
+        if (ftmp == nullptr) {
           if (excluded != -1 && j == 0) {
             /* Cannot exclude the only track */
             excluded = -1;
             j++;
           }
-          files[j] = NULL;
+          files[j] = nullptr;
           break;
         }
         files[j] = ftmp;
@@ -490,7 +490,7 @@ static int audio_play_tag(struct section_file *sfile,
       cb = music_finished_callback;
     }
 
-    if (NULL == soundfile) {
+    if (soundfile == nullptr) {
       log_verbose("No sound file for tag %s", tag);
     } else {
       fullpath = fileinfoname(get_data_dirs(), soundfile);
@@ -535,7 +535,7 @@ void audio_play_sound(const char *const tag, const char *const alt_tag,
   const char *pretty_alt2_tag = alt_tag2 ? alt_tag2 : "(null)";
 
   if (gui_options.sound_enable_effects) {
-    fc_assert_ret(tag != NULL);
+    fc_assert_ret(tag != nullptr);
 
     log_debug("audio_play_sound('%s', '%s', '%s')",
               tag, pretty_alt_tag, pretty_alt2_tag);
@@ -559,7 +559,7 @@ static void real_audio_play_music(const char *const tag, char *const alt_tag,
 {
   char *pretty_alt_tag = alt_tag ? alt_tag : "(null)";
 
-  fc_assert_ret(tag != NULL);
+  fc_assert_ret(tag != nullptr);
 
   log_debug("audio_play_music('%s', '%s')", tag, pretty_alt_tag);
 
@@ -663,7 +663,7 @@ void audio_shutdown(bool play_quit_tag)
   audio_stop_usage();
 
   if (play_quit_tag) {
-    audio_play_sound("e_client_quit", NULL, NULL);
+    audio_play_sound("e_client_quit", nullptr, nullptr);
   }
 
   if (plugins[selected_plugin].initialized) {
@@ -671,13 +671,13 @@ void audio_shutdown(bool play_quit_tag)
     plugins[selected_plugin].shutdown(&(plugins[selected_plugin]));
   }
 
-  if (NULL != ss_tagfile) {
+  if (ss_tagfile != nullptr) {
     secfile_destroy(ss_tagfile);
-    ss_tagfile = NULL;
+    ss_tagfile = nullptr;
   }
-  if (NULL != ms_tagfile) {
+  if (ms_tagfile != nullptr) {
     musicspec_close(ms_tagfile);
-    ms_tagfile = NULL;
+    ms_tagfile = nullptr;
   }
 }
 
diff --git a/client/audio.h b/client/audio.h
index 3bebe14c9c..989ff2bd25 100644
--- a/client/audio.h
+++ b/client/audio.h
@@ -20,8 +20,8 @@ extern "C" {
 /* utility */
 #include "support.h"            /* bool type */
 
-#define MAX_AUDIO_NAME_LEN		20
-#define MAX_AUDIO_DESCR_LEN		200
+#define MAX_AUDIO_NAME_LEN              20
+#define MAX_AUDIO_DESCR_LEN             200
 
 #define MAX_ALT_AUDIO_FILES             25
 
diff --git a/client/audio_sdl.c b/client/audio_sdl.c
index 31fa9ff885..7b739f2b67 100644
--- a/client/audio_sdl.c
+++ b/client/audio_sdl.c
@@ -59,12 +59,12 @@ const size_t buf_size = 1024;
 
 #ifdef AUDIO_SDL3
 #define MIX_CHANNELS 8
-static MIX_Audio *mus = NULL;
-static MIX_Mixer *mixer = NULL;
+static MIX_Audio *mus = nullptr;
+static MIX_Mixer *mixer = nullptr;
 static MIX_Track *tracks[MIX_CHANNELS];
 static SDL_PropertiesID forever_loop;
 #else  /* AUDIO_SDL3 */
-static Mix_Music *mus = NULL;
+static Mix_Music *mus = nullptr;
 #endif /* AUDIO_SDL3 */
 
 static struct sample samples[MIX_CHANNELS];
@@ -115,12 +115,12 @@ static bool sdl_audio_play(const char *const tag, const char *const fullpath,
 {
   int j;
 #ifdef AUDIO_SDL3
-  MIX_Audio *wave = NULL;
+  MIX_Audio *wave = nullptr;
   int channel;
   static int channel_turn = 1; /* Channel 0 is music */
 #else  /* AUDIO_SDL3 */
   int i;
-  Mix_Chunk *wave = NULL;
+  Mix_Chunk *wave = nullptr;
 #endif /* AUDIO_SDL3 */
 
   if (!fullpath) {
@@ -154,12 +154,12 @@ static bool sdl_audio_play(const char *const tag, const char *const fullpath,
 #else  /* AUDIO_SDL3 */
     mus = Mix_LoadMUS(fullpath);
 #endif /* AUDIO_SDL3 */
-    if (mus == NULL) {
+    if (mus == nullptr) {
       log_error("Can't open file \"%s\": %s",
                 fullpath, SDL_GetError());
     }
 
-    if (cb == NULL) {
+    if (cb == nullptr) {
 #ifdef AUDIO_SDL3
       MIX_SetTrackAudio(tracks[channel], mus);
       MIX_PlayTrack(tracks[channel], forever_loop);
@@ -209,7 +209,7 @@ static bool sdl_audio_play(const char *const tag, const char *const fullpath,
 #else  /* AUDIO_SDL3 */
     wave = Mix_LoadWAV(fullpath);
 #endif /* AUDIO_SDL3 */
-    if (wave == NULL) {
+    if (wave == nullptr) {
       log_error("Can't open file \"%s\"", fullpath);
     }
 
@@ -224,7 +224,7 @@ static bool sdl_audio_play(const char *const tag, const char *const fullpath,
        longer be playing by the time we get here */
     if (samples[channel].wave) {
       MIX_DestroyAudio(samples[channel].wave);
-      samples[channel].wave = NULL;
+      samples[channel].wave = nullptr;
     }
 
     /* Remember for caching */
@@ -239,11 +239,11 @@ static bool sdl_audio_play(const char *const tag, const char *const fullpath,
       return FALSE;
     }
     log_verbose("Playing file \"%s\" on channel %d", fullpath, i);
-    /* Free previous sample on this channel. it will by definition no
+    /* Free previous sample on this channel. It will by definition no
        longer be playing by the time we get here */
     if (samples[i].wave) {
       Mix_FreeChunk(samples[i].wave);
-      samples[i].wave = NULL;
+      samples[i].wave = nullptr;
     }
 
     /* Remember for caching */
@@ -428,8 +428,8 @@ static bool sdl_audio_init(struct audio_plugin *self)
   }
 
 #ifdef AUDIO_SDL3
-  mixer = MIX_CreateMixerDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, NULL);
-  if (mixer == NULL) {
+  mixer = MIX_CreateMixerDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, nullptr);
+  if (mixer == nullptr) {
     log_error("Error calling MIX_CreateMixerDevice()");
 #else  /* AUDIO_SDL3 */
   /* Initialize variables */
@@ -457,7 +457,7 @@ static bool sdl_audio_init(struct audio_plugin *self)
 #ifdef AUDIO_SDL3
     tracks[i] = MIX_CreateTrack(mixer);
 #endif /* AUDIO_SDL3 */
-    samples[i].wave = NULL;
+    samples[i].wave = nullptr;
   }
 
   /* Sanity check, for now; add volume controls later */
-- 
2.53.0

