Sequencer: Don't leak from the output buffer when suppressing duplicate noteon/offs.

This commit is contained in:
Jonathan Moore Liles 2012-03-06 04:44:11 -08:00
parent 0f86ee6882
commit 9a80f4c3f3
1 changed files with 13 additions and 5 deletions

View File

@ -121,17 +121,18 @@ midi_output_event ( int port, const midievent *e )
event *fe = freelist.first();
if ( ! fe )
{
WARNING( "output buffer underrun" );
}
else
{
freelist.unlink( fe );
*fe = *e;
if ( e->is_note_on() )
{
if ( notes_on[ port ][ e->channel() ][ e->note() ] == 0 )
{
freelist.unlink( fe );
*fe = *e;
output[ port ].events.insert( fe );
++notes_on[ port ][ e->channel() ][ e->note() ];
}
@ -148,13 +149,20 @@ midi_output_event ( int port, const midievent *e )
}
else
{
output[ port ].events.insert( fe );
freelist.unlink( fe );
*fe = *e;
output[ port ].events.insert( fe );
--notes_on[ port ][ e->channel() ][ e->note() ];
}
}
else
{
freelist.unlink( fe );
*fe = *e;
output[ port ].events.insert( fe );
}
}
}