libsent/src/adin/adin_mic_linux_alsa.c File Reference

Microphone input on Linux/ALSA. More...

#include <sent/stddefs.h>
#include <sent/adin.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <alsa/asoundlib.h>

Go to the source code of this file.

Defines

#define MAXPOLLINTERVAL   300
 Read timeout in msec.

Functions

static void output_card_info (char *pcm_name, snd_pcm_t *handle)
 Output detailed device information.
boolean adin_alsa_standby (int sfreq, void *dummy)
 Device initialization: check device capability and open for recording.
static int xrun_recovery (snd_pcm_t *handle, int err)
 Error recovery when PCM buffer underrun or suspend.
boolean adin_alsa_begin ()
 Start recording.
boolean adin_alsa_end ()
 Stop recording.
int adin_alsa_read (SP16 *buf, int sampnum)
 Read samples from device.

Variables

static snd_pcm_t * handle
 Audio handler.
static char * pcm_name = "default"
 Name of the PCM device, can be overridden by env ALSADEV.
static int latency = 32
 Lantency time in msec. You can override this value by specifying environment valuable "LATENCY_MSEC".
static boolean need_swap
 Whether samples need byte swap.
static struct pollfd * ufds
 Poll descriptor.
static int count
 Poll descriptor count.


Detailed Description

Microphone input on Linux/ALSA.

Low level I/O functions for microphone input on Linux using Advanced Linux Sound Architechture (ALSA) API, developed on version 0.9.x.

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 alsamixer.

Note that sound card should support 16bit monaural recording, and multiple cards are not supported (in that case the first one will be used).

This file supports alsa version 1.x, and tested on 1.0.13.

The default PCM device name is "default", and can be overwritten by environment variable "ALSADEV".

See also:
http://www.alsa-project.org/
Author:
Akinobu LEE
Date:
Sun Feb 13 16:18:26 2005
Revision
1.9

Definition in file adin_mic_linux_alsa.c.


Function Documentation

static void output_card_info ( char *  pcm_name,
snd_pcm_t *  handle 
) [static]

Output detailed device information.

Parameters:
pcm_name [in] device name string
handle [in] pcm audio handler

Definition at line 95 of file adin_mic_linux_alsa.c.

Referenced by adin_alsa_standby().

boolean adin_alsa_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.

< Pointer to device hardware parameters

Definition at line 163 of file adin_mic_linux_alsa.c.

Referenced by adin_mic_standby(), and adin_select().

static int xrun_recovery ( snd_pcm_t *  handle,
int  err 
) [static]

Error recovery when PCM buffer underrun or suspend.

Parameters:
handle [in] audio handler
err [in] error code
Returns:
0 on success, otherwise the given errno.

Definition at line 385 of file adin_mic_linux_alsa.c.

Referenced by adin_alsa_begin().

boolean adin_alsa_begin (  ) 

Start recording.

Returns:
TRUE on success, FALSE on failure.

Definition at line 412 of file adin_mic_linux_alsa.c.

Referenced by adin_mic_begin(), and adin_select().

boolean adin_alsa_end (  ) 

Stop recording.

Returns:
TRUE on success, FALSE on failure.

Definition at line 465 of file adin_mic_linux_alsa.c.

Referenced by adin_mic_end(), and adin_select().

int adin_alsa_read ( SP16 buf,
int  sampnum 
)

Read samples from device.

Try to read sampnum samples and returns actual number of recorded samples currently available. This function will block until at least one sample can be obtained.

Parameters:
buf [out] samples obtained in this function
sampnum [in] wanted number of samples to be read
Returns:
actural number of read samples, -2 if an error occured.

Definition at line 483 of file adin_mic_linux_alsa.c.

Referenced by adin_mic_read(), and adin_select().


Generated on Thu Jul 23 12:14:19 2009 for Julius by  doxygen 1.5.1