midiproc: some further improvements
Recent versions of SDL_Mixer allow for rendering MIDI songs using the fluidsynth backend and recent versions of fluidsynth allow for using soundfonts in SF3 format (which contain OGG compressed samples). The midiproc process currently assumes that it is possible to remove the temporary music file immediately after Mix_LoadMUS() has been called, which is true if the music is rendered using Windows's limited intrnal MIDI playback. However, when using an advanced backend like fluidsynth, this file maybe locked by this library. Furthermore, midiproc currently assumes that it is possible to override the temporary music file as soon as Mix_HaltMusic() has been called which is again not true if fluidsynth is used. In this case, this is only possible after Mix_FreeMusic() has been called (and returned). Additionally, we increase the time-out value after which we give up waiting for the midiproc process to send an acknowledgement to 1s to give it some time to load the fluidsynth library and a soundfont (although 1s will still not be enough for soundfonts in SF3 format which reportedly load up to the order of 10s!).
This commit is contained in:
parent
95bd2d4483
commit
241d056f60
3 changed files with 14 additions and 9 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue