Skip to content
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
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ elseif(UNIX)
)
target_include_directories(PortAudio PRIVATE src/os/unix)
target_link_libraries(PortAudio PRIVATE m)
set(PKGCONFIG_LDFLAGS_PRIVATE "${PKGCONFIG_LDFLAGS_PUBLIC} -lm -lpthread")
if (NOT WASM)
set(PKGCONFIG_LDFLAGS_PRIVATE "${PKGCONFIG_LDFLAGS_PUBLIC} -lm -lpthread")
endif()
set(PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS} -pthread")

if(APPLE)
Expand Down Expand Up @@ -330,6 +332,17 @@ elseif(UNIX)

set(PKGCONFIG_LDFLAGS_PRIVATE
"${PKGCONFIG_LDFLAGS_PRIVATE} -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreFoundation -framework CoreServices")
elseif(WASM)
option(PA_USE_WEBAUDIO "Enable support for WebAudio" ON)

if (PA_USE_WEBAUDIO)
target_compile_definitions(PortAudio PUBLIC PA_USE_WEBAUDIO=1)
set(PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS} -DPA_USE_WEBAUDIO=1")

set(PORTAUDIO_PUBLIC_HEADERS ${PORTAUDIO_PUBLIC_HEADERS} include/pa_webaudio.h)
target_sources(PortAudio PRIVATE src/hostapi/webaudio/pa_webaudio.c)
set(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIOS} PA_USE_WEBAUDIO)
endif()
else()
# Some BSDs have a reimplementation of alsalib, so do not explicitly check for Linux.
find_package(ALSA)
Expand Down
16 changes: 16 additions & 0 deletions doc/src/tutorial/compiling_wasm.dox
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** @page compile_wasm Building PortAudio for WebAssemblys
@ingroup tutorial

<b>NOTE:</b> These instructions best work under Linux. Other platforms haven't been tested and might not work.

Building PortAudio for WebAssembly is support only through CMake. To build PortAudio for WebAssembly, you need to install Emscripten. Follow the instructions at https://emscripten.org/docs/getting_started/downloads.html to install and setup Emscripten. Make sure that you also install emcmake and emmake as well.

Once you've installed Emscripten, run the following:

@code
mkdir build && cd build
emcmake cmake -DWASM=1 <portaudio_root>
emmake make
@endcode

*/
12 changes: 12 additions & 0 deletions include/pa_webaudio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef PA_WEBAUDIO_H
#define PA_WEBAUDIO_H

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif

#endif
7 changes: 7 additions & 0 deletions src/common/pa_hostapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ are defaulted to 1.
#error "Portaudio: PA_NO_<APINAME> is no longer supported, please remove definition and use PA_USE_<APINAME> instead"
#endif

#ifndef PA_USE_WEBAUDIO
#define PA_USE_WEBAUDIO 0
#elif (PA_USE_WEBAUDIO != 0) && (PA_USE_WEBAUDIO != 1)
#undef PA_USE_WEBAUDIO
#define PA_USE_WEBAUDIO 1
#endif

#ifndef PA_USE_OSS
#define PA_USE_OSS 0
#elif (PA_USE_OSS != 0) && (PA_USE_OSS != 1)
Expand Down
Loading