mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-04-22 07:30:50 +00:00
Use sequencer as a buffer for incoming midi events to ensure thread safety (ticket #43). Note: should be reverted once the synth has better thread safety on its own.
This commit is contained in:
parent
e25765e61b
commit
20949ac440
1 changed files with 10 additions and 3 deletions
|
@ -225,6 +225,7 @@ int main(int argc, char** argv)
|
|||
int midi_in = 1;
|
||||
fluid_player_t* player = NULL;
|
||||
fluid_midi_router_t* router = NULL;
|
||||
fluid_sequencer_t* sequencer = NULL;
|
||||
fluid_midi_driver_t* mdriver = NULL;
|
||||
fluid_audio_driver_t* adriver = NULL;
|
||||
fluid_synth_t* synth = NULL;
|
||||
|
@ -523,18 +524,20 @@ int main(int argc, char** argv)
|
|||
/* In dump mode, text output is generated for events going into and out of the router.
|
||||
* The example dump functions are put into the chain before and after the router..
|
||||
*/
|
||||
sequencer = new_fluid_sequencer2(0);
|
||||
|
||||
router = new_fluid_midi_router(
|
||||
settings,
|
||||
dump ? fluid_midi_dump_postrouter : fluid_synth_handle_midi_event,
|
||||
(void*)synth);
|
||||
dump ? fluid_midi_dump_postrouter : fluid_sequencer_add_midi_event_to_buffer,
|
||||
(void*)sequencer);
|
||||
|
||||
if (router == NULL) {
|
||||
if (router == NULL || sequencer == NULL) {
|
||||
fprintf(stderr, "Failed to create the MIDI input router; no MIDI input\n"
|
||||
"will be available. You can access the synthesizer \n"
|
||||
"through the console.\n");
|
||||
} else {
|
||||
fluid_synth_set_midi_router(synth, router); /* Fixme, needed for command handler */
|
||||
fluid_sequencer_register_fluidsynth(sequencer, synth);
|
||||
mdriver = new_fluid_midi_driver(
|
||||
settings,
|
||||
dump ? fluid_midi_dump_prerouter : fluid_midi_router_handle_midi_event,
|
||||
|
@ -651,6 +654,10 @@ int main(int argc, char** argv)
|
|||
#endif
|
||||
}
|
||||
|
||||
if (sequencer) {
|
||||
delete_fluid_sequencer(sequencer);
|
||||
}
|
||||
|
||||
if (adriver) {
|
||||
delete_fluid_audio_driver(adriver);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue