From a47fbff9d8f030d44b3db05b315b4cf0fb1b8c0c Mon Sep 17 00:00:00 2001 From: Dallas Strouse Date: Sat, 10 Jun 2023 14:26:48 -0500 Subject: [PATCH] Initial support for PipeWire Gets most of the work done for adding support for PipeWire. Still needs PipeWire itself to be implemented. Signed-off-by: Dallas Strouse --- .gitignore | 1 + audio/Makefile | 2 +- audio/audioP.h | 2 ++ audio/gen_audio.cc | 10 ++++++++++ audio/meson.build | 7 +++++++ audio/pipewire.cc | 38 +++++++++++++++++++++++++++++++++++++ config/config.in | 3 +++ config/modules/pipewire.mak | 12 ++++++++++++ configure | 17 +++++++++++++++-- configure.ac | 22 +++++++++++++++++++++ include/EST_audio.h | 1 + meson_options.txt | 1 + 12 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 audio/pipewire.cc create mode 100644 config/modules/pipewire.mak diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..53ec402 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.buildconfig diff --git a/audio/Makefile b/audio/Makefile index 477b14d..b9f9263 100644 --- a/audio/Makefile +++ b/audio/Makefile @@ -44,7 +44,7 @@ LOCAL_DEFAULT_LIBRARY = estbase H = audioP.h CPPSRCS = gen_audio.cc nas.cc esd.cc sun16audio.cc \ mplayer.cc win32audio.cc irixaudio.cc os2audio.cc \ - macosxaudio.cc pulseaudio.cc linux_sound.cc + macosxaudio.cc pulseaudio.cc pipewire.cc linux_sound.cc SRCS = $(CPPSRCS) OBJS = $(SRCS:.cc=.o) diff --git a/audio/audioP.h b/audio/audioP.h index 3e84864..2ca8d37 100644 --- a/audio/audioP.h +++ b/audio/audioP.h @@ -44,6 +44,7 @@ int play_pulse_wave(EST_Wave &inwave, EST_Option &al); int play_esd_wave(EST_Wave &inwave, EST_Option &al); int play_sun16_wave(EST_Wave &inwave, EST_Option &al); int play_linux_wave(EST_Wave &inwave, EST_Option &al); +int play_pipewire_wave(EST_Wave &inwave, EST_Option &al); int play_mplayer_wave(EST_Wave &inwave, EST_Option &al); int play_win32audio_wave(EST_Wave &inwave, EST_Option &al); int play_irix_wave(EST_Wave &inwave, EST_Option &al); @@ -54,5 +55,6 @@ int record_pulse_wave(EST_Wave &inwave, EST_Option &al); int record_esd_wave(EST_Wave &inwave, EST_Option &al); int record_sun16_wave(EST_Wave &inwave, EST_Option &al); int record_linux_wave(EST_Wave &inwave, EST_Option &al); +int record_pipewire_wave(EST_Wave &inwave, EST_Option &al); #endif /* __AUDIOP_H__ */ diff --git a/audio/gen_audio.cc b/audio/gen_audio.cc index e1f7b69..44265b9 100644 --- a/audio/gen_audio.cc +++ b/audio/gen_audio.cc @@ -83,6 +83,8 @@ int play_wave(EST_Wave &inwave, EST_Option &al) { if (nas_supported) protocol = "netaudio"; // the default protocol + else if (pipewire_supported) + protocol = "pipewire"; else if (pulse_supported) protocol = "pulseaudio"; else if (esd_supported) @@ -116,6 +118,8 @@ int play_wave(EST_Wave &inwave, EST_Option &al) if (upcase(protocol) == "NETAUDIO") return play_nas_wave(*toplay,al); + else if (upcase(protocol) == "PIPEWIRE") + return play_pipewire_wave(*toplay,al); else if (upcase(protocol) == "PULSEAUDIO") return play_pulse_wave(*toplay,al); else if (upcase(protocol) == "ESDAUDIO") @@ -255,6 +259,8 @@ EST_String options_supported_audio(void) audios += " audio_command"; if (nas_supported) audios += " netaudio"; + else if (pipewire_supported) + audios += " pipewire"; else if (pulse_supported) audios += " pulseaudio"; else if (esd_supported) @@ -299,6 +305,8 @@ int record_wave(EST_Wave &wave, EST_Option &al) { if (nas_supported) protocol = "netaudio"; // the default protocol + else if (pipewire_supported) + protocol = "pipewire"; else if (pulse_supported) protocol = "pulseaudio"; else if (esd_supported) @@ -321,6 +329,8 @@ int record_wave(EST_Wave &wave, EST_Option &al) if (upcase(protocol) == "NETAUDIO") return record_nas_wave(wave,al); + else if (upcase(protocol) == "PIPEWIRE") + return record_pipewire_wave(wave,al); else if (upcase(protocol) == "PULSEAUDIO") return record_pulse_wave(wave,al); else if (upcase(protocol) == "ESDAUDIO") diff --git a/audio/meson.build b/audio/meson.build index 3f65fec..a5dbce3 100644 --- a/audio/meson.build +++ b/audio/meson.build @@ -94,6 +94,13 @@ if audio_alsa_dep.found() audio_lib_deps += audio_alsa_dep endif +#pipewire +audio_pipewire_dep = dependency('libpipewire-0.3', version: '>= 0.3.52', required: get_option('audio_pipewire')) +if audio_pipewire_dep.found() + audio_lib_cpp_args += '-DSUPPORT_PIPEWIRE' + audio_lib_deps += audio_pipewire_dep +endif + ## voxware if host_machine.system() == 'freebsd' or host_machine.system() == 'netbsd' or host_machine.system() == 'openbsd' audio_lib_cpp_args += '-DSUPPORT_FREEBSD16' diff --git a/audio/pipewire.cc b/audio/pipewire.cc new file mode 100644 index 0000000..0fe2cf6 --- /dev/null +++ b/audio/pipewire.cc @@ -0,0 +1,38 @@ +/*************************************************************************/ +/* */ +/* Centre for Speech Technology Research */ +/* University of Edinburgh, UK */ +/* Copyright (c) 1997,1998 */ +/* Red Hat, Inc. */ +/* Copyright (c) 2008 */ +/* All Rights Reserved. */ +/* */ +/* Permission is hereby granted, free of charge, to use and distribute */ +/* this software and its documentation without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of this work, and to */ +/* permit persons to whom this work is furnished to do so, subject to */ +/* the following conditions: */ +/* 1. The code must retain the above copyright notice, this list of */ +/* conditions and the following disclaimer. */ +/* 2. Any modifications must be clearly marked as such. */ +/* 3. Original authors' names are not deleted. */ +/* 4. The authors' names are not used to endorse or promote products */ +/* derived from this software without specific prior written */ +/* permission. */ +/* */ +/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ +/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ +/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ +/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ +/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ +/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ +/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ +/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ +/* THIS SOFTWARE. */ +/* */ +/*************************************************************************/ +/* Support for PipeWire */ +/*=======================================================================*/ + +// TODO diff --git a/config/config.in b/config/config.in index c0433b1..7522901 100644 --- a/config/config.in +++ b/config/config.in @@ -86,6 +86,9 @@ INCLUDE_MODULES += @NAS_AUDIO@ ## Elightenment Sound Demon, for KDE etc. # INCLUDE_MODULES += ESD_AUDIO +## PipeWire sound server. Write PIPEWIRE to include it. +INCLUDE_MODULES += @PIPEWIRE@ + ## PulseAudio sound server. Write PULSE_AUDIO to include it. INCLUDE_MODULES += @PULSE_AUDIO@ diff --git a/config/modules/pipewire.mak b/config/modules/pipewire.mak new file mode 100644 index 0000000..07ce4e7 --- /dev/null +++ b/config/modules/pipewire.mak @@ -0,0 +1,12 @@ +## Definitions for PipeWire + +INCLUDE_PipeWire=1 + +MOD_DESC_PIPEWIRE=PipeWire support + +AUDIO_DEFINES += -DSUPPORT_PIPEWIRE +AUDIO_INCLUDES += -I$(PIPEWIRE_INCLUDE) +MODULE_LIBS += -lpipewire-0.3 -lpipewire +PROJECT_LIBRARY_SYSLIBS_estbase += -lpipewire-0.3 -lpipewire + + diff --git a/configure b/configure index 20833b5..c8e34e4 100755 --- a/configure +++ b/configure @@ -623,6 +623,7 @@ ac_subst_vars='LTLIBOBJS LIBOBJS OMP_DEFS OMP_OPTS +PIPEWIRE PULSE_AUDIO NAS_AUDIO LINUXAUDIO @@ -703,6 +704,7 @@ ac_subst_files='' ac_user_opts=' enable_option_checking with_nas_audio +with_pipewire with_pulseaudio ' ac_precious_vars='build_alias @@ -1346,6 +1348,7 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-nas_audio enable NCD's network audio system + --with-pipewire Compile PipeWire audio module [default=no] --with-pulseaudio Compile PulseAudio audio module [default=no] Some influential environment variables: @@ -4342,6 +4345,18 @@ fi +# Check whether --with-pipewire was given. +if test "${with_pipewire+set}" = set; then : + withval=$with_pipewire; +else + with_pipewire=no +fi + +PIPEWIRE= +if test "x$with_pipewire" != xno; then : + PIPEWIRE="PIPEwIRE" +fi + # Check whether --with-pulseaudio was given. if test "${with_pulseaudio+set}" = set; then : @@ -4350,8 +4365,6 @@ else with_pulseaudio=no fi - - PULSE_AUDIO= if test "x$with_pulseaudio" != xno; then : PULSE_AUDIO="PULSE_AUDIO" diff --git a/configure.ac b/configure.ac index f67749a..494f982 100644 --- a/configure.ac +++ b/configure.ac @@ -131,6 +131,28 @@ AC_ARG_WITH([nas_audio], [NAS_AUDIO=]) AC_SUBST(NAS_AUDIO) + +PIPEWIRE= +AS_IF([test "x$with_pipewire" != xno], + [PIPEWIRE="PIPEWIRE"], + [] +) + +AC_ARG_WITH([pipewire], + [AS_HELP_STRING([--with-pipewire], + [Compile PipeWire audio module @<:@default=no@:>@])], + [], + [with_pipewire=no]) + + +PIPEWIRE= +AS_IF([test "x$with_pipewire" != xno], + [PIPEWIRE="PIPEWIRE"], + [] +) + +AC_SUBST(PIPEWIRE) + AC_ARG_WITH([pulseaudio], [AS_HELP_STRING([--with-pulseaudio], [Compile PulseAudio audio module @<:@default=no@:>@])], diff --git a/include/EST_audio.h b/include/EST_audio.h index fe59645..6701966 100644 --- a/include/EST_audio.h +++ b/include/EST_audio.h @@ -43,6 +43,7 @@ #include "EST_Option.h" extern int nas_supported; +extern int pipewire_supported; extern int pulse_supported; extern int esd_supported; extern int sun16_supported; diff --git a/meson_options.txt b/meson_options.txt index 18fbf08..fca9e1f 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -8,6 +8,7 @@ option('audio_os2', type: 'feature', value: 'disabled') # not implemented in mes option('audio_osx', type: 'feature', value: 'auto') option('audio_pulseaudio', type: 'feature', value: 'disabled') option('audio_alsa', type: 'feature', value: 'auto') +option('audio_pipewire', type: 'feature', value: 'disabled') option('editline', type: 'feature', value: 'auto') option('siod_python', type: 'feature', value: 'auto')