sndio supported as default audio output method for mpeglib

eyeballed by ratchov@
This commit is contained in:
jakemsr 2010-04-26 01:37:59 +00:00
parent d095622dbe
commit c3bff210a6
5 changed files with 136 additions and 31 deletions

View File

@ -1,10 +1,10 @@
# $OpenBSD: Makefile,v 1.64 2009/12/21 20:46:02 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.65 2010/04/26 01:37:59 jakemsr Exp $
COMMENT = K Desktop Environment, multimedia applications
CATEGORIES = x11 x11/kde
VERSION = 3.5.10
DISTNAME = kdemultimedia-${VERSION}
PKGNAME = ${DISTNAME}p4
PKGNAME = ${DISTNAME}p5
MODKDE_VERSION = 3.5.8
SHARED_LIBS += artsbuilder 1.0 # .0.0
SHARED_LIBS += artsmidi_idl 1.0 # .0.0
@ -68,4 +68,7 @@ WANTLIB = ICE SM X11 Xau Xdmcp Xext Xrender Xv Xxf86dga Xxf86vm \
jpeg m mad ossaudio pcre pcreposix png pthread rpcsvc sndio \
stdc++ util xml2 z pthread-stubs xcb
post-extract:
cp ${FILESDIR}/audioIO_sndio.cpp ${WRKSRC}/mpeglib/lib/util/audio
.include <bsd.port.mk>

View File

@ -0,0 +1,115 @@
/*
* Copyright (c) 2010 Jacob Meuser <jakemsr@sdf.lonestar.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <unistd.h>
#include <stdio.h>
#include <sndio.h>
#include "audioIO.h"
static struct sio_hdl *hdl;
static struct sio_par par;
int
audioConstruct()
{
hdl = NULL;
return true;
}
void
audioDestruct()
{
}
int
audioOpen()
{
hdl = sio_open(NULL, SIO_PLAY, 0);
if (hdl == NULL) {
fprintf(stderr, "unable to open audio device\n");
return 0;
}
return true;
}
inline void
audioFlush()
{
}
void
audioClose()
{
if (hdl != NULL)
sio_close(hdl);
}
void
audioInit(int sampleSize, int frequency, int stereo, int sign, int big)
{
sio_initpar(&par);
par.bits = sampleSize;
par.sig = sign ? 1 : 0;
par.le = big ? 0 : 1;
par.rate = frequency;
par.pchan = stereo ? 2 : 1;
if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par))
fprintf(stderr, "error setting sndio parameters\n");
if (par.bits != sampleSize ||
par.sig != sign ? 1 : 0 ||
par.le != big ? 0 : 1 ||
par.rate != frequency ||
par.pchan != stereo ? 2 : 1)
fprintf(stderr, "could not set requested audio parameters");
if (!sio_start(hdl))
fprintf(stderr, "could not start audio");
}
int
getAudioBufferSize()
{
return (par.appbufsz * par.bps * par.pchan);
}
void
mixerSetVolume(int leftVolume, int rightVolume)
{
/* values from 0..100 */
}
int
mixerOpen()
{
return false;
}
void
mixerClose()
{
}
int
audioWrite(char *buffer, int count)
{
return(sio_write(hdl, buffer, count));
}

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-mpeglib_lib_Makefile_in,v 1.8 2010/04/26 01:37:59 jakemsr Exp $
--- mpeglib/lib/Makefile.in.orig Thu Apr 22 19:09:59 2010
+++ mpeglib/lib/Makefile.in Thu Apr 22 19:10:32 2010
@@ -293,7 +293,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TAGLIB_CONFIG = @TAGLIB_CONFIG@
-THIS_LIB_LIBS = @THIS_LIB_LIBS@
+THIS_LIB_LIBS = @THIS_LIB_LIBS@ -lsndio
THIS_LIB_MAJOR_VERSION = @THIS_LIB_MAJOR_VERSION@
THIS_LIB_MICRO_VERSION = @THIS_LIB_MICRO_VERSION@
THIS_LIB_MINOR_VERSION = @THIS_LIB_MINOR_VERSION@

View File

@ -1,25 +0,0 @@
$OpenBSD: patch-mpeglib_lib_util_audio_audioIO_SunOS_cpp,v 1.1 2009/01/29 22:37:21 jakemsr Exp $
--- mpeglib/lib/util/audio/audioIO_SunOS.cpp.orig Sun Dec 28 14:56:16 2008
+++ mpeglib/lib/util/audio/audioIO_SunOS.cpp Sun Dec 28 14:59:46 2008
@@ -8,10 +8,11 @@
*/
#include <sys/types.h>
-#include <sys/stropts.h>
+#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
+#include <sys/ioctl.h>
#include <sys/audioio.h>
#include "audioIO.h"
#include <iostream.h>
@@ -128,7 +129,7 @@ void mixerSetVolume(int leftVolume,int rightVolume) {
//someone should fix the volume on solaris
balance=0;
- auinfo.play.balance=(uchar_t)balance;
+ auinfo.play.balance=(unsigned char)balance;
if (ioctl(audio_fd,AUDIO_SETINFO,&auinfo)<0)
perror("Unable to set sound volume");
}

View File

@ -1,12 +1,12 @@
$OpenBSD: patch-mpeglib_lib_util_audio_audioIO_cpp,v 1.1 2009/01/29 22:37:21 jakemsr Exp $
--- mpeglib/lib/util/audio/audioIO.cpp.orig Sun Dec 28 13:31:48 2008
+++ mpeglib/lib/util/audio/audioIO.cpp Sun Dec 28 13:32:36 2008
$OpenBSD: patch-mpeglib_lib_util_audio_audioIO_cpp,v 1.2 2010/04/26 01:37:59 jakemsr Exp $
--- mpeglib/lib/util/audio/audioIO.cpp.orig Sat Sep 10 01:19:53 2005
+++ mpeglib/lib/util/audio/audioIO.cpp Thu Apr 22 19:06:05 2010
@@ -26,7 +26,11 @@
#endif
#ifdef OS_BSD
+#ifdef __OpenBSD__
+ #include "audioIO_SunOS.cpp"
+ #include "audioIO_sndio.cpp"
+#else
#include "audioIO_Linux.cpp"
+#endif