[Julius Web page]
[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
[julius-u:00023] Re: [announce] julius-2.2 available
- From: Kunihiko IMAI <bak@xxxxxxxxxxxxx>
- Date: Mon, 27 Dec 1999 19:52:02 +0900
今井%現実逃避,です (^^;;;;;;
早速 julius-2.2 と linux のキット,ダウンロードしてみました.
で,
kernel 2.2.13 + OSS
の環境で make して実行してみたところ,core を吐いてお亡くなりになりました.
で,gdb で追っていったところ,
julius-2.2/lib/adin/adin_mic_linux_oss.c
がバグっていました.
内容としては,要するに read() のエラー処理の問題です.
read() 自体は -1 を返してきているのですが,
read()/sizeof(short) の演算結果がなぜか 0x7fffffff になっていました.
なんぢゃこれわ.
で,errno を見てみると,EAGAIN を返していたので,素直に retry するように
してみました.
というわけで,パッチです.
では
_._. __._ _.. . .___ ._. _____ _... ._ _._ _.._. .____ .__. ... . _._
Kunihiko IMAI
今井 邦彦
--- adin_mic_linux_oss.c.orig Mon Aug 30 12:47:02 1999
+++ adin_mic_linux_oss.c Mon Dec 27 19:32:31 1999
@@ -22,6 +22,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <errno.h>
static int audio_fd; /* audio descriptor */
static boolean need_swap; /* whether samples need byte swap */
@@ -139,7 +140,13 @@
adin_mic_read(short *buf, int sampnum)
{
int cnt;
- cnt = read(audio_fd, buf, sampnum*sizeof(short)) / sizeof(short);
+
+ do {
+ errno = 0;
+ cnt = read(audio_fd, buf, sampnum*sizeof(short));
+ } while ( cnt < 0 && ( errno == EINTR || errno == EAGAIN ) );
+ if ( cnt < 0 ) return ( -1 );
+ cnt /= sizeof(short);
if (need_swap) swap_short_bytes(buf, cnt);
return(cnt);
}
Follow-Ups:
References: