- update to 0.6

- implement and use sndio backend

help from and ok jakemsr@ ratchov@
This commit is contained in:
eric 2010-04-26 07:12:30 +00:00
parent e2459e6367
commit 37b7171cf0
6 changed files with 181 additions and 40 deletions

View File

@ -1,13 +1,13 @@
# $OpenBSD: Makefile,v 1.2 2009/07/16 09:05:32 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.3 2010/04/26 07:12:30 eric Exp $
COMMENT= common libraries for the CMU speech recognition engines
VERSION= 0.4.1
VERSION= 0.6
DISTNAME= sphinxbase-${VERSION}
PKGNAME= cmu-sphinxbase-${VERSION}p0
PKGNAME= cmu-sphinxbase-${VERSION}
CATEGORIES= audio
SHARED_LIBS= sphinxbase 0.0 \
sphinxad 0.0
SHARED_LIBS= sphinxbase 1.0 \
sphinxad 1.0
HOMEPAGE= http://cmusphinx.sourceforge.net/
@ -21,7 +21,7 @@ PERMIT_DISTFILES_FTP= Yes
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=cmusphinx/}
WANTLIB= blas c g2c m ossaudio pthread
WANTLIB= blas c g2c m pthread sndio
MODULES= converters/libiconv
@ -33,6 +33,9 @@ CONFIGURE_STYLE= gnu
CONFIGURE_ARGS= --without-python
CONFIGURE_ENV= CPPFLAGS=-I${LOCALBASE}/include \
LDFLAGS=-L${LOCALBASE}/lib \
LIBS="-lblas -lm -lg2c -lossaudio"
LIBS="-lblas -lm -lg2c -lsndio"
pre-build:
@cp ${FILESDIR}/ad_sndio.c ${WRKSRC}/src/libsphinxad/
.include <bsd.port.mk>

View File

@ -1,5 +1,5 @@
MD5 (sphinxbase-0.4.1.tar.gz) = s7NKTeEEDgxUwmmMjtSqRA==
RMD160 (sphinxbase-0.4.1.tar.gz) = eD4Y3TlaOPC3RQXp7rMpT8CnapI=
SHA1 (sphinxbase-0.4.1.tar.gz) = LLyOyAfloEUMV0puN7N+p5kJb/I=
SHA256 (sphinxbase-0.4.1.tar.gz) = NmgFqRNCmGh69l7uUD3d+FyLX+g+840j7AUuDqWYy5E=
SIZE (sphinxbase-0.4.1.tar.gz) = 2126416
MD5 (sphinxbase-0.6.tar.gz) = X4mVCWZSW19ppqs2s7gX3Q==
RMD160 (sphinxbase-0.6.tar.gz) = hu+y1S2s3TPmS/vvGK8ILLKQisQ=
SHA1 (sphinxbase-0.6.tar.gz) = iS1nheKYSE0V2Ic+G68iI2T+o0g=
SHA256 (sphinxbase-0.6.tar.gz) = KTgywxDVzIHtjs9C1wLGdlE2yzOKA2qvhPR+Ekv3Lfw=
SIZE (sphinxbase-0.6.tar.gz) = 2872665

View File

@ -0,0 +1,128 @@
/*
* Copyright (c) 2010 Eric Faurot <eric@openbsd.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 <sndio.h>
#include <stdio.h>
#include <config.h>
#include "prim_type.h"
#include "ad.h"
#define bPS 16
#define BPS 2
ad_rec_t *
ad_open_dev(const char *dev, int32 rate)
{
struct sio_hdl *hdl;
struct sio_par param;
hdl = sio_open(dev, SIO_REC, 1);
if (hdl == NULL) {
fprintf(stderr, "ad_open_dev: sio_open(%s) failed\n", dev);
return NULL;
}
sio_initpar(&param);
param.bits = bPS;
param.bps = BPS;
param.sig = 1;
param.le = 1;
param.rchan = 1;
param.rate = rate;
if (!sio_setpar(hdl, &param)) {
fprintf(stderr, "ad_open_dev: sio_setpar() failed\n");
sio_close(hdl);
return NULL;
}
if (!sio_getpar(hdl, &param)) {
fprintf(stderr, "ad_open_dev: sio_getpar() failed\n");
sio_close(hdl);
return NULL;
}
if (param.bits != bPS ||
param.bps != BPS ||
param.sig != 1 ||
param.le != 1 ||
param.rchan != 1 ||
param.rate != rate) {
fprintf(stderr, "ad_open_dev: can't set specified params\n");
sio_close(hdl);
return NULL;
}
return (ad_rec_t*)hdl;
}
ad_rec_t *
ad_open_sps(int32 rate)
{
return ad_open_dev(NULL, rate);
}
ad_rec_t *
ad_open(void)
{
return ad_open_sps(DEFAULT_SAMPLES_PER_SEC);
}
int32
ad_start_rec(ad_rec_t *r)
{
struct sio_hdl *hdl = (struct sio_hdl*)r;
if (!sio_start(hdl))
return AD_ERR_GEN;
return (0);
}
int32
ad_stop_rec(ad_rec_t *r)
{
struct sio_hdl *hdl = (struct sio_hdl*)r;
if (!sio_stop(hdl))
return AD_ERR_GEN;
return (0);
}
int32
ad_read(ad_rec_t *r, int16 *buf, int32 max)
{
size_t n, t;
char* b = (char *)buf;
struct sio_hdl *hdl = (struct sio_hdl*)r;
n = sio_read(hdl, b, max * BPS);
while (n % BPS) {
t = sio_read(hdl, b + n, BPS - (n % BPS));
if (t == 0)
return AD_ERR_GEN;
n += t;
}
return (n / BPS);
}
int32
ad_close(ad_rec_t *r)
{
struct sio_hdl *hdl = (struct sio_hdl*)r;
sio_close(hdl);
return (0);
}

View File

@ -1,24 +1,24 @@
$OpenBSD: patch-configure,v 1.1 2009/07/16 09:05:32 ajacoutot Exp $
--- configure.orig Mon Jul 13 13:25:48 2009
+++ configure Mon Jul 13 13:25:57 2009
@@ -8589,13 +8589,13 @@ fi
$OpenBSD: patch-configure,v 1.2 2010/04/26 07:12:30 eric Exp $
--- configure.orig Thu Mar 18 21:49:35 2010
+++ configure Wed Apr 21 14:24:52 2010
@@ -7240,13 +7240,13 @@ fi
done
-{ echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5
-echo $ECHO_N "checking for pthread_create in -lpthread... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking for pthread_create in -pthread" >&5
+echo $ECHO_N "checking for pthread_create in -pthread... $ECHO_C" >&6; }
if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5
-$as_echo_n "checking for pthread_create in -lpthread... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -pthread" >&5
+$as_echo_n "checking for pthread_create in -pthread... " >&6; }
if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpthread $LIBS"
+LIBS="-pthread $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@@ -8655,7 +8655,7 @@ if test $ac_cv_lib_pthread_pthread_create = yes; then
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7281,7 +7281,7 @@ if test "x$ac_cv_lib_pthread_pthread_create" = x""yes;
#define HAVE_LIBPTHREAD 1
_ACEOF
@ -27,3 +27,23 @@ $OpenBSD: patch-configure,v 1.1 2009/07/16 09:05:32 ajacoutot Exp $
fi
@@ -7432,11 +7432,18 @@ fi
;;
# FIXME: isn't this the same OSS as on Linux?
- *-*-freebsd*|*-*-netbsd*|*-*-openbsd*)
+ *-*-freebsd*|*-*-netbsd*)
ad_files="ad_oss_bsd.lo"
ad_backend="AD_BACKEND_OSS_BSD"
$as_echo "#define AD_BACKEND_OSS_BSD /**/" >>confdefs.h
+
+ ;;
+ *-*-openbsd*)
+ ad_files="ad_sndio.lo"
+ ad_backend="AD_BACKEND_SNDIO"
+
+$as_echo "#define AD_BACKEND_SNDIO /**/" >>confdefs.h
;;
*-*-sunos4*)

View File

@ -1,12 +0,0 @@
$OpenBSD: patch-src_libsphinxad_ad_oss_bsd_c,v 1.1.1.1 2009/06/07 07:23:37 eric Exp $
--- src/libsphinxad/ad_oss_bsd.c.orig Mon Jun 1 20:01:13 2009
+++ src/libsphinxad/ad_oss_bsd.c Mon Jun 1 20:01:34 2009
@@ -64,7 +64,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/soundcard.h>
+#include <soundcard.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <unistd.h>

View File

@ -1,10 +1,11 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2009/06/07 07:23:37 eric Exp $
@comment $OpenBSD: PLIST,v 1.2 2010/04/26 07:12:30 eric Exp $
%%SHARED%%
@bin bin/sphinx_cepview
@bin bin/sphinx_cont_adseg
@bin bin/sphinx_cont_fileseg
@bin bin/sphinx_fe
@bin bin/sphinx_jsgf2fsg
@bin bin/sphinx_lm_convert
@bin bin/sphinx_lm_eval
bin/sphinx_lm_sort
@bin bin/sphinx_pitch
@ -31,6 +32,7 @@ include/sphinxbase/genrand.h
include/sphinxbase/glist.h
include/sphinxbase/hash_table.h
include/sphinxbase/heap.h
include/sphinxbase/huff_code.h
include/sphinxbase/info.h
include/sphinxbase/jsgf.h
include/sphinxbase/libutil.h