Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Zyn GUI to main thread #4065

Merged
merged 1 commit into from Dec 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 9 additions & 16 deletions plugins/zynaddsubfx/RemoteZynAddSubFx.cpp
Expand Up @@ -62,18 +62,11 @@ class RemoteZynAddSubFx : public RemotePluginClient, public LocalZynAddSubFx
waitForMessage( IdInitDone );

pthread_mutex_init( &m_guiMutex, NULL );
pthread_create( &m_guiThreadHandle, NULL, guiThread, this );
pthread_create( &m_messageThreadHandle, NULL, messageLoop, this );
}

virtual ~RemoteZynAddSubFx()
{
m_guiExit = true;
#ifdef LMMS_BUILD_WIN32
Sleep( m_guiSleepTime * 2 );
#else
usleep( m_guiSleepTime * 2 * 1000 );
#endif

Nio::stop();
}

Expand All @@ -87,7 +80,7 @@ class RemoteZynAddSubFx : public RemotePluginClient, public LocalZynAddSubFx
LocalZynAddSubFx::setBufferSize( bufferSize() );
}

void run()
void messageLoop()
{
message m;
while( ( m = receiveMessage() ).id != IdQuit )
Expand All @@ -96,6 +89,7 @@ class RemoteZynAddSubFx : public RemotePluginClient, public LocalZynAddSubFx
processMessage( m );
pthread_mutex_unlock( &m_master->mutex );
}
m_guiExit = true;
}

virtual bool processMessage( const message & _m )
Expand Down Expand Up @@ -151,23 +145,22 @@ class RemoteZynAddSubFx : public RemotePluginClient, public LocalZynAddSubFx
LocalZynAddSubFx::processAudio( _out );
}

static void * guiThread( void * _arg )
static void * messageLoop( void * _arg )
{
RemoteZynAddSubFx * _this =
static_cast<RemoteZynAddSubFx *>( _arg );

_this->guiThread();
_this->messageLoop();

return NULL;
}

void guiLoop();

private:
void guiThread();

const int m_guiSleepTime;

pthread_t m_guiThreadHandle;
pthread_t m_messageThreadHandle;
pthread_mutex_t m_guiMutex;
std::queue<RemotePluginClient::message> m_guiMessages;
bool m_guiExit;
Expand All @@ -177,7 +170,7 @@ class RemoteZynAddSubFx : public RemotePluginClient, public LocalZynAddSubFx



void RemoteZynAddSubFx::guiThread()
void RemoteZynAddSubFx::guiLoop()
{
int exitProgram = 0;
MasterUI * ui = NULL;
Expand Down Expand Up @@ -292,7 +285,7 @@ int main( int _argc, char * * _argv )
RemoteZynAddSubFx * remoteZASF = new RemoteZynAddSubFx( _argv[1] );
#endif

remoteZASF->run();
remoteZASF->guiLoop();

delete remoteZASF;

Expand Down