Actually update buffer and dsp percentages in GUI.

This commit is contained in:
Jonathan Moore Liles 2008-04-23 00:35:49 -05:00
parent 6cc26446b6
commit 8622209fe1
5 changed files with 83 additions and 7 deletions

View File

@ -50,7 +50,8 @@
/* TODO: read/write data from/to disk in larger chunks to avoid
* excessive seeking. 256k is supposedly the sweetspot. */
float Disk_Stream::seconds_to_buffer = 5.0f;
//float Disk_Stream::seconds_to_buffer = 5.0f;
float Disk_Stream::seconds_to_buffer = 2.0f;
// size_t Disk_Stream::disk_block_frames = 2048;
Disk_Stream::Disk_Stream ( Track *th, float frame_rate, nframes_t nframes, int channels ) : _th( th )

View File

@ -64,6 +64,7 @@ public:
nframes_t nframes ( void ) const { return jack_get_buffer_size( _client ); }
float frame_rate ( void ) const { return jack_get_sample_rate( _client ); }
float cpu_load ( void ) const { return jack_cpu_load( _client ); }
};

View File

@ -2,8 +2,13 @@
version 1.0108
header_name {.H}
code_name {.C}
decl {const float STATUS_UPDATE_FREQ = 0.5f;} {}
decl {\#include "Timeline.H"} {}
decl {\#include "Engine.H"} {selected
}
decl {\#include "Transport.H"} {}
decl {\#include "Clock.H"} {public
@ -21,7 +26,10 @@ class TLE {open
Fl::visible_focus( 0 );
Fl::get_system_colors();
Fl::scheme( "plastic" );} {}
Fl::scheme( "plastic" );
Fl::add_timeout( STATUS_UPDATE_FREQ, update_cb, this );} {}
}
Function {make_window()} {open
} {
@ -32,7 +40,7 @@ Fl::scheme( "plastic" );} {}
Fl_Group {} {open
xywh {0 0 1024 25}
} {}
Fl_Menu_Bar {} {open
Fl_Menu_Bar {} {
xywh {0 0 1024 25}
} {
Submenu {} {
@ -233,7 +241,7 @@ Fl::scheme( "plastic" );} {}
xywh {139 25 285 46} type HORIZONTAL
} {
Fl_Box playhead_clock {
label PLAYHEAD selected
label PLAYHEAD
xywh {139 29 137 40} box BORDER_BOX color 46
code0 {o->type( Clock::HMS );}
code1 {o->run( &transport->frame );}
@ -247,15 +255,15 @@ Fl::scheme( "plastic" );} {}
}
}
Fl_Progress capture_buffer_progress {
label {c:}
label {capture:}
xywh {925 26 99 14} labelsize 10 align 4
}
Fl_Progress dsp_usage_progress {
Fl_Progress cpu_load_progress {
label {DSP:}
xywh {925 55 99 16} labelsize 9 align 4
}
Fl_Progress playback_buffer_progress {
label {p:}
label {playback:}
xywh {925 40 99 14} labelsize 10 align 4
}
Fl_Box {} {
@ -265,4 +273,21 @@ Fl::scheme( "plastic" );} {}
}
}
}
Function {update_status()} {open
} {
code {capture_buffer_progress->value( timeline->total_input_buffer_percent() );
playback_buffer_progress->value( timeline->total_output_buffer_percent() );
cpu_load_progress->value( engine->cpu_load() );
// TODO: dsp} {}
}
Function {update_cb( void *v )} {open return_type {static void}
} {
code {Fl::repeat_timeout( STATUS_UPDATE_FREQ, update_cb, v );
((TLE*)v)->update_status();} {}
}
}
Function {make_window()} {open
} {}

View File

@ -35,6 +35,7 @@ const float UPDATE_FREQ = 0.02f;
#include "Playback_DS.H"
#include "Record_DS.H"
#include "Transport.H"
@ -895,3 +896,47 @@ Timeline::seek_pending ( void )
r += t->playback_ds->buffer_percent() < 50;
}
}
/* FIXME: shouldn't these belong to the engine? */
int
Timeline::total_input_buffer_percent ( void )
{
int r = 0;
int cnt = 0;
for ( int i = tracks->children(); i-- ; )
{
Track *t = (Track*)tracks->child( i );
if ( t->record_ds )
{
++cnt;
r += t->record_ds->buffer_percent();
}
}
return r / cnt;
}
int
Timeline::total_output_buffer_percent ( void )
{
int r = 0;
int cnt = 0;
for ( int i = tracks->children(); i-- ; )
{
Track *t = (Track*)tracks->child( i );
if ( t->playback_ds )
{
++cnt;
r += t->playback_ds->buffer_percent();
}
}
return r / cnt;
}

View File

@ -155,6 +155,10 @@ public:
void add_track ( Track *track );
void remove_track ( Track *track );
int total_input_buffer_percent ( void );
int total_output_buffer_percent ( void );
private:
friend class Engine; // FIXME: only Engine::process() needs to be friended.x