From aee1c1761b775b44e59d3d688644c6961d130b4e Mon Sep 17 00:00:00 2001 From: skyjake Date: Thu, 12 Jul 2012 18:24:20 +0300 Subject: [PATCH] dsFluidSynth: Refuse non-MIDI input; fixed song looping/status check --- .../fluidsynth/src/fluidsynth_music.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/doomsday/plugins/fluidsynth/src/fluidsynth_music.cpp b/doomsday/plugins/fluidsynth/src/fluidsynth_music.cpp index ddb8db392b..a8331f76ac 100644 --- a/doomsday/plugins/fluidsynth/src/fluidsynth_music.cpp +++ b/doomsday/plugins/fluidsynth/src/fluidsynth_music.cpp @@ -253,7 +253,7 @@ static int streamOutSamples(sfxbuffer_t* buf, void* data, unsigned int size) if(blockBuffer->availableForReading() >= int(size)) { - DSFLUIDSYNTH_TRACE("Streaming out " << size << " bytes."); + //DSFLUIDSYNTH_TRACE("Streaming out " << size << " bytes."); blockBuffer->read(data, size); return size; } @@ -420,8 +420,12 @@ int DM_Music_Get(int prop, void* ptr) } break; - case MUSIP_PLAYING: - return fsPlayer != 0; + case MUSIP_PLAYING: { + if(!fsPlayer) return false; + int playing = (fluid_player_get_status(fsPlayer) == FLUID_PLAYER_PLAYING); + DSFLUIDSYNTH_TRACE("Music_Get: MUSIP_PLAYING = " << playing); + return playing; + } default: break; @@ -564,13 +568,21 @@ int DM_Music_PlayFile(const char *filename, int looped) DENG_ASSERT(fsPlayer == NULL); + if(!fluid_is_midifile(filename)) + { + // It doesn't look like MIDI. + Con_Message("Cannot play \"%s\": not a MIDI file.\n", filename); + return false; + } + // Create a new player. fsPlayer = new_fluid_player(DMFluid_Synth()); fluid_player_add(fsPlayer, filename); + fluid_player_set_loop(fsPlayer, looped? -1 /*infinite times*/ : 1); fluid_player_play(fsPlayer); startPlayer(); - DSFLUIDSYNTH_TRACE("PlayFile: playing '" << filename << "' using player " << fsPlayer); + DSFLUIDSYNTH_TRACE("PlayFile: playing '" << filename << "' using player " << fsPlayer << " looped:" << looped); return true; }