Skip to content

Commit e01f69d

Browse files
authored
chore: updates build to allow portaudio to be dynamically linked (#877)
1 parent deb98ff commit e01f69d

7 files changed

Lines changed: 57 additions & 21 deletions

File tree

pkg/portaudio/portaudio.go

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
1-
// Package portaudio provides Go bindings for PortAudio, compiled from vendored source.
1+
// Package portaudio provides Go bindings for PortAudio.
2+
//
3+
// By default the C sources are compiled directly from the vendored pa_src
4+
// submodule (see portaudio_vendored*.go). Build with -tags portaudio_system to
5+
// link against a system libportaudio via pkg-config instead (portaudio_system.go);
6+
// the Homebrew formula uses this so it depends on the brew `portaudio` formula
7+
// rather than the vendored copy. The Go API below is identical either way.
28
package portaudio
39

410
/*
5-
#cgo CFLAGS: -I${SRCDIR}/pa_src/include -I${SRCDIR}/pa_src/src/common -DPA_LITTLE_ENDIAN -Wno-unused-parameter -Wno-deprecated-declarations
6-
7-
#if !__has_include("pa_src/include/portaudio.h")
8-
#error "PortAudio submodule not found. Run: git submodule update --init --recursive"
9-
#else
10-
11-
#include "pa_src/src/common/pa_allocation.c"
12-
#include "pa_src/src/common/pa_converters.c"
13-
#include "pa_src/src/common/pa_cpuload.c"
14-
#include "pa_src/src/common/pa_debugprint.c"
15-
#include "pa_src/src/common/pa_dither.c"
16-
#include "pa_src/src/common/pa_front.c"
17-
#include "pa_src/src/common/pa_process.c"
18-
#include "pa_src/src/common/pa_ringbuffer.c"
19-
#include "pa_src/src/common/pa_stream.c"
20-
#include "pa_src/src/common/pa_trace.c"
21-
22-
#include "portaudio.h"
23-
#endif
11+
#include <portaudio.h>
2412
*/
2513
import "C"
2614

pkg/portaudio/portaudio_darwin.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !portaudio_system
2+
13
package portaudio
24

35
/*

pkg/portaudio/portaudio_linux.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !portaudio_system
2+
13
package portaudio
24

35
/*

pkg/portaudio/portaudio_system.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//go:build portaudio_system
2+
3+
package portaudio
4+
5+
// Link against a system libportaudio (e.g. Homebrew's `portaudio`) instead of
6+
// compiling the vendored sources. Selected with -tags portaudio_system. The
7+
// system library already bundles its host-API backends, so no per-OS backend
8+
// link flags are needed here. pkg-config supplies the include and link flags.
9+
10+
/*
11+
#cgo pkg-config: portaudio-2.0
12+
*/
13+
import "C"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//go:build !portaudio_system
2+
3+
package portaudio
4+
5+
// Vendored PortAudio: the cross-platform core sources are compiled directly into
6+
// this package (a cgo unity build). The per-OS host APIs and their backend link
7+
// flags live in portaudio_<os>.go. Build with -tags portaudio_system to link a
8+
// system libportaudio instead, in which case none of these sources compile.
9+
10+
/*
11+
#cgo CFLAGS: -I${SRCDIR}/pa_src/include -I${SRCDIR}/pa_src/src/common -DPA_LITTLE_ENDIAN -Wno-unused-parameter -Wno-deprecated-declarations
12+
13+
#if !__has_include("pa_src/include/portaudio.h")
14+
#error "PortAudio submodule not found. Run: git submodule update --init --recursive (or build with -tags portaudio_system to use a system libportaudio)"
15+
#else
16+
17+
#include "pa_src/src/common/pa_allocation.c"
18+
#include "pa_src/src/common/pa_converters.c"
19+
#include "pa_src/src/common/pa_cpuload.c"
20+
#include "pa_src/src/common/pa_debugprint.c"
21+
#include "pa_src/src/common/pa_dither.c"
22+
#include "pa_src/src/common/pa_front.c"
23+
#include "pa_src/src/common/pa_process.c"
24+
#include "pa_src/src/common/pa_ringbuffer.c"
25+
#include "pa_src/src/common/pa_stream.c"
26+
#include "pa_src/src/common/pa_trace.c"
27+
#endif
28+
*/
29+
import "C"

pkg/portaudio/portaudio_windows.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !portaudio_system
2+
13
package portaudio
24

35
/*

version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
package livekitcli
1616

1717
const (
18-
Version = "2.16.5"
18+
Version = "2.16.6"
1919
)

0 commit comments

Comments
 (0)