From 2e7fab494abc0962392064b37f90cd307a41f585 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Wed, 23 Apr 2008 17:29:14 -0500 Subject: [PATCH] Actiavte compaction menu option. --- Timeline/Loggable.C | 20 +++++++++++++++++++- Timeline/Loggable.H | 1 + Timeline/TLE.fl | 14 ++++++++++++-- Timeline/Timeline.C | 11 +++++++++-- Timeline/Track.H | 12 +++++++++--- 5 files changed, 50 insertions(+), 8 deletions(-) diff --git a/Timeline/Loggable.C b/Timeline/Loggable.C index a50acb2..fc18d65 100644 --- a/Timeline/Loggable.C +++ b/Timeline/Loggable.C @@ -333,7 +333,7 @@ Loggable::snapshot( const char *file ) { FILE *ofp = _fp; - if ( ! ( _fp = fopen( file, "a" ) ) ) + if ( ! ( _fp = fopen( file, "w" ) ) ) { _fp = ofp; return false; @@ -352,6 +352,24 @@ Loggable::snapshot( const char *file ) return true; } +void +Loggable::compact ( void ) +{ + fclose( _fp ); + _fp = NULL; + + /* FIXME: don't use name here */ + snapshot( "history" ); + + if ( ! ( _fp = fopen( "history", "a+" ) ) ) + { + printf( "Could not open log file for writing!" ); +// return false; + } +} + + + void Loggable::log ( const char *fmt, ... ) { diff --git a/Timeline/Loggable.H b/Timeline/Loggable.H index 2079f50..dd806fe 100644 --- a/Timeline/Loggable.H +++ b/Timeline/Loggable.H @@ -95,6 +95,7 @@ public: static void undo ( void ); static int undo_index ( void ) { return _undo_index; } static bool snapshot( const char *file ); + static void compact( void ); static void diff --git a/Timeline/TLE.fl b/Timeline/TLE.fl index dbd2c00..0a4b835 100644 --- a/Timeline/TLE.fl +++ b/Timeline/TLE.fl @@ -10,6 +10,8 @@ decl {\#include "Engine.H"} {} decl {\#include "Transport.H"} {} +decl {\#include "Loggable.H"} {} + decl {\#include "Clock.H"} {public } @@ -17,6 +19,8 @@ decl {\#include "Waveform.H" // for options} {} decl {\#include "Control_Sequence.H" // for options} {} +decl {\#include } {} + decl {\#include } {} class TLE {open @@ -44,7 +48,7 @@ Fl::add_timeout( STATUS_UPDATE_FREQ, update_cb, this );} {} } { Fl_Window main_window { label {Non-DAW - Timeline} open - xywh {483 100 1024 768} type Double resizable xclass {Non-DAW} visible + xywh {581 446 1024 768} type Double resizable xclass {Non-DAW} visible } { Fl_Group {} {open xywh {0 0 1024 25} @@ -66,6 +70,12 @@ Fl::add_timeout( STATUS_UPDATE_FREQ, update_cb, this );} {} } MenuItem {} { label {&Compact} + callback {int n = fl_choice( "Compacting will replace the session history with a snapshot of the current state.\\n You will not be able to use Undo to go back beyond this point.\\n This operation is irreversible!", NULL, "Abort", "Procede with compaction" ); + +if ( n != 2 ) + return; + +Loggable::compact();} selected xywh {20 20 40 25} } Submenu {} { @@ -253,7 +263,7 @@ timeline->redraw();} } } Submenu {} { - label {C&olors} open selected + label {C&olors} open xywh {0 0 74 25} } { MenuItem {} { diff --git a/Timeline/Timeline.C b/Timeline/Timeline.C index d203769..bf22110 100644 --- a/Timeline/Timeline.C +++ b/Timeline/Timeline.C @@ -766,11 +766,11 @@ Timeline::handle ( int m ) Track *t = new Track( name ); - add_track( t ); - Sequence *o = new Audio_Sequence( t ); new Control_Sequence( t ); + add_track( t ); + t->track( o ); /* t->add( new Control_Sequence( t ); */ @@ -966,12 +966,16 @@ Timeline::total_input_buffer_percent ( void ) } } + if ( ! cnt ) + return 0; + return r / cnt; } int Timeline::total_output_buffer_percent ( void ) { + int r = 0; int cnt = 0; @@ -987,5 +991,8 @@ Timeline::total_output_buffer_percent ( void ) } } + if ( ! cnt ) + return 0; + return r / cnt; } diff --git a/Timeline/Track.H b/Timeline/Track.H index fe0f03c..1b84db1 100644 --- a/Timeline/Track.H +++ b/Timeline/Track.H @@ -143,9 +143,15 @@ public: { Sequence *t = (Sequence*)Loggable::find( i ); - assert( t ); - - track( t ); + /* FIXME: our track might not have been + * defined yet... what should we do about this + * chicken/egg problem? */ + if ( t ) + { +// assert( t ); + + track( t ); + } } } }