Skip to content

Commit

Permalink
Add Sun/NetBSD hostapi
Browse files Browse the repository at this point in the history
This hostapi has been available in the pkgsrc package for PortAudio
for over a year (we build for Solaris and NetBSD). It was inspired by
problems interfacing between PortAudio's OSS hostapi and NetBSD's OSS
compatibility layer that I couldn't fix without adding very ugly hacks
to the OSS hostapi - in the end I decided to write a new, clean one for
the native interface.

Tested building with the autotools and CMake build systems.
Test and example programs work.
  • Loading branch information
alarixnia committed Sep 12, 2021
1 parent 55b97bf commit 3643853
Show file tree
Hide file tree
Showing 7 changed files with 1,146 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,13 @@ elseif(UNIX)
# The FindOSS.cmake module does not need to be installed like the JACK modules because it
# does not link any library; it only adds an include directory and compile definition.
endif()

CHECK_INCLUDE_FILE(sys/audioio.h HAVE_SYS_AUDIOIO_H)
cmake_dependent_option(SUN "Enable support for Sun/NetBSD Audio" ON "SUN_FOUND" SUN)
if(SUN AND HAVE_SYS_AUDIOIO_H)
target_sources(PortAudio PRIVATE src/hostapi/sun/pa_unix_sun.c)
target_compile_definitions(PortAudio PRIVATE PA_USE_SUN=1)
endif()
endif()
endif()

Expand Down
1 change: 1 addition & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ SRC_DIRS = \
src/hostapi/dsound \
src/hostapi/jack \
src/hostapi/oss \
src/hostapi/sun \
src/hostapi/skeleton \
src/hostapi/wasapi \
src/hostapi/wdmks \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,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/sun = /dev/audio (Sun/NetBSD Audio)
src/hostapi/wasapi = Windows Vista WASAPI
src/hostapi/wdmks = Windows WDM Kernel Streaming
src/hostapi/wmme = Windows MultiMedia Extensions (MME)
Expand Down
14 changes: 14 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ AC_ARG_WITH(oss,
AS_HELP_STRING([--with-oss], [Enable support for OSS @<:@autodetect@:>@]),
[with_oss=$withval])

AC_ARG_WITH(sun,
AS_HELP_STRING([--with-sun], [Enable support for Sun/NetBSD @<:@autodetect@:>@]),
[with_sun=$withval])

AC_ARG_WITH(asihpi,
AS_HELP_STRING([--with-asihpi], [Enable support for ASIHPI @<:@autodetect@:>@]),
[with_asihpi=$withval])
Expand Down Expand Up @@ -141,6 +145,10 @@ if test "x$with_oss" != "xno"; then
AC_CHECK_LIB(ossaudio, _oss_ioctl, have_libossaudio=yes, have_libossaudio=no)
fi
fi
have_sun=no
if test "x$with_sun" != "xno"; then
AC_CHECK_HEADERS([sys/audioio.h], [have_sun=yes])
fi
have_jack=no
if test "x$with_jack" != "xno"; then
PKG_CHECK_MODULES(JACK, jack, have_jack=yes, have_jack=no)
Expand Down Expand Up @@ -386,6 +394,11 @@ case "${host_os}" in
AC_DEFINE(PA_USE_OSS,1)
fi

if [[ "$with_sun" != "no" ]] ; then
OTHER_OBJS="$OTHER_OBJS src/hostapi/sun/pa_unix_sun.o"
AC_DEFINE(PA_USE_SUN,1)
fi

if [[ "$have_asihpi" = "yes" ] && [ "$with_asihpi" != "no" ]] ; then
LIBS="$LIBS -lhpi"
DLL_LIBS="$DLL_LIBS -lhpi"
Expand Down Expand Up @@ -473,6 +486,7 @@ case "$target_os" in
*)
AC_MSG_RESULT([
OSS ......................... $have_oss
Sun/NetBSD .................. $have_sun
JACK ........................ $have_jack
])
;;
Expand Down
3 changes: 2 additions & 1 deletion include/portaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ typedef enum PaHostApiTypeId
paWDMKS=11,
paJACK=12,
paWASAPI=13,
paAudioScienceHPI=14
paAudioScienceHPI=14,
paSun=15
} PaHostApiTypeId;


Expand Down
Loading

0 comments on commit 3643853

Please sign in to comment.