From 60132b859585188709050fd849654fa147fcc2f7 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sat, 17 May 2008 20:45:56 -0500 Subject: [PATCH] Work on freewheel mode. --- Timeline/Engine.C | 53 +++++++++++++++++++++++++++------------------ Timeline/Engine.H | 2 +- Timeline/Timeline.C | 9 ++++++++ Timeline/Timeline.H | 14 +++++++----- 4 files changed, 51 insertions(+), 27 deletions(-) diff --git a/Timeline/Engine.C b/Timeline/Engine.C index 45172b9..70d7e21 100644 --- a/Timeline/Engine.C +++ b/Timeline/Engine.C @@ -95,8 +95,10 @@ Engine::freewheel ( bool starting ) { _freewheeling = starting; - if ( _freewheeling ) - FATAL( "Freewheeling mode is unimplemented" ); + if ( starting ) + DMESSAGE( "entering freewheeling mode" ); + else + DMESSAGE( "leaving freewheeling mode" ); } /* THREAD: RT */ @@ -174,29 +176,38 @@ Engine::process ( nframes_t nframes ) { transport->poll(); - if ( ! trylock() ) + if ( freewheeling() ) { - /* 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; + /* freewheeling mode/export. We're actually running + non-RT. Assume that everything is quiescent, locking is + unecessary and do I/O synchronously */ + if ( timeline ) + timeline->process( nframes ); + + /* 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 ) */ -/* timeline->silence( nframes ); */ -/* return 0; */ + /* 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 ); - - /* 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(); + unlock(); + } return 0; } diff --git a/Timeline/Engine.H b/Timeline/Engine.H index 7bfddb8..ba2c061 100644 --- a/Timeline/Engine.H +++ b/Timeline/Engine.H @@ -79,7 +79,7 @@ public: nframes_t sample_rate ( void ) const { return _sample_rate; } int xruns ( void ) const { return _xruns; }; int dropped ( void ) const { return _buffers_dropped; } - bool freehweeling ( void ) const { return _freewheeling; } + bool freewheeling ( void ) const { return _freewheeling; } void freewheeling ( bool yes ); float cpu_load ( void ) const { return jack_cpu_load( _client ); } diff --git a/Timeline/Timeline.C b/Timeline/Timeline.C index 0b86c62..a9181a7 100644 --- a/Timeline/Timeline.C +++ b/Timeline/Timeline.C @@ -1284,6 +1284,15 @@ Timeline::total_output_buffer_percent ( void ) 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 Timeline::total_playback_xruns ( void ) { diff --git a/Timeline/Timeline.H b/Timeline/Timeline.H index ae4df53..1a46b79 100644 --- a/Timeline/Timeline.H +++ b/Timeline/Timeline.H @@ -183,6 +183,14 @@ public: void add_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_output_buffer_percent ( void ); @@ -192,11 +200,7 @@ public: bool record ( void ); void stop ( void ); - void zoom ( float secs ); - void zoom_in ( void ); - void zoom_out ( void ); - void zoom_fit ( void ); - + void wait_for_buffers ( void ); private: