Hi all
I am working on an application that communicates with a USB Midi device using Sysex packages. The routines handling the midi connection and midi data is called from a timer interupt.
Sometimes the application “hangs” after I unplug the USB cable and it seems to happend if I unplug the cable while a transmission of data has just been initiated. When the application
"hangs" the timercallback handling the midi connection is no longer called and when I stop the debugger (windows)the code executed is:
bool WaitableEvent::wait (const int timeOutMillisecs) const noexcept
{
return WaitForSingleObject (internal, (DWORD) timeOutMillisecs) == WAIT_OBJECT_0;
}
This code is located in “juce_win32_Threads.cpp”
If I run the code on a Mac and stops the debugger when the application hangs the code being executed is:
bool WaitableEvent::wait (const int timeOutMillisecs) const noexcept
{
return static_cast <WaitableEventImpl*> (internal)->wait (timeOutMillisecs);
}
This code is located in “juce_posix_SharedCode.h”
Any suggestions on how to make the code stable even if the cable is being unplugged while a transmission is taking place is highly appreciated.
Other suggestions are also welcome.
Mery xmas
John