changeset 548:1954be7d4889 trunk

[svn] added support for the FluidSynth ALSA backend, by sending a MIDI_CTL_ALL_SOUNDS_OFF controller event when playback is halted
author giacomo
date Sun, 29 Jan 2006 12:38:24 -0800
parents 2d86cb17b5af
children 5a8f8c28871a
files Plugins/Input/amidi-plug/amidi-plug.c
diffstat 1 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Input/amidi-plug/amidi-plug.c	Sat Jan 28 19:23:29 2006 -0800
+++ b/Plugins/Input/amidi-plug/amidi-plug.c	Sun Jan 29 12:38:24 2006 -0800
@@ -379,7 +379,7 @@
 void * amidiplug_play_loop( void * arg )
 {
   snd_seq_event_t ev;
-  gint i;
+  gint i, p, c;
   gboolean rewind = FALSE;
 
   pthread_mutex_lock( &amidiplug_playing_mutex );
@@ -520,7 +520,32 @@
     snd_seq_sync_output_queue(sc.seq);
   }
 
+  /* time to shutdown playback! */
+  /* send "ALL SOUNDS OFF" to all channels on all ports */
+  ev.type = SND_SEQ_EVENT_CONTROLLER;
+  ev.time.tick = 0;
+  snd_seq_ev_set_fixed(&ev);
+  ev.data.control.param = MIDI_CTL_ALL_SOUNDS_OFF;
+  ev.data.control.value = 0;
+  for ( p = 0 ; p < sc.dest_port_num ; p++)
+  {
+    ev.queue = sc.queue;
+    ev.dest = sc.dest_port[p];
+
+    for ( c = 0 ; c < 16 ; c++ )
+    {
+      ev.data.control.channel = c;
+      snd_seq_event_output(sc.seq, &ev);
+      snd_seq_drain_output(sc.seq);
+    }
+  }
+
   /* schedule queue stop at end of song */
+  snd_seq_ev_clear(&ev);
+  ev.queue = sc.queue;
+  ev.source.port = 0;
+  ev.flags = SND_SEQ_TIME_STAMP_TICK;
+
   snd_seq_ev_set_fixed(&ev);
   ev.type = SND_SEQ_EVENT_STOP;
   ev.time.tick = midifile.max_tick - midifile.skip_offset;