GSIPCM(3)

NAME
gsipcm (gsipcm_*) - functions for direct pcm access (part of GSI - general sound interface)

SYNTAX
#include <gsi/gsipcm.h> Link the program with -lgsipcm

DESCRIPTION
N.B. GSIPCM_HW is used below as an abbreviation for gsi_pcm_device_t *hw, gsi_pcm_devicedata_t *hw_status.

int gsipcm_init (GSIPCM_HW, int modus);
    Grabs the pcm device and tries to set DMA mode if requested. returns 0 if init was ok, -1/-2 if unable to set requested write mode (NONE/BUSY; BUSY is returned when the PCM device is busy, NONE when neither write modes are available (e.g. when using NAS, but then we just get BUSY so?? what did I mean here? check if NAS is running? Or if GSI then return GSIPCM_GSI?).

int gsipcm_close (GSIPCM_HW);
    Releases the PCM device and resources that have been allocated.

int gsipcm_set_pcm (GSIPCM_HW, int pcm_samplerate, int pcm_channels, int pcm_type, int pcm_log2_fragsize);
    Returns 0 if parameters set as requested, -1 if another choice had to be made. The best mode that could be set can be obtained from the hardware status structure shown below (if you don't like the results you can retry with other values).

int gsipcm_write_fragment (GSIPCM_HW);
    Returns the number of bytes written

//CHANGE TO int gsipcm_write_fragment(GSIPCM_HW, char *your_buffer); ??
//OR int gsipcm_write_fragment(GSIPCM_HW, char *your_buffer, int bytes); ?? Not recommended (gsipcm_set_pcm will probably be better at handling choices):
int gsipcm_set_fragment (GSIPCM_HW, int pcm_log2_fragsize);
int gsipcm_set_samplerate (GSIPCM_HW, int pcm_samplerate);
int gsipcm_set_channels (GSIPCM_HW, int pcm_channels);
int gsipcm_set_type (GSIPCM_HW, int pcm_type);
These functions call gsipcm_set_pcm using the old paramaters for the other arguments. int gsipcm_set_mode (GSIPCM_HW, int modus);
Set blocking, non-blocking, dma (add blocking fragment mode?). int gsipcm_write_space (GSIPCM_HW);
Returns available space in system output buffer. int gsipcm_read_data (GSIPCM_HW);
Returns available data (bytes recorded) in system input buffer.

DATA STRUCTURES
typedef struct gsi_pcm_devicedata {
    int dev; /* Remove ? */
    int fd;
    int fd_ct;
    int modus; /* DMA, or blocking/non-blocking write. */
    int samplerate;
    int channels;
    int type;
    int byte_order; /* GSI_LITTLE_ENDIAN (lsb first) / GSI_BIG_ENDIAN. */
    int log2_fragsize;
    int fragsize;
    int max_write_space; /* Kernel/API write buffer size. */
    //int max_read_data; /* Kernel/API read buffer size. */
    int buf_size;
    int bps; /* Bytes per sample */
    int samples; /* Number of samples that fit in the current fragment size. */
    unsigned char *fragment; /* Pointer to the fragment (allocated by user program). */
} gsi_pcm_devicedata_t;

SUPPORTED DATA FORMATS
The data formats supported by the gsipcm library are 8 bit mu-law, 8 bit uncompressed and 16 bit MSB/LSB (mono and stereo).

EXAMPLE APPLICATION
Is this really necessary ?

BUGS & UNIMPLEMENTED FEATURES
Probably.

SEE ALSO
gsi(3)

AUTHOR
Wouter Scholten email: whs@xs4all.nl
WWW page: http://www.xs4all.nl/~whs/