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,13 +1704,16 @@ Timeline::process_osc ( void )
|
||||||
{
|
{
|
||||||
Track *t = (Track*)tracks->child( i );
|
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 );
|
for ( int j = t->control->children(); j--; )
|
||||||
c->process_osc();
|
{
|
||||||
|
Control_Sequence *c = (Control_Sequence*)t->control->child( j );
|
||||||
|
c->process_osc();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,8 @@ public:
|
||||||
nframes_t _sample_rate;
|
nframes_t _sample_rate;
|
||||||
|
|
||||||
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 );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue