diff --git a/midiproc/main.c b/midiproc/main.c index 473eb4de..19d2c047 100644 --- a/midiproc/main.c +++ b/midiproc/main.c @@ -99,6 +99,7 @@ static void UnregisterSong() } Mix_FreeMusic(music); + music = NULL; } // @@ -121,6 +122,9 @@ static boolean RegisterSong(const char *filename) UnregisterSong(); music = Mix_LoadMUS(filename); + // Remove the temporary MIDI file + remove(filename); + if (music == NULL) { return false; @@ -218,6 +222,7 @@ boolean MidiPipe_PlaySong(buffer_reader_t *reader) boolean MidiPipe_StopSong() { StopSong(); + UnregisterSong(); return true; } diff --git a/src/i_midipipe.c b/src/i_midipipe.c index a318e999..330377d9 100644 --- a/src/i_midipipe.c +++ b/src/i_midipipe.c @@ -58,7 +58,7 @@ boolean midi_server_registered = false; // Data // -#define MIDIPIPE_MAX_WAIT 500 // Max amount of ms to wait for expected data. +#define MIDIPIPE_MAX_WAIT 1000 // Max amount of ms to wait for expected data. static HANDLE midi_process_in_reader; // Input stream for midi process. static HANDLE midi_process_in_writer; diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c index 67c01b9d..f4b08452 100644 --- a/src/i_sdlmusic.c +++ b/src/i_sdlmusic.c @@ -1242,16 +1242,16 @@ static void *I_SDL_RegisterSong(void *data, int len) // Failed to load fprintf(stderr, "Error loading midi: %s\n", Mix_GetError()); } - } - // Remove the temporary MIDI file; however, when using an external - // MIDI program we can't delete the file. Otherwise, the program - // won't find the file to play. This means we leave a mess on - // disk :( + // Remove the temporary MIDI file; however, when using an external + // MIDI program we can't delete the file. Otherwise, the program + // won't find the file to play. This means we leave a mess on + // disk :( - if (strlen(snd_musiccmd) == 0) - { - remove(filename); + if (strlen(snd_musiccmd) == 0) + { + remove(filename); + } } free(filename);