From 71c75ff48a9e5f95130b1e15c3a804880e053745 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Wed, 14 May 2008 20:10:49 -0500 Subject: [PATCH] Continue integrating LASH support. --- Timeline/LASH.C | 56 ++++++++++++++++++++++++++++++++++++++++++ Timeline/LASH.H | 36 +++++++++++++++++++++++++++ Timeline/LASH_Client.C | 9 +------ Timeline/LASH_Client.H | 4 +-- Timeline/main.C | 19 ++++++++++++++ Timeline/makefile.inc | 1 + 6 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 Timeline/LASH.C create mode 100644 Timeline/LASH.H diff --git a/Timeline/LASH.C b/Timeline/LASH.C new file mode 100644 index 0000000..641c8de --- /dev/null +++ b/Timeline/LASH.C @@ -0,0 +1,56 @@ + +/*******************************************************************************/ +/* Copyright (C) 2008 Jonathan Moore Liles */ +/* */ +/* This program is free software; you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation; either version 2 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ +/* more details. */ +/* */ +/* You should have received a copy of the GNU General Public License along */ +/* with This program; see the file COPYING. If not,write to the Free Software */ +/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/*******************************************************************************/ + +/* actual implementation of our side of the LASH protocol */ + +#include "LASH.H" + +#include "debug.h" + + +LASH::LASH ( ) +{ +} + +LASH::~LASH ( ) +{ +} + + +bool +LASH::handle_save_file ( const char *path ) +{ + MESSAGE( "LASH wants us to save \"%s\"", path ); + + return true; +} + +bool +LASH::handle_restore_file ( const char *path ) +{ + MESSAGE( "LASH wants us to load \"%s\"", path ); + + return true; +} + +void +LASH::handle_quit ( void ) +{ + MESSAGE( "LASH wants us to quit" ); +} diff --git a/Timeline/LASH.H b/Timeline/LASH.H new file mode 100644 index 0000000..8e23ed3 --- /dev/null +++ b/Timeline/LASH.H @@ -0,0 +1,36 @@ + +/*******************************************************************************/ +/* Copyright (C) 2008 Jonathan Moore Liles */ +/* */ +/* This program is free software; you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation; either version 2 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ +/* more details. */ +/* */ +/* You should have received a copy of the GNU General Public License along */ +/* with This program; see the file COPYING. If not,write to the Free Software */ +/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/*******************************************************************************/ + +#pragma once + +#include "LASH_Client.H" + +class LASH : public LASH_Client +{ + +public: + + LASH ( ); + ~LASH ( ); + + bool handle_save_file ( const char *path ); + bool handle_restore_file ( const char *path ); + void handle_quit ( void ); + +}; diff --git a/Timeline/LASH_Client.C b/Timeline/LASH_Client.C index ab53dd5..982ec7c 100644 --- a/Timeline/LASH_Client.C +++ b/Timeline/LASH_Client.C @@ -38,8 +38,6 @@ LASH_Client::~LASH_Client ( ) bool LASH_Client::init ( const char *jack_name, const char *long_name, int *argc, char ***argv ) { - MESSAGE( "Initializing LASH" ); - if ( ! ( _void = lash_init( lash_extract_args( argc, argv ), jack_name, LASH_Config_File, LASH_PROTOCOL( 2, 0 ) ) ) ) return false; @@ -68,8 +66,6 @@ LASH_Client::poll ( void ) { case LASH_Save_File: { - MESSAGE( "LASH wants us to save \"%s\"", name ); - handle_save_file( name ); lash_send_event( _client, lash_event_new_with_type( LASH_Save_File ) ); @@ -79,9 +75,7 @@ LASH_Client::poll ( void ) } case LASH_Restore_File: { - MESSAGE( "LASH wants us to load \"%s\"", name ); - - if ( ! handle_load_file( name ) ) + if ( ! handle_restore_file( name ) ) /* FIXME: should we tell lash that we couldn't load the song? */; lash_send_event( _client, lash_event_new_with_type( LASH_Restore_File ) ); @@ -89,7 +83,6 @@ LASH_Client::poll ( void ) break; } case LASH_Quit: - MESSAGE( "LASH wants us to quit" ); handle_quit(); break; default: diff --git a/Timeline/LASH_Client.H b/Timeline/LASH_Client.H index 5c21ea5..9de1af3 100644 --- a/Timeline/LASH_Client.H +++ b/Timeline/LASH_Client.H @@ -29,9 +29,9 @@ class LASH_Client protected: - virtual bool handle_load_file ( const char *path ) = 0; virtual bool handle_save_file ( const char *path ) = 0; - virtual bool handle_quit ( void ) = 0; + virtual bool handle_restore_file ( const char *path ) = 0; + virtual void handle_quit ( void ) = 0; public: diff --git a/Timeline/main.C b/Timeline/main.C index 7105486..7e67f59 100644 --- a/Timeline/main.C +++ b/Timeline/main.C @@ -51,9 +51,12 @@ #include "Project.H" +#include "LASH.H" + Engine *engine; Timeline *timeline; Transport *transport; +LASH *lash; /* TODO: put these in a header */ #define USER_CONFIG_DIR ".non-daw/" @@ -81,6 +84,15 @@ ensure_dirs ( void ) return r == 0 || errno == EEXIST; } +const float lash_poll_interval = 0.2f; + +static void +lash_cb ( void *arg ) +{ + lash->poll(); + + Fl::repeat_timeout( lash_poll_interval, lash_cb, 0 ); +} int main ( int argc, char **argv ) @@ -116,6 +128,13 @@ main ( int argc, char **argv ) * scenario requiring otherwise */ transport->stop(); + MESSAGE( "Initializing LASH" ); + lash = new LASH; + + lash->init( APP_NAME, APP_TITLE, &argc, &argv ); + + Fl::add_timeout( lash_poll_interval, lash_cb, 0 ); + if ( argc > 1 ) if ( ! Project::open( argv[ 1 ] ) ) FATAL( "Could not open project specified on command line" ); diff --git a/Timeline/makefile.inc b/Timeline/makefile.inc index 1a0b30f..acecfe6 100644 --- a/Timeline/makefile.inc +++ b/Timeline/makefile.inc @@ -3,6 +3,7 @@ Timeline_VERSION := 0.5.0 Timeline_SRCS= \ +Timeline/LASH.C \ Timeline/LASH_Client.C \ Timeline/Annotation_Region.C \ Timeline/Audio_File.C \