make sidplay use sndio

ok sthen
This commit is contained in:
ratchov 2014-10-26 15:24:09 +00:00
parent 59185197a0
commit 0c65a92fd5
5 changed files with 235 additions and 3 deletions

View File

@ -1,10 +1,10 @@
# $OpenBSD: Makefile,v 1.10 2013/03/10 22:55:05 espie Exp $
# $OpenBSD: Makefile,v 1.11 2014/10/26 15:24:09 ratchov Exp $
COMMENT= Commodore 64 music player and SID chip emulator
DISTNAME= sidplay-base-1.0.9
PKGNAME= ${DISTNAME:S/-base//}
REVISION= 0
REVISION= 1
CATEGORIES= audio
MAINTAINER= Christian Weisgerber <naddy@openbsd.org>
@ -12,7 +12,7 @@ MAINTAINER= Christian Weisgerber <naddy@openbsd.org>
# 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
@ -23,4 +23,9 @@ 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>

View File

@ -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;
}

View File

@ -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

View File

@ -0,0 +1,18 @@
$OpenBSD: patch-configure,v 1.3 2014/10/26 15:24:10 ratchov Exp $
--- 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

View File

@ -0,0 +1,18 @@
$OpenBSD: patch-configure_in,v 1.1 2014/10/26 15:24:10 ratchov Exp $
--- 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