Skip to content
Permalink
Browse files
Fixed bug 2909 - Mix_PauseMusic and Mix_ResumeMusic not working on MI…
…DI (.mid)

Philipp Wiesemann

This is a patch to make Mix_PauseMusic() and Mix_ResumeMusic() work with the Windows native MIDI decoder.
  • Loading branch information
slouken committed Oct 18, 2017
1 parent 7f11e57 commit 13b57d62a5b4070d91abf000bd5456d0ee00de5a
Showing 6 changed files with 55 additions and 2 deletions.
@@ -53,6 +53,16 @@ static SDL_bool NATIVEMIDI_IsPlaying(void *context)
return native_midi_active() ? SDL_TRUE : SDL_FALSE;
}

static void NATIVEMIDI_Pause(void *context)
{
native_midi_pause();
}

static void NATIVEMIDI_Resume(void *context)
{
native_midi_resume();
}

static void NATIVEMIDI_Stop(void *context)
{
native_midi_stop();
@@ -81,8 +91,8 @@ Mix_MusicInterface Mix_MusicInterface_NATIVEMIDI =
NATIVEMIDI_IsPlaying,
NULL, /* GetAudio */
NULL, /* Seek */
NULL, /* Pause */
NULL, /* Resume */
NATIVEMIDI_Pause,
NATIVEMIDI_Resume,
NATIVEMIDI_Stop,
NATIVEMIDI_Delete,
NULL, /* Close */
@@ -30,6 +30,8 @@ int native_midi_detect(void);
NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc);
void native_midi_freesong(NativeMidiSong *song);
void native_midi_start(NativeMidiSong *song, int loops);
void native_midi_pause(void);
void native_midi_resume(void);
void native_midi_stop(void);
int native_midi_active(void);
void native_midi_setvolume(int volume);
@@ -253,6 +253,7 @@ void native_midi_freesong(NativeMidiSong *song)
delete song->store;
delete song; song = 0;
}

void native_midi_start(NativeMidiSong *song, int loops)
{
native_midi_stop();
@@ -261,6 +262,15 @@ void native_midi_start(NativeMidiSong *song, int loops)
song->store->Start();
currentSong = song;
}

void native_midi_pause(void)
{
}

void native_midi_resume(void)
{
}

void native_midi_stop(void)
{
if (currentSong == NULL) return;
@@ -270,6 +280,7 @@ void native_midi_stop(void)
usleep(1000);
currentSong = NULL;
}

int native_midi_active(void)
{
if (currentSong == NULL) return 0;
@@ -242,6 +242,14 @@ void native_midi_start(NativeMidiSong *song, int loops)
SDL_PauseAudio(0);
}

void native_midi_pause(void)
{
}

void native_midi_resume(void)
{
}

void native_midi_stop(void)
{
if (gTunePlayer == NULL)
@@ -287,6 +287,14 @@ void native_midi_start(NativeMidiSong *song, int loops)
SDL_PauseAudio(0);
}

void native_midi_pause(void)
{
}

void native_midi_resume(void)
{
}

void native_midi_stop(void)
{
if (currentsong) {
@@ -272,6 +272,20 @@ void native_midi_start(NativeMidiSong *song, int loops)
}
}

void native_midi_pause(void)
{
if (!hMidiStream)
return;
midiStreamPause(hMidiStream);
}

void native_midi_resume(void)
{
if (!hMidiStream)
return;
midiStreamRestart(hMidiStream);
}

void native_midi_stop(void)
{
if (!hMidiStream)

0 comments on commit 13b57d6

Please sign in to comment.