Main Page Compound List File List Compound Members File Members

# cslmain.h File Reference

`#include <csl/csldefs.h>`
`#include <csl/cslutils.h>`

Go to the source code of this file.

## Compounds
struct | _CslMutex
| User-defined mutex object. More...
struct | _CslOptions
| Command line options. More...
## Defines
#define | CSL_DRIVER_NAME_ARTS "arts"
| Symbolic name for aRts driver. More...
#define | CSL_DRIVER_NAME_OSS "oss"
| Symbolic name for OSS driver. More...
## Typedefs
typedef _CslDriver | CslDriver
| CSL Driver handle. More...
typedef _CslMutex | CslMutex
| CSL Mutex. More...
typedef void(* | CslMutexLock )(CslMutex *mutex)
| Mutex lock callback. More...
typedef void(* | CslMutexUnlock )(CslMutex *mutex)
| Mutex unlock callback. More...
typedef void(* | CslMutexDestroy )(CslMutex *mutex)
| Mutex destroy callback. More...
typedef _CslOptions | CslOptions
| Command line options. More...
## Enumerations
enum | CslErrorType { CSL_ENONE, CSL_EINTERN, CSL_ENODRIVER, CSL_ENOIMPL, CSL_EBUSY, CSL_EPERMS, CSL_EIO, CSL_EFMTINVAL, CSL_EGETCAPS, CSL_ECAPSUPPORT, CSL_ESETCAPS }
| CSL return codes. More...
enum | CslDriverCaps { CSL_DRIVER_CAP_PCM = (1 << 0), CSL_DRIVER_CAP_SAMPLE = (1 << 1), CSL_DRIVER_CAP_MIXER = (1 << 2), CSL_DRIVER_CAP_MASK = 0x07 }
| Driver capabilities. More...
## Functions
const char ** | csl_list_drivers (unsigned int *n_backends)
| Return list of drivers. More...
CslErrorType | csl_driver_init (const char *driver_name, CslDriver **driver)
| Initialize the CSL library. More...
CslErrorType | csl_driver_init_mutex (const char *driver_name, CslDriverCaps required_caps, CslMutex *mutex, CslDriver **driver)
| Initialize the CSL library. More...
void | csl_driver_shutdown (CslDriver *driver)
| Shutdown driver. More...
const char * | csl_strerror (CslErrorType error_type)
| Return error description. More...
void | csl_options_parse (CslOptions *options, int *argc_p, char **argv_p[])
| Parse command line options. More...
char * | csl_options_dump (CslOptions *options)
| Dump CSL options. More...
char * | csl_options_describe (unsigned int indent)
| Describe command line options. More...
char * | csl_describe_pcm_format (unsigned int pcm_format)
| Describe a PCM format. More...

## Detailed Description

This file defines most of the CSL driver API functions.

## Define Documentation

#define CSL_DRIVER_NAME_ARTS "arts"

| Symbolic name for aRts driver. Can use this value when calling csl_driver_init or csl_driver_init_mutex. See also: csl_driver_init , csl_driver_init_mutex.

#define CSL_DRIVER_NAME_OSS "oss"

| Symbolic name for OSS driver. Can use this value when calling csl_driver_init or csl_driver_init_mutex. See also: csl_driver_init , csl_driver_init_mutex.

## Typedef Documentation

typedef struct _CslDriver CslDriver

| CSL Driver handle. Opaque type used as a handle to a CSL driver.

typedef struct _CslMutex CslMutex

| CSL Mutex. Data type used for CSL mutual exclusion/locking functions. See also: csl_driver_init_mutex

typedef void(* CslMutexDestroy)(CslMutex *mutex)

| Mutex destroy callback. Function prototype for callback function to mutex destroy function.

typedef void(* CslMutexLock)(CslMutex *mutex)

| Mutex lock callback. Function prototype for callback function to mutex lock function.

typedef void(* CslMutexUnlock)(CslMutex *mutex)

| Mutex unlock callback. Function prototype for callback function to mutex unlock function.

typedef struct _CslOptions CslOptions

| Command line options. Data type for storing CSL command line options.

## Enumeration Type Documentation

enum CslDriverCaps

  | Driver capabilities. CSL driver capabilities. These are used when selecting a driver to be used when calling csl_driver_init_mutex. See also: csl_driver_init_mutex Enumeration values:
  CSL_DRIVER_CAP_PCM |
  CSL_DRIVER_CAP_SAMPLE |
  CSL_DRIVER_CAP_MIXER |
  CSL_DRIVER_CAP_MASK |

enum CslErrorType

  | CSL return codes. CSL error values, returned by most CSL function calls. See also: csl_strerror Enumeration values:
  CSL_ENONE |
  CSL_EINTERN |
  CSL_ENODRIVER |
  CSL_ENOIMPL |
  CSL_EBUSY |
  CSL_EPERMS |
  CSL_EIO |
  CSL_EFMTINVAL |
  CSL_EGETCAPS |
  CSL_ECAPSUPPORT |
  CSL_ESETCAPS |

## Function Documentation

char* csl_describe_pcm_format | ( | unsigned int | format | ) |

  | Describe a PCM format. Given a PCM format value, return a string describing the selected format (e.g. "16bit, little-endian, signed") Parameters:
  pcm_format | The PCM format
Returns: A newly allocated text string describing the format.

CslErrorType csl_driver_init | ( | const char * | driver_name,
|  | CslDriver ** | driver_p
| ) |

  | Initialize the CSL library. Call this function to initialize the CSL library. You need to call this to obtain a handle to a driver before performing any driver functions. For multithreaded applications you should use csl_driver_init_mutex instead. Note: The OSS backend looks at the environment variable OSS_DEVICE, and if defined, uses that for the audio device. Otherwise it uses /dev/dsp. Parameters:
  driver_name | Name of the driver desired. Use NULL to have CSL auto-detect a suitable driver. Pass CSL_DRIVER_NAME_ARTS or CSL_DRIVER_NAME_OSS or the string "arts" or "oss" to select a specific driver.
  driver | Returns driver (which is a pointer to an opaque type) to be used in subsequent CSL calls.
Returns: Error status See also: csl_driver_init_mutex , csl_driver_shutdown

CslErrorType csl_driver_init_mutex | ( | const char * | driver_name,
|  | CslDriverCaps | required_caps,
|  | CslMutex * | mutex,
|  | CslDriver ** | driver_p
| ) |

  | Initialize the CSL library. Call this function to initialize the CSL library. You need to call this to obtain a handle to a driver before performing any driver functions. For non-multithreaded applications you can use csl_driver_init instead. Note: The OSS backend looks at the environment variable OSS_DEVICE, and if defined, uses that for the audio device. Otherwise it uses /dev/dsp. Parameters:
  driver_name | Name of the driver desired. Use NULL to have CSL auto-detect a suitable driver. Pass CSL_DRIVER_NAME_ARTS or CSL_DRIVER_NAME_OSS or the string "arts" or "oss" to select a specific driver.
  required_caps | A set of driver capabilities that you desire, specified as one or more values of type CslDriverCaps bitwise ORed together.
  mutex | A pointer to a variable of type CslMutex which is initialized with the user-defined lock, unlock, and destroy functions for ensuring mutual exclusion. This allows locking to be done in a portable way.
  driver | Returns driver (which is a pointer to an opaque type) to be used in subsequent CSL calls.
Returns: Error status See also: csl_driver_init , csl_driver_shutdown

void csl_driver_shutdown | ( | CslDriver * | driver | ) |

  | Shutdown driver. Shutdown a driver and release any resources associated with it. There is no way of determining if the call was successful. Be sure to close any PCM streams associated with the driver first. Parameters:
  driver | A handle to the driver
See also: csl_driver_init , csl_driver_init_mutex , csl_pcm_close

const char** csl_list_drivers | ( | unsigned int * | n_backends_p | ) |

  | Return list of drivers. Return a list of the available CSL back-end drivers. Parameters:
  n_backends | The number of backends found will be written to the variable pointed to.
Returns: A pointer to the start of the list of driver names (null terminated strings).

char* csl_options_describe | ( | unsigned int | indent | ) |

| Describe command line options. Outputs a usage string describing the command line options supported by csl_parse_options. Typical output is:
     -B, -L          big/little endian
     -s, -u          signed/unsigned samples
     -F              float samples (32bit)
     -w [8|16]       number of bits (width is 16 or 8)
     -c <n_channels> number of channels
     -r <rate>       sampling frequency
     -D <level>      debugging level
  Parameters:
  indent | Number of spaces to pad before the output to support formatting in a usage message.
Returns: String describing the options. See also: csl_parse_options , csl_describe_pcm_format

char* csl_options_dump | ( | CslOptions * | options | ) |

  | Dump CSL options. This function returns a debug string describing the CSL options. Parameters:
  options | Point to CslOptions variable.
Returns: A string describing the options. The strings is dynamically allocated and must be freed using csl_free when no longer needed.

void csl_options_parse | ( | CslOptions * | options,
|  | int * | argc_p,
|  | char ** | argv_p[]
| ) |

  | Parse command line options. Parses the programs command line options and fills in a CslOptions variable. Parameters:
  options | Pointer to options variable in which to store result.
  argv_p | Pointer to number of arguments, typically argc in main()
  argv_p | Pointer to argument pointer, typically argv in main()
See also: csl_describe_options

const char* csl_strerror | ( | CslErrorType | error_type | ) |

  | Return error description. Return a string describing a CSL error code. Parameters:
  error_type | The error code.
Returns: A string describing the error. See also: CslErrorType