diff options
Diffstat (limited to 'src/libs/engine')
-rw-r--r-- | src/libs/engine/Makefile.am | 83 | ||||
-rw-r--r-- | src/libs/engine/cmdline.c | 150 | ||||
-rw-r--r-- | src/libs/engine/cmdline.ggo | 7 | ||||
-rw-r--r-- | src/libs/engine/cmdline.h | 45 | ||||
-rw-r--r-- | src/libs/engine/main.cpp | 153 |
5 files changed, 17 insertions, 421 deletions
diff --git a/src/libs/engine/Makefile.am b/src/libs/engine/Makefile.am index ae0b3e53..3b425ba2 100644 --- a/src/libs/engine/Makefile.am +++ b/src/libs/engine/Makefile.am @@ -1,11 +1,13 @@ 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/libom_la -I$(top_srcdir)/src/engine/events -fno-exceptions -fno-rtti MAINTAINERCLEANFILES = Makefile.in -common_SOURCES = \ +LTLIBRARIES = libom.la + +libom_la_SOURCES = \ util.h \ tuning.h \ Node.h \ @@ -98,16 +100,13 @@ common_SOURCES = \ 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 += \ + ../libom_la/util/Semaphore.h \ + ../libom_la/util/types.h \ + ../libom_la/util/Path.h \ + ../libom_la/util/Queue.h \ + ../libom_la/interface/ClientInterface.h \ + ../libom_la/interface/EngineInterface.h \ + instantiations.cpp \ events/RegisterClientEvent.h \ events/RegisterClientEvent.cpp \ events/UnregisterClientEvent.h \ @@ -165,25 +164,25 @@ common_SOURCES += \ events/MidiLearnEvent.cpp if WITH_JACK_MIDI -common_SOURCES += \ +libom_la_SOURCES += \ JackMidiDriver.h \ JackMidiDriver.cpp endif if WITH_ALSA_MIDI -common_SOURCES += \ +libom_la_SOURCES += \ AlsaMidiDriver.h \ AlsaMidiDriver.cpp endif if WITH_LADSPA -common_SOURCES += \ +libom_la_SOURCES += \ LADSPAPlugin.h \ LADSPAPlugin.cpp endif if WITH_DSSI -common_SOURCES += \ +libom_la_SOURCES += \ DSSIPlugin.h \ DSSIPlugin.cpp \ events/DSSIConfigureEvent.cpp \ @@ -197,63 +196,15 @@ common_SOURCES += \ endif if WITH_LV2 -common_SOURCES += \ +libom_la_SOURCES += \ LV2Plugin.h \ LV2Plugin.cpp endif if WITH_LASH -common_SOURCES += \ +libom_la_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_SOURCES = \ - main.cpp \ - cmdline.h \ - cmdline.c - -endif # BUILD_ENGINE - - - -# -# Jack internal client -# -if BUILD_IN_PROCESS_ENGINE - - -# 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 - - diff --git a/src/libs/engine/cmdline.c b/src/libs/engine/cmdline.c deleted file mode 100644 index 6b7ddf6a..00000000 --- a/src/libs/engine/cmdline.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - 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/libs/engine/cmdline.ggo b/src/libs/engine/cmdline.ggo deleted file mode 100644 index 8c006ca7..00000000 --- a/src/libs/engine/cmdline.ggo +++ /dev/null @@ -1,7 +0,0 @@ -# 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/libs/engine/cmdline.h b/src/libs/engine/cmdline.h deleted file mode 100644 index fe36a969..00000000 --- a/src/libs/engine/cmdline.h +++ /dev/null @@ -1,45 +0,0 @@ -/* 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/libs/engine/main.cpp b/src/libs/engine/main.cpp deleted file mode 100644 index a69c7e76..00000000 --- a/src/libs/engine/main.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* 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; -} - |