SecBSD's official ports repository

This commit is contained in:
purplerain 2023-08-16 22:26:55 +00:00
commit 2c0afcbbf3
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
64331 changed files with 5339189 additions and 0 deletions

View file

@ -0,0 +1,40 @@
--- src/js/jsBSD.cxx.orig Tue Mar 11 03:06:21 2008
+++ src/js/jsBSD.cxx Thu Mar 12 21:33:03 2009
@@ -50,8 +50,10 @@
#if defined(__FreeBSD__)
# include <sys/joystick.h>
#else
+#if defined(__i386__)
# include <machine/joystick.h> // For analog joysticks
#endif
+#endif
#ifdef HAVE_USB_JS
#if defined(__NetBSD__)
#ifdef HAVE_USBHID_H
@@ -85,7 +87,9 @@ struct os_specific_s {
int fd;
int is_analog;
// The following structure members are specific to analog joysticks
+#if defined(__i386__)
struct joystick ajs;
+#endif
#ifdef HAVE_USB_JS
// The following structure members are specific to USB joysticks
struct hid_item *hids;
@@ -437,7 +441,7 @@ void jsJoystick::rawRead ( int *buttons, float *axes )
return ;
}
-
+#if defined(__i386__)
if ( os->is_analog )
{
int status = ::read ( os->fd, &os->ajs, sizeof(os->ajs) );
@@ -462,6 +466,7 @@ void jsJoystick::rawRead ( int *buttons, float *axes )
return;
}
+#endif
#ifdef HAVE_USB_JS
while ((len = ::read(os->fd, os->hid_data_buf, os->hid_dlen)) == os->hid_dlen)

View file

@ -0,0 +1,150 @@
--- src/sl/slDSP.cxx.orig Mon Mar 10 19:06:24 2008
+++ src/sl/slDSP.cxx Wed Dec 16 13:17:24 2009
@@ -413,7 +413,7 @@ void slDSP::stop ()
/* NetBSD/OpenBSD 2.3 this should be very close to SUN Audio */
/* ------------------------------------------------------------ */
-#elif (defined(UL_BSD) && !defined(__FreeBSD__)) || defined(UL_SOLARIS)
+#elif (defined(UL_BSD) && !defined(SL_USING_SNDIO) && !defined(__FreeBSD__)) || defined(UL_SOLARIS)
void slDSP::open ( const char *device, int _rate, int _stereo, int _bps )
{
@@ -1083,3 +1083,138 @@ float slDSP::secondsUsed ()
#endif
+#ifdef SL_USING_SNDIO
+
+#include <poll.h>
+
+static long long realpos, playpos;
+
+void
+movecb(void *v, int delta)
+{
+ realpos += delta;
+}
+
+void
+slDSP::open(const char *device, int _rate, int _stereo, int _bps )
+{
+ error = SL_FALSE;
+
+ if (!strncmp(device, "default", FILENAME_MAX))
+ hdl = sio_open(NULL, SIO_PLAY, 0);
+ else
+ hdl = sio_open(device, SIO_PLAY, 0);
+ if (hdl == NULL) {
+ error = SL_TRUE;
+ fprintf(stderr, "slDSP: open\n");
+ return;
+ }
+
+ sio_initpar(&par);
+ par.pchan = _stereo ? 2 : 1;
+ par.bits = _bps;
+ par.rate = _rate;
+ par.appbufsz = 4096;
+
+ realpos = playpos = 0;
+ sio_onmove(hdl, movecb, NULL);
+
+ if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par) ||
+ !sio_start(hdl)) {
+ fprintf(stderr, "slDSP: sndio params\n");
+ error = SL_TRUE;
+ return;
+ }
+
+ bps = par.bits;
+ rate = par.rate;
+ stereo = par.pchan == 2 ? SL_TRUE : SL_FALSE;
+}
+
+void
+slDSP::close()
+{
+ if (hdl != NULL)
+ sio_close(hdl);
+ hdl = NULL;
+}
+
+int
+slDSP::getDriverBufferSize()
+{
+ if (error)
+ return 0;
+
+ return par.round * par.bps * par.pchan;
+}
+
+void
+slDSP::getBufferInfo()
+{
+ struct pollfd pfd;
+ nfds_t nfd;
+
+ if (error)
+ return;
+
+ /* updates counters */
+ nfd = sio_pollfd(hdl, &pfd, POLLOUT);
+ poll(&pfd, nfd, 0);
+ sio_revents(hdl, &pfd);
+}
+
+void
+slDSP::write(void *buffer, size_t length)
+{
+ int ret, todo, pos;
+
+ if (error || (int)length <= 0)
+ return;
+
+ pos = 0;
+ todo = length;
+ while (todo > 0) {
+ ret = sio_write(hdl, (char *)buffer + pos, todo);
+ pos += ret;
+ todo -= ret;
+ }
+ playpos += length / par.bps / par.pchan;
+}
+
+float
+slDSP::secondsRemaining()
+{
+ if (error)
+ return 0.0f;
+
+ getBufferInfo();
+
+ /* wtf? tuxkart won't play sounds if less ??? */
+ return 0.1f;
+ return((float)(par.appbufsz - (playpos - realpos)) / par.rate);
+}
+
+float
+slDSP::secondsUsed()
+{
+ if (error)
+ return 0.0f ;
+
+ getBufferInfo();
+
+ if (realpos > playpos)
+ return 0.0f;
+
+ return((float)(playpos - realpos) / par.rate);
+}
+
+void
+slDSP::sync()
+{
+}
+
+void slDSP::stop()
+{
+}
+
+#endif

View file

@ -0,0 +1,29 @@
--- src/sl/slPortability.h.orig Mon Mar 10 19:06:24 2008
+++ src/sl/slPortability.h Wed Dec 16 01:43:22 2009
@@ -51,7 +51,7 @@
#include <limits.h>
#include <math.h>
-#if (defined(UL_LINUX) || defined(UL_BSD)) && !defined(__NetBSD__)
+#if (defined(UL_LINUX) || defined(UL_BSD)) && !defined(__NetBSD__) && !defined(__OpenBSD__)
#define SL_USING_OSS_AUDIO 1
#endif
@@ -75,9 +75,14 @@
#endif
#ifdef UL_BSD
-#ifndef __FreeBSD__
-# include <sys/audioio.h>
-#endif
+# ifdef __OpenBSD__
+# define SL_USING_SNDIO
+# include <sndio.h>
+# else
+# ifndef __FreeBSD__
+# include <sys/audioio.h>
+# endif
+# endif
#endif
/* Tom */

View file

@ -0,0 +1,30 @@
--- src/sl/sl.h.orig Mon Mar 10 19:06:24 2008
+++ src/sl/sl.h Wed Dec 16 02:01:05 2009
@@ -32,6 +32,8 @@
#define SLDSP_DEFAULT_DEVICE "/dev/dsp"
#elif defined(UL_WIN32)
#define SLDSP_DEFAULT_DEVICE "dsp"
+#elif defined(SL_USING_SNDIO)
+#define SLDSP_DEFAULT_DEVICE "default"
#elif defined(UL_BSD)
#define SLDSP_DEFAULT_DEVICE "/dev/audio"
#elif defined(UL_IRIX)
@@ -78,6 +80,9 @@ class slDSP (private)
#if defined(SL_USING_OSS_AUDIO)
audio_buf_info buff_info ;
+#elif defined(SL_USING_SNDIO)
+ struct sio_hdl *hdl;
+ struct sio_par par;
#elif defined(UL_BSD)
audio_info_t ainfo; // ioctl structure
audio_offset_t audio_offset; // offset in audiostream
@@ -120,7 +125,7 @@ class slDSP (private)
#endif
-#if !defined(UL_WIN32) && !defined(UL_MACINTOSH) && !defined(UL_MAC_OSX)
+#if !defined(UL_WIN32) && !defined(UL_MACINTOSH) && !defined(UL_MAC_OSX) && !defined(SL_USING_SNDIO)
int ioctl ( int cmd, int param = 0 )
{
if ( error ) return param ;