diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c33b1b8b..033ca91f7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -196,7 +196,7 @@ jobs: - script: linux-checks/check-formatting image: rocstreaming/env-ubuntu - - script: linux-checks/check-doctests + - script: linux-checks/check-scons image: rocstreaming/env-ubuntu - script: linux-checks/pulseaudio-versions diff --git a/SConstruct b/SConstruct index 63f829862..32f3be877 100644 --- a/SConstruct +++ b/SConstruct @@ -440,13 +440,13 @@ doc_env = env.DeepClone() doc_env.SConscript('docs/SConscript', duplicate=0, exports='doc_env') -# run python doctests -env.AlwaysBuild(env.Alias('doctest', [], [ - env.DocTest('#scripts/scons_helpers/build-3rdparty.py'), +# run scons self-test +env.AlwaysBuild(env.Alias('selftest', [], [ + env.SelfTest(), ])) # exit early if there is nothing to build -non_build_targets = ['fmt', 'docs', 'sphinx', 'doxygen', 'doctest'] +non_build_targets = ['fmt', 'docs', 'sphinx', 'doxygen', 'selftest'] if set(COMMAND_LINE_TARGETS) \ and set(COMMAND_LINE_TARGETS).intersection(non_build_targets) == set(COMMAND_LINE_TARGETS): Return() @@ -893,7 +893,7 @@ if meta.compiler in ['gcc', 'clang']: '-std=c11', ]) -if 'target_posix' in env['ROC_TARGETS'] and meta.platform not in ['macos']: +if 'target_posix' in env['ROC_TARGETS'] and meta.platform not in ['darwin']: # macOS is special, otherwise rely on _POSIX_C_SOURCE env.Append(CPPDEFINES=[('_POSIX_C_SOURCE', env['ROC_POSIX_PLATFORM'])]) @@ -902,18 +902,6 @@ env.Append(CPPDEFINES=[ ('__STDC_LIMIT_MACROS', '1'), ]) -if meta.platform in ['windows']: - env.Append(CPPDEFINES=[ - # enable M_PI and similar - '_USE_MATH_DEFINES', - # disable min() and max() macros - 'NOMINMAX', - # disable winsock1 and redundant macros like far/near - 'WIN32_LEAN_AND_MEAN', - # minimal supported windows version (windows 7) - ('_WIN32_WINNT', '0x0601'), - ]) - # env will hold settings common to all code # subenvs will hold settings specific to particular parts of code subenv_names = 'internal_modules public_libs examples tools tests generated_code'.split() @@ -927,7 +915,7 @@ subenvs = type('subenvs', (), subenv_attrs) env, subenvs = env.SConscript('3rdparty/SConscript', duplicate=0, exports='env subenvs meta') -if meta.platform in ['macos']: +if meta.platform in ['darwin']: if env['ROC_MACOS_PLATFORM']: for var in ['CXXFLAGS', 'CFLAGS', 'LINKFLAGS']: env.Append(**{var: [ diff --git a/docs/sphinx/_static/sphinx_extras.css b/docs/sphinx/_static/sphinx_extras.css index 3c46dde69..b440c5f9c 100644 --- a/docs/sphinx/_static/sphinx_extras.css +++ b/docs/sphinx/_static/sphinx_extras.css @@ -77,7 +77,3 @@ table.align-center { width: 180px; height: 90px; } - -.api-examples li a { - background-color: #d0dcdf36; -} diff --git a/docs/sphinx/about_project/licensing.rst b/docs/sphinx/about_project/licensing.rst index b84e5cdea..aa122e099 100644 --- a/docs/sphinx/about_project/licensing.rst +++ b/docs/sphinx/about_project/licensing.rst @@ -29,4 +29,5 @@ OpenFEC OpenFEC is an optional but very useful dependency that allows to restore lost packets. OpenFEC source code has several licenses. Most of the code is licensed under CeCCIL-C, which is LGPL-like. LDPC-Staircase codec, however, is licensed under CeCCIL, a stricter GPL-like license. There are also portions under BSD-like and CC BY-SA licenses that may require attribution. +OpenFEC If you can't fulfill CeCCIL requirements, you can build OpenFEC with LDPC-Staircase disabled. When using `our fork `_, you can pass ``-DOF_USE_LDPC_STAIRCASE_CODEC=OFF`` option to cmake. Alternatively, you can disable OpenFEC dependency altogether by passing ``--disable-openfec`` option to scons, but then you won't have loss recovery. diff --git a/docs/sphinx/building/dependencies.rst b/docs/sphinx/building/dependencies.rst index 0c6ea02b1..71fc137e1 100644 --- a/docs/sphinx/building/dependencies.rst +++ b/docs/sphinx/building/dependencies.rst @@ -77,6 +77,11 @@ Runtime dependencies - LGPL - optional, enables additional audio file formats + * - `libsndfile `_ + - >= 1.0.26 + - LGPL + - optional, used for audio I/O + * - `libunwind `_ - >= 1.2.1 - X11 @@ -90,7 +95,7 @@ Runtime dependencies * - `OpenFEC `_ - >= 1.4.2 (recommended to use `our fork `_) - CeCCIL-C (LGPL-like) + CeCCIL (GPL-like, only for LDPC-Staircase) + BSD-like + CC BY-SA - - optional, enables packet loss repair with FECFRAME + - optional, used for FECFRAME support * - `OpenSSL `_ - >= 1.1.1 @@ -105,7 +110,7 @@ Runtime dependencies * - `SoX `_ - >= 14.4.0 - LGPL - - optional, enables additional audio file formats and sound servers + - optional, used for audio I/O * - `SpeexDSP `_ - >= 1.2beta3 diff --git a/docs/sphinx/internals/audio_backends.rst b/docs/sphinx/internals/audio_backends.rst index 747341f5e..4097c4c4e 100644 --- a/docs/sphinx/internals/audio_backends.rst +++ b/docs/sphinx/internals/audio_backends.rst @@ -45,7 +45,7 @@ The job of ``roc-send`` and ``roc-recv`` is thus to open a source and a sink and - in ``roc-recv``, ``ISource`` is implemented by receiver pipeline from ``roc_pipeline``, and ``ISink`` is implemented by device or file from ``roc_sndio`` -The task of transferring sound from ``ISource`` to ``ISink`` is implemented in `sndio::IoPump `_ class, which works uniformly with any pair of source and sink, being it file, device, or pipeline. +The task of transferring sound from ``ISource`` to ``ISink`` is implemented in `sndio::Pump `_ class, which works uniformly with any pair of source and sink, being it file, device, or pipeline. Backends and drivers ==================== diff --git a/docs/sphinx/internals/code_structure.rst b/docs/sphinx/internals/code_structure.rst index 89de35b00..5553f3470 100644 --- a/docs/sphinx/internals/code_structure.rst +++ b/docs/sphinx/internals/code_structure.rst @@ -137,6 +137,17 @@ target_pc Enabled for PC (like server, desktop, laptop) target_posix Enabled for a POSIX OS target_posix_ext Enabled for a POSIX OS with POSIX extensions target_posix_pc Enabled for a POSIX OS on PC +target_gnu Enabled for GNU-like libc and compiler +target_darwin Enabled for macOS +target_android Enabled for Android +target_c11 Enabled for C11 compilers +target_libunwind Enabled if libunwind is available +target_libatomic_ops Enabled if libatomic_ops is available +target_libuv Enabled if libuv is available +target_openfec Enabled if OpenFEC is available +target_speexdsp Enabled if SpeexDSP is available +target_sox Enabled if SoX is available +target_sndfile Enabled if libsndfile is available target_pulseaudio Enabled if PulseAudio is available target_sndfile Enabled if libsndfile is available target_sox Enabled if SoX is available diff --git a/scripts/ci_checks/linux-arm/run-tests-in-qemu.sh b/scripts/ci_checks/linux-arm/run-tests-in-qemu.sh index 54c2a3c62..c9d5c21b4 100755 --- a/scripts/ci_checks/linux-arm/run-tests-in-qemu.sh +++ b/scripts/ci_checks/linux-arm/run-tests-in-qemu.sh @@ -20,6 +20,6 @@ find bin/"$toolchain" -name 'roc-test-*' | \ do LD_LIBRARY_PATH="/opt/sysroot/lib:$(echo \ "$PWD/build/3rdparty/$toolchain/$compiler"/*/rpath | tr ' ' ':')" \ - python3 scripts/scons_helpers/timeout-run.py 900 \ + python3 scripts/scons_helpers/timeout-run.py 300 \ "$qemu_cmd" -L "/opt/sysroot" -cpu "$cpu" "$tst" done diff --git a/scripts/ci_checks/linux-checks/check-scons.sh b/scripts/ci_checks/linux-checks/check-scons.sh new file mode 100755 index 000000000..959ec99e7 --- /dev/null +++ b/scripts/ci_checks/linux-checks/check-scons.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -euo pipefail + +scons -Q selftest diff --git a/scripts/scons_helpers/build-3rdparty.py b/scripts/scons_helpers/build-3rdparty.py index 16ecf9b61..64d47aaff 100644 --- a/scripts/scons_helpers/build-3rdparty.py +++ b/scripts/scons_helpers/build-3rdparty.py @@ -287,21 +287,12 @@ def _getvar(var, default): else: args += ['-DCMAKE_BUILD_TYPE=Release'] - if flags: - cflags += [flags] - - if os.name == 'posix' and which('env'): - env_cmd = 'env' - else: - env_cmd = 'cmake -E env' - - cmake_cmd = \ - env_cmd + \ - ' ' + quote('CFLAGS=' + ' '.join(cflags)) + \ - ' ' + quote('CXXFLAGS=' + ' '.join(cflags)) + \ - ' cmake ' + src_dir + ' ' + ' '.join(args) + # compatibility with older cmake files + args += [ + '-DCMAKE_POLICY_VERSION_MINIMUM=3.5', + ] - execute(ctx, cmake_cmd) + execute(ctx, 'cmake ' + src_dir + ' ' + ' '.join(args)) def execute_cmake_build(ctx): cmd = ['cmake', '--build', '.'] @@ -1323,89 +1314,244 @@ def die(text, *args): '--enable-static', ]))) execute_make(ctx) - install_files(ctx, 'src/sndfile.h', ctx.pkg_inc_dir) - install_files(ctx, 'src/.libs/libsndfile.a', ctx.pkg_lib_dir) - elif ctx.pkg_name == 'sox': - download( - ctx, - 'https://downloads.sourceforge.net/project/sox/sox/' - '{ctx.pkg_ver}/sox-{ctx.pkg_ver}.tar.gz', - 'sox-{ctx.pkg_ver}.tar.gz') - unpack( - ctx, - 'sox-{ctx.pkg_ver}.tar.gz', - 'sox-{ctx.pkg_ver}') - changedir(ctx, 'src/sox-{ctx.pkg_ver}') - execute(ctx, './configure --host={host} {vars} {flags} {opts}'.format( - host=ctx.toolchain, - vars=format_vars(ctx), - flags=format_flags(ctx, cflags=' '.join([ - '-w', - '-Wno-implicit-function-declaration', - '-Wno-incompatible-function-pointer-types' - ])), - opts=' '.join([ - '--disable-openmp', - '--disable-shared', - '--enable-static', - '--with-amrnb=no', - '--with-amrwb=no', - '--with-ao=no', - '--with-flac=no', - '--with-gsm=no', - '--with-lpc10=no', - '--with-mp3=no', - '--with-oggvorbis=no', - '--with-opus=no', - '--with-pulseaudio=no', - '--with-sndfile=no', - '--with-sndio=no', - '--with-wavpack=no', - '--without-ao', - '--without-id3tag', - '--without-ladspa', - '--without-lame', - '--without-libltdl', - '--without-mad', - '--without-magic', - '--without-opus', - '--without-png', - '--without-twolame', - ]))) - execute_make(ctx) - install_files(ctx, 'src/sox.h', ctx.pkg_inc_dir) - install_files(ctx, 'src/.libs/libsox.a', ctx.pkg_lib_dir) - elif ctx.pkg_name == 'alsa': - download( - ctx, - 'https://www.alsa-project.org/files/pub/lib/alsa-lib-{ctx.pkg_ver}.tar.bz2', - 'alsa-lib-{ctx.pkg_ver}.tar.bz2') - unpack(ctx, - 'alsa-lib-{ctx.pkg_ver}.tar.bz2', - 'alsa-lib-{ctx.pkg_ver}') - changedir(ctx, 'src/alsa-lib-{ctx.pkg_ver}') - execute(ctx, './configure --host={host} {vars} {opts}'.format( - host=ctx.toolchain, - vars=format_vars(ctx), - opts=' '.join([ - '--disable-python', - '--disable-static', - '--enable-shared', - ]))) - execute_make(ctx) - install_tree(ctx, 'include/alsa', - os.path.join(ctx.pkg_inc_dir, 'alsa'), - exclude=['alsa']) - install_files(ctx, 'src/.libs/libasound.so', ctx.pkg_lib_dir) - install_files(ctx, 'src/.libs/libasound.so.*', ctx.pkg_rpath_dir) - elif ctx.pkg_name == 'pulseaudio': - download( - ctx, - 'https://freedesktop.org/software/pulseaudio/releases/' - 'pulseaudio-{ctx.pkg_ver}.tar.gz', - 'pulseaudio-{ctx.pkg_ver}.tar.gz') - unpack( - ctx, + shutil.copy('.libs/libuv.a', 'libuv.a') + install_tree(ctx, 'include', ctx.pkg_inc_dir) + install_files(ctx, 'libuv.a', ctx.pkg_lib_dir) +elif ctx.pkg_name == 'libatomic_ops': + download( + ctx, + 'https://github.com/ivmai/libatomic_ops/releases/download/' + 'v{ctx.pkg_ver}/libatomic_ops-{ctx.pkg_ver}.tar.gz', + 'libatomic_ops-{ctx.pkg_ver}.tar.gz') + unpack(ctx, + 'libatomic_ops-{ctx.pkg_ver}.tar.gz', + 'libatomic_ops-{ctx.pkg_ver}') + changedir(ctx, 'src/libatomic_ops-{ctx.pkg_ver}') + execute(ctx, './configure --host={host} {vars} {flags} {opts}'.format( + host=ctx.toolchain, + vars=format_vars(ctx), + flags=format_flags(ctx, cflags='-fPIC'), + opts=' '.join([ + '--disable-docs', + '--disable-shared', + '--enable-static', + ]))) + execute_make(ctx) + install_tree(ctx, 'src', ctx.pkg_inc_dir, include=['*.h']) + install_files(ctx, 'src/.libs/libatomic_ops.a', ctx.pkg_lib_dir) +elif ctx.pkg_name == 'libunwind': + download( + ctx, + 'http://download.savannah.nongnu.org/releases/libunwind/' + 'libunwind-{ctx.pkg_ver}.tar.gz', + 'libunwind-{ctx.pkg_ver}.tar.gz') + unpack(ctx, + 'libunwind-{ctx.pkg_ver}.tar.gz', + 'libunwind-{ctx.pkg_ver}') + changedir(ctx, 'src/libunwind-{ctx.pkg_ver}') + execute(ctx, './configure --host={host} {vars} {flags} {opts}'.format( + host=ctx.toolchain, + vars=format_vars(ctx), + flags=format_flags(ctx, cflags='-fcommon -fPIC'), + opts=' '.join([ + '--disable-coredump', + '--disable-minidebuginfo', + '--disable-ptrace', + '--disable-setjmp', + '--disable-shared', + '--enable-static', + ]))) + execute_make(ctx) + install_files(ctx, 'include/*.h', ctx.pkg_inc_dir) + install_files(ctx, 'src/.libs/libunwind.a', ctx.pkg_lib_dir) +elif ctx.pkg_name == 'openfec': + if ctx.variant == 'debug': + setattr(ctx, 'res_dir', 'bin/Debug') + else: + setattr(ctx, 'res_dir', 'bin/Release') + download( + ctx, + 'https://github.com/roc-streaming/openfec/archive/v{ctx.pkg_ver}.tar.gz', + 'openfec_v{ctx.pkg_ver}.tar.gz') + unpack(ctx, + 'openfec_v{ctx.pkg_ver}.tar.gz', + 'openfec-{ctx.pkg_ver}') + changedir(ctx, 'src/openfec-{ctx.pkg_ver}') + mkpath('build') + changedir(ctx, 'build') + execute_cmake(ctx, '..', args=[ + '-DBUILD_STATIC_LIBS=ON', + '-DDEBUG:STRING=%s' % ('ON' if ctx.variant == 'debug' else 'OFF'), + ]) + execute_cmake_build(ctx) + changedir(ctx, '..') + install_tree(ctx, 'src', ctx.pkg_inc_dir, include=['*.h']) + install_files(ctx, '{ctx.res_dir}/libopenfec.a', ctx.pkg_lib_dir) +elif ctx.pkg_name == 'openssl': + download( + ctx, + 'https://www.openssl.org/source/openssl-{ctx.pkg_ver}.tar.gz', + 'openssl-{ctx.pkg_ver}.tar.gz') + unpack( + ctx, + 'openssl-{ctx.pkg_ver}.tar.gz', + 'openssl-{ctx.pkg_ver}') + changedir(ctx, 'src/openssl-{ctx.pkg_ver}') + # see https://github.com/openssl/openssl/blob/master/INSTALL.md#configuration-options + execute(ctx, '{vars} {flags} ./Configure {platform} {variant} {options}'.format( + vars=format_vars(ctx, disable_launcher=True), + flags=format_flags(ctx), + platform=detect_openssl_platform(ctx.host), + variant='--debug' if ctx.variant == 'debug' else '--release', + options=' '.join([ + 'no-asan', + 'no-buildtest-c++', + 'no-external-tests', + 'no-fuzz-afl', + 'no-fuzz-libfuzzer', + 'no-shared', + 'no-tests', + 'no-ubsan', + 'no-ui-console', + 'no-unit-test', + ]))) + execute_make(ctx) + install_tree(ctx, 'include', ctx.pkg_inc_dir) + install_files(ctx, 'libssl.a', ctx.pkg_lib_dir) + install_files(ctx, 'libcrypto.a', ctx.pkg_lib_dir) +elif ctx.pkg_name == 'speexdsp': + if ctx.pkg_ver.split('.', 1) > ['1', '2'] and ( + not re.match('^1.2[a-z]', ctx.pkg_ver) or ctx.pkg_ver == '1.2rc3'): + setattr(ctx, 'pkg_repo', 'speexdsp') + else: + setattr(ctx, 'pkg_repo', 'speex') + download( + ctx, + 'http://downloads.xiph.org/releases/speex/{ctx.pkg_repo}-{ctx.pkg_ver}.tar.gz', + '{ctx.pkg_repo}-{ctx.pkg_ver}.tar.gz') + unpack( + ctx, + '{ctx.pkg_repo}-{ctx.pkg_ver}.tar.gz', + '{ctx.pkg_repo}-{ctx.pkg_ver}') + changedir(ctx, 'src/{ctx.pkg_repo}-{ctx.pkg_ver}') + execute(ctx, './configure --host={host} {vars} {flags} {opts}'.format( + host=ctx.toolchain, + vars=format_vars(ctx), + flags=format_flags(ctx, cflags='-fPIC'), + opts=' '.join([ + '--disable-examples', + '--disable-shared', + '--enable-static', + ]))) + execute_make(ctx) + install_tree(ctx, 'include', ctx.pkg_inc_dir) + install_files(ctx, 'lib{ctx.pkg_repo}/.libs/libspeexdsp.a', ctx.pkg_lib_dir) +elif ctx.pkg_name == 'sndfile': + download( + ctx, + 'http://www.mega-nerd.com/libsndfile/files/libsndfile-{ctx.pkg_ver}.tar.gz', + 'libsndfile-{ctx.pkg_ver}.tar.gz') + unpack( + ctx, + 'libsndfile-{ctx.pkg_ver}.tar.gz', + 'libsndfile-{ctx.pkg_ver}') + changedir(ctx, 'src/libsndfile-{ctx.pkg_ver}') + execute(ctx, '{configure} --host={host} {vars} {flags} {opts}'.format( + configure=' '.join(filter(None, [ + # workaround for outdated config.sub + 'ac_cv_host=%s' % ctx.toolchain if ctx.toolchain else '', + # configure + './configure', + ])), + host=ctx.toolchain, + vars=format_vars(ctx), + # explicitly enable -pthread because libtool doesn't add it on some platforms + flags=format_flags(ctx, cflags='-fPIC', pthread=True), + opts=' '.join([ + '--disable-external-libs', + '--disable-shared', + '--enable-static', + ]))) + execute_make(ctx) + install_files(ctx, 'src/sndfile.h', ctx.pkg_inc_dir) + install_files(ctx, 'src/.libs/libsndfile.a', ctx.pkg_lib_dir) +elif ctx.pkg_name == 'sox': + download( + ctx, + 'https://downloads.sourceforge.net/project/sox/sox/' + '{ctx.pkg_ver}/sox-{ctx.pkg_ver}.tar.gz', + 'sox-{ctx.pkg_ver}.tar.gz') + unpack( + ctx, + 'sox-{ctx.pkg_ver}.tar.gz', + 'sox-{ctx.pkg_ver}') + changedir(ctx, 'src/sox-{ctx.pkg_ver}') + execute(ctx, './configure --host={host} {vars} {flags} {opts}'.format( + host=ctx.toolchain, + vars=format_vars(ctx), + flags=format_flags(ctx, cflags=' '.join([ + '-w', + '-Wno-implicit-function-declaration', + '-Wno-incompatible-function-pointer-types' + ])), + opts=' '.join([ + '--disable-openmp', + '--disable-shared', + '--enable-static', + '--with-amrnb=no', + '--with-amrwb=no', + '--with-ao=no', + '--with-flac=no', + '--with-gsm=no', + '--with-lpc10=no', + '--with-mp3=no', + '--with-oggvorbis=no', + '--with-opus=no', + '--with-pulseaudio=no', + '--with-sndfile=no', + '--with-sndio=no', + '--with-wavpack=no', + '--without-ao', + '--without-id3tag', + '--without-ladspa', + '--without-lame', + '--without-libltdl', + '--without-mad', + '--without-magic', + '--without-opus', + '--without-png', + '--without-twolame', + ]))) + execute_make(ctx) + install_files(ctx, 'src/sox.h', ctx.pkg_inc_dir) + install_files(ctx, 'src/.libs/libsox.a', ctx.pkg_lib_dir) +elif ctx.pkg_name == 'alsa': + download( + ctx, + 'https://www.alsa-project.org/files/pub/lib/alsa-lib-{ctx.pkg_ver}.tar.bz2', + 'alsa-lib-{ctx.pkg_ver}.tar.bz2') + unpack(ctx, + 'alsa-lib-{ctx.pkg_ver}.tar.bz2', + 'alsa-lib-{ctx.pkg_ver}') + changedir(ctx, 'src/alsa-lib-{ctx.pkg_ver}') + execute(ctx, './configure --host={host} {vars} {opts}'.format( + host=ctx.toolchain, + vars=format_vars(ctx), + opts=' '.join([ + '--disable-python', + '--disable-static', + '--enable-shared', + ]))) + execute_make(ctx) + install_tree(ctx, 'include/alsa', + os.path.join(ctx.pkg_inc_dir, 'alsa'), + exclude=['alsa']) + install_files(ctx, 'src/.libs/libasound.so', ctx.pkg_lib_dir) + install_files(ctx, 'src/.libs/libasound.so.*', ctx.pkg_rpath_dir) +elif ctx.pkg_name == 'pulseaudio': + download( + ctx, + 'https://freedesktop.org/software/pulseaudio/releases/' 'pulseaudio-{ctx.pkg_ver}.tar.gz', 'pulseaudio-{ctx.pkg_ver}') pa_ver = parse_ver(ctx.pkg_ver, int) diff --git a/scripts/scons_plugin/commands.py b/scripts/scons_plugin/commands.py index ee8a46ebc..0e05de131 100644 --- a/scripts/scons_plugin/commands.py +++ b/scripts/scons_plugin/commands.py @@ -42,16 +42,11 @@ def HeaderFormat(env, src_dir): files=' '.join(map(str, files))), env.PrettyCommand('FMT', env.Dir(src_dir).path, 'yellow')) -def DocTest(env, path): - try: - path = env.Dir(path).path - except: - path = env.File(path).path +def SelfTest(env): return env.Action( - '{python} scripts/scons_helpers/doctests.py {module}'.format( - python=quote(env.GetPythonExecutable()), - module=quote(path)), - env.PrettyCommand('DOCTEST', path, 'green')) + '{python} scripts/scons_helpers/build-3rdparty.py --self-test'.format( + python=quote(env.GetPythonExecutable())), + env.PrettyCommand('TEST', 'build-3rdparty.py', 'green')) def Doxygen(env, build_dir='', html_dir=None, config='', sources=[], werror=False): target = os.path.join(build_dir, 'commit') @@ -311,7 +306,7 @@ def noop(target, source, env): def init(env): env.AddMethod(ClangFormat, 'ClangFormat') env.AddMethod(HeaderFormat, 'HeaderFormat') - env.AddMethod(DocTest, 'DocTest') + env.AddMethod(SelfTest, 'SelfTest') env.AddMethod(Doxygen, 'Doxygen') env.AddMethod(Sphinx, 'Sphinx') env.AddMethod(Ragel, 'Ragel') diff --git a/shell.nix b/shell.nix index 1a402b25e..c89348462 100644 --- a/shell.nix +++ b/shell.nix @@ -1,52 +1,34 @@ -# Development shell initialization for NixOS. -# -# Details: https://roc-streaming.org/toolkit/docs/building/dependencies.html +{ pkgs ? import {} }: -{ - pkgs ? import { }, -}: + pkgs.mkShell { + buildInputs = [ + # build deps + pkgs.autoconf + pkgs.automake + pkgs.clang + pkgs.cmake + pkgs.gcc + pkgs.gengetopt + pkgs.gnumake + pkgs.intltool + pkgs.libtool + pkgs.meson + pkgs.pkg-config + pkgs.ragel + pkgs.scons -pkgs.clangStdenv.mkDerivation { - name = "clang-shell"; + # other deps + pkgs.libpulseaudio + pkgs.libsndfile + pkgs.libunwind + pkgs.libuv + pkgs.openssl + pkgs.sox + pkgs.speexdsp - nativeBuildInputs = [ - pkgs.clang-tools - # A properly wrapped clangd is already made available by the clang-tools derivation. - # clang-tools has to come before clang to set precedence in PATH for clangd. - pkgs.clang - - # build deps - pkgs.autoconf - pkgs.automake - pkgs.cmake - pkgs.gengetopt - pkgs.gnumake - pkgs.intltool - pkgs.libtool - pkgs.meson - pkgs.pkg-config - pkgs.ragel - pkgs.scons - - # documentation - pkgs.doxygen - #~pkgs.graphviz-nox - #~(pkgs.python3.withPackages(ps: with ps; [ breathe sphinx ])) - ]; - - buildInputs = [ - # other deps - pkgs.libpulseaudio - pkgs.libsndfile - pkgs.libunwind - pkgs.libuuid - pkgs.libuv - pkgs.openssl - pkgs.sox - pkgs.speexdsp - - # optional deps: formatting, tests, ... - pkgs.cpputest - pkgs.gbenchmark - ]; -} + # optional deps: formatting, tests, ... + pkgs.clang-tools + pkgs.cpputest + pkgs.gbenchmark + ]; + } diff --git a/src/internal_modules/Doxyfile b/src/internal_modules/Doxyfile index 7151ea6a1..50a5b396c 100644 --- a/src/internal_modules/Doxyfile +++ b/src/internal_modules/Doxyfile @@ -11,8 +11,7 @@ STRIP_FROM_INC_PATH = . FILE_PATTERNS = *.h *.dox EXCLUDE = \ - roc_core/target_posix/roc_core/cpu_traits.h \ - roc_core/target_windows/roc_core/cpu_traits.h + roc_core/target_posix/roc_core/cpu_traits.h EXCLUDE_SYMBOLS = \ AllocationPolicy @@ -42,17 +41,12 @@ ENABLE_PREPROCESSING = YES MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES -PREDEFINED = \ - ROC_DOXYGEN= \ - ROC_EXPORT= \ - ROC_ALIGNED= \ - ROC_PACKED_BEGIN= \ - ROC_PACKED_END= \ - ROC_PRINTF(x,y)= \ - ROC_NORETURN= \ - ROC_NODISCARD= \ - ROC_NOUNUSED= \ - ROC_NOSANITIZE= +PREDEFINED = \ + ROC_ATTR_NORETURN= \ + ROC_ATTR_NODISCARD= \ + ROC_ATTR_PRINTF(x,y)= \ + ROC_ATTR_PACKED_BEGIN= \ + ROC_ATTR_PACKED_END= OUTPUT_DIRECTORY = ../../build/docs/internal_modules HTML_OUTPUT = ../../../docs/html/doxygen diff --git a/src/internal_modules/main.dox b/src/internal_modules/main.dox index 9aeb36694..81228e8da 100644 --- a/src/internal_modules/main.dox +++ b/src/internal_modules/main.dox @@ -13,12 +13,6 @@ namespace roc { namepsace core {} } -namespace roc { - //! @namespace roc::stat - //! Statistical functions. - namepsace stat {} -} - namespace roc { //! @namespace roc::status //! Status codes. diff --git a/src/tests/roc_audio/bench_codecs.cpp b/src/tests/roc_audio/bench_codecs.cpp new file mode 100644 index 000000000..8d3c8f38d --- /dev/null +++ b/src/tests/roc_audio/bench_codecs.cpp @@ -0,0 +1,81 @@ +#include +#include "roc_audio/pcm_encoder.h" +#include "roc_audio/pcm_decoder.h" +#include "roc_audio/sample_spec.h" +#include "roc_audio/channel_set.h" +#include "roc_audio/channel_defs.h" +#include +#include + +using namespace roc::audio; + +static void bench_pcm_encoder(benchmark::State& s) { + ChannelSet channels( + ChanLayout_Surround, + ChanOrder_Smpte, + ChanMask_Surround_Stereo + ); + + SampleSpec spec( + 48000, + PcmFormat_Float32, + channels + ); + + PcmEncoder enc(spec); + + const size_t samples_per_channel = 48000; + const size_t num_channels = channels.num_channels(); + const size_t total_samples = samples_per_channel * num_channels; + + std::vector samples(total_samples, 0.0f); + + // encoded_byte_count expects samples per channel + size_t frame_size = enc.encoded_byte_count(samples_per_channel); + std::vector frame(frame_size); + + for (auto _ : s) { + enc.begin(frame.data(), frame_size); + enc.write(samples.data(), total_samples); + enc.end(); + } + + s.SetItemsProcessed(int64_t(s.iterations()) * int64_t(total_samples)); +} + +static void bench_pcm_decoder(benchmark::State& s) { + ChannelSet channels( + ChanLayout_Surround, + ChanOrder_Smpte, + ChanMask_Surround_Stereo + ); + + SampleSpec spec( + 48000, + PcmFormat_Float32, + channels + ); + + PcmDecoder dec(spec); + + const size_t samples_per_channel = 48000; + const size_t num_channels = channels.num_channels(); + const size_t total_samples = samples_per_channel * num_channels; + + std::vector samples(total_samples, 0.0f); + + // For PCM float32 encoded frame size (bytes) = samples_per_channel * num_channels * sizeof(float) + size_t frame_size = samples_per_channel * num_channels * sizeof(float); + std::vector frame(frame_size); + + for (auto _ : s) { + dec.begin(0, frame.data(), frame.size()); + dec.read(samples.data(), total_samples); + dec.end(); + } + + s.SetItemsProcessed(int64_t(s.iterations()) * int64_t(total_samples)); +} + +BENCHMARK(bench_pcm_encoder); +BENCHMARK(bench_pcm_decoder); diff --git a/src/tests/roc_core/test_spsc_ring_buffer.cpp b/src/tests/roc_core/test_spsc_ring_buffer.cpp index cbcc0c451..d22cf58ea 100644 --- a/src/tests/roc_core/test_spsc_ring_buffer.cpp +++ b/src/tests/roc_core/test_spsc_ring_buffer.cpp @@ -44,7 +44,6 @@ struct Object { Object& operator=(const Object& other) { value = other.value; - valid = other.valid; return *this; } };