File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -68,15 +68,18 @@ pthread_mutex_t preset_mutex;
6868
6969projectM::~projectM ()
7070{
71+ void *status;
7172
7273 #ifdef USE_THREADS
7374 std::cout << " [projectM] thread " ;
7475 printf (" c" );
76+ pthread_mutex_lock ( &mutex );
7577 running = false ;
78+ pthread_mutex_unlock ( &mutex );
7679 printf (" l" );
7780 pthread_cond_signal (&condition);
7881 printf (" e" );
79- pthread_mutex_unlock ( &mutex );
82+ pthread_join (thread, &status );
8083 printf (" a" );
8184 pthread_detach (thread);
8285 printf (" n" );
@@ -381,16 +384,17 @@ static void *thread_callback(void *prjm) {
381384 assert ( m_activePreset2.get () );
382385
383386 #ifdef USE_THREADS
384-
385- pthread_cond_signal (&condition);
386- pthread_mutex_unlock ( &mutex );
387+ pthread_cond_signal (&condition);
387388 #endif
389+
388390 m_activePreset->Render (*beatDetect, pipelineContext ());
389391
390392 #ifdef USE_THREADS
391- pthread_mutex_lock ( &mutex );
393+ // wait for the thread
394+ pthread_mutex_lock ( &mutex );
395+ pthread_mutex_unlock ( &mutex );
392396 #else
393- evaluateSecondPreset ();
397+ evaluateSecondPreset ();
394398 #endif
395399
396400 Pipeline pipeline;
@@ -524,7 +528,6 @@ static void *thread_callback(void *prjm) {
524528 std::cerr << " [projectM] failed to allocate a thread! try building with option USE_THREADS turned off" << std::endl;;
525529 exit (EXIT_FAILURE);
526530 }
527- pthread_mutex_lock ( &mutex );
528531 #endif
529532
530533 // / @bug order of operatoins here is busted
You can’t perform that action at this time.
0 commit comments