ALSA project - the C library reference
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
Case Interface

Macros

#define SND_USE_CASE_VERB_INACTIVE   "Inactive"
#define SND_USE_CASE_VERB_HIFI   "HiFi"
#define SND_USE_CASE_VERB_HIFI_LOW_POWER   "HiFi Low Power"
#define SND_USE_CASE_VERB_VOICE   "Voice"
#define SND_USE_CASE_VERB_VOICE_LOW_POWER   "Voice Low Power"
#define SND_USE_CASE_VERB_VOICECALL   "Voice Call"
#define SND_USE_CASE_VERB_IP_VOICECALL   "Voice Call IP"
#define SND_USE_CASE_VERB_ANALOG_RADIO   "FM Analog Radio"
#define SND_USE_CASE_VERB_DIGITAL_RADIO   "FM Digital Radio"
#define SND_USE_CASE_DEV_NONE   "None"
#define SND_USE_CASE_DEV_SPEAKER   "Speaker"
#define SND_USE_CASE_DEV_LINE   "Line"
#define SND_USE_CASE_DEV_HEADPHONES   "Headphones"
#define SND_USE_CASE_DEV_HEADSET   "Headset"
#define SND_USE_CASE_DEV_HANDSET   "Handset"
#define SND_USE_CASE_DEV_BLUETOOTH   "Bluetooth"
#define SND_USE_CASE_DEV_EARPIECE   "Earpiece"
#define SND_USE_CASE_DEV_SPDIF   "SPDIF"
#define SND_USE_CASE_DEV_HDMI   "HDMI"
#define SND_USE_CASE_MOD_CAPTURE_VOICE   "Capture Voice"
#define SND_USE_CASE_MOD_CAPTURE_MUSIC   "Capture Music"
#define SND_USE_CASE_MOD_PLAY_MUSIC   "Play Music"
#define SND_USE_CASE_MOD_PLAY_VOICE   "Play Voice"
#define SND_USE_CASE_MOD_PLAY_TONE   "Play Tone"
#define SND_USE_CASE_MOD_ECHO_REF   "Echo Reference"
#define SND_USE_CASE_TQ_MUSIC   "Music"
#define SND_USE_CASE_TQ_VOICE   "Voice"
#define SND_USE_CASE_TQ_TONES   "Tones"

Functions

char * snd_use_case_identifier (const char *fmt,...)
 Create an identifier.
int snd_use_case_free_list (const char *list[], int items)
 Free a string list.
int snd_use_case_get_list (snd_use_case_mgr_t *uc_mgr, const char *identifier, const char **list[])
 Obtain a list of entries.
int snd_use_case_get (snd_use_case_mgr_t *uc_mgr, const char *identifier, const char **value)
 Get current - string.
int snd_use_case_geti (snd_use_case_mgr_t *uc_mgr, const char *identifier, long *value)
 Get current - integer.
int snd_use_case_set (snd_use_case_mgr_t *uc_mgr, const char *identifier, const char *value)
 Set new.
int snd_use_case_mgr_open (snd_use_case_mgr_t **uc_mgr, const char *card_name)
 Open and initialise use case core for sound card.
int snd_use_case_mgr_reload (snd_use_case_mgr_t *uc_mgr)
 Reload and re-parse use case configuration files for sound card.
int snd_use_case_mgr_close (snd_use_case_mgr_t *uc_mgr)
 Close use case manager.
int snd_use_case_mgr_reset (snd_use_case_mgr_t *uc_mgr)
 Reset use case manager verb, device, modifier to deafult settings.

Detailed Description

The ALSA Use Case manager interface. See ALSA Use Case Interface page for more details.

ALSA Use Case Interface

ALSA Use Case InterfaceThe use case manager works by configuring the sound card ALSA kcontrols to change the hardware digital and analog audio routing to match the requested device use case. The use case manager kcontrol configurations are stored in easy to modify text files.An audio use case can be defined by a verb and device parameter. The verb describes the use case action i.e. a phone call, listening to music, recording a conversation etc. The device describes the physical audio capture and playback hardware i.e. headphones, phone handset, bluetooth headset, etc.It's intended clients will mostly only need to set the use case verb and device for each system use case change (as the verb and device parameters cover most audio use cases).However there are times when a use case has to be modified at runtime. e.g.o Incoming phone call when the device is playing music o Recording sections of a phone call o Playing tones during a call.In order to allow asynchronous runtime use case adaptations, we have a third optional modifier parameter that can be used to further configure the use case during live audio runtime.This interface allows clients to :-o Query the supported use case verbs, devices and modifiers for the machine. o Set and Get use case verbs, devices and modifiers for the machine. o Get the ALSA PCM playback and capture device PCMs for use case verb, use case device and modifier. o Get the TQ parameter for each use case verb, use case device and modifier. o Get the ALSA master playback and capture volume/switch kcontrols for each use case.

Macro Definition Documentation

#define SND_USE_CASE_DEV_BLUETOOTH   "Bluetooth"

Bluetooth Device

#define SND_USE_CASE_DEV_EARPIECE   "Earpiece"

Earpiece Device

#define SND_USE_CASE_DEV_HANDSET   "Handset"

Handset Device

#define SND_USE_CASE_DEV_HDMI   "HDMI"

HDMI Device

#define SND_USE_CASE_DEV_HEADPHONES   "Headphones"

Headphones Device

#define SND_USE_CASE_DEV_HEADSET   "Headset"

Headset Device

#define SND_USE_CASE_DEV_LINE   "Line"

Line Device

#define SND_USE_CASE_DEV_NONE   "None"

None Device

#define SND_USE_CASE_DEV_SPDIF   "SPDIF"

SPDIF Device

#define SND_USE_CASE_DEV_SPEAKER   "Speaker"

Speaker Device

#define SND_USE_CASE_MOD_CAPTURE_MUSIC   "Capture Music"

Capture Music Modifier

#define SND_USE_CASE_MOD_CAPTURE_VOICE   "Capture Voice"

Capture Voice Modifier

#define SND_USE_CASE_MOD_ECHO_REF   "Echo Reference"

Echo Reference Modifier

#define SND_USE_CASE_MOD_PLAY_MUSIC   "Play Music"

Play Music Modifier

#define SND_USE_CASE_MOD_PLAY_TONE   "Play Tone"

Play Tone Modifier

#define SND_USE_CASE_MOD_PLAY_VOICE   "Play Voice"

Play Voice Modifier

#define SND_USE_CASE_TQ_MUSIC   "Music"

TQ - Tone Quality

The interface allows clients to determine the audio TQ required for each use case verb and modifier. It's intended as an optional hint to the audio driver in order to lower power consumption. Music Tone Quality

#define SND_USE_CASE_TQ_TONES   "Tones"

Tones Tone Quality

#define SND_USE_CASE_TQ_VOICE   "Voice"

Voice Tone Quality

#define SND_USE_CASE_VERB_ANALOG_RADIO   "FM Analog Radio"

FM Analog Radio Verb

#define SND_USE_CASE_VERB_DIGITAL_RADIO   "FM Digital Radio"

FM Digital Radio Verb

#define SND_USE_CASE_VERB_HIFI   "HiFi"

HiFi Verb

#define SND_USE_CASE_VERB_HIFI_LOW_POWER   "HiFi Low Power"

HiFi Low Power Verb

#define SND_USE_CASE_VERB_INACTIVE   "Inactive"

Inactive Verb

#define SND_USE_CASE_VERB_IP_VOICECALL   "Voice Call IP"

Voice Call IP Verb

#define SND_USE_CASE_VERB_VOICE   "Voice"

Voice Verb

#define SND_USE_CASE_VERB_VOICE_LOW_POWER   "Voice Low Power"

Voice Low Power Verb

#define SND_USE_CASE_VERB_VOICECALL   "Voice Call"

Voice Call Verb


Function Documentation

int snd_use_case_free_list ( const char *  list[],
int  items 
)

Free a string list.

Parameters:
listThe string list to free
itemsCount of strings
Returns:
Zero if success, otherwise a negative error code
int snd_use_case_get ( snd_use_case_mgr_t *  uc_mgr,
const char *  identifier,
const char **  value 
)

Get current - string.

Parameters:
uc_mgrUse case manager
identifier
valueValue pointer
Returns:
Zero if success, otherwise a negative error code

Note: String is dynamically allocated, use free() to deallocate this string.

Known identifiers: NULL - return current card _verb - return current verb

[=]{NAME}[/[{modifier}|{/device}][/{verb}]]

  • value identifier {NAME}
  • Search starts at given modifier or device if any, else at a verb
  • Search starts at given verb if any, else current verb
  • Searches modifier/device, then verb, then defaults
  • Specify a leading "=" to search only the exact device/modifier/verb specified, and not search through each object in turn.
  • Examples: "PlaybackPCM/Play Music" "CapturePCM/SPDIF" From ValueDefaults only: "=Variable" From current active verb: "=Variable//" From verb "Verb": "=Variable//Verb" From "Modifier" in current active verb: "=Variable/Modifier/" From "Modifier" in "Verb": "=Variable/Modifier/Verb"

Recommended names for values: TQ - Tone Quality PlaybackPCM - full PCM playback device name CapturePCM - full PCM capture device name PlaybackRate - playback device sample rate PlaybackChannels - playback device channel count PlaybackCTL - playback control device name PlaybackVolume - playback control volume ID string PlaybackSwitch - playback control switch ID string CaptureRate - capture device sample rate CaptureChannels - capture device channel count CaptureCTL - capture control device name CaptureVolume - capture control volume ID string CaptureSwitch - capture control switch ID string PlaybackMixer - name of playback mixer PlaybackMixerID - mixer playback ID CaptureMixer - name of capture mixer CaptureMixerID - mixer capture ID

Parameters:
uc_mgrUse case manager
identifier
valueValue pointer
Returns:
Zero if success, otherwise a negative error code

Note: String is dynamically allocated, use free() to deallocate this string.

int snd_use_case_get_list ( snd_use_case_mgr_t *  uc_mgr,
const char *  identifier,
const char **  list[] 
)

Obtain a list of entries.

Parameters:
uc_mgrUse case manager (may be NULL - card list)
identifier(may be NULL - card list)
listReturned allocated list
Returns:
Number of list entries if success, otherwise a negative error code

Defined identifiers: NULL - get card list (in pair cardname+comment) _verbs - get verb list (in pair verb+comment) _devices[/{verb}] - get list of supported devices (in pair device+comment) _modifiers[/{verb}]- get list of supported modifiers (in pair modifier+comment) TQ[/{verb}] - get list of TQ identifiers _enadevs - get list of enabled devices _enamods - get list of enabled modifiers

_supporteddevs/{modifier}|{device}[/{verb}] - list of supported devices _conflictingdevs/{modifier}|{device}[/{verb}] - list of conflicting devices Note that at most one of the supported/conflicting devs lists has any entries, and when neither is present, all devices are supported.

Parameters:
uc_mgrUse case manager (may be NULL - card list)
identifier(may be NULL - card list)
listReturned allocated list
Returns:
Number of list entries if success, otherwise a negative error code
int snd_use_case_geti ( snd_use_case_mgr_t *  uc_mgr,
const char *  identifier,
long *  value 
)

Get current - integer.

Parameters:
uc_mgrUse case manager
identifier
valueresult
Returns:
Zero if success, otherwise a negative error code

Known identifiers: _devstatus/{device} - return status for given device _modstatus/{modifier} - return status for given modifier

Parameters:
uc_mgrUse case manager
identifier
Returns:
Value if success, otherwise a negative error code
char* snd_use_case_identifier ( const char *  fmt,
  ... 
)

Create an identifier.

Parameters:
fmtFormat (sprintf like)
...Optional arguments for sprintf like format
Returns:
Allocated string identifier or NULL on error
int snd_use_case_mgr_close ( snd_use_case_mgr_t *  uc_mgr)

Close use case manager.

Parameters:
uc_mgrUse case manager
Returns:
zero if success, otherwise a negative error code
Parameters:
uc_mgrUse case manager
Returns:
zero on success, otherwise a negative error code
int snd_use_case_mgr_open ( snd_use_case_mgr_t **  uc_mgr,
const char *  card_name 
)

Open and initialise use case core for sound card.

Parameters:
uc_mgrReturned use case manager pointer
card_nameSound card name.
Returns:
zero if success, otherwise a negative error code

Open and initialise use case core for sound card.

Parameters:
uc_mgrReturned use case manager pointer
card_namename of card to open
Returns:
zero on success, otherwise a negative error code
int snd_use_case_mgr_reload ( snd_use_case_mgr_t *  uc_mgr)

Reload and re-parse use case configuration files for sound card.

Parameters:
uc_mgrUse case manager
Returns:
zero if success, otherwise a negative error code

Reload and re-parse use case configuration files for sound card.

Parameters:
uc_mgrUse case manager
Returns:
zero on success, otherwise a negative error code
int snd_use_case_mgr_reset ( snd_use_case_mgr_t *  uc_mgr)

Reset use case manager verb, device, modifier to deafult settings.

Parameters:
uc_mgrUse case manager
Returns:
zero if success, otherwise a negative error code

Reset use case manager verb, device, modifier to deafult settings.

Parameters:
uc_mgrUse case manager
Returns:
zero on success, otherwise a negative error code
int snd_use_case_set ( snd_use_case_mgr_t *  uc_mgr,
const char *  identifier,
const char *  value 
)

Set new.

Parameters:
uc_mgrUse case manager
identifier
valueValue
Returns:
Zero if success, otherwise a negative error code

Known identifiers: _verb - set current verb = value _enadev - enable given device = value _disdev - disable given device = value _swdev/{old_device} - new_device = value

  • disable old_device and then enable new_device
  • if old_device is not enabled just return
  • check transmit sequence firstly _enamod - enable given modifier = value _dismod - disable given modifier = value _swmod/{old_modifier} - new_modifier = value
  • disable old_modifier and then enable new_modifier
  • if old_modifier is not enabled just return
  • check transmit sequence firstly
Parameters:
uc_mgrUse case manager
identifier
valueValue
Returns:
Zero if success, otherwise a negative error code