- Support for building without ALSA

- Readline build fixes
- Fix for daemon auto launching (prevent zombies patch from larsl)


git-svn-id: svn://svn.savannah.nongnu.org/lash/trunk@35 1de19dc7-4e3f-0410-a61d-eddf686bf0b7
This commit is contained in:
Dave Robillard 2006-05-21 18:44:38 +00:00
parent 9302fd07c4
commit 2d808f3531
16 changed files with 276 additions and 93 deletions

View File

@ -1 +1,5 @@
SUBDIRS = simple_client control synth save_button panel
SUBDIRS = control save_button panel
if WITH_ALSA
SUBDIRS += simple_client synth
endif

View File

@ -2,6 +2,10 @@ include $(top_srcdir)/common.am
EXTRA_PROGRAMS = lash_control
if HAVE_READLINE
bin_PROGRAMS = lash_control
lash_control_SOURCES = \
main.c \
lash_control.c \
@ -10,15 +14,10 @@ lash_control_SOURCES = \
project.c \
project.h
lash_control_CFLAGS = \
$(LASH_CFLAGS)
lash_control_CFLAGS = $(LASH_CFLAGS) @READLINE_INCLUDES@
lash_control_LDADD = \
$(top_builddir)/liblash/liblash.la \
$(LASH_LIBS) \
$(READLINE_LIBS)
$(LASH_LIBS) @READLINE_LIBS@
if HAVE_READLINE
bin_PROGRAMS = lash_control
endif

View File

@ -32,24 +32,41 @@ AC_DEFINE_UNQUOTED(JACK_VERSION, "$JACK_VERSION", [The version of jack we're com
############
### ALSA ###
############
PKG_CHECK_MODULES(ALSA, alsa >= 0.9, true, AC_MSG_ERROR([you need alsa >= 0.9. see http://www.alsa-project.org/]))
# check that there's seq functions in the library
ORIG_LIBS="$LIBS"
LIBS="$LIBS $ALSA_LIBS"
ORIG_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $ALSA_CFLAGS"
lash_alsa_midi="yes"
AC_ARG_ENABLE(alsa-midi,
[AS_HELP_STRING(--enable-alsa-midi, [Enable Alsa sequencer support (true)])],
[ if test x$enable_alsa_midi = xno ; then lash_alsa_midi=no ; fi ])
AC_CHECK_FUNC(snd_seq_open, true,
AC_MSG_ERROR([the alsa library you're using doesn't have sequencer functions]))
if test "x$lash_alsa_midi" = "xyes"; then
LIBS="$ORIG_LIBS"
CFLAGS="$ORIG_CFLAGS"
PKG_CHECK_MODULES(ALSA, alsa >= 0.9, ALSA_FOUND="true", ALSA_FOUND="false")
if test "x$ALSA_FOUND" = "xyes"; then
# Check that there's seq functions in the library
ORIG_LIBS="$LIBS"
LIBS="$LIBS $ALSA_LIBS"
ORIG_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $ALSA_CFLAGS"
AC_CHECK_FUNC(snd_seq_open, true,
AC_MSG_ERROR([The Alsa library you're using doesn't have sequencer functions]))
LIBS="$ORIG_LIBS"
CFLAGS="$ORIG_CFLAGS"
ALSA_VERSION=$( pkg-config --modversion alsa )
AC_SUBST(ALSA_CFLAGS)
AC_SUBST(ALSA_LIBS)
AC_DEFINE(HAVE_ALSA, 1, [Alsa sequencer support])
AC_DEFINE_UNQUOTED(ALSA_VERSION, "$ALSA_VERSION", [The version of alsa we're compiling against])
else
AC_MSG_WARN([You don't have ALSA >= 0.9. See http://www.alsa-project.org/])
AC_MSG_WARN([ALSA support not being built.])
fi
fi
AM_CONDITIONAL(WITH_ALSA, [test "x$ALSA_FOUND" = "xyes"])
ALSA_VERSION=$( pkg-config --modversion alsa )
AC_SUBST(ALSA_CFLAGS)
AC_SUBST(ALSA_LIBS)
AC_DEFINE_UNQUOTED(ALSA_VERSION, "$ALSA_VERSION", [The version of alsa we're compiling against])
###############
### libxml2 ###
@ -117,7 +134,9 @@ AM_CONDITIONAL(HAVE_GTK2, test x$GTK2_FOUND = xyes)
### readline ###
################
lash_readline="yes"
VL_LIB_READLINE
#VL_LIB_READLINE
AC_CHECK_READLINE
AC_SUBST(READLINE_INCLUDES)
AC_SUBST(READLINE_LIBS)
AC_MSG_CHECKING([whether to enable readline])
@ -259,6 +278,7 @@ AC_MSG_RESULT([
LASH Configured
Alsa support: $lash_alsa_midi
Readline support: $lash_readline
Gtk support: $lash_gtk2
Debugging output: $lash_debug

View File

@ -12,15 +12,19 @@ lashd_SOURCES = \
store.c store.h \
server.c server.h \
client_event.c client_event.h \
alsa_patch.c alsa_patch.h \
jack_patch.c jack_patch.h \
jack_mgr.c jack_mgr.h \
jack_mgr_client.c jack_mgr_client.h \
jack_fport.c jack_fport.h \
globals.h
if WITH_ALSA
lashd_SOURCES += \
alsa_patch.c alsa_patch.h \
alsa_fport.c alsa_fport.h \
alsa_mgr.c alsa_mgr.h \
alsa_client.c alsa_client.h \
globals.h
alsa_client.c alsa_client.h
endif
lashd_LDADD = \
$(LASH_LIBS) \
@ -28,7 +32,7 @@ lashd_LDADD = \
$(ALSA_LIBS) \
$(XML2_LIBS) \
$(UUID_LIBS) \
$(top_builddir)/liblash/liblash.la
$(top_builddir)/liblash/liblash.la
lashd_CFLAGS = \
$(LASH_CFLAGS) \
@ -48,3 +52,4 @@ install-data-local:
echo -e "\nlash\t\t14541/tcp\t\t\t# LASH client/server protocol" >> /etc/services; \
fi
endif

View File

@ -21,6 +21,8 @@
#ifndef __LASH_ALSA_CLIENT_H__
#define __LASH_ALSA_CLIENT_H__
#ifdef WITH_ALSA
#include <pthread.h>
#include <uuid/uuid.h>
@ -49,4 +51,6 @@ void alsa_client_get_id (const alsa_client_t * client, uuid_t
void alsa_client_free_patches (alsa_client_t * client);
void alsa_client_free_backup_patches (alsa_client_t * client);
#endif /* WITH_ALSA */
#endif /* __LASH_ALSA_CLIENT_H__ */

View File

@ -21,6 +21,8 @@
#ifndef __LASHD_ALSA_FPORT_H__
#define __LASHD_ALSA_FPORT_H__
#ifdef WITH_ALSA
#include <pthread.h>
typedef struct _alsa_fport alsa_fport_t;
@ -41,4 +43,6 @@ void alsa_fport_set_port (alsa_fport_t * fport, unsigned char port);
unsigned char alsa_fport_get_client (const alsa_fport_t * fport);
unsigned char alsa_fport_get_port (const alsa_fport_t * fport);
#endif /* WITH_ALSA */
#endif /* __LASHD_ALSA_FPORT_H__ */

View File

@ -21,6 +21,8 @@
#ifndef __LASH_ALSA_MGR_H__
#define __LASH_ALSA_MGR_H__
#ifdef WITH_ALSA
#include <pthread.h>
#include <uuid/uuid.h>
#include <alsa/asoundlib.h>
@ -60,5 +62,6 @@ void alsa_mgr_unlock (alsa_mgr_t * alsa_mgr);
const char * get_alsa_port_name_only (const char * port_name);
#endif /* WITH_ALSA */
#endif /* __LASH_ALSA_MGR_H__ */

View File

@ -21,6 +21,8 @@
#ifndef __LASHD_ALSA_PATCH_H__
#define __LASHD_ALSA_PATCH_H__
#ifdef WITH_ALSA
#include <uuid/uuid.h>
#include <alsa/asoundlib.h>
#include <libxml/tree.h>
@ -68,4 +70,6 @@ void alsa_patch_parse_xml (alsa_patch_t * patch, xmlNodePtr parent);
const char * alsa_patch_get_desc (alsa_patch_t * patch);
#endif /* WITH_ALSA */
#endif /* __LASHD_ALSA_PATCH_H__ */

View File

@ -20,6 +20,7 @@
#include <lash/internal_headers.h>
#include "config.h"
#include "client.h"
#include "jack_patch.h"
#include "alsa_patch.h"
@ -210,7 +211,9 @@ client_parse_xml(client_t * client, xmlNodePtr parent)
xmlNodePtr xmlnode, argnode;
xmlChar *content;
jack_patch_t *jack_patch;
#ifdef HAVE_ALSA
alsa_patch_t *alsa_patch;
#endif
LASH_PRINT_DEBUG("parsing client");
@ -262,14 +265,19 @@ client_parse_xml(client_t * client, xmlNodePtr parent)
lash_list_append(client->jack_patches, jack_patch);
}
} else if (strcmp(CAST_BAD(xmlnode->name), "alsa_patch_set") == 0) {
for (argnode = xmlnode->children; argnode;
argnode = argnode->next)
#ifdef HAVE_ALSA
for (argnode = xmlnode->children; argnode; argnode = argnode->next) {
if (strcmp(CAST_BAD argnode->name, "alsa_patch") == 0) {
alsa_patch = alsa_patch_new();
alsa_patch_parse_xml(alsa_patch, argnode);
client->alsa_patches =
lash_list_append(client->alsa_patches, alsa_patch);
}
}
#else
LASH_PRINT_DEBUG("Warning: Session contains ALSA information, but LASH"
" is built without ALSA support.");
#endif
}
}

View File

@ -20,6 +20,8 @@
#define _GNU_SOURCE
#include "config.h"
#include <unistd.h>
#include <errno.h>
@ -109,7 +111,7 @@ server_lash_event_alsa_client_id(project_t * project, client_t * client,
__FUNCTION__, client_get_id_str(client));
return;
}
#ifdef HAVE_ALSA
alsa_id = (unsigned char)string[0];
client_set_alsa_client_id(client, alsa_id);
@ -121,6 +123,7 @@ server_lash_event_alsa_client_id(project_t * project, client_t * client,
server_notify_interfaces(project, client, LASH_Alsa_Client_ID,
string);
#endif
} else {
lash_event_t *event;
char id[2];

View File

@ -71,9 +71,11 @@ print_help()
("under the terms of the GNU General Public License, version 2 or later. See\n");
printf("the COPYING file that came with this software for details.\n");
printf("\n");
printf("Compiled with ALSA %s, JACK %s and libxml2 %s\n", ALSA_VERSION,
JACK_VERSION, XML2_VERSION);
printf("\n");
printf("Compiled with JACK %s, libxml2 %s", JACK_VERSION, XML2_VERSION);
#ifdef ALSA_SUPPORT
printf(", ALSA %s", ALSA_VERSION);
#endif
printf("\n\n");
printf(" -h, --help Display this help info\n");
printf
(" -d, --default-dir <dir> Use <dir> within $HOME to store project directories\n");

View File

@ -20,6 +20,8 @@
#define _GNU_SOURCE
#include "config.h"
#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>
@ -33,9 +35,12 @@
#include <stdio.h>
#include <jack/jack.h>
#include <alsa/asoundlib.h>
#include <libxml/tree.h>
#ifdef HAVE_ALSA
#include <alsa/asoundlib.h>
#endif
#include <lash/lash.h>
#include <lash/internal_headers.h>
@ -600,6 +605,7 @@ project_create_client_jack_patch_xml(project_t * project, client_t * client,
lash_list_free(patches);
}
#ifdef HAVE_ALSA
void
project_create_client_alsa_patch_xml(project_t * project, client_t * client,
xmlNodePtr clientxml)
@ -629,6 +635,8 @@ project_create_client_alsa_patch_xml(project_t * project, client_t * client,
lash_list_free(patches);
}
#endif
static xmlDocPtr
project_create_xml(project_t * project)
@ -676,9 +684,10 @@ project_create_xml(project_t * project)
if (client->jack_client_name)
project_create_client_jack_patch_xml(project, client, clientxml);
#ifdef HAVE_ALSA
if (client->alsa_client_id)
project_create_client_alsa_patch_xml(project, client, clientxml);
#endif
}
return doc;
@ -850,24 +859,25 @@ project_restore(server_t * server, const char *dir)
lash_list_t *list;
int i;
LASH_DEBUG("resored project with:");
LASH_PRINT_DEBUG("resored project with:");
LASH_DEBUGARGS(" directory: '%s'", project->directory);
LASH_DEBUGARGS(" name: '%s'", project->name);
LASH_DEBUG(" clients:");
LASH_PRINT_DEBUG(" clients:");
for (client_list = project->lost_clients; client_list;
client_list = client_list->next) {
client = (client_t *) client_list->data;
LASH_DEBUG(" ------");
LASH_PRINT_DEBUG(" ------");
LASH_DEBUGARGS(" id: '%s'",
client_get_id_str(client));
LASH_DEBUGARGS(" working dir: '%s'", client->working_dir);
LASH_DEBUGARGS(" flags: %d", client->flags);
LASH_DEBUGARGS(" argc: %d", client->argc);
LASH_DEBUG(" args:");
LASH_PRINT_DEBUG(" args:");
for (i = 0; i < client->argc; i++) {
LASH_DEBUGARGS(" %d: '%s'", i, client->argv[i]);
}
#ifdef HAVE_ALSA
if (client->alsa_patches) {
LASH_PRINT_DEBUG(" alsa patches:");
for (list = client->alsa_patches; list; list = list->next) {
@ -877,6 +887,7 @@ project_restore(server_t * server, const char *dir)
}
} else
LASH_PRINT_DEBUG(" no alsa patches");
#endif
if (client->jack_patches) {
LASH_PRINT_DEBUG(" jack patches:");
@ -983,6 +994,7 @@ project_destroy(project_t * project)
lash_list_free(patches);
}
#ifdef HAVE_ALSA
if (client->alsa_client_id) {
alsa_mgr_lock(project->server->alsa_mgr);
patches =
@ -993,6 +1005,7 @@ project_destroy(project_t * project)
alsa_patch_destroy((alsa_patch_t *) pnode->data);
lash_list_free(patches);
}
#endif
/* remove the client name links */
if (CLIENT_CONFIG_DATA_SET(client) || CLIENT_CONFIG_FILE(client))

View File

@ -20,6 +20,8 @@
#define _GNU_SOURCE
#include "config.h"
#include <signal.h>
#include <assert.h>
#include <uuid/uuid.h>
@ -51,7 +53,9 @@ server_new(const char *default_dir)
LASH_PRINT_DEBUG("starting jack, alsa and comm threads");
server->jack_mgr = jack_mgr_new(server);
#ifdef HAVE_ALSA
server->alsa_mgr = alsa_mgr_new(server);
#endif
server->conn_mgr = conn_mgr_new(server);
if (!server->conn_mgr)
exit(1);
@ -71,9 +75,11 @@ server_destroy(server_t * server)
LASH_PRINT_DEBUG("destroying connection manager");
conn_mgr_destroy(server->conn_mgr);
#ifdef HAVE_ALSA
LASH_PRINT_DEBUG("destroying alsa manager");
alsa_mgr_lock(server->alsa_mgr);
alsa_mgr_destroy(server->alsa_mgr);
#endif
LASH_PRINT_DEBUG("destroying jack manager");
jack_mgr_lock(server->jack_mgr);
jack_mgr_destroy(server->jack_mgr);
@ -537,12 +543,13 @@ server_event_client_disconnect(server_t * server, server_event_t * event)
jack_patches = jack_mgr_remove_client(server->jack_mgr, client->id);
jack_mgr_unlock(server->jack_mgr);
}
#ifdef HAVE_ALSA
if (client->alsa_client_id) {
alsa_mgr_lock(server->alsa_mgr);
alsa_patches = alsa_mgr_remove_client(server->alsa_mgr, client->id);
alsa_mgr_unlock(server->alsa_mgr);
}
#endif
project_lose_client(project, client, jack_patches, alsa_patches);

View File

@ -36,7 +36,12 @@ struct _server
{
conn_mgr_t * conn_mgr;
jack_mgr_t * jack_mgr;
#ifdef WITH_ALSA
alsa_mgr_t * alsa_mgr;
#else
void * alsa_mgr;
#endif
loader_t * loader;
int loader_quit;

View File

@ -175,29 +175,48 @@ lash_init(lash_args_t * args,
case something must be broken if we can't connect */
lash_args_get_id(args, id);
if (err && getenv("LASH_START_SERVER") != NULL && uuid_is_null(id)) {
fprintf(stderr, "%s: trying to start new LASH server\n",
LASH_DEBUGARGS("%s: trying to start new LASH server\n",
__FUNCTION__);
/* using the same double fork() trick as JACK does to prevent
zombie children */
err = fork();
/* child process will run this statement */
if (err == 0) {
daemon(0, 0);
execlp("lashd", "lashd", NULL);
_exit(-1);
switch (fork()) {
/* grandchild process will run this block */
case 0:
setsid();
execlp("lashd", "lashd", NULL);
_exit(-1);
/* this block only runs if the second fork() fails */
case -1:
_exit (-1);
/* exit the child process here */
default:
_exit (0);
}
}
/* if the fork succeeded, try to connect to the new server */
else if (err > 0) {
waitpid(err, NULL, 0);
for (tries = 0; tries < 5; ++tries) {
sleep(1);
err = lash_comm_connect_to_server(client,
cstr ? cstr : "localhost",
"lash", connect_params);
if (err == 0)
if (err == 0) {
LASH_PRINT_DEBUG("successfully launched and connected to lashd");
break;
}
}
}
/* fork failed */
else {
} else {
fprintf(stderr, "%s: fork failed while starting new server: %s\n",
__FUNCTION__, strerror(err));
}

View File

@ -1,47 +1,130 @@
#
# downloaded from the gnu autoconf macro archive
#
AC_DEFUN([VL_LIB_READLINE], [
AC_CACHE_CHECK([for a readline compatible library],
vl_cv_lib_readline, [
ORIG_LIBS="$LIBS"
for readline_lib in readline edit editline; do
for termcap_lib in "" termcap curses ncurses; do
if test -z "$termcap_lib"; then
TRY_LIB="-l$readline_lib"
else
TRY_LIB="-l$readline_lib -l$termcap_lib"
fi
LIBS="$ORIG_LIBS $TRY_LIB"
AC_TRY_LINK_FUNC(readline, vl_cv_lib_readline="$TRY_LIB")
if test -n "$vl_cv_lib_readline"; then
break
fi
done
if test -n "$vl_cv_lib_readline"; then
break
fi
done
if test -z "$vl_cv_lib_readline"; then
vl_cv_lib_readline="no"
LIBS="$ORIG_LIBS"
fi
])
dnl readline detection
dnl based on curses.m4 from gnome
dnl
dnl What it does:
dnl =============
dnl
dnl - Determine which version of readline is installed on your system
dnl and set the -I/-L/-l compiler entries and add a few preprocessor
dnl symbols
dnl - Do an AC_SUBST on the READLINE_INCLUDES and READLINE_LIBS so that
dnl @READLINE_INCLUDES@ and @READLINE_LIBS@ will be available in
dnl Makefile.in's
dnl - Modify the following configure variables (these are the only
dnl readline.m4 variables you can access from within configure.in)
dnl READLINE_INCLUDES - contains -I's
dnl READLINE_LIBS - sets -L and -l's appropriately
dnl has_readline - exports result of tests to rest of configure
dnl
dnl Usage:
dnl ======
dnl 1) call AC_CHECK_READLINE after AC_PROG_CC in your configure.in
dnl 2) Make sure to add @READLINE_INCLUDES@ to your preprocessor flags
dnl 3) Make sure to add @READLINE_LIBS@ to your linker flags or LIBS
dnl
dnl Notes with automake:
dnl - call AM_CONDITIONAL(HAS_READLINE, test "$has_readline" = true) from
dnl configure.in
dnl - your Makefile.am can look something like this
dnl -----------------------------------------------
dnl INCLUDES= blah blah blah $(READLINE_INCLUDES)
dnl if HAS_READLINE
dnl READLINE_TARGETS=name_of_readline_prog
dnl endif
dnl bin_PROGRAMS = other_programs $(READLINE_TARGETS)
dnl other_programs_SOURCES = blah blah blah
dnl name_of_readline_prog_SOURCES = blah blah blah
dnl other_programs_LDADD = blah
dnl name_of_readline_prog_LDADD = blah $(READLINE_LIBS)
dnl -----------------------------------------------
dnl
dnl
if test "$vl_cv_lib_readline" != "no"; then
AC_DEFINE(HAVE_LIBREADLINE, 1,
[Define if you have a readline compatible library])
AC_CHECK_HEADERS(readline.h readline/readline.h)
AC_CACHE_CHECK([whether readline supports history],
vl_cv_lib_readline_history, [
vl_cv_lib_readline_history="no"
AC_TRY_LINK_FUNC(add_history, vl_cv_lib_readline_history="yes")
])
if test "$vl_cv_lib_readline_history" = "yes"; then
AC_DEFINE(HAVE_READLINE_HISTORY, 1,
[Define if your readline library has \`add_history'])
AC_CHECK_HEADERS(history.h readline/history.h)
fi
fi
])dnl
AH_TEMPLATE([HAS_READLINE],
[ Defined if found readline ])
AC_DEFUN([AC_CHECK_READLINE],[
search_readline=true
has_readline=false
dnl CFLAGS=${CFLAGS--O}
AC_SUBST(READLINE_LIBS)
AC_SUBST(READLINE_INCLUDES)
AC_ARG_WITH(readline,
[ --with-readline[=dir] Compile with readline/locate base dir [no compile]],
if test "x$withval" = "xno" ; then
search_readline=false
elif test "x$withval" != "xyes" ; then
READLINE_LIBS="$LIBS -L$withval/lib -lreadline"
READLINE_INCLUDES="-I$withval/include"
search_readline=false
AC_DEFINE(HAS_READLINE)
has_readline=true
else
search_readline=true
fi
)
if $search_readline
then
AC_SEARCH_READLINE()
fi
if $has_readline
then
AC_DEFINE(HAS_READLINE)
AC_READLINE_VERSION()
fi
])
dnl
dnl Parameters: directory filename cureses_LIBS curses_INCLUDES nicename
dnl
AC_DEFUN([AC_READLINE], [
if $search_readline
then
if test -f $1/$2
then
AC_MSG_RESULT(Found readline on $1/$2)
READLINE_LIBS="$3"
READLINE_INCLUDES="$4"
search_readline=false
has_readline=true
fi
fi
])
AC_DEFUN([AC_SEARCH_READLINE], [
AC_CHECKING(location of readline.h file)
AC_READLINE(/usr/include, readline.h, -lreadline,, "readline on /usr/include")
AC_READLINE(/usr/include/readline, readline.h, -lreadline, -I/usr/include/readline, "readline on /usr/include/readline")
AC_READLINE(/usr/local/include, readline.h, -L/usr/local/lib -lreadline, -I/usr/local/include, "readline on /usr/local")
AC_READLINE(/usr/local/include/readline, readline.h, -L/usr/local/lib -L/usr/local/lib/readline -lreadline, -I/usr/local/include/readline, "readline on /usr/local/include/readline")
] )
AC_DEFUN([AC_READLINE_VERSION], [
AC_MSG_CHECKING(for readline version)
readline_version=unknown
cat > conftest.$ac_ext <<EOF
[#]line __oline__ "configure"
#include "confdefs.h"
#include <readline.h>
#undef VERSION
VERSION:RL_VERSION_MAJOR.RL_VERSION_MINOR
EOF
if (eval "$ac_cpp $READLINE_INCLUDES conftest.$ac_ext") 2>&AC_FD_CC |
egrep "VERSION:" >conftest.out 2>&1; then
changequote(,)dnl
readline_version=`cat conftest.out|sed -e 's/ //g' -e 's/^VERSION://' -e 's/\..*$//'`
changequote([,])dnl
fi
rm -rf conftest*
AC_MSG_RESULT($readline_version)
] )