sumom****@users*****
sumom****@users*****
2008年 7月 1日 (火) 13:29:46 JST
Index: julius4/libsent/src/adin/adin_esd.c diff -u julius4/libsent/src/adin/adin_esd.c:1.2 julius4/libsent/src/adin/adin_esd.c:1.3 --- julius4/libsent/src/adin/adin_esd.c:1.2 Tue Dec 18 17:45:50 2007 +++ julius4/libsent/src/adin/adin_esd.c Tue Jul 1 13:29:46 2008 @@ -21,7 +21,7 @@ * @author Akinobu LEE * @date Sun Feb 13 16:18:26 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -33,13 +33,15 @@ #include <sent/stddefs.h> #include <sent/adin.h> -/* sound header */ -#include <esd.h> +#ifdef HAS_ESD +#include <esd.h> static int sock; ///< Audio socket static char name_buf[ESD_NAME_MAX]; ///< Unique identifier of this process that will be passed to EsounD static int latency = 50; ///< Lantency time in msec +#endif + /** * Connection initialization: check connectivity and open for recording. * @@ -49,8 +51,12 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_standby(int sfreq, void *dummy) +adin_esd_standby(int sfreq, void *dummy) { +#ifndef HAS_ESD + jlog("Error: esd not compiled in\n"); + return FALSE; +#else esd_format_t format = ESD_BITS16 | ESD_MONO | ESD_STREAM | ESD_RECORD; /* generate uniq ID */ @@ -65,6 +71,7 @@ } return TRUE; +#endif } /** @@ -73,7 +80,7 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_begin() +adin_esd_begin() { return(TRUE); } @@ -84,7 +91,7 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_end() +adin_esd_end() { return TRUE; } @@ -102,8 +109,11 @@ * @return actural number of read samples, -2 if an error occured. */ int -adin_mic_read(SP16 *buf, int sampnum) +adin_esd_read(SP16 *buf, int sampnum) { +#ifndef HAS_ESD + return -2; +#else int size, cnt; size = sampnum; @@ -112,11 +122,12 @@ while((cnt = read(sock, buf, size)) <= 0) { if (cnt < 0) { - perror("adin_mic_read: read error\n"); + perror("adin_esd_read: read error\n"); return ( -2 ); } usleep(latency * 1000); } cnt /= sizeof(SP16); return(cnt); +#endif } Index: julius4/libsent/src/adin/adin_mic_linux_alsa.c diff -u julius4/libsent/src/adin/adin_mic_linux_alsa.c:1.5 julius4/libsent/src/adin/adin_mic_linux_alsa.c:1.6 --- julius4/libsent/src/adin/adin_mic_linux_alsa.c:1.5 Thu May 8 14:44:26 2008 +++ julius4/libsent/src/adin/adin_mic_linux_alsa.c Tue Jul 1 13:29:46 2008 @@ -44,7 +44,7 @@ * @author Akinobu LEE * @date Sun Feb 13 16:18:26 2005 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ /* @@ -61,6 +61,8 @@ #include <sys/stat.h> #include <fcntl.h> +#ifdef HAS_ALSA + #ifdef HAVE_ALSA_ASOUNDLIB_H #include <alsa/asoundlib.h> #elif HAVE_SYS_ASOUNDLIB_H @@ -77,7 +79,9 @@ #define MAXPOLLINTERVAL 300 ///< Read timeout in msec. +#endif /* HAS_ALSA */ +#ifdef HAS_ALSA /** * Output detailed device information. * @@ -143,6 +147,7 @@ snd_ctl_close(ctl); } +#endif /* HAS_ALSA */ /** * Device initialization: check device capability and open for recording. @@ -153,8 +158,12 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_standby(int sfreq, void *dummy) +adin_alsa_standby(int sfreq, void *dummy) { +#ifndef HAS_ALSA + jlog("Error: ALSA not compiled in\n"); + return FALSE; +#else int err; snd_pcm_hw_params_t *hwparams; ///< Pointer to device hardware parameters #if (SND_LIB_MAJOR == 0) @@ -358,8 +367,10 @@ output_card_info(pcm_name, handle); return(TRUE); +#endif /* HAS_ALSA */ } +#ifdef HAS_ALSA /** * Error recovery when PCM buffer underrun or suspend. * @@ -388,6 +399,7 @@ } return err; } +#endif /* HAS_ALSA */ /** * Start recording. @@ -395,8 +407,11 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_begin() +adin_alsa_begin() { +#ifndef HAS_ALSA + return FALSE; +#else int err; snd_pcm_state_t status; @@ -433,6 +448,7 @@ } return(TRUE); +#endif /* HAS_ALSA */ } /** @@ -441,7 +457,7 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_end() +adin_alsa_end() { return(TRUE); } @@ -459,8 +475,11 @@ * @return actural number of read samples, -2 if an error occured. */ int -adin_mic_read(SP16 *buf, int sampnum) +adin_alsa_read(SP16 *buf, int sampnum) { +#ifndef HAS_ALSA + return -2; +#else int cnt; #if (SND_LIB_MAJOR == 0) @@ -502,5 +521,7 @@ } return(cnt); +#endif /* HAS_ALSA */ } + /* end of file */ Index: julius4/libsent/src/adin/adin_mic_linux_oss.c diff -u julius4/libsent/src/adin/adin_mic_linux_oss.c:1.3 julius4/libsent/src/adin/adin_mic_linux_oss.c:1.4 --- julius4/libsent/src/adin/adin_mic_linux_oss.c:1.3 Tue Dec 18 17:45:50 2007 +++ julius4/libsent/src/adin/adin_mic_linux_oss.c Tue Jul 1 13:29:46 2008 @@ -51,7 +51,7 @@ * @author Akinobu LEE * @date Sun Feb 13 16:18:26 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -62,8 +62,8 @@ */ #include <sent/stddefs.h> -#include <sent/adin.h> +#include <sent/adin.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> @@ -71,7 +71,13 @@ #include <fcntl.h> /* sound header */ +#ifdef HAS_OSS +#ifdef HAVE_SYS_SOUNDCARD_H #include <sys/soundcard.h> +#elif HAVE_MACHINE_SOUNDCARD_H +#include <machine/soundcard.h> +#endif +#endif /// Default device name, can be overridden by AUDIODEV environment variable #define DEFAULT_DEVICE "/dev/dsp" @@ -106,8 +112,12 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_standby(int sfreq, void *dummy) +adin_oss_standby(int sfreq, void *dummy) { +#ifndef HAS_OSS + jlog("Error: OSS not compiled in\n"); + return FALSE; +#else int fmt, fmt_can, fmt1, fmt2, rfmt; /* sampling format */ int samplerate; /* 16kHz */ char *defaultdev = DEFAULT_DEVICE; /* default device */ @@ -325,6 +335,8 @@ jlog("Stat: adin_oss: audio I/O Latency = %d msec (fragment size = %d samples)\n", frag_size * 1000/ (sfreq * sizeof(SP16)), frag_size / sizeof(SP16)); return TRUE; + +#endif /* HAS_OSS */ } /** @@ -333,7 +345,7 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_begin() +adin_oss_begin() { char buf[4]; /* Read 1 sample (and ignore it) to tell the audio device start recording. @@ -352,7 +364,7 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_end() +adin_oss_end() { /* * Not reset device on each end of speech, just let the buffer overrun... @@ -381,8 +393,11 @@ * MAXPOLLINTERVAL msec, -2 if error. */ int -adin_mic_read(SP16 *buf, int sampnum) +adin_oss_read(SP16 *buf, int sampnum) { +#ifndef HAS_OSS + return -2; +#else int size,cnt,i; audio_buf_info info; fd_set rfds; @@ -434,4 +449,6 @@ } return(cnt); +#endif /* HAS_OSS */ } +