Fix for a bug in the sndio backend with the capture support.
Index: Makefile =================================================================== RCS file: /home/cvs/ports/audio/openal/Makefile,v retrieving revision 1.57 diff -u -p -u -p -r1.57 Makefile --- Makefile 20 Aug 2021 21:54:22 -0000 1.57 +++ Makefile 4 Oct 2021 02:23:13 -0000 @@ -6,7 +6,7 @@ V = 1.21.1 EPOCH = 0 DISTNAME = openal-soft-$V PKGNAME = openal-$V -REVISION = 1 +REVISION = 2 CATEGORIES = audio SHARED_LIBS = openal 4.1 Index: patches/patch-alc_backends_sndio_cpp =================================================================== RCS file: /home/cvs/ports/audio/openal/patches/patch-alc_backends_sndio_cpp,v retrieving revision 1.3 diff -u -p -u -p -r1.3 patch-alc_backends_sndio_cpp --- patches/patch-alc_backends_sndio_cpp 20 Aug 2021 21:54:22 -0000 1.3 +++ patches/patch-alc_backends_sndio_cpp 4 Oct 2021 02:25:36 -0000 @@ -6,6 +6,8 @@ Simplify channel handling in the sndio b Use non-block mode for sndio capture 1fd4c865fc084f134363db5155361d5483679235 +Fix crashes in SndioCapture::recordProc +a4b0a3d7b3ec271243cfda4780e567e49f2b37b7 Index: alc/backends/sndio.cpp --- alc/backends/sndio.cpp.orig @@ -269,7 +271,19 @@ Index: alc/backends/sndio.cpp RingBufferPtr mRing; std::atomic<bool> mKillNow{true}; -@@ -326,37 +309,53 @@ int SndioCapture::recordProc() +@@ -323,40 +306,65 @@ int SndioCapture::recordProc() + + const uint frameSize{mDevice->frameSizeFromFmt()}; + ++ int nfds_pre{sio_nfds(mSndHandle)}; ++ if (nfds_pre <= 0) ++ { ++ mDevice->handleDisconnect("Incorrect return value from sio_nfds(): %d", nfds_pre); ++ return 1; ++ } ++ ++ mFds.resize(nfds_pre); ++ while(!mKillNow.load(std::memory_order_acquire) && mDevice->Connected.load(std::memory_order_acquire)) { @@ -345,7 +359,7 @@ Index: alc/backends/sndio.cpp } return 0; -@@ -371,76 +370,80 @@ void SndioCapture::open(const char *name) +@@ -371,76 +379,80 @@ void SndioCapture::open(const char *name) throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found", name};