Skip to content

Commit

Permalink
Add webaudio hostapi
Browse files Browse the repository at this point in the history
  • Loading branch information
ahilss authored and fwcd committed Mar 5, 2024
1 parent 4600d81 commit d3df80d
Show file tree
Hide file tree
Showing 5 changed files with 830 additions and 0 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ if(WIN32)
configure_file(cmake/portaudio.def.in "${CMAKE_CURRENT_BINARY_DIR}/portaudio.def" @ONLY)
target_sources(PortAudio PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/portaudio.def")
endif()
elseif(EMSCRIPTEN)
option(PA_USE_WEBAUDIO "Enable support for WebAudio" ON)

if(PA_USE_WEBAUDIO)
target_sources(PortAudio PRIVATE
src/hostapi/webaudio/pa_webaudio.c
)
target_compile_definitions(PortAudio PUBLIC PA_USE_WEBAUDIO=1)
set(PORTAUDIO_PUBLIC_HEADERS "${PORTAUDIO_PUBLIC_HEADERS}" include/pa_webaudio.h)
set(PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS} -DPA_USE_WEBAUDIO=1")
endif()
elseif(UNIX)
target_sources(PortAudio PRIVATE
src/os/unix/pa_unix_hostapis.c
Expand Down
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

0 comments on commit d3df80d

Please sign in to comment.