diff options
author | David Robillard <d@drobilla.net> | 2006-06-10 02:43:54 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-06-10 02:43:54 +0000 |
commit | 47246db7e9d71ba694b719001033fba1766a58c4 (patch) | |
tree | 25614ea4f2c92033a3cd37f6413df742f09a5369 /src/progs/om | |
parent | 98fe0e7056e6697396249531785d3899f94d79be (diff) | |
download | ingen-47246db7e9d71ba694b719001033fba1766a58c4.tar.gz ingen-47246db7e9d71ba694b719001033fba1766a58c4.tar.bz2 ingen-47246db7e9d71ba694b719001033fba1766a58c4.zip |
More juggling
git-svn-id: http://svn.drobilla.net/lad/grauph@16 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/progs/om')
-rw-r--r-- | src/progs/om/Makefile.am | 254 | ||||
-rw-r--r-- | src/progs/om/cmdline.c | 150 | ||||
-rw-r--r-- | src/progs/om/cmdline.ggo | 7 | ||||
-rw-r--r-- | src/progs/om/cmdline.h | 45 | ||||
-rw-r--r-- | src/progs/om/main.cpp | 153 |
5 files changed, 374 insertions, 235 deletions
diff --git a/src/progs/om/Makefile.am b/src/progs/om/Makefile.am index ae0b3e53..2f503130 100644 --- a/src/progs/om/Makefile.am +++ b/src/progs/om/Makefile.am @@ -1,232 +1,15 @@ -SUBDIRS = tests -DIST_SUBDIRS = events - -AM_CXXFLAGS = @JACK_CFLAGS@ @LOSC_CFLAGS@ @ALSA_CFLAGS@ @LASH_CFLAGS@ @SLV2_CFLAGS@ -I$(top_srcdir)/src/common -I$(top_srcdir)/src/engine/events -fno-exceptions -fno-rtti +AM_CXXFLAGS = @JACK_CFLAGS@ @LOSC_CFLAGS@ @ALSA_CFLAGS@ @LASH_CFLAGS@ @SLV2_CFLAGS@ -I$(top_srcdir)/src/common -I$(top_srcdir)/src/engine -I$(top_srcdir)/src/engine/events -fno-exceptions -fno-rtti MAINTAINERCLEANFILES = Makefile.in -common_SOURCES = \ - util.h \ - tuning.h \ - Node.h \ - NodeBase.h \ - NodeBase.cpp \ - InternalNode.h \ - Patch.h \ - Patch.cpp \ - NodeFactory.h \ - NodeFactory.cpp \ - Om.h \ - Om.cpp \ - OmApp.h \ - OmApp.cpp \ - JackAudioDriver.h \ - JackAudioDriver.cpp \ - OSCReceiver.h \ - OSCReceiver.cpp \ - Responder.h \ - OSCResponder.h \ - OSCResponder.cpp \ - ClientKey.h \ - ClientBroadcaster.h \ - ClientBroadcaster.cpp \ - ObjectSender.h \ - ObjectSender.cpp \ - OSCClient.h \ - OSCClient.cpp \ - Buffer.h \ - Buffer.cpp \ - Port.h \ - Port.cpp \ - PortBase.h \ - PortBase.cpp \ - InputPort.h \ - InputPort.cpp \ - OutputPort.h \ - OutputPort.cpp \ - MidiMessage.h \ - MidiNoteNode.h \ - MidiNoteNode.cpp \ - MidiTriggerNode.h \ - MidiTriggerNode.cpp \ - MidiControlNode.h \ - MidiControlNode.cpp \ - BridgeNode.h \ - BridgeNode.cpp \ - ControlInputNode.h \ - ControlInputNode.cpp \ - ControlOutputNode.h \ - ControlOutputNode.cpp \ - AudioInputNode.h \ - AudioInputNode.cpp \ - AudioOutputNode.h \ - AudioOutputNode.cpp \ - MidiInputNode.h \ - MidiInputNode.cpp \ - MidiOutputNode.h \ - MidiOutputNode.cpp \ - Event.h \ - Event.cpp \ - QueuedEvent.h \ - EventSource.h \ - QueuedEventSource.h \ - QueuedEventSource.cpp \ - QueuedEngineInterface.h \ - QueuedEngineInterface.cpp \ - OmObject.h \ - Maid.h \ - Maid.cpp \ - MaidObject.h \ - Tree.h \ - ClientRecord.h \ - PortInfo.h \ - PluginLibrary.h \ - Plugin.h \ - Array.h \ - List.h \ - PostProcessor.h \ - PostProcessor.cpp \ - Connection.h \ - Connection.cpp \ - ConnectionBase.h \ - ConnectionBase.cpp \ - ObjectStore.h \ - ObjectStore.cpp \ - TransportNode.h \ - TransportNode.cpp \ - Driver.h \ - AudioDriver.h \ - MidiDriver.h \ - midi.h \ - ../common/util/Semaphore.h \ - ../common/util/types.h \ - ../common/util/Path.h \ - ../common/util/Queue.h \ - ../common/interface/ClientInterface.h \ - ../common/interface/EngineInterface.h \ - instantiations.cpp - -# Events -common_SOURCES += \ - events/RegisterClientEvent.h \ - events/RegisterClientEvent.cpp \ - events/UnregisterClientEvent.h \ - events/UnregisterClientEvent.cpp \ - events/PingQueuedEvent.h \ - events/ActivateEvent.h \ - events/ActivateEvent.cpp \ - events/DeactivateEvent.h \ - events/DeactivateEvent.cpp \ - events/SetPortValueEvent.h \ - events/SetPortValueEvent.cpp \ - events/SetPortValueQueuedEvent.h \ - events/SetPortValueQueuedEvent.cpp \ - events/NoteOnEvent.h \ - events/NoteOnEvent.cpp \ - events/NoteOffEvent.h \ - events/NoteOffEvent.cpp \ - events/AllNotesOffEvent.h \ - events/AllNotesOffEvent.cpp \ - events/ConnectionEvent.h \ - events/ConnectionEvent.cpp \ - events/DisconnectionEvent.h \ - events/DisconnectionEvent.cpp \ - events/DisconnectNodeEvent.h \ - events/DisconnectNodeEvent.cpp \ - events/DisconnectPortEvent.h \ - events/DisconnectPortEvent.cpp \ - events/DestroyEvent.h \ - events/DestroyEvent.cpp \ - events/AddNodeEvent.h \ - events/AddNodeEvent.cpp \ - events/SetMetadataEvent.h \ - events/SetMetadataEvent.cpp \ - events/RequestMetadataEvent.h \ - events/RequestMetadataEvent.cpp \ - events/RequestPortValueEvent.h \ - events/RequestPortValueEvent.cpp \ - events/RequestAllObjectsEvent.h \ - events/RequestAllObjectsEvent.cpp \ - events/RequestPluginsEvent.h \ - events/RequestPluginsEvent.cpp \ - events/CreatePatchEvent.h \ - events/CreatePatchEvent.cpp \ - events/LoadPluginsEvent.h \ - events/LoadPluginsEvent.cpp \ - events/EnablePatchEvent.h \ - events/EnablePatchEvent.cpp \ - events/DisablePatchEvent.h \ - events/DisablePatchEvent.cpp \ - events/ClearPatchEvent.h \ - events/ClearPatchEvent.cpp \ - events/RenameEvent.h \ - events/RenameEvent.cpp \ - events/MidiLearnEvent.h \ - events/MidiLearnEvent.cpp - -if WITH_JACK_MIDI -common_SOURCES += \ - JackMidiDriver.h \ - JackMidiDriver.cpp -endif - -if WITH_ALSA_MIDI -common_SOURCES += \ - AlsaMidiDriver.h \ - AlsaMidiDriver.cpp -endif - -if WITH_LADSPA -common_SOURCES += \ - LADSPAPlugin.h \ - LADSPAPlugin.cpp -endif - -if WITH_DSSI -common_SOURCES += \ - DSSIPlugin.h \ - DSSIPlugin.cpp \ - events/DSSIConfigureEvent.cpp \ - events/DSSIConfigureEvent.h \ - events/DSSIControlEvent.cpp \ - events/DSSIControlEvent.h \ - events/DSSIProgramEvent.cpp \ - events/DSSIProgramEvent.h \ - events/DSSIUpdateEvent.cpp \ - events/DSSIUpdateEvent.h -endif - -if WITH_LV2 -common_SOURCES += \ - LV2Plugin.h \ - LV2Plugin.cpp -endif - -if WITH_LASH -common_SOURCES += \ - LashDriver.h \ - LashDriver.cpp \ - LashRestoreDoneEvent.h -endif - - -# -# Non-installed library to link stand-alone and in-process build against -# - -noinst_LTLIBRARIES = libom.la -libom_la_SOURCES = $(common_SOURCES) - - - # # Stand-alone engine # if BUILD_ENGINE bin_PROGRAMS = om -om_DEPENDENCIES = libom.la -om_LDADD = @JACK_LIBS@ @LOSC_LIBS@ @ALSA_LIBS@ @LASH_LIBS@ @SLV2_LIBS@ -lrt libom.la +om_DEPENDENCIES = ../../libs/engine/libom.la +om_LDADD = @JACK_LIBS@ @LOSC_LIBS@ @ALSA_LIBS@ @LASH_LIBS@ @SLV2_LIBS@ -lrt ../../libs/engine/libom.la om_SOURCES = \ main.cpp \ @@ -236,24 +19,25 @@ om_SOURCES = \ endif # BUILD_ENGINE - +## +## Jack internal client +## +#if BUILD_IN_PROCESS_ENGINE # -# Jack internal client # -if BUILD_IN_PROCESS_ENGINE - - -# FIXME: broken - - -# FIXME: Figure out how to get this properly -omdir = $(prefix)/lib/jack +## FIXME: broken +# +# +## FIXME: Figure out how to get this properly +#omdir = $(prefix)/lib/jack +# +#om_la_CFLAGS = -fPIC +#om_LTLIBRARIES = om.la +#om_la_LDFLAGS = -module -avoid-version @JACK_LIBS@ @LOSC_LIBS@ @ALSA_LIBS@ @LASH_LIBS@ @SLV2_LIBS@ +#om_la_SOURCES = OmInProcess.cpp +# +#endif # BUILD_IN_PROCESS_ENGINE -om_la_CFLAGS = -fPIC -om_LTLIBRARIES = om.la -om_la_LDFLAGS = -module -avoid-version @JACK_LIBS@ @LOSC_LIBS@ @ALSA_LIBS@ @LASH_LIBS@ @SLV2_LIBS@ -om_la_SOURCES = OmInProcess.cpp -endif # BUILD_IN_PROCESS_ENGINE diff --git a/src/progs/om/cmdline.c b/src/progs/om/cmdline.c new file mode 100644 index 00000000..6b7ddf6a --- /dev/null +++ b/src/progs/om/cmdline.c @@ -0,0 +1,150 @@ +/* + File autogenerated by gengetopt version 2.10 + generated with the following command: + gengetopt + + The developers of gengetopt consider the fixed text that goes in all + gengetopt output files to be in the public domain: + we make no copyright claims on it. +*/ + + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +/* If we use autoconf. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "getopt.h" + +#include "cmdline.h" + +void +cmdline_parser_print_version (void) +{ + printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); +} + +void +cmdline_parser_print_help (void) +{ + cmdline_parser_print_version (); + printf("\n" + "Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE); + printf(" -h --help Print help and exit\n"); + printf(" -V --version Print version and exit\n"); + printf(" -pSTRING --port=STRING OSC port to listen on (default='16180')\n"); + printf(" -i --in-jackd Run engine as in-process JACK client (default=off)\n"); +} + + +static char *gengetopt_strdup (const char *s); + +/* gengetopt_strdup() */ +/* strdup.c replacement of strdup, which is not standard */ +char * +gengetopt_strdup (const char *s) +{ + char *result = (char*)malloc(strlen(s) + 1); + if (result == (char*)0) + return (char*)0; + strcpy(result, s); + return result; +} + +int +cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) +{ + int c; /* Character of the parsed option. */ + int missing_required_options = 0; + + args_info->help_given = 0 ; + args_info->version_given = 0 ; + args_info->port_given = 0 ; + args_info->in_jackd_given = 0 ; +#define clear_args() { \ + args_info->port_arg = gengetopt_strdup("16180") ;\ + args_info->in_jackd_flag = 0;\ +} + + clear_args(); + + optarg = 0; + optind = 1; + opterr = 1; + optopt = '?'; + + while (1) + { + int option_index = 0; + char *stop_char; + + static struct option long_options[] = { + { "help", 0, NULL, 'h' }, + { "version", 0, NULL, 'V' }, + { "port", 1, NULL, 'p' }, + { "in-jackd", 0, NULL, 'i' }, + { NULL, 0, NULL, 0 } + }; + + stop_char = 0; + c = getopt_long (argc, argv, "hVp:i", long_options, &option_index); + + if (c == -1) break; /* Exit from `while (1)' loop. */ + + switch (c) + { + case 'h': /* Print help and exit. */ + clear_args (); + cmdline_parser_print_help (); + exit (EXIT_SUCCESS); + + case 'V': /* Print version and exit. */ + clear_args (); + cmdline_parser_print_version (); + exit (EXIT_SUCCESS); + + case 'p': /* OSC port to listen on. */ + if (args_info->port_given) + { + fprintf (stderr, "%s: `--port' (`-p') option given more than once\n", CMDLINE_PARSER_PACKAGE); + clear_args (); + exit (EXIT_FAILURE); + } + args_info->port_given = 1; + args_info->port_arg = gengetopt_strdup (optarg); + break; + + case 'i': /* Run engine as in-process JACK client. */ + if (args_info->in_jackd_given) + { + fprintf (stderr, "%s: `--in-jackd' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE); + clear_args (); + exit (EXIT_FAILURE); + } + args_info->in_jackd_given = 1; + args_info->in_jackd_flag = !(args_info->in_jackd_flag); + break; + + + case 0: /* Long option with no short option */ + + case '?': /* Invalid option. */ + /* `getopt_long' already printed an error message. */ + exit (EXIT_FAILURE); + + default: /* bug: option not considered. */ + fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c); + abort (); + } /* switch */ + } /* while */ + + + if ( missing_required_options ) + exit (EXIT_FAILURE); + + return 0; +} diff --git a/src/progs/om/cmdline.ggo b/src/progs/om/cmdline.ggo new file mode 100644 index 00000000..8c006ca7 --- /dev/null +++ b/src/progs/om/cmdline.ggo @@ -0,0 +1,7 @@ +# Process this file with gengetopt -u to generate the necessary code (in cmdline.h, cmdline.c) + +package "Om - An OSC controlled realtime modular synthesizer" + +option "port" p "OSC port to listen on" string default="16180" no +option "in-jackd" i "Run engine as in-process JACK client" flag off + diff --git a/src/progs/om/cmdline.h b/src/progs/om/cmdline.h new file mode 100644 index 00000000..fe36a969 --- /dev/null +++ b/src/progs/om/cmdline.h @@ -0,0 +1,45 @@ +/* cmdline.h */ + +/* File autogenerated by gengetopt version 2.10 */ + +#ifndef CMDLINE_H +#define CMDLINE_H + +/* If we use autoconf. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef CMDLINE_PARSER_PACKAGE +#define CMDLINE_PARSER_PACKAGE "Om - An OSC controlled realtime modular synthesizer" +#endif + +#ifndef CMDLINE_PARSER_VERSION +#define CMDLINE_PARSER_VERSION VERSION +#endif + +struct gengetopt_args_info +{ + char * port_arg; /* OSC port to listen on (default='16180'). */ + int in_jackd_flag; /* Run engine as in-process JACK client (default=off). */ + + int help_given ; /* Whether help was given. */ + int version_given ; /* Whether version was given. */ + int port_given ; /* Whether port was given. */ + int in_jackd_given ; /* Whether in-jackd was given. */ + +} ; + +int cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info); + +void cmdline_parser_print_help(void); +void cmdline_parser_print_version(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* CMDLINE_H */ diff --git a/src/progs/om/main.cpp b/src/progs/om/main.cpp new file mode 100644 index 00000000..a69c7e76 --- /dev/null +++ b/src/progs/om/main.cpp @@ -0,0 +1,153 @@ +/* This file is part of Om. Copyright (C) 2006 Dave Robillard. + * + * Om 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. + * + * Om 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 details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <iostream> +#include <cstddef> +#include <signal.h> +#include "config.h" +#include "util.h" +#include "cmdline.h" +#include "Om.h" +#include "OmApp.h" +#ifdef HAVE_LASH +#include "LashDriver.h" +#endif +#ifdef BUILD_IN_PROCESS_ENGINE +#include <jack/jack.h> +#include <jack/intclient.h> +#endif + +using std::cout; using std::endl; using std::cerr; + + +void +catch_int(int) +{ + signal(SIGINT, catch_int); + signal(SIGTERM, catch_int); + + std::cout << "[Main] Om interrupted." << std::endl; + Om::om->quit(); +} + + +#ifdef BUILD_IN_PROCESS_ENGINE + +jack_client_t* jack_client; +jack_intclient_t jack_intclient; + + +void +unload_in_process_engine(int) +{ + jack_status_t status; + int ret = EXIT_SUCCESS; + + cout << "Unloading..."; + status = jack_internal_client_unload(jack_client, jack_intclient); + if (status & JackFailure) { + cout << "failed" << endl; + ret = EXIT_FAILURE; + } else { + cout << "done" << endl; + } + jack_client_close(jack_client); + exit(ret); +} + + +int +load_in_process_engine(const char* port) +{ + int ret = EXIT_SUCCESS; + + jack_status_t status; + + if ((jack_client = jack_client_open("om_load", JackNoStartServer, + &status)) != NULL) { + jack_intclient = + jack_internal_client_load(jack_client, "Om", + (jack_options_t)(JackLoadName|JackLoadInit), + &status, "om", port); + if (status == 0) { + cout << "Engine loaded" << endl; + signal(SIGINT, unload_in_process_engine); + signal(SIGTERM, unload_in_process_engine); + + while (1) { + sleep(1); + } + } else if (status & JackFailure) { + cerr << "Could not load om.so" << endl; + ret = EXIT_FAILURE; + } + + jack_client_close(jack_client); + } else { + cerr << "jack_client_open failed" << endl; + ret = EXIT_FAILURE; + } +} + +#endif // BUILD_IN_PROCESS_ENGINE + + +int +main(int argc, char** argv) +{ +#ifdef HAVE_LASH + lash_args_t* lash_args = lash_extract_args(&argc, &argv); +#endif + + int ret = EXIT_SUCCESS; + + /* Parse command line options */ + gengetopt_args_info args_info; + if (cmdline_parser (argc, argv, &args_info) != 0) + return EXIT_FAILURE; + + + if (args_info.in_jackd_flag) { +#ifdef BUILD_IN_PROCESS_ENGINE + ret = load_in_process_engine(args_info.port_arg); +#else + cerr << "In-process Jack client support not enabled in this build." << endl; + ret = EXIT_FAILURE; +#endif // JACK_IN_PROCESS_ENGINE + } else { + signal(SIGINT, catch_int); + signal(SIGTERM, catch_int); + + Om::set_denormal_flags(); + + Om::om = new Om::OmApp(args_info.port_arg); + +#ifdef HAVE_LASH + Om::lash_driver = new Om::LashDriver(Om::om, lash_args); +#endif + + Om::om->main(); + +#ifdef HAVE_LASH + delete Om::lash_driver; +#endif + + delete Om::om; + } + + return ret; +} + |