Skip to content

Commit

Permalink
Fix for glsl threading crash #97
Browse files Browse the repository at this point in the history
  • Loading branch information
deltaoscarmike committed Sep 2, 2018
1 parent 0682ef1 commit db1a225
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/libprojectM/projectM.cpp
Expand Up @@ -68,15 +68,18 @@ pthread_mutex_t preset_mutex;

projectM::~projectM()
{
void *status;

#ifdef USE_THREADS
std::cout << "[projectM] thread ";
printf("c");
pthread_mutex_lock( &mutex );
running = false;
pthread_mutex_unlock( &mutex );
printf("l");
pthread_cond_signal(&condition);
printf("e");
pthread_mutex_unlock( &mutex );
pthread_join(thread, &status);
printf("a");
pthread_detach(thread);
printf("n");
Expand Down Expand Up @@ -381,16 +384,17 @@ static void *thread_callback(void *prjm) {
assert ( m_activePreset2.get() );

#ifdef USE_THREADS

pthread_cond_signal(&condition);
pthread_mutex_unlock( &mutex );
pthread_cond_signal(&condition);
#endif

m_activePreset->Render(*beatDetect, pipelineContext());

#ifdef USE_THREADS
pthread_mutex_lock( &mutex );
// wait for the thread
pthread_mutex_lock( &mutex );
pthread_mutex_unlock( &mutex );
#else
evaluateSecondPreset();
evaluateSecondPreset();
#endif

Pipeline pipeline;
Expand Down Expand Up @@ -524,7 +528,6 @@ static void *thread_callback(void *prjm) {
std::cerr << "[projectM] failed to allocate a thread! try building with option USE_THREADS turned off" << std::endl;;
exit(EXIT_FAILURE);
}
pthread_mutex_lock( &mutex );
#endif

/// @bug order of operatoins here is busted
Expand Down

2 comments on commit db1a225

@revmischa
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could probably lose the printf()s?

@deltaoscarmike
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Please sign in to comment.