From upstream..
Use a local unique_ptr array instead of a struct member for the sndio
poll fds.
Index: Makefile
===================================================================
RCS file: /home/cvs/ports/audio/openal/Makefile,v
retrieving revision 1.58
diff -u -p -u -p -r1.58 Makefile
--- Makefile 16 Oct 2021 07:59:12 -0000 1.58
+++ Makefile 31 Oct 2021 01:44:29 -0000
@@ -6,7 +6,7 @@ V = 1.21.1
EPOCH = 0
DISTNAME = openal-soft-$V
PKGNAME = openal-$V
-REVISION = 2
+REVISION = 3
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.4
diff -u -p -u -p -r1.4 patch-alc_backends_sndio_cpp
--- patches/patch-alc_backends_sndio_cpp 16 Oct 2021 07:59:12 -0000 1.4
+++ patches/patch-alc_backends_sndio_cpp 31 Oct 2021 01:54:32 -0000
@@ -9,6 +9,10 @@ Use non-block mode for sndio capture
Fix crashes in SndioCapture::recordProc
a4b0a3d7b3ec271243cfda4780e567e49f2b37b7
+Use a local unique_ptr array instead of a struct member
+for the sndio poll fds.
+2df78e49b1359e7603e3816270737c68cccd5b05
+
Index: alc/backends/sndio.cpp
--- alc/backends/sndio.cpp.orig
+++ alc/backends/sndio.cpp
@@ -263,26 +267,18 @@ Index: alc/backends/sndio.cpp
struct SndioCapture final : public BackendBase {
SndioCapture(ALCdevice *device) noexcept : BackendBase{device} { }
~SndioCapture() override;
-@@ -301,6 +283,7 @@ struct SndioCapture final : public BackendBase {
-
- sio_hdl *mSndHandle{nullptr};
-
-+ al::vector<struct pollfd> mFds;
- RingBufferPtr mRing;
-
- std::atomic<bool> mKillNow{true};
-@@ -323,40 +306,65 @@ int SndioCapture::recordProc()
+@@ -323,40 +305,65 @@ int SndioCapture::recordProc()
const uint frameSize{mDevice->frameSizeFromFmt()};
+ int nfds_pre{sio_nfds(mSndHandle)};
-+ if (nfds_pre <= 0)
++ if(nfds_pre <= 0)
+ {
+ mDevice->handleDisconnect("Incorrect return value from sio_nfds(): %d", nfds_pre);
+ return 1;
+ }
+
-+ mFds.resize(nfds_pre);
++ auto fds = std::make_unique<pollfd[]>(static_cast<uint>(nfds_pre));
+
while(!mKillNow.load(std::memory_order_acquire)
&& mDevice->Connected.load(std::memory_order_acquire))
@@ -291,7 +287,7 @@ Index: alc/backends/sndio.cpp
- size_t todo{data.first.len + data.second.len};
- if(todo == 0)
+ /* Wait until there's some samples to read. */
-+ const int nfds{sio_pollfd(mSndHandle, mFds.data(), POLLIN)};
++ const int nfds{sio_pollfd(mSndHandle, fds.get(), POLLIN)};
+ if(nfds <= 0)
{
- static char junk[4096];
@@ -300,7 +296,7 @@ Index: alc/backends/sndio.cpp
+ mDevice->handleDisconnect("Failed to get polling fds: %d", nfds);
+ break;
+ }
-+ int pollres{::poll(mFds.data(), static_cast<uint>(nfds), 2000)};
++ int pollres{::poll(fds.get(), static_cast<uint>(nfds), 2000)};
+ if(pollres < 0)
+ {
+ if(errno == EINTR) continue;
@@ -310,7 +306,7 @@ Index: alc/backends/sndio.cpp
+ if(pollres == 0)
continue;
+
-+ const int revents{sio_revents(mSndHandle, mFds.data())};
++ const int revents{sio_revents(mSndHandle, fds.get())};
+ if((revents&POLLHUP))
+ {
+ mDevice->handleDisconnect("Got POLLHUP from poll events");
@@ -359,7 +355,7 @@ Index: alc/backends/sndio.cpp
}
return 0;
-@@ -371,76 +379,80 @@ void SndioCapture::open(const char *name)
+@@ -371,76 +378,80 @@ void SndioCapture::open(const char *name)
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
name};
No comments:
Post a Comment