Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to use Portaudio (v2) #870

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/autobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ jobs:
cmd3_postbuild: powershell .\autobuild\windows\autobuild_windowsinstaller_3_copy_files.ps1
uses_codeql: true

- config_name: Windows portaudio (artifact+codeQL)
target_os: windows
building_on_os: windows-latest
cmd1_prebuild: powershell .\autobuild\windows\autobuild_windowsinstaller_1_prepare.ps1
cmd2_build: powershell .\autobuild\windows\autobuild_windowsinstaller_2_build_portaudio.ps1
cmd3_postbuild: powershell .\autobuild\windows\autobuild_windowsinstaller_3_copy_files_portaudio.ps1
uses_codeql: true

runs-on: ${{ matrix.config.building_on_os }}
steps:

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
[submodule "tools/jamulus-server-remote"]
path = tools/jamulus-server-remote
url = ../../vdellamea/jamulus-server-remote
[submodule "libs/portaudio"]
path = libs/portaudio
url = ../../npostavs/portaudio.git
153 changes: 132 additions & 21 deletions Jamulus.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ CONFIG += qt \
thread \
lrelease

CONFIG (portaudio) {
message("driver portaudio")
}

QT += network \
xml \
concurrent
Expand Down Expand Up @@ -56,6 +60,11 @@ INCLUDEPATH_OPUS = libs/opus/include \
libs/opus/silk/fixed \
libs/opus

INCLUDEPATH_PORTAUDIO = libs/portaudio/include libs/portaudio/src/common
win32 {
INCLUDEPATH_PORTAUDIO += libs/portaudio/src/os/win
}

DEFINES += APP_VERSION=\\\"$$VERSION\\\" \
CUSTOM_MODES \
_REENTRANT
Expand All @@ -64,31 +73,40 @@ DEFINES += APP_VERSION=\\\"$$VERSION\\\" \
# TODO as soon as we drop support for the old Qt version, remove the following line
DEFINES += QT_NO_DEPRECATED_WARNINGS

# msvc uses a different options syntax for adding libraries.
defineReplace(libnames) {
libopts =
names = $$1
for(libname, names) {
win32-msvc* {
libopts += $${libname}.lib
} else {
libopts += -l$${libname}
}
}
return($$libopts)
}

win32 {
DEFINES -= UNICODE # fixes issue with ASIO SDK (asiolist.cpp is not unicode compatible)
DEFINES += NOMINMAX # solves a compiler error in qdatetime.h (Qt5)
HEADERS += windows/sound.h
SOURCES += windows/sound.cpp \
windows/ASIOSDK2/common/asio.cpp \
!CONFIG(portaudio) {
HEADERS += windows/sound.h
SOURCES += windows/sound.cpp
}
win32-msvc* {
DEFINES += NOMINMAX # solves a compiler error in qdatetime.h (Qt5) when compiling with MSVC, breaks portaudio build under mingw
}

SOURCES += windows/ASIOSDK2/common/asio.cpp \
windows/ASIOSDK2/host/asiodrivers.cpp \
windows/ASIOSDK2/host/pc/asiolist.cpp
RC_FILE = windows/mainicon.rc
INCLUDEPATH += windows/ASIOSDK2/common \
windows/ASIOSDK2/host \
windows/ASIOSDK2/host/pc
mingw* {
LIBS += -lole32 \
-luser32 \
-ladvapi32 \
-lwinmm \
-lws2_32
} else {
LIBS += $$libnames(ole32 user32 advapi32 winmm ws2_32)
win32-msvc* {
QMAKE_LFLAGS += /DYNAMICBASE:NO # fixes crash with libjack64.dll, see https://github.com/jamulussoftware/jamulus/issues/93
LIBS += ole32.lib \
user32.lib \
advapi32.lib \
winmm.lib \
ws2_32.lib
}

# replace ASIO with jack if requested
Expand Down Expand Up @@ -136,8 +154,10 @@ win32 {
}

QT += macextras
HEADERS += mac/sound.h
SOURCES += mac/sound.cpp
!CONFIG(portaudio) {
HEADERS += mac/sound.h
SOURCES += mac/sound.cpp
}
HEADERS += mac/activity.h
OBJECTIVE_SOURCES += mac/activity.mm
CONFIG += x86
Expand Down Expand Up @@ -179,6 +199,7 @@ win32 {
}
} else:ios {
QMAKE_INFO_PLIST = ios/Info.plist
CONFIG(portaudio) { error( "Portaudio not supported on iOS" ) }
QT += macextras
OBJECTIVE_SOURCES += ios/ios_app_delegate.mm
HEADERS += ios/ios_app_delegate.h
Expand All @@ -204,6 +225,7 @@ win32 {
target.path = /tmp/your_executable # path on device
INSTALLS += target

CONFIG(portaudio) { error( "Portaudio not supported on Android" ) }
HEADERS += android/sound.h \
android/ring_buffer.h

Expand Down Expand Up @@ -340,8 +362,10 @@ win32 {
# unnecessarily without this workaround (#741):
QMAKE_LFLAGS += -Wl,--as-needed

HEADERS += linux/sound.h
SOURCES += linux/sound.cpp
!CONFIG(portaudio) {
HEADERS += linux/sound.h
SOURCES += linux/sound.cpp
}

# we assume to have lrintf() one moderately modern linux distributions
# would be better to have that tested, though
Expand All @@ -354,7 +378,7 @@ win32 {
contains(CONFIG, "nosound") {
message(Restricting build to server-only due to CONFIG+=nosound.)
DEFINES += SERVER_ONLY
} else {
} else:!CONFIG(portaudio) {
message(Jack Audio Interface Enabled.)

contains(CONFIG, "raspijamulus") {
Expand Down Expand Up @@ -512,6 +536,19 @@ HEADERS_OPUS_X86 = libs/opus/celt/x86/celt_lpc_sse.h \
libs/opus/celt/x86/x86cpu.h \
$$files(libs/opus/silk/x86/*.h)

HEADERS_PORTAUDIO = $$files(libs/portaudio/include/*.h) $$files(libs/portaudio/src/common/*.h)

win32 {
HEADERS_PORTAUDIO += $$files(libs/portaudio/src/os/win/*.h) \
$$files(libs/portaudio/src/hostapi/asio/*.h) \
$$files(libs/portaudio/src/hostapi/wdmks/*.h) \
$$files(libs/portaudio/src/hostapi/wmme/*.h) \
$$files(libs/portaudio/src/hostapi/wasapi/*.h)
} else {
# Mac OS X uses the portaudio unix header files too.
HEADERS_PORTAUDIO += $$files(libs/portaudio/src/os/unix/*.h)
}

SOURCES += src/buffer.cpp \
src/channel.cpp \
src/client.cpp \
Expand Down Expand Up @@ -710,6 +747,52 @@ contains(QT_ARCH, armeabi-v7a) | contains(QT_ARCH, arm64-v8a) {
}
DEFINES_OPUS += OPUS_BUILD=1 USE_ALLOCA=1 OPUS_HAVE_RTCD=1 HAVE_LRINTF=1 HAVE_LRINT=1


SOURCES_PORTAUDIO = $$files(libs/portaudio/src/common/*.c)
SOURCES_CXX_PORTAUDIO =

win32 {
SOURCES_PORTAUDIO += $$files(libs/portaudio/src/os/win/*.c) \
$$files(libs/portaudio/src/hostapi/wdmks/*.c) \
$$files(libs/portaudio/src/hostapi/wmme/*.c) \
$$files(libs/portaudio/src/hostapi/wasapi/*.c)
SOURCES_CXX_PORTAUDIO += $$files(libs/portaudio/src/hostapi/asio/*.cpp)
# Adapter for C++ compiler-specific calling convention not needed for msvc
win32-msvc* {
SOURCES_CXX_PORTAUDIO -= libs/portaudio/src/hostapi/asio/iasiothiscallresolver.cpp
}
} else:unix {
SOURCES_PORTAUDIO += $$files(libs/portaudio/src/os/unix/*.c)
SOURCES_PORTAUDIO += $$files(libs/portaudio/src/os/hostapi/alsa/*.c) \
$$files(libs/portaudio/src/os/hostapi/jack/*.c) \
$$files(libs/portaudio/src/os/hostapi/oss/*.c)
} else:macx {
SOURCES_PORTAUDIO += $$files(libs/portaudio/src/os/unix/*.c)
SOURCES_PORTAUDIO += $$files(libs/portaudio/src/os/hostapi/coreaudio/*.c)
}

# I can't figure out how to make the custom compiler stuff work for
# msvc, we'll have to live with portaudio compile warnings in that
# build.
!win32-msvc* {
# Suppress warnings from portaudio sources, with -w
# NOTE: we set portaudio(cc|cxx).variable_out to OBJECTS down near the
# bottom depending on the configuration.
# See also
# - https://wiki.qt.io/Undocumented_QMake#Custom_tools
# - https://stackoverflow.com/questions/27683777/how-to-specify-compiler-flag-to-a-single-source-file-with-qmake
portaudiocc.name = portaudiocc
portaudiocc.input = SOURCES_PORTAUDIO
portaudiocc.dependency_type = TYPE_C
portaudiocc.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_IN_BASE}$${first(QMAKE_EXT_OBJ)}
portaudiocc.commands = ${CC} $(CFLAGS) -w $(INCPATH) -c ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
portaudiocxx.name = portaudiocxx
portaudiocxx.input = SOURCES_CXX_PORTAUDIO
portaudiocxx.dependency_type = TYPE_C
portaudiocxx.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_IN_BASE}$${first(QMAKE_EXT_OBJ)}
portaudiocxx.commands = ${CXX} $(CXXFLAGS) -w $(INCPATH) -c ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
}

DISTFILES += ChangeLog \
COPYING \
CONTRIBUTING.md \
Expand Down Expand Up @@ -1074,6 +1157,9 @@ DISTFILES_OPUS += libs/opus/AUTHORS \
libs/opus/celt/arm/armopts.s.in \
libs/opus/celt/arm/celt_pitch_xcorr_arm.s \

DISTFILES_PORTAUDIO += libs/portaudio/LICENSE.txt \
libs/portaudio/README.txt

contains(CONFIG, "headless") {
DEFINES += HEADLESS
} else {
Expand Down Expand Up @@ -1138,6 +1224,31 @@ contains(CONFIG, "opus_shared_lib") {
}
}


CONFIG(portaudio) {
DEFINES += USE_PORTAUDIO
HEADERS += src/portaudiosound.h
SOURCES += src/portaudiosound.cpp
CONFIG(portaudio_shared_lib) {
LIBS += $$libnames(portaudio)
} else:win32 {
DEFINES += PA_USE_ASIO=1 PA_USE_WASAPI=1 PA_USE_WDMKS=1
INCLUDEPATH += $$INCLUDEPATH_PORTAUDIO
HEADERS += $$HEADERS_PORTAUDIO
mingw {
portaudiocxx.variable_out = OBJECTS
portaudiocc.variable_out = OBJECTS
QMAKE_EXTRA_COMPILERS += portaudiocc portaudiocxx
} else {
SOURCES += $$SOURCES_PORTAUDIO $$SOURCES_CXX_PORTAUDIO
}
DISTFILES += $$DISTFILES_PORTAUDIO
LIBS += $$libnames(winmm ole32 uuid setupapi)
} else {
error ( "non-shared portaudio only implemented for win32" )
}
}

# disable version check if requested (#370)
contains(CONFIG, "disable_version_check") {
message(The version check is disabled.)
Expand Down
34 changes: 34 additions & 0 deletions autobuild/windows/autobuild_windowsinstaller_2_build_portaudio.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Powershell

# autobuild_2_build: actual build process


####################
### PARAMETERS ###
####################

# Get the source path via parameter
param (
[string] $jamulus_project_path = $Env:jamulus_project_path
)
# Sanity check of parameters
if (("$jamulus_project_path" -eq $null) -or ("$jamulus_project_path" -eq "")) {
throw "expecting ""jamulus_project_path"" as parameter or ENV"
} elseif (!(Test-Path -Path $jamulus_project_path)) {
throw "non.existing jamulus_project_path: $jamulus_project_path"
} else {
echo "jamulus_project_path is valid: $jamulus_project_path"
}


###################
### PROCEDURE ###
###################

# set variable to build with portaudio
$Env:jamulus_build_config="portaudio"

echo "Build installer..."
# Build the installer
powershell "$jamulus_project_path\windows\deploy_windows.ps1" "C:\Qt\5.15.2"

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (($jamulus_buildversionstring -eq $null) -or ($jamulus_buildversionstring -eq

# Rename the file
echo "rename"
$artifact_deploy_filename = "jamulus_${Env:jamulus_buildversionstring}_win.exe"
$artifact_deploy_filename = "jamulus_standard_${Env:jamulus_buildversionstring}_win.exe"
echo "rename deploy file to $artifact_deploy_filename"
cp "$jamulus_project_path\deploy\Jamulus*installer-win.exe" "$jamulus_project_path\deploy\$artifact_deploy_filename"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Powershell

# autobuild_3_copy_files: copy the built files to deploy folder


####################
### PARAMETERS ###
####################

# Get the source path via parameter
param (
[string] $jamulus_project_path = $Env:jamulus_project_path,
[string] $jamulus_buildversionstring = $Env:jamulus_buildversionstring
)
# Sanity check of parameters
if (("$jamulus_project_path" -eq $null) -or ("$jamulus_project_path" -eq "")) {
throw "expecting ""jamulus_project_path"" as parameter or ENV"
} elseif (!(Test-Path -Path "$jamulus_project_path")) {
throw "non.existing jamulus_project_path: $jamulus_project_path"
} else {
echo "jamulus_project_path is valid: $jamulus_project_path"
}
if (($jamulus_buildversionstring -eq $null) -or ($jamulus_buildversionstring -eq "")) {
echo "expecting ""jamulus_buildversionstring"" as parameter or ENV"
echo "using ""NoVersion"" as jamulus_buildversionstring for filenames"
$jamulus_buildversionstring = "NoVersion"
}


###################
### PROCEDURE ###
###################

# Rename the file
echo "rename"
$artifact_deploy_filename = "jamulus_portaudio_${Env:jamulus_buildversionstring}_win.exe"
echo "rename deploy file to $artifact_deploy_filename"
cp "$jamulus_project_path\deploy\Jamulus*installer-win.exe" "$jamulus_project_path\deploy\$artifact_deploy_filename"




Function github_output_value
{
param (
[Parameter(Mandatory=$true)]
[string] $name,
[Parameter(Mandatory=$true)]
[string] $value
)

echo "github_output_value() $name = $value"
echo "::set-output name=$name::$value"
}


github_output_value -name "artifact_1" -value "$artifact_deploy_filename"
1 change: 1 addition & 0 deletions libs/portaudio
Submodule portaudio added at e0d9b7
12 changes: 11 additions & 1 deletion src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ CClient::CClient ( const quint16 iPortNumber,
const QString& strMIDISetup,
const bool bNoAutoJackConnect,
const QString& strNClientName,
const QString& strApiName,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#ifdef around this.

const bool bNMuteMeInPersonalMix ) :
ChannelInfo(),
strClientName ( strNClientName ),
Expand All @@ -47,7 +48,16 @@ CClient::CClient ( const quint16 iPortNumber,
bMuteOutStream ( false ),
fMuteOutStreamGain ( 1.0f ),
Socket ( &Channel, iPortNumber, iQosNumber ),
Sound ( AudioCallback, this, strMIDISetup, bNoAutoJackConnect, strNClientName ),
Sound ( AudioCallback,
this,
strMIDISetup,
bNoAutoJackConnect,
strNClientName
#ifdef USE_PORTAUDIO
,
strApiName
#endif
),
iAudioInFader ( AUD_FADER_IN_MIDDLE ),
bReverbOnLeftChan ( false ),
iReverbLevel ( 0 ),
Expand Down
Loading