Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 43eef97

Browse files
authored
Merge pull request #90 from Cuda-Chen/detect-sound-mux
Add sound multiplexer auto-detection when building
2 parents 83d31fb + 85afd27 commit 43eef97

File tree

3 files changed

+50
-11
lines changed

3 files changed

+50
-11
lines changed

‎.github/workflows/main.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ jobs:
88
strategy:
99
matrix:
1010
dependency:
11-
- libpulse-dev
1211
- none
12+
- libpulse-dev
13+
- libjack-jackd2-dev
1314
steps:
1415
- name: checkout code
1516
uses: actions/checkout@v4
@@ -19,7 +20,9 @@ jobs:
1920
sudo apt-get install libasound2-dev libudev-dev
2021
- name: install sound multiplexer ${{ matrix.dependency }}
2122
if: matrix.dependency != 'none'
22-
run: sudo apt-get install ${{ matrix.dependency }}
23+
run: |
24+
sudo apt-get update
25+
sudo apt-get install ${{ matrix.dependency }}
2326
- name: default build
2427
run: make
2528
shell: bash

‎Makefile

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,33 +77,50 @@ $(call set-feature, VIRTIOSND)
7777
ifeq ($(call has, VIRTIOSND), 1)
7878
OBJS_EXTRA += virtio-snd.o
7979

80-
PORTAUDIOLIB := portaudio/lib/.libs/libportaudio.a
81-
LDFLAGS += $(PORTAUDIOLIB)
80+
PA_LIB := portaudio/lib/.libs/libportaudio.a
81+
PA_CFLAGS := -Iportaudio/include
82+
PA_CONFIG_PARAMS :=
83+
LDFLAGS += $(PA_LIB)
84+
CFLAGS += $(PA_CFLAGS)
8285

8386
ifeq ($(UNAME_S),Linux)
8487
LDFLAGS += -lasound -lrt
88+
PA_CONFIG_PARAMS += --with-alsa
8589
# Check PulseAudio installation
8690
ifeq (0, $(call check-pa))
8791
LDFLAGS += -lpulse
92+
PA_CONFIG_PARAMS += --with-pulseaudio
93+
endif
94+
ifeq (0, $(call check-jack2))
95+
LDFLAGS += -ljack
96+
PA_CONFIG_PARAMS += --with-jack
8897
endif
8998
endif
9099
ifeq ($(UNAME_S),Darwin)
91100
LDFLAGS += -framework CoreServices -framework CoreFoundation -framework AudioUnit -framework AudioToolbox -framework CoreAudio
92101
endif
93102

94-
CFLAGS += -Iportaudio/include
95103
# PortAudio requires libm, yet we set -lm in the end of LDFLAGS
96104
# so that the other libraries will be benefited for no need to set
97105
# -lm separately.
98106
LDFLAGS += -lpthread
99107

100108
portaudio/Makefile:
101109
git submodule update --init portaudio
102-
$(PORTAUDIOLIB): portaudio/Makefile
103-
cd $(dir $<) && LDFLAGS="" ./configure --without-sndio
110+
$(PA_LIB): portaudio/Makefile
111+
cd $(dir $<) && git clean -fdx && git reset --hard HEAD
112+
cd $(dir $<) && ./configure \
113+
--enable-static \
114+
--disable-shared \
115+
--without-samples \
116+
--without-tests \
117+
--without-oss \
118+
--without-sndio \
119+
--disable-dependency-tracking \
120+
$(PA_CONFIG_PARAMS)
104121
$(MAKE) -C $(dir $<)
105-
main.o: $(PORTAUDIOLIB)
106-
122+
main.o: $(PA_LIB)
123+
virtio-snd.o: $(PA_LIB)
107124
# suppress warning when compiling PortAudio
108125
virtio-snd.o: CFLAGS += -Wno-unused-parameter
109126
endif

‎mk/check-libs.mk

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,27 @@ endef
2424
define create-ca-prog
2525
echo '\
2626
#include <CoreAudio/CoreAudio.h>\n\
27-
#include <AudioToolbox/AudioQueue.h>
27+
#include <AudioToolbox/AudioQueue.h>\n\
2828
int main(){\n\
2929
AudioQueueRef queue;\n\
3030
AudioQueueDispose(queue, TRUE);\n\
3131
return 0;\n\
3232
}\n'
3333
endef
3434

35+
# Create a mininal jack2 program
36+
define create-jack2-prog
37+
echo '\
38+
#include <stdlib.h>\n\
39+
#include <jack/jack.h>\n\
40+
int main(){\n\
41+
jack_default_audio_sample_t *signal;\n\
42+
signal = (jack_default_audio_sample_t *)malloc(1024 * sizeof(jack_default_audio_sample_t));\n\
43+
free(signal);\n\
44+
return 0;\n\
45+
}\n'
46+
endef
47+
3548
# Check ALSA installation
3649
define check-alsa
3750
$(shell $(call create-alsa-prog) | $(CC) -x c - -lasound -o /dev/null > /dev/null 2> /dev/null
@@ -40,11 +53,17 @@ endef
4053

4154
# Check PulseAudio installation
4255
define check-pa
43-
$(shell $(call create-pa-prog) | $(CC) -x c - -lpulse -o /dev/null && echo 0 || echo 1)
56+
$(shell $(call create-pa-prog) | $(CC) -x c - -lpulse -o /dev/null > /dev/null 2> /dev/null && echo 0 || echo 1)
4457
endef
4558

4659
# Check CoreAudio installation
4760
define check-coreaudio
4861
$(shell $(call create-ca-prog) | $(CC) -x c - -framework AudioToolbox -o /dev/null > /dev/null 2> /dev/null
4962
&& echo 0 || echo 1)
5063
endef
64+
65+
# Check JACK (formally jack2) installation
66+
define check-jack2
67+
$(shell $(call create-jack2-prog) | $(CC) -x c - -ljack -o /dev/null > /dev/null 2> /dev/null
68+
&& echo 0 || echo 1)
69+
endef

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /