Skip to content

midiOutUnprepareHeader intermittently hangs on Windows during repeated large sysex sends #333

Open
@insolace

Description

@insolace

I tried submitting a pull request but did not have permissions.

Starting at line 3184 of RtMidi.cpp:

// Unprepare the buffer and MIDIHDR.
while ( MIDIERR_STILLPLAYING == midiOutUnprepareHeader( data->outHandle, &sysex, sizeof ( MIDIHDR ) ) ) Sleep( 1 );

This line of code is problematic and can cause our application to crash during our firmware update process, when we are sending multiple reboot commands in between large sysex payloads. Our current workaround is to delete the RtMidi in/out objects and then recreate them, otherwise depending on the state of the update process things can hang.

We'd prefer if there was better error handling and/or a timeout inside of this loop. Here is a simple timeout that would be better if there was a method to change the duration:

int timeOut = 0;
// Unprepare the buffer and MIDIHDR.
while ( MIDIERR_STILLPLAYING == midiOutUnprepareHeader( data->outHandle, &sysex, sizeof ( MIDIHDR ) ) )
{
    if (timeOut++ > 25000)
        break;
    Sleep( 1 );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions