[Julius-cvs 596] CVS update: julius4/libsent/src/adin

アーカイブの一覧に戻る

sumom****@users***** sumom****@users*****
2011年 2月 8日 (火) 00:15:30 JST


Index: julius4/libsent/src/adin/adin_portaudio.c
diff -u julius4/libsent/src/adin/adin_portaudio.c:1.14 julius4/libsent/src/adin/adin_portaudio.c:1.15
--- julius4/libsent/src/adin/adin_portaudio.c:1.14	Mon Feb  7 13:56:14 2011
+++ julius4/libsent/src/adin/adin_portaudio.c	Tue Feb  8 00:15:30 2011
@@ -56,7 +56,7 @@
  * @author Akinobu LEE
  * @date   Mon Feb 14 12:03:48 2005
  *
- * $Revision: 1.14 $
+ * $Revision: 1.15 $
  * 
  */
 /*
@@ -193,9 +193,9 @@
 }
 
 #ifdef OLDVER
-static PortAudioStream *stream;		///< Stream information
+static PortAudioStream *stream = NULL;		///< Stream information
 #else
-static PaStream *stream;		///< Stream information
+static PaStream *stream = NULL;		///< Stream information
 #endif
 static int srate;		///< Required sampling rate
 
@@ -531,12 +531,14 @@
 
   /* initialize device and open stream */
   if (adin_mic_open(arg) == FALSE) {
+    stream = NULL;
     return(FALSE);
   }
   /* start stream */
   err = Pa_StartStream(stream);
   if (err != paNoError) {
     jlog("Error: adin_portaudio: failed to begin stream: %s\n", Pa_GetErrorText(err));
+    stream = NULL;
     return(FALSE);
   }
   
@@ -553,6 +555,8 @@
 {
   PaError err;
 
+  if (stream == NULL) return(TRUE);
+
   /* stop stream (do not wait callback and buffer flush, stop immediately) */
   err = Pa_AbortStream(stream);
   if (err != paNoError) {
@@ -572,6 +576,8 @@
     return(FALSE);
   }
   
+  stream = NULL;
+  
   return TRUE;
 }
 
@@ -594,6 +600,11 @@
   int avail;
   int len;
 
+  if (stream == NULL) {
+    // stream closed, return error
+    return(-2);
+  }
+
   if (buffer_overflowed) {
     jlog("Error: adin_portaudio: input buffer OVERFLOW, increase INPUT_DELAY_SEC in sent/speech.h\n");
     buffer_overflowed = FALSE;



Julius-cvs メーリングリストの案内
アーカイブの一覧に戻る