From 7893ea238d5ae042dc2e689f049da0f512d3b415 Mon Sep 17 00:00:00 2001 From: Abramo Bagnara Date: Mon, 26 Mar 2001 12:45:48 +0000 Subject: [PATCH] Added mode argument to open functions where it was missing. First part of CTL documentation --- aserver/aserver.c | 2 +- include/control.h | 258 ++++++++++++++++++-------------- include/mixer.h | 2 +- include/timer.h | 2 +- src/control/cards.c | 6 +- src/control/control.c | 286 ++++++++++++++++++++++++++++++++++-- src/control/control_hw.c | 12 +- src/control/control_local.h | 6 +- src/control/control_shm.c | 8 +- src/control/defaults.c | 4 +- src/control/hcontrol.c | 4 +- src/input.c | 4 +- src/mixer/mixer.c | 4 +- src/output.c | 4 +- src/pcm/pcm.c | 198 ++++++++++++------------- src/pcm/pcm_hw.c | 2 +- src/pcm/pcm_meter.c | 6 +- src/pcm/pcm_params.c | 2 +- src/rawmidi/rawmidi.c | 32 ++-- src/rawmidi/rawmidi_hw.c | 2 +- src/timer/timer.c | 2 +- 21 files changed, 570 insertions(+), 276 deletions(-) diff --git a/aserver/aserver.c b/aserver/aserver.c index d3281f9e..e46cc5d5 100644 --- a/aserver/aserver.c +++ b/aserver/aserver.c @@ -499,7 +499,7 @@ int ctl_shm_open(client_t *client, int *cookie) snd_ctl_t *ctl; int err; int result; - err = snd_ctl_open(&ctl, client->name); + err = snd_ctl_open(&ctl, client->name, SND_CTL_NONBLOCK); if (err < 0) return err; client->device.control.handle = ctl; diff --git a/include/control.h b/include/control.h index c8e7bd00..5ae53f39 100644 --- a/include/control.h +++ b/include/control.h @@ -6,138 +6,170 @@ ****************************************************************************/ typedef struct sndrv_aes_iec958 snd_aes_iec958_t; + +/** CTL card info container */ typedef struct _snd_ctl_card_info snd_ctl_card_info_t; + +/** CTL element identificator container */ typedef struct _snd_ctl_elem_id snd_ctl_elem_id_t; + +/** CTL element identificator list container */ typedef struct _snd_ctl_elem_list snd_ctl_elem_list_t; + +/** CTL element info container */ typedef struct _snd_ctl_elem_info snd_ctl_elem_info_t; + +/** CTL element value container */ typedef struct _snd_ctl_elem_value snd_ctl_elem_value_t; + +/** CTL event container */ typedef struct _snd_ctl_event snd_ctl_event_t; -#ifdef SND_ENUM_TYPECHECK -typedef struct __snd_card_type *snd_card_type_t; -typedef struct __snd_ctl_elem_type *snd_ctl_elem_type_t; -typedef struct __snd_ctl_elem_iface *snd_ctl_elem_iface_t; -typedef struct __snd_ctl_event_type *snd_ctl_event_type_t; -#else -typedef enum sndrv_card_type snd_card_type_t; -typedef enum sndrv_ctl_elem_type snd_ctl_elem_type_t; -typedef enum sndrv_ctl_elem_iface snd_ctl_elem_iface_t; -typedef enum sndrv_ctl_event_type snd_ctl_event_type_t; -#endif +/** Card type */ +typedef enum _snd_card_type { + SND_CARD_TYPE_GUS_CLASSIC = SNDRV_CARD_TYPE_GUS_CLASSIC, + SND_CARD_TYPE_GUS_EXTREME = SNDRV_CARD_TYPE_GUS_EXTREME, + SND_CARD_TYPE_GUS_ACE = SNDRV_CARD_TYPE_GUS_ACE, + SND_CARD_TYPE_GUS_MAX = SNDRV_CARD_TYPE_GUS_MAX, + SND_CARD_TYPE_AMD_INTERWAVE = SNDRV_CARD_TYPE_AMD_INTERWAVE, + SND_CARD_TYPE_SB_10 = SNDRV_CARD_TYPE_SB_10, + SND_CARD_TYPE_SB_20 = SNDRV_CARD_TYPE_SB_20, + SND_CARD_TYPE_SB_PRO = SNDRV_CARD_TYPE_SB_PRO, + SND_CARD_TYPE_SB_16 = SNDRV_CARD_TYPE_SB_16, + SND_CARD_TYPE_SB_AWE = SNDRV_CARD_TYPE_SB_AWE, + SND_CARD_TYPE_ESS_ES1688 = SNDRV_CARD_TYPE_ESS_ES1688, + SND_CARD_TYPE_OPL3_SA2 = SNDRV_CARD_TYPE_OPL3_SA2, + SND_CARD_TYPE_MOZART = SNDRV_CARD_TYPE_MOZART, + SND_CARD_TYPE_S3_SONICVIBES = SNDRV_CARD_TYPE_S3_SONICVIBES, + SND_CARD_TYPE_ENS1370 = SNDRV_CARD_TYPE_ENS1370, + SND_CARD_TYPE_ENS1371 = SNDRV_CARD_TYPE_ENS1371, + SND_CARD_TYPE_CS4232 = SNDRV_CARD_TYPE_CS4232, + SND_CARD_TYPE_CS4236 = SNDRV_CARD_TYPE_CS4236, + SND_CARD_TYPE_AMD_INTERWAVE_STB = SNDRV_CARD_TYPE_AMD_INTERWAVE_STB, + SND_CARD_TYPE_ESS_ES1938 = SNDRV_CARD_TYPE_ESS_ES1938, + SND_CARD_TYPE_ESS_ES18XX = SNDRV_CARD_TYPE_ESS_ES18XX, + SND_CARD_TYPE_CS4231 = SNDRV_CARD_TYPE_CS4231, + SND_CARD_TYPE_OPTI92X = SNDRV_CARD_TYPE_OPTI92X, + SND_CARD_TYPE_SERIAL = SNDRV_CARD_TYPE_SERIAL, + SND_CARD_TYPE_AD1848 = SNDRV_CARD_TYPE_AD1848, + SND_CARD_TYPE_TRID4DWAVEDX = SNDRV_CARD_TYPE_TRID4DWAVEDX, + SND_CARD_TYPE_TRID4DWAVENX = SNDRV_CARD_TYPE_TRID4DWAVENX, + SND_CARD_TYPE_SGALAXY = SNDRV_CARD_TYPE_SGALAXY, + SND_CARD_TYPE_CS46XX = SNDRV_CARD_TYPE_CS46XX, + SND_CARD_TYPE_WAVEFRONT = SNDRV_CARD_TYPE_WAVEFRONT, + SND_CARD_TYPE_TROPEZ = SNDRV_CARD_TYPE_TROPEZ, + SND_CARD_TYPE_TROPEZPLUS = SNDRV_CARD_TYPE_TROPEZPLUS, + SND_CARD_TYPE_MAUI = SNDRV_CARD_TYPE_MAUI, + SND_CARD_TYPE_CMI8330 = SNDRV_CARD_TYPE_CMI8330, + SND_CARD_TYPE_DUMMY = SNDRV_CARD_TYPE_DUMMY, + SND_CARD_TYPE_ALS100 = SNDRV_CARD_TYPE_ALS100, + SND_CARD_TYPE_SHARE = SNDRV_CARD_TYPE_SHARE, + SND_CARD_TYPE_SI_7018 = SNDRV_CARD_TYPE_SI_7018, + SND_CARD_TYPE_OPTI93X = SNDRV_CARD_TYPE_OPTI93X, + SND_CARD_TYPE_MTPAV = SNDRV_CARD_TYPE_MTPAV, + SND_CARD_TYPE_VIRMIDI = SNDRV_CARD_TYPE_VIRMIDI, + SND_CARD_TYPE_EMU10K1 = SNDRV_CARD_TYPE_EMU10K1, + SND_CARD_TYPE_HAMMERFALL = SNDRV_CARD_TYPE_HAMMERFALL, + SND_CARD_TYPE_HAMMERFALL_LIGHT = SNDRV_CARD_TYPE_HAMMERFALL_LIGHT, + SND_CARD_TYPE_ICE1712 = SNDRV_CARD_TYPE_ICE1712, + SND_CARD_TYPE_CMI8338 = SNDRV_CARD_TYPE_CMI8338, + SND_CARD_TYPE_CMI8738 = SNDRV_CARD_TYPE_CMI8738, + SND_CARD_TYPE_AD1816A = SNDRV_CARD_TYPE_AD1816A, + SND_CARD_TYPE_INTEL8X0 = SNDRV_CARD_TYPE_INTEL8X0, + SND_CARD_TYPE_ESS_ESOLDM1 = SNDRV_CARD_TYPE_ESS_ESOLDM1, + SND_CARD_TYPE_ESS_ES1968 = SNDRV_CARD_TYPE_ESS_ES1968, + SND_CARD_TYPE_ESS_ES1978 = SNDRV_CARD_TYPE_ESS_ES1978, + SND_CARD_TYPE_DIGI96 = SNDRV_CARD_TYPE_DIGI96, + SND_CARD_TYPE_VIA82C686A = SNDRV_CARD_TYPE_VIA82C686A, + SND_CARD_TYPE_FM801 = SNDRV_CARD_TYPE_FM801, + SND_CARD_TYPE_AZT2320 = SNDRV_CARD_TYPE_AZT2320, + SND_CARD_TYPE_PRODIF_PLUS = SNDRV_CARD_TYPE_PRODIF_PLUS, + SND_CARD_TYPE_YMFPCI = SNDRV_CARD_TYPE_YMFPCI, + SND_CARD_TYPE_CS4281 = SNDRV_CARD_TYPE_CS4281, + SND_CARD_TYPE_MPU401_UART = SNDRV_CARD_TYPE_MPU401_UART, + SND_CARD_TYPE_ALS4000 = SNDRV_CARD_TYPE_ALS4000, + SND_CARD_TYPE_ALLEGRO_1 = SNDRV_CARD_TYPE_ALLEGRO_1, + SND_CARD_TYPE_ALLEGRO = SNDRV_CARD_TYPE_ALLEGRO, + SND_CARD_TYPE_MAESTRO3 = SNDRV_CARD_TYPE_MAESTRO3, + SND_CARD_TYPE_AWACS = SNDRV_CARD_TYPE_AWACS, + SND_CARD_TYPE_NM256AV = SNDRV_CARD_TYPE_NM256AV, + SND_CARD_TYPE_NM256ZX = SNDRV_CARD_TYPE_NM256ZX, + SND_CARD_TYPE_VIA8233 = SNDRV_CARD_TYPE_VIA8233, + SND_CARD_TYPE_LAST = SNDRV_CARD_TYPE_LAST, +} snd_card_type_t; + +/** CTL element type */ +typedef enum _snd_ctl_elem_type { + /** Invalid type */ + SND_CTL_ELEM_TYPE_NONE = SNDRV_CTL_ELEM_TYPE_NONE, + /** Boolean contents */ + SND_CTL_ELEM_TYPE_BOOLEAN = SNDRV_CTL_ELEM_TYPE_BOOLEAN, + /** Integer contents */ + SND_CTL_ELEM_TYPE_INTEGER = SNDRV_CTL_ELEM_TYPE_INTEGER, + /** Enumerated contents */ + SND_CTL_ELEM_TYPE_ENUMERATED = SNDRV_CTL_ELEM_TYPE_ENUMERATED, + /** Bytes contents */ + SND_CTL_ELEM_TYPE_BYTES = SNDRV_CTL_ELEM_TYPE_BYTES, + /** IEC958 (S/PDIF) setting content */ + SND_CTL_ELEM_TYPE_IEC958 = SNDRV_CTL_ELEM_TYPE_IEC958, + SND_CTL_ELEM_TYPE_LAST = SNDRV_CTL_ELEM_TYPE_LAST, +} snd_ctl_elem_type_t; + +/** CTL related interface */ +typedef enum _snd_ctl_elem_iface { + /** Card level */ + SND_CTL_ELEM_IFACE_CARD = SNDRV_CTL_ELEM_IFACE_CARD, + /** Hardware dependent device */ + SND_CTL_ELEM_IFACE_HWDEP = SNDRV_CTL_ELEM_IFACE_HWDEP, + /** Mixer */ + SND_CTL_ELEM_IFACE_MIXER = SNDRV_CTL_ELEM_IFACE_MIXER, + /** PCM */ + SND_CTL_ELEM_IFACE_PCM = SNDRV_CTL_ELEM_IFACE_PCM, + /** RawMidi */ + SND_CTL_ELEM_IFACE_RAWMIDI = SNDRV_CTL_ELEM_IFACE_RAWMIDI, + /** Timer */ + SND_CTL_ELEM_IFACE_TIMER = SNDRV_CTL_ELEM_IFACE_TIMER, + /** Sequencer */ + SND_CTL_ELEM_IFACE_SEQUENCER = SNDRV_CTL_ELEM_IFACE_SEQUENCER, + SND_CTL_ELEM_IFACE_LAST = SNDRV_CTL_ELEM_IFACE_LAST, +} snd_ctl_elem_iface_t; -#define SND_CARD_TYPE_GUS_CLASSIC ((snd_card_type_t) SNDRV_CARD_TYPE_GUS_CLASSIC) -#define SND_CARD_TYPE_GUS_EXTREME ((snd_card_type_t) SNDRV_CARD_TYPE_GUS_EXTREME) -#define SND_CARD_TYPE_GUS_ACE ((snd_card_type_t) SNDRV_CARD_TYPE_GUS_ACE) -#define SND_CARD_TYPE_GUS_MAX ((snd_card_type_t) SNDRV_CARD_TYPE_GUS_MAX) -#define SND_CARD_TYPE_AMD_INTERWAVE ((snd_card_type_t) SNDRV_CARD_TYPE_AMD_INTERWAVE) -#define SND_CARD_TYPE_SB_10 ((snd_card_type_t) SNDRV_CARD_TYPE_SB_10) -#define SND_CARD_TYPE_SB_20 ((snd_card_type_t) SNDRV_CARD_TYPE_SB_20) -#define SND_CARD_TYPE_SB_PRO ((snd_card_type_t) SNDRV_CARD_TYPE_SB_PRO) -#define SND_CARD_TYPE_SB_16 ((snd_card_type_t) SNDRV_CARD_TYPE_SB_16) -#define SND_CARD_TYPE_SB_AWE ((snd_card_type_t) SNDRV_CARD_TYPE_SB_AWE) -#define SND_CARD_TYPE_ESS_ES1688 ((snd_card_type_t) SNDRV_CARD_TYPE_ESS_ES1688) -#define SND_CARD_TYPE_OPL3_SA2 ((snd_card_type_t) SNDRV_CARD_TYPE_OPL3_SA2) -#define SND_CARD_TYPE_MOZART ((snd_card_type_t) SNDRV_CARD_TYPE_MOZART) -#define SND_CARD_TYPE_S3_SONICVIBES ((snd_card_type_t) SNDRV_CARD_TYPE_S3_SONICVIBES) -#define SND_CARD_TYPE_ENS1370 ((snd_card_type_t) SNDRV_CARD_TYPE_ENS1370) -#define SND_CARD_TYPE_ENS1371 ((snd_card_type_t) SNDRV_CARD_TYPE_ENS1371) -#define SND_CARD_TYPE_CS4232 ((snd_card_type_t) SNDRV_CARD_TYPE_CS4232) -#define SND_CARD_TYPE_CS4236 ((snd_card_type_t) SNDRV_CARD_TYPE_CS4236) -#define SND_CARD_TYPE_AMD_INTERWAVE_STB ((snd_card_type_t) SNDRV_CARD_TYPE_AMD_INTERWAVE_STB) -#define SND_CARD_TYPE_ESS_ES1938 ((snd_card_type_t) SNDRV_CARD_TYPE_ESS_ES1938) -#define SND_CARD_TYPE_ESS_ES18XX ((snd_card_type_t) SNDRV_CARD_TYPE_ESS_ES18XX) -#define SND_CARD_TYPE_CS4231 ((snd_card_type_t) SNDRV_CARD_TYPE_CS4231) -#define SND_CARD_TYPE_OPTI92X ((snd_card_type_t) SNDRV_CARD_TYPE_OPTI92X) -#define SND_CARD_TYPE_SERIAL ((snd_card_type_t) SNDRV_CARD_TYPE_SERIAL) -#define SND_CARD_TYPE_AD1848 ((snd_card_type_t) SNDRV_CARD_TYPE_AD1848) -#define SND_CARD_TYPE_TRID4DWAVEDX ((snd_card_type_t) SNDRV_CARD_TYPE_TRID4DWAVEDX) -#define SND_CARD_TYPE_TRID4DWAVENX ((snd_card_type_t) SNDRV_CARD_TYPE_TRID4DWAVENX) -#define SND_CARD_TYPE_SGALAXY ((snd_card_type_t) SNDRV_CARD_TYPE_SGALAXY) -#define SND_CARD_TYPE_CS46XX ((snd_card_type_t) SNDRV_CARD_TYPE_CS46XX) -#define SND_CARD_TYPE_WAVEFRONT ((snd_card_type_t) SNDRV_CARD_TYPE_WAVEFRONT) -#define SND_CARD_TYPE_TROPEZ ((snd_card_type_t) SNDRV_CARD_TYPE_TROPEZ) -#define SND_CARD_TYPE_TROPEZPLUS ((snd_card_type_t) SNDRV_CARD_TYPE_TROPEZPLUS) -#define SND_CARD_TYPE_MAUI ((snd_card_type_t) SNDRV_CARD_TYPE_MAUI) -#define SND_CARD_TYPE_CMI8330 ((snd_card_type_t) SNDRV_CARD_TYPE_CMI8330) -#define SND_CARD_TYPE_DUMMY ((snd_card_type_t) SNDRV_CARD_TYPE_DUMMY) -#define SND_CARD_TYPE_ALS100 ((snd_card_type_t) SNDRV_CARD_TYPE_ALS100) -#define SND_CARD_TYPE_SHARE ((snd_card_type_t) SNDRV_CARD_TYPE_SHARE) -#define SND_CARD_TYPE_SI_7018 ((snd_card_type_t) SNDRV_CARD_TYPE_SI_7018) -#define SND_CARD_TYPE_OPTI93X ((snd_card_type_t) SNDRV_CARD_TYPE_OPTI93X) -#define SND_CARD_TYPE_MTPAV ((snd_card_type_t) SNDRV_CARD_TYPE_MTPAV) -#define SND_CARD_TYPE_VIRMIDI ((snd_card_type_t) SNDRV_CARD_TYPE_VIRMIDI) -#define SND_CARD_TYPE_EMU10K1 ((snd_card_type_t) SNDRV_CARD_TYPE_EMU10K1) -#define SND_CARD_TYPE_HAMMERFALL ((snd_card_type_t) SNDRV_CARD_TYPE_HAMMERFALL) -#define SND_CARD_TYPE_HAMMERFALL_LIGHT ((snd_card_type_t) SNDRV_CARD_TYPE_HAMMERFALL_LIGHT) -#define SND_CARD_TYPE_ICE1712 ((snd_card_type_t) SNDRV_CARD_TYPE_ICE1712) -#define SND_CARD_TYPE_CMI8338 ((snd_card_type_t) SNDRV_CARD_TYPE_CMI8338) -#define SND_CARD_TYPE_CMI8738 ((snd_card_type_t) SNDRV_CARD_TYPE_CMI8738) -#define SND_CARD_TYPE_AD1816A ((snd_card_type_t) SNDRV_CARD_TYPE_AD1816A) -#define SND_CARD_TYPE_INTEL8X0 ((snd_card_type_t) SNDRV_CARD_TYPE_INTEL8X0) -#define SND_CARD_TYPE_ESS_ESOLDM1 ((snd_card_type_t) SNDRV_CARD_TYPE_ESS_ESOLDM1) -#define SND_CARD_TYPE_ESS_ES1968 ((snd_card_type_t) SNDRV_CARD_TYPE_ESS_ES1968) -#define SND_CARD_TYPE_ESS_ES1978 ((snd_card_type_t) SNDRV_CARD_TYPE_ESS_ES1978) -#define SND_CARD_TYPE_DIGI96 ((snd_card_type_t) SNDRV_CARD_TYPE_DIGI96) -#define SND_CARD_TYPE_VIA82C686A ((snd_card_type_t) SNDRV_CARD_TYPE_VIA82C686A) -#define SND_CARD_TYPE_FM801 ((snd_card_type_t) SNDRV_CARD_TYPE_FM801) -#define SND_CARD_TYPE_AZT2320 ((snd_card_type_t) SNDRV_CARD_TYPE_AZT2320) -#define SND_CARD_TYPE_PRODIF_PLUS ((snd_card_type_t) SNDRV_CARD_TYPE_PRODIF_PLUS) -#define SND_CARD_TYPE_YMFPCI ((snd_card_type_t) SNDRV_CARD_TYPE_YMFPCI) -#define SND_CARD_TYPE_CS4281 ((snd_card_type_t) SNDRV_CARD_TYPE_CS4281) -#define SND_CARD_TYPE_MPU401_UART ((snd_card_type_t) SNDRV_CARD_TYPE_MPU401_UART) -#define SND_CARD_TYPE_ALS4000 ((snd_card_type_t) SNDRV_CARD_TYPE_ALS4000) -#define SND_CARD_TYPE_ALLEGRO_1 ((snd_card_type_t) SNDRV_CARD_TYPE_ALLEGRO_1) -#define SND_CARD_TYPE_ALLEGRO ((snd_card_type_t) SNDRV_CARD_TYPE_ALLEGRO) -#define SND_CARD_TYPE_MAESTRO3 ((snd_card_type_t) SNDRV_CARD_TYPE_MAESTRO3) -#define SND_CARD_TYPE_AWACS ((snd_card_type_t) SNDRV_CARD_TYPE_AWACS) -#define SND_CARD_TYPE_NM256AV ((snd_card_type_t) SNDRV_CARD_TYPE_NM256AV) -#define SND_CARD_TYPE_NM256ZX ((snd_card_type_t) SNDRV_CARD_TYPE_NM256ZX) -#define SND_CARD_TYPE_VIA8233 ((snd_card_type_t) SNDRV_CARD_TYPE_VIA8233) -#define SND_CARD_TYPE_LAST ((snd_card_type_t) SNDRV_CARD_TYPE_LAST) - -#define SND_CTL_ELEM_TYPE_NONE ((snd_ctl_elem_type_t) SNDRV_CTL_ELEM_TYPE_NONE) -#define SND_CTL_ELEM_TYPE_BOOLEAN ((snd_ctl_elem_type_t) SNDRV_CTL_ELEM_TYPE_BOOLEAN) -#define SND_CTL_ELEM_TYPE_INTEGER ((snd_ctl_elem_type_t) SNDRV_CTL_ELEM_TYPE_INTEGER) -#define SND_CTL_ELEM_TYPE_ENUMERATED ((snd_ctl_elem_type_t) SNDRV_CTL_ELEM_TYPE_ENUMERATED) -#define SND_CTL_ELEM_TYPE_BYTES ((snd_ctl_elem_type_t) SNDRV_CTL_ELEM_TYPE_BYTES) -#define SND_CTL_ELEM_TYPE_IEC958 ((snd_ctl_elem_type_t) SNDRV_CTL_ELEM_TYPE_IEC958) -#define SND_CTL_ELEM_TYPE_LAST ((snd_ctl_elem_type_t) SNDRV_CTL_ELEM_TYPE_LAST) - -#define SND_CTL_ELEM_IFACE_CARD ((snd_ctl_elem_iface_t) SNDRV_CTL_ELEM_IFACE_CARD) -#define SND_CTL_ELEM_IFACE_HWDEP ((snd_ctl_elem_iface_t) SNDRV_CTL_ELEM_IFACE_HWDEP) -#define SND_CTL_ELEM_IFACE_MIXER ((snd_ctl_elem_iface_t) SNDRV_CTL_ELEM_IFACE_MIXER) -#define SND_CTL_ELEM_IFACE_PCM ((snd_ctl_elem_iface_t) SNDRV_CTL_ELEM_IFACE_PCM) -#define SND_CTL_ELEM_IFACE_RAWMIDI ((snd_ctl_elem_iface_t) SNDRV_CTL_ELEM_IFACE_RAWMIDI) -#define SND_CTL_ELEM_IFACE_TIMER ((snd_ctl_elem_iface_t) SNDRV_CTL_ELEM_IFACE_TIMER) -#define SND_CTL_ELEM_IFACE_SEQUENCER ((snd_ctl_elem_iface_t) SNDRV_CTL_ELEM_IFACE_SEQUENCER) -#define SND_CTL_ELEM_IFACE_LAST ((snd_ctl_elem_iface_t) SNDRV_CTL_ELEM_IFACE_LAST) - -#define SND_CTL_EVENT_ELEM ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_ELEM) -#define SND_CTL_EVENT_LAST ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_LAST) +/** Event class */ +typedef enum _snd_ctl_event_type { + /** Elements related event */ + SND_CTL_EVENT_ELEM = SNDRV_CTL_EVENT_ELEM, + SND_CTL_EVENT_LAST = SNDRV_CTL_EVENT_LAST, +}snd_ctl_event_type_t; +/** Element has been removed (Warning: test this first and if set don't + * test the other masks) \hideinitializer */ +#define SND_CTL_EVENT_MASK_REMOVE SNDRV_CTL_EVENT_MASK_REMOVE +/** Element has been added \hideinitializer */ #define SND_CTL_EVENT_MASK_ADD SNDRV_CTL_EVENT_MASK_ADD +/** Element info has been changed \hideinitializer */ #define SND_CTL_EVENT_MASK_INFO SNDRV_CTL_EVENT_MASK_INFO +/** Element value has been changed \hideinitializer */ #define SND_CTL_EVENT_MASK_VALUE SNDRV_CTL_EVENT_MASK_VALUE -#define SND_CTL_EVENT_MASK_REMOVE SNDRV_CTL_EVENT_MASK_REMOVE #define SND_CTL_NAME_IEC958 SNDRV_CTL_NAME_IEC958 -enum _snd_ctl_type { +/** CTL type */ +typedef enum _snd_ctl_type { + /** Kernel level CTL */ SND_CTL_TYPE_HW, + /** Shared memory client CTL */ SND_CTL_TYPE_SHM, + /** INET client CTL (not yet implemented) */ SND_CTL_TYPE_INET -}; +} snd_ctl_type_t; -#ifdef SND_ENUM_TYPECHECK -typedef struct __snd_ctl_type *snd_ctl_type_t; -#else -typedef enum _snd_ctl_type snd_ctl_type_t; -#endif +/** Non blocking mode \hideinitializer */ +#define SND_CTL_NONBLOCK 0x0001 -#define SND_CTL_TYPE_HW ((snd_ctl_type_t) SND_CTL_TYPE_HW) -#define SND_CTL_TYPE_SHM ((snd_ctl_type_t) SND_CTL_TYPE_SHM) -#define SND_CTL_TYPE_INET ((snd_ctl_type_t) SND_CTL_TYPE_INET) +/** Async notification \hideinitializer */ +#define SND_CTL_ASYNC 0x0002 +/** CTL handle */ typedef struct _snd_ctl snd_ctl_t; #ifdef __cplusplus @@ -158,7 +190,7 @@ int snd_defaults_rawmidi_card(void); int snd_defaults_rawmidi_device(void); snd_ctl_type_t snd_ctl_type(snd_ctl_t *ctl); -int snd_ctl_open(snd_ctl_t **ctl, const char *name); +int snd_ctl_open(snd_ctl_t **ctl, const char *name, int mode); int snd_ctl_close(snd_ctl_t *ctl); int snd_ctl_nonblock(snd_ctl_t *ctl, int nonblock); int snd_ctl_async(snd_ctl_t *ctl, int sig, pid_t pid); @@ -225,7 +257,7 @@ typedef int (*snd_hctl_callback_t)(snd_hctl_t *hctl, typedef int (*snd_hctl_elem_callback_t)(snd_hctl_elem_t *elem, unsigned int mask); -int snd_hctl_open(snd_hctl_t **hctl, const char *name); +int snd_hctl_open(snd_hctl_t **hctl, const char *name, int mode); int snd_hctl_close(snd_hctl_t *hctl); int snd_hctl_nonblock(snd_hctl_t *hctl, int nonblock); int snd_hctl_async(snd_hctl_t *hctl, int sig, pid_t pid); diff --git a/include/mixer.h b/include/mixer.h index 23e4d3b3..f012d097 100644 --- a/include/mixer.h +++ b/include/mixer.h @@ -36,7 +36,7 @@ typedef enum _snd_mixer_elem_type snd_mixer_elem_type_t; extern "C" { #endif -int snd_mixer_open(snd_mixer_t **mixer); +int snd_mixer_open(snd_mixer_t **mixer, int mode); int snd_mixer_close(snd_mixer_t *mixer); int snd_mixer_info(snd_mixer_t *mixer, snd_mixer_info_t *info); snd_mixer_elem_t *snd_mixer_first_elem(snd_mixer_t *mixer); diff --git a/include/timer.h b/include/timer.h index 2e0496fd..6c97aae3 100644 --- a/include/timer.h +++ b/include/timer.h @@ -48,7 +48,7 @@ typedef struct _snd_timer snd_timer_t; extern "C" { #endif -int snd_timer_open(snd_timer_t **handle); +int snd_timer_open(snd_timer_t **handle, int mode); int snd_timer_close(snd_timer_t *handle); int snd_timer_poll_descriptors_count(snd_timer_t *handle); int snd_timer_poll_descriptors(snd_timer_t *handle, struct pollfd *pfds, unsigned int space); diff --git a/src/control/cards.c b/src/control/cards.c index d785ab75..ece0a023 100644 --- a/src/control/cards.c +++ b/src/control/cards.c @@ -88,7 +88,7 @@ int snd_card_get_index(const char *string) for (card = 0; card < 32; card++) { if (snd_card_load(card) < 0) continue; - if (snd_ctl_hw_open(&handle, NULL, card) < 0) + if (snd_ctl_hw_open(&handle, NULL, card, 0) < 0) continue; if (snd_ctl_card_info(handle, &info) < 0) { snd_ctl_close(handle); @@ -109,7 +109,7 @@ int snd_card_get_name(int card, char **name) if (name == NULL) return -EINVAL; - if ((err = snd_ctl_hw_open(&handle, NULL, card)) < 0) + if ((err = snd_ctl_hw_open(&handle, NULL, card, 0)) < 0) return err; if ((err = snd_ctl_card_info(handle, &info)) < 0) { snd_ctl_close(handle); @@ -130,7 +130,7 @@ int snd_card_get_longname(int card, char **name) if (name == NULL) return -EINVAL; - if ((err = snd_ctl_hw_open(&handle, NULL, card)) < 0) + if ((err = snd_ctl_hw_open(&handle, NULL, card, 0)) < 0) return err; if ((err = snd_ctl_card_info(handle, &info)) < 0) { snd_ctl_close(handle); diff --git a/src/control/control.c b/src/control/control.c index 194771ff..262c07d1 100644 --- a/src/control/control.c +++ b/src/control/control.c @@ -1,3 +1,10 @@ +/** + * \file control/control.c + * \author Abramo Bagnara + * \date 2000 + * + * CTL interface is designed to access primitive controls. + */ /* * Control Interface - main file * Copyright (c) 2000 by Abramo Bagnara @@ -19,6 +26,7 @@ * */ +#ifndef DOC_HIDDEN #include #include #include @@ -26,21 +34,46 @@ #include #include #include +#include #include #include "control_local.h" +#endif +/** + * \brief get identifier of CTL handle + * \param ctl CTL handle + * \return ascii identifier of CTL handle + * + * Returns the ASCII identifier of given CTL handle. It's the same + * identifier specified in snd_ctl_open(). + */ const char *snd_ctl_name(snd_ctl_t *ctl) { assert(ctl); return ctl->name; } +/** + * \brief get type of CTL handle + * \param ctl CTL handle + * \return type of CTL handle + * + * Returns the type #snd_ctl_type_t of given CTL handle. + */ snd_ctl_type_t snd_ctl_type(snd_ctl_t *ctl) { assert(ctl); return ctl->type; } +/** + * \brief close CTL handle + * \param ctl CTL handle + * \return 0 on success otherwise a negative error code + * + * Closes the specified CTL handle and frees all associated + * resources. + */ int snd_ctl_close(snd_ctl_t *ctl) { int res; @@ -51,6 +84,12 @@ int snd_ctl_close(snd_ctl_t *ctl) return res; } +/** + * \brief set nonblock mode + * \param ctl CTL handle + * \param nonblock 0 = block, 1 = nonblock mode + * \return 0 on success otherwise a negative error code + */ int snd_ctl_nonblock(snd_ctl_t *ctl, int nonblock) { int err; @@ -62,24 +101,51 @@ int snd_ctl_nonblock(snd_ctl_t *ctl, int nonblock) return 0; } +/** + * \brief set async mode + * \param ctl CTL handle + * \param sig Signal to raise: < 0 disable, 0 default (SIGIO) + * \param pid Process ID to signal: 0 current + * \return 0 on success otherwise a negative error code + * + * A signal is raised when a change happens. + */ int snd_ctl_async(snd_ctl_t *ctl, int sig, pid_t pid) { + int err; assert(ctl); - return ctl->ops->async(ctl, sig, pid); -} - -int _snd_ctl_poll_descriptor(snd_ctl_t *ctl) -{ - assert(ctl); - return ctl->ops->poll_descriptor(ctl); + err = ctl->ops->async(ctl, sig, pid); + if (err < 0) + return err; + if (sig) + ctl->async_sig = sig; + else + ctl->async_sig = SIGIO; + if (pid) + ctl->async_pid = pid; + else + ctl->async_pid = getpid(); + return 0; } +/** + * \brief get count of poll descriptors for CTL handle + * \param ctl CTL handle + * \return count of poll descriptors + */ int snd_ctl_poll_descriptors_count(snd_ctl_t *ctl) { assert(ctl); return 1; } +/** + * \brief get poll descriptors + * \param ctl CTL handle + * \param pfds array of poll descriptors + * \param space space in the poll descriptor array + * \return count of filled descriptors + */ int snd_ctl_poll_descriptors(snd_ctl_t *ctl, struct pollfd *pfds, unsigned int space) { assert(ctl); @@ -91,18 +157,37 @@ int snd_ctl_poll_descriptors(snd_ctl_t *ctl, struct pollfd *pfds, unsigned int s return 0; } +/** + * \brief Ask to be informed about events (poll, #snd_ctl_async, #snd_ctl_read) + * \param ctl CTL handle + * \param subscribe 0 = unsubscribe, 1 = subscribe + * \return 0 on success otherwise a negative error code + */ int snd_ctl_subscribe_events(snd_ctl_t *ctl, int subscribe) { assert(ctl); return ctl->ops->subscribe_events(ctl, subscribe); } + +/** + * \brief Get card related information + * \param ctl CTL handle + * \param info Card info pointer + * \return 0 on success otherwise a negative error code + */ int snd_ctl_card_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info) { assert(ctl && info); return ctl->ops->card_info(ctl, info); } +/** + * \brief Get a list of element identificators + * \param ctl CTL handle + * \param list CTL element identificators list pointer + * \return 0 on success otherwise a negative error code + */ int snd_ctl_elem_list(snd_ctl_t *ctl, snd_ctl_elem_list_t *list) { assert(ctl && list); @@ -110,78 +195,157 @@ int snd_ctl_elem_list(snd_ctl_t *ctl, snd_ctl_elem_list_t *list) return ctl->ops->element_list(ctl, list); } +/** + * \brief Get CTL element information + * \param ctl CTL handle + * \param info CTL element id/information pointer + * \return 0 on success otherwise a negative error code + */ int snd_ctl_elem_info(snd_ctl_t *ctl, snd_ctl_elem_info_t *info) { assert(ctl && info && (info->id.name[0] || info->id.numid)); return ctl->ops->element_info(ctl, info); } +/** + * \brief Get CTL element value + * \param ctl CTL handle + * \param control CTL element id/value pointer + * \return 0 on success otherwise a negative error code + */ int snd_ctl_elem_read(snd_ctl_t *ctl, snd_ctl_elem_value_t *control) { assert(ctl && control && (control->id.name[0] || control->id.numid)); return ctl->ops->element_read(ctl, control); } +/** + * \brief Set CTL element value + * \param ctl CTL handle + * \param control CTL element id/value pointer + * \return 0 on success otherwise a negative error code + */ int snd_ctl_elem_write(snd_ctl_t *ctl, snd_ctl_elem_value_t *control) { assert(ctl && control && (control->id.name[0] || control->id.numid)); return ctl->ops->element_write(ctl, control); } +/** + * \brief Get next hardware dependent device number + * \param ctl CTL handle + * \param device current device on entry and next device on return + * \return 0 on success otherwise a negative error code + */ int snd_ctl_hwdep_next_device(snd_ctl_t *ctl, int *device) { assert(ctl && device); return ctl->ops->hwdep_next_device(ctl, device); } +/** + * \brief Get info about a hardware dependent device + * \param ctl CTL handle + * \param info Hardware dependent device id/info pointer + * \return 0 on success otherwise a negative error code + */ int snd_ctl_hwdep_info(snd_ctl_t *ctl, snd_hwdep_info_t * info) { assert(ctl && info); return ctl->ops->hwdep_info(ctl, info); } +/** + * \brief Get next PCM device number + * \param ctl CTL handle + * \param device current device on entry and next device on return + * \return 0 on success otherwise a negative error code + */ int snd_ctl_pcm_next_device(snd_ctl_t *ctl, int * device) { assert(ctl && device); return ctl->ops->pcm_next_device(ctl, device); } +/** + * \brief Get info about a PCM device + * \param ctl CTL handle + * \param info PCM device id/info pointer + * \return 0 on success otherwise a negative error code + */ int snd_ctl_pcm_info(snd_ctl_t *ctl, snd_pcm_info_t * info) { assert(ctl && info); return ctl->ops->pcm_info(ctl, info); } +/** + * \brief Set preferred PCM subdevice number of successive PCM open + * \param ctl CTL handle + * \param subdev Preferred PCM subdevice number + * \return 0 on success otherwise a negative error code + */ int snd_ctl_pcm_prefer_subdevice(snd_ctl_t *ctl, int subdev) { assert(ctl); return ctl->ops->pcm_prefer_subdevice(ctl, subdev); } +/** + * \brief Get next RawMidi device number + * \param ctl CTL handle + * \param device current device on entry and next device on return + * \return 0 on success otherwise a negative error code + */ int snd_ctl_rawmidi_next_device(snd_ctl_t *ctl, int * device) { assert(ctl && device); return ctl->ops->rawmidi_next_device(ctl, device); } +/** + * \brief Get info about a RawMidi device + * \param ctl CTL handle + * \param info RawMidi device id/info pointer + * \return 0 on success otherwise a negative error code + */ int snd_ctl_rawmidi_info(snd_ctl_t *ctl, snd_rawmidi_info_t * info) { assert(ctl && info); return ctl->ops->rawmidi_info(ctl, info); } +/** + * \brief Set preferred RawMidi subdevice number of successive RawMidi open + * \param ctl CTL handle + * \param subdev Preferred RawMidi subdevice number + * \return 0 on success otherwise a negative error code + */ int snd_ctl_rawmidi_prefer_subdevice(snd_ctl_t *ctl, int subdev) { assert(ctl); return ctl->ops->rawmidi_prefer_subdevice(ctl, subdev); } + +/** + * \brief Read an event + * \param ctl CTL handle + * \param event Event pointer + * \return number of events read otherwise a negative error code on failure + */ int snd_ctl_read(snd_ctl_t *ctl, snd_ctl_event_t *event) { assert(ctl && event); return ctl->ops->read(ctl, event); } +/** + * \brief Wait for a CTL to become ready (i.e. at least one event pending) + * \param ctl CTL handle + * \param timeout maximum time in milliseconds to wait + * \return 0 otherwise a negative error code on failure + */ int snd_ctl_wait(snd_ctl_t *ctl, int timeout) { struct pollfd pfd; @@ -194,7 +358,14 @@ int snd_ctl_wait(snd_ctl_t *ctl, int timeout) return 0; } -int snd_ctl_open(snd_ctl_t **ctlp, const char *name) +/** + * \brief Opens a CTL + * \param ctlp Returned CTL handle + * \param name ASCII identifier of the CTL handle + * \param mode Open mode (see #SND_CTL_NONBLOCK, #SND_CTL_ASYNC) + * \return 0 on success otherwise a negative error code + */ +int snd_ctl_open(snd_ctl_t **ctlp, const char *name, int mode) { const char *str; char buf[256]; @@ -202,7 +373,7 @@ int snd_ctl_open(snd_ctl_t **ctlp, const char *name) snd_config_t *ctl_conf, *conf, *type_conf; snd_config_iterator_t i, next; const char *lib = NULL, *open = NULL; - int (*open_func)(snd_ctl_t **ctlp, const char *name, snd_config_t *conf); + int (*open_func)(snd_ctl_t **ctlp, const char *name, snd_config_t *conf, int mode); void *h; const char *name1; assert(ctlp && name); @@ -217,10 +388,10 @@ int snd_ctl_open(snd_ctl_t **ctlp, const char *name) char socket[256], sname[256]; err = sscanf(name1, "hw:%d", &card); if (err == 1) - return snd_ctl_hw_open(ctlp, name, card); + return snd_ctl_hw_open(ctlp, name, card, mode); err = sscanf(name1, "shm:%256[^,],%256[^,]", socket, sname); if (err == 2) - return snd_ctl_shm_open(ctlp, name, socket, sname); + return snd_ctl_shm_open(ctlp, name, socket, sname, mode); SNDERR("Unknown ctl %s", name1); return -ENOENT; } @@ -278,21 +449,31 @@ int snd_ctl_open(snd_ctl_t **ctlp, const char *name) dlclose(h); return -ENXIO; } - return open_func(ctlp, name, ctl_conf); + return open_func(ctlp, name, ctl_conf, mode); } +/** + * \brief Set CTL element #SND_CTL_ELEM_TYPE_BYTES value + * \param ctl CTL handle + * \param data Bytes value + * \param size Size in bytes + */ void snd_ctl_elem_set_bytes(snd_ctl_elem_value_t *obj, void *data, size_t size) { assert(obj); - assert(size <= sizeof(obj->value.bytes.data)); + if (size >= sizeof(obj->value.bytes.data)) { + assert(0); + return; + } memcpy(obj->value.bytes.data, data, size); } +#ifndef DOC_HIDDEN #define TYPE(v) [SND_CTL_ELEM_TYPE_##v] = #v #define IFACE(v) [SND_CTL_ELEM_IFACE_##v] = #v #define EVENT(v) [SND_CTL_EVENT_##v] = #v -const char *snd_ctl_elem_type_names[] = { +static const char *snd_ctl_elem_type_names[] = { TYPE(NONE), TYPE(BOOLEAN), TYPE(INTEGER), @@ -301,7 +482,7 @@ const char *snd_ctl_elem_type_names[] = { TYPE(IEC958), }; -const char *snd_ctl_elem_iface_names[] = { +static const char *snd_ctl_elem_iface_names[] = { IFACE(CARD), IFACE(HWDEP), IFACE(MIXER), @@ -311,28 +492,50 @@ const char *snd_ctl_elem_iface_names[] = { IFACE(SEQUENCER), }; -const char *snd_ctl_event_type_names[] = { +static const char *snd_ctl_event_type_names[] = { EVENT(ELEM), }; +#endif +/** + * \brief get name of a CTL element type + * \param type CTL element type + * \return ascii name of CTL element type + */ const char *snd_ctl_elem_type_name(snd_ctl_elem_type_t type) { assert(type <= SND_CTL_ELEM_TYPE_LAST); return snd_ctl_elem_type_names[snd_enum_to_int(type)]; } +/** + * \brief get name of a CTL element related interface + * \param iface CTL element related interface + * \return ascii name of CTL element related interface + */ const char *snd_ctl_elem_iface_name(snd_ctl_elem_iface_t iface) { assert(iface <= SND_CTL_ELEM_IFACE_LAST); return snd_ctl_elem_iface_names[snd_enum_to_int(iface)]; } +/** + * \brief get name of a CTL event type + * \param type CTL event type + * \return ascii name of CTL event type + */ const char *snd_ctl_event_type_name(snd_ctl_event_type_t type) { assert(type <= SND_CTL_EVENT_LAST); return snd_ctl_event_type_names[snd_enum_to_int(type)]; } +/** + * \brief allocate space for CTL element identificators list + * \param obj CTL element identificators list + * \param entries Entries to allocate + * \return 0 on success otherwise a negative error code + */ int snd_ctl_elem_list_alloc_space(snd_ctl_elem_list_t *obj, unsigned int entries) { if (obj->pids) @@ -346,12 +549,21 @@ int snd_ctl_elem_list_alloc_space(snd_ctl_elem_list_t *obj, unsigned int entries return 0; } +/** + * \brief free previously allocated space for CTL element identificators list + * \param obj CTL element identificators list + */ void snd_ctl_elem_list_free_space(snd_ctl_elem_list_t *obj) { free(obj->pids); obj->pids = NULL; } +/** + * \brief Get event mask for an element related event + * \param obj CTL event + * \return event mask for element related event + */ unsigned int snd_ctl_event_elem_get_mask(const snd_ctl_event_t *obj) { assert(obj); @@ -359,6 +571,11 @@ unsigned int snd_ctl_event_elem_get_mask(const snd_ctl_event_t *obj) return obj->data.elem.mask; } +/** + * \brief Get element numeric identificator for an element related event + * \param obj CTL event + * \return element numeric identificator for element related event + */ unsigned int snd_ctl_event_elem_get_numid(const snd_ctl_event_t *obj) { assert(obj); @@ -366,6 +583,11 @@ unsigned int snd_ctl_event_elem_get_numid(const snd_ctl_event_t *obj) return obj->data.elem.id.numid; } +/** + * \brief Get CTL element identificator for an element related event + * \param obj CTL event + * \param ptr Pointer to returned CTL element identificator + */ void snd_ctl_event_elem_get_id(const snd_ctl_event_t *obj, snd_ctl_elem_id_t *ptr) { assert(obj && ptr); @@ -373,6 +595,11 @@ void snd_ctl_event_elem_get_id(const snd_ctl_event_t *obj, snd_ctl_elem_id_t *pt *ptr = obj->data.elem.id; } +/** + * \brief Get interface part of CTL element identificator for an element related event + * \param obj CTL event + * \return interface part of element identificator + */ snd_ctl_elem_iface_t snd_ctl_event_elem_get_interface(const snd_ctl_event_t *obj) { assert(obj); @@ -380,6 +607,11 @@ snd_ctl_elem_iface_t snd_ctl_event_elem_get_interface(const snd_ctl_event_t *obj return snd_int_to_enum(obj->data.elem.id.iface); } +/** + * \brief Get device part of CTL element identificator for an element related event + * \param obj CTL event + * \return device part of element identificator + */ unsigned int snd_ctl_event_elem_get_device(const snd_ctl_event_t *obj) { assert(obj); @@ -387,6 +619,11 @@ unsigned int snd_ctl_event_elem_get_device(const snd_ctl_event_t *obj) return obj->data.elem.id.device; } +/** + * \brief Get subdevice part of CTL element identificator for an element related event + * \param obj CTL event + * \return subdevice part of element identificator + */ unsigned int snd_ctl_event_elem_get_subdevice(const snd_ctl_event_t *obj) { assert(obj); @@ -394,6 +631,11 @@ unsigned int snd_ctl_event_elem_get_subdevice(const snd_ctl_event_t *obj) return obj->data.elem.id.subdevice; } +/** + * \brief Get name part of CTL element identificator for an element related event + * \param obj CTL event + * \return name part of element identificator + */ const char *snd_ctl_event_elem_get_name(const snd_ctl_event_t *obj) { assert(obj); @@ -401,6 +643,11 @@ const char *snd_ctl_event_elem_get_name(const snd_ctl_event_t *obj) return obj->data.elem.id.name; } +/** + * \brief Get index part of CTL element identificator for an element related event + * \param obj CTL event + * \return index part of element identificator + */ unsigned int snd_ctl_event_elem_get_index(const snd_ctl_event_t *obj) { assert(obj); @@ -408,3 +655,10 @@ unsigned int snd_ctl_event_elem_get_index(const snd_ctl_event_t *obj) return obj->data.elem.id.index; } +#ifndef DOC_HIDDEN +int _snd_ctl_poll_descriptor(snd_ctl_t *ctl) +{ + assert(ctl); + return ctl->ops->poll_descriptor(ctl); +} +#endif diff --git a/src/control/control_hw.c b/src/control/control_hw.c index 048ff0da..b07cdd93 100644 --- a/src/control/control_hw.c +++ b/src/control/control_hw.c @@ -259,10 +259,11 @@ snd_ctl_ops_t snd_ctl_hw_ops = { read: snd_ctl_hw_read, }; -int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card) +int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode) { int fd, ver; char filename[32]; + int fmode; snd_ctl_t *ctl; snd_ctl_hw_t *hw; @@ -270,7 +271,12 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card) assert(card >= 0 && card < 32); sprintf(filename, SNDRV_FILE_CONTROL, card); - if ((fd = open(filename, O_RDWR)) < 0) { + fmode = O_RDWR; + if (mode & SND_CTL_NONBLOCK) + fmode |= O_NONBLOCK; + if (mode & SND_CTL_ASYNC) + fmode |= O_ASYNC; + if ((fd = open(filename, fmode)) < 0) { snd_card_load(card); if ((fd = open(filename, O_RDWR)) < 0) return -errno; @@ -335,6 +341,6 @@ int _snd_ctl_hw_open(snd_ctl_t **handlep, char *name, snd_config_t *conf) } if (card < 0) return -EINVAL; - return snd_ctl_hw_open(handlep, name, card); + return snd_ctl_hw_open(handlep, name, card, 0); } diff --git a/src/control/control_local.h b/src/control/control_local.h index 198dc7b6..6bbd0e78 100644 --- a/src/control/control_local.h +++ b/src/control/control_local.h @@ -51,6 +51,8 @@ struct _snd_ctl { snd_ctl_ops_t *ops; void *private_data; int nonblock; + int async_sig; + pid_t async_pid; }; struct _snd_hctl_elem { @@ -77,5 +79,5 @@ struct _snd_hctl { int _snd_ctl_poll_descriptor(snd_ctl_t *ctl); -int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card); -int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *socket, const char *sname); +int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode); +int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *socket, const char *sname, int mode); diff --git a/src/control/control_shm.c b/src/control/control_shm.c index 7bec2fe2..ce951fac 100644 --- a/src/control/control_shm.c +++ b/src/control/control_shm.c @@ -402,7 +402,7 @@ static int make_inet_socket(const char *host, int port) } #endif -int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *socket, const char *sname) +int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *socket, const char *sname, int mode) { snd_ctl_t *ctl; snd_ctl_shm_t *shm = NULL; @@ -430,7 +430,7 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *socket, req->dev_type = SND_DEV_TYPE_CONTROL; req->transport_type = SND_TRANSPORT_TYPE_SHM; req->stream = 0; - req->mode = 0; + req->mode = mode; req->namelen = snamelen; err = write(sock, req, reqlen); if (err < 0) { @@ -498,7 +498,7 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *socket, extern int is_local(struct hostent *hent); -int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf) +int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf, int mode) { snd_config_iterator_t i, next; const char *server = NULL; @@ -604,6 +604,6 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf) SNDERR("%s is not the local host", host); return -EINVAL; } - return snd_ctl_shm_open(handlep, name, socket, sname); + return snd_ctl_shm_open(handlep, name, socket, sname, mode); } diff --git a/src/control/defaults.c b/src/control/defaults.c index 328e7969..1e785b81 100644 --- a/src/control/defaults.c +++ b/src/control/defaults.c @@ -90,7 +90,7 @@ int snd_defaults_pcm_device(void) if (result >= 0) return result; sprintf(id, "hw:%i", snd_defaults_pcm_card()); - if (snd_ctl_open(&handle, id) < 0) + if (snd_ctl_open(&handle, id, 0) < 0) return -ENOENT; result = -1; if (snd_ctl_pcm_next_device(handle, &result) < 0) { @@ -120,7 +120,7 @@ int snd_defaults_rawmidi_device(void) if (result >= 0) return result; sprintf(id, "hw:%i", snd_defaults_rawmidi_card()); - if (snd_ctl_open(&handle, id) < 0) + if (snd_ctl_open(&handle, id, 0) < 0) return -ENOENT; result = -1; if (snd_ctl_rawmidi_next_device(handle, &result) < 0) { diff --git a/src/control/hcontrol.c b/src/control/hcontrol.c index 572e45df..81bd5ec3 100644 --- a/src/control/hcontrol.c +++ b/src/control/hcontrol.c @@ -34,7 +34,7 @@ static int snd_hctl_compare_default(const snd_hctl_elem_t *c1, const snd_hctl_elem_t *c2); -int snd_hctl_open(snd_hctl_t **hctlp, const char *name) +int snd_hctl_open(snd_hctl_t **hctlp, const char *name, int mode) { snd_hctl_t *hctl; snd_ctl_t *ctl; @@ -42,7 +42,7 @@ int snd_hctl_open(snd_hctl_t **hctlp, const char *name) assert(hctlp); *hctlp = NULL; - if ((err = snd_ctl_open(&ctl, name)) < 0) + if ((err = snd_ctl_open(&ctl, name, mode)) < 0) return err; if ((hctl = (snd_hctl_t *)calloc(1, sizeof(snd_hctl_t))) == NULL) { snd_ctl_close(ctl); diff --git a/src/input.c b/src/input.c index eb8e46b3..52da5aff 100644 --- a/src/input.c +++ b/src/input.c @@ -51,7 +51,7 @@ struct _snd_input { /** * \brief close input handle * \param input Input handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_input_close(snd_input_t *input) { @@ -65,7 +65,7 @@ int snd_input_close(snd_input_t *input) * \param input Input handle * \param format fscanf format * \param ... other fscanf arguments - * \return number of input itmes assigned or a negative error code + * \return number of input items assigned otherwise a negative error code */ int snd_input_scanf(snd_input_t *input, const char *format, ...) { diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c index 3cb88089..a40f45ea 100644 --- a/src/mixer/mixer.c +++ b/src/mixer/mixer.c @@ -43,7 +43,7 @@ static int snd_mixer_compare_default(const snd_mixer_elem_t *c1, const snd_mixer_elem_t *c2); -int snd_mixer_open(snd_mixer_t **mixerp) +int snd_mixer_open(snd_mixer_t **mixerp, int mode ATTRIBUTE_UNUSED) { snd_mixer_t *mixer; assert(mixerp); @@ -152,7 +152,7 @@ int snd_mixer_attach(snd_mixer_t *mixer, const char *name) slave = calloc(1, sizeof(*slave)); if (slave == NULL) return -ENOMEM; - err = snd_hctl_open(&hctl, name); + err = snd_hctl_open(&hctl, name, 0); if (err < 0) { free(slave); return err; diff --git a/src/output.c b/src/output.c index 463c2067..2b3886d9 100644 --- a/src/output.c +++ b/src/output.c @@ -51,7 +51,7 @@ struct _snd_output { /** * \brief close output handle * \param output Output handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_output_close(snd_output_t *output) { @@ -65,7 +65,7 @@ int snd_output_close(snd_output_t *output) * \param output Output handle * \param format fprintf format * \param ... other fprintf arguments - * \return number of characters written or a negative error code + * \return number of characters written otherwise a negative error code */ int snd_output_printf(snd_output_t *output, const char *format, ...) { diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 1cacbaf6..bbca5bd5 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -54,7 +54,7 @@ * \return ascii identifier of PCM handle * * Returns the ASCII identifier of given PCM handle. It's the same - * identifier as for snd_pcm_open(). + * identifier specified in snd_pcm_open(). */ const char *snd_pcm_name(snd_pcm_t *pcm) { @@ -91,7 +91,7 @@ snd_pcm_stream_t snd_pcm_stream(snd_pcm_t *pcm) /** * \brief close PCM handle * \param pcm PCM handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code * * Closes the specified PCM handle and frees all associated * resources. @@ -124,7 +124,7 @@ int snd_pcm_close(snd_pcm_t *pcm) * \brief set nonblock mode * \param pcm PCM handle * \param nonblock 0 = block, 1 = nonblock mode - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock) { @@ -144,7 +144,7 @@ int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock) * \param pcm PCM handle * \param sig Signal to raise: < 0 disable, 0 default (SIGIO) * \param pid Process ID to signal: 0 current - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code * * A signal is raised every period. */ @@ -170,7 +170,7 @@ int snd_pcm_async(snd_pcm_t *pcm, int sig, pid_t pid) * \brief Obtain general (static) information for PCM handle * \param pcm PCM handle * \param info Information container - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info) { @@ -181,7 +181,7 @@ int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info) /** \brief Install one PCM hardware configuration choosen from a configuration space and #snd_pcm_prepare it * \param pcm PCM handle * \param params Configuration space definition container - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code * * The configuration is choosen fixing single parameters in this order: * first access, first format, first subformat, min channels, min rate, @@ -199,7 +199,7 @@ int snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) /** \brief Remove PCM hardware configuration and free associated resources * \param pcm PCM handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_hw_free(snd_pcm_t *pcm) { @@ -219,7 +219,7 @@ int snd_pcm_hw_free(snd_pcm_t *pcm) /** \brief Install PCM software configuration defined by params * \param pcm PCM handle * \param params Configuration container - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) { @@ -244,7 +244,7 @@ int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) * \brief Obtain status (runtime) information for PCM handle * \param pcm PCM handle * \param status Status container - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_status(snd_pcm_t *pcm, snd_pcm_status_t *status) { @@ -267,7 +267,7 @@ snd_pcm_state_t snd_pcm_state(snd_pcm_t *pcm) * \brief Obtain delay for a running PCM handle * \param pcm PCM handle * \param delayp Returned delay in frames - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code * * Delay is distance between current application frame position and * sound frame position. @@ -285,7 +285,7 @@ int snd_pcm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp) /** * \brief Prepare PCM for use * \param pcm PCM handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_prepare(snd_pcm_t *pcm) { @@ -297,7 +297,7 @@ int snd_pcm_prepare(snd_pcm_t *pcm) /** * \brief Reset PCM position * \param pcm PCM handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code * * Reduce PCM delay to 0. */ @@ -311,7 +311,7 @@ int snd_pcm_reset(snd_pcm_t *pcm) /** * \brief Start a PCM * \param pcm PCM handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_start(snd_pcm_t *pcm) { @@ -323,7 +323,7 @@ int snd_pcm_start(snd_pcm_t *pcm) /** * \brief Stop a PCM dropping pending frames * \param pcm PCM handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_drop(snd_pcm_t *pcm) { @@ -335,7 +335,7 @@ int snd_pcm_drop(snd_pcm_t *pcm) /** * \brief Stop a PCM preserving pending frames * \param pcm PCM handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code * * For playback wait for all pending frames to be played and then stop * the PCM. @@ -352,7 +352,7 @@ int snd_pcm_drain(snd_pcm_t *pcm) * \brief Pause/resume PCM * \param pcm PCM handle * \param pause 0 = resume, 1 = pause - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_pause(snd_pcm_t *pcm, int enable) { @@ -448,7 +448,7 @@ snd_pcm_sframes_t snd_pcm_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t s * \brief Link two PCMs * \param pcm1 first PCM handle * \param pcm2 first PCM handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code * * The two PCMs will start/stop/prepare in sync. */ @@ -468,7 +468,7 @@ int snd_pcm_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2) /** * \brief Remove a PCM from a linked group * \param pcm PCM handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_unlink(snd_pcm_t *pcm) { @@ -762,7 +762,7 @@ const char *snd_pcm_state_name(snd_pcm_state_t state) * \brief Dump current hardware setup for PCM * \param pcm PCM handle * \param out Output handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_dump_hw_setup(snd_pcm_t *pcm, snd_output_t *out) { @@ -788,7 +788,7 @@ int snd_pcm_dump_hw_setup(snd_pcm_t *pcm, snd_output_t *out) * \brief Dump current software setup for PCM * \param pcm PCM handle * \param out Output handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, snd_output_t *out) { @@ -812,7 +812,7 @@ int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, snd_output_t *out) * \brief Dump current setup (hardware and software) for PCM * \param pcm PCM handle * \param out Output handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_dump_setup(snd_pcm_t *pcm, snd_output_t *out) { @@ -825,7 +825,7 @@ int snd_pcm_dump_setup(snd_pcm_t *pcm, snd_output_t *out) * \brief Dump status * \param status Status container * \param out Output handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_status_dump(snd_pcm_status_t *status, snd_output_t *out) { @@ -845,7 +845,7 @@ int snd_pcm_status_dump(snd_pcm_status_t *status, snd_output_t *out) * \brief Dump PCM info * \param pcm PCM handle * \param out Output handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_dump(snd_pcm_t *pcm, snd_output_t *out) { @@ -913,7 +913,7 @@ ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, int samples) * \param name ASCII identifier of the PCM handle * \param stream Wanted stream * \param mode Open mode (see #SND_PCM_NONBLOCK, #SND_PCM_ASYNC) - * \return 0 or a negative error code on failure or zero on success + * \return 0 on success otherwise a negative error code */ int snd_pcm_open(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t stream, int mode) @@ -1060,7 +1060,7 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name, * \brief Wait for a PCM to become ready * \param pcm PCM handle * \param timeout maximum time in milliseconds to wait - * \return 0 or a negative error code on failure or zero on success + * \return 0 on success otherwise a negative error code */ int snd_pcm_wait(snd_pcm_t *pcm, int timeout) { @@ -1111,7 +1111,7 @@ snd_pcm_sframes_t snd_pcm_mmap_forward(snd_pcm_t *pcm, snd_pcm_uframes_t size) * \param dst_offset offset in frames inside area * \param samples samples to silence * \param format PCM sample format - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t dst_offset, unsigned int samples, snd_pcm_format_t format) @@ -1202,7 +1202,7 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes * \param channels channels count * \param frames frames to silence * \param format PCM sample format - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_areas_silence(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format) @@ -1253,7 +1253,7 @@ int snd_pcm_areas_silence(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufram * \param src_offset offset in frames inside source area * \param samples samples to copy * \param format PCM sample format - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_area, snd_pcm_uframes_t src_offset, @@ -1360,7 +1360,7 @@ int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t * \param channels channels count * \param frames frames to copy * \param format PCM sample format - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_areas_copy(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset, @@ -1417,7 +1417,7 @@ int snd_pcm_areas_copy(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_ * \brief Dump a PCM hardware configuration space * \param params Configuration space * \param out Output handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_hw_params_dump(snd_pcm_hw_params_t *params, snd_output_t *out) { @@ -1435,7 +1435,7 @@ int snd_pcm_hw_params_dump(snd_pcm_hw_params_t *params, snd_output_t *out) * \param params Configuration space * \param rate_num Pointer to returned rate numerator * \param rate_den Pointer to returned rate denominator - * \return 0 or a negative error code if the info is not available + * \return 0 otherwise a negative error code if the info is not available */ int snd_pcm_hw_params_get_rate_numden(const snd_pcm_hw_params_t *params, unsigned int *rate_num, unsigned int *rate_den) @@ -1450,7 +1450,7 @@ int snd_pcm_hw_params_get_rate_numden(const snd_pcm_hw_params_t *params, /** * \brief Get sample resolution info from a configuration space * \param params Configuration space - * \return significative bits in sample or a negative error code if the info is not available + * \return significative bits in sample otherwise a negative error code if the info is not available */ int snd_pcm_hw_params_get_sbits(const snd_pcm_hw_params_t *params) { @@ -1462,7 +1462,7 @@ int snd_pcm_hw_params_get_sbits(const snd_pcm_hw_params_t *params) /** * \brief Get hardare fifo size info from a configuration space * \param params Configuration space - * \return fifo size in frames or a negative error code if the info is not available + * \return fifo size in frames otherwise a negative error code if the info is not available */ int snd_pcm_hw_params_get_fifo_size(const snd_pcm_hw_params_t *params) { @@ -1494,7 +1494,7 @@ size_t snd_pcm_access_mask_sizeof() /** * \brief allocate an empty #snd_pcm_access_mask_t using standard malloc * \param ptr returned pointer - * \return zero on success otherwise negative error code + * \return 0 on success otherwise negative error code */ int snd_pcm_access_mask_malloc(snd_pcm_access_mask_t **ptr) { @@ -1585,7 +1585,7 @@ size_t snd_pcm_format_mask_sizeof() /** * \brief allocate an empty #snd_pcm_format_mask_t using standard malloc * \param ptr returned pointer - * \return zero on success otherwise negative error code + * \return 0 on success otherwise negative error code */ int snd_pcm_format_mask_malloc(snd_pcm_format_mask_t **ptr) { @@ -1677,7 +1677,7 @@ size_t snd_pcm_subformat_mask_sizeof() /** * \brief allocate an empty #snd_pcm_subformat_mask_t using standard malloc * \param ptr returned pointer - * \return zero on success otherwise negative error code + * \return 0 on success otherwise negative error code */ int snd_pcm_subformat_mask_malloc(snd_pcm_subformat_mask_t **ptr) { @@ -1769,7 +1769,7 @@ size_t snd_pcm_hw_params_sizeof() /** * \brief allocate an invalid #snd_pcm_hw_params_t using standard malloc * \param ptr returned pointer - * \return zero on success otherwise negative error code + * \return 0 on success otherwise negative error code */ int snd_pcm_hw_params_malloc(snd_pcm_hw_params_t **ptr) { @@ -1803,7 +1803,7 @@ void snd_pcm_hw_params_copy(snd_pcm_hw_params_t *dst, const snd_pcm_hw_params_t /** * \brief Extract access type from a configuration space * \param params Configuration space - * \return access type or a negative error code if not exactly one is present + * \return access type otherwise a negative error code if not exactly one is present */ int snd_pcm_hw_params_get_access(const snd_pcm_hw_params_t *params) { @@ -1827,7 +1827,7 @@ int snd_pcm_hw_params_test_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, s * \param pcm PCM handle * \param params Configuration space * \param val access type - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty */ int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t val) { @@ -1872,7 +1872,7 @@ int snd_pcm_hw_params_set_access_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *param /** * \brief Extract format from a configuration space * \param params Configuration space - * \return format or a negative error code if not exactly one is present + * \return format otherwise a negative error code if not exactly one is present */ int snd_pcm_hw_params_get_format(const snd_pcm_hw_params_t *params) { @@ -1896,7 +1896,7 @@ int snd_pcm_hw_params_test_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, s * \param pcm PCM handle * \param params Configuration space * \param val format - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty */ int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val) { @@ -1953,7 +1953,7 @@ int snd_pcm_hw_params_test_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params /** * \brief Extract subformat from a configuration space * \param params Configuration space - * \return subformat or a negative error code if not exactly one is present + * \return subformat otherwise a negative error code if not exactly one is present */ int snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params) { @@ -1965,7 +1965,7 @@ int snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params) * \param pcm PCM handle * \param params Configuration space * \param val subformat - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty */ int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t val) { @@ -2010,7 +2010,7 @@ int snd_pcm_hw_params_set_subformat_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *pa /** * \brief Extract channels from a configuration space * \param params Configuration space - * \return channels count or a negative error code if not exactly one is present + * \return channels count otherwise a negative error code if not exactly one is present */ int snd_pcm_hw_params_get_channels(const snd_pcm_hw_params_t *params) { @@ -2054,7 +2054,7 @@ int snd_pcm_hw_params_test_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, * \param pcm PCM handle * \param params Configuration space * \param val channels count - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty */ int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val) { @@ -2066,7 +2066,7 @@ int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, * \param pcm PCM handle * \param params Configuration space * \param val minimum channels count (on return filled with actual minimum) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty */ int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val) { @@ -2078,7 +2078,7 @@ int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *para * \param pcm PCM handle * \param params Configuration space * \param val maximum channels count (on return filled with actual maximum) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty */ int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val) { @@ -2091,7 +2091,7 @@ int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *para * \param params Configuration space * \param min minimum channels count (on return filled with actual minimum) * \param max maximum channels count (on return filled with actual maximum) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty */ int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, unsigned int *max) { @@ -2137,7 +2137,7 @@ unsigned int snd_pcm_hw_params_set_channels_last(snd_pcm_t *pcm, snd_pcm_hw_para * \brief Extract rate from a configuration space * \param params Configuration space * \param dir Sub unit direction - * \return approximate rate or a negative error code if not exactly one is present + * \return approximate rate otherwise a negative error code if not exactly one is present * * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) */ @@ -2193,7 +2193,7 @@ int snd_pcm_hw_params_test_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, uns * \param params Configuration space * \param val approximate rate * \param dir Sub unit direction - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted exact value is <,=,> val following dir (-1,0,1) */ @@ -2208,7 +2208,7 @@ int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsi * \param params Configuration space * \param val approximate minimum rate (on return filled with actual minimum) * \param dir Sub unit direction (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) */ @@ -2223,7 +2223,7 @@ int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, * \param params Configuration space * \param val approximate maximum rate (on return filled with actual maximum) * \param dir Sub unit direction (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1) */ @@ -2240,7 +2240,7 @@ int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, * \param mindir Sub unit direction for minimum (on return filled with actual direction) * \param max approximate maximum rate (on return filled with actual maximum) * \param maxdir Sub unit direction for maximum (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1) */ @@ -2296,7 +2296,7 @@ unsigned int snd_pcm_hw_params_set_rate_last(snd_pcm_t *pcm, snd_pcm_hw_params_t * \brief Extract period time from a configuration space * \param params Configuration space * \param dir Sub unit direction - * \return approximate period duration in us or a negative error code if not exactly one is present + * \return approximate period duration in us otherwise a negative error code if not exactly one is present * * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) */ @@ -2352,7 +2352,7 @@ int snd_pcm_hw_params_test_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *para * \param params Configuration space * \param val approximate period duration in us * \param dir Sub unit direction - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted exact value is <,=,> val following dir (-1,0,1) */ @@ -2368,7 +2368,7 @@ int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *param * \param params Configuration space * \param val approximate minimum period duration in us (on return filled with actual minimum) * \param dir Sub unit direction (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) */ @@ -2383,7 +2383,7 @@ int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *p * \param params Configuration space * \param val approximate maximum period duration in us (on return filled with actual maximum) * \param dir Sub unit direction (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1) */ @@ -2400,7 +2400,7 @@ int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *p * \param mindir Sub unit direction for minimum (on return filled with actual direction) * \param max approximate maximum period duration in us (on return filled with actual maximum) * \param maxdir Sub unit direction for maximum (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1) */ @@ -2456,7 +2456,7 @@ unsigned int snd_pcm_hw_params_set_period_time_last(snd_pcm_t *pcm, snd_pcm_hw_p * \brief Extract period size from a configuration space * \param params Configuration space * \param dir Sub unit direction - * \return approximate period size in frames or a negative error code if not exactly one is present + * \return approximate period size in frames otherwise a negative error code if not exactly one is present * * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) */ @@ -2512,7 +2512,7 @@ int snd_pcm_hw_params_test_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *para * \param params Configuration space * \param val approximate period size in frames * \param dir Sub unit direction - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted exact value is <,=,> val following dir (-1,0,1) */ @@ -2527,7 +2527,7 @@ int snd_pcm_hw_params_set_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *param * \param params Configuration space * \param val approximate minimum period size in frames (on return filled with actual minimum) * \param dir Sub unit direction (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) */ @@ -2545,7 +2545,7 @@ int snd_pcm_hw_params_set_period_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *p * \param params Configuration space * \param val approximate maximum period size in frames (on return filled with actual maximum) * \param dir Sub unit direction (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) */ @@ -2565,7 +2565,7 @@ int snd_pcm_hw_params_set_period_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *p * \param mindir Sub unit direction for minimum (on return filled with actual direction) * \param max approximate maximum period size in frames (on return filled with actual maximum) * \param maxdir Sub unit direction for maximum (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1) */ @@ -2625,7 +2625,7 @@ snd_pcm_uframes_t snd_pcm_hw_params_set_period_size_last(snd_pcm_t *pcm, snd_pcm * \brief Restrict a configuration space to contain only integer period sizes * \param pcm PCM handle * \param params Configuration space - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty */ int snd_pcm_hw_params_set_period_size_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) { @@ -2637,7 +2637,7 @@ int snd_pcm_hw_params_set_period_size_integer(snd_pcm_t *pcm, snd_pcm_hw_params_ * \brief Extract periods from a configuration space * \param params Configuration space * \param dir Sub unit direction - * \return approximate periods per buffer or a negative error code if not exactly one is present + * \return approximate periods per buffer otherwise a negative error code if not exactly one is present * * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) */ @@ -2693,7 +2693,7 @@ int snd_pcm_hw_params_test_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, * \param params Configuration space * \param val approximate periods per buffer * \param dir Sub unit direction - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted exact value is <,=,> val following dir (-1,0,1) */ @@ -2708,7 +2708,7 @@ int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, u * \param params Configuration space * \param val approximate minimum periods per buffer (on return filled with actual minimum) * \param dir Sub unit direction (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) */ @@ -2723,7 +2723,7 @@ int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *param * \param params Configuration space * \param val approximate maximum periods per buffer (on return filled with actual maximum) * \param dir Sub unit direction (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1) */ @@ -2740,7 +2740,7 @@ int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *param * \param mindir Sub unit direction for minimum (on return filled with actual direction) * \param max approximate maximum periods per buffer (on return filled with actual maximum) * \param maxdir Sub unit direction for maximum (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1) */ @@ -2795,7 +2795,7 @@ unsigned int snd_pcm_hw_params_set_periods_last(snd_pcm_t *pcm, snd_pcm_hw_param * \brief Restrict a configuration space to contain only integer periods counts * \param pcm PCM handle * \param params Configuration space - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty */ int snd_pcm_hw_params_set_periods_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) { @@ -2807,7 +2807,7 @@ int snd_pcm_hw_params_set_periods_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *p * \brief Extract buffer time from a configuration space * \param params Configuration space * \param dir Sub unit direction - * \return approximate buffer duration in us or a negative error code if not exactly one is present + * \return approximate buffer duration in us otherwise a negative error code if not exactly one is present * * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) */ @@ -2863,7 +2863,7 @@ int snd_pcm_hw_params_test_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *para * \param params Configuration space * \param val approximate buffer duration in us * \param dir Sub unit direction - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted exact value is <,=,> val following dir (-1,0,1) */ @@ -2878,7 +2878,7 @@ int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *param * \param params Configuration space * \param val approximate minimum buffer duration in us (on return filled with actual minimum) * \param dir Sub unit direction (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) */ @@ -2893,7 +2893,7 @@ int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *p * \param params Configuration space * \param val approximate maximum buffer duration in us (on return filled with actual maximum) * \param dir Sub unit direction (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1) */ @@ -2910,7 +2910,7 @@ int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *p * \param mindir Sub unit direction for minimum (on return filled with actual direction) * \param max approximate maximum buffer duration in us (on return filled with actual maximum) * \param maxdir Sub unit direction for maximum (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1) */ @@ -2965,7 +2965,7 @@ unsigned int snd_pcm_hw_params_set_buffer_time_last(snd_pcm_t *pcm, snd_pcm_hw_p /** * \brief Extract buffer size from a configuration space * \param params Configuration space - * \return buffer size in frames or a negative error code if not exactly one is present + * \return buffer size in frames otherwise a negative error code if not exactly one is present */ snd_pcm_sframes_t snd_pcm_hw_params_get_buffer_size(const snd_pcm_hw_params_t *params) { @@ -3018,7 +3018,7 @@ int snd_pcm_hw_params_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *para * \param pcm PCM handle * \param params Configuration space * \param val buffer size in frames - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted exact value is <,=,> val following dir (-1,0,1) */ @@ -3033,7 +3033,7 @@ int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *param * \param params Configuration space * \param val approximate minimum buffer size in frames (on return filled with actual minimum) * \param dir Sub unit direction (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) */ @@ -3051,7 +3051,7 @@ int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *p * \param params Configuration space * \param val approximate maximum buffer size in frames (on return filled with actual maximum) * \param dir Sub unit direction (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) */ @@ -3071,7 +3071,7 @@ int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *p * \param mindir Sub unit direction for minimum (on return filled with actual direction) * \param max approximate maximum buffer size in frames (on return filled with actual maximum) * \param maxdir Sub unit direction for maximum (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1) */ @@ -3126,7 +3126,7 @@ snd_pcm_uframes_t snd_pcm_hw_params_set_buffer_size_last(snd_pcm_t *pcm, snd_pcm * \brief Extract tick time from a configuration space * \param params Configuration space * \param dir Sub unit direction - * \return approximate tick duration in us or a negative error code if not exactly one is present + * \return approximate tick duration in us otherwise a negative error code if not exactly one is present * * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) */ @@ -3182,7 +3182,7 @@ int snd_pcm_hw_params_test_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params * \param params Configuration space * \param val approximate tick duration in us * \param dir Sub unit direction - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted exact value is <,=,> val following dir (-1,0,1) */ @@ -3197,7 +3197,7 @@ int snd_pcm_hw_params_set_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, * \param params Configuration space * \param val approximate minimum tick duration in us (on return filled with actual minimum) * \param dir Sub unit direction (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) */ @@ -3212,7 +3212,7 @@ int snd_pcm_hw_params_set_tick_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *par * \param params Configuration space * \param val approximate maximum tick duration in us (on return filled with actual maximum) * \param dir Sub unit direction (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1) */ @@ -3229,7 +3229,7 @@ int snd_pcm_hw_params_set_tick_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *par * \param mindir Sub unit direction for minimum (on return filled with actual direction) * \param max approximate maximum tick duration in us (on return filled with actual maximum) * \param maxdir Sub unit direction for maximum (on return filled with actual direction) - * \return 0 or a negative error code if configuration space would become empty + * \return 0 otherwise a negative error code if configuration space would become empty * * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1) */ @@ -3284,7 +3284,7 @@ unsigned int snd_pcm_hw_params_set_tick_time_last(snd_pcm_t *pcm, snd_pcm_hw_par * \brief Return current software configuration for a PCM * \param pcm PCM handle * \param params Software configuration container - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) { @@ -3307,7 +3307,7 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) * \brief Dump a software configuration * \param params Software configuration container * \param out Output handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_sw_params_dump(snd_pcm_sw_params_t *params, snd_output_t *out) { @@ -3336,7 +3336,7 @@ size_t snd_pcm_sw_params_sizeof() /** * \brief allocate an invalid #snd_pcm_sw_params_t using standard malloc * \param ptr returned pointer - * \return zero on success otherwise negative error code + * \return 0 on success otherwise negative error code */ int snd_pcm_sw_params_malloc(snd_pcm_sw_params_t **ptr) { @@ -3372,7 +3372,7 @@ void snd_pcm_sw_params_copy(snd_pcm_sw_params_t *dst, const snd_pcm_sw_params_t * \param pcm PCM handle * \param params Software configuration container * \param val Start mode - * \return 0 or a negative error code + * \return 0 otherwise a negative error code */ int snd_pcm_sw_params_set_start_mode(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_start_t val) { @@ -3399,7 +3399,7 @@ snd_pcm_start_t snd_pcm_sw_params_get_start_mode(const snd_pcm_sw_params_t *para * \param pcm PCM handle * \param params Software configuration container * \param val Xrun mode - * \return 0 or a negative error code + * \return 0 otherwise a negative error code */ int snd_pcm_sw_params_set_xrun_mode(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_xrun_t val) { @@ -3426,7 +3426,7 @@ snd_pcm_xrun_t snd_pcm_sw_params_get_xrun_mode(const snd_pcm_sw_params_t *params * \param pcm PCM handle * \param params Software configuration container * \param val Timestamp mode - * \return 0 or a negative error code + * \return 0 otherwise a negative error code */ int snd_pcm_sw_params_set_tstamp_mode(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_tstamp_t val) { @@ -3469,7 +3469,7 @@ unsigned int snd_pcm_sw_params_get_period_step(const snd_pcm_sw_params_t *params * \param pcm PCM handle * \param params Software configuration container * \param val Minimum ticks to sleep or 0 to disable the use of tick timer - * \return 0 or a negative error code + * \return 0 otherwise a negative error code */ int snd_pcm_sw_params_set_sleep_min(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, unsigned int val) { @@ -3494,7 +3494,7 @@ unsigned int snd_pcm_sw_params_get_sleep_min(const snd_pcm_sw_params_t *params) * \param pcm PCM handle * \param params Software configuration container * \param val Minimum avail frames to consider PCM ready - * \return 0 or a negative error code + * \return 0 otherwise a negative error code */ int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val) { @@ -3520,7 +3520,7 @@ snd_pcm_uframes_t snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *par * \param pcm PCM handle * \param params Software configuration container * \param val Chunk size (frames are attempted to be transferred in chunks) - * \return 0 or a negative error code + * \return 0 otherwise a negative error code */ int snd_pcm_sw_params_set_xfer_align(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val) { @@ -3547,7 +3547,7 @@ snd_pcm_uframes_t snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *pa * \param pcm PCM handle * \param params Software configuration container * \param val Silence threshold in frames - * \return 0 or a negative error code + * \return 0 otherwise a negative error code * * A portion of playback buffer is overwritten with silence (see * #snd_pcm_sw_params_set_silence_size) when playback underrun is nearer @@ -3582,7 +3582,7 @@ snd_pcm_uframes_t snd_pcm_sw_params_get_silence_threshold(const snd_pcm_sw_param * \param pcm PCM handle * \param params Software configuration container * \param val Silence size in frames (0 for disabled) - * \return 0 or a negative error code + * \return 0 otherwise a negative error code * * A portion of playback buffer is overwritten with silence when playback * underrun is nearer than silence threshold (see @@ -3624,7 +3624,7 @@ size_t snd_pcm_status_sizeof() /** * \brief allocate an invalid #snd_pcm_status_t using standard malloc * \param ptr returned pointer - * \return zero on success otherwise negative error code + * \return 0 on success otherwise negative error code */ int snd_pcm_status_malloc(snd_pcm_status_t **ptr) { @@ -3733,7 +3733,7 @@ size_t snd_pcm_info_sizeof() /** * \brief allocate an invalid #snd_pcm_info_t using standard malloc * \param ptr returned pointer - * \return zero on success otherwise negative error code + * \return 0 on success otherwise negative error code */ int snd_pcm_info_malloc(snd_pcm_info_t **ptr) { @@ -3800,7 +3800,7 @@ snd_pcm_stream_t snd_pcm_info_get_stream(const snd_pcm_info_t *obj) /** * \brief Get card from a PCM info container * \param obj PCM info container - * \return card number or a negative error code if not associable to a card + * \return card number otherwise a negative error code if not associable to a card */ int snd_pcm_info_get_card(const snd_pcm_info_t *obj) { diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index 8858a15b..d6dac2d4 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -542,7 +542,7 @@ int snd_pcm_hw_open_subdevice(snd_pcm_t **pcmp, int card, int device, int subdev assert(pcmp); - if ((ret = snd_ctl_hw_open(&ctl, NULL, card)) < 0) + if ((ret = snd_ctl_hw_open(&ctl, NULL, card, 0)) < 0) return ret; switch (snd_enum_to_int(stream)) { diff --git a/src/pcm/pcm_meter.c b/src/pcm/pcm_meter.c index f8e106a9..907b6528 100644 --- a/src/pcm/pcm_meter.c +++ b/src/pcm/pcm_meter.c @@ -785,7 +785,7 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name, * \brief Add a scope to a #SND_PCM_TYPE_METER PCM * \param pcm PCM handle * \param scope Scope handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_pcm_meter_add_scope(snd_pcm_t *pcm, snd_pcm_scope_t *scope) { @@ -1115,7 +1115,7 @@ snd_pcm_scope_ops_t s16_ops = { * \brief Add a s16 pseudo scope to a #SND_PCM_TYPE_METER PCM * \param name Scope name * \param scopep Pointer to newly created and added scope - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code * * s16 pseudo scope convert #SND_PCM_TYPE_METER PCM frames in CPU endian * 16 bit frames for use with other scopes. Don't forget to insert it before @@ -1170,7 +1170,7 @@ int16_t *snd_pcm_scope_s16_get_channel_buffer(snd_pcm_scope_t *scope, /** * \brief allocate an invalid #snd_pcm_scope_t using standard malloc * \param ptr returned pointer - * \return zero on success otherwise negative error code + * \return 0 on success otherwise negative error code */ int snd_pcm_scope_malloc(snd_pcm_scope_t **ptr) { diff --git a/src/pcm/pcm_params.c b/src/pcm/pcm_params.c index 4e8d0978..0ccb4fee 100644 --- a/src/pcm/pcm_params.c +++ b/src/pcm/pcm_params.c @@ -2043,7 +2043,7 @@ int snd_pcm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) min rate min period_size max periods - Return 0 on success or a negative number expressing the error. + Return 0 on success otherwise a negative error code */ int _snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) { diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c index 4abd50a8..aa04d5cd 100644 --- a/src/rawmidi/rawmidi.c +++ b/src/rawmidi/rawmidi.c @@ -48,7 +48,7 @@ * \brief setup the default parameters * \param rawmidi RawMidi handle * \param params pointer to a snd_rawmidi_params_t structure - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ static int snd_rawmidi_params_default(snd_rawmidi_t *rawmidi, snd_rawmidi_params_t *params) { @@ -66,7 +66,7 @@ static int snd_rawmidi_params_default(snd_rawmidi_t *rawmidi, snd_rawmidi_params * \param outputp Returned output handle (NULL if not wanted) * \param name ASCII identifier of the RawMidi handle * \param mode Open mode - * \return a negative error code on failure or zero on success + * \return 0 on success otherwise a negative error code * * Opens a new connection to the RawMidi interface specified with * an ASCII identifier and mode. @@ -179,7 +179,7 @@ int snd_rawmidi_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, /** * \brief close RawMidi handle * \param rawmidi RawMidi handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code * * Closes the specified RawMidi handle and frees all associated * resources. @@ -202,7 +202,7 @@ int snd_rawmidi_close(snd_rawmidi_t *rawmidi) * \return ascii identifier of RawMidi handle * * Returns the ASCII identifier of given RawMidi handle. It's the same - * identifier as for snd_rawmidi_open(). + * identifier specified in snd_rawmidi_open(). */ const char *snd_rawmidi_name(snd_rawmidi_t *rawmidi) { @@ -269,7 +269,7 @@ int snd_rawmidi_poll_descriptors(snd_rawmidi_t *rawmidi, struct pollfd *pfds, un * \brief set nonblock mode * \param rawmidi RawMidi handle * \param nonblock 0 = block, 1 = nonblock mode - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_rawmidi_nonblock(snd_rawmidi_t *rawmidi, int nonblock) { @@ -297,7 +297,7 @@ size_t snd_rawmidi_info_sizeof() /** * \brief allocate a new snd_rawmidi_info_t structure * \param ptr returned pointer - * \return zero on success or a negative error code if fails + * \return 0 on success otherwise a negative error code if fails * * Allocates a new snd_rawmidi_params_t structure using the standard * malloc C library function. @@ -482,7 +482,7 @@ void snd_rawmidi_info_set_stream(snd_rawmidi_info_t *info, snd_rawmidi_stream_t * \brief get information about RawMidi handle * \param rawmidi RawMidi handle * \param info pointer to a snd_rawmidi_info_t structure to be filled - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_rawmidi_info(snd_rawmidi_t *rawmidi, snd_rawmidi_info_t * info) { @@ -503,7 +503,7 @@ size_t snd_rawmidi_params_sizeof() /** * \brief allocate the snd_rawmidi_params_t structure * \param ptr returned pointer - * \return zero on success or a negative error code if fails + * \return 0 on success otherwise a negative error code if fails * * Allocates a new snd_rawmidi_params_t structure using the standard * malloc C library function. @@ -546,7 +546,7 @@ void snd_rawmidi_params_copy(snd_rawmidi_params_t *dst, const snd_rawmidi_params * \param rawmidi RawMidi handle * \param params pointer to a snd_rawmidi_params_t structure * \param val size in bytes - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_rawmidi_params_set_buffer_size(snd_rawmidi_t *rawmidi ATTRIBUTE_UNUSED, snd_rawmidi_params_t *params, size_t val) { @@ -597,7 +597,7 @@ size_t snd_rawmidi_params_get_avail_min(const snd_rawmidi_params_t *params) * \param rawmidi RawMidi handle * \param params pointer to snd_rawmidi_params_t structure * \param val value: 0 = enable to send the active sensing message, 1 = disable - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_rawmidi_params_set_no_active_sensing(snd_rawmidi_t *rawmidi ATTRIBUTE_UNUSED, snd_rawmidi_params_t *params, int val) { @@ -621,7 +621,7 @@ int snd_rawmidi_params_get_no_active_sensing(const snd_rawmidi_params_t *params) * \brief get parameters about rawmidi stream * \param rawmidi RawMidi handle * \param params pointer to a snd_rawmidi_params_t structure to be filled - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_rawmidi_params(snd_rawmidi_t *rawmidi, snd_rawmidi_params_t * params) { @@ -641,7 +641,7 @@ int snd_rawmidi_params(snd_rawmidi_t *rawmidi, snd_rawmidi_params_t * params) * \brief get current parameters about rawmidi stream * \param rawmidi RawMidi handle * \param params pointer to a snd_rawmidi_params_t structure to be filled - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_rawmidi_params_current(snd_rawmidi_t *rawmidi, snd_rawmidi_params_t *params) { @@ -665,7 +665,7 @@ size_t snd_rawmidi_status_sizeof() /** * \brief allocate the snd_rawmidi_status_t structure * \param ptr returned pointer - * \return zero on success or a negative error code if fails + * \return 0 on success otherwise a negative error code if fails * * Allocates a new snd_rawmidi_status_t structure using the standard * malloc C library function. @@ -740,7 +740,7 @@ size_t snd_rawmidi_status_get_xruns(const snd_rawmidi_status_t *status) * \brief get status of rawmidi stream * \param rawmidi RawMidi handle * \param status pointer to a snd_rawmidi_status_t structure to be filled - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_rawmidi_status(snd_rawmidi_t *rawmidi, snd_rawmidi_status_t * status) { @@ -752,7 +752,7 @@ int snd_rawmidi_status(snd_rawmidi_t *rawmidi, snd_rawmidi_status_t * status) /** * \brief drop all bytes in the rawmidi I/O ring buffer immediately * \param rawmidi RawMidi handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code */ int snd_rawmidi_drop(snd_rawmidi_t *rawmidi) { @@ -763,7 +763,7 @@ int snd_rawmidi_drop(snd_rawmidi_t *rawmidi) /** * \brief drain all bytes in the rawmidi I/O ring buffer * \param rawmidi RawMidi handle - * \return zero on success otherwise a negative error code + * \return 0 on success otherwise a negative error code * * Waits until all MIDI bytes are not drained (sent) to the * hardware device. diff --git a/src/rawmidi/rawmidi_hw.c b/src/rawmidi/rawmidi_hw.c index ec0b5e7d..206ca47d 100644 --- a/src/rawmidi/rawmidi_hw.c +++ b/src/rawmidi/rawmidi_hw.c @@ -178,7 +178,7 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, if (outputp) *outputp = NULL; - if ((ret = snd_ctl_hw_open(&ctl, NULL, card)) < 0) + if ((ret = snd_ctl_hw_open(&ctl, NULL, card, 0)) < 0) return ret; sprintf(filename, SNDRV_FILE_RAWMIDI, card, device); diff --git a/src/timer/timer.c b/src/timer/timer.c index da5b6803..3bb96395 100644 --- a/src/timer/timer.c +++ b/src/timer/timer.c @@ -34,7 +34,7 @@ struct _snd_timer { int fd; }; -int snd_timer_open(snd_timer_t **handle) +int snd_timer_open(snd_timer_t **handle, int mode ATTRIBUTE_UNUSED) { int fd, ver; snd_timer_t *tmr; -- 2.47.1