diff --git a/dssi-vst-server.cpp b/dssi-vst-server.cpp index 8b45184..ff11a07 100644 --- a/dssi-vst-server.cpp +++ b/dssi-vst-server.cpp @@ -249,6 +249,7 @@ RemoteVSTServer::reset() void RemoteVSTServer::terminate() { + cerr << "RemoteVSTServer::terminate: setting exiting flag" << endl; exiting = true; } @@ -701,6 +702,7 @@ AudioThreadMain(LPVOID parameter) } if (exiting) { + cerr << "Remote VST plugin audio thread: returning" << endl; param.sched_priority = 0; (void)sched_setscheduler(0, SCHED_OTHER, ¶m); return 0; @@ -977,9 +979,16 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow) MSG msg; exiting = false; - while (GetMessage(&msg, 0, 0, 0)) { - DispatchMessage(&msg); - if (exiting) break; + while (!exiting) { + if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { + DispatchMessage(&msg); + } else { + if (tryGui) { + usleep(10000); + } else { + sleep(1); + } + } } if (debugLevel > 0) { diff --git a/dssi-vst.cpp b/dssi-vst.cpp index a2858d8..99c88ac 100644 --- a/dssi-vst.cpp +++ b/dssi-vst.cpp @@ -342,8 +342,6 @@ DSSIVSTPluginInstance::runSynth(unsigned long sampleCount, if (index >= MIDI_BUFFER_SIZE - 4) break; - std::cout << "DSSIVSTPluginInstance::runSynth: event at offset " << ev->time.tick << std::endl; - m_frameOffsetsBuffer[i] = ev->time.tick; long count = snd_midi_event_decode(m_alsaDecoder, diff --git a/remotepluginclient.cpp b/remotepluginclient.cpp index f16b6a4..eb2d4a2 100644 --- a/remotepluginclient.cpp +++ b/remotepluginclient.cpp @@ -105,8 +105,9 @@ RemotePluginClient::syncStartup() // for this and the process fd anyway. bool connected = false; + int timeout = 15; - for (int attempt = 0; attempt < 6; ++attempt) { + for (int attempt = 0; attempt < timeout; ++attempt) { if ((m_controlRequestFd = open(m_controlRequestFileName, O_WRONLY | O_NONBLOCK)) >= 0) { diff --git a/remotevstclient.cpp b/remotevstclient.cpp index d60e6cf..7f81608 100644 --- a/remotevstclient.cpp +++ b/remotevstclient.cpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include "rdwrops.h" #include "paths.h" @@ -89,6 +91,10 @@ RemoteVSTClient::RemoteVSTClient(std::string dllName, bool showGUI) : RemoteVSTClient::~RemoteVSTClient() { + for (int i = 0; i < 3; ++i) { + if (waitpid(-1, NULL, WNOHANG)) break; + sleep(1); + } } void @@ -216,8 +222,9 @@ RemoteVSTClient::queryPlugins(std::vector &plugins) pfd.fd = fd; pfd.events = POLLIN; int sec; + int timeout = 15; - for (sec = 0; sec < 6; ++sec) { + for (sec = 0; sec < timeout; ++sec) { int rv = poll(&pfd, 1, 1000); @@ -236,7 +243,7 @@ RemoteVSTClient::queryPlugins(std::vector &plugins) } } - if (sec >= 6) { + if (sec >= timeout) { close(fd); unlink(fifoFile); throw ((std::string)"Plugin scanner timed out on startup."); @@ -308,5 +315,10 @@ RemoteVSTClient::queryPlugins(std::vector &plugins) close(fd); unlink(fifoFile); + + for (int i = 0; i < 3; ++i) { + if (waitpid(-1, NULL, WNOHANG)) break; + sleep(1); + } }