Skip to content

Commit

Permalink
Libsndfile Sink and Source
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrick87 committed Dec 16, 2023
1 parent 9fb7379 commit 9a64a0e
Show file tree
Hide file tree
Showing 36 changed files with 1,892 additions and 161 deletions.
44 changes: 44 additions & 0 deletions 3rdparty/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,50 @@ elif 'sox' in system_dependencies:

env = conf.Finish()

# dep: sndfile
if 'sndfile' in autobuild_dependencies:
sndfile_deps = []

if 'alsa' in autobuild_dependencies:
sndfile_deps += ['alsa']

if 'pulseaudio' in autobuild_dependencies:
sndfile_deps += ['pulseaudio']

env.BuildThirdParty(thirdparty_versions, 'sndfile', deps=sndfile_deps)

conf = Configure(env, custom_tests=env.CustomTests)

if not 'alsa' in autobuild_dependencies:
for lib in [
'asound',
]:
conf.CheckLib(lib)

if meta.platform in ['darwin']:
env.Append(LINKFLAGS=[
'-Wl,-framework,CoreAudio'
])

env = conf.Finish()

elif 'sndfile' in system_dependencies:
conf = Configure(env, custom_tests=env.CustomTests)

if not conf.AddPkgConfigDependency('sndfile', '--cflags --libs', exclude_from_pc=True):
conf.env.AddManualDependency(libs=['sndfile'], exclude_from_pc=True)

if not is_crosscompiling:
if not conf.CheckLibWithHeaderExt(
'sndfile', 'sndfile.h', 'C',
expr='SNDFILE_LIB_VERSION_CODE >= SNDFILE_LIB_VERSION(1, 0, 28'):
env.Die("libsndfile >= 1.0.28 not found (see 'config.log' for details)")
else:
if not conf.CheckLibWithHeaderExt('sndfile', 'sndfile.h', 'C', run=False):
env.Die("libsndfile not found (see 'config.log' for details)")

env = conf.Finish()

# dep: ragel
if 'ragel' in autobuild_dependencies:
env.BuildThirdParty(thirdparty_versions, 'ragel', is_native=True)
Expand Down
9 changes: 9 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ AddOption('--disable-sox',
action='store_true',
help='disable SoX support in tools')

AddOption('--disable-sndfile',
dest='disable_sndfile',
action='store_true',
help='disable SndFile support in tools')

AddOption('--disable-openssl',
dest='disable_openssl',
action='store_true',
Expand Down Expand Up @@ -821,6 +826,10 @@ else:
env.Append(ROC_TARGETS=[
'target_sox',
])
if not GetOption('disable_sndfile'):
env.Append(ROC_TARGETS=[
'target_sndfile',
])
if not GetOption('disable_alsa') and meta.platform in ['linux']:
env.Append(ROC_TARGETS=[
'target_alsa',
Expand Down
2 changes: 1 addition & 1 deletion scripts/android_emu/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ then
--enable-tests \
--disable-soversion \
--disable-tools \
--build-3rdparty=libuv,openfec,openssl,speexdsp,cpputest
--build-3rdparty=libuv,openfec,openssl,speexdsp,cpputest,sndfile
fi

if [[ "${action}" == prep ]]
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci_checks/android/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ scons -Q \
--disable-soversion \
--disable-tools \
--enable-tests \
--build-3rdparty=libuv,openfec,speexdsp,openssl,cpputest \
--build-3rdparty=libuv,openfec,speexdsp,openssl,cpputest,sndfile \
--compiler=clang \
--host="$1"
2 changes: 1 addition & 1 deletion scripts/ci_checks/linux-arm/aarch64-linux-gnu-gcc-7.4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain="aarch64-linux-gnu"
compiler="gcc-7.4.1-release"
cpu="cortex-a53" # armv8

third_party="libuv,libunwind,openfec,alsa,speexdsp,sox,openssl,cpputest"
third_party="libuv,libunwind,openfec,alsa,speexdsp,sox,openssl,cpputest,sndfile"

for pulse_ver in 8.0 15.99.1
do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain="arm-bcm2708hardfp-linux-gnueabi"
compiler="gcc-4.7.1-release"
cpu="arm1176" # armv6

third_party="libuv,libunwind,libatomic_ops,openfec,alsa,pulseaudio:5.0,speexdsp,sox,openssl,cpputest"
third_party="libuv,libunwind,libatomic_ops,openfec,alsa,pulseaudio:5.0,speexdsp,sox,openssl,cpputest,sndfile"

scons -Q \
--enable-werror \
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci_checks/linux-arm/arm-linux-gnueabihf-gcc-4.9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain="arm-linux-gnueabihf"
compiler="gcc-4.9.4-release"
cpu="cortex-a15" # armv7

third_party="libuv,libunwind,openfec,alsa,pulseaudio:10.0,speexdsp,sox,openssl,cpputest"
third_party="libuv,libunwind,openfec,alsa,pulseaudio:10.0,speexdsp,sox,openssl,cpputest,sndfile"

scons -Q \
--enable-werror \
Expand Down
4 changes: 3 additions & 1 deletion scripts/ci_checks/linux-checks/conditional-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ scons -Q --enable-werror --build-3rdparty=all \
--disable-openfec \
--disable-speex \
--disable-sox \
--disable-pulseaudio
--disable-pulseaudio \
--disable-sndfile \

# optional dependencies: none, optional targets: all
scons -Q --enable-werror --build-3rdparty=all \
Expand All @@ -24,6 +25,7 @@ scons -Q --enable-werror --build-3rdparty=all \
--disable-speex \
--disable-sox \
--disable-pulseaudio \
--disable-sndfile \
test

# optional dependencies: all, optional targets: all
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci_checks/linux-checks/pulseaudio-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ do
--enable-werror \
--enable-tests \
--enable-examples \
--build-3rdparty=openfec,pulseaudio:$pulse_ver \
--build-3rdparty=openfec,pulseaudio:$pulse_ver,sndfile \
test
done
2 changes: 1 addition & 1 deletion scripts/ci_checks/linux-x86_64/alpine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ scons -Q \
--enable-benchmarks \
--enable-examples \
--enable-doxygen \
--build-3rdparty=openfec,cpputest,google-benchmark \
--build-3rdparty=openfec,cpputest,google-benchmark,sndfile \
test
2 changes: 1 addition & 1 deletion scripts/ci_checks/linux-x86_64/archlinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ scons -Q \
--enable-benchmarks \
--enable-examples \
--enable-doxygen \
--build-3rdparty=openfec,cpputest,google-benchmark:1.5.5 \
--build-3rdparty=openfec,cpputest,google-benchmark:1.5.5,sndfile \
test
2 changes: 1 addition & 1 deletion scripts/ci_checks/linux-x86_64/debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ scons -Q \
--enable-benchmarks \
--enable-examples \
--enable-doxygen \
--build-3rdparty=libuv,openfec,cpputest \
--build-3rdparty=libuv,openfec,cpputest,sndfile \
test
2 changes: 1 addition & 1 deletion scripts/ci_checks/linux-x86_64/fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ scons -Q \
--enable-benchmarks \
--enable-examples \
--enable-doxygen \
--build-3rdparty=openfec,cpputest \
--build-3rdparty=openfec,cpputest,sndfile \
test
2 changes: 1 addition & 1 deletion scripts/ci_checks/linux-x86_64/opensuse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ scons -Q \
--enable-benchmarks \
--enable-examples \
--enable-doxygen \
--build-3rdparty=openfec,cpputest \
--build-3rdparty=openfec,cpputest,sndfile \
test
2 changes: 1 addition & 1 deletion scripts/ci_checks/linux-x86_64/ubuntu-14.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ do
--enable-tests \
--enable-examples \
--enable-doxygen \
--build-3rdparty=libuv,libatomic_ops,openfec,openssl,pulseaudio,cpputest \
--build-3rdparty=libuv,libatomic_ops,openfec,openssl,pulseaudio,cpputest,sndfile \
--compiler=${comp} \
test
done
2 changes: 1 addition & 1 deletion scripts/ci_checks/linux-x86_64/ubuntu-16.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ do
--enable-benchmarks \
--enable-examples \
--enable-doxygen \
--build-3rdparty=libatomic_ops,openfec,openssl,cpputest,google-benchmark \
--build-3rdparty=libatomic_ops,openfec,openssl,cpputest,google-benchmark,sndfile \
--compiler=${comp} \
test
done
2 changes: 1 addition & 1 deletion scripts/ci_checks/linux-x86_64/ubuntu-18.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ do
--enable-benchmarks \
--enable-examples \
--enable-doxygen \
--build-3rdparty=openfec,google-benchmark \
--build-3rdparty=openfec,google-benchmark,sndfile \
--compiler=${comp} \
test
done
2 changes: 1 addition & 1 deletion scripts/ci_checks/linux-x86_64/ubuntu-20.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ do
--enable-tests \
--enable-benchmarks \
--enable-examples \
--build-3rdparty=openfec \
--build-3rdparty=openfec,sndfile \
--compiler=${comp} \
test
done
2 changes: 1 addition & 1 deletion scripts/ci_checks/linux-x86_64/ubuntu-22.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ do
--enable-tests \
--enable-benchmarks \
--enable-examples \
--build-3rdparty=openfec \
--build-3rdparty=openfec,sndfile \
--compiler=${comp} \
test
done
6 changes: 3 additions & 3 deletions scripts/ci_checks/macos/standard-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euxo pipefail
brew install \
automake scons ragel gengetopt \
libuv speexdsp sox openssl@3 \
cpputest google-benchmark
cpputest google-benchmark libsndfile

# debug build
scons -Q \
Expand All @@ -15,7 +15,7 @@ scons -Q \
--enable-examples \
--enable-debug \
--sanitizers=all \
--build-3rdparty=openfec \
--build-3rdparty=openfec,sndfile \
test

# release build
Expand All @@ -24,5 +24,5 @@ scons -Q \
--enable-tests \
--enable-benchmarks \
--enable-examples \
--build-3rdparty=openfec \
--build-3rdparty=openfec,sndfile \
test
2 changes: 1 addition & 1 deletion src/internal_modules/roc_audio/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Frame : public core::NonCopyable<> {
FlagIncomplete = (1 << 1),

//! Set if some late packets were dropped while the frame was being built.
//! It's not necessarty that the frame itself is blank or incomplete.
//! It's not necessarily that the frame itself is blank or incomplete.
FlagDrops = (1 << 2)
};

Expand Down
4 changes: 4 additions & 0 deletions src/internal_modules/roc_sndio/backend_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ void BackendMap::register_backends_() {
pulseaudio_backend_.reset(new (pulseaudio_backend_) PulseaudioBackend);
add_backend_(pulseaudio_backend_.get());
#endif // ROC_TARGET_PULSEAUDIO
#ifdef ROC_TARGET_SNDFILE
sndfile_backend_.reset(new (sndfile_backend_) SndfileBackend);
add_backend_(sndfile_backend_.get());
#endif // ROC_TARGET_SNDFILE
#ifdef ROC_TARGET_SOX
sox_backend_.reset(new (sox_backend_) SoxBackend);
add_backend_(sox_backend_.get());
Expand Down
8 changes: 8 additions & 0 deletions src/internal_modules/roc_sndio/backend_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include "roc_sndio/pulseaudio_backend.h"
#endif // ROC_TARGET_PULSEAUDIO

#ifdef ROC_TARGET_SNDFILE
#include "roc_sndio/sndfile_backend.h"
#endif // ROC_TARGET_SNDFILE

#ifdef ROC_TARGET_SOX
#include "roc_sndio/sox_backend.h"
#endif // ROC_TARGET_SOX
Expand Down Expand Up @@ -67,6 +71,10 @@ class BackendMap : public core::NonCopyable<> {
core::Optional<PulseaudioBackend> pulseaudio_backend_;
#endif // ROC_TARGET_PULSEAUDIO

#ifdef ROC_TARGET_SNDFILE
core::Optional<SndfileBackend> sndfile_backend_;
#endif // ROC_TARGET_SOX

#ifdef ROC_TARGET_SOX
core::Optional<SoxBackend> sox_backend_;
#endif // ROC_TARGET_SOX
Expand Down
2 changes: 1 addition & 1 deletion src/internal_modules/roc_sndio/isource.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ISource : public IDevice, public audio::IFrameReader {

//! Adjust source clock to match consumer clock.
//! @remarks
//! Invoked regularly after reading every or a several frames.
//! Invoked regularly after reading every or several frames.
//! @p timestamp defines the time in Unix domain when the last sample of the last
//! frame read from source is going to be actually processed by consumer.
virtual void reclock(core::nanoseconds_t timestamp) = 0;
Expand Down
Loading

0 comments on commit 9a64a0e

Please sign in to comment.