Browse Source

Work on moving journaling into engine process.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
db29b21d2c
5 changed files with 75 additions and 125 deletions
  1. +58
    -116
      Engine/Loggable.C
  2. +3
    -0
      Engine/Loggable.H
  3. +4
    -4
      Engine/Peaks.H
  4. +2
    -1
      Engine/Timeline_Server.C
  5. +8
    -4
      Engine/main.C

+ 58
- 116
Engine/Loggable.C View File

@@ -47,8 +47,11 @@ Loggable::open ( const char *filename )
return true; return true;
} }


/** sigh. parse a string of ":name value :name value" pairs into an array of strings, one per pair */
// FIXME: doesn't handle the case of :name ":foo bar". Also, quotes should be removed here, not in client code.
/** sigh. parse a string of ":name value :name value" pairs into an
* array of strings, one per pair */
// FIXME: doesn't handle the case of :name ":foo bar", nested quotes
// or other things it should. Also, quotes should be removed here, not
// in client code.
static static
char ** char **
parse_alist( const char *s ) parse_alist( const char *s )
@@ -108,68 +111,66 @@ void free_sa ( char **sa )
free( sa ); free( sa );
} }


/* void */
/* Loggable::redo ( const char *s ) */
/* { */
/* int id; */
/* sscanf( s, "%*s %X ", &id ); */
/* Loggable *l = find( id ); */
/* // assert( l ); */

/* char classname[40]; */
/* char command[40]; */
/* char *arguments; */

/* sscanf( s, "%s %*X %s %*[^\n<] << %a[^\n]", classname, command, &arguments ); */


/* int ui = _undo_index; */


/* if ( ! l ) */
/* { */
/* printf( "corrupt undo?\n" ); */
/* abort(); */
/* } */


/** 'do' a message like "Region 0xF1 set :r 123" */
bool
Loggable::do_this ( const char *s, bool reverse )
{
int id;
sscanf( s, "%*s %X ", &id );
Loggable *l = find( id );
// assert( l );


/* if ( ! strcmp( command, "destroy" ) ) */
/* { */
/* char **sa = parse_alist( arguments ); */
char classname[40];
char command[40];
char *arguments;


/* if ( ! _class_map[ string( classname ) ] ) */
/* printf( "error class %s is unregistered!\n", classname ); */
/* else */
/* { */
/* /\* create *\/ */
/* Loggable *l = _class_map[ string( classname ) ]( sa ); */
/* l->update_id( id ); */
/* } */
/* } */
/* else */
/* if ( ! strcmp( command, "set" ) ) */
/* { */
const char *create, *destroy;


/* printf( "got set command.\n" ); */
if ( reverse )
{
sscanf( s, "%s %*X %s %*[^\n<] %a[^\n]", classname, command, &arguments );
create = "destroy";
destroy = "create";
}
else
{
sscanf( s, "%s %*X %s %a[^\n<]", classname, command, &arguments );
create = "create";
destroy = "destroy";
}


/* char **sa = parse_alist( arguments ); */
if ( ! strcmp( command, destroy ) )
{
int id = l->id();
delete l;
_loggables[ id ] = NULL;
}
else if ( ! strcmp( command, "set" ) )
{
printf( "got set command.\n" );


/* l->log_start(); */
/* l->set( sa ); */
/* l->log_end(); */
char **sa = parse_alist( arguments );


/* } */
/* else */
/* if ( ! strcmp( command, "create" ) ) */
/* { */
/* int id = l->id(); */
/* delete l; */
/* _loggables[ id ] = NULL; */
/* } */
l->log_start();
l->set( sa );
l->log_end();
}
else if ( ! strcmp( command, create ) )
{
char **sa = parse_alist( arguments );


if ( ! _class_map[ string( classname ) ] )
printf( "error class %s is unregistered!\n", classname );
else
{
/* create */
Loggable *l = _class_map[ string( classname ) ]( sa );
l->update_id( id );
l->log_create();
}


/* } */
}
}


void void
Loggable::undo ( void ) Loggable::undo ( void )
@@ -210,16 +211,8 @@ Loggable::undo ( void )
} }
s++; s++;



buf[ len ] = NULL; buf[ len ] = NULL;



// fsync( fileno( _fp ) );
/* pop the entry off the end */

/* fseek( _fp, 0 - i, SEEK_END ); */
/* ftruncate( fileno( _fp ), ftell( _fp ) ); */

if ( ! strlen( s ) ) if ( ! strlen( s ) )
{ {
printf( "corrupt undo file or no undo entries.\n" ); printf( "corrupt undo file or no undo entries.\n" );
@@ -268,58 +261,7 @@ Loggable::undo ( void )


printf( "undoing \"%s\"\n", s ); printf( "undoing \"%s\"\n", s );


int id;
sscanf( s, "%*s %X ", &id );
Loggable *l = find( id );
// assert( l );

char classname[40];
char command[40];
char *arguments;

sscanf( s, "%s %*X %s %*[^\n<] << %a[^\n]", classname, command, &arguments );


/* if ( ! l ) */
/* { */
/* printf( "corrupt undo?\n" ); */
/* abort(); */
/* } */

if ( ! strcmp( command, "destroy" ) )
{
char **sa = parse_alist( arguments );

if ( ! _class_map[ string( classname ) ] )
printf( "error class %s is unregistered!\n", classname );
else
{
/* create */
Loggable *l = _class_map[ string( classname ) ]( sa );
l->update_id( id );
l->log_create();
}
}
else
if ( ! strcmp( command, "set" ) )
{

printf( "got set command.\n" );

char **sa = parse_alist( arguments );

l->log_start();
l->set( sa );
l->log_end();

}
else
if ( ! strcmp( command, "create" ) )
{
int id = l->id();
delete l;
_loggables[ id ] = NULL;
}
do_this( s, true );


s -= 2; s -= 2;
} }


+ 3
- 0
Engine/Loggable.H View File

@@ -156,6 +156,9 @@ public:
virtual void set ( char **sa ) = 0; virtual void set ( char **sa ) = 0;
// void log ( const char *module, const char *action, const char *fmt, ... ); // void log ( const char *module, const char *action, const char *fmt, ... );



static bool do_this ( const char *s, bool reverse );

protected: protected:


void log_start ( void ); void log_start ( void );


+ 4
- 4
Engine/Peaks.H View File

@@ -35,16 +35,16 @@ class Peaks


struct peakdata { struct peakdata {


int chunksize; /* should always be a power of 2 */
int chunksize; /* should always be a power of 2 */
Peak data[]; Peak data[];


}; };


struct peakbuffer { struct peakbuffer {


size_t size; /* total allocation size */
size_t len; /* number of peaks */
nframes_t offset; /* starting sample */
size_t size; /* total allocation size */
size_t len; /* number of peaks */
nframes_t offset; /* starting sample */


peakdata *buf; peakdata *buf;




+ 2
- 1
Engine/Timeline_Server.C View File

@@ -31,7 +31,6 @@


/* Timeline Server. /* Timeline Server.



The timeline server runs in its own thread and manages communication The timeline server runs in its own thread and manages communication
between the engine and any connected timeline editors. between the engine and any connected timeline editors.


@@ -71,5 +70,7 @@ Timeline_Server::handle_request ( int s, const char *buf, int l )
{ {
printf( "request: %s", buf ); printf( "request: %s", buf );


// Loggable::do( buf );

send( s, "fuckoff\n", strlen( "fuckoff\n" ), 0 ); send( s, "fuckoff\n", strlen( "fuckoff\n" ), 0 );
} }

+ 8
- 4
Engine/main.C View File

@@ -62,12 +62,16 @@ int
main ( int argc, char **argv ) main ( int argc, char **argv )
{ {


/* Timeline_Server tls( 6110 ); */
if ( ! fork() )
{
Peak_Server pks( 6111 );


/* tls.run(); */
pks.run();
exit( 0 );
}


Timeline_Server tls( 6110 );


Peak_Server pks( 6111 );
tls.run();


pks.run();
} }

Loading…
Cancel
Save