diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 4c4053899b..052d049527 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -2517,6 +2517,21 @@ void S_RestartMusic () } } +//========================================================================== +// +// S_MIDIDeviceChanged +// +//========================================================================== + +void S_MIDIDeviceChanged() +{ + if (mus_playing.handle != NULL && mus_playing.handle->IsMIDI()) + { + mus_playing.handle->Stop(); + mus_playing.handle->Start(mus_playing.loop, -1, mus_playing.baseorder); + } +} + //========================================================================== // // S_GetMusic diff --git a/src/s_sound.h b/src/s_sound.h index 12e7ee3c65..d82e273ac2 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -313,6 +313,8 @@ bool S_ChangeCDMusic (int track, unsigned int id=0, bool looping=true); void S_RestartMusic (); +void S_MIDIDeviceChanged(); + int S_GetMusic (char **name); // Stops the music for sure. diff --git a/src/sound/music_midi_base.cpp b/src/sound/music_midi_base.cpp index 86134c9548..e0d67683d7 100644 --- a/src/sound/music_midi_base.cpp +++ b/src/sound/music_midi_base.cpp @@ -43,13 +43,20 @@ static void MIDIDeviceChanged(int newdev) static int oldmididev = INT_MIN; // If a song is playing, move it to the new device. - if (oldmididev != newdev && currSong != NULL && currSong->IsMIDI()) + if (oldmididev != newdev) { - MusInfo *song = currSong; - if (song->m_Status == MusInfo::STATE_Playing) + if (currSong != NULL && currSong->IsMIDI()) { - song->Stop(); - song->Start(song->m_Looping); + MusInfo *song = currSong; + if (song->m_Status == MusInfo::STATE_Playing) + { + song->Stop(); + song->Start(song->m_Looping); + } + } + else + { + S_MIDIDeviceChanged(); } } oldmididev = newdev;