diff -crN julius-3.3p3-multipath/Release.txt julius-3.3p4-multipath/Release.txt
*** julius-3.3p3-multipath/Release.txt	Wed Jan  8 17:21:48 2003
--- julius-3.3p4-multipath/Release.txt	Tue May  6 17:55:37 2003
***************
*** 1,3 ****
--- 1,13 ----
+ 3.3p4 (2003.05.06)
+ ===================
+ - Fixes for audio input:
+   - Fix segfault/hangup with continuous microphone input.
+   - Fix client hangup when input speech too long in module mode.
+     (now send an buffer overflow message to the client)
+   - Fix audio input buffering for very short input (<1000 samples).
+   - Fix blocking handling in tcpip adin.
+ - Some cosmetic changes (jcontrol, LOG_TEN, etc.)
+ 
  3.3p3 (2003.01.08)
  ===================
  - New inter-word short pause handling:
diff -crN julius-3.3p3-multipath/Release.txt.ja julius-3.3p4-multipath/Release.txt.ja
*** julius-3.3p3-multipath/Release.txt.ja	Wed Jan  8 17:21:48 2003
--- julius-3.3p4-multipath/Release.txt.ja	Tue May  6 17:55:37 2003
***************
*** 1,3 ****
--- 1,14 ----
+ 3.3p4 (2003.05.06)
+ ===================
+ - 音声入力のいくつかの不具合を改善
+   - マイク入力で長時間動作させたときに突然ハングアップする不具合を修正
+   - モジュールモードで,入力音声が長すぎたときにクライアントがハングアッ
+     プする不具合の修正(クライアントにエラーメッセージを送信するようになっ
+     た)
+   - 1000サンプル以下の短い入力に対するバッファリングの改良.
+   - ネットワーク経由の音声入力におけるブロッキングの改良.
+ - ソースの見栄えの修正 (jcontrolのtypo, 定数LOG_TENを定義,など)
+ 
  3.3p3 (2003.01.08)
  ===================
  - 単語間ショートポーズの扱いが新たに追加された.
diff -crN julius-3.3p3-multipath/jcontrol/japi.h julius-3.3p4-multipath/jcontrol/japi.h
*** julius-3.3p3-multipath/jcontrol/japi.h	Thu Sep 12 07:12:03 2002
--- julius-3.3p4-multipath/jcontrol/japi.h	Tue May  6 17:55:37 2003
***************
*** 13,19 ****
  void do_disconnect(int sd);
  void do_sendf(int sd, char *fmt, ...);
  void do_send(int sd, char *buf);
! char *do_reveive(int sd, char *buf, int maxlen);
  
  /* japi_misc.c */
  void japi_die(int);
--- 13,19 ----
  void do_disconnect(int sd);
  void do_sendf(int sd, char *fmt, ...);
  void do_send(int sd, char *buf);
! char *do_receive(int sd, char *buf, int maxlen);
  
  /* japi_misc.c */
  void japi_die(int);
diff -crN julius-3.3p3-multipath/jcontrol/jcontrol.c julius-3.3p4-multipath/jcontrol/jcontrol.c
*** julius-3.3p3-multipath/jcontrol/jcontrol.c	Thu Sep 12 07:12:03 2002
--- julius-3.3p4-multipath/jcontrol/jcontrol.c	Tue May  6 17:55:37 2003
***************
*** 70,76 ****
  void
  do_output(int sd)
  {
!   while(do_reveive(sd, rbuf, MAXLINELEN) != NULL) {
      if (rbuf[0] == '.' && rbuf[1] == '\0') break;
      printf("> %s\n", rbuf);
    }
--- 70,76 ----
  void
  do_output(int sd)
  {
!   while(do_receive(sd, rbuf, MAXLINELEN) != NULL) {
      if (rbuf[0] == '.' && rbuf[1] == '\0') break;
      printf("> %s\n", rbuf);
    }
diff -crN julius-3.3p3-multipath/jcontrol/server.c julius-3.3p4-multipath/jcontrol/server.c
*** julius-3.3p3-multipath/jcontrol/server.c	Thu Sep 12 07:12:03 2002
--- julius-3.3p4-multipath/jcontrol/server.c	Tue May  6 17:55:37 2003
***************
*** 83,93 ****
    }
  }
  
! /* reveive data from server (return at newline or EOM) */
  /* strip newline */
  /* return pointer to buf, or NULL on error */
  char *
! do_reveive(int sd, char *buf, int maxlen)
  {
    int cnt;
    char *p;
--- 83,93 ----
    }
  }
  
! /* receive data from server (return at newline or EOM) */
  /* strip newline */
  /* return pointer to buf, or NULL on error */
  char *
! do_receive(int sd, char *buf, int maxlen)
  {
    int cnt;
    char *p;
diff -crN julius-3.3p3-multipath/julius/configure julius-3.3p4-multipath/julius/configure
*** julius-3.3p3-multipath/julius/configure	Wed Sep 11 01:13:52 2002
--- julius-3.3p4-multipath/julius/configure	Tue May  6 18:02:56 2003
***************
*** 734,740 ****
    enableval="$enable_julian"
    	EXECNAME=julian
  	PRODUCTNAME=Julian
! 	VERSION=3.3-multipath
  	cat >> confdefs.h <<\EOF
  #define USE_DFA 1
  EOF
--- 734,740 ----
    enableval="$enable_julian"
    	EXECNAME=julian
  	PRODUCTNAME=Julian
! 	VERSION=3.3p4-multipath
  	cat >> confdefs.h <<\EOF
  #define USE_DFA 1
  EOF
***************
*** 747,753 ****
  else
    	EXECNAME=julius
  	PRODUCTNAME=Julius
! 	VERSION=3.3-multipath
  	
  fi
  
--- 747,753 ----
  else
    	EXECNAME=julius
  	PRODUCTNAME=Julius
! 	VERSION=3.3p4-multipath
  	
  fi
  
diff -crN julius-3.3p3-multipath/julius/configure.in julius-3.3p4-multipath/julius/configure.in
*** julius-3.3p3-multipath/julius/configure.in	Thu Sep 12 07:12:03 2002
--- julius-3.3p4-multipath/julius/configure.in	Tue May  6 18:02:56 2003
***************
*** 101,107 ****
  dnl JULIUS related end
  	EXECNAME=julian
  	PRODUCTNAME=Julian
! 	VERSION=3.3-multipath
  	AC_DEFINE(USE_DFA)
  	AC_DEFINE(CATEGORY_TREE)
  dnl JULIUS related begin
--- 101,107 ----
  dnl JULIUS related end
  	EXECNAME=julian
  	PRODUCTNAME=Julian
! 	VERSION=3.3p4-multipath
  	AC_DEFINE(USE_DFA)
  	AC_DEFINE(CATEGORY_TREE)
  dnl JULIUS related begin
***************
*** 109,115 ****
  dnl JULIAN related end
  	EXECNAME=julius
  	PRODUCTNAME=Julius
! 	VERSION=3.3-multipath
  dnl JULIAN related begin
  	)
  dnl JULIAN related end
--- 109,115 ----
  dnl JULIAN related end
  	EXECNAME=julius
  	PRODUCTNAME=Julius
! 	VERSION=3.3p4-multipath
  dnl JULIAN related begin
  	)
  dnl JULIAN related end
diff -crN julius-3.3p3-multipath/libsent/configure julius-3.3p4-multipath/libsent/configure
*** julius-3.3p3-multipath/libsent/configure	Mon Nov 25 21:55:26 2002
--- julius-3.3p4-multipath/libsent/configure	Tue May  6 18:02:56 2003
***************
*** 553,559 ****
  ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
  
  
! VERSION=3.3-multipath
  
  # specify mic type
  # Check whether --with-mictype or --without-mictype was given.
--- 553,559 ----
  ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
  
  
! VERSION=3.3p4-multipath
  
  # specify mic type
  # Check whether --with-mictype or --without-mictype was given.
diff -crN julius-3.3p3-multipath/libsent/configure.in julius-3.3p4-multipath/libsent/configure.in
*** julius-3.3p3-multipath/libsent/configure.in	Mon Nov 25 21:55:27 2002
--- julius-3.3p4-multipath/libsent/configure.in	Tue May  6 18:02:56 2003
***************
*** 10,16 ****
  AC_CONFIG_HEADER(include/sent/config.h)
  AC_CONFIG_AUX_DIR(../support)
  
! VERSION=3.3-multipath
  
  dnl Checks for options
  # specify mic type
--- 10,16 ----
  AC_CONFIG_HEADER(include/sent/config.h)
  AC_CONFIG_AUX_DIR(../support)
  
! VERSION=3.3p4-multipath
  
  dnl Checks for options
  # specify mic type
diff -crN julius-3.3p3-multipath/libsent/include/sent/hmm.h julius-3.3p4-multipath/libsent/include/sent/hmm.h
*** julius-3.3p3-multipath/libsent/include/sent/hmm.h	Tue Nov 26 12:58:56 2002
--- julius-3.3p4-multipath/libsent/include/sent/hmm.h	Tue May  6 18:00:02 2003
***************
*** 14,21 ****
  #include <sent/htk_hmm.h>
  #include <sent/htk_param.h>
  
- #define LOGTEN 2.30258509
- 
  /* transition arc data */
  typedef struct __a_cell__ {
    LOGPROB		a;	/* transition logprob */
--- 14,19 ----
***************
*** 48,54 ****
  /* addlog.c */
  void make_log_tbl();
  LOGPROB addlog(LOGPROB x, LOGPROB y);
- LOGPROB addlog10(LOGPROB x, LOGPROB y);
  LOGPROB addlog_array(LOGPROB *x, int n);
  
  /* outprob_init.c */
--- 46,51 ----
diff -crN julius-3.3p3-multipath/libsent/include/sent/stddefs.h julius-3.3p4-multipath/libsent/include/sent/stddefs.h
*** julius-3.3p3-multipath/libsent/include/sent/stddefs.h	Thu Sep 12 07:12:04 2002
--- julius-3.3p4-multipath/libsent/include/sent/stddefs.h	Tue May  6 17:55:38 2003
***************
*** 4,10 ****
  
  /* stddefs.h --- nifty standard definitions */
  
! /* $Id: stddefs.h,v 1.5 2002/09/11 22:01:50 ri Exp $ */
  
  #ifndef __SENT_STANDARD_DEFS__
  #define __SENT_STANDARD_DEFS__
--- 4,10 ----
  
  /* stddefs.h --- nifty standard definitions */
  
! /* $Id: stddefs.h,v 1.6 2003/02/25 01:44:57 ri Exp $ */
  
  #ifndef __SENT_STANDARD_DEFS__
  #define __SENT_STANDARD_DEFS__
***************
*** 29,34 ****
--- 29,37 ----
  #if !defined(TPI)
  #define TPI 6.28318530717959
  #define LOGTPI 1.83787706640935
+ #endif
+ #if !defined(LOG_TEN)
+ #define LOG_TEN 2.30258509
  #endif
  
  /* define boolean */
diff -crN julius-3.3p3-multipath/libsent/src/adin/adin-cut.c julius-3.3p4-multipath/libsent/src/adin/adin-cut.c
*** julius-3.3p3-multipath/libsent/src/adin/adin-cut.c	Mon Nov 25 21:55:27 2002
--- julius-3.3p4-multipath/libsent/src/adin/adin-cut.c	Tue May  6 17:55:38 2003
***************
*** 4,10 ****
  
  /* adin-cut.c --- read audio input from device with skipping silence */
  
! /* $Id: adin-cut.c,v 1.7 2002/11/25 02:23:29 ri Exp $ */
  
  /* use zerocross & level threshold for silence detection */
  /* process one speech segment till next silence at a call */
--- 4,10 ----
  
  /* adin-cut.c --- read audio input from device with skipping silence */
  
! /* $Id: adin-cut.c,v 1.9 2003/04/22 01:59:44 ri Exp $ */
  
  /* use zerocross & level threshold for silence detection */
  /* process one speech segment till next silence at a call */
***************
*** 99,105 ****
    samples_in_msec = (float) sample_freq / 1000.0;
    c_length = head_margin * samples_in_msec;	/* in msec. */
    noise_zerocross = czc * c_length / sample_freq;
!   nc_max = (tail_margin * samples_in_msec / DEFAULT_WSTEP) + 2;
    /*printf("c_length=%d, noise_zerocross=%d nc_max=%d\n", c_length, noise_zerocross, nc_max);*/
  
  #ifdef HAVE_PTHREAD
--- 99,106 ----
    samples_in_msec = (float) sample_freq / 1000.0;
    c_length = head_margin * samples_in_msec;	/* in msec. */
    noise_zerocross = czc * c_length / sample_freq;
!   wstep = DEFAULT_WSTEP;
!   nc_max = (tail_margin * samples_in_msec / wstep) + 2;
    /*printf("c_length=%d, noise_zerocross=%d nc_max=%d\n", c_length, noise_zerocross, nc_max);*/
  
  #ifdef HAVE_PTHREAD
***************
*** 131,136 ****
--- 132,138 ----
  static pthread_mutex_t mutex;	/* lock primitive */
  static int dummy;		/* dummy arg */
  static boolean transfer_online = FALSE;
+ static boolean adinthread_buffer_overflowed = FALSE;
  #endif
  
  /* temporary input data buffer */
***************
*** 164,169 ****
--- 166,172 ----
    int imax, len, cnt;
    static boolean end_of_stream;
    static int end_status;
+   static boolean transfer_online_local;
    
    /* variables for zero-cross routines*/
    static int zc;
***************
*** 189,195 ****
        is_valid_data = FALSE;
      }
      end_of_stream = FALSE;
-     wstep = DEFAULT_WSTEP;
      nc = 0;
      cbuf = (SP16 *)mymalloc(sizeof(SP16) * c_length);
    }
--- 192,197 ----
***************
*** 252,272 ****
        }
      }
  
!     /* set process step */
!     if (end_of_stream && wstep > current_len) wstep = current_len;
  
!     /* set maximum number of processed samples per loop */
  #ifdef HAVE_PTHREAD
!     if (enable_thread) imax = current_len; /* store as many as possible */
!     else imax = (current_len < wstep) ? current_len : wstep;
  #else
!     imax = (current_len < wstep) ? current_len : wstep;
  #endif
  
  #ifdef THREAD_DEBUG
      printf("process %d samples by %d step\n", imax, wstep);
  #endif
  
      /* proceed for each 'wstep' steps */
      i = 0;
      while (i + wstep <= imax) {
--- 254,284 ----
        }
      }
  
!     if (current_len == 0) continue;
  
!     /* set length that should be processed at this call */
!     wstep = DEFAULT_WSTEP;
  #ifdef HAVE_PTHREAD
!     if (enable_thread) imax = current_len; /* process whole */
!     else imax = (current_len < wstep) ? current_len : wstep; /* one step */
  #else
!     imax = (current_len < wstep) ? current_len : wstep;	/* one step */
  #endif
+     
+     /* set process step per loop */
+     if (wstep > current_len) wstep = current_len;
  
  #ifdef THREAD_DEBUG
      printf("process %d samples by %d step\n", imax, wstep);
  #endif
  
+ #ifdef HAVE_PTHREAD
+     /* get transfer status to local */
+     pthread_mutex_lock(&mutex);
+     transfer_online_local = transfer_online;
+     pthread_mutex_unlock(&mutex);
+ #endif
+ 
      /* proceed for each 'wstep' steps */
      i = 0;
      while (i + wstep <= imax) {
***************
*** 281,289 ****
  	    printf("detect on\n");
  #endif
  	    /* process stored samples in cycle buffer */
  	    if ( ad_process != NULL
  #ifdef HAVE_PTHREAD
! 		 && (!enable_thread || transfer_online)
  #endif
  		 ) {
  	      zc_copy_buffer(cbuf, &len);
--- 293,302 ----
  	    printf("detect on\n");
  #endif
  	    /* process stored samples in cycle buffer */
+ 	    
  	    if ( ad_process != NULL
  #ifdef HAVE_PTHREAD
! 		 && (!enable_thread || transfer_online_local)
  #endif
  		 ) {
  	      zc_copy_buffer(cbuf, &len);
***************
*** 294,310 ****
  		ad_process_ret = (*ad_process)(cbuf, len - wstep);
  		switch(ad_process_ret) {
  		case 1:		/* segmented */
- 		  end_status = 1;
- 		  adin_purge(i);
  #ifdef HAVE_PTHREAD
  		  if (enable_thread) { /* just stop transfer */
  		    pthread_mutex_lock(&mutex);
! 		    transfer_online = FALSE;
  		    pthread_mutex_unlock(&mutex);
  		  } else {
  		    goto break_input;
  		  }
  #else
  		  goto break_input;
  #endif
  		case -1:		/* error */
--- 307,326 ----
  		ad_process_ret = (*ad_process)(cbuf, len - wstep);
  		switch(ad_process_ret) {
  		case 1:		/* segmented */
  #ifdef HAVE_PTHREAD
  		  if (enable_thread) { /* just stop transfer */
  		    pthread_mutex_lock(&mutex);
! 		    transfer_online = transfer_online_local = FALSE;
  		    pthread_mutex_unlock(&mutex);
  		  } else {
+ 		    end_status = 1;
+ 		    adin_purge(i);
  		    goto break_input;
  		  }
+ 		  break;
  #else
+ 		  end_status = 1;
+ 		  adin_purge(i);
  		  goto break_input;
  #endif
  		case -1:		/* error */
***************
*** 325,331 ****
        if(
  	 (!adin_cut_on || is_valid_data == TRUE)
  #ifdef HAVE_PTHREAD
! 	 && (!enable_thread || transfer_online)
  #endif
  	 ) {
  	/* process data */
--- 341,347 ----
        if(
  	 (!adin_cut_on || is_valid_data == TRUE)
  #ifdef HAVE_PTHREAD
! 	 && (!enable_thread || transfer_online_local)
  #endif
  	 ) {
  	/* process data */
***************
*** 337,353 ****
  	  ad_process_ret = (*ad_process)(&(buffer[i]),  wstep);
  	  switch(ad_process_ret) {
  	  case 1:		/* segmented by ad_process() */
- 	    adin_purge(i+wstep);
- 	    end_status = 1;
  #ifdef HAVE_PTHREAD
  	    if (enable_thread) { /* just stop transfer */
  	      pthread_mutex_lock(&mutex);
! 	      transfer_online = FALSE;
  	      pthread_mutex_unlock(&mutex);
  	    } else {
  	      goto break_input;
  	    }
  #else
  	    goto break_input;
  #endif
  	  case -1:		/* error */
--- 353,372 ----
  	  ad_process_ret = (*ad_process)(&(buffer[i]),  wstep);
  	  switch(ad_process_ret) {
  	  case 1:		/* segmented by ad_process() */
  #ifdef HAVE_PTHREAD
  	    if (enable_thread) { /* just stop transfer */
  	      pthread_mutex_lock(&mutex);
! 	      transfer_online = transfer_online_local = FALSE;
  	      pthread_mutex_unlock(&mutex);
  	    } else {
+ 	      adin_purge(i+wstep);
+ 	      end_status = 1;
  	      goto break_input;
  	    }
+ 	    break;
  #else
+ 	    adin_purge(i+wstep);
+ 	    end_status = 1;
  	    goto break_input;
  #endif
  	  case -1:		/* error */
***************
*** 362,378 ****
  #endif
  	/* end input by silence */
  	is_valid_data = FALSE;
- 	adin_purge(i+wstep);
- 	end_status = 1;
  #ifdef HAVE_PTHREAD
  	if (enable_thread) { /* just stop transfer */
  	  pthread_mutex_lock(&mutex);
! 	  transfer_online = FALSE;
  	  pthread_mutex_unlock(&mutex);
  	} else {
  	  goto break_input;
  	}
  #else
  	goto break_input;
  #endif
        }
--- 381,399 ----
  #endif
  	/* end input by silence */
  	is_valid_data = FALSE;
  #ifdef HAVE_PTHREAD
  	if (enable_thread) { /* just stop transfer */
  	  pthread_mutex_lock(&mutex);
! 	  transfer_online = transfer_online_local = FALSE;
  	  pthread_mutex_unlock(&mutex);
  	} else {
+ 	  adin_purge(i+wstep);
+ 	  end_status = 1;
  	  goto break_input;
  	}
  #else
+ 	adin_purge(i+wstep);
+ 	end_status = 1;
  	goto break_input;
  #endif
        }
***************
*** 419,426 ****
  adin_store_buffer(SP16 *now, int len)
  {
    if (speechlen + len > MAXSPEECHLEN) {
!     j_printerr("Warning: too long input (> %d samples), segmented now\n", MAXSPEECHLEN);
!     return(1);			/* force segment */
    }
    pthread_mutex_lock(&mutex);
    memcpy(&(speech[speechlen]), now, len * sizeof(SP16));
--- 440,450 ----
  adin_store_buffer(SP16 *now, int len)
  {
    if (speechlen + len > MAXSPEECHLEN) {
!     /* just mark as overflowed, and continue this thread */
!     pthread_mutex_lock(&mutex);
!     adinthread_buffer_overflowed = TRUE;
!     pthread_mutex_unlock(&mutex);
!     return(0);
    }
    pthread_mutex_lock(&mutex);
    memcpy(&(speech[speechlen]), now, len * sizeof(SP16));
***************
*** 450,455 ****
--- 474,480 ----
    speech = (SP16 *)mymalloc(sizeof(SP16) * MAXSPEECHLEN);
  
    transfer_online = FALSE; /* tell adin-mic thread to wait at initial */
+   adinthread_buffer_overflowed = FALSE;
  
    if (pthread_mutex_init(&(mutex), NULL) != 0) { /* error */
      j_error("Error: pthread: cannot initialize mutex\n");
***************
*** 472,477 ****
--- 497,504 ----
    int ad_process_ret;
    int end_status;
    int i;
+   boolean overflowed_p;
+   boolean transfer_online_local;
  
    /* reset storing buffer --- input while recognition will be ignored */
    pthread_mutex_lock(&mutex);
***************
*** 489,500 ****
      /* get current length (locking) */
      pthread_mutex_lock(&mutex);
      nowlen = speechlen;
      pthread_mutex_unlock(&mutex);
      if (ad_check != NULL) {
        if ((i = (*ad_check)()) < 0) {
  	if ((i == -1 && nowlen == 0) || i == -2) {
  	  pthread_mutex_lock(&mutex);
! 	  transfer_online = FALSE;
  	  speechlen = 0;
  	  pthread_mutex_unlock(&mutex);
  	  return(-2);
--- 516,541 ----
      /* get current length (locking) */
      pthread_mutex_lock(&mutex);
      nowlen = speechlen;
+     overflowed_p = adinthread_buffer_overflowed;
+     transfer_online_local = transfer_online;
      pthread_mutex_unlock(&mutex);
+     /* check if other input thread has overflowed */
+     if (overflowed_p) {
+       j_printerr("Warning: too long input (> %d samples), segmented now\n", MAXSPEECHLEN);
+       /* segment input here */
+       pthread_mutex_lock(&mutex);
+       adinthread_buffer_overflowed = FALSE;
+       speechlen = 0;
+       transfer_online = transfer_online_local = FALSE;
+       pthread_mutex_unlock(&mutex);
+       return(1);		/* return with segmented status */
+     }
+     /* callback poll */
      if (ad_check != NULL) {
        if ((i = (*ad_check)()) < 0) {
  	if ((i == -1 && nowlen == 0) || i == -2) {
  	  pthread_mutex_lock(&mutex);
! 	  transfer_online = transfer_online_local = FALSE;
  	  speechlen = 0;
  	  pthread_mutex_unlock(&mutex);
  	  return(-2);
***************
*** 532,551 ****
  	  } else {
  	    speechlen = 0;
  	  }
! 	  transfer_online = FALSE;
  	  pthread_mutex_unlock(&mutex);
  	  /* keep transfering */
  	  return(1);		/* return with segmented status */
  	case -1:		/* error */
  	  pthread_mutex_lock(&mutex);
! 	  transfer_online = FALSE;
  	  pthread_mutex_unlock(&mutex);
  	  return(-1);		/* return with error */
  	}
        }
        prev_len = nowlen;
      } else {
!       if (transfer_online == FALSE) {
  	/* segmented by zero-cross */
  	/* reset storing buffer for next input */
  	pthread_mutex_lock(&mutex);
--- 573,592 ----
  	  } else {
  	    speechlen = 0;
  	  }
! 	  transfer_online = transfer_online_local = FALSE;
  	  pthread_mutex_unlock(&mutex);
  	  /* keep transfering */
  	  return(1);		/* return with segmented status */
  	case -1:		/* error */
  	  pthread_mutex_lock(&mutex);
! 	  transfer_online = transfer_online_local = FALSE;
  	  pthread_mutex_unlock(&mutex);
  	  return(-1);		/* return with error */
  	}
        }
        prev_len = nowlen;
      } else {
!       if (transfer_online_local == FALSE) {
  	/* segmented by zero-cross */
  	/* reset storing buffer for next input */
  	pthread_mutex_lock(&mutex);
diff -crN julius-3.3p3-multipath/libsent/src/adin/adin_mic_linux_oss.c julius-3.3p4-multipath/libsent/src/adin/adin_mic_linux_oss.c
*** julius-3.3p3-multipath/libsent/src/adin/adin_mic_linux_oss.c	Mon Nov 25 21:55:27 2002
--- julius-3.3p4-multipath/libsent/src/adin/adin_mic_linux_oss.c	Thu May  8 17:41:49 2003
***************
*** 4,10 ****
  
  /* adin_mic_linux_oss.c --- adin microphone library for OSS API */
  
! /* $Id: adin_mic_linux_oss.c,v 1.4 2002/11/24 14:14:33 ri Exp $ */
  
  /* for standard sound drivers in linux-2.0.x, 2.2.x */
  /* for OSS/Linux, OSS/Free or other OSS compatible API */
--- 4,10 ----
  
  /* adin_mic_linux_oss.c --- adin microphone library for OSS API */
  
! /* $Id: adin_mic_linux_oss.c,v 1.6 2003/05/08 08:23:49 ri Exp $ */
  
  /* for standard sound drivers in linux-2.0.x, 2.2.x */
  /* for OSS/Linux, OSS/Free or other OSS compatible API */
***************
*** 27,45 ****
  #include <sys/stat.h>
  #include <fcntl.h>
  #include <unistd.h>
- #include <poll.h>
  
  /* sound header */
  #include <sys/soundcard.h>
  
  static int audio_fd;		/* audio descriptor */
  static boolean need_swap;	/* whether samples need byte swap */
  static int fmt;			/* signed 16bit */
! struct pollfd fds[1];		/* structure for polling */
! 
! #define FREQALLOWRANGE 200	/* acceptable sampling frequency width around 16kHz */
! #define POLLINTERVAL 50	/* in miliseconds */
! 
  
  /* check audio port resource and initialize */
  /* will be called once at startup time */
--- 27,46 ----
  #include <sys/stat.h>
  #include <fcntl.h>
  #include <unistd.h>
  
  /* sound header */
  #include <sys/soundcard.h>
  
+ #define FREQALLOWRANGE 200	/* acceptable sampling frequency width around 16kHz */
+ #define MAXPOLLINTERVAL 300	/* adin read timeout interval (msec) */
+ #define FRAGMENT_POWER 10	/* data fragment size (= input delay)
+ 				  2^10 = 1024 byte = 32ms in 16kHz */
+ 
  static int audio_fd;		/* audio descriptor */
  static boolean need_swap;	/* whether samples need byte swap */
  static int fmt;			/* signed 16bit */
! static int frag_size;		/* data fragment size */
! static int poll_interval;
  
  /* check audio port resource and initialize */
  /* will be called once at startup time */
***************
*** 98,103 ****
--- 99,116 ----
      perror("adin_mic_standby: open /dev/dsp");
      return(FALSE);
    }
+ 
+   /* try to set a small fragment size to minimize delay, */
+   /* although many devices use static fragment size... */
+   /* (and smaller fragment causes busy buffering) */
+   {
+     int arg;
+     arg = 0x7fff0000 | FRAGMENT_POWER;
+     if (ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &arg)) {
+       fprintf(stderr, "adin_mic_standby: set fragment size to 2^%d=%d bytes (%d msec)\n", FRAGMENT_POWER, 2 << (FRAGMENT_POWER-1), (2 << (FRAGMENT_POWER-1)) * 1000 / (sfreq * sizeof(SP16)));
+     }
+   }
+   
    /* set format, samplerate, channels */
    rfmt = fmt;
    if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &rfmt) == -1) {
***************
*** 132,141 ****
      fprintf(stderr,"adin_mic_standby: set sampling rate to %dHz\n", samplerate);
    }
  
!   /* set polling status */
!   fds[0].fd = audio_fd;
!   fds[0].events = POLLIN;
!   
    return TRUE;
  }
   
--- 145,161 ----
      fprintf(stderr,"adin_mic_standby: set sampling rate to %dHz\n", samplerate);
    }
  
!   /* get actual fragment size */
!   if (ioctl(audio_fd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) {
!     fprintf(stderr, "adin_mic_standby: failed to get fragment size\n");
!     return(FALSE);
!   }
!   j_printf("fragment size = %d bytes (%d msec)", frag_size, frag_size * 1000/ (sfreq * sizeof(SP16)));
!   if (frag_size !=  2 << (FRAGMENT_POWER-1)) {
!     j_printf(" (tried = %d bytes)", 2 << (FRAGMENT_POWER-1));
!   }
!   j_printf("\n");
! 
    return TRUE;
  }
   
***************
*** 171,201 ****
  {
    int size,cnt;
    audio_buf_info info;
! 
!   /* wait till at least one sample can be read */
!   poll(fds, 1, POLLINTERVAL);
!   /* get actual sample num in the device buffer */
!   if (ioctl(audio_fd, SNDCTL_DSP_GETISPACE, &info) == -1) {
!     perror("adin_mic_read: sndctl_dsp_getispace");
!     return(-2);
    }
!   /*printf("%d\n",info.bytes);*/
!   
!   /* get them as much as possible */
!   size = sampnum * sizeof(SP16);
!   if (size > info.bytes) size = info.bytes;
!   cnt = read(audio_fd, buf, size);
! /* 
!  *   do {
!  *     errno = 0;
!  *     cnt = read(audio_fd, buf, sampnum*sizeof(short));
!  *   } while ( cnt < 0 && ( errno == EINTR || errno == EAGAIN ) );
!  */
!   if ( cnt < 0 ) {
!     perror("adin_mic_read: read error\n");
!     return ( -1 );
!   }
!   cnt /= sizeof(short);
!   if (need_swap) swap_sample_bytes(buf, cnt);
    return(cnt);
  }
--- 191,235 ----
  {
    int size,cnt;
    audio_buf_info info;
!   fd_set rfds;
!   struct timeval tv;
!   int status;
! 
!   /* check for incoming samples in device buffer */
!   /* if there is at least one sample fragment, go next */
!   /* if not exist, wait for the data to come for at most MAXPOLLINTERVAL msec */
!   /* if no sample fragment has come in the MAXPOLLINTERVAL period, go next */
!   FD_ZERO(&rfds);
!   FD_SET(audio_fd, &rfds);
!   tv.tv_sec = 0;
!   tv.tv_usec = MAXPOLLINTERVAL * 1000;
!   status = select(audio_fd+1, &rfds, NULL, NULL, &tv);
!   if (status < 0) {
!     /* select() failed */
!     j_printerr("adin_mic_read: device polling failed\n");
!     return(-2);			/* error */
!   }
!   if (FD_ISSET(audio_fd, &rfds)) { /* has some data */
!     /* get sample num that can be read without blocking */
!     if (ioctl(audio_fd, SNDCTL_DSP_GETISPACE, &info) == -1) {
!       perror("adin_mic_read: sndctl_dsp_getispace");
!       return(-2);
!     }
!     /* get them as much as possible */
!     size = sampnum * sizeof(SP16);
!     if (size > info.bytes) size = info.bytes;
!     if (size < frag_size) size = frag_size;
!     cnt = read(audio_fd, buf, size);
!     if ( cnt < 0 ) {
!       perror("adin_mic_read: read error\n");
!       return ( -2 );
!     }
!     cnt /= sizeof(short);
!     if (need_swap) swap_sample_bytes(buf, cnt);
!   } else {			/* no data after waiting */
!     j_printerr("adin_mic_read: no data fragment after %d msec?\n", MAXPOLLINTERVAL);
!     cnt = 0;
    }
! 
    return(cnt);
  }
diff -crN julius-3.3p3-multipath/libsent/src/adin/adin_tcpip.c julius-3.3p4-multipath/libsent/src/adin/adin_tcpip.c
*** julius-3.3p3-multipath/libsent/src/adin/adin_tcpip.c	Tue Dec  3 11:35:26 2002
--- julius-3.3p4-multipath/libsent/src/adin/adin_tcpip.c	Tue May  6 17:55:38 2003
***************
*** 4,10 ****
  
  /* adin_tcpip.c --- adin via TCP/IP network */
  
! /* $Id: adin_tcpip.c,v 1.4 2002/12/02 06:02:25 ri Exp $ */
  
  /* ignore sampling frequency config. ... incoming speech stream via socket is undoubtedly accepted without qualification.  Be care! */
  
--- 4,10 ----
  
  /* adin_tcpip.c --- adin via TCP/IP network */
  
! /* $Id: adin_tcpip.c,v 1.5 2003/02/25 01:23:47 ri Exp $ */
  
  /* ignore sampling frequency config. ... incoming speech stream via socket is undoubtedly accepted without qualification.  Be care! */
  
***************
*** 87,93 ****
    /* check if some commands are waiting in queue */
    p.fd = adinnet_asd;
    p.events = POLLIN;
!   status = poll(&p, 1, 50);
    if (status < 0) {
      j_printerr("adin_tcpip_read: cannot poll\n");
      return -2;			/* error */
--- 87,93 ----
    /* check if some commands are waiting in queue */
    p.fd = adinnet_asd;
    p.events = POLLIN;
!   status = poll(&p, 1, -1);	/* wait till some data comes */
    if (status < 0) {
      j_printerr("adin_tcpip_read: cannot poll\n");
      return -2;			/* error */
***************
*** 104,111 ****
        last_is_segmented = FALSE;
        return -1;
      }
!   } else {
!     cnt = 0;			/* no data */
    }
    cnt /= sizeof(SP16);
    return cnt;
--- 104,112 ----
        last_is_segmented = FALSE;
        return -1;
      }
!   } else {			/* no data? */
!     j_printerr("adin_tcpip_read: no data?\n");
!     return -2;			/* error */
    }
    cnt /= sizeof(SP16);
    return cnt;
diff -crN julius-3.3p3-multipath/libsent/src/net/server-client.c julius-3.3p4-multipath/libsent/src/net/server-client.c
*** julius-3.3p3-multipath/libsent/src/net/server-client.c	Mon Nov 18 22:05:38 2002
--- julius-3.3p4-multipath/libsent/src/net/server-client.c	Tue May  6 17:55:38 2003
***************
*** 4,10 ****
  
  /* server-client.c --- functions for TCP/IP server & client */
  
! /* $Id: server-client.c,v 1.4 2002/11/06 08:37:06 ri Exp $ */
  
  #include <sent/stddefs.h>
  #include <sent/tcpip.h>
--- 4,10 ----
  
  /* server-client.c --- functions for TCP/IP server & client */
  
! /* $Id: server-client.c,v 1.5 2003/02/25 01:23:47 ri Exp $ */
  
  #include <sent/stddefs.h>
  #include <sent/tcpip.h>
***************
*** 105,111 ****
  accept_from(int sd)
  {
    int asd;
!   
    asd = accept(sd, (struct sockaddr *)&from, &nbyte);
    if (asd < 0) {
      perror("accept_from: accept() error");
--- 105,112 ----
  accept_from(int sd)
  {
    int asd;
! 
!   nbyte = sizeof(struct sockaddr_in);
    asd = accept(sd, (struct sockaddr *)&from, &nbyte);
    if (asd < 0) {
      perror("accept_from: accept() error");
diff -crN julius-3.3p3-multipath/libsent/src/phmm/addlog.c julius-3.3p4-multipath/libsent/src/phmm/addlog.c
*** julius-3.3p3-multipath/libsent/src/phmm/addlog.c	Thu Sep 12 07:12:04 2002
--- julius-3.3p4-multipath/libsent/src/phmm/addlog.c	Tue May  6 17:59:41 2003
***************
*** 115,124 ****
    return(y);
  }
  #endif
- 
- /* return log10(exp10(x)+exp10(y)) */
- LOGPROB
- addlog10(LOGPROB x, LOGPROB y)
- {
-   return(addlog(x * LOGTEN, y * LOGTEN) / LOGTEN);
- }
--- 115,117 ----
diff -crN julius-3.3p3-multipath/libsent/src/phmm/calc_mix.c julius-3.3p4-multipath/libsent/src/phmm/calc_mix.c
*** julius-3.3p3-multipath/libsent/src/phmm/calc_mix.c	Thu Sep 12 07:12:04 2002
--- julius-3.3p4-multipath/libsent/src/phmm/calc_mix.c	Tue May  6 17:58:18 2003
***************
*** 5,11 ****
  /* calc_mix.c --- calculate outprob of mixture */
  /*                       mixture tying is not considered */
  
! /* $Id: calc_mix.c,v 1.2 2002/09/11 22:01:50 ri Exp $ */
  
  #include <sent/stddefs.h>
  #include <sent/htk_hmm.h>
--- 5,11 ----
  /* calc_mix.c --- calculate outprob of mixture */
  /*                       mixture tying is not considered */
  
! /* $Id: calc_mix.c,v 1.3 2003/02/25 01:44:57 ri Exp $ */
  
  #include <sent/stddefs.h>
  #include <sent/htk_hmm.h>
***************
*** 32,36 ****
    }
    logprob = addlog_array(OP_calced_score, OP_calced_num);
    if (logprob <= LOG_ZERO) return LOG_ZERO;
!   return (logprob / LOGTEN);
  }
--- 32,36 ----
    }
    logprob = addlog_array(OP_calced_score, OP_calced_num);
    if (logprob <= LOG_ZERO) return LOG_ZERO;
!   return (logprob / LOG_TEN);
  }
diff -crN julius-3.3p3-multipath/libsent/src/phmm/calc_tied_mix.c julius-3.3p4-multipath/libsent/src/phmm/calc_tied_mix.c
*** julius-3.3p3-multipath/libsent/src/phmm/calc_tied_mix.c	Thu Sep 12 07:12:04 2002
--- julius-3.3p4-multipath/libsent/src/phmm/calc_tied_mix.c	Tue May  6 17:58:30 2003
***************
*** 5,11 ****
  /* calc_tied_mix.c --- calculate outprob of tied mixture */
  /*                     codebook-level cache is enabled */
  
! /* $Id: calc_tied_mix.c,v 1.2 2002/09/11 22:01:50 ri Exp $ */
  
  #include <sent/stddefs.h>
  #include <sent/htk_hmm.h>
--- 5,11 ----
  /* calc_tied_mix.c --- calculate outprob of tied mixture */
  /*                     codebook-level cache is enabled */
  
! /* $Id: calc_tied_mix.c,v 1.3 2003/02/25 01:44:57 ri Exp $ */
  
  #include <sent/stddefs.h>
  #include <sent/htk_hmm.h>
***************
*** 126,130 ****
    }
    logprob = addlog_array(OP_calced_score, OP_calced_num);
    if (logprob <= LOG_ZERO) return LOG_ZERO;
!   return (logprob / LOGTEN);
  }  
--- 126,130 ----
    }
    logprob = addlog_array(OP_calced_score, OP_calced_num);
    if (logprob <= LOG_ZERO) return LOG_ZERO;
!   return (logprob / LOG_TEN);
  }  
diff -crN julius-3.3p3-multipath/libsent/src/phmm/gms_gprune.c julius-3.3p4-multipath/libsent/src/phmm/gms_gprune.c
*** julius-3.3p3-multipath/libsent/src/phmm/gms_gprune.c	Thu Sep 12 07:12:04 2002
--- julius-3.3p4-multipath/libsent/src/phmm/gms_gprune.c	Tue May  6 17:58:58 2003
***************
*** 4,10 ****
  
  /* gms_gprune.c --- compute GMS HMM with Gaussian pruning */
  
! /* $Id: gms_gprune.c,v 1.2 2002/09/11 22:01:50 ri Exp $ */
  
  #include <sent/stddefs.h>
  #include <sent/htk_hmm.h>
--- 4,10 ----
  
  /* gms_gprune.c --- compute GMS HMM with Gaussian pruning */
  
! /* $Id: gms_gprune.c,v 1.3 2003/02/25 01:44:57 ri Exp $ */
  
  #include <sent/stddefs.h>
  #include <sent/htk_hmm.h>
***************
*** 184,190 ****
      *maxi_ret = maxi;
    }
  
!   return((maxprob + stateinfo->bweight[maxi]) / LOGTEN);
  }
    
  #else  /* ~LAST_BEST */
--- 184,190 ----
      *maxi_ret = maxi;
    }
  
!   return((maxprob + stateinfo->bweight[maxi]) / LOG_TEN);
  }
    
  #else  /* ~LAST_BEST */
***************
*** 204,210 ****
        maxi = i;
      }
    }
!   return((maxprob + stateinfo->bweight[maxi]) / LOGTEN);
  }
  #endif
  
--- 204,210 ----
        maxi = i;
      }
    }
!   return((maxprob + stateinfo->bweight[maxi]) / LOG_TEN);
  }
  #endif