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