From c9e703b681485c4fa77be32b56f262d350219f19 Mon Sep 17 00:00:00 2001 From: sletz Date: Fri, 7 Dec 2007 09:44:07 +0000 Subject: [PATCH] Pieter Palmers second new build system: scons and Makefile based build. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1728 0c269be4-1314-0410-8aa9-9f06e86f4224 --- SConstruct | 289 ++---------------------------- common/JackDriverLoader.cpp | 2 + common/JackServerLaunch.cpp | 4 +- common/SConscript | 196 +-------------------- example-clients/SConscript | 86 --------- linux/Makefile | 3 +- linux/SConscript | 78 --------- linux/alsa/driver.h | 311 --------------------------------- macosx/JackCoreAudioDriver.cpp | 14 +- tests/SConscript | 52 ------ 10 files changed, 32 insertions(+), 1003 deletions(-) diff --git a/SConstruct b/SConstruct index 5bf4e5c2..db4d37ac 100644 --- a/SConstruct +++ b/SConstruct @@ -21,6 +21,8 @@ import os from string import Template +platform = ARGUMENTS.get('OS', Platform()) + build_dir = ARGUMENTS.get('BUILDDIR', "") if build_dir: build_base=build_dir+'/' @@ -79,7 +81,8 @@ else: buildenv['LD_LIBRARY_PATH']='' -env = Environment( tools=['default','scanreplace','pkgconfig', 'doxygen'], toolpath=['admin'], ENV=buildenv, options=opts ) +env = Environment( tools=['default','scanreplace','pkgconfig', 'doxygen'], toolpath=['admin'], + ENV=buildenv, PLATFORM = platform, options=opts ) Help( """ For building jackdmp you can set different options as listed below. You have to @@ -186,8 +189,8 @@ if env['DEBUG']: env.AppendUnique( CCFLAGS=["-DDEBUG","-Wall","-g"] ) env.AppendUnique( CFLAGS=["-DDEBUG","-Wall","-g"] ) else: - env.AppendUnique( CCFLAGS=["-O2","-DNDEBUG"] ) - env.AppendUnique( CFLAGS=["-O2","-DNDEBUG"] ) + env.AppendUnique( CCFLAGS=["-O3","-DNDEBUG"] ) + env.AppendUnique( CFLAGS=["-O3","-DNDEBUG"] ) env.AppendUnique( CCFLAGS=["-fPIC", "-DSOCKET_RPC_FIFO_SEMA", "-D__SMP__"] ) env.AppendUnique( CFLAGS=["-fPIC", "-DUSE_POSIX_SHM"] ) @@ -236,260 +239,14 @@ if env['BUILD_DOXYGEN_DOCS']: env.Doxygen("doxyfile") subdirs=['common'] -if build_for_linux: +if env['PLATFORM'] == 'posix': subdirs.append('linux') -if env['BUILD_EXAMPLES']: - subdirs.append('example-clients') - -if env['BUILD_TESTS']: - subdirs.append('tests') - -if build_base: - env.SConscript( dirs=subdirs, exports="env", build_dir=build_base+subdir ) -else: - env.SConscript( dirs=subdirs, exports="env" ) - -# -# Copyright (C) 2007 Arnold Krille -# Copyright (C) 2007 Pieter Palmers -# -# This file originates from FFADO (www.ffado.org) -# -# 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 3 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. If not, see . -# - -import os -from string import Template - -build_dir = ARGUMENTS.get('BUILDDIR', "") -if build_dir: - build_base=build_dir+'/' - if not os.path.isdir( build_base ): - os.makedirs( build_base ) - print "Building into: " + build_base -else: - build_base='' - -if not os.path.isdir( "cache" ): - os.makedirs( "cache" ) - -opts = Options( "cache/"+build_base+"options.cache" ) - -# make this into a command line option and/or a detected value -build_for_linux = True - -# -# If this is just to display a help-text for the variable used via ARGUMENTS, then its wrong... -opts.Add( "BUILDDIR", "Path to place the built files in", "") - -opts.AddOptions( -# BoolOption( "DEBUG", """\ -#Toggle debug-build. DEBUG means \"-g -Wall\" and more, otherwise we will use -# \"-O2\" to optimise.""", True ), - PathOption( "PREFIX", "The prefix where jackdmp will be installed to.", "/usr/local", PathOption.PathAccept ), - PathOption( "BINDIR", "Overwrite the directory where apps are installed to.", "$PREFIX/bin", PathOption.PathAccept ), - PathOption( "LIBDIR", "Overwrite the directory where libs are installed to.", "$PREFIX/lib", PathOption.PathAccept ), - PathOption( "INCLUDEDIR", "Overwrite the directory where headers are installed to.", "$PREFIX/include", PathOption.PathAccept ), - PathOption( "SHAREDIR", "Overwrite the directory where misc shared files are installed to.", "$PREFIX/share/libffado", PathOption.PathAccept ), - BoolOption( "ENABLE_ALSA", "Enable/Disable the ALSA backend.", True ), - BoolOption( "ENABLE_FREEBOB", "Enable/Disable the FreeBoB backend.", True ), - BoolOption( "ENABLE_FIREWIRE", "Enable/Disable the FireWire backend.", True ), - BoolOption( "DEBUG", """Do a debug build.""", True ), - BoolOption( "BUILD_TESTS", """Build tests where applicable.""", True ), - BoolOption( "BUILD_EXAMPLES", """Build the example clients in their directory.""", True ), - BoolOption( "INSTALL_EXAMPLES", """Install the example clients in the BINDIR directory.""", True ), - BoolOption( "BUILD_DOXYGEN_DOCS", """Build doxygen documentation.""", True ), - ) - -## Load the builders in config -buildenv={} -if os.environ.has_key('PATH'): - buildenv['PATH']=os.environ['PATH'] -else: - buildenv['PATH']='' - -if os.environ.has_key('PKG_CONFIG_PATH'): - buildenv['PKG_CONFIG_PATH']=os.environ['PKG_CONFIG_PATH'] -else: - buildenv['PKG_CONFIG_PATH']='' - -if os.environ.has_key('LD_LIBRARY_PATH'): - buildenv['LD_LIBRARY_PATH']=os.environ['LD_LIBRARY_PATH'] -else: - buildenv['LD_LIBRARY_PATH']='' - - -env = Environment( tools=['default','scanreplace','pkgconfig', 'doxygen'], toolpath=['admin'], ENV=buildenv, options=opts ) - -Help( """ -For building jackdmp you can set different options as listed below. You have to -specify them only once, scons will save the last value you used and re-use -that. -To really undo your settings and return to the factory defaults, remove the -"cache"-folder and the file ".sconsign.dblite" from this directory. -For example with: "rm -Rf .sconsign.dblite cache" - -""" ) -Help( opts.GenerateHelpText( env ) ) - -# make sure the necessary dirs exist -if not os.path.isdir( "cache/" + build_base ): - os.makedirs( "cache/" + build_base ) -if not os.path.isdir( 'cache/objects' ): - os.makedirs( 'cache/objects' ) - -if build_base: - env['build_base']="#/"+build_base -else: - env['build_base']="#/" - - -CacheDir( 'cache/objects' ) -opts.Save( 'cache/' + build_base + "options.cache", env ) - -tests = {} -tests.update( env['PKGCONFIG_TESTS'] ) - -if not env.GetOption('clean'): - conf = Configure( env, - custom_tests = tests, - conf_dir = "cache/" + build_base, - log_file = "cache/" + build_base + 'config.log' ) - - # - # Check if the environment can actually compile c-files by checking for a - # header shipped with gcc. - # - if not conf.CheckHeader( "stdio.h" ): - print "It seems as if stdio.h is missing. This probably means that your build environment is broken, please make sure you have a working c-compiler and libstdc installed and usable." - Exit( 1 ) - - # - # The following checks are for headers and libs and packages we need. - # - allpresent = 1; - - if build_for_linux: - allpresent &= conf.CheckForPKGConfig(); - -# example on how to check for additional libs -# pkgs = { -# 'alsa' : '1.0.0', -# } -# for pkg in pkgs: -# name2 = pkg.replace("+","").replace(".","").replace("-","").upper() -# env['%s_FLAGS' % name2] = conf.GetPKGFlags( pkg, pkgs[pkg] ) -# if env['%s_FLAGS'%name2] == 0: -# allpresent &= 0 - - if not allpresent: - print """ -(At least) One of the dependencies is missing. I can't go on without it, please -install the needed packages (remember to also install the *-devel packages) -""" - Exit( 1 ) - - # jack doesn't have to be present, but it would be nice to know if it is - env['JACK_FLAGS'] = conf.GetPKGFlags( 'jack', '0.100.0' ) - if env['JACK_FLAGS']: - env['JACK_PREFIX'] = conf.GetPKGPrefix( 'jack' ) - env['JACK_EXEC_PREFIX'] = conf.GetPKGExecPrefix( 'jack' ) - env['JACK_LIBDIR'] = conf.GetPKGLibdir( 'jack' ) - env['JACK_INCLUDEDIR'] = conf.GetPKGIncludedir( 'jack' ) - - # - # Optional checks follow: - # - if build_for_linux and env['ENABLE_ALSA']: - env['ALSA_FLAGS'] = conf.GetPKGFlags( 'ALSA', '1.0.0' ) - if env['ALSA_FLAGS'] == 0: - print " Disabling 'alsa' backend since no useful ALSA installation found." - env['ENABLE_ALSA'] = False - - if build_for_linux and env['ENABLE_FREEBOB']: - env['FREEBOB_FLAGS'] = conf.GetPKGFlags( 'libfreebob', '1.0.0' ) - if env['FREEBOB_FLAGS'] == 0: - print " Disabling 'freebob' backend since no useful FreeBoB installation found." - env['ENABLE_FREEBOB'] = False - - if build_for_linux and env['ENABLE_FIREWIRE']: - env['FFADO_FLAGS'] = conf.GetPKGFlags( 'libffado', '1.999.7' ) - if env['FFADO_FLAGS'] == 0: - print " Disabling 'firewire' backend since no useful FFADO installation found." - env['ENABLE_FIREWIRE'] = False - - env = conf.Finish() - -if env['DEBUG']: - print "Doing a DEBUG build" - # -Werror could be added to, which would force the devs to really remove all the warnings :-) - env.AppendUnique( CCFLAGS=["-DDEBUG","-Wall","-g"] ) - env.AppendUnique( CFLAGS=["-DDEBUG","-Wall","-g"] ) -else: - env.AppendUnique( CCFLAGS=["-O2","-DNDEBUG"] ) - env.AppendUnique( CFLAGS=["-O2","-DNDEBUG"] ) - -env.AppendUnique( CCFLAGS=["-fPIC", "-DSOCKET_RPC_FIFO_SEMA", "-D__SMP__"] ) -env.AppendUnique( CFLAGS=["-fPIC", "-DUSE_POSIX_SHM"] ) - -# -# XXX: Maybe we can even drop these lower-case variables and only use the uppercase ones? -# -env['prefix'] = Template( os.path.join( env['PREFIX'] ) ).safe_substitute( env ) -env['bindir'] = Template( os.path.join( env['BINDIR'] ) ).safe_substitute( env ) -env['libdir'] = Template( os.path.join( env['LIBDIR'] ) ).safe_substitute( env ) -env['includedir'] = Template( os.path.join( env['INCLUDEDIR'] ) ).safe_substitute( env ) -env['sharedir'] = Template( os.path.join( env['SHAREDIR'] ) ).safe_substitute( env ) - -env.Alias( "install", env['libdir'] ) -env.Alias( "install", env['includedir'] ) -env.Alias( "install", env['sharedir'] ) -env.Alias( "install", env['bindir'] ) - -# for config.h.in -env['ADDON_DIR']='%s' % env['prefix'] -env['LIB_DIR']='lib' -env['JACK_LOCATION']='%s' % env['bindir'] - -# -# To have the top_srcdir as the doxygen-script is used from auto* -# -env['top_srcdir'] = env.Dir( "." ).abspath - -#subprojects = env.Split('common common/jack tests example-clients linux/alsa linux/freebob linux/firewire') - -#for subproject in subprojects: - #env.AppendUnique( CCFLAGS=["-I%s" % subproject] ) - #env.AppendUnique( CFLAGS=["-I%s" % subproject] ) - -env.ScanReplace( "config.h.in" ) -# ensure that the config.h is always updated, since it -# sometimes fails to pick up the changes -# note: this still doesn't seem to cause dependent files to be rebuilt. -NoCache("config.h") -AlwaysBuild("config.h") +if env['PLATFORM'] == 'macosx': # FIXME FOR SLETZ: check macosx/SConscript + subdirs.append('macosx') -# -# Start building -# -if env['BUILD_DOXYGEN_DOCS']: - env.Doxygen("doxyfile") - -subdirs=['common'] -if build_for_linux: - subdirs.append('linux') +if env['PLATFORM'] == 'windows': # FIXME FOR SLETZ: create/check macosx/SConscript + subdirs.append('windows') if env['BUILD_EXAMPLES']: subdirs.append('example-clients') @@ -502,27 +259,3 @@ if build_base: else: env.SConscript( dirs=subdirs, exports="env" ) -# -*- python -*- - -import os -import sys -import re -import shutil -import glob -import errno -import time -import platform -import string -import commands - -platform = ARGUMENTS.get('OS', Platform()) - -env = Environment(PLATFORM = platform, - CPPPATH = ['macosx', 'common']) - -Export('env') - -print platform - -env.SConscript(['common/SConscript']) - \ No newline at end of file diff --git a/common/JackDriverLoader.cpp b/common/JackDriverLoader.cpp index 0d088d3d..1e46241d 100644 --- a/common/JackDriverLoader.cpp +++ b/common/JackDriverLoader.cpp @@ -23,8 +23,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #endif #ifdef __linux__ +#ifndef ADDON_DIR #include "config.h" #endif +#endif #include "JackDriverLoader.h" #include "JackError.h" diff --git a/common/JackServerLaunch.cpp b/common/JackServerLaunch.cpp index efe7a0d4..838e3ed8 100644 --- a/common/JackServerLaunch.cpp +++ b/common/JackServerLaunch.cpp @@ -18,9 +18,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef __linux__ +#ifdef __linux__ +#ifndef ADDON_DIR #include "config.h" #endif +#endif #include "JackChannel.h" #include "JackLibGlobals.h" diff --git a/common/SConscript b/common/SConscript index 0a3fbb9e..d96bb21b 100644 --- a/common/SConscript +++ b/common/SConscript @@ -27,123 +27,8 @@ Import( 'env' ) # paths where include files can be found env.AppendUnique( CPPPATH=["#/", "#/common", "#/common/jack"] ) -# -# Define the source files -# - -srcfiles_common_serverlib = env.Split( '\ - JackActivationCount.cpp JackAPI.cpp JackAudioDriver.cpp JackClient.cpp JackConnectionManager.cpp \ - JackDriver.cpp JackEngine.cpp JackEngineControl.cpp JackError.c JackExternalClient.cpp JackFrameTimer.cpp \ - JackFreewheelDriver.cpp JackGlobalsServer.cpp JackGraphManager.cpp JackInternalClient.cpp JackPort.cpp JackPosixSemaphore.cpp \ - JackPosixThread.cpp JackFifo.cpp JackLoopbackDriver.cpp JackPortType.cpp JackAudioPort.cpp JackMidiPort.cpp \ - JackServer.cpp JackShmMem.cpp JackThreadedDriver.cpp shm.c JackSocket.cpp JackSocketServerChannel.cpp JackSocketNotifyChannel.cpp \ - JackSocketServerNotifyChannel.cpp JackTime.c JackServerAPI.cpp JackGlobals.cpp JackDriverLoader.cpp JackDebugClient.cpp \ - JackTransportEngine.cpp JackServerGlobals.cpp JackServerLaunch.cpp timestamps.c JackTools.cpp \ - ') - -# FIXME: this is not pretty -srcfiles_common_serverlib.append('#/example-clients/internal_metro.cpp') - -srcfiles_common_clientlib = env.Split( '\ - JackActivationCount.cpp JackAPI.cpp JackClient.cpp JackConnectionManager.cpp ringbuffer.c JackServerLaunch.cpp\ - JackError.c JackFrameTimer.cpp JackGlobalsClient.cpp JackGraphManager.cpp JackLibClient.cpp JackLibAPI.cpp JackPort.cpp JackPosixSemaphore.cpp \ - JackFifo.cpp JackPortType.cpp JackAudioPort.cpp JackMidiPort.cpp JackMidiAPI.cpp JackEngineControl.cpp JackPosixThread.cpp JackShmMem.cpp \ - shm.c JackSocket.cpp JackSocketClientChannel.cpp JackTime.c JackGlobals.cpp JackDebugClient.cpp JackTransportEngine.cpp timestamps.c JackTools.cpp \ - ') - -srcfiles_common_wrapperlib = ['JackAPIWrapper.cpp', 'ringbuffer.c'] - -jack_headers = env.Split( 'intclient.h jack.h midiport.h ringbuffer.h \ - statistics.h thread.h transport.h types.h') - -# -# Start building -# - -#pkgconfig = env.ScanReplace( "libjackmp.pc.in" ) -#env.Install( env['libdir'] + '/pkgconfig', pkgconfig ) - -env.AppendUnique( LIBS=["rt", "pthread"] ) - -# build the common stuff -clientlib = env.SharedLibrary( "jackmp", srcfiles_common_clientlib ) -env.Install( "$libdir", clientlib ) -serverlib = env.SharedLibrary( "jackdmp", srcfiles_common_serverlib ) -env.Install( "$libdir", serverlib ) -wrapperlib = env.SharedLibrary( "jackwrapper", srcfiles_common_wrapperlib ) -env.Install( "$libdir", wrapperlib ) - - -# install the headers -#if env['JACK_FLAGS']: - #jack_include_dir = env['JACK_INCLUDEDIR'] - #if 'install' in COMMAND_LINE_TARGETS and os.path.isdir( jack_include_dir ): - #if env.GetOption('clean'): - #pass - #else: - #jack_old_includes_dir = env['includedir'] + '/jack_up' - #print "moving old jack includes to %s..." % jack_old_includes_dir - #env.Command(jack_old_includes_dir, jack_include_dir, Move("$TARGET", "$SOURCE")) - -for header in jack_headers: - env.Alias("install", env.Install( env['includedir'] + '/jack', 'jack/' + header )) - - -# install the libs -env.Alias("install", env.Install(env['libdir'], serverlib)) -env.Alias("install", env.Install(env['libdir'], clientlib)) -env.Alias("install", env.Install(env['libdir'], wrapperlib)) -#jack_libdir = env['JACK_LIBDIR'] -#libjackdmp_location = env['libdir'] + '/libjackmp.so' -#if 'install' in COMMAND_LINE_TARGETS and os.path.isdir( jack_libdir ): - - #if env.GetOption('clean'): - ##note: is this executed before the actual uninstall? - #lib_files = glob.glob(jack_libdir + '/libjack.so.*.up') - #for old_name in lib_files: - #new_name = old_name[:-3] - #print "restoring old jack lib %s to %s..." % (old_name, new_name) - #env.Command(Delete(new_name)) - #env.Command(new_name, old_name, Move("$TARGET", "$SOURCE")) - #else: - #lib_files = glob.glob(jack_libdir + '/libjack.so.*') - #env.Alias("install", env.Install(env['libdir'], serverlib)) - #env.Alias("install", env.Install(env['libdir'], clientlib)) - - #for old_name in lib_files: - #new_name = old_name + '.up' - #print "moving old jack lib %s to %s..." % (old_name, new_name) - #env.Command(new_name, old_name, Move("$TARGET", "$SOURCE")) - #print " linking to %s..." % (libjackdmp_location) - #env.Command(old_name, libjackdmp_location, "ln -s $TARGET $SOURCE") -# -# Copyright (C) 2007 Arnold Krille -# Copyright (C) 2007 Pieter Palmers -# -# This file originally was part of FFADO -# -# 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 3 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. If not, see . -# - -import os -import glob -from string import Template - -Import( 'env' ) - -# paths where include files can be found -env.AppendUnique( CPPPATH=["#/", "#/common", "#/common/jack"] ) +#HACK: this should not be here ideally +env.AppendUnique( CPPPATH=["#/linux","#/macosx"] ) # # Define the source files @@ -234,80 +119,3 @@ env.Alias("install", env.Install(env['libdir'], wrapperlib)) #env.Command(new_name, old_name, Move("$TARGET", "$SOURCE")) #print " linking to %s..." % (libjackdmp_location) #env.Command(old_name, libjackdmp_location, "ln -s $TARGET $SOURCE") -# -*- python -*- - -import os -import os.path -import glob -#Import('env') - -#CPPPATH = ['macosx', 'common'] - -objects_common_server_lib=Split(""" -JackActivationCount.cpp -JackAPI.cpp -JackAudioDriver.cpp -JackClient.cpp -JackConnectionManager.cpp -JackDriver.cpp -JackEngine.cpp -JackEngineTiming.cpp -JackError.cpp -JackExternalClient.cpp -JackFrameTimer.cpp -JackFreewheelDriver.o -JackGlobalsServer.cpp -JackGraphManager.cpp -JackInternalClient.cpp -JackPort.cpp -JackPosixSemaphore.cpp -JackPosixThread.cpp -JackFifo.cpp -JackLoopbackDriver.cpp -JackServer.cpp -JackShmMem.cpp -JackThreadedDriver.cpp -shm.c -JackSocket.cpp -JackSocketServerChannel.cpp -JackSocketNotifyChannel.cpp -JackSocketServerNotifyChannel.cpp -JackTime.cpp -JackServerAPI.cpp -JackGlobals.cpp -JackDriverLoader.cpp -internal_metro.cpp -JackDebugClient.cpp -JackTransportEngine.cpp -JackServerGlobals.o -""") - -objects_common_client_lib =Split(""" -JackActivationCount.cpp -JackAPI.cpp -JackClient.cpp -JackConnectionManager.cpp -ringbuffer.cpp -JackError.cpp -JackFrameTimer.cpp -JackGlobalsClient.cpp -JackGraphManager.cpp -JackLibClient.cpp -JackLibAPI.cpp -JackPort.cpp -JackPosixSemaphore.cpp -JackFifo.cpp -JackPosixThread.cpp -JackShmMem.cpp -shm.c -JackSocket.cpp -JackSocketClientChannel.cpp -JackTime.cpp -JackGlobals.cpp -JackDebugClient.cpp -JackTransportEngine.cpp -""") - - -SharedLibrary('libjackdmp', objects_common_server_lib, CPPPATH = ['.','../macosx','jack'], CXXFLAGS=["-O3"]) -SharedLibrary('libjackmp', objects_common_client_lib, CPPPATH = ['.','../macosx','jack'], CXXFLAGS=["-O3"]) diff --git a/example-clients/SConscript b/example-clients/SConscript index 716d729d..bdc361d5 100644 --- a/example-clients/SConscript +++ b/example-clients/SConscript @@ -66,92 +66,6 @@ if env['HAS_READLINE']: # Start building # -# build the example clients -if env['BUILD_EXAMPLES']: - clientenv = env.Copy() - clientenv.PrependUnique( LIBPATH=env['build_base'] ) - - for example_client_program in example_client_programs.keys(): - clientenv.Program(target=example_client_program, - source=env.Split( example_client_programs[example_client_program]), - LIBS=extra_libs[example_client_program] ) - if env['INSTALL_EXAMPLES']: - clientenv.Install( "$bindir", example_client_program ) - - for example_client_lib in example_client_libs.keys(): - clientenv.SharedLibrary(target=example_client_lib, - source=env.Split( example_client_libs[example_client_lib] ) ) - if env['INSTALL_EXAMPLES']: - #clientenv.Install( "$libdir", example_client_lib ) - pass -# -# Copyright (C) 2007 Arnold Krille -# Copyright (C) 2007 Pieter Palmers -# -# This file originates from FFADO (www.ffado.org) -# -# 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 3 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. If not, see . -# - -import os -from string import Template - -Import( 'env' ) - -# paths where include files can be found -env.AppendUnique( CPPPATH=["#/", "#/common"] ) - -# -# Define the source files -# - -example_client_programs = { - "jack_freewheel" : "freewheel.c", - "jack_connect" : "connect.c", - "jack_lsp" : "lsp.c", - "jack_metro" : "metro.c", - #"jack_midiseq" : "midiseq.c", - #"jack_midisine" : "midisine.c", - "jack_showtime" : "showtime.c", - "jack_simple_client" : "simple_client.c", - "jack_zombie" : "zombie.c", - "jack_load" : "ipload.c", - "jack_unload" : "ipunload.c", -} - -example_client_libs = { - "inprocess" : "inprocess.c", -} - -# link extra libs? -extra_libs = {} -for example_client_program in example_client_programs.keys(): - extra_libs[example_client_program] = ["jackdmp", "dl"] - -# special cases -extra_libs["jack_load"] = ["jackmp"] -extra_libs["jack_unload"] = ["jackmp"] - -env['HAS_READLINE']=True -if env['HAS_READLINE']: - extra_libs["jack_transport"] = ["readline", "jackdmp", "dl"] - example_client_programs["jack_transport"] = "transport.c" - -# -# Start building -# - # build the example clients if env['BUILD_EXAMPLES']: clientenv = env.Copy() diff --git a/linux/Makefile b/linux/Makefile index 5b4306a2..a366c841 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -5,7 +5,7 @@ prefix := /usr prefix := ${DESTDIR}${prefix} libdir := lib -subprojects := ../common ../common/jack ../tests ../example-clients alsa freebob firewire +subprojects := ../common ../common/jack ../tests ../example-clients alsa freebob firewire ../linux .. sources := $(wildcard *.cpp) $(wildcard */*.cpp) $(wildcard ../common/*.cpp) $(wildcard ../tests/*.cpp) @@ -121,7 +121,6 @@ $(TARGET_LINUX_FIREWIRE) : $(objects_linux_firewire) $(TARGET_LINUX_DUMMY) : $(objects_linux_dummy) $(CXX) $(CXXFLAGS) -shared $(objects_linux_dummy) $(LIB_LINUX) libjackdmp.so -o $(TARGET_LINUX_DUMMY) - # Install jackdmp and overwrite jack installation install: cp jackdmp $(prefix)/bin diff --git a/linux/SConscript b/linux/SConscript index bf0d60c6..e7d63191 100644 --- a/linux/SConscript +++ b/linux/SConscript @@ -59,84 +59,6 @@ serverenv.Install( env['bindir'], server ) drv = serverenv.SharedLibrary( "jack_dummy", srcfiles_linux_dummy ) serverenv.InstallAs( env['libdir']+ "/jackmp/jack_dummy.so", drv ) -if env['ENABLE_ALSA']: - if not env.GetOption('clean'): - serverenv.MergeFlags( env['ALSA_FLAGS'] ) - drv = serverenv.SharedLibrary( "jack_alsa", srcfiles_linux_alsa ) - serverenv.InstallAs( env['libdir']+ "/jackmp/jack_alsa.so", drv ) - -if env['ENABLE_FREEBOB']: - if not env.GetOption('clean'): - serverenv.MergeFlags( env['FREEBOB_FLAGS'] ) - drv = serverenv.SharedLibrary( "jack_freebob", srcfiles_linux_freebob ) - serverenv.InstallAs( env['libdir']+ "/jackmp/jack_freebob.so", drv ) - -if env['ENABLE_FIREWIRE']: - if not env.GetOption('clean'): - serverenv.MergeFlags( env['FFADO_FLAGS'] ) - drv = serverenv.SharedLibrary( "jack_firewire", srcfiles_linux_ffado ) - serverenv.InstallAs( env['libdir']+ "/jackmp/jack_firewire.so", drv ) -# -# Copyright (C) 2007 Arnold Krille -# Copyright (C) 2007 Pieter Palmers -# -# This file originates from FFADO (www.ffado.org) -# -# 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 3 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. If not, see . -# - -import os -from string import Template - -Import( 'env' ) - -# paths where include files can be found -env.AppendUnique( CPPPATH=["#/", "#/common", "#/common/jack", "#/linux"] ) - -# -# Define the source files -# - -srcfiles_linux_server = ['#/common/Jackdmp.cpp'] - -srcfiles_linux_alsa = env.Split( '\ - JackAlsaDriver.cpp memops.c generic_hw.c hdsp.c hammerfall.c ice1712.c') -for i in range(len(srcfiles_linux_alsa)): - srcfiles_linux_alsa[i] = 'alsa/%s' % srcfiles_linux_alsa[i] - -srcfiles_linux_freebob = ['freebob/JackFreebobDriver.cpp'] -srcfiles_linux_ffado = ['firewire/JackFFADODriver.cpp'] -srcfiles_linux_dummy = ['#/common/JackDummyDriver.cpp'] - -# -# Start building -# - -#pkgconfig = env.ScanReplace( "libjackmp.pc.in" ) -#env.Install( env['libdir'] + '/pkgconfig', pkgconfig ) - -# build the server and its backends -serverenv = env.Copy() -serverenv.PrependUnique( LIBPATH=env['build_base'] ) -serverenv.PrependUnique( LIBS=["jackdmp", "dl"] ) - -server = serverenv.Program("jackdmp", srcfiles_linux_server) -serverenv.Install( env['bindir'], server ) - -drv = serverenv.SharedLibrary( "jack_dummy", srcfiles_linux_dummy ) -serverenv.InstallAs( env['libdir']+ "/jackmp/jack_dummy.so", drv ) - if env['ENABLE_ALSA']: if not env.GetOption('clean'): serverenv.MergeFlags( env['ALSA_FLAGS'] ) diff --git a/linux/alsa/driver.h b/linux/alsa/driver.h index 36f9408b..e69de29b 100644 --- a/linux/alsa/driver.h +++ b/linux/alsa/driver.h @@ -1,311 +0,0 @@ -/* - Copyright (C) 2001 Paul Davis - - 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; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: driver.h,v 1.2 2005/11/23 11:24:29 letz Exp $ -*/ - -#ifndef __jack_driver_h__ -#define __jack_driver_h__ - -#include -#include "types.h" -#include "jslist.h" -#include "driver_interface.h" - -typedef float gain_t; -typedef long channel_t; - -typedef enum { - Lock = 0x1, - NoLock = 0x2, - Sync = 0x4, - NoSync = 0x8 -} ClockSyncStatus; - -typedef void (*ClockSyncListenerFunction)(channel_t, ClockSyncStatus, void*); - -typedef struct -{ - unsigned long id; - ClockSyncListenerFunction function; - void *arg; -} -ClockSyncListener; - -struct _jack_engine; -struct _jack_driver; - -typedef int (*JackDriverAttachFunction)(struct _jack_driver *, - struct _jack_engine *); -typedef int (*JackDriverDetachFunction)(struct _jack_driver *, - struct _jack_engine *); -typedef int (*JackDriverReadFunction)(struct _jack_driver *, - jack_nframes_t nframes); -typedef int (*JackDriverWriteFunction)(struct _jack_driver *, - jack_nframes_t nframes); -typedef int (*JackDriverNullCycleFunction)(struct _jack_driver *, - jack_nframes_t nframes); -typedef int (*JackDriverStopFunction)(struct _jack_driver *); -typedef int (*JackDriverStartFunction)(struct _jack_driver *); -typedef int (*JackDriverBufSizeFunction)(struct _jack_driver *, - jack_nframes_t nframes); -/* - Call sequence summary: - - 1) engine loads driver via runtime dynamic linking - - calls jack_driver_load - - we call dlsym for "driver_initialize" and execute it - 2) engine attaches to driver - 3) engine starts driver - 4) driver runs its own thread, calling - while () { - driver->wait (); - driver->engine->run_cycle () - } - 5) engine stops driver - 6) engine detaches from driver - 7) engine calls driver `finish' routine - - Note that stop/start may be called multiple times in the event of an - error return from the `wait' function. -*/ - -typedef struct _jack_driver -{ - - /* The _jack_driver structure fields are included at the beginning of - each driver-specific structure using the JACK_DRIVER_DECL macro, - which is defined below. The comments that follow describe each - common field. - - The driver should set this to be the interval it expects to elapse - between returning from the `wait' function. if set to zero, it - implies that the driver does not expect regular periodic wakeups. - - jack_time_t period_usecs; - - - The driver should set this within its "wait" function to indicate - the UST of the most recent determination that the engine cycle - should run. it should not be set if the "extra_fd" argument of - the wait function is set to a non-zero value. - - jack_time_t last_wait_ust; - - - These are not used by the driver. They should not be written to or - modified in any way - - void *handle; - struct _jack_internal_client *internal_client; - - This should perform any cleanup associated with the driver. it will - be called when jack server process decides to get rid of the - driver. in some systems, it may not be called at all, so the driver - should never rely on a call to this. it can set it to NULL if - it has nothing do do. - - void (*finish)(struct _jack_driver *); - - - The JACK engine will call this when it wishes to attach itself to - the driver. the engine will pass a pointer to itself, which the driver - may use in anyway it wishes to. the driver may assume that this - is the same engine object that will make `wait' calls until a - `detach' call is made. - - JackDriverAttachFunction attach; - - - The JACK engine will call this when it is finished using a driver. - - JackDriverDetachFunction detach; - - - The JACK engine will call this when it wants to wait until the - driver decides that its time to process some data. the driver returns - a count of the number of audioframes that can be processed. - - it should set the variable pointed to by `status' as follows: - - zero: the wait completed normally, processing may begin - negative: the wait failed, and recovery is not possible - positive: the wait failed, and the driver stopped itself. - a call to `start' will return the driver to - a correct and known state. - - the driver should also fill out the `delayed_usecs' variable to - indicate any delay in its expected periodic execution. for example, - if it discovers that its return from poll(2) is later than it - expects it to be, it would place an estimate of the delay - in this variable. the engine will use this to decide if it - plans to continue execution. - - JackDriverWaitFunction wait; - - - The JACK engine will call this to ask the driver to move - data from its inputs to its output port buffers. it should - return 0 to indicate successful completion, negative otherwise. - - This function will always be called after the wait function (above). - - JackDriverReadFunction read; - - - The JACK engine will call this to ask the driver to move - data from its input port buffers to its outputs. it should - return 0 to indicate successful completion, negative otherwise. - - this function will always be called after the read function (above). - - JackDriverWriteFunction write; - - - The JACK engine will call this after the wait function (above) has - been called, but for some reason the engine is unable to execute - a full "cycle". the driver should do whatever is necessary to - keep itself running correctly, but cannot reference ports - or other JACK data structures in any way. - - JackDriverNullCycleFunction null_cycle; - - - The engine will call this when it plans to stop calling the `wait' - function for some period of time. the driver should take - appropriate steps to handle this (possibly no steps at all). - NOTE: the driver must silence its capture buffers (if any) - from within this function or the function that actually - implements the change in state. - - JackDriverStopFunction stop; - - - The engine will call this to let the driver know that it plans - to start calling the `wait' function on a regular basis. the driver - should take any appropriate steps to handle this (possibly no steps - at all). NOTE: The driver may wish to silence its playback buffers - (if any) from within this function or the function that actually - implements the change in state. - - JackDriverStartFunction start; - - The engine will call this to let the driver know that some client - has requested a new buffer size. The stop function will be called - prior to this, and the start function after this one has returned. - - JackDriverBufSizeFunction bufsize; - */ - - /* define the fields here... */ -#define JACK_DRIVER_DECL \ - jack_time_t period_usecs; \ - jack_time_t last_wait_ust; \ - void *handle; \ - struct _jack_client_internal * internal_client; \ - void (*finish)(struct _jack_driver *);\ - JackDriverAttachFunction attach; \ - JackDriverDetachFunction detach; \ - JackDriverReadFunction read; \ - JackDriverWriteFunction write; \ - JackDriverNullCycleFunction null_cycle; \ - JackDriverStopFunction stop; \ - JackDriverStartFunction start; \ - JackDriverBufSizeFunction bufsize; - - JACK_DRIVER_DECL /* expand the macro */ - -} -jack_driver_t; - - -typedef jack_driver_desc_t * (*JackDriverDescFunction) (); - -void jack_driver_init (jack_driver_t *); -void jack_driver_release (jack_driver_t *); - -jack_driver_t *jack_driver_load (int argc, char **argv); -void jack_driver_unload (jack_driver_t *); - - -/**************************** - *** Non-Threaded Drivers *** - ****************************/ - -/* - Call sequence summary: - - 1) engine loads driver via runtime dynamic linking - - calls jack_driver_load - - we call dlsym for "driver_initialize" and execute it - - driver_initialize calls jack_driver_nt_init - 2) nt layer attaches to driver - 3) nt layer starts driver - 4) nt layer runs a thread, calling - while () { - driver->nt_run_ctcle(); - } - 5) nt layer stops driver - 6) nt layer detaches driver - 7) engine calls driver `finish' routine which calls jack_driver_nt_finish - - Note that stop/start may be called multiple times in the event of an - error return from the `wait' function. - - -*/ - -struct _jack_driver_nt; - -typedef int (*JackDriverNTAttachFunction)(struct _jack_driver_nt *); -typedef int (*JackDriverNTDetachFunction)(struct _jack_driver_nt *); -typedef int (*JackDriverNTStopFunction)(struct _jack_driver_nt *); -typedef int (*JackDriverNTStartFunction)(struct _jack_driver_nt *); -typedef int (*JackDriverNTBufSizeFunction)(struct _jack_driver_nt *, - jack_nframes_t nframes); -typedef int (*JackDriverNTRunCycleFunction)(struct _jack_driver_nt *); - -typedef struct _jack_driver_nt -{ - -#define JACK_DRIVER_NT_DECL \ - JACK_DRIVER_DECL \ - struct _jack_engine * engine; \ - volatile int nt_run; \ - pthread_t nt_thread; \ - pthread_mutex_t nt_run_lock; \ - JackDriverNTAttachFunction nt_attach; \ - JackDriverNTDetachFunction nt_detach; \ - JackDriverNTStopFunction nt_stop; \ - JackDriverNTStartFunction nt_start; \ - JackDriverNTBufSizeFunction nt_bufsize; \ - JackDriverNTRunCycleFunction nt_run_cycle; -#define nt_read read -#define nt_write write -#define nt_null_cycle null_cycle - - JACK_DRIVER_NT_DECL - - -} -jack_driver_nt_t; - -void jack_driver_nt_init (jack_driver_nt_t * driver); -void jack_driver_nt_finish (jack_driver_nt_t * driver); - - -#endif /* __jack_driver_h__ */ diff --git a/macosx/JackCoreAudioDriver.cpp b/macosx/JackCoreAudioDriver.cpp index 7c15b55a..f3a40b55 100644 --- a/macosx/JackCoreAudioDriver.cpp +++ b/macosx/JackCoreAudioDriver.cpp @@ -282,10 +282,17 @@ OSStatus JackCoreAudioDriver::DeviceNotificationCallback(AudioDeviceID inDevice, break; case kAudioDevicePropertyNominalSampleRate: { + OSStatus err; + /* + err = AudioOutputUnitStop(driver->fAUHAL); + if (err != noErr) + jack_error("Error calling AudioOutputUnitStop"); + */ + UInt32 outSize = sizeof(Float64); Float64 sampleRate; AudioStreamBasicDescription srcFormat, dstFormat; - OSStatus err = AudioDeviceGetProperty(driver->fDeviceID, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyNominalSampleRate, &outSize, &sampleRate); + err = AudioDeviceGetProperty(driver->fDeviceID, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyNominalSampleRate, &outSize, &sampleRate); if (err != noErr) { jack_error("Cannot get current sample rate"); printError(err); @@ -319,6 +326,11 @@ OSStatus JackCoreAudioDriver::DeviceNotificationCallback(AudioDeviceID inDevice, jack_error("Error calling AudioUnitSetProperty - kAudioUnitProperty_StreamFormat kAudioUnitScope_Output"); printError(err); } + /* + err = AudioOutputUnitStart(driver->fAUHAL); + if (err != noErr) + jack_error("Error calling AudioOutputUnitStart"); + */ break; } } diff --git a/tests/SConscript b/tests/SConscript index c65d7f03..c37175ea 100644 --- a/tests/SConscript +++ b/tests/SConscript @@ -47,58 +47,6 @@ testenv = env.Copy() testenv.PrependUnique( LIBPATH=env['build_base'] ) testenv.PrependUnique( LIBS="jackmp" ) -for test_program in test_programs.keys(): - testenv.Program(target=test_program, - source=env.Split( test_programs[test_program] ) ) -# -# Copyright (C) 2007 Arnold Krille -# Copyright (C) 2007 Pieter Palmers -# -# This file originates from FFADO (www.ffado.org) -# -# 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 3 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. If not, see . -# - -import os -from string import Template - -Import( 'env' ) - -# paths where include files can be found -env.AppendUnique( CPPPATH=["#/", "#/common"] ) - -# -# Define the source files -# - -test_programs = { - "synchroClient" : "testSynchroClient.cpp #/common/JackPosixSemaphore.cpp #/common/JackPosixThread.cpp #/common/JackError.c #/common/JackFifo.cpp", - "synchroServer" : "testSynchroServer.cpp #/common/JackPosixSemaphore.cpp #/common/JackPosixThread.cpp #/common/JackError.c #/common/JackFifo.cpp", - "synchroServerClient" : "testSynchroServerClient.cpp #/common/JackPosixSemaphore.cpp #/common/JackPosixThread.cpp #/common/JackError.c #/common/JackFifo.cpp #/common/JackPthreadCond.cpp", - "testSem" : "testSem.cpp #/common/JackPosixSemaphore.cpp #/common/JackPosixThread.cpp #/common/JackError.c #/common/JackFifo.cpp", - "jack_test" : "jack_test.cpp", -} - -# -# Start building -# - -# build the tests -testenv = env.Copy() -testenv.PrependUnique( LIBPATH=env['build_base'] ) -testenv.PrependUnique( LIBS="jackmp" ) - for test_program in test_programs.keys(): testenv.Program(target=test_program, source=env.Split( test_programs[test_program] ) )