libsent/src/adin/adin_mic_linux_oss.c File Reference

Microphone input on Linux/OSS. More...

#include <sent/stddefs.h>
#include <sent/adin.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <sys/soundcard.h>

Include dependency graph for adin_mic_linux_oss.c:

Go to the source code of this file.

Defines

#define DEFAULT_DEVICE   "/dev/dsp"
 Default device name, can be overridden by AUDIODEV environment variable.
#define FREQALLOWRANGE   200
 Acceptable width of sampling frequency.
#define MAXPOLLINTERVAL   300
 Read timeout in msec.
#define FRAGMENT_POWER   10

Functions

boolean adin_mic_standby (int sfreq, void *dummy)
boolean adin_mic_start ()
boolean adin_mic_stop ()
int adin_mic_read (SP16 *buf, int sampnum)
 Read samples from the daemon.

Variables

static int audio_fd
 Audio descriptor.
static boolean need_swap
 Whether samples need byte swap.
static int frag_size
 Actual data fragment size.
static boolean stereo_rec
 TRUE if stereo recording (use left only).


Detailed Description

Microphone input on Linux/OSS.

Author:
Akinobu LEE
Date:
Sun Feb 13 16:18:26 2005
Low level I/O functions for microphone input on Linux using OSS API. Works on kernel driver, OSS/Linux, ALSA OSS compatible device, and other OSS compatible drivers. This will work on kernel 2.0.x and later.

This OSS API is used by default on Linux machines. If you want another API (like ALSA native, esd, portaudio, spAudio), please specify "--with-mictype=TYPE" options at compilation time to configure script.

Sound card should support 16bit monaural recording. On Linux, however, if you unfortunately have a device with only stereo recording support, Julius will try to get input from the left channel of the stereo input.

Julius does not alter any mixer device setting at all on Linux. You should configure the mixer for recording source (mic/line) and recording volume correctly using other audio tool such as xmixer.

The default device name is "/dev/dsp", which can be changed by setting environment variable AUDIODEV.

Revision
1.3

Definition in file adin_mic_linux_oss.c.


Define Documentation

#define FRAGMENT_POWER   10

Data fragment size. Input will be delayed by 2^X bytes. The default value of 10 means we treat input per a unit of 2~10=1024 bytes, which corresponds to 32 msec in 16kHz sampling.

Definition at line 86 of file adin_mic_linux_oss.c.

Referenced by adin_mic_standby().


Function Documentation

boolean adin_mic_standby ( int  sfreq,
void *  dummy 
)

Device initialization: check device capability and open for recording.

Parameters:
sfreq [in] required sampling frequency.
dummy [in] a dummy data
Returns:
TRUE on success, FALSE on failure.

Definition at line 102 of file adin_mic_linux_oss.c.

boolean adin_mic_start (  ) 

Start recording.

Returns:
TRUE on success, FALSE on failure.

Definition at line 298 of file adin_mic_linux_oss.c.

boolean adin_mic_stop (  ) 

Stop recording.

Returns:
TRUE on success, FALSE on failure.

Definition at line 318 of file adin_mic_linux_oss.c.

int adin_mic_read ( SP16 buf,
int  sampnum 
)

Read samples from the daemon.

Try to read sampnum samples and returns actual number of recorded samples currently available. This function will block at most MAXPOLLINTERVAL msec, until at least one sample can be obtained. If no data has been obtained after waiting for MAXPOLLINTERVAL msec, returns 0.

When stereo input, only left channel will be used.

Parameters:
buf [out] samples obtained in this function
sampnum [in] wanted number of samples to be read
Returns:
actural number of read samples, 0 of no sample has been captured in MAXPOLLINTERVAL msec, -2 if error.

Definition at line 347 of file adin_mic_linux_oss.c.


Generated on Tue Dec 26 12:54:25 2006 for Julian by  doxygen 1.5.0