Yes, i'm using the C++ wrapper. I compiled the wrapper with thread support. I was not using the queued layer. Should I use both (mutex and queued layer)? I made some test now (with mutex, without mutex, with mutex and queued, with mutex and without queued, etc), and there is no difference, the opengl draw is being blocked during the execution of the metronome. I tested the function with a std::thread:
void BasicGLPane::rightClick(wxMouseEvent& event) {
manager->init();
SLEEP(2000);
std::thread t(&BasicGLPane::start_thread,this);
t.join();
}
and made some changes in the thread function:
void BasicGLPane::start_thread() {
wxGLCanvas::SetCurrent(*m_context);
ctx = CGLGetCurrentContext();
err = CGLEnable( ctx, kCGLCEMPEngine);
int timer = 0;
manager->play();
while (_object->getCounter()<10) {
if (err==0 && timer<_object->getCounter()) {
std::cout<<"if CGLError: "<<err<<" timer: "<<timer<<std::endl;
glTranslatef(p3->x, p3->y, 0);
timer = _object->getCounter();
Refresh();
}
}
manager->stop();
Refresh();
}
There is no context error in the OpenGL draw now (solved with the call wxGLCanvas::SetCurrent(*m_context) but the draw still doesn't works (the object is moved after the manager->stop() and not during the execution) . I still think RtAudio is owning the CPU and blocking the execution of other threads or process. It will be better to do it with PortAudio?