Browse Source

Reduce conditional compilation of PAL_HAS_NATIVEMIDI

LouYihua 7 years ago
parent
commit
c706728e89
4 changed files with 37 additions and 42 deletions
  1. 5 5
      audio.c
  2. 0 2
      input.c
  3. 10 26
      midi.c
  4. 22 9
      midi.h

+ 5 - 5
audio.c

@@ -385,9 +385,10 @@ AUDIO_CloseDevice(
 	  gAudioDevice.pSoundBuffer = NULL;
    }
 
-#if PAL_HAS_NATIVEMIDI
-   if (gConfig.eMusicType == MUSIC_MIDI) MIDI_Play(0, FALSE);
-#endif
+   if (gConfig.eMusicType == MUSIC_MIDI)
+   {
+      MIDI_Play(0, FALSE);
+   }
 }
 
 SDL_AudioSpec*
@@ -498,13 +499,12 @@ AUDIO_PlayMusic(
    FLOAT     flFadeTime
 )
 {
-#if PAL_HAS_NATIVEMIDI
    if (gConfig.eMusicType == MUSIC_MIDI)
    {
       MIDI_Play(iNumRIX, fLoop);
       return;
    }
-#endif
+
    SDL_LockAudio();
    if (gAudioDevice.pMusPlayer)
    {

+ 0 - 2
input.c

@@ -1018,9 +1018,7 @@ PAL_ProcessEvent(
 
 --*/
 {
-#if PAL_HAS_NATIVEMIDI
    MIDI_CheckLoop();
-#endif
    while (PAL_PollEvent(NULL));
 }
 

+ 10 - 26
midi.c

@@ -22,35 +22,18 @@
 
 #include "main.h"
 
-#if PAL_HAS_NATIVEMIDI
-
-static INT iMidCurrent = -1;
+static int  iMidCurrent = -1;
 static BOOL fMidLoop = FALSE;
 
 static NativeMidiSong *g_pMid = NULL;
 
-VOID
+void
 MIDI_Play(
-   INT       iNumRIX,
-   BOOL      fLoop
+	int       iNumRIX,
+	BOOL      fLoop
 )
-/*++
-  Purpose:
-
-    Start playing the specified music in MIDI format.
-
-  Parameters:
-
-    [IN]  iNumRIX - number of the music. 0 to stop playing current music.
-
-    [IN]  fLoop - Whether the music should be looped or not.
-
-  Return value:
-
-    None.
-
---*/
 {
+#if PAL_HAS_NATIVEMIDI
    if (g_pMid != NULL && iNumRIX == iMidCurrent && native_midi_active())
    {
       return;
@@ -125,17 +108,18 @@ MIDI_Play(
       SDL_RWclose(rw);
       free(buf);
    }
+#endif
 }
 
-VOID
+void
 MIDI_CheckLoop(
-   VOID
+   void
 )
 {
+#if PAL_HAS_NATIVEMIDI
    if (fMidLoop && g_pMid != NULL && !native_midi_active())
    {
       MIDI_Play(iMidCurrent, TRUE);
    }
-}
-
 #endif
+}

+ 22 - 9
midi.h

@@ -24,22 +24,35 @@
 #define PAL_MIDI_H
 
 #include "common.h"
-
-#if PAL_HAS_NATIVEMIDI
-# include "native_midi/native_midi.h"
-#endif
+#include "native_midi/native_midi.h"
 
 PAL_C_LINKAGE_BEGIN
 
-VOID
+/*++
+  Purpose:
+
+    Start playing the specified music in MIDI format.
+
+  Parameters:
+
+    [IN]  iNumRIX - number of the music. 0 to stop playing current music.
+
+    [IN]  fLoop - Whether the music should be looped or not.
+
+  Return value:
+
+    None.
+
+--*/
+void
 MIDI_Play(
-   INT       iNumRIX,
-   BOOL      fLoop
+	int       iNumRIX,
+	BOOL      fLoop
 );
 
-VOID
+void
 MIDI_CheckLoop(
-   VOID
+	void
 );
 
 PAL_C_LINKAGE_END