From 05ab03fb10ca34358f226f2cb7a92645e3dd9079 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Wed, 14 May 2008 19:48:46 -0500 Subject: [PATCH] Add LASH_Client interface class. --- Makefile | 10 ++-- Timeline/LASH_Client.C | 101 +++++++++++++++++++++++++++++++++++++++++ Timeline/LASH_Client.H | 49 ++++++++++++++++++++ Timeline/makefile.inc | 3 +- 4 files changed, 158 insertions(+), 5 deletions(-) create mode 100644 Timeline/LASH_Client.C create mode 100644 Timeline/LASH_Client.H diff --git a/Makefile b/Makefile index 7b4c48a..8bf680e 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,14 @@ - VERSION := 0.5.0 FLTK_LIBS := `fltk-config --ldflags` -JACK_LIBS := `pkg-config --libs jack` -SNDFILE_LIBS := `pkg-config --libs sndfile` +JACK_LIBS := `pkg-config --libs jack` +SNDFILE_LIBS := `pkg-config --libs sndfile` +LASH_LIBS := `pkg-config --libs lash-1.0` -CXXFLAGS := -DVERSION=\"$(VERSION)\" -ggdb -Wextra -Wno-missing-field-initializers -O0 -fno-rtti -fno-exceptions +LASH_CFLAGS := `pkg-config --cflags lash-1.0` + +CXXFLAGS := $(LASH_CFLAGS) -DVERSION=\"$(VERSION)\" -ggdb -Wextra -Wno-missing-field-initializers -O0 -fno-rtti -fno-exceptions all: makedepend FL Timeline Mixer diff --git a/Timeline/LASH_Client.C b/Timeline/LASH_Client.C new file mode 100644 index 0000000..ab53dd5 --- /dev/null +++ b/Timeline/LASH_Client.C @@ -0,0 +1,101 @@ + +/*******************************************************************************/ +/* 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. */ +/*******************************************************************************/ + +#include "LASH_Client.H" + +#include + +#define _client (static_cast(_void)) + +#include "debug.h" + +LASH_Client::LASH_Client ( ) +{ + _void = NULL; +} + +LASH_Client::~LASH_Client ( ) +{ + /* TODO: anything? */ +} + +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; + + /* register name */ + lash_jack_client_name( _client, jack_name ); + + lash_event_t *e = lash_event_new_with_type( LASH_Client_Name ); + lash_event_set_string( e, long_name ); + lash_send_event( _client, e ); + + return true; +} + +/** process any queued events */ +void +LASH_Client::poll ( void ) +{ + lash_event_t *e; + + while ( ( e = lash_get_event( _client ) ) ) + { + const char *name = lash_event_get_string( e ); + + switch ( lash_event_get_type( e ) ) + { + 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 ) ); + + break; + + } + case LASH_Restore_File: + { + MESSAGE( "LASH wants us to load \"%s\"", name ); + + if ( ! handle_load_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 ) ); + + break; + } + case LASH_Quit: + MESSAGE( "LASH wants us to quit" ); + handle_quit(); + break; + default: + WARNING( "unhandled LASH event" ); + } + + lash_event_destroy( e ); + } +} diff --git a/Timeline/LASH_Client.H b/Timeline/LASH_Client.H new file mode 100644 index 0000000..5c21ea5 --- /dev/null +++ b/Timeline/LASH_Client.H @@ -0,0 +1,49 @@ + +/*******************************************************************************/ +/* 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. */ +/*******************************************************************************/ + + +/* generic master class for interfacing with LASH... */ + +#pragma once + +class LASH_Client +{ + /* to avoid including the lash header here... */ + void *_void; + +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; + +public: + + LASH_Client ( ); + virtual ~LASH_Client ( ); + + bool init ( const char *jack_name, const char *full_name, int *argc, char ***argv ); + void poll ( void ); + + void project_save ( void ); + void project_quit ( void ); + + /* TODO: project_add, project_remove, project_dir, project_name, percentage */ + +}; diff --git a/Timeline/makefile.inc b/Timeline/makefile.inc index 68de35b..1a0b30f 100644 --- a/Timeline/makefile.inc +++ b/Timeline/makefile.inc @@ -3,6 +3,7 @@ Timeline_VERSION := 0.5.0 Timeline_SRCS= \ +Timeline/LASH_Client.C \ Timeline/Annotation_Region.C \ Timeline/Audio_File.C \ Timeline/Audio_File_SF.C \ @@ -40,7 +41,7 @@ Timeline_OBJS:=$(Timeline_SRCS:.C=.o) $(Timeline_OBJS): Makefile -Timeline_LIBS := $(FLTK_LIBS) $(JACK_LIBS) $(SNDFILE_LIBS) +Timeline_LIBS := $(FLTK_LIBS) $(JACK_LIBS) $(SNDFILE_LIBS) $(LASH_LIBS) Timeline/timeline: $(Timeline_OBJS) FL $(CXX) $(CXXFLAGS) $(INCLUDES) $(Timeline_LIBS) $(Timeline_OBJS) -o $@ -LFL -lfl_widgets