Skip to content

Commit

Permalink
Merge pull request #111 from mmitch/pipewire
Browse files Browse the repository at this point in the history
add PipeWire audio plugout
  • Loading branch information
ranma authored Feb 3, 2024
2 parents e59ba36 + 4c1212a commit 249f263
Show file tree
Hide file tree
Showing 13 changed files with 315 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libasound2-dev libpulse-dev libaudio-dev libxcb1-dev libxcb-icccm4-dev libcairo2-dev libsdl2-dev
sudo apt-get install libasound2-dev libpulse-dev libaudio-dev libxcb1-dev libxcb-icccm4-dev libcairo2-dev libsdl2-dev libpipewire-0.3-dev
- name: Install valgrind
if: ${{ matrix.flags == '' }}
run: |
Expand All @@ -39,7 +39,7 @@ jobs:
make
- name: Check activated plugouts
run: |
./check_plugouts.sh alsa pulse devdsp nas sdl
./check_plugouts.sh alsa pulse devdsp nas sdl pipewire
- name: Check WAV plugout
run: |
./check_plugout_wav.sh
Expand Down
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

gbsplay - A Gameboy sound player

(C) 2003-2022 by Tobias Diedrich <ranma+gbsplay@tdiedrich.de>
(C) 2003-2024 by Tobias Diedrich <ranma+gbsplay@tdiedrich.de>
Christian Garbs <mitch@cgarbs.de>
Maximilian Rehkopf <otakon@gmx.net>
Vegard Nossum <vegardno@ifi.uio.no>
Expand Down
3 changes: 3 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Bugfixes:

Enhancements:

- gbsplay:
- add PipeWire plugout

- build process:
- add automated build pipeline for FreeBSD (x86-64 and arm64)

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ endif
ifeq ($(plugout_altmidi),yes)
plugout_objs += plugout_altmidi.o midifile.o filewriter.o
endif
ifeq ($(plugout_pipewire),yes)
plugout_objs += plugout_pipewire.o
plugout_ldflags += $(libpipewire_0_3_flags)
endif
ifeq ($(plugout_pulse),yes)
plugout_objs += plugout_pulse.o
plugout_ldflags += -lpulse-simple -lpulse
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ the following parts:
## License

```
(C) 2003-2022 by Tobias Diedrich <ranma+gbsplay@tdiedrich.de>
(C) 2003-2024 by Tobias Diedrich <ranma+gbsplay@tdiedrich.de>
Christian Garbs <mitch@cgarbs.de>
Maximilian Rehkopf <otakon@gmx.net>
Vegard Nossum <vegardno@ifi.uio.no>
Expand Down
69 changes: 67 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# generate config.mk for gbsplay Makefile
#
# 2003-2022 (C) by Christian Garbs <mitch@cgarbs.de>
# 2003-2024 (C) by Christian Garbs <mitch@cgarbs.de>
# Tobias Diedrich <ranma+gbsplay@tdiedrich.de>
#
# Licensed under GNU GPL v1 or, at your option, any later version.
Expand Down Expand Up @@ -186,14 +186,17 @@ check_libs()
local INFILE="$TEMPDIR/cl.c"
local OUTFILE="$TEMPDIR/cl"
local checklib="$1"
local libname="$(echo "$checklib" | sed -e 's@[/\.-]@_@g')"
local libname="$(echo "$checklib" | sed -e 's@[/\.-]@_@g' -e 's/ //g')"
local extralibs="${checklib} ${2-}"
local extralibdirs="${3-}"
local name="${4-}"
local extraflags="${5-}"
local msg="${6-$checklib}"
local cflags="$CFLAGS $LDFLAGS"

# don't let -pedantic mess with our checks
cflags="$(sed -E 's/-pedantic ?//g'<<<"$cflags")"

eval "lib${libname}_flags="

cat > "$INFILE"
Expand Down Expand Up @@ -221,6 +224,7 @@ check_libs()
done

if [ "$minerrs" -ne 0 ]; then
echo "...but it still won't compile cleanly"
# log the default result to config.err
(
echo "minerrs: $minerrs > 0"
Expand Down Expand Up @@ -542,6 +546,7 @@ Output Plugins:
--disable-midi omit MIDI file writer plugin
--disable-altmidi omit alternative MIDI file writer plugin
--disable-nas omit NAS sound output plugin
--disable-pipewire omit PipeWire sound output plugin
--disable-pulse omit PulseAudio sound output plugin
--disable-sdl omit SDL sound output plugin
--disable-stdout omit stdout file writer plugin
Expand All @@ -565,6 +570,7 @@ OPTS="${OPTS} use_iodumper"
OPTS="${OPTS} use_midi"
OPTS="${OPTS} use_altmidi"
OPTS="${OPTS} use_nas"
OPTS="${OPTS} use_pipewire"
OPTS="${OPTS} use_pulse"
OPTS="${OPTS} use_sdl"
OPTS="${OPTS} use_sharedlibgbs"
Expand Down Expand Up @@ -698,6 +704,7 @@ if [ "$windows_build" = yes ]; then
# don't look for audio libs that are unavailable on Windows
setdefault use_alsa no
setdefault use_nas no
setdefault use_pipewire no
setdefault use_pulse no
if cc_check "" "" "" <<EOF; then
int main(int argc, char **argv)
Expand Down Expand Up @@ -840,6 +847,61 @@ EOF
recheck_use dsound
fi

if [ "$use_pipewire" != no ]; then
remember_use pipewire

pipewire_version='libpipewire-0.3'
if command -v pkg-config >/dev/null && pkg-config ${pipewire_version}; then
pipewire_have_pkg_config=yes
else
pipewire_have_pkg_config=no
fi

if [ "$pipewire_have_pkg_config" = yes ]; then
pipewire_include_flags="$(pkg-config --cflags-only-I ${pipewire_version})"
pipewire_cflags="$(pkg-config --cflags-only-other ${pipewire_version})"
else
pipewire_include_flags='-I/usr/include/pipewire-0.3 -I/usr/include/spa-0.2'
pipewire_cflags=''
fi
pipewire_include_path="$(sed -e 's/^-I//' -e 's/ -I/ /g' <<<"${pipewire_include_flags}")"

check_include spa/support/plugin.h "$pipewire_include_path"
if [ "$have_spa_support_plugin_h" = yes ]; then
append_nodupe CFLAGS "-I${include_spa_support_plugin_h_path}"
check_include pipewire/pipewire.h "$pipewire_include_path"
if [ "$have_pipewire_pipewire_h" = yes ]; then
append_nodupe CFLAGS "-I${include_pipewire_pipewire_h_path} ${pipewire_cflags}"

if [ "$pipewire_have_pkg_config" = yes ]; then
pipewire_ldpath_flags="$(pkg-config --libs-only-L ${pipewire_version})"
pipewire_libname_flags="$(pkg-config --libs-only-l ${pipewire_version})"
pipewire_ldflags="$(pkg-config --libs-only-other ${pipewire_version})"
else
pipewire_ldpath_flags=''
pipewire_libname_flags='-lpipewire-0.3'
pipewire_ldflags=''
fi
pipewire_ldpath="$(sed -e 's/^-L//' -e 's/ -L/ /g' <<<"${pipewire_ldpath_flags}")"
pipewire_libname="${pipewire_libname_flags#*-l}"

check_libs "${pipewire_libname}" "" "${pipewire_ldpath}" "" "${pipewire_ldflags}" <<EOF
#include <pipewire/pipewire.h>
int main(int argc, char **argv) {
pw_init(0, NULL);
pw_deinit();
return 0;
}
EOF
if [ "$?" -eq 0 ]; then
use_pipewire=yes
fi
fi
fi

recheck_use pipewire
fi

if [ "$use_pulse" != no ]; then
remember_use pulse
check_include pulse/simple.h
Expand Down Expand Up @@ -1230,6 +1292,7 @@ use_verbosebuild
windows_build
windows_libprefix
libaudio_flags
libpipewire_0_3_flags
libSDL2_flags
__EOF__
echo plugout_alsa := $use_alsa
Expand All @@ -1239,6 +1302,7 @@ __EOF__
echo plugout_midi := $use_midi
echo plugout_altmidi := $use_altmidi
echo plugout_nas := $use_nas
echo plugout_pipewire := $use_pipewire
echo plugout_pulse := $use_pulse
echo plugout_sdl := $use_sdl
echo plugout_stdout := $use_stdout
Expand All @@ -1260,6 +1324,7 @@ __EOF__
plugout_x MIDI
plugout_x ALTMIDI
plugout_x NAS
plugout_x PIPEWIRE
plugout_x PULSE
plugout_x STDOUT
plugout_x SDL
Expand Down
5 changes: 4 additions & 1 deletion man/gbsplay.in.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" This manpage 2003-2022 (C) by Christian Garbs <mitch@cgarbs.de>
.\" This manpage 2003-2024 (C) by Christian Garbs <mitch@cgarbs.de>
.\" Licensed under GNU GPL v1 or, at your option, any later version.
.TH "GBSPLAY" "1" "%%%VERSION%%%" "Tobias Diedrich" "Gameboy sound player"
.SH "NAME"
Expand Down Expand Up @@ -254,6 +254,9 @@ using tricks and hacks will not be converted properly.
.B nas
Use the NAS sound driver for sound output to a Network Audio Server.
.TP
.B pipewire
Use the PipeWire sound driver for sound output.
.TP
.B pulse
Use the Pulseaudio sound driver for sound output.
.TP
Expand Down
5 changes: 4 additions & 1 deletion man/xgbsplay.in.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" This manpage 2003-2022 (C) by Christian Garbs <mitch@cgarbs.de>
.\" This manpage 2003-2024 (C) by Christian Garbs <mitch@cgarbs.de>
.\" Licensed under GNU GPL v1 or, at your option, any later version.
.TH "GBSPLAY" "1" "%%%VERSION%%%" "Tobias Diedrich" "Gameboy sound player"
.SH "NAME"
Expand Down Expand Up @@ -174,6 +174,9 @@ using tricks and hacks will not be converted properly.
.B nas
Use the NAS sound driver for sound output to a Network Audio Server.
.TP
.B pipewire
Use the PipeWire sound driver for sound output.
.TP
.B pulse
Use the Pulseaudio sound driver for sound output.
.TP
Expand Down
6 changes: 6 additions & 0 deletions plugout.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ extern const struct output_plugin plugout_altmidi;
#ifdef PLUGOUT_NAS
extern const struct output_plugin plugout_nas;
#endif
#ifdef PLUGOUT_PIPEWIRE
extern const struct output_plugin plugout_pipewire;
#endif
#ifdef PLUGOUT_PULSE
extern const struct output_plugin plugout_pulse;
#endif
Expand Down Expand Up @@ -70,6 +73,9 @@ static output_plugin_const_t plugouts[] = {
#ifdef PLUGOUT_STDOUT
&plugout_stdout,
#endif
#ifdef PLUGOUT_PIPEWIRE
&plugout_pipewire,
#endif
#ifdef PLUGOUT_NAS
&plugout_nas,
#endif
Expand Down
2 changes: 2 additions & 0 deletions plugout.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#if PLUGOUT_DSOUND == 1
# define PLUGOUT_DEFAULT "dsound"
#elif PLUGOUT_PIPEWIRE == 1
# define PLUGOUT_DEFAULT "pipewire"
#elif PLUGOUT_PULSE == 1
# define PLUGOUT_DEFAULT "pulse"
#elif PLUGOUT_ALSA == 1
Expand Down
Loading

0 comments on commit 249f263

Please sign in to comment.