Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PulseAudio Portaudio HostAPI #336

Merged
merged 122 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
c96df06
PulseAudio: Add Skeleton HostAPI Pulseaudio-driver to Portaudio.
illuusio Nov 17, 2015
8371055
PulseAudio: Fix crash during PaPulseAudio_Initialize
sqweek Dec 29, 2015
c99c40c
PulseAudio: Make Portaudio Terminate-callback work as it should.
illuusio Jan 15, 2016
7cee797
PulseAudio: Fix Portaudio block playing API.
sqweek Jan 12, 2016
55418fa
PulseAudio: MONO stream is converted to STEREO
illuusio Aug 21, 2016
471031e
PulseAudio: Add 'src/hostapi/pulseaudio' to README.md
illuusio Oct 1, 2020
f865303
PulseAudio: Fix printf-formating building warnings
illuusio Oct 19, 2020
bd17afc
PulseAudio: Renamed FindPULSEAUDIO.cmake to FindPulseAudio.cmake
illuusio Oct 19, 2020
ab76ef1
PulseAudio: Fix strncpy logic
illuusio Oct 19, 2020
1dd1465
PulseAudio: Remove unused variable 'proc' in 'PaPulseAudio_New'-funct…
illuusio Oct 19, 2020
9368f0f
PulseAudio: Rework pulseaudioDefaultSource and pulseaudioDefaultSink
illuusio Oct 19, 2020
94b18b2
PulseAudio: Rework _PaPulseAudio_AddAudioDevice's Device name and Rea…
illuusio Oct 19, 2020
8118be4
PulseAudio: Update copyright year 2016 to 2020
illuusio Oct 19, 2020
a33b944
PulseAudio: Remove unneeded '\0'-char adding
illuusio Oct 20, 2020
ef4b99c
PulseAudio: Check that PAPULSEAUDIO_MAX_DEVICECOUNT (1024) is not exc…
illuusio Oct 20, 2020
e4d2728
PulseAudio: Fix test building in CMake system
illuusio Oct 20, 2020
1ea9991
PulseAudio: Remove PulseAudio simple interface as it's not used anymore
illuusio Oct 20, 2020
7e27996
PulseAudio: Re-style functions within code and headers to fit Portaud…
illuusio Nov 19, 2020
577a56d
PulseAudio: Re-style functions inside code
illuusio Nov 19, 2020
9f2a6b7
PulseAudio: Re-style if/while/switch and comments within them
illuusio Nov 19, 2020
8f98cdd
PulseAudio: Fix regression in name copying code which prevented playi…
illuusio Nov 23, 2020
0a4690b
PulseAudio: More precise full memory message
illuusio Nov 24, 2020
81dec9f
PulseAudio: More precise message for Invalid context
illuusio Nov 24, 2020
9fceb73
PulseAudio: Update debug message from general 'Out of memory' to vali…
illuusio Nov 25, 2020
fb931b2
PulseAudio: Make sure copying Sink name does not overflow in any circ…
illuusio Nov 24, 2020
b91a92c
PulseAudio: Add type-cast for PaPulseAudio_HostApiRepresentation to a…
illuusio Nov 24, 2020
c29c70d
PulseAudio: Check if context or info are NULL which means we are out …
illuusio Nov 24, 2020
ecabd50
PulseAudio: Remove unneeded state from struct
illuusio Nov 25, 2020
4f488b8
PulseAudio: Remove untested and not very sofisticated underrun code. …
illuusio Nov 25, 2020
e129062
PulseAudio: Not having PulseAudio server or one can't connect to is s…
illuusio Nov 25, 2020
b823cb2
PulseAudio: Update error message when cannot allocate mainloop
illuusio Nov 25, 2020
feed80a
PulseAudio: Make sure that PA_PULSEAUDIO_SET_LAST_HOST_ERROR has func…
illuusio Nov 25, 2020
dcd47e2
PulseAudio: Add switch to make precises error message
illuusio Nov 25, 2020
c57eff8
PulseAudio: Change buf variable name to something more prensentative
illuusio Nov 25, 2020
9d9b732
PulseAudio: Rename internal headers to have '_internal.h' file-ending…
illuusio Nov 26, 2020
b4e290e
PulseAudio: Update copyright years, remove emails from headers and ad…
illuusio Nov 26, 2020
20c9604
PulseAudio: Update debug print for underflows
illuusio Jan 15, 2021
5233622
PulseAudio: Change general underflows to more precises outputUnderflows
illuusio Jan 15, 2021
e0d712d
PulseAudio: Remove implemented TO-DO item
illuusio Jan 15, 2021
5224636
PulseAudio: Fix floats to PaTime (which is double) in PulseAudio Call…
illuusio Jan 15, 2021
6690a9b
PulseAudio: Remove old debug fprintf
illuusio Jan 15, 2021
02d6885
PulseAudio: Add PA_STREAM_DONT_MOVE to playback and record for not al…
illuusio Mar 7, 2021
5db214a
PulseAudio: Adjust stream latency as suggested in suggestedLatency
illuusio Apr 11, 2021
2b51c75
PulseAudio: fix scaling of latency values using PA_USEC_PER_SEC
daschuer Apr 14, 2021
0e7ca8e
PulseAudio: Avoid using uninitialized memory
daschuer Apr 14, 2021
e142ca4
PulseAudio: Make small changes to latency handling code
illuusio Apr 16, 2021
9e7b5d8
PulseAudio: Add basic stream end handling to escape inifite loops
illuusio Apr 21, 2021
a16c38d
PulseAudio: Use correct Ringbuffer function in PaUtil_GetRingBufferWr…
illuusio Apr 21, 2021
595c7f3
PulseAudio: Check that returned operation is not NULL
illuusio Apr 21, 2021
f8fedd2
PulseAudio: Initial implementation of stream renaming.
tmiw Apr 12, 2021
0d71183
PulseAudio: Forgot to add new include file.
tmiw Apr 12, 2021
c5ff701
PulseAudio: Add const qualifier to stream name.
tmiw Apr 14, 2021
480fd90
PulseAudio: Split stream renaming into source and sink specific funct…
tmiw Apr 15, 2021
03d1075
PulseAudio: Fix whitespace + return failure instead of assert.
tmiw Apr 15, 2021
91d2981
PulseAudio: enable stream renaming prior to start.
tmiw Apr 15, 2021
ec0c2df
PulseAudio: fix compile errors from previous commit.
tmiw Apr 15, 2021
092bee5
PulseAudio: add public API for new functions.
tmiw Apr 15, 2021
37bd590
PulseAudio: move public API documentation to header file.
tmiw Apr 15, 2021
e15197a
PulseAudio: remove unnecessary null checks before freeing memory used…
tmiw Apr 16, 2021
2e47294
PulseAudio: consolidate duplicate constant strings.
tmiw Apr 16, 2021
1720b9c
PulseAudio: cap stream names at PAPULSEAUDIO_MAX_DEVICENAME length.
tmiw Apr 16, 2021
f04fbad
PulseAudio: fail rename if the associated source/sink doesn't exist.
tmiw Apr 16, 2021
7874057
PulseAudio: fix ALSA typo in include file.
tmiw Apr 15, 2021
ee0dd99
PulseAudio: forgot to set op variable.
tmiw Apr 16, 2021
758a081
PulseAudio: wait for completion at least once even if op is NULL.
tmiw Apr 16, 2021
88eb1ff
PulseAudio: copy only the minimum number of characters needed.
tmiw Apr 16, 2021
eb6b4e9
PulseAudio: ensure terminating null for default stream names.
tmiw Apr 16, 2021
d1b4a8e
PulseAudio: lock main loop at beginning of rename process to avoid th…
tmiw Apr 16, 2021
6dcc74e
PulseAudio: undo previous change to main loop wait logic.
tmiw Apr 16, 2021
b02288c
PulseAudio: add const to string constants.
tmiw Apr 21, 2021
01a842d
PulseAudio: streamline string copying using snprintf().
tmiw Apr 24, 2021
cb2b5dd
PulseAudio: Move FindPulseAudio.cmake CMake helper to correct place
illuusio Aug 20, 2021
591cf43
PulseAudio: Move FindPulseAudio.cmake CMake helper to correct place
illuusio Aug 20, 2021
4d452f4
PulseAudio: Fix most of the cmakelint warnings
illuusio Aug 20, 2021
819cfd0
PulseAudio: Use PULSEAUDIO not PulseAudio in CMake-script
illuusio Aug 20, 2021
89836c4
PulseAudio: Split rows under under 80 bytes in PULSEAUDIO CMake-helpe…
illuusio Aug 20, 2021
a88cc9c
PulseAudio: Update CmakeLists.txt to contain PulseAudio compiling fil…
illuusio Aug 20, 2021
7348043
PulseAudio: Add a "Default" sink and source
daschuer Apr 14, 2021
86be880
PulseAudio: Update comment block on CmakeList.txt for PulseAudio
illuusio Aug 21, 2021
fde7812
PulseAudio: Only public header is currently 'include/pa_linux_pulseau…
illuusio Aug 21, 2021
9d0510d
PulseAudio: Add full BSD-3-Three-Clausal license to FindPulseAudio.cm…
illuusio Aug 23, 2021
cc1194e
PulseAudio: Rework CMake CMakelist.txt to pair with upstream
illuusio Oct 21, 2021
b7a30e8
PulseAudio: Make compile defination PUBLIC with cmake
illuusio Nov 16, 2021
dd4a69a
PulseAudio: Rework Playback and Record connection
illuusio Mar 7, 2022
86d4581
PulseAudio: Rework active stream
illuusio Mar 7, 2022
8be4b78
PulseAudio: Make sure if stream occurs error then fail activation
illuusio Mar 7, 2022
b1bac8b
PulseAudio: Fix audio timestamp calculation.
kleinerm Jan 15, 2022
29db3e3
PulseAudio: Use more descriptive names for default source and sink.
kleinerm Mar 9, 2022
fff12f4
PulseAudio: Fix copy-paste error in default latency assignment.
kleinerm Mar 9, 2022
1517c30
PulseAudio: Use reasonable hard-coded default latency values.
kleinerm Mar 9, 2022
5f88f27
PulseAudio: Start using thread
illuusio Mar 7, 2022
f8b2d24
PulseAudio: Add time back
illuusio May 13, 2022
b3271c2
PulseAudio: Make sure Duplex has correct values if 'paFramesPerBuffer…
illuusio May 13, 2022
9425307
PulseAudio: Change ringbuffer allocation from hardcoded to more dynamic
illuusio May 13, 2022
e98ed6a
PulseAudio: Streamline stream starting
illuusio May 13, 2022
8b658bd
PulseAudio: Update some code from review and update writing code
illuusio Jun 6, 2022
aecbe43
PulseAudio: Simpler calculation for testing
illuusio Jun 10, 2022
d3b3c5e
PulseAudio: Update to current API changes
illuusio Sep 5, 2022
7b2fc07
PulseAudio: Fix building with debug printing on
illuusio Sep 5, 2022
fef040d
PulseAudio: Make sure that what we pass to Ringbuffer init is power o…
illuusio Sep 5, 2022
f2b1beb
PulseAudio: Fix code formating problems
illuusio Feb 17, 2023
d3106b1
PulseAudio: Ensure that we have enough input buffer
illuusio Feb 17, 2023
e70ef87
PulseAudio: Make sure that calculation is integer not float
illuusio Feb 17, 2023
b775bb0
PulseAudio: Rework latency calculation
illuusio Feb 24, 2023
66a3329
Pulseaudio: New way of handling output
illuusio Feb 24, 2023
c454c37
PulseAudio: Rearrange code for easier maintenance
illuusio Mar 27, 2023
5b98b38
pulseaudio: Duplex playing tuned
illuusio Aug 14, 2023
5864a7f
Pulseaudio: Fix white space issues
illuusio Aug 14, 2023
600b952
Pulseaudio: Make sure that stream is active after starting
illuusio Aug 16, 2023
a1e1049
Pulseaudio: Fix input with callback and paFramesPerBufferUnspecified
illuusio Aug 16, 2023
19ca2df
Pulseaudio: Sane default is better than malfunctioning calculation
illuusio Aug 26, 2023
5b5c08d
Pulseaudio: Update state machine comment
illuusio Aug 26, 2023
5ffbe99
Pulseaudio: Add more comments
illuusio Aug 26, 2023
069213c
Pulseaudio: Remove unneeded old stuff and refactor little bit
illuusio Aug 26, 2023
b263b8a
Pulseaudio: Fix missed CI issues
illuusio Aug 26, 2023
535538d
Pulseaudio: Make sure tlength is set
illuusio Aug 26, 2023
7cf4af9
Pulseaudio: Remove some unneeded variables
illuusio Aug 28, 2023
ab656ba
Pulseaudio: Make sure there is sane paFramesPerBufferUnspecified
illuusio Aug 28, 2023
f8fdbdf
Pulseaudio: Handle Mono to stereo
illuusio Sep 1, 2023
4e3f10f
Pulseaudio: Massive variable renaming
illuusio Sep 4, 2023
8a84e9f
Pulseaudio: Another manual intetantion round
illuusio Sep 4, 2023
001ac5c
Pulseaudio: Intendation correction and error handling
illuusio Sep 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,24 @@ elseif(UNIX)
target_compile_definitions(PortAudio PUBLIC PA_USE_AUDIOIO=1)
set(PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS} -DPA_USE_AUDIOIO=1")
endif()

find_package(PulseAudio)
cmake_dependent_option(PA_USE_PULSEAUDIO "Enable support for PulseAudio general purpose sound server" ON PulseAudio_FOUND OFF)
if(PA_USE_PULSEAUDIO)
target_link_libraries(PortAudio PRIVATE PulseAudio::PulseAudio)
target_sources(PortAudio PRIVATE
src/hostapi/pulseaudio/pa_linux_pulseaudio_block.c
src/hostapi/pulseaudio/pa_linux_pulseaudio.c
src/hostapi/pulseaudio/pa_linux_pulseaudio_cb.c)

target_compile_definitions(PortAudio PUBLIC PA_USE_PULSEAUDIO=1)
set(PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS} -DPA_USE_PULSEAUDIO=1")
set(PKGCONFIG_REQUIRES_PRIVATE "${PKGCONFIG_REQUIRES_PRIVATE} libpulse")

# needed for PortAudioConfig.cmake so `find_package(PortAudio)` works in downstream projects
install(FILES cmake/modules/FindPulseAudio.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/portaudio/modules")
endif()

endif()
endif()

Expand Down
7 changes: 4 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ PALIB = libportaudio.la
PAINC = include/portaudio.h

PA_LDFLAGS = $(LDFLAGS) $(SHARED_FLAGS) -rpath $(libdir) -no-undefined \
-export-symbols-regex "(Pa|PaMacCore|PaJack|PaAlsa|PaAsio|PaOSS|PaWasapi|PaWasapiWinrt|PaWinMME)_.*" \
-export-symbols-regex "(Pa|PaMacCore|PaPulseAudio|PaJack|PaAlsa|PaAsio|PaOSS|PaWasapi|PaWasapiWinrt|PaWinMME)_.*" \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)

COMMON_OBJS = \
Expand All @@ -66,7 +66,7 @@ LOOPBACK_OBJS = \
qa/loopback/src/test_audio_analyzer.o \
qa/loopback/src/write_wav.o \
qa/loopback/src/paqa.o

EXAMPLES = \
bin/pa_devs \
bin/pa_fuzz \
Expand All @@ -82,7 +82,7 @@ SELFTESTS = \
bin/paqa_devs \
bin/paqa_errs \
bin/paqa_latency

TESTS = \
bin/patest1 \
bin/patest_buffer \
Expand Down Expand Up @@ -146,6 +146,7 @@ SRC_DIRS = \
src/hostapi/coreaudio \
src/hostapi/dsound \
src/hostapi/jack \
src/hostapi/pulseaudio \
src/hostapi/oss \
src/hostapi/skeleton \
src/hostapi/wasapi \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Please feel free to join. See http://www.portaudio.com for details.
src/hostapi/dsound = Windows Direct Sound
src/hostapi/jack = JACK Audio Connection Kit
src/hostapi/oss = Unix Open Sound System (OSS)
src/hostapi/pulseaudio = Sound system for POSIX OSes
src/hostapi/wasapi = Windows Vista WASAPI
src/hostapi/wdmks = Windows WDM Kernel Streaming
src/hostapi/wmme = Windows MultiMedia Extensions (MME)
Expand Down
147 changes: 147 additions & 0 deletions cmake/modules/FindPulseAudio.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Copyright 2008 Matthias Kretz <kretz@kde.org>
# Copyright 2009 Marcus Hufgard <Marcus.Hufgard@hufgard.de>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# SPDX-FileCopyrightText: 2008 Matthias Kretz <kretz@kde.org>
# SPDX-FileCopyrightText: 2009 Marcus Hufgard <Marcus.Hufgard@hufgard.de>
#
# SPDX-License-Identifier: BSD-3-Clause

#.rst:
# FindPulseAudio
# --------------
#
# This is base on
# https://invent.kde.org/frameworks/extra-cmake-modules/-/blob/master/find-modules/FindPulseAudio.cmake
#
# Try to locate the PulseAudio library.
# If found, this will define the following variables:
#
# ``PulseAudio_FOUND``
# True if the system has the PulseAudio library of at least
# the minimum version specified by either the version parameter
# to find_package() or the variable PulseAudio_MINIMUM_VERSION
# ``PulseAudio_INCLUDE_DIRS``
# The PulseAudio include directory
# ``PulseAudio_LIBRARIES``
# The PulseAudio libraries for linking
# ``PulseAudio_MAINLOOP_LIBRARY``
# The libraries needed to use PulseAudio Mainloop
# ``PulseAudio_VERSION``
# The version of PulseAudio that was found
# ``PulseAudio_INCLUDE_DIR``
# Deprecated, use ``PulseAudio_INCLUDE_DIRS``
# ``PulseAudio_LIBRARY``
# Deprecated, use ``PulseAudio_LIBRARIES``
#
# If ``PulseAudio_FOUND`` is TRUE, it will also define the following
# imported target:
#
# ``PulseAudio::PulseAudio``
# The PulseAudio library
#
# Since 5.41.0.

# Support PulseAudio_MINIMUM_VERSION for compatibility:
if(NOT PulseAudio_FIND_VERSION)
set(PulseAudio_FIND_VERSION "${PulseAudio_MINIMUM_VERSION}")
endif()

# the minimum version of PulseAudio we require
if(NOT PulseAudio_FIND_VERSION)
set(PulseAudio_FIND_VERSION "1.0.0")
endif()

find_package(PkgConfig)
pkg_check_modules(PC_PulseAudio QUIET libpulse>=${PulseAudio_FIND_VERSION})
pkg_check_modules(PC_PulseAudio_MAINLOOP QUIET libpulse-mainloop-glib)

find_path(PulseAudio_INCLUDE_DIRS pulse/pulseaudio.h
HINTS
${PC_PulseAudio_INCLUDEDIR}
${PC_PulseAudio_INCLUDE_DIRS}
)

find_library(PulseAudio_LIBRARIES NAMES pulse libpulse
HINTS
${PC_PulseAudio_LIBDIR}
${PC_PulseAudio_LIBRARY_DIRS}
)

find_library(PulseAudio_MAINLOOP_LIBRARY
NAMES pulse-mainloop pulse-mainloop-glib libpulse-mainloop-glib
HINTS
${PC_PulseAudio_LIBDIR}
${PC_PulseAudio_LIBRARY_DIRS}
)

# Store the version number in the cache,
# so we don't have to search every time again:
if(PulseAudio_INCLUDE_DIRS AND NOT PulseAudio_VERSION)

# get PulseAudio's version from its version.h
file(STRINGS "${PulseAudio_INCLUDE_DIRS}/pulse/version.h" pulse_version_h
REGEX ".*pa_get_headers_version\\(\\).*")
string(REGEX REPLACE ".*pa_get_headers_version\\(\\)\ \\(\"([0-9]+\\.[0-9]+\\.[0-9]+)[^\"]*\"\\).*" "\\1"
_PulseAudio_VERSION "${pulse_version_h}")

set(PulseAudio_VERSION "${_PulseAudio_VERSION}"
CACHE STRING "Version number of PulseAudio"
FORCE)
endif()

# Use the new extended syntax of
# find_package_handle_standard_args(),
# which also handles version checking:
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PulseAudio
REQUIRED_VARS PulseAudio_LIBRARIES
PulseAudio_INCLUDE_DIRS
VERSION_VAR PulseAudio_VERSION)

# Deprecated synonyms
set(PulseAudio_INCLUDE_DIR "${PulseAudio_INCLUDE_DIRS}")
set(PulseAudio_LIBRARY "${PulseAudio_LIBRARIES}")
set(PulseAudio_MAINLOOP_LIBRARY "${PulseAudio_MAINLOOP_LIBRARY}")
set(PulseAudio_FOUND "${PulseAudio_FOUND}")

if(PulseAudio_FOUND AND NOT TARGET PulseAudio::PulseAudio)
add_library(PulseAudio::PulseAudio UNKNOWN IMPORTED)
set_target_properties(PulseAudio::PulseAudio PROPERTIES
IMPORTED_LOCATION "${PulseAudio_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${PulseAudio_INCLUDE_DIRS}")
endif()

mark_as_advanced(PulseAudio_INCLUDE_DIRS PulseAudio_INCLUDE_DIR
PulseAudio_LIBRARIES PulseAudio_LIBRARY
PulseAudio_MAINLOOP_LIBRARY PulseAudio_MAINLOOP_LIBRARY)

include(FeatureSummary)
set_package_properties(PulseAudio PROPERTIES
URL "https://www.freedesktop.org/wiki/Software/PulseAudio"
DESCRIPTION "Sound server, for sound stream routing and mixing")
29 changes: 28 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ AC_ARG_WITH(jack,
AS_HELP_STRING([--with-jack], [Enable support for JACK @<:@autodetect@:>@]),
[with_jack=$withval])

AC_ARG_WITH(pulseaudio,
philburk marked this conversation as resolved.
Show resolved Hide resolved
AS_HELP_STRING([--with-pulseaudio], [Enable support for PulseAudio @<:@autodetect@:>@]),
[with_pulseaudio=$withval])

AC_ARG_WITH(oss,
AS_HELP_STRING([--with-oss], [Enable support for OSS @<:@autodetect@:>@]),
[with_oss=$withval])
Expand Down Expand Up @@ -149,10 +153,17 @@ if test "x$with_oss" != "xno"; then
AC_CHECK_LIB(ossaudio, _oss_ioctl, have_libossaudio=yes, have_libossaudio=no)
fi
fi
if [[ "x$with_jack" != "xno" ] || [ "x$with_pulseaudio" != "xno" ]]; then
PKG_PROG_PKG_CONFIG
fi
have_jack=no
if test "x$with_jack" != "xno"; then
PKG_CHECK_MODULES(JACK, jack, have_jack=yes, have_jack=no)
fi
have_pulse=no
if test "x$with_pulseaudio" != "xno"; then
PKG_CHECK_MODULES(PULSE, libpulse, have_pulse=yes, have_pulse=no)
fi


dnl sizeof checks: we will need a 16-bit and a 32-bit type
Expand Down Expand Up @@ -386,11 +397,26 @@ case "${host_os}" in
if [[ "$have_jack" = "yes" ] && [ "$with_jack" != "no" ]] ; then
DLL_LIBS="$DLL_LIBS $JACK_LIBS"
CFLAGS="$CFLAGS $JACK_CFLAGS"
OTHER_OBJS="$OTHER_OBJS src/hostapi/jack/pa_jack.o src/common/pa_ringbuffer.o"
OTHER_OBJS="$OTHER_OBJS src/hostapi/jack/pa_jack.o"
INCLUDES="$INCLUDES pa_jack.h"
AC_DEFINE(PA_USE_JACK,1)
fi

if [[ "$have_pulse" = "yes" ] || [ "$have_jack" = "yes" ]] ; then
OTHER_OBJS="$OTHER_OBJS src/common/pa_ringbuffer.o"
INCLUDES="$INCLUDES pa_linux_pulseaudio.h"
Copy link
Collaborator

@RossBencina RossBencina Sep 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will add pa_linux_pulsaudio.h even if only $have_jack is yes. Is that what you want?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is merged now, but I'd still like to get clarification about whether this has the intended behavior please.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be copy paste.. I'll make PR to solve this. I think it should be something like "$have_pulse" = "yes" ] && [ "$with_pulse" != "no" or just merge it to one to rule them all if. I have to admit I use CMake so this was not tested very deeply.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now there is pull request with small fix to make it work. Jack and Pulseaudio needs ringbuffer so it's just merged together.

fi

if [[ "$have_pulse" = "yes" ] && [ "$with_pulse" != "no" ]] ; then
DLL_LIBS="$DLL_LIBS $PULSE_LIBS"
CFLAGS="$CFLAGS $PULSE_CFLAGS"
OTHER_OBJS="$OTHER_OBJS src/hostapi/pulseaudio/pa_linux_pulseaudio_cb.o"
OTHER_OBJS="$OTHER_OBJS src/hostapi/pulseaudio/pa_linux_pulseaudio_block.o"
OTHER_OBJS="$OTHER_OBJS src/hostapi/pulseaudio/pa_linux_pulseaudio.o"
dnl INCLUDES="$INCLUDES pa_pulseaudio.h src/hostapi/pulseaudio/pa_linux_pulseaudio_internal.h src/hostapi/pulseaudio/pa_linux_pulseaudio_block_internal.h src/hostapi/pulseaudio/pa_linux_pulseaudio_cb_internal.h"
AC_DEFINE(PA_USE_PULSEAUDIO,1)
fi

if [[ "$with_oss" != "no" ]] ; then
OTHER_OBJS="$OTHER_OBJS src/hostapi/oss/pa_unix_oss.o"
if [[ "$have_libossaudio" = "yes" ]] ; then
Expand Down Expand Up @@ -489,6 +515,7 @@ case "$target_os" in
AudioIO ..................... $have_audioio
OSS ......................... $have_oss
JACK ........................ $have_jack
PulseAudio .................. $have_pulse
])
;;
esac
79 changes: 79 additions & 0 deletions include/pa_linux_pulseaudio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#ifndef PA_LINUX_PULSEAUDIO_H
#define PA_LINUX_PULSEAUDIO_H

/*
* $Id$
* PortAudio Portable Real-Time Audio Library
* PulseAudio-specific extensions
*
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/*
* The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
* they can be incorporated into the canonical version. It is also
* requested that these non-binding requests be included along with the
* license above.
*/

/** @file
* @ingroup public_header
* @brief PulseAudio-specific PortAudio API extension header file.
*/

#include "portaudio.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* Renames the PulseAudio description for the source that is opened
* by PortAudio.
*
* @param s The PortAudio stream to operate on.
* @param streamName The new name/description of the source.
*
* @return paNoError on success or the error encountered otherwise.
*/
PaError PaPulseAudio_RenameSource( PaStream *s, const char *streamName );

/**
* Renames the PulseAudio description for the sink that is opened
* by PortAudio.
*
* @param s The PortAudio stream to operate on.
* @param streamName The new name/description of the sink.
*
* @return paNoError on success or the error encountered otherwise.
*/
PaError PaPulseAudio_RenameSink( PaStream *s, const char *streamName );

#ifdef __cplusplus
}
#endif

#endif
3 changes: 2 additions & 1 deletion include/portaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ typedef enum PaHostApiTypeId
paJACK=12,
paWASAPI=13,
paAudioScienceHPI=14,
paAudioIO=15
paAudioIO=15,
paPulseAudio=16
} PaHostApiTypeId;


Expand Down
9 changes: 8 additions & 1 deletion src/common/pa_hostapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ are defaulted to 1.
#define PA_USE_SKELETON 1
#endif

#if defined(PA_NO_ASIO) || defined(PA_NO_DS) || defined(PA_NO_WMME) || defined(PA_NO_WASAPI) || defined(PA_NO_WDMKS)
#if defined(PA_NO_PULSEAUDIO) || defined(PA_NO_ASIO) || defined(PA_NO_DS) || defined(PA_NO_WMME) || defined(PA_NO_WASAPI) || defined(PA_NO_WDMKS)
#error "Portaudio: PA_NO_<APINAME> is no longer supported, please remove definition and use PA_USE_<APINAME> instead"
#endif

Expand Down Expand Up @@ -132,6 +132,13 @@ are defaulted to 1.
#define PA_USE_JACK 1
#endif

#ifndef PA_USE_PULSEAUDIO
#define PA_USE_PULSEAUDIO 0
#elif (PA_USE_PULSEAUDIO != 0) && (PA_USE_PULSEAUDIO != 1)
#undef PA_USE_PULSEAUDIO
#define PA_USE_PULSEAUDIO 1
#endif

#ifndef PA_USE_SGI
#define PA_USE_SGI 0
#elif (PA_USE_SGI != 0) && (PA_USE_SGI != 1)
Expand Down
Loading