ALSA project - the C library reference
Loading...
Searching...
No Matches
cards.c File Reference

Basic Soundcard Operations. More...

Functions

int snd_card_load (int card)
 Try to load the driver for a card.
 
int snd_card_next (int *rcard)
 Iterate over physical sound cards.
 
int snd_card_get_index (const char *string)
 Convert a card string to the card index.
 
int snd_card_get_name (int card, char **name)
 Obtain the card name.
 
int snd_card_get_longname (int card, char **name)
 Obtain the card long name.
 

Detailed Description

Basic Soundcard Operations.

Author
Jaroslav Kysela perex.nosp@m.@per.nosp@m.ex.cz
Date
1998-2001

Function Documentation

◆ snd_card_get_index()

int snd_card_get_index ( const char * string)

Convert a card string to the card index.

This works only for physical sound cards, not for virtual cards.

Parameters
stringA string identifying the card.
Returns
The index of the card. On error, a a negative error code is returned.

The accepted formats for "string" are:

  • The index of the card (as listed in /proc/asound/cards), given as string
  • The ID of the card (as listed in /proc/asound/cards)
  • The control device name (like /dev/snd/controlC0)

◆ snd_card_get_longname()

int snd_card_get_longname ( int card,
char ** name )

Obtain the card long name.

Parameters
cardIndex of the card.
nameResult - card long name corresponding to card index.
Returns
Zero if success, otherwise a negative error code.

The value returned in name is allocated with strdup and should be freed when no longer used.

◆ snd_card_get_name()

int snd_card_get_name ( int card,
char ** name )

Obtain the card name.

Parameters
cardThe index of the card.
nameResult - card name corresponding to card index.
Returns
zero if success, otherwise a negative error code

The value returned in name is allocated with strdup and should be freed when no longer used.

◆ snd_card_load()

int snd_card_load ( int card)

Try to load the driver for a card.

Parameters
cardCard index.
Returns
1 if driver is present, zero if driver is not present.

◆ snd_card_next()

int snd_card_next ( int * rcard)

Iterate over physical sound cards.

This function takes the index of a physical sound card and sets it to the index of the next card. If index is -1, it is set to the index of the first card. After the last card, the index is set to -1.

For example, if you have 2 sound cards (with index 0 and 1), the index will be modified as follows:

  • -1 --> 0
  • 0 --> 1
  • 1 --> -1

This does not work for virtual sound cards.

Parameters
rcardIndex of current card. The index of the next card is stored here.
Returns
zero if success, otherwise a negative error code.