This diff adds the missing sndio backend to sidplay. Tested on
amd64

OKs?

Index: Makefile
===================================================================
RCS file: /cvs/ports/audio/sidplay/Makefile,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 Makefile
--- Makefile    10 Mar 2013 22:55:05 -0000      1.10
+++ Makefile    24 Oct 2014 14:01:54 -0000
@@ -4,7 +4,7 @@ COMMENT=        Commodore 64 music player and S
 
 DISTNAME=      sidplay-base-1.0.9
 PKGNAME=       ${DISTNAME:S/-base//}
-REVISION=      0
+REVISION=      1
 CATEGORIES=    audio
 
 MAINTAINER=    Christian Weisgerber <na...@openbsd.org>
@@ -12,7 +12,7 @@ MAINTAINER=   Christian Weisgerber <naddy@
 # GPL
 PERMIT_PACKAGE_CDROM=  Yes
 
-WANTLIB=               c m ossaudio sidplay>=1 stdc++
+WANTLIB=               c m sidplay>=1 sndio stdc++
 
 MASTER_SITES=  ${MASTER_SITE_OPENBSD}
 EXTRACT_SUFX=  .tgz
@@ -22,5 +22,10 @@ LIB_DEPENDS= audio/libsidplay
 CONFIGURE_STYLE= gnu
 CONFIGURE_ARGS=        --with-sidplay-includes=${LOCALBASE}/include \
                --with-sidplay-library=${LOCALBASE}/lib
+
+post-extract:
+       @mkdir -p ${WRKSRC}/audio/sndio
+       @cp ${FILESDIR}/audiodrv.cpp ${WRKSRC}/audio/sndio
+       @cp ${FILESDIR}/audiodrv.h ${WRKSRC}/audio/sndio
 
 .include <bsd.port.mk>
Index: files/audiodrv.cpp
===================================================================
RCS file: files/audiodrv.cpp
diff -N files/audiodrv.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ files/audiodrv.cpp  24 Oct 2014 14:01:54 -0000
@@ -0,0 +1,100 @@
+// --------------------------------------------------------------------------
+// ``sndio'' specific audio driver interface.
+// --------------------------------------------------------------------------
+
+#include "audiodrv.h"
+
+audioDriver::audioDriver()
+{
+       hdl = NULL;
+}
+
+bool audioDriver::IsThere()
+{
+       return 1;
+}
+
+bool audioDriver::Open(udword inFreq, int inPrecision, int inChannels,
+    int inFragments, int inFragBase)
+{
+       sio_par askpar, retpar;
+
+       hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0);
+       if (hdl == NULL)
+       {
+               errorString = "ERROR: Could not open audio device.";
+               return false;
+       }
+
+       frequency = inFreq;
+       channels = inChannels;
+       precision = inPrecision;
+       encoding = retpar.sig ? SIDEMU_SIGNED_PCM :  SIDEMU_UNSIGNED_PCM;
+
+       sio_initpar(&askpar);
+       if (precision == SIDEMU_8BIT)
+       {
+               askpar.le = SIO_LE_NATIVE;
+               askpar.bits = 16;
+               askpar.sig = 1;
+       } else {
+               askpar.bits = 8;
+               askpar.sig = 0;
+       }
+       askpar.pchan = inChannels == SIDEMU_MONO ? 1 : 2;
+       askpar.rate = inFreq;
+       askpar.round = 1 << inFragBase;
+       askpar.appbufsz = inFragments * askpar.round;
+
+       if (!sio_setpar(hdl, &askpar) || !sio_getpar(hdl, &retpar))
+       {
+               errorString = "ERROR: Could not set audio parameters.";
+               goto bad_close;
+       }
+
+       if (retpar.bits != askpar.bits || retpar.sig != askpar.sig ||
+           (retpar.bits > 8 && retpar.le != askpar.le) ||
+           retpar.pchan != askpar.pchan || retpar.rate != askpar.rate)
+       {
+               errorString = "ERROR: Unsupported audio parameters.";
+               goto bad_close;
+       }
+       blockSize = retpar.round;
+
+       if (!sio_start(hdl))
+       {
+               errorString = "ERROR: Could not start audio device.";
+               goto bad_close;
+       }
+       return true;
+
+bad_close:
+       sio_close(hdl);
+       hdl = NULL;
+       return false;
+}
+
+void audioDriver::Close()
+{
+       if (hdl != NULL)
+       {
+               sio_close(hdl);
+               hdl = NULL;
+       }
+}
+
+void audioDriver::Play(ubyte* pBuffer, int bufferSize)
+{
+       if (hdl != NULL)
+               sio_write(hdl, pBuffer, bufferSize);
+}
+
+bool audioDriver::Reset()
+{
+       if (hdl != NULL) {
+               sio_stop(hdl);
+               sio_start(hdl);
+               return true;
+       }
+       return false;
+}
Index: files/audiodrv.h
===================================================================
RCS file: files/audiodrv.h
diff -N files/audiodrv.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ files/audiodrv.h    24 Oct 2014 14:01:54 -0000
@@ -0,0 +1,91 @@
+// --------------------------------------------------------------------------
+// ``sndio'' specific audio driver interface.
+// --------------------------------------------------------------------------
+
+#ifndef AUDIODRV_H
+#define AUDIODRV_H
+
+
+#include <sndio.h>
+#include <stdio.h>
+#include <sidplay/emucfg.h>
+
+class audioDriver
+{
+       
+ public:  // --------------------------------------------------------- public
+
+    audioDriver();
+  
+       bool IsThere();
+       
+       bool Open(udword freq, int precision, int channels,
+                         int fragments, int fragBase);
+       
+       void Close();
+       
+       void Play(ubyte* buffer, int bufferSize);
+       
+       bool Reset();
+       
+       int GetAudioHandle()
+       {
+               return -1;
+       }
+       
+       udword GetFrequency()
+       { 
+               return frequency;
+       }
+       
+       int GetChannels()
+       {
+               return channels;
+       }
+       
+       int GetSamplePrecision()
+       {
+               return precision;
+       }
+       
+       int GetSampleEncoding()
+       {
+               return encoding;
+       }
+       
+       int GetBlockSize()
+       {
+               return blockSize;
+       }
+       
+       int GetFragments()
+       {
+               return 1;
+       }
+       
+       int GetFragSizeBase()
+       {
+               return 0;
+       }
+       
+       const char* GetErrorString()
+       {
+               return errorString;
+       }
+                       
+ private:  // ------------------------------------------------------- private
+       struct sio_hdl *hdl;
+
+       const char* errorString;
+       int blockSize;
+
+       udword frequency;
+
+       // These are constants/enums from ``libsidplay/include/emucfg.h''.
+       int encoding;
+       int precision;
+       int channels;
+};
+
+
+#endif  // AUDIODRV_H
Index: patches/patch-configure
===================================================================
RCS file: patches/patch-configure
diff -N patches/patch-configure
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-configure     24 Oct 2014 14:01:54 -0000
@@ -0,0 +1,18 @@
+$OpenBSD$
+--- configure.orig     Sat Sep 28 20:44:14 2002
++++ configure  Fri Oct 24 15:49:10 2014
+@@ -1590,11 +1590,9 @@ EOF
+ #define HAVE_OPENBSD 1
+ EOF
+ 
+-    $CP audio/oss/* .
+-    echo "$ac_t""oss" 1>&6
+-    if test -z "$LIBAUDIO"; then
+-      { echo "configure: error: libossaudio required, but not found." 1>&2; 
exit 1; };
+-    fi
++    $CP audio/sndio/* .
++    LIBAUDIO=-lsndio
++    echo "$ac_t""sndio" 1>&6
+        ;;
+ esac
+ 
Index: patches/patch-configure_in
===================================================================
RCS file: patches/patch-configure_in
diff -N patches/patch-configure_in
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-configure_in  24 Oct 2014 14:01:54 -0000
@@ -0,0 +1,18 @@
+$OpenBSD$
+--- configure.in.orig  Sat Sep 28 20:44:02 2002
++++ configure.in       Fri Oct 24 15:57:45 2014
+@@ -64,11 +64,9 @@ case "$host" in 
+     fi
+        ;;
+   *openbsd*) AC_DEFINE(HAVE_OPENBSD,1)
+-    $CP audio/oss/* .
+-    AC_MSG_RESULT(oss)
+-    if test -z "$LIBAUDIO"; then
+-      AC_MSG_ERROR([libossaudio required, but not found.]);
+-    fi
++    $CP audio/sndio/* .
++    LIBAUDIO=-lsndio
++    AC_MSG_RESULT(sndio)
+        ;;
+ esac
+ 

Reply via email to