Work on freewheel mode.

This commit is contained in:
Jonathan Moore Liles 2008-05-17 20:45:56 -05:00
parent 5cd2475609
commit 60132b8595
4 changed files with 51 additions and 27 deletions

View File

@ -95,8 +95,10 @@ Engine::freewheel ( bool starting )
{ {
_freewheeling = starting; _freewheeling = starting;
if ( _freewheeling ) if ( starting )
FATAL( "Freewheeling mode is unimplemented" ); DMESSAGE( "entering freewheeling mode" );
else
DMESSAGE( "leaving freewheeling mode" );
} }
/* THREAD: RT */ /* THREAD: RT */
@ -174,29 +176,38 @@ Engine::process ( nframes_t nframes )
{ {
transport->poll(); transport->poll();
if ( ! trylock() ) if ( freewheeling() )
{ {
/* the data structures we need to access here (tracks and /* freewheeling mode/export. We're actually running
* their ports, but not track contents) may be in an non-RT. Assume that everything is quiescent, locking is
* inconsistent state at the moment. Just punt and drop this unecessary and do I/O synchronously */
* buffer. */ if ( timeline )
++_buffers_dropped; timeline->process( nframes );
return 0;
/* because we're going faster than realtime. */
timeline->wait_for_buffers();
} }
else
{
if ( ! trylock() )
{
/* the data structures we need to access here (tracks and
* their ports, but not track contents) may be in an
* inconsistent state at the moment. Just punt and drop this
* buffer. */
++_buffers_dropped;
return 0;
}
/* if ( ! transport->rolling ) */ /* handle chicken/egg problem */
/* timeline->silence( nframes ); */ if ( timeline )
/* return 0; */ /* this will initiate the process() call graph for the various
* number and types of tracks, which will in turn send data out
* the appropriate ports. */
timeline->process( nframes );
unlock();
/* handle chicken/egg problem */ }
if ( timeline )
/* this will initiate the process() call graph for the various
* number and types of tracks, which will in turn send data out
* the appropriate ports. */
timeline->process( nframes );
unlock();
return 0; return 0;
} }

View File

@ -79,7 +79,7 @@ public:
nframes_t sample_rate ( void ) const { return _sample_rate; } nframes_t sample_rate ( void ) const { return _sample_rate; }
int xruns ( void ) const { return _xruns; }; int xruns ( void ) const { return _xruns; };
int dropped ( void ) const { return _buffers_dropped; } int dropped ( void ) const { return _buffers_dropped; }
bool freehweeling ( void ) const { return _freewheeling; } bool freewheeling ( void ) const { return _freewheeling; }
void freewheeling ( bool yes ); void freewheeling ( bool yes );
float cpu_load ( void ) const { return jack_cpu_load( _client ); } float cpu_load ( void ) const { return jack_cpu_load( _client ); }

View File

@ -1284,6 +1284,15 @@ Timeline::total_output_buffer_percent ( void )
return r / cnt; return r / cnt;
} }
/** wait for I/O threads to fill their buffers */
void
Timeline::wait_for_buffers ( void )
{
while ( total_output_buffer_percent() + total_input_buffer_percent() < 200 )
usleep( 5000 );
}
int int
Timeline::total_playback_xruns ( void ) Timeline::total_playback_xruns ( void )
{ {

View File

@ -183,6 +183,14 @@ public:
void add_track ( Track *track ); void add_track ( Track *track );
void remove_track ( Track *track ); void remove_track ( Track *track );
void zoom ( float secs );
void zoom_in ( void );
void zoom_out ( void );
void zoom_fit ( void );
/* Engine */
int total_input_buffer_percent ( void ); int total_input_buffer_percent ( void );
int total_output_buffer_percent ( void ); int total_output_buffer_percent ( void );
@ -192,11 +200,7 @@ public:
bool record ( void ); bool record ( void );
void stop ( void ); void stop ( void );
void zoom ( float secs ); void wait_for_buffers ( void );
void zoom_in ( void );
void zoom_out ( void );
void zoom_fit ( void );
private: private: