Skip to content

Commit fd58de0

Browse files
committed
[WIP] Switch to PortAudio
Switch to PortAudio for cross-platform and cross backend compatibility. There are two limitations: 1. The last period of sound is lost. 2. You cannot play sound twice or the device will crash thus whole system crashes.
1 parent b42df15 commit fd58de0

File tree

5 files changed

+202
-170
lines changed

5 files changed

+202
-170
lines changed

.gitmodules

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
[submodule "cnfa"]
2-
path = cnfa
3-
url = https://github.com/cntools/cnfa
4-
shallow = true
51
[submodule "mini-gdbstub"]
62
path = mini-gdbstub
73
url = https://github.com/RinHizakura/mini-gdbstub
84
shallow = true
5+
[submodule "portaudio"]
6+
path = portaudio
7+
url = https://github.com/PortAudio/portaudio
8+
shallow = true

Makefile

+20-15
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ OBJS_EXTRA :=
1414
# command line option
1515
OPTS :=
1616

17-
LDFLAGS := -lm
17+
LDFLAGS :=
1818

1919
# virtio-blk
2020
ENABLE_VIRTIOBLK ?= 1
@@ -70,22 +70,27 @@ $(call set-feature, VIRTIOSND)
7070
ifeq ($(call has, VIRTIOSND), 1)
7171
OBJS_EXTRA += virtio-snd.o
7272

73-
LDFLAGS += -lasound -lpthread
74-
CFLAGS += -Icnfa
75-
76-
cnfa/Makefile:
77-
git submodule update --init cnfa
78-
cnfa/os_generic: cnfa/Makefile
79-
$(MAKE) -C $(dir $<) os_generic.h
80-
CNFA_LIB := cnfa/CNFA_sf.h
81-
$(CNFA_LIB): cnfa/Makefile cnfa/os_generic
82-
$(MAKE) -C $(dir $<) CNFA_sf.h
83-
main.o: $(CNFA_LIB)
84-
85-
# suppress warning when compiling CNFA
86-
virtio-snd.o: CFLAGS += -Wno-unused-parameter -Wno-sign-compare
73+
PORTAUDIOLIB := portaudio/lib/.libs/libportaudio.a
74+
# PortAudio requires libm, yet we set -lm in the end of LDFLAGS
75+
# so that the other libraries will be benefited for no need to set
76+
# -lm separately.
77+
LDFLAGS += $(PORTAUDIOLIB) -lasound -lpthread -lrt -lpulse
78+
CFLAGS += -Iportaudio/include
79+
80+
portaudio/Makefile:
81+
git submodule update --init portaudio
82+
$(PORTAUDIOLIB): portaudio/Makefile
83+
@cd $(dir $<) && ./configure
84+
@cd $(dir $<) && $(MAKE)
85+
main.o: $(PORTAUDIOLIB)
86+
87+
# suppress warning when compiling PortAudio
88+
virtio-snd.o: CFLAGS += -Wno-unused-parameter
8789
endif
8890

91+
# Set libm as the last dependency so that no need to set -lm seperately.
92+
LDFLAGS += -lm
93+
8994
# .DEFAULT_GOAL should be set to all since the very first target is not all
9095
# after git submodule.
9196
.DEFAULT_GOAL := all

cnfa

-1
This file was deleted.

portaudio

Submodule portaudio added at e97effb

0 commit comments

Comments
 (0)