summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoran Mekić <meka@tilda.center>2020-11-27 12:42:28 +0100
committer0EVSG <dev@submerge.ch>2021-12-27 20:45:57 +0100
commit4e2167ace1522ccfd4c049d5224a389b9f405985 (patch)
tree245af1e0b5f78db7820c61ee48a0244ff9a31c70
parent1d3926a56b3f374811636894113a9c7d6fdb6c2b (diff)
downloadjack2-4e2167ace1522ccfd4c049d5224a389b9f405985.tar.gz
Add FreeBSD support
-rw-r--r--common/JackAudioAdapterFactory.cpp2
-rw-r--r--common/wscript42
-rw-r--r--dbus/wscript4
-rw-r--r--example-clients/wscript6
-rw-r--r--freebsd/JackFreeBSDTime.c90
-rw-r--r--freebsd/JackPlatformPlug_os.h85
-rw-r--r--freebsd/driver.h1
-rw-r--r--freebsd/jackAtomic_os.h34
-rw-r--r--tests/wscript2
-rw-r--r--tools/wscript2
-rw-r--r--wscript15
11 files changed, 278 insertions, 5 deletions
diff --git a/common/JackAudioAdapterFactory.cpp b/common/JackAudioAdapterFactory.cpp
index 9ceeee04..f121ed2b 100644
--- a/common/JackAudioAdapterFactory.cpp
+++ b/common/JackAudioAdapterFactory.cpp
@@ -35,7 +35,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define JackPlatformAdapter JackAlsaAdapter
#endif
-#if defined(__sun__) || defined(sun)
+#if defined(__sun__) || defined(sun) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include "JackOSSAdapter.h"
#define JackPlatformAdapter JackOSSAdapter
#endif
diff --git a/common/wscript b/common/wscript
index 24f024ec..27bb60ff 100644
--- a/common/wscript
+++ b/common/wscript
@@ -22,12 +22,15 @@ def create_jack_process_obj(bld, target, sources, uselib = None, framework = Non
if not bld.env['IS_WINDOWS']:
process.env['cxxshlib_PATTERN'] = '%s.so'
process.defines = ['HAVE_CONFIG_H','SERVER_SIDE']
+ print(bld.env)
if bld.env['IS_MACOSX']:
if framework:
process.framework = framework
env_includes = ['../macosx', '../posix', '../macosx/coreaudio']
if bld.env['IS_LINUX']:
env_includes = ['../linux', '../posix', '../linux/alsa']
+ if bld.env['IS_FREEBSD']:
+ env_includes = ['../freebsd', '../posix', '../solaris/oss']
if bld.env['IS_SUN']:
env_includes = ['../solaris', '../posix', '../solaris/oss']
if bld.env['IS_WINDOWS']:
@@ -36,7 +39,7 @@ def create_jack_process_obj(bld, target, sources, uselib = None, framework = Non
process.name = target
process.target = target
process.source = sources
- if bld.env['IS_LINUX'] or bld.env['IS_MACOSX']:
+ if bld.env['IS_LINUX'] or bld.env['IS_MACOSX'] or bld.env['IS_FREEBSD']:
process.env.append_value('CPPFLAGS', '-fvisibility=hidden')
process.install_path = '${ADDON_DIR}/'
process.use = [uselib.name]
@@ -92,6 +95,20 @@ def build(bld):
uselib.append('RT')
uselib.append('DL')
+ if bld.env['IS_FREEBSD']:
+ common_libsources += [
+ 'JackDebugClient.cpp',
+ 'timestamps.c',
+ 'promiscuous.c',
+ '../posix/JackPosixThread.cpp',
+ '../posix/JackPosixProcessSync.cpp',
+ '../posix/JackPosixMutex.cpp',
+ '../posix/JackPosixSemaphore.cpp',
+ '../posix/JackSocket.cpp',
+ '../freebsd/JackFreeBSDTime.c',
+ ]
+ includes = ['../freebsd', '../posix'] + includes
+
if bld.env['IS_SUN']:
common_libsources += [
'JackDebugClient.cpp',
@@ -177,6 +194,12 @@ def build(bld):
'../posix/JackPosixServerLaunch.cpp',
]
+ if bld.env['IS_FREEBSD']:
+ clientlib.source += [
+ '../posix/JackSocketClientChannel.cpp',
+ '../posix/JackPosixServerLaunch.cpp',
+ ]
+
if bld.env['IS_SUN']:
clientlib.source += [
'../posix/JackSocketClientChannel.cpp',
@@ -206,6 +229,9 @@ def build(bld):
if bld.env['IS_LINUX']:
clientlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
+ if bld.env['IS_FREEBSD']:
+ clientlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
+
if bld.env['IS_MACOSX']:
clientlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
clientlib.env.append_value('LINKFLAGS', '-single_module')
@@ -282,6 +308,14 @@ def build(bld):
'../posix/JackNetUnixSocket.cpp',
]
+ if bld.env['IS_FREEBSD']:
+ serverlib.source += [
+ '../posix/JackSocketServerChannel.cpp',
+ '../posix/JackSocketNotifyChannel.cpp',
+ '../posix/JackSocketServerNotifyChannel.cpp',
+ '../posix/JackNetUnixSocket.cpp',
+ ]
+
if bld.env['IS_SUN']:
serverlib.source += [
'../posix/JackSocketServerChannel.cpp',
@@ -361,6 +395,10 @@ def build(bld):
netlib.source += ['../posix/JackNetUnixSocket.cpp','../posix/JackPosixThread.cpp', '../posix/JackPosixMutex.cpp', '../linux/JackLinuxTime.c']
netlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
+ if bld.env['IS_FREEBSD']:
+ netlib.source += ['../posix/JackNetUnixSocket.cpp','../posix/JackPosixThread.cpp', '../posix/JackPosixMutex.cpp', '../linux/JackLinuxTime.c']
+ netlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
+
if bld.env['IS_SUN']:
netlib.source += ['../posix/JackNetUnixSocket.cpp','../posix/JackPosixThread.cpp', '../posix/JackPosixMutex.cpp', '../solaris/JackSolarisTime.c']
netlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
@@ -423,7 +461,7 @@ def build(bld):
process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
process.use += ['ALSA', 'SAMPLERATE']
- if bld.env['BUILD_ADAPTER'] and bld.env['IS_SUN']:
+ if bld.env['BUILD_ADAPTER'] and (bld.env['IS_SUN'] or bld.env['IS_FREEBSD']):
audio_adapter_sources += ['../solaris/oss/JackOSSAdapter.cpp', 'memops.c']
process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
process.use += 'SAMPLERATE'
diff --git a/dbus/wscript b/dbus/wscript
index fa40b4f1..2c6452eb 100644
--- a/dbus/wscript
+++ b/dbus/wscript
@@ -39,6 +39,8 @@ def build(bld):
obj = bld(features = ['c', 'cprogram'], idx=17)
if bld.env['IS_LINUX']:
sysdeps_dbus_include = ['../linux', '../posix']
+ if bld.env['IS_FREEBSD']:
+ sysdeps_dbus_include = ['../freebsd', '../posix']
if bld.env['IS_MACOSX']:
sysdeps_dbus_include = ['../macosx', '../posix']
@@ -67,6 +69,8 @@ def build(bld):
'../linux/uptime.c',
]
obj.use += ['PTHREAD', 'DL', 'RT', 'DBUS-1', 'EXPAT', 'STDC++']
+ if bld.env['IS_FREEBSD']:
+ obj.use += ['PTHREAD', 'EXECINFO', 'LIBSYSINFO', 'DBUS-1', 'EXPAT']
if bld.env['IS_MACOSX']:
obj.source += [
'../macosx/uptime.c',
diff --git a/example-clients/wscript b/example-clients/wscript
index c452b688..c6d1bbb1 100644
--- a/example-clients/wscript
+++ b/example-clients/wscript
@@ -31,6 +31,8 @@ def build(bld):
os_incdir = ['../linux', '../posix']
if bld.env['IS_MACOSX']:
os_incdir = ['../macosx', '../posix']
+ if bld.env['IS_FREEBSD']:
+ os_incdir = ['../freebsd', '../posix']
if bld.env['IS_SUN']:
os_incdir = ['../solaris', '../posix']
if bld.env['IS_WINDOWS']:
@@ -65,6 +67,8 @@ def build(bld):
prog.use += ['RT', 'M']
if bld.env['IS_SUN']:
prog.use += ['M']
+ if bld.env['IS_FREEBSD']:
+ prog.use += ['M']
if bld.env['IS_WINDOWS'] and bld.env['BUILD_STATIC']:
prog.env['LIB_PTHREAD'] = [':libwinpthread.a']
#prog.cflags = ['-Wno-deprecated-declarations', '-Wno-misleading-indentation']
@@ -81,6 +85,8 @@ def build(bld):
prog.use += ['SNDFILE']
if bld.env['IS_LINUX']:
prog.use += ['RT', 'SNDFILE']
+ if bld.env['IS_FREEBSD']:
+ prog.use += ['SNDFILE']
if bld.env['IS_SUN']:
prog.use += ['RT', 'SNDFILE']
if bld.env['IS_WINDOWS']:
diff --git a/freebsd/JackFreeBSDTime.c b/freebsd/JackFreeBSDTime.c
new file mode 100644
index 00000000..66790167
--- /dev/null
+++ b/freebsd/JackFreeBSDTime.c
@@ -0,0 +1,90 @@
+/*
+Copyright (C) 2001-2003 Paul Davis
+Copyright (C) 2005 Jussi Laako
+Copyright (C) 2004-2008 Grame
+Copyright (C) 2018 Greg V
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser 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 "JackConstants.h"
+#include "JackTime.h"
+#include "JackTypes.h"
+#include "JackError.h"
+
+#include <time.h>
+#include <unistd.h>
+
+jack_time_t (*_jack_get_microseconds)(void) = 0;
+
+static jack_time_t jack_get_microseconds_from_system (void)
+{
+ jack_time_t jackTime;
+ struct timespec time;
+
+ clock_gettime(CLOCK_MONOTONIC, &time);
+ jackTime = (jack_time_t) time.tv_sec * 1e6 +
+ (jack_time_t) time.tv_nsec / 1e3;
+ return jackTime;
+}
+
+
+SERVER_EXPORT void JackSleep(long usec)
+{
+ usleep(usec);
+}
+
+SERVER_EXPORT void InitTime()
+{
+ /* nothing to do on a generic system - we use the system clock */
+}
+
+SERVER_EXPORT void EndTime()
+{}
+
+void SetClockSource(jack_timer_type_t source)
+{
+ jack_log("Clock source : %s", ClockSourceName(source));
+
+ switch (source)
+ {
+ case JACK_TIMER_SYSTEM_CLOCK:
+ default:
+ _jack_get_microseconds = jack_get_microseconds_from_system;
+ break;
+ }
+}
+
+const char* ClockSourceName(jack_timer_type_t source)
+{
+ switch (source) {
+ case JACK_TIMER_SYSTEM_CLOCK:
+ return "system clock via clock_gettime";
+ }
+
+ return "unknown";
+}
+
+SERVER_EXPORT jack_time_t GetMicroSeconds()
+{
+ return _jack_get_microseconds();
+}
+
+SERVER_EXPORT jack_time_t jack_get_microseconds()
+{
+ return _jack_get_microseconds();
+}
+
diff --git a/freebsd/JackPlatformPlug_os.h b/freebsd/JackPlatformPlug_os.h
new file mode 100644
index 00000000..f4a4345d
--- /dev/null
+++ b/freebsd/JackPlatformPlug_os.h
@@ -0,0 +1,85 @@
+/*
+Copyright (C) 2004-2008 Grame
+Copyright (C) 2018 Greg V
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser 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.
+
+*/
+
+#ifndef __JackPlatformPlug_freebsd__
+#define __JackPlatformPlug_freebsd__
+
+#define jack_server_dir "/tmp"
+#define jack_client_dir "/tmp"
+#define JACK_DEFAULT_DRIVER "oss"
+
+namespace Jack
+{
+ struct JackRequest;
+ struct JackResult;
+
+ class JackPosixMutex;
+ class JackPosixThread;
+ class JackPosixSemaphore;
+
+ class JackSocketServerChannel;
+ class JackSocketClientChannel;
+ class JackSocketServerNotifyChannel;
+ class JackSocketNotifyChannel;
+ class JackClientSocket;
+ class JackNetUnixSocket;
+}
+
+/* __JackPlatformMutex__ */
+#include "JackPosixMutex.h"
+namespace Jack {typedef JackPosixMutex JackMutex; }
+
+/* __JackPlatformThread__ */
+#include "JackPosixThread.h"
+namespace Jack { typedef JackPosixThread JackThread; }
+
+/* __JackPlatformSynchro__ client activation */
+#include "JackPosixSemaphore.h"
+namespace Jack { typedef JackPosixSemaphore JackSynchro; }
+
+/* __JackPlatformChannelTransaction__ */
+#include "JackSocket.h"
+namespace Jack { typedef JackClientSocket JackChannelTransaction; }
+
+/* __JackPlatformProcessSync__ */
+#include "JackPosixProcessSync.h"
+namespace Jack { typedef JackPosixProcessSync JackProcessSync; }
+
+/* __JackPlatformServerChannel__ */
+#include "JackSocketServerChannel.h"
+namespace Jack { typedef JackSocketServerChannel JackServerChannel; }
+
+/* __JackPlatformClientChannel__ */
+#include "JackSocketClientChannel.h"
+namespace Jack { typedef JackSocketClientChannel JackClientChannel; }
+
+/* __JackPlatformServerNotifyChannel__ */
+#include "JackSocketServerNotifyChannel.h"
+namespace Jack { typedef JackSocketServerNotifyChannel JackServerNotifyChannel; }
+
+/* __JackPlatformNotifyChannel__ */
+#include "JackSocketNotifyChannel.h"
+namespace Jack { typedef JackSocketNotifyChannel JackNotifyChannel; }
+
+/* __JackPlatformNetSocket__ */
+#include "JackNetUnixSocket.h"
+namespace Jack { typedef JackNetUnixSocket JackNetSocket; }
+
+#endif
diff --git a/freebsd/driver.h b/freebsd/driver.h
new file mode 100644
index 00000000..eb240b9c
--- /dev/null
+++ b/freebsd/driver.h
@@ -0,0 +1 @@
+../linux/driver.h \ No newline at end of file
diff --git a/freebsd/jackAtomic_os.h b/freebsd/jackAtomic_os.h
new file mode 100644
index 00000000..ca731f25
--- /dev/null
+++ b/freebsd/jackAtomic_os.h
@@ -0,0 +1,34 @@
+/*
+Copyright (C) 2004-2008 Grame
+Copyright (C) 2018 Greg V
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser 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.
+
+*/
+
+#ifndef __JackAtomic_freebsd__
+#define __JackAtomic_freebsd__
+
+#include "JackTypes.h"
+#include <sys/types.h>
+#include <machine/atomic.h>
+
+static inline char CAS(volatile UInt32 value, UInt32 newvalue, volatile void* addr)
+{
+ return atomic_cmpset_32((uint32_t*)addr, value, newvalue);
+}
+
+#endif
+
diff --git a/tests/wscript b/tests/wscript
index 96a63bc9..0795025c 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -20,6 +20,8 @@ def build(bld):
prog.includes = ['..','../macosx', '../posix', '../common/jack', '../common']
if bld.env['IS_LINUX']:
prog.includes = ['..','../linux', '../posix', '../common/jack', '../common']
+ if bld.env['IS_FREEBSD']:
+ prog.includes = ['..','../freebsd', '../posix', '../common/jack', '../common']
if bld.env['IS_SUN']:
prog.includes = ['..','../solaris', '../posix', '../common/jack', '../common']
prog.source = test_program_sources
diff --git a/tools/wscript b/tools/wscript
index 4192a4c8..54735b57 100644
--- a/tools/wscript
+++ b/tools/wscript
@@ -29,6 +29,8 @@ def build(bld):
os_incdir = ['../linux', '../posix']
if bld.env['IS_MACOSX']:
os_incdir = ['../macosx', '../posix']
+ if bld.env['IS_FREEBSD']:
+ os_incdir = ['../freebsd', '../posix']
if bld.env['IS_SUN']:
os_incdir = ['../solaris', '../posix']
if bld.env['IS_WINDOWS']:
diff --git a/wscript b/wscript
index e0d32c8d..451ca7e0 100644
--- a/wscript
+++ b/wscript
@@ -191,6 +191,7 @@ def detect_platform(conf):
platforms = [
# ('KEY, 'Human readable name', ['strings', 'to', 'check', 'for'])
('IS_LINUX', 'Linux', ['gnu0', 'gnukfreebsd', 'linux', 'posix']),
+ ('IS_FREEBSD', 'FreeBSD', ['freebsd']),
('IS_MACOSX', 'MacOS X', ['darwin']),
('IS_SUN', 'SunOS', ['sunos']),
('IS_WINDOWS', 'Windows', ['cygwin', 'msys', 'win32'])
@@ -230,6 +231,10 @@ def configure(conf):
conf.env.append_unique('CXXFLAGS', ['-Wall', '-Wno-invalid-offsetof'])
conf.env.append_unique('CXXFLAGS', '-std=gnu++11')
+ if conf.env['IS_FREEBSD']:
+ conf.check(lib='execinfo', uselib='EXECINFO', define_name='EXECINFO')
+ conf.check_cfg(package='libsysinfo', args='--cflags --libs')
+
if not conf.env['IS_MACOSX']:
conf.env.append_unique('LDFLAGS', '-Wl,--no-undefined')
else:
@@ -524,6 +529,9 @@ def obj_add_includes(bld, obj):
if bld.env['IS_LINUX']:
obj.includes += ['linux', 'posix']
+ if bld.env['IS_FREEBSD']:
+ obj.includes += ['freebsd', 'posix']
+
if bld.env['IS_MACOSX']:
obj.includes += ['macosx', 'posix']
@@ -551,6 +559,9 @@ def build_jackd(bld):
if bld.env['IS_LINUX']:
jackd.use += ['DL', 'M', 'PTHREAD', 'RT', 'STDC++']
+ if bld.env['IS_FREEBSD']:
+ jackd.use += ['M', 'PTHREAD']
+
if bld.env['IS_MACOSX']:
jackd.use += ['DL', 'PTHREAD']
jackd.framework = ['CoreFoundation']
@@ -768,7 +779,7 @@ def build_drivers(bld):
use = ['serverlib'], # FIXME: Is this needed?
framework = ['AudioUnit', 'CoreMIDI', 'CoreServices', 'Foundation'])
- if bld.env['IS_SUN']:
+ if bld.env['IS_SUN'] or bld.env['IS_FREEBSD']:
create_driver_obj(
bld,
target = 'boomer',
@@ -819,7 +830,7 @@ def build(bld):
bld.recurse('example-clients')
bld.recurse('tools')
- if bld.env['IS_LINUX']:
+ if bld.env['IS_LINUX'] or bld.env['IS_FREEBSD']:
bld.recurse('man')
bld.recurse('systemd')
if not bld.env['IS_WINDOWS']: