Browse Source

Add FreeBSD support

tags/v1.9.20
Goran Mekić falkTX <falktx@falktx.com> 3 years ago
parent
commit
5c667d5282
11 changed files with 278 additions and 5 deletions
  1. +1
    -1
      common/JackAudioAdapterFactory.cpp
  2. +40
    -2
      common/wscript
  3. +4
    -0
      dbus/wscript
  4. +6
    -0
      example-clients/wscript
  5. +90
    -0
      freebsd/JackFreeBSDTime.c
  6. +85
    -0
      freebsd/JackPlatformPlug_os.h
  7. +1
    -0
      freebsd/driver.h
  8. +34
    -0
      freebsd/jackAtomic_os.h
  9. +2
    -0
      tests/wscript
  10. +2
    -0
      tools/wscript
  11. +13
    -2
      wscript

+ 1
- 1
common/JackAudioAdapterFactory.cpp View File

@@ -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


+ 40
- 2
common/wscript View File

@@ -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'


+ 4
- 0
dbus/wscript View File

@@ -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',


+ 6
- 0
example-clients/wscript View File

@@ -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']:


+ 90
- 0
freebsd/JackFreeBSDTime.c View File

@@ -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();
}


+ 85
- 0
freebsd/JackPlatformPlug_os.h View File

@@ -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

+ 1
- 0
freebsd/driver.h View File

@@ -0,0 +1 @@
../linux/driver.h

+ 34
- 0
freebsd/jackAtomic_os.h View File

@@ -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


+ 2
- 0
tests/wscript View File

@@ -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


+ 2
- 0
tools/wscript View File

@@ -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']:


+ 13
- 2
wscript View File

@@ -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']:


Loading…
Cancel
Save