Timeline: Prevent segfault at shut down due to OSC output thread left running.
This commit is contained in:
parent
989b6f0e4b
commit
f04c36cae9
|
@ -24,16 +24,23 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
extern Timeline *timeline;
|
extern Timeline *timeline;
|
||||||
|
|
||||||
OSC_Thread::OSC_Thread ( )
|
OSC_Thread::OSC_Thread ( )
|
||||||
{
|
{
|
||||||
// _thread.init();
|
// _thread.init();
|
||||||
|
_shutdown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSC_Thread::~OSC_Thread ( )
|
OSC_Thread::~OSC_Thread ( )
|
||||||
{
|
{
|
||||||
|
if ( _shutdown == false )
|
||||||
|
{
|
||||||
|
_shutdown = true;
|
||||||
|
_thread.join();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -42,17 +49,27 @@ OSC_Thread::start ( )
|
||||||
_thread.clone( &OSC_Thread::process, this );
|
_thread.clone( &OSC_Thread::process, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
OSC_Thread::join ( )
|
||||||
|
{
|
||||||
|
_thread.join();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OSC_Thread::process ( void )
|
OSC_Thread::process ( void )
|
||||||
{
|
{
|
||||||
_thread.name( "OSC" );
|
_thread.name( "OSC" );
|
||||||
|
|
||||||
for ( ;; )
|
DMESSAGE( "OSC Thread starting" );
|
||||||
|
|
||||||
|
while ( !_shutdown )
|
||||||
{
|
{
|
||||||
usleep( 100 * 1000 );
|
usleep( 100 * 1000 );
|
||||||
|
|
||||||
timeline->process_osc();
|
timeline->process_osc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DMESSAGE( "OSC Thread stopping." );
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
|
|
@ -26,12 +26,16 @@ class OSC_Thread : public Mutex
|
||||||
{
|
{
|
||||||
Thread _thread; /* io thread */
|
Thread _thread; /* io thread */
|
||||||
|
|
||||||
|
volatile bool _shutdown;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
OSC_Thread ( );
|
OSC_Thread ( );
|
||||||
|
|
||||||
virtual ~OSC_Thread ( );
|
virtual ~OSC_Thread ( );
|
||||||
|
|
||||||
|
void join ( void );
|
||||||
|
void shutdown ( void ) { _shutdown = true; }
|
||||||
void start ( void );
|
void start ( void );
|
||||||
void process ( void );
|
void process ( void );
|
||||||
static void *process ( void * );
|
static void *process ( void * );
|
||||||
|
|
|
@ -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 )
|
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 );
|
Loggable::snapshot_callback( &Timeline::snapshot, this );
|
||||||
|
@ -1698,12 +1704,15 @@ Timeline::process_osc ( void )
|
||||||
{
|
{
|
||||||
Track *t = (Track*)tracks->child( i );
|
Track *t = (Track*)tracks->child( i );
|
||||||
|
|
||||||
|
if ( t->control )
|
||||||
|
{
|
||||||
for ( int j = t->control->children(); j--; )
|
for ( int j = t->control->children(); j--; )
|
||||||
{
|
{
|
||||||
Control_Sequence *c = (Control_Sequence*)t->control->child( j );
|
Control_Sequence *c = (Control_Sequence*)t->control->child( j );
|
||||||
c->process_osc();
|
c->process_osc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,8 @@ public:
|
||||||
|
|
||||||
Timeline ( int X, int Y, int W, int H, const char *L=0 );
|
Timeline ( int X, int Y, int W, int H, const char *L=0 );
|
||||||
|
|
||||||
|
virtual ~Timeline ( );
|
||||||
|
|
||||||
void update_tempomap ( void );
|
void update_tempomap ( void );
|
||||||
|
|
||||||
const char *session_manager_name ( void );
|
const char *session_manager_name ( void );
|
||||||
|
|
Loading…
Reference in New Issue