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

Add support for sndio #647

Closed
wants to merge 3 commits into from
Closed

Add support for sndio #647

wants to merge 3 commits into from

Conversation

lanodan
Copy link
Contributor

@lanodan lanodan commented Sep 16, 2021

New attempt to get sndio into portaudio, sadly I couldn't get the comments to the diff on Assembla for some reason.

Closes: #220

@RossBencina
Copy link
Collaborator

@Ianodan: Please clarify: are you saying that you have not made the changes requested at Assembla?

@philburk
Copy link
Collaborator

We merged a PR last week, Add Sun/NetBSD hostapi #645
I thought that included support for sndio. Maybe not.

Is there any overlap between these two implementations? Do we need both?

@lanodan
Copy link
Contributor Author

lanodan commented Sep 23, 2021

@Ianodan: Please clarify: are you saying that you have not made the changes requested at Assembla?

I cannot see the comments that were made on Assembla for the PR done some years ago by someone else, so no.

We merged a PR last week, Add Sun/NetBSD hostapi #645
I thought that included support for sndio. Maybe not.

Is there any overlap between these two implementations? Do we need both?

There is no relation between Sun/NetBSD audio and sndio.
sndio is from OpenBSD but works on multiple operating systems (OpenBSD, NetBSD, FreeBSD, Linux, …) as it isn't a kernel-level audio system but an audio server (like JACK or PulseAudio).
As for the need for it, there is an ALSA compatibility layer but it's rather limited (lack of (sub)device selection, which is annoying for audio recording purposes).

Copy link
Collaborator

@philburk philburk left a comment

Choose a reason for hiding this comment

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

Thanks for resurrecting this code. I have not given a it a full review. But I did notice some stylistic issues.

README.md Outdated Show resolved Hide resolved
src/hostapi/sndio/pa_sndio.c Outdated Show resolved Hide resolved
src/hostapi/sndio/pa_sndio.c Outdated Show resolved Hide resolved
src/hostapi/sndio/pa_sndio.c Outdated Show resolved Hide resolved
src/hostapi/sndio/pa_sndio.c Outdated Show resolved Hide resolved
src/hostapi/sndio/pa_sndio.c Outdated Show resolved Hide resolved
@RossBencina
Copy link
Collaborator

We are interested in this contribution, but we will not accept it as-is. Our basic formatting conventions need to be adhered to (e.g. use spaces not tabs, formatting of function declarations) see: https://github.com/PortAudio/portaudio/wiki/ImplementationStyleGuidelines . Beyond this, I think the review comments to-date are reasonable, but perhaps there is some room for compromise in the style of variable names (inch vs. inputChannelCount for example).

@philburk
Copy link
Collaborator

Please let us know if you are interested in updating the code style.

Also please let us know if you are willing to be an "owner" of this code and make bug fixes if needed.

@loveJesus
Copy link

loveJesus commented Nov 6, 2021

God is good,
Just wanted to say thanks for the work on portaudio and this patch. It is working for me on OpenBSD 7.0, at least to the point of using through the pyaudio package. In case it helps anyone: to compile, i needed to

doas pkg_add automake autoconf gmake libtool
# The following were the versions installed and are needed on OpenBSD. 
export AUTOMAKE_VERSION=1.16
export AUTOCONF_VERSION=2.71 
autoreconf -ri
./configure --without-audioio --without-oss --with-sndio
gmake clean  #(instead of make)
gmake 
doas gmake install
#Likely there is a better way to do the following
doas cp include/portaudio.h /usr/local/include 
export CFLAGS="-I/usr/local/include"
# Now can pip install pyaudio

Hope that covers things and did not forget anything.

@philburk
Copy link
Collaborator

@lanodan - Please let us know if you would like to keep working on this. Please see comments above.

@lanodan lanodan marked this pull request as ready for review November 12, 2021 11:49
@lanodan
Copy link
Contributor Author

lanodan commented Nov 12, 2021

@lanodan - Please let us know if you would like to keep working on this. Please see comments above.

Yes, I do want to keep working on it. AFAIK I just addressed all the comments above.

please let us know if you are willing to be an "owner" of this code and make bug fixes if needed.

I am willing to maintain this code as I need it to work and would gladly welcome co-owners, specially ones which are from non-Linux to cover more systems (as I've yet to get actually working audio in QEMU).

As for the code style, I pushed a .clang-format file to avoid mismatched indentation settings for at least the sndio module, could be moved into the sndio module folder.
Variable renaming is a bit tedious but I think it's much better to have it be similar enough to other modules.

.github/workflows/cmake.yml Outdated Show resolved Hide resolved
.github/workflows/cmake.yml Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
@RossBencina
Copy link
Collaborator

It's looking much more consistent with our other code. Could you please also make a global find and replace of sndio_stream -> sndioStream and pa_stream -> paStream.

par->bps = 3; /* paInt24 is packed format */
break;
case paInt16:
case paFloat32:
Copy link
Collaborator

@RossBencina RossBencina Nov 18, 2021

Choose a reason for hiding this comment

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

I'm not sure whether this is a bug, but ideally float32 should be mapped to 24 or 32 bit IO (assuming that sndio doesn't support float IO natively).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also please leave a comment explaining why it works even though it may look odd. That will save you from having people ask questions about the code in the future.

Copy link
Contributor Author

@lanodan lanodan Dec 1, 2021

Choose a reason for hiding this comment

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

Looks like this was a bug I inherited, it doesn't looks like sndio supports floats so I removed the case paFloat32: line for now, will try to fix it properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mapped it to 32bit IO, not entirely sure what would be the best way to test or be sure which to pick.

PaSndioHostApiRepresentation *sndioHostApi;
PaDeviceInfo *info;
struct sio_hdl *hdl;
char *audiodevices;
Copy link
Collaborator

Choose a reason for hiding this comment

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

should be audioDevices

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fixed in #878

typedef struct PaSndioStream
{
PaUtilStreamRepresentation base;
PaUtilBufferProcessor bufproc; /* format conversion */
Copy link
Collaborator

Choose a reason for hiding this comment

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

rename to bufferProcessor

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fixed in #878

@@ -0,0 +1,10 @@
AlignTrailingComments: 'false'
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is looking very good.
This file can lead to unexpected reformatting.
Can you please move this .clang-format file into the /sndio/ folder?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fixed in #878

struct sio_par par;
unsigned mode;
int inputChannelCount, outputChannelCount;
PaSampleFormat ifmt, ofmt, siofmt;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use more clear names like "inputFormat".

have_sndio=no
if test "x$with_sndio" != "xno"; then
AC_CHECK_LIB(sndio, sio_open, have_sndio=yes, have_sndio=no)
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

Should use PKG_CHECK_MODULES(SNDIO, sndio, have_sndio=yes, have_sndio=no) here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in #878

@@ -382,6 +390,13 @@ case "${host_os}" in
AC_DEFINE(PA_USE_AUDIOIO,1)
fi

if [[ "$have_sndio" = "yes" -a "$with_sndio" != "no" ]] ; then
DLL_LIBS="$DLL_LIBS -lsndio"
LIBS="$LIBS -lsndio"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should use

DLL_LIBS="$DLL_LIBS $SNDIO_LIBS"
LIBS="$LIBS $SNDIO_LIBS"
CFLAGS="$CFLAGS $SNDIO_CFLAGS"

here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in #878

@brad0
Copy link
Contributor

brad0 commented Oct 27, 2022

BTW, I came across this ticket as I am an OpenBSD developer and was going to consider another push of a sndio backend, but came across this PR before doing so.

@c64skin
Copy link

c64skin commented Jan 31, 2023

Any chance of this getting merged before we die of old age?

@philburk
Copy link
Collaborator

Is anyone interested in moving this forward?
It needs to be rebased and there are unresolved issues.

@brad0
Copy link
Contributor

brad0 commented Jan 20, 2024

Is anyone interested in moving this forward?

We have had a PA backend in our tree for 15 years. I would very much like to see something moving forward. Even if it's not perceived to be 100% perfect. You have to start somewhere.

It needs to be rebased and there are unresolved issues.

@lanodan seems to have disappeared.

@lanodan
Copy link
Contributor Author

lanodan commented Jan 20, 2024 via email

@lanodan lanodan closed this Jan 20, 2024
@philburk philburk mentioned this pull request Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Review OpenBSD sndio Host APl implementation
7 participants