ref: f4abf51e5c0c6dc4768e38fb2958d21e01af797a
parent: 413f4ecd7aae41229cc7b40ea3275970dc18cdb4
author: Fabian Greffrath <fabian@greffrath.com>
date: Wed Nov 22 15:46:04 EST 2017
i_sdlmusic: avoid code duplication and code path splitting
--- a/src/i_midipipe.h
+++ b/src/i_midipipe.h
@@ -36,6 +36,12 @@
boolean I_MidiPipe_InitServer();
+#else
+
+#include "doomtype.h"
+
+static const boolean midi_server_registered = false;
+
#endif
#endif
--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -1030,11 +1030,7 @@
return;
}
-#if defined(_WIN32)
if (handle == NULL && !midi_server_registered)
-#else
- if (handle == NULL)
-#endif
{
return;
}
@@ -1067,12 +1063,10 @@
I_MidiPipe_PlaySong(loops);
}
else
+#endif
{
Mix_PlayMusic(current_track_music, loops);
}
-#else
- Mix_PlayMusic(current_track_music, loops);
-#endif
}
static void I_SDL_PauseSong(void)
@@ -1112,12 +1106,10 @@
I_MidiPipe_StopSong();
}
else
+#endif
{
Mix_HaltMusic();
}
-#else
- Mix_HaltMusic();
-#endif
playing_substitute = false;
current_track_music = NULL;
@@ -1242,6 +1234,7 @@
}
}
else
+#endif
{
music = Mix_LoadMUS(filename);
if (music == NULL)
@@ -1250,14 +1243,6 @@
fprintf(stderr, "Error loading midi: %s\n", Mix_GetError());
}
}
-#else
- music = Mix_LoadMUS(filename);
- if (music == NULL)
- {
- // Failed to load
- fprintf(stderr, "Error loading midi: %s\n", Mix_GetError());
- }
-#endif
// Remove the temporary MIDI file; however, when using an external
// MIDI program we can't delete the file. Otherwise, the program