Skip to content

Commit

Permalink
Support Portaudio on Linux (shared lib only)
Browse files Browse the repository at this point in the history
And potentially on macOS too, but that is completely untested.
  • Loading branch information
npostavs committed Jun 18, 2021
1 parent bb017bd commit 8113c4f
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 79 deletions.
58 changes: 34 additions & 24 deletions Jamulus.pro
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ CONFIG += qt \
lrelease

CONFIG (portaudio) {
message("driver WINDOWS portaudio")
} else {
message("driver WINDOWS standard")
message("driver portaudio")
}

QT += network \
Expand Down Expand Up @@ -156,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 @@ -199,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 @@ -224,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 @@ -360,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 @@ -374,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 @@ -540,6 +544,9 @@ win32 {
$$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 \
Expand Down Expand Up @@ -755,8 +762,13 @@ win32 {
SOURCES_CXX_PORTAUDIO -= libs/portaudio/src/hostapi/asio/iasiothiscallresolver.cpp
}
} else:unix {
# FIXME: also some hostapi files, probably.
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
Expand Down Expand Up @@ -1217,25 +1229,23 @@ CONFIG(portaudio) {
DEFINES += USE_PORTAUDIO
HEADERS += src/portaudiosound.h
SOURCES += src/portaudiosound.cpp
win32 {
CONFIG(portaudio_shared_lib) {
LIBS += $$libnames(portaudio)
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 {
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
SOURCES += $$SOURCES_PORTAUDIO $$SOURCES_CXX_PORTAUDIO
}
DISTFILES += $$DISTFILES_PORTAUDIO
LIBS += $$libnames(winmm ole32 uuid setupapi)
} else {
error( "portaudio only tested on win32 for now" )
error ( "non-shared portaudio only implemented for win32" )
}
}

Expand Down
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,
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
42 changes: 16 additions & 26 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,23 @@
#include "signalhandler.h"
#ifdef LLCON_VST_PLUGIN
# include "vstsound.h"
#elif defined( USE_PORTAUDIO )
# include "portaudiosound.h"
#elif defined( _WIN32 ) && !defined( JACK_REPLACES_ASIO )
# include "../windows/sound.h"
#elif defined( Q_OS_MACX ) && !defined( JACK_REPLACES_COREAUDIO )
# include "../mac/sound.h"
#elif defined( Q_OS_IOS )
# include "../ios/sound.h"
#elif defined( ANDROID )
# include "../android/sound.h"
#else
# if defined( _WIN32 ) && !defined( JACK_REPLACES_ASIO )
# ifdef USE_PORTAUDIO
// FIXME: this shouldn't be windows specific
# include "portaudiosound.h"
# else
# include "../windows/sound.h"
# endif
# else
# if ( defined( Q_OS_MACX ) ) && !defined( JACK_REPLACES_COREAUDIO )
# include "../mac/sound.h"
# else
# if defined( Q_OS_IOS )
# include "../ios/sound.h"
# else
# ifdef ANDROID
# include "../android/sound.h"
# else
# include "../linux/sound.h"
# ifndef JACK_REPLACES_ASIO // these headers are not available in Windows OS
# include <sched.h>
# include <netdb.h>
# endif
# include <socket.h>
# endif
# endif
# endif
# include "../linux/sound.h"
# ifndef JACK_REPLACES_ASIO // these headers are not available in Windows OS
# include <sched.h>
# include <netdb.h>
# endif
# include <socket.h>
#endif

/* Definitions ****************************************************************/
Expand Down Expand Up @@ -118,6 +107,7 @@ class CClient : public QObject
const QString& strMIDISetup,
const bool bNoAutoJackConnect,
const QString& strNClientName,
const QString& strApiName,
const bool bNMuteMeInPersonalMix );

virtual ~CClient();
Expand Down
7 changes: 4 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,11 @@ int main ( int argc, char** argv )
strConnOnStartupAddress,
strMIDISetup,
bNoAutoJackConnect,
#if defined (_WIN32) && defined (USE_PORTAUDIO)
strApiName, // TODO: don't abuse Jack client name for this.
#else
strClientName,
#ifdef USE_PORTAUDIO
strApiName,
#else
"",
#endif
bMuteMeInPersonalMix );

Expand Down
Loading

0 comments on commit 8113c4f

Please sign in to comment.