Fixed bug 2909 - Mix_PauseMusic and Mix_ResumeMusic not working on MIDI (.mid)
authorSam Lantinga <slouken@libsdl.org>
Tue, 17 Oct 2017 22:29:19 -0700
changeset 7845cb894f15335
parent 783 2b559c85819d
child 785 e391c406adbd
Fixed bug 2909 - Mix_PauseMusic and Mix_ResumeMusic not working on MIDI (.mid)

Philipp Wiesemann

This is a patch to make Mix_PauseMusic() and Mix_ResumeMusic() work with the Windows native MIDI decoder.
music_nativemidi.c
native_midi/native_midi.h
native_midi/native_midi_haiku.cpp
native_midi/native_midi_mac.c
native_midi/native_midi_macosx.c
native_midi/native_midi_win32.c
     1.1 --- a/music_nativemidi.c	Tue Oct 17 22:10:50 2017 -0700
     1.2 +++ b/music_nativemidi.c	Tue Oct 17 22:29:19 2017 -0700
     1.3 @@ -53,6 +53,16 @@
     1.4      return native_midi_active() ? SDL_TRUE : SDL_FALSE;
     1.5  }
     1.6  
     1.7 +static void NATIVEMIDI_Pause(void *context)
     1.8 +{
     1.9 +    native_midi_pause();
    1.10 +}
    1.11 +
    1.12 +static void NATIVEMIDI_Resume(void *context)
    1.13 +{
    1.14 +    native_midi_resume();
    1.15 +}
    1.16 +
    1.17  static void NATIVEMIDI_Stop(void *context)
    1.18  {
    1.19      native_midi_stop();
    1.20 @@ -81,8 +91,8 @@
    1.21      NATIVEMIDI_IsPlaying,
    1.22      NULL,   /* GetAudio */
    1.23      NULL,   /* Seek */
    1.24 -    NULL,   /* Pause */
    1.25 -    NULL,   /* Resume */
    1.26 +    NATIVEMIDI_Pause,
    1.27 +    NATIVEMIDI_Resume,
    1.28      NATIVEMIDI_Stop,
    1.29      NATIVEMIDI_Delete,
    1.30      NULL,   /* Close */
     2.1 --- a/native_midi/native_midi.h	Tue Oct 17 22:10:50 2017 -0700
     2.2 +++ b/native_midi/native_midi.h	Tue Oct 17 22:29:19 2017 -0700
     2.3 @@ -30,6 +30,8 @@
     2.4  NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc);
     2.5  void native_midi_freesong(NativeMidiSong *song);
     2.6  void native_midi_start(NativeMidiSong *song, int loops);
     2.7 +void native_midi_pause(void);
     2.8 +void native_midi_resume(void);
     2.9  void native_midi_stop(void);
    2.10  int native_midi_active(void);
    2.11  void native_midi_setvolume(int volume);
     3.1 --- a/native_midi/native_midi_haiku.cpp	Tue Oct 17 22:10:50 2017 -0700
     3.2 +++ b/native_midi/native_midi_haiku.cpp	Tue Oct 17 22:29:19 2017 -0700
     3.3 @@ -253,6 +253,7 @@
     3.4    delete song->store;
     3.5    delete song; song = 0;
     3.6  }
     3.7 +
     3.8  void native_midi_start(NativeMidiSong *song, int loops)
     3.9  {
    3.10    native_midi_stop();
    3.11 @@ -261,6 +262,15 @@
    3.12    song->store->Start();
    3.13    currentSong = song;
    3.14  }
    3.15 +
    3.16 +void native_midi_pause(void)
    3.17 +{
    3.18 +}
    3.19 +
    3.20 +void native_midi_resume(void)
    3.21 +{
    3.22 +}
    3.23 +
    3.24  void native_midi_stop(void)
    3.25  {
    3.26    if (currentSong == NULL) return;
    3.27 @@ -270,6 +280,7 @@
    3.28      usleep(1000);
    3.29    currentSong = NULL;
    3.30  }
    3.31 +
    3.32  int native_midi_active(void)
    3.33  {
    3.34    if (currentSong == NULL) return 0;
     4.1 --- a/native_midi/native_midi_mac.c	Tue Oct 17 22:10:50 2017 -0700
     4.2 +++ b/native_midi/native_midi_mac.c	Tue Oct 17 22:29:19 2017 -0700
     4.3 @@ -242,6 +242,14 @@
     4.4      SDL_PauseAudio(0);
     4.5  }
     4.6  
     4.7 +void native_midi_pause(void)
     4.8 +{
     4.9 +}
    4.10 +
    4.11 +void native_midi_resume(void)
    4.12 +{
    4.13 +}
    4.14 +
    4.15  void native_midi_stop(void)
    4.16  {
    4.17      if (gTunePlayer == NULL)
     5.1 --- a/native_midi/native_midi_macosx.c	Tue Oct 17 22:10:50 2017 -0700
     5.2 +++ b/native_midi/native_midi_macosx.c	Tue Oct 17 22:29:19 2017 -0700
     5.3 @@ -287,6 +287,14 @@
     5.4      SDL_PauseAudio(0);
     5.5  }
     5.6  
     5.7 +void native_midi_pause(void)
     5.8 +{
     5.9 +}
    5.10 +
    5.11 +void native_midi_resume(void)
    5.12 +{
    5.13 +}
    5.14 +
    5.15  void native_midi_stop(void)
    5.16  {
    5.17      if (currentsong) {
     6.1 --- a/native_midi/native_midi_win32.c	Tue Oct 17 22:10:50 2017 -0700
     6.2 +++ b/native_midi/native_midi_win32.c	Tue Oct 17 22:29:19 2017 -0700
     6.3 @@ -272,6 +272,20 @@
     6.4    }
     6.5  }
     6.6  
     6.7 +void native_midi_pause(void)
     6.8 +{
     6.9 +  if (!hMidiStream)
    6.10 +    return;
    6.11 +  midiStreamPause(hMidiStream);
    6.12 +}
    6.13 +
    6.14 +void native_midi_resume(void)
    6.15 +{
    6.16 +  if (!hMidiStream)
    6.17 +    return;
    6.18 +  midiStreamRestart(hMidiStream);
    6.19 +}
    6.20 +
    6.21  void native_midi_stop(void)
    6.22  {
    6.23    if (!hMidiStream)