Timeline: Prevent segfault at shut down due to OSC output thread left running.

pull/3/head
Jonathan Moore Liles 2012-06-10 11:56:22 -07:00
parent 989b6f0e4b
commit f04c36cae9
4 changed files with 38 additions and 6 deletions

View File

@ -24,16 +24,23 @@
#include <stdlib.h>
#include <unistd.h>
#include "debug.h"
extern Timeline *timeline;
OSC_Thread::OSC_Thread ( )
{
// _thread.init();
_shutdown = false;
}
OSC_Thread::~OSC_Thread ( )
{
if ( _shutdown == false )
{
_shutdown = true;
_thread.join();
}
}
void
@ -42,17 +49,27 @@ OSC_Thread::start ( )
_thread.clone( &OSC_Thread::process, this );
}
void
OSC_Thread::join ( )
{
_thread.join();
}
void
OSC_Thread::process ( void )
{
_thread.name( "OSC" );
for ( ;; )
DMESSAGE( "OSC Thread starting" );
while ( !_shutdown )
{
usleep( 100 * 1000 );
timeline->process_osc();
}
DMESSAGE( "OSC Thread stopping." );
}
void *

View File

@ -26,12 +26,16 @@ class OSC_Thread : public Mutex
{
Thread _thread; /* io thread */
volatile bool _shutdown;
public:
OSC_Thread ( );
virtual ~OSC_Thread ( );
void join ( void );
void shutdown ( void ) { _shutdown = true; }
void start ( void );
void process ( void );
static void *process ( void * );

View File

@ -398,6 +398,12 @@ Timeline::ntracks ( void ) const
}
Timeline::~Timeline ( )
{
delete osc_thread;
osc_thread = 0;
}
Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : BASE( X, Y, W, H, L )
{
Loggable::snapshot_callback( &Timeline::snapshot, this );
@ -1698,13 +1704,16 @@ Timeline::process_osc ( void )
{
Track *t = (Track*)tracks->child( i );
for ( int j = t->control->children(); j--; )
if ( t->control )
{
Control_Sequence *c = (Control_Sequence*)t->control->child( j );
c->process_osc();
for ( int j = t->control->children(); j--; )
{
Control_Sequence *c = (Control_Sequence*)t->control->child( j );
c->process_osc();
}
}
}
unlock();
}

View File

@ -163,6 +163,8 @@ public:
nframes_t _sample_rate;
Timeline ( int X, int Y, int W, int H, const char *L=0 );
virtual ~Timeline ( );
void update_tempomap ( void );