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>

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 MAX_FRAGMENT_MSEC   50
 Maximum Data fragment Length in msec.
#define MIN_FRAGMENT_SIZE   256
 Minimum fragment length in bytes.

Functions

boolean adin_mic_standby (int sfreq, void *dummy)
 Device initialization: check device capability and open for recording.
boolean adin_mic_begin ()
 Start recording.
boolean adin_mic_end ()
 Stop recording.
int adin_mic_read (SP16 *buf, int sampnum)
 Read samples from device.

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.

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.

Author:
Akinobu LEE
Date:
Sun Feb 13 16:18:26 2005
Revision
1.2

Definition in file adin_mic_linux_oss.c.


Define Documentation

#define MAX_FRAGMENT_MSEC   50

Maximum Data fragment Length in msec.

Input can be delayed to this time. a maximum of 2^x number smaller than this value will be taken. You can override this value by specifying environment valuable "LATENCY_MSEC".

Definition at line 88 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.

Connection initialization: check connectivity 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 109 of file adin_mic_linux_oss.c.

boolean adin_mic_begin (  ) 

Start recording.

Returns:
TRUE on success, FALSE on failure.

Definition at line 336 of file adin_mic_linux_oss.c.

boolean adin_mic_end (  ) 

Stop recording.

Returns:
TRUE on success, FALSE on failure.

Definition at line 355 of file adin_mic_linux_oss.c.

int adin_mic_read ( SP16 buf,
int  sampnum 
)

Read samples from device.

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 384 of file adin_mic_linux_oss.c.


Generated on Tue Dec 18 16:01:37 2007 for Julius by  doxygen 1.5.4