Browse Source

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

tags/non-daw-v1.2.0
Jonathan Moore Liles 13 years ago
parent
commit
f04c36cae9
4 changed files with 38 additions and 6 deletions
  1. +19
    -2
      timeline/src/OSC_Thread.C
  2. +4
    -0
      timeline/src/OSC_Thread.H
  3. +13
    -4
      timeline/src/Timeline.C
  4. +2
    -0
      timeline/src/Timeline.H

+ 19
- 2
timeline/src/OSC_Thread.C 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 *


+ 4
- 0
timeline/src/OSC_Thread.H 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 * );


+ 13
- 4
timeline/src/Timeline.C 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();
}


+ 2
- 0
timeline/src/Timeline.H 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 );



Loading…
Cancel
Save