Yo!

So, openal-soft 1.19.0 was released yesterday and today kcat has pushed
3 commits one of which adds sndio input support (thanks to ratchov@'s
work) that will happen in 1.19.1 release, meanwhile I am taking upstream
patches and removing redundant patches, making this port easier to
maintain. I raised minor version number and nothing seems to be broken
yet...
Index: Makefile
===================================================================
RCS file: /cvs/ports/audio/openal/Makefile,v
retrieving revision 1.51
diff -u -p -u -p -r1.51 Makefile
--- Makefile    9 Aug 2018 20:50:47 -0000       1.51
+++ Makefile    8 Sep 2018 13:42:50 -0000
@@ -1,16 +1,13 @@
 # $OpenBSD: Makefile,v 1.51 2018/08/09 20:50:47 ratchov Exp $
 
-BROKEN-hppa =  undefined reference to __sync atomic ops
-
 COMMENT =      cross-platform 3D audio API
 
-V =            1.17.2
+V =            1.19.0
 EPOCH =                0
 DISTNAME =     openal-soft-$V
 PKGNAME =      openal-$V
 CATEGORIES =   audio
-SHARED_LIBS =  openal  3.0
-REVISION =     1
+SHARED_LIBS =  openal  3.1
 
 HOMEPAGE =     http://kcat.strangesoft.net/openal.html
 
@@ -19,7 +16,7 @@ MAINTAINER =  David Carlier <devnexen@gma
 # LGPLv2+
 PERMIT_PACKAGE_CDROM = Yes
 
-WANTLIB +=     c m pthread sndio ${COMPILER_LIBCXX}
+WANTLIB +=     c m pthread sndio
 
 MASTER_SITES = ${HOMEPAGE:S,.html,-releases/,}
 EXTRACT_SUFX = .tar.bz2
@@ -42,21 +39,13 @@ CONFIGURE_ARGS =-DCMAKE_BUILD_TYPE=OpenB
                -DCMAKE_DISABLE_FIND_PACKAGE_PortAudio:Bool=Yes \
                -DCMAKE_DISABLE_FIND_PACKAGE_PulseAudio:Bool=Yes \
                -DCMAKE_DISABLE_FIND_PACKAGE_QSA:Bool=Yes \
+               -DCMAKE_DISABLE_FIND_PACKAGE_SDL2:Bool=Yes \
                -DALSOFT_NO_CONFIG_UTIL=On
 
 MODULES =      devel/cmake
 
-COMPILER =             base-clang ports-clang ports-gcc
+COMPILER =     base-clang ports-clang ports-gcc
 
-SEPARATE_BUILD =Yes
 NO_TEST =      Yes
-
-pre-build:
-       @${SUBST_CMD} ${WRKSRC}/Alc/alcConfig.c ${WRKSRC}/alsoftrc.sample
-
-post-install:
-       ${INSTALL_DATA_DIR} ${PREFIX}/share/examples/openal
-       ${INSTALL_DATA} ${WRKSRC}/alsoftrc.sample \
-               ${PREFIX}/share/examples/openal
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/audio/openal/distinfo,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 distinfo
--- distinfo    15 Nov 2017 13:02:42 -0000      1.10
+++ distinfo    8 Sep 2018 13:42:50 -0000
@@ -1,2 +1,2 @@
-SHA256 (openal-soft-1.17.2.tar.bz2) = 
o0H4VC8fC4xlJBoX2hPQc/GOwGZY4aFgao7Mi7wrMxQ=
-SIZE (openal-soft-1.17.2.tar.bz2) = 486934
+SHA256 (openal-soft-1.19.0.tar.bz2) = 
8a3zpuc+L5JwoP0AiH6iN5OWj6eH9g3N7EGjsvQqDtY=
+SIZE (openal-soft-1.19.0.tar.bz2) = 575163
Index: patches/patch-Alc_ALc_c
===================================================================
RCS file: /cvs/ports/audio/openal/patches/patch-Alc_ALc_c,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 patch-Alc_ALc_c
--- patches/patch-Alc_ALc_c     31 Dec 2017 18:46:26 -0000      1.1
+++ patches/patch-Alc_ALc_c     8 Sep 2018 13:42:50 -0000
@@ -1,35 +1,54 @@
-$OpenBSD: patch-Alc_ALc_c,v 1.1 2017/12/31 18:46:26 jca Exp $
-
-commit d1e98c36d375433cb11a7a74ce20c968491773aa
-Author: Chris Robinson <chris.k...@gmail.com>
-Date:   Sat Apr 30 17:14:55 2016 -0700
-
-    Don't crash when there's no backend to probe
+$OpenBSD$
 
 Index: Alc/ALc.c
 --- Alc/ALc.c.orig
 +++ Alc/ALc.c
-@@ -1117,6 +1117,11 @@ static void alc_initconfig(void)
-         V0(factory,init)();
-     }
+@@ -79,7 +79,7 @@ static struct BackendInfo BackendList[] = {
+     { "solaris", ALCsolarisBackendFactory_getFactory },
+ #endif
+ #ifdef HAVE_SNDIO
+-    { "sndio", ALCsndioBackendFactory_getFactory },
++    { "sndio", SndioBackendFactory_getFactory },
+ #endif
+ #ifdef HAVE_OSS
+     { "oss", ALCossBackendFactory_getFactory },
+@@ -656,9 +656,9 @@ static const struct {
  
-+    if(!PlaybackBackend.name)
-+        WARN("No playback backend available!\n");
-+    if(!CaptureBackend.name)
-+        WARN("No capture backend available!\n");
-+
-     if(ConfigValueStr(NULL, NULL, "excludefx", &str))
-     {
-         size_t len;
-@@ -1230,9 +1235,9 @@ static void ProbeDevices(al_string *list, struct Backe
-     LockLists();
-     al_string_clear(list);
- 
--    if(!backendinfo->getFactory)
-+    if(backendinfo->Probe)
-         backendinfo->Probe(type);
--    else
-+    else if(backendinfo->getFactory)
+     DECL(AL_DEDICATED_GAIN),
+ 
+-    DECL(AL_AUTOWAH_ATTACK_TIME),
+-    DECL(AL_AUTOWAH_RELEASE_TIME),
+-    DECL(AL_AUTOWAH_RESONANCE),
++    DECL(AL_AUTOWAH_ATTACK_TIME),
++    DECL(AL_AUTOWAH_RELEASE_TIME),
++    DECL(AL_AUTOWAH_RESONANCE),
+     DECL(AL_AUTOWAH_PEAK_GAIN),
+ 
+     DECL(AL_NUM_RESAMPLERS_SOFT),
+@@ -1314,7 +1314,7 @@ static void ProbeDevices(al_string *list, struct Backe
+     if(backendinfo->getFactory)
      {
          ALCbackendFactory *factory = backendinfo->getFactory();
-         V(factory,probe)(type);
+-        V(factory,probe)(type);
++        V(factory,probe)(type, list);
+     }
+ 
+     UnlockLists();
+@@ -1323,17 +1323,6 @@ static void ProbeAllDevicesList(void)
+ { ProbeDevices(&alcAllDevicesList, &PlaybackBackend, ALL_DEVICE_PROBE); }
+ static void ProbeCaptureDeviceList(void)
+ { ProbeDevices(&alcCaptureDeviceList, &CaptureBackend, CAPTURE_DEVICE_PROBE); 
}
+-
+-static void AppendDevice(const ALCchar *name, al_string *devnames)
+-{
+-    size_t len = strlen(name);
+-    if(len > 0)
+-        alstr_append_range(devnames, name, name+len+1);
+-}
+-void AppendAllDevicesList(const ALCchar *name)
+-{ AppendDevice(name, &alcAllDevicesList); }
+-void AppendCaptureDeviceList(const ALCchar *name)
+-{ AppendDevice(name, &alcCaptureDeviceList); }
+ 
+ 
+ /************************************************
Index: patches/patch-Alc_alcConfig_c
===================================================================
RCS file: patches/patch-Alc_alcConfig_c
diff -N patches/patch-Alc_alcConfig_c
--- patches/patch-Alc_alcConfig_c       15 Nov 2017 13:02:42 -0000      1.4
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,13 +0,0 @@
-$OpenBSD: patch-Alc_alcConfig_c,v 1.4 2017/11/15 13:02:42 sthen Exp $
-Index: Alc/alcConfig.c
---- Alc/alcConfig.c.orig
-+++ Alc/alcConfig.c
-@@ -353,7 +353,7 @@ void ReadALConfig(void)
-     const char *str;
-     FILE *f;
- 
--    str = "/etc/openal/alsoft.conf";
-+    str = "${SYSCONFDIR}/openal/alsoft.conf";
- 
-     TRACE("Loading config %s...\n", str);
-     f = al_fopen(str, "r");
Index: patches/patch-Alc_backends_base_h
===================================================================
RCS file: patches/patch-Alc_backends_base_h
diff -N patches/patch-Alc_backends_base_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Alc_backends_base_h   8 Sep 2018 13:42:50 -0000
@@ -0,0 +1,40 @@
+$OpenBSD$
+
+Index: Alc/backends/base.h
+--- Alc/backends/base.h.orig
++++ Alc/backends/base.h
+@@ -3,6 +3,7 @@
+ 
+ #include "alMain.h"
+ #include "threads.h"
++#include "alstring.h"
+ 
+ 
+ #ifdef __cplusplus
+@@ -115,7 +116,7 @@ struct ALCbackendFactoryVtable {
+ 
+     ALCboolean (*const querySupport)(ALCbackendFactory *self, ALCbackend_Type 
type);
+ 
+-    void (*const probe)(ALCbackendFactory *self, enum DevProbe type);
++    void (*const probe)(ALCbackendFactory *self, enum DevProbe type, 
al_string *outnames);
+ 
+     ALCbackend* (*const createBackend)(ALCbackendFactory *self, ALCdevice 
*device, ALCbackend_Type type);
+ };
+@@ -124,7 +125,7 @@ struct ALCbackendFactoryVtable {
+ DECLARE_THUNK(T, ALCbackendFactory, ALCboolean, init)                         
\
+ DECLARE_THUNK(T, ALCbackendFactory, void, deinit)                             
\
+ DECLARE_THUNK1(T, ALCbackendFactory, ALCboolean, querySupport, 
ALCbackend_Type) \
+-DECLARE_THUNK1(T, ALCbackendFactory, void, probe, enum DevProbe)              
\
++DECLARE_THUNK2(T, ALCbackendFactory, void, probe, enum DevProbe, al_string*)  
\
+ DECLARE_THUNK2(T, ALCbackendFactory, ALCbackend*, createBackend, ALCdevice*, 
ALCbackend_Type) \
+                                                                               
\
+ static const struct ALCbackendFactoryVtable T##_ALCbackendFactory_vtable = {  
\
+@@ -142,7 +143,7 @@ ALCbackendFactory *ALCcoreAudioBackendFactory_getFacto
+ ALCbackendFactory *ALCossBackendFactory_getFactory(void);
+ ALCbackendFactory *ALCjackBackendFactory_getFactory(void);
+ ALCbackendFactory *ALCsolarisBackendFactory_getFactory(void);
+-ALCbackendFactory *ALCsndioBackendFactory_getFactory(void);
++ALCbackendFactory *SndioBackendFactory_getFactory(void);
+ ALCbackendFactory *ALCqsaBackendFactory_getFactory(void);
+ ALCbackendFactory *ALCwasapiBackendFactory_getFactory(void);
+ ALCbackendFactory *ALCdsoundBackendFactory_getFactory(void);
Index: patches/patch-Alc_backends_loopback_c
===================================================================
RCS file: patches/patch-Alc_backends_loopback_c
diff -N patches/patch-Alc_backends_loopback_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Alc_backends_loopback_c       8 Sep 2018 13:42:50 -0000
@@ -0,0 +1,23 @@
+$OpenBSD$
+
+Index: Alc/backends/loopback.c
+--- Alc/backends/loopback.c.orig
++++ Alc/backends/loopback.c
+@@ -87,7 +87,7 @@ ALCbackendFactory *ALCloopbackFactory_getFactory(void)
+ static ALCboolean ALCloopbackFactory_init(ALCloopbackFactory *self);
+ static DECLARE_FORWARD(ALCloopbackFactory, ALCbackendFactory, void, deinit)
+ static ALCboolean ALCloopbackFactory_querySupport(ALCloopbackFactory *self, 
ALCbackend_Type type);
+-static void ALCloopbackFactory_probe(ALCloopbackFactory *self, enum DevProbe 
type);
++static void ALCloopbackFactory_probe(ALCloopbackFactory *self, enum DevProbe 
type, al_string *outnames);
+ static ALCbackend* ALCloopbackFactory_createBackend(ALCloopbackFactory *self, 
ALCdevice *device, ALCbackend_Type type);
+ DEFINE_ALCBACKENDFACTORY_VTABLE(ALCloopbackFactory);
+ 
+@@ -110,7 +110,7 @@ static ALCboolean ALCloopbackFactory_querySupport(ALCl
+     return ALC_FALSE;
+ }
+ 
+-static void ALCloopbackFactory_probe(ALCloopbackFactory* UNUSED(self), enum 
DevProbe UNUSED(type))
++static void ALCloopbackFactory_probe(ALCloopbackFactory* UNUSED(self), enum 
DevProbe UNUSED(type), al_string* UNUSED(outnames))
+ {
+ }
+ 
Index: patches/patch-Alc_backends_null_c
===================================================================
RCS file: patches/patch-Alc_backends_null_c
diff -N patches/patch-Alc_backends_null_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Alc_backends_null_c   8 Sep 2018 13:42:50 -0000
@@ -0,0 +1,31 @@
+$OpenBSD$
+
+Index: Alc/backends/null.c
+--- Alc/backends/null.c.orig
++++ Alc/backends/null.c
+@@ -171,7 +171,7 @@ ALCbackendFactory *ALCnullBackendFactory_getFactory(vo
+ static ALCboolean ALCnullBackendFactory_init(ALCnullBackendFactory *self);
+ static DECLARE_FORWARD(ALCnullBackendFactory, ALCbackendFactory, void, deinit)
+ static ALCboolean ALCnullBackendFactory_querySupport(ALCnullBackendFactory 
*self, ALCbackend_Type type);
+-static void ALCnullBackendFactory_probe(ALCnullBackendFactory *self, enum 
DevProbe type);
++static void ALCnullBackendFactory_probe(ALCnullBackendFactory *self, enum 
DevProbe type, al_string *outnames);
+ static ALCbackend* ALCnullBackendFactory_createBackend(ALCnullBackendFactory 
*self, ALCdevice *device, ALCbackend_Type type);
+ DEFINE_ALCBACKENDFACTORY_VTABLE(ALCnullBackendFactory);
+ 
+@@ -195,14 +195,13 @@ static ALCboolean ALCnullBackendFactory_querySupport(A
+     return ALC_FALSE;
+ }
+ 
+-static void ALCnullBackendFactory_probe(ALCnullBackendFactory* UNUSED(self), 
enum DevProbe type)
++static void ALCnullBackendFactory_probe(ALCnullBackendFactory* UNUSED(self), 
enum DevProbe type, al_string *outnames)
+ {
+     switch(type)
+     {
+         case ALL_DEVICE_PROBE:
+-            AppendAllDevicesList(nullDevice);
+-            break;
+         case CAPTURE_DEVICE_PROBE:
++            alstr_append_range(outnames, nullDevice, 
nullDevice+sizeof(nullDevice));
+             break;
+     }
+ }
Index: patches/patch-Alc_backends_sndio_c
===================================================================
RCS file: /cvs/ports/audio/openal/patches/patch-Alc_backends_sndio_c,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 patch-Alc_backends_sndio_c
--- patches/patch-Alc_backends_sndio_c  9 Aug 2018 20:50:47 -0000       1.1
+++ patches/patch-Alc_backends_sndio_c  8 Sep 2018 13:42:50 -0000
@@ -1,404 +1,494 @@
-$OpenBSD: patch-Alc_backends_sndio_c,v 1.1 2018/08/09 20:50:47 ratchov Exp $
+$OpenBSD$
 
 Index: Alc/backends/sndio.c
 --- Alc/backends/sndio.c.orig
 +++ Alc/backends/sndio.c
-@@ -42,16 +42,18 @@ static ALCboolean sndio_load(void)
+@@ -27,15 +27,17 @@
+ #include "alMain.h"
+ #include "alu.h"
+ #include "threads.h"
++#include "ringbuffer.h"
  
- typedef struct {
-     struct sio_hdl *sndHandle;
-+    int mode, started;
+ #include "backends/base.h"
  
-     ALvoid *mix_data;
-     ALsizei data_size;
+ #include <sndio.h>
  
-+    ll_ringbuffer_t *ring;
-+
-     volatile int killNow;
+ 
++static const ALCchar sndio_device[] = "SndIO Default";
+ 
+ 
+-typedef struct ALCsndioBackend {
++typedef struct SndioPlayback {
+     DERIVE_FROM_TYPE(ALCbackend);
+ 
+     struct sio_hdl *sndHandle;
+@@ -45,40 +47,37 @@ typedef struct ALCsndioBackend {
+ 
+     ATOMIC(int) killNow;
      althrd_t thread;
- } sndio_data;
+-} ALCsndioBackend;
++} SndioPlayback;
  
+-static int ALCsndioBackend_mixerProc(void *ptr);
++static int SndioPlayback_mixerProc(void *ptr);
+ 
+-static void ALCsndioBackend_Construct(ALCsndioBackend *self, ALCdevice 
*device);
+-static void ALCsndioBackend_Destruct(ALCsndioBackend *self);
+-static ALCenum ALCsndioBackend_open(ALCsndioBackend *self, const ALCchar 
*name);
+-static ALCboolean ALCsndioBackend_reset(ALCsndioBackend *self);
+-static ALCboolean ALCsndioBackend_start(ALCsndioBackend *self);
+-static void ALCsndioBackend_stop(ALCsndioBackend *self);
+-static DECLARE_FORWARD2(ALCsndioBackend, ALCbackend, ALCenum, captureSamples, 
void*, ALCuint)
+-static DECLARE_FORWARD(ALCsndioBackend, ALCbackend, ALCuint, availableSamples)
+-static DECLARE_FORWARD(ALCsndioBackend, ALCbackend, ClockLatency, 
getClockLatency)
+-static DECLARE_FORWARD(ALCsndioBackend, ALCbackend, void, lock)
+-static DECLARE_FORWARD(ALCsndioBackend, ALCbackend, void, unlock)
+-DECLARE_DEFAULT_ALLOCATORS(ALCsndioBackend)
++static void SndioPlayback_Construct(SndioPlayback *self, ALCdevice *device);
++static void SndioPlayback_Destruct(SndioPlayback *self);
++static ALCenum SndioPlayback_open(SndioPlayback *self, const ALCchar *name);
++static ALCboolean SndioPlayback_reset(SndioPlayback *self);
++static ALCboolean SndioPlayback_start(SndioPlayback *self);
++static void SndioPlayback_stop(SndioPlayback *self);
++static DECLARE_FORWARD2(SndioPlayback, ALCbackend, ALCenum, captureSamples, 
void*, ALCuint)
++static DECLARE_FORWARD(SndioPlayback, ALCbackend, ALCuint, availableSamples)
++static DECLARE_FORWARD(SndioPlayback, ALCbackend, ClockLatency, 
getClockLatency)
++static DECLARE_FORWARD(SndioPlayback, ALCbackend, void, lock)
++static DECLARE_FORWARD(SndioPlayback, ALCbackend, void, unlock)
++DECLARE_DEFAULT_ALLOCATORS(SndioPlayback)
+ 
+-DEFINE_ALCBACKEND_VTABLE(ALCsndioBackend);
++DEFINE_ALCBACKEND_VTABLE(SndioPlayback);
+ 
+ 
+-static const ALCchar sndio_device[] = "SndIO Default";
+-
 -
--static int sndio_proc(void *ptr)
-+static int sndio_proc_playback(void *ptr)
+-static void ALCsndioBackend_Construct(ALCsndioBackend *self, ALCdevice 
*device)
++static void SndioPlayback_Construct(SndioPlayback *self, ALCdevice *device)
  {
-     ALCdevice *device = ptr;
-     sndio_data *data = device->ExtraData;
-@@ -89,53 +91,22 @@ static int sndio_proc(void *ptr)
-     return 0;
+     ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+-    SET_VTABLE2(ALCsndioBackend, ALCbackend, self);
++    SET_VTABLE2(SndioPlayback, ALCbackend, self);
+ 
+     self->sndHandle = NULL;
+     self->mix_data = NULL;
+     ATOMIC_INIT(&self->killNow, AL_TRUE);
  }
  
--
--
--static ALCenum sndio_open_playback(ALCdevice *device, const ALCchar 
*deviceName)
-+static ALCboolean sndio_setparams(ALCdevice *device)
+-static void ALCsndioBackend_Destruct(ALCsndioBackend *self)
++static void SndioPlayback_Destruct(SndioPlayback *self)
  {
--    sndio_data *data;
--
--    if(!deviceName)
--        deviceName = sndio_device;
--    else if(strcmp(deviceName, sndio_device) != 0)
--        return ALC_INVALID_VALUE;
--
--    data = calloc(1, sizeof(*data));
--    data->killNow = 0;
--
--    data->sndHandle = sio_open(NULL, SIO_PLAY, 0);
--    if(data->sndHandle == NULL)
--    {
--        free(data);
--        ERR("Could not open device\n");
--        return ALC_INVALID_VALUE;
--    }
--
--    al_string_copy_cstr(&device->DeviceName, deviceName);
--    device->ExtraData = data;
--
--    return ALC_NO_ERROR;
--}
--
--static void sndio_close_playback(ALCdevice *device)
--{
-     sndio_data *data = device->ExtraData;
--
--    sio_close(data->sndHandle);
--    free(data);
--    device->ExtraData = NULL;
--}
--
--static ALCboolean sndio_reset_playback(ALCdevice *device)
--{
--    sndio_data *data = device->ExtraData;
-     struct sio_par par;
-+    unsigned int nch;
+     if(self->sndHandle)
+         sio_close(self->sndHandle);
+@@ -91,9 +90,9 @@ static void ALCsndioBackend_Destruct(ALCsndioBackend *
+ }
  
-     sio_initpar(&par);
  
-     par.rate = device->Frequency;
--    par.pchan = ((device->FmtChans != DevFmtMono) ? 2 : 1);
-+    nch = ((device->FmtChans != DevFmtMono) ? 2 : 1);
+-static int ALCsndioBackend_mixerProc(void *ptr)
++static int SndioPlayback_mixerProc(void *ptr)
+ {
+-    ALCsndioBackend *self = (ALCsndioBackend*)ptr;
++    SndioPlayback *self = (SndioPlayback*)ptr;
+     ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
+     ALsizei frameSize;
+     size_t wrote;
+@@ -109,9 +108,9 @@ static int ALCsndioBackend_mixerProc(void *ptr)
+         ALsizei len = self->data_size;
+         ALubyte *WritePtr = self->mix_data;
+ 
+-        ALCsndioBackend_lock(self);
++        SndioPlayback_lock(self);
+         aluMixData(device, WritePtr, len/frameSize);
+-        ALCsndioBackend_unlock(self);
++        SndioPlayback_unlock(self);
+         while(len > 0 && !ATOMIC_LOAD(&self->killNow, almemory_order_acquire))
+         {
+             wrote = sio_write(self->sndHandle, WritePtr, len);
+@@ -133,7 +132,7 @@ static int ALCsndioBackend_mixerProc(void *ptr)
+ }
  
-+    if (data->mode & SIO_PLAY)
-+      par.pchan = nch;
-+    else if (data->mode & SIO_REC)
-+      par.rchan = nch;
-+
-     switch(device->FmtType)
-     {
-         case DevFmtByte:
-@@ -182,8 +153,10 @@ static ALCboolean sndio_reset_playback(ALCdevice *devi
-         return ALC_FALSE;
-     }
  
-+    nch = (data->mode & SIO_PLAY) ? par.pchan : par.rchan;
-+
-     device->Frequency = par.rate;
--    device->FmtChans = ((par.pchan==1) ? DevFmtMono : DevFmtStereo);
-+    device->FmtChans = ((nch == 1) ? DevFmtMono : DevFmtStereo);
- 
-     if(par.bits == 8 && par.sig == 1)
-         device->FmtType = DevFmtByte;
-@@ -211,10 +184,46 @@ static ALCboolean sndio_reset_playback(ALCdevice *devi
+-static ALCenum ALCsndioBackend_open(ALCsndioBackend *self, const ALCchar 
*name)
++static ALCenum SndioPlayback_open(SndioPlayback *self, const ALCchar *name)
+ {
+     ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice;
+ 
+@@ -154,7 +153,7 @@ static ALCenum ALCsndioBackend_open(ALCsndioBackend *s
+     return ALC_NO_ERROR;
+ }
+ 
+-static ALCboolean ALCsndioBackend_reset(ALCsndioBackend *self)
++static ALCboolean SndioPlayback_reset(SndioPlayback *self)
+ {
+     ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice;
+     struct sio_par par;
+@@ -239,7 +238,7 @@ static ALCboolean ALCsndioBackend_reset(ALCsndioBacken
      return ALC_TRUE;
  }
  
-+static ALCenum sndio_open_playback(ALCdevice *device, const ALCchar 
*deviceName)
-+{
-+    sndio_data *data;
-+
-+    if(!deviceName)
-+        deviceName = sndio_device;
-+    else if(strcmp(deviceName, sndio_device) != 0)
-+        return ALC_INVALID_VALUE;
-+
-+    data = calloc(1, sizeof(*data));
-+    data->killNow = 0;
-+    data->started = 0;
-+
-+    data->mode = SIO_PLAY;
-+    data->sndHandle = sio_open(NULL, data->mode, 0);
-+    if(data->sndHandle == NULL)
-+    {
-+        free(data);
-+        ERR("Could not open device\n");
-+        return ALC_INVALID_VALUE;
-+    }
-+
-+    al_string_copy_cstr(&device->DeviceName, deviceName);
-+    device->ExtraData = data;
-+
-+    return ALC_NO_ERROR;
-+}
-+
-+static ALCboolean sndio_reset_playback(ALCdevice *device)
-+{
-+    return sndio_setparams(device);
-+}
-+
- static ALCboolean sndio_start_playback(ALCdevice *device)
+-static ALCboolean ALCsndioBackend_start(ALCsndioBackend *self)
++static ALCboolean SndioPlayback_start(SndioPlayback *self)
  {
-     sndio_data *data = device->ExtraData;
+     ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice;
  
-+    if (data->started)
-+        return ALC_TRUE;
-+
-     if(!sio_start(data->sndHandle))
-     {
-         ERR("Error starting playback\n");
-@@ -225,7 +234,7 @@ static ALCboolean sndio_start_playback(ALCdevice *devi
-     data->mix_data = calloc(1, data->data_size);
- 
-     data->killNow = 0;
--    if(althrd_create(&data->thread, sndio_proc, device) != althrd_success)
-+    if(althrd_create(&data->thread, sndio_proc_playback, device) != 
althrd_success)
-     {
-         sio_stop(data->sndHandle);
-         free(data->mix_data);
-@@ -233,6 +242,7 @@ static ALCboolean sndio_start_playback(ALCdevice *devi
-         return ALC_FALSE;
+@@ -256,7 +255,7 @@ static ALCboolean ALCsndioBackend_start(ALCsndioBacken
      }
  
-+    data->started = 1;
+     ATOMIC_STORE(&self->killNow, AL_FALSE, almemory_order_release);
+-    if(althrd_create(&self->thread, ALCsndioBackend_mixerProc, self) != 
althrd_success)
++    if(althrd_create(&self->thread, SndioPlayback_mixerProc, self) != 
althrd_success)
+     {
+         sio_stop(self->sndHandle);
+         return ALC_FALSE;
+@@ -265,7 +264,7 @@ static ALCboolean ALCsndioBackend_start(ALCsndioBacken
      return ALC_TRUE;
  }
  
-@@ -241,6 +251,9 @@ static void sndio_stop_playback(ALCdevice *device)
-     sndio_data *data = device->ExtraData;
+-static void ALCsndioBackend_stop(ALCsndioBackend *self)
++static void SndioPlayback_stop(SndioPlayback *self)
+ {
      int res;
  
-+    if (!data->started)
-+        return;
-+
-     if(data->killNow)
-         return;
+@@ -281,59 +280,318 @@ static void ALCsndioBackend_stop(ALCsndioBackend *self
+ }
  
-@@ -252,21 +265,215 @@ static void sndio_stop_playback(ALCdevice *device)
  
-     free(data->mix_data);
-     data->mix_data = NULL;
-+    data->started = 0;
+-typedef struct ALCsndioBackendFactory {
+-    DERIVE_FROM_TYPE(ALCbackendFactory);
+-} ALCsndioBackendFactory;
+-#define ALCSNDIOBACKENDFACTORY_INITIALIZER { { 
GET_VTABLE2(ALCsndioBackendFactory, ALCbackendFactory) } }
++typedef struct SndioCapture {
++    DERIVE_FROM_TYPE(ALCbackend);
+ 
+-ALCbackendFactory *ALCsndioBackendFactory_getFactory(void);
++    struct sio_hdl *sndHandle;
+ 
+-static ALCboolean ALCsndioBackendFactory_init(ALCsndioBackendFactory *self);
+-static DECLARE_FORWARD(ALCsndioBackendFactory, ALCbackendFactory, void, 
deinit)
+-static ALCboolean ALCsndioBackendFactory_querySupport(ALCsndioBackendFactory 
*self, ALCbackend_Type type);
+-static void ALCsndioBackendFactory_probe(ALCsndioBackendFactory *self, enum 
DevProbe type);
+-static ALCbackend* 
ALCsndioBackendFactory_createBackend(ALCsndioBackendFactory *self, ALCdevice 
*device, ALCbackend_Type type);
+-DEFINE_ALCBACKENDFACTORY_VTABLE(ALCsndioBackendFactory);
++    ll_ringbuffer_t *ring;
+ 
++    ATOMIC(int) killNow;
++    althrd_t thread;
++} SndioCapture;
+ 
+-ALCbackendFactory *ALCsndioBackendFactory_getFactory(void)
++static int SndioCapture_recordProc(void *ptr);
++
++static void SndioCapture_Construct(SndioCapture *self, ALCdevice *device);
++static void SndioCapture_Destruct(SndioCapture *self);
++static ALCenum SndioCapture_open(SndioCapture *self, const ALCchar *name);
++static DECLARE_FORWARD(SndioCapture, ALCbackend, ALCboolean, reset)
++static ALCboolean SndioCapture_start(SndioCapture *self);
++static void SndioCapture_stop(SndioCapture *self);
++static ALCenum SndioCapture_captureSamples(SndioCapture *self, void *buffer, 
ALCuint samples);
++static ALCuint SndioCapture_availableSamples(SndioCapture *self);
++static DECLARE_FORWARD(SndioCapture, ALCbackend, ClockLatency, 
getClockLatency)
++static DECLARE_FORWARD(SndioCapture, ALCbackend, void, lock)
++static DECLARE_FORWARD(SndioCapture, ALCbackend, void, unlock)
++DECLARE_DEFAULT_ALLOCATORS(SndioCapture)
++
++DEFINE_ALCBACKEND_VTABLE(SndioCapture);
++
++
++static void SndioCapture_Construct(SndioCapture *self, ALCdevice *device)
+ {
+-    static ALCsndioBackendFactory factory = 
ALCSNDIOBACKENDFACTORY_INITIALIZER;
+-    return STATIC_CAST(ALCbackendFactory, &factory);
++    ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
++    SET_VTABLE2(SndioCapture, ALCbackend, self);
++
++    self->sndHandle = NULL;
++    self->ring = NULL;
++    ATOMIC_INIT(&self->killNow, AL_TRUE);
  }
  
-+static void sndio_close_playback(ALCdevice *device)
++static void SndioCapture_Destruct(SndioCapture *self)
 +{
-+    sndio_data *data = device->ExtraData;
- 
-+    if (data->started)
-+        sndio_stop_playback(device);
-+    sio_close(data->sndHandle);
-+    free(data);
-+    device->ExtraData = NULL;
++    if(self->sndHandle)
++        sio_close(self->sndHandle);
++    self->sndHandle = NULL;
+ 
+-static ALCboolean ALCsndioBackendFactory_init(ALCsndioBackendFactory* 
UNUSED(self))
++    ll_ringbuffer_free(self->ring);
++    self->ring = NULL;
++
++    ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
 +}
 +
-+static int sndio_proc_capture(void *ptr)
-+{
-+    static char dummy[1024];
-+    ALCdevice *device = ptr;
-+    sndio_data *data = device->ExtraData;
-+    ll_ringbuffer_data_t vec[2], *v;
++
++static int SndioCapture_recordProc(void* ptr)
+ {
++    SndioCapture *self = (SndioCapture*)ptr;
++    ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
 +    ALsizei frameSize;
-+    size_t n, todo, len;
-+    char *buf;
 +
 +    SetRTPriority();
 +    althrd_setname(althrd_current(), RECORD_THREAD_NAME);
 +
-+    frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType);
++    frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, 
device->AmbiOrder);
 +
-+    while(!data->killNow && device->Connected)
++    while(!ATOMIC_LOAD(&self->killNow, almemory_order_acquire) &&
++          ATOMIC_LOAD(&device->Connected, almemory_order_acquire))
 +    {
-+        todo = device->UpdateSize * frameSize;
-+        ll_ringbuffer_get_write_vector(data->ring, vec);
-+
-+      if (vec[0].len + vec[1].len < device->UpdateSize) {
-+
-+          /* we're out of free space, drop next block */
-+          while (todo > 0) {
-+              len = sizeof(dummy);
-+              if (len > todo)
-+                  len = todo;
-+              n = sio_read(data->sndHandle, dummy, len);
-+              if (n == 0) {
-+                  ERR("sio_read failed\n");
-+                  ALCdevice_Lock(device);
-+                          aluHandleDisconnect(device);
-+                  ALCdevice_Unlock(device);
-+              }
-+              todo -= n;
-+          }
-+
-+      } else {
-+
-+          /* record into the ring */
-+          v = vec;
-+          buf = NULL;
-+          len = 0;
-+          while (todo > 0) {
-+              if (len == 0) {
-+                  buf = v->buf;
-+                  len = v->len * frameSize;
-+                  v++;
-+              }
-+              n = sio_read(data->sndHandle, buf, len);
-+              if (n == 0) {
-+                  ERR("sio_read failed\n");
-+                  ALCdevice_Lock(device);
-+                          aluHandleDisconnect(device);
-+                  ALCdevice_Unlock(device);
-+              }
-+              len -= n;
-+              buf += n;
-+              todo -= n;
-+          }
-+          ll_ringbuffer_write_advance(data->ring, device->UpdateSize);
++        ll_ringbuffer_data_t data[2];
++        size_t total, todo;
 +
-+      }
++        ll_ringbuffer_get_write_vector(self->ring, data);
++        todo = data[0].len + data[1].len;
++        if(todo == 0)
++        {
++            static char junk[4096];
++            sio_read(self->sndHandle, junk, minz(sizeof(junk)/frameSize, 
device->UpdateSize)*frameSize);
++            continue;
++        }
++
++        total = 0;
++        data[0].len *= frameSize;
++        data[1].len *= frameSize;
++        todo = minz(todo, device->UpdateSize) * frameSize;
++        while(total < todo)
++        {
++            size_t got;
++
++            if(!data[0].len)
++                data[0] = data[1];
++
++            got = sio_read(self->sndHandle, data[0].buf, minz(todo-total, 
data[0].len));
++            if(!got)
++            {
++                SndioCapture_lock(self);
++                aluHandleDisconnect(device, "Failed to read capture samples");
++                SndioCapture_unlock(self);
++                break;
++            }
++
++            data[0].buf += got;
++            data[0].len -= got;
++            total += got;
++        }
++        ll_ringbuffer_write_advance(self->ring, total / frameSize);
 +    }
 +
 +    return 0;
 +}
 +
-+static ALCenum sndio_open_capture(ALCdevice *device, const ALCchar 
*deviceName)
++
++static ALCenum SndioCapture_open(SndioCapture *self, const ALCchar *name)
 +{
-+    sndio_data *data;
++    ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice;
++    struct sio_par par;
 +
-+    if(!deviceName)
-+        deviceName = sndio_device;
-+    else if(strcmp(deviceName, sndio_device) != 0)
++    if(!name)
++        name = sndio_device;
++    else if(strcmp(name, sndio_device) != 0)
 +        return ALC_INVALID_VALUE;
 +
-+    data = calloc(1, sizeof(*data));
-+    data->killNow = 0;
-+    data->started = 0;
-+    data->ring = NULL;
-+    data->mode = SIO_REC;
-+    data->sndHandle = sio_open(NULL, data->mode, 0);
-+    if(data->sndHandle == NULL)
++    self->sndHandle = sio_open(NULL, SIO_REC, 0);
++    if(self->sndHandle == NULL)
 +    {
-+        free(data);
 +        ERR("Could not open device\n");
 +        return ALC_INVALID_VALUE;
 +    }
 +
-+    al_string_copy_cstr(&device->DeviceName, deviceName);
-+    device->ExtraData = data;
++    sio_initpar(&par);
 +
-+    if (!sndio_setparams(device)) {
-+      sio_close(data->sndHandle);
-+        free(data);
-+        return ALC_INVALID_VALUE;
++    switch(device->FmtType)
++    {
++        case DevFmtByte:
++            par.bps = 1;
++            par.sig = 1;
++            break;
++        case DevFmtUByte:
++            par.bps = 1;
++            par.sig = 0;
++            break;
++        case DevFmtShort:
++            par.bps = 2;
++            par.sig = 1;
++            break;
++        case DevFmtUShort:
++            par.bps = 2;
++            par.sig = 0;
++            break;
++        case DevFmtInt:
++            par.bps = 4;
++            par.sig = 1;
++            break;
++        case DevFmtUInt:
++            par.bps = 4;
++            par.sig = 0;
++            break;
++        case DevFmtFloat:
++            ERR("%s capture samples not supported\n", 
DevFmtTypeString(device->FmtType));
++            return ALC_INVALID_VALUE;
 +    }
++    par.bits = par.bps * 8;
++    par.le = SIO_LE_NATIVE;
++    par.msb = SIO_LE_NATIVE ? 0 : 1;
++    par.rchan = ChannelsFromDevFmt(device->FmtChans, device->AmbiOrder);
++    par.rate = device->Frequency;
++
++    par.appbufsz = maxu(device->UpdateSize*device->NumUpdates, 
(device->Frequency+9)/10);
++    par.round = clampu(par.appbufsz/device->NumUpdates, 
(device->Frequency+99)/100,
++                       (device->Frequency+19)/20);
 +
-+    return ALC_NO_ERROR;
-+}
++    device->UpdateSize = par.round;
++    device->NumUpdates = maxu(par.appbufsz/par.round, 1);
 +
-+static void sndio_start_capture(ALCdevice *device)
-+{
-+    sndio_data *data = device->ExtraData;
-+    int frameSize;
++    if(!sio_setpar(self->sndHandle, &par) || !sio_getpar(self->sndHandle, 
&par))
++    {
++        ERR("Failed to set device parameters\n");
++        return ALC_INVALID_VALUE;
++    }
 +
-+    if (data->started)
-+        return;
++    if(par.bits != par.bps*8)
++    {
++        ERR("Padded samples not supported (%u of %u bits)\n", par.bits, 
par.bps*8);
++        return ALC_INVALID_VALUE;
++    }
 +
-+    if(!sio_start(data->sndHandle))
++    if(!((device->FmtType == DevFmtByte && par.bits == 8 && par.sig != 0) ||
++         (device->FmtType == DevFmtUByte && par.bits == 8 && par.sig == 0) ||
++         (device->FmtType == DevFmtShort && par.bits == 16 && par.sig != 0) ||
++         (device->FmtType == DevFmtUShort && par.bits == 16 && par.sig == 0) 
||
++         (device->FmtType == DevFmtInt && par.bits == 32 && par.sig != 0) ||
++         (device->FmtType == DevFmtUInt && par.bits == 32 && par.sig == 0)) ||
++       ChannelsFromDevFmt(device->FmtChans, device->AmbiOrder) != 
(ALsizei)par.rchan ||
++       device->Frequency != par.rate)
 +    {
-+        ERR("Error starting capture\n");
-+        return;
++        ERR("Failed to set format %s %s %uhz, got %c%u %u-channel %uhz 
instead\n",
++            DevFmtTypeString(device->FmtType), 
DevFmtChannelsString(device->FmtChans),
++            device->Frequency, par.sig?'s':'u', par.bits, par.rchan, 
par.rate);
++        return ALC_INVALID_VALUE;
 +    }
 +
-+    frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType);
-+    data->ring = ll_ringbuffer_create(device->UpdateSize * 
device->NumUpdates, frameSize);
-+    if (!data->ring) {
-+        sio_stop(data->sndHandle);
-+        return;
++    self->ring = ll_ringbuffer_create(device->UpdateSize*device->NumUpdates, 
par.bps*par.rchan, 0);
++    if(!self->ring)
++    {
++        ERR("Failed to allocate %u-byte ringbuffer\n",
++            device->UpdateSize*device->NumUpdates*par.bps*par.rchan);
++        return ALC_OUT_OF_MEMORY;
++    }
++
++    SetDefaultChannelOrder(device);
++
++    alstr_copy_cstr(&device->DeviceName, name);
++
++    return ALC_NO_ERROR;
++}
++
++static ALCboolean SndioCapture_start(SndioCapture *self)
++{
++    if(!sio_start(self->sndHandle))
++    {
++        ERR("Error starting playback\n");
++        return ALC_FALSE;
 +    }
 +
-+    data->killNow = 0;
-+    if(althrd_create(&data->thread, sndio_proc_capture, device) != 
althrd_success)
++    ATOMIC_STORE(&self->killNow, AL_FALSE, almemory_order_release);
++    if(althrd_create(&self->thread, SndioCapture_recordProc, self) != 
althrd_success)
 +    {
-+        ll_ringbuffer_free(data->ring);
-+        sio_stop(data->sndHandle);
-+        return;
++        sio_stop(self->sndHandle);
++        return ALC_FALSE;
 +    }
 +
-+    data->started = 1;
-+    return;
++    return ALC_TRUE;
 +}
 +
-+static void sndio_stop_capture(ALCdevice *device)
++static void SndioCapture_stop(SndioCapture *self)
 +{
-+    sndio_data *data = device->ExtraData;
 +    int res;
 +
-+    if (!data->started)
-+        return;
-+
-+    if(data->killNow)
++    if(ATOMIC_EXCHANGE(&self->killNow, AL_TRUE, almemory_order_acq_rel))
 +        return;
++    althrd_join(self->thread, &res);
 +
-+    data->killNow = 1;
-+    althrd_join(data->thread, &res);
-+
-+    if(!sio_stop(data->sndHandle))
++    if(!sio_stop(self->sndHandle))
 +        ERR("Error stopping device\n");
-+
-+    ll_ringbuffer_free(data->ring);
-+    data->ring = NULL;
-+    data->started = 0;
 +}
 +
-+static ALCenum sndio_captureSamples(ALCdevice *device, ALCvoid *buffer, 
ALCuint samples)
++static ALCenum SndioCapture_captureSamples(SndioCapture *self, void *buffer, 
ALCuint samples)
 +{
-+    sndio_data *data = device->ExtraData;
-+
-+    ll_ringbuffer_read(data->ring, buffer, samples);
++    ll_ringbuffer_read(self->ring, buffer, samples);
 +    return ALC_NO_ERROR;
 +}
 +
-+static ALCuint sndio_availableSamples(ALCdevice *device)
++static ALCuint SndioCapture_availableSamples(SndioCapture *self)
 +{
-+    sndio_data *data = device->ExtraData;
-+
-+    return ll_ringbuffer_read_space(data->ring);
++    return ll_ringbuffer_read_space(self->ring);
 +}
 +
-+static void sndio_close_capture(ALCdevice *device)
-+{
-+    sndio_data *data = device->ExtraData;
 +
-+    if (data->started)
-+        sndio_stop_capture(device);
-+    sio_close(data->sndHandle);
-+    free(data);
-+    device->ExtraData = NULL;
++typedef struct SndioBackendFactory {
++    DERIVE_FROM_TYPE(ALCbackendFactory);
++} SndioBackendFactory;
++#define SNDIOBACKENDFACTORY_INITIALIZER { { GET_VTABLE2(SndioBackendFactory, 
ALCbackendFactory) } }
++
++ALCbackendFactory *SndioBackendFactory_getFactory(void);
++
++static ALCboolean SndioBackendFactory_init(SndioBackendFactory *self);
++static DECLARE_FORWARD(SndioBackendFactory, ALCbackendFactory, void, deinit)
++static ALCboolean SndioBackendFactory_querySupport(SndioBackendFactory *self, 
ALCbackend_Type type);
++static void SndioBackendFactory_probe(SndioBackendFactory *self, enum 
DevProbe type, al_string *outnames);
++static ALCbackend* SndioBackendFactory_createBackend(SndioBackendFactory 
*self, ALCdevice *device, ALCbackend_Type type);
++DEFINE_ALCBACKENDFACTORY_VTABLE(SndioBackendFactory);
++
++ALCbackendFactory *SndioBackendFactory_getFactory(void)
++{
++    static SndioBackendFactory factory = SNDIOBACKENDFACTORY_INITIALIZER;
++    return STATIC_CAST(ALCbackendFactory, &factory);
 +}
 +
- static const BackendFuncs sndio_funcs = {
-     sndio_open_playback,
-     sndio_close_playback,
-     sndio_reset_playback,
-     sndio_start_playback,
-     sndio_stop_playback,
--    NULL,
--    NULL,
--    NULL,
--    NULL,
--    NULL,
--    NULL
-+    sndio_open_capture,
-+    sndio_close_capture,
-+    sndio_start_capture,
-+    sndio_stop_capture,
-+    sndio_captureSamples,
-+    sndio_availableSamples
- };
- 
- ALCboolean alc_sndio_init(BackendFuncs *func_list)
-@@ -289,6 +496,7 @@ void alc_sndio_probe(enum DevProbe type)
-             AppendAllDevicesList(sndio_device);
-             break;
++static ALCboolean SndioBackendFactory_init(SndioBackendFactory* UNUSED(self))
++{
+     /* No dynamic loading */
+     return ALC_TRUE;
+ }
+ 
+-static ALCboolean ALCsndioBackendFactory_querySupport(ALCsndioBackendFactory* 
UNUSED(self), ALCbackend_Type type)
++static ALCboolean SndioBackendFactory_querySupport(SndioBackendFactory* 
UNUSED(self), ALCbackend_Type type)
+ {
+-    if(type == ALCbackend_Playback)
++    if(type == ALCbackend_Playback || type == ALCbackend_Capture)
+         return ALC_TRUE;
+     return ALC_FALSE;
+ }
+ 
+-static void ALCsndioBackendFactory_probe(ALCsndioBackendFactory* 
UNUSED(self), enum DevProbe type)
++static void SndioBackendFactory_probe(SndioBackendFactory* UNUSED(self), enum 
DevProbe type, al_string *outnames)
+ {
+     switch(type)
+     {
+         case ALL_DEVICE_PROBE:
+-            AppendAllDevicesList(sndio_device);
+-            break;
          case CAPTURE_DEVICE_PROBE:
-+            AppendCaptureDeviceList(sndio_device);
++            alstr_append_range(outnames, sndio_device, 
sndio_device+sizeof(sndio_device));
              break;
      }
  }
+ 
+-static ALCbackend* 
ALCsndioBackendFactory_createBackend(ALCsndioBackendFactory* UNUSED(self), 
ALCdevice *device, ALCbackend_Type type)
++static ALCbackend* SndioBackendFactory_createBackend(SndioBackendFactory* 
UNUSED(self), ALCdevice *device, ALCbackend_Type type)
+ {
+     if(type == ALCbackend_Playback)
+     {
+-        ALCsndioBackend *backend;
+-        NEW_OBJ(backend, ALCsndioBackend)(device);
++        SndioPlayback *backend;
++        NEW_OBJ(backend, SndioPlayback)(device);
++        if(!backend) return NULL;
++        return STATIC_CAST(ALCbackend, backend);
++    }
++    if(type == ALCbackend_Capture)
++    {
++        SndioCapture *backend;
++        NEW_OBJ(backend, SndioCapture)(device);
+         if(!backend) return NULL;
+         return STATIC_CAST(ALCbackend, backend);
+     }
Index: patches/patch-CMakeLists_txt
===================================================================
RCS file: patches/patch-CMakeLists_txt
diff -N patches/patch-CMakeLists_txt
--- patches/patch-CMakeLists_txt        15 Nov 2017 13:02:42 -0000      1.7
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,34 +0,0 @@
-$OpenBSD: patch-CMakeLists_txt,v 1.7 2017/11/15 13:02:42 sthen Exp $
-Index: CMakeLists.txt
---- CMakeLists.txt.orig
-+++ CMakeLists.txt
-@@ -843,17 +843,14 @@ ENDIF()
- 
- # Check SndIO backend
- OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
--FIND_PACKAGE(SoundIO)
--IF(SOUNDIO_FOUND)
-+FIND_LIBRARY(SNDIOLIB NAMES sndio)
-+IF(NOT SNDIOLIB-NOTFOUND)
-     OPTION(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
-     IF(ALSOFT_BACKEND_SNDIO)
-         SET(HAVE_SNDIO 1)
-         SET(BACKENDS  "${BACKENDS} SndIO (linked),")
-         SET(ALC_OBJS  ${ALC_OBJS} Alc/backends/sndio.c)
--        SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
--        IF(CMAKE_VERSION VERSION_LESS "2.8.8")
--            INCLUDE_DIRECTORIES(${SOUNDIO_INCLUDE_DIRS})
--        ENDIF()
-+        SET(EXTRA_LIBS ${SNDIOLIB} ${EXTRA_LIBS})
-     ENDIF()
- ENDIF()
- IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
-@@ -1207,7 +1204,7 @@ ENDIF()
- # Install alsoft.conf configuration file
- IF(ALSOFT_CONFIG)
-     INSTALL(FILES alsoftrc.sample
--            DESTINATION ${SHARE_INSTALL_DIR}/openal
-+            DESTINATION ${SHARE_INSTALL_DIR}/examples/openal
-     )
-     MESSAGE(STATUS "Installing sample configuration")
-     MESSAGE(STATUS "")
Index: patches/patch-OpenAL32_Include_alMain_h
===================================================================
RCS file: patches/patch-OpenAL32_Include_alMain_h
diff -N patches/patch-OpenAL32_Include_alMain_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-OpenAL32_Include_alMain_h     8 Sep 2018 13:42:50 -0000
@@ -0,0 +1,15 @@
+$OpenBSD$
+
+Index: OpenAL32/Include/alMain.h
+--- OpenAL32/Include/alMain.h.orig
++++ OpenAL32/Include/alMain.h
+@@ -856,9 +856,6 @@ void ALCcontext_ProcessUpdates(ALCcontext *context);
+ 
+ void AllocateVoices(ALCcontext *context, ALsizei num_voices, ALsizei 
old_sends);
+ 
+-void AppendAllDevicesList(const ALCchar *name);
+-void AppendCaptureDeviceList(const ALCchar *name);
+-
+ 
+ extern ALint RTPrioLevel;
+ void SetRTPriority(void);
Index: patches/patch-OpenAL32_alBuffer_c
===================================================================
RCS file: /cvs/ports/audio/openal/patches/patch-OpenAL32_alBuffer_c,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 patch-OpenAL32_alBuffer_c
--- patches/patch-OpenAL32_alBuffer_c   15 Nov 2017 13:02:42 -0000      1.2
+++ patches/patch-OpenAL32_alBuffer_c   8 Sep 2018 13:42:50 -0000
@@ -1,10 +1,11 @@
-$OpenBSD: patch-OpenAL32_alBuffer_c,v 1.2 2017/11/15 13:02:42 sthen Exp $
+$OpenBSD$
+
 Index: OpenAL32/alBuffer.c
 --- OpenAL32/alBuffer.c.orig
 +++ OpenAL32/alBuffer.c
-@@ -1209,7 +1209,7 @@ static ALboolean DecomposeFormat(ALenum format, enum F
-         { AL_FORMAT_BFORMAT3D_16,      FmtBFormat3D, FmtShort },
-         { AL_FORMAT_BFORMAT3D_FLOAT32, FmtBFormat3D, FmtFloat },
+@@ -1118,7 +1118,7 @@ static ALboolean DecomposeUserFormat(ALenum format, en
+         { AL_FORMAT_BFORMAT3D_FLOAT32, UserFmtBFormat3D, UserFmtFloat },
+         { AL_FORMAT_BFORMAT3D_MULAW,   UserFmtBFormat3D, UserFmtMulaw },
      };
 -    ALuint i;
 +    volatile ALuint i;
Index: patches/patch-utils_makehrtf_c
===================================================================
RCS file: patches/patch-utils_makehrtf_c
diff -N patches/patch-utils_makehrtf_c
--- patches/patch-utils_makehrtf_c      15 Nov 2017 13:02:42 -0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,13 +0,0 @@
-$OpenBSD: patch-utils_makehrtf_c,v 1.3 2017/11/15 13:02:42 sthen Exp $
-Index: utils/makehrtf.c
---- utils/makehrtf.c.orig
-+++ utils/makehrtf.c
-@@ -2070,7 +2070,7 @@ static int StoreMhr (const HrirDataT * hData, const ch
-   step = hData -> mIrSize;
-   end = hData -> mIrCount * step;
-   n = hData -> mIrPoints;
--  srand (0x31DF840C);
-+  srand_deterministic (0x31DF840C);
-   for (j = 0; j < end; j += step) {
-       hpHist = 0;
-       for (i = 0; i < n; i ++) {
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/audio/openal/pkg/PLIST,v
retrieving revision 1.9
diff -u -p -u -p -r1.9 PLIST
--- pkg/PLIST   15 Nov 2017 13:02:42 -0000      1.9
+++ pkg/PLIST   8 Sep 2018 13:42:50 -0000
@@ -1,6 +1,5 @@
 @comment $OpenBSD: PLIST,v 1.9 2017/11/15 13:02:42 sthen Exp $
 @bin bin/altonegen
-@bin bin/bsincgen
 @bin bin/makehrtf
 @bin bin/openal-info
 include/AL/
@@ -10,13 +9,24 @@ include/AL/alext.h
 include/AL/efx-creative.h
 include/AL/efx-presets.h
 include/AL/efx.h
+lib/cmake/
+lib/cmake/OpenAL/
+lib/cmake/OpenAL/OpenALConfig-openbsd.cmake
+lib/cmake/OpenAL/OpenALConfig.cmake
 @lib lib/libopenal.so.${LIBopenal_VERSION}
 lib/pkgconfig/openal.pc
-share/examples/openal/
+share/openal/
 @sample ${SYSCONFDIR}/openal/
-share/examples/openal/alsoftrc.sample
+share/openal/alsoftrc.sample
 @sample ${SYSCONFDIR}/openal/alsoft.conf
-share/openal/
 share/openal/hrtf/
 share/openal/hrtf/default-44100.mhr
 share/openal/hrtf/default-48000.mhr
+share/openal/presets/
+share/openal/presets/3D7.1.ambdec
+share/openal/presets/hexagon.ambdec
+share/openal/presets/itu5.1-nocenter.ambdec
+share/openal/presets/itu5.1.ambdec
+share/openal/presets/presets.txt
+share/openal/presets/rectangle.ambdec
+share/openal/presets/square.ambdec

Reply via email to