summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aserver/aserver.c4
-rw-r--r--include/Makefile.am8
-rw-r--r--include/control.h1
-rw-r--r--include/conv.h8
-rw-r--r--include/error.h4
-rw-r--r--include/global.h4
-rw-r--r--include/header.h10
-rw-r--r--include/instr.h60
-rw-r--r--include/pcm.h13
-rw-r--r--src/conf.c8
-rw-r--r--src/control/control.c32
-rw-r--r--src/control/hcontrol.c6
-rw-r--r--src/control/setup.c10
-rw-r--r--src/hwdep/hwdep_m4.c2
-rw-r--r--src/instr/fm.c25
-rw-r--r--src/instr/iwffff.c101
-rw-r--r--src/instr/simple.c25
-rw-r--r--src/mixer/simple.c4
-rw-r--r--src/pcm/pcm.c70
-rw-r--r--src/pcm/pcm_hw.c2
-rw-r--r--src/pcm/pcm_misc.c14
-rw-r--r--src/pcm/pcm_mmap.c6
-rw-r--r--src/pcm/pcm_null.c8
-rw-r--r--src/pcm/pcm_params.c26
-rw-r--r--src/pcm/pcm_plug.c16
-rw-r--r--src/pcm/pcm_share.c20
-rw-r--r--src/pcm/pcm_shm.c4
-rw-r--r--src/rawmidi/rawmidi.c14
-rw-r--r--src/rawmidi/rawmidi_hw.c10
-rw-r--r--src/seq/seq_midi_event.c152
30 files changed, 440 insertions, 227 deletions
diff --git a/aserver/aserver.c b/aserver/aserver.c
index 9ba0eea8..72633a1f 100644
--- a/aserver/aserver.c
+++ b/aserver/aserver.c
@@ -277,7 +277,7 @@ static int pcm_shm_open(client_t *client, int *cookie)
snd_pcm_t *pcm;
int err;
int result;
- err = snd_pcm_open(&pcm, client->name, snd_int_to_enum(client->stream), SND_PCM_NONBLOCK);
+ err = snd_pcm_open(&pcm, client->name, client->stream, SND_PCM_NONBLOCK);
if (err < 0)
return err;
client->device.pcm.handle = pcm;
@@ -417,7 +417,7 @@ static int pcm_shm_cmd(client_t *client)
ctrl->result = snd_pcm_status(pcm, (snd_pcm_status_t *) &ctrl->u.status);
break;
case SND_PCM_IOCTL_STATE:
- ctrl->result = snd_enum_to_int(snd_pcm_state(pcm));
+ ctrl->result = snd_pcm_state(pcm);
break;
case SNDRV_PCM_IOCTL_DELAY:
ctrl->result = snd_pcm_delay(pcm, (snd_pcm_sframes_t *) &ctrl->u.delay.frames);
diff --git a/include/Makefile.am b/include/Makefile.am
index 14ba36fe..e0c8c1c0 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -23,12 +23,14 @@ stamp-vh: $(top_builddir)/configure.in
@echo " * version.h" >> ver.tmp
@echo " */" >> ver.tmp
@echo "" >> ver.tmp
- @echo "#define SND_LIB_MAJOR $(SND_LIB_MAJOR)" >> ver.tmp
- @echo "#define SND_LIB_MINOR $(SND_LIB_MINOR)" >> ver.tmp
- @echo "#define SND_LIB_SUBMINOR $(SND_LIB_SUBMINOR)" >> ver.tmp
+ @echo "#define SND_LIB_MAJOR $(SND_LIB_MAJOR) /**< major number of library version */" >> ver.tmp
+ @echo "#define SND_LIB_MINOR $(SND_LIB_MINOR) /**< minor number of library version */" >> ver.tmp
+ @echo "#define SND_LIB_SUBMINOR $(SND_LIB_SUBMINOR) /**< subminor number of library version */" >> ver.tmp
+ @echo "/** library version */" >> ver.tmp
@echo "#define SND_LIB_VERSION ((SND_LIB_MAJOR<<16)|\\" >> ver.tmp
@echo " (SND_LIB_MINOR<<8)|\\" >> ver.tmp
@echo " SND_LIB_SUBMINOR)" >> ver.tmp
+ @echo "/** library version (string) */" >> ver.tmp
@echo "#define SND_LIB_VERSION_STR \"$(SND_LIB_VERSION)\"" >> ver.tmp
@echo >> ver.tmp
@cmp -s version.h ver.tmp \
diff --git a/include/control.h b/include/control.h
index a7e49e11..d510419a 100644
--- a/include/control.h
+++ b/include/control.h
@@ -84,6 +84,7 @@ typedef enum _snd_ctl_event_type {
/** Element value has been changed \hideinitializer */
#define SND_CTL_EVENT_MASK_VALUE SNDRV_CTL_EVENT_MASK_VALUE
+/** Element name for IEC958 (S/PDIF) */
#define SND_CTL_NAME_IEC958 SNDRV_CTL_NAME_IEC958
/** CTL type */
diff --git a/include/conv.h b/include/conv.h
index 3ca7fd65..45e5488e 100644
--- a/include/conv.h
+++ b/include/conv.h
@@ -11,13 +11,21 @@
* \{
*/
+/** convert 16-bit value from host to Little Endian byte order */
#define snd_host_to_LE_16(val) __cpu_to_le16(val)
+/** convert 16-bit value from Little Endian to host byte order */
#define snd_LE_to_host_16(val) __le16_to_cpu(val)
+/** convert 32-bit value from host to Little Endian byte order */
#define snd_host_to_LE_32(val) __cpu_to_le32(val)
+/** convert 32-bit value from Little Endian to host byte order */
#define snd_LE_to_host_32(val) __le32_to_cpu(val)
+/** convert 16-bit value from host to Big Endian byte order */
#define snd_host_to_BE_16(val) __cpu_to_be16(val)
+/** convert 16-bit value from Big Endian to host byte order */
#define snd_BE_to_host_16(val) __be16_to_cpu(val)
+/** convert 32-bit value from host to Big Endian byte order */
#define snd_host_to_BE_32(val) __cpu_to_be32(val)
+/** convert 32-bit value from Big Endian to host byte order */
#define snd_BE_to_host_32(val) __be32_to_cpu(val)
/** \} */
diff --git a/include/error.h b/include/error.h
index 6e6f0446..249cbc12 100644
--- a/include/error.h
+++ b/include/error.h
@@ -4,8 +4,8 @@
* \{
*/
-#define SND_ERROR_BEGIN 500000
-#define SND_ERROR_INCOMPATIBLE_VERSION (SND_ERROR_BEGIN+0)
+#define SND_ERROR_BEGIN 500000 /**< begin boundary of sound error codes */
+#define SND_ERROR_INCOMPATIBLE_VERSION (SND_ERROR_BEGIN+0) /**< protocol is not compatible */
#ifdef __cplusplus
extern "C" {
diff --git a/include/global.h b/include/global.h
index 9db9aff0..13cf47c6 100644
--- a/include/global.h
+++ b/include/global.h
@@ -12,10 +12,6 @@
#define SND_BIG_ENDIAN SNDRV_BIG_ENDIAN
#endif
-#define snd_enum_to_int(v) (v)
-#define snd_int_to_enum(v) (v)
-#define snd_enum_incr(v) (++(v))
-
/** \} */
/** Async notification client handler */
diff --git a/include/header.h b/include/header.h
index fd477662..e8275531 100644
--- a/include/header.h
+++ b/include/header.h
@@ -39,14 +39,14 @@
#include <errno.h>
#ifndef ATTRIBUTE_UNUSED
-#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+#define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) /**< don't print warning when attribute is not used */
#endif
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
-#define SNDERR(...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, 0, __VA_ARGS__)
-#define SYSERR(...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, errno, __VA_ARGS__)
+#define SNDERR(...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, 0, __VA_ARGS__) /**< show sound error */
+#define SYSERR(...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, errno, __VA_ARGS__) /**< show system error */
#else
-#define SNDERR(args...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, 0, ##args)
-#define SYSERR(args...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, errno, ##args)
+#define SNDERR(args...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, 0, ##args) /**< show sound error */
+#define SYSERR(args...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, errno, ##args) /**< show system error */
#endif
diff --git a/include/instr.h b/include/instr.h
index 7892432c..47c33e83 100644
--- a/include/instr.h
+++ b/include/instr.h
@@ -25,7 +25,7 @@ do {\
assert(ptr);\
*ptr = (snd_instr_header_t *)alloca(snd_instr_header_sizeof());\
memset(*ptr, 0, snd_instr_header_sizeof());\
-} while (0)
+} while (0) /**< allocate instrument header on stack */
int snd_instr_header_malloc(snd_instr_header_t **ptr, size_t len);
void snd_instr_header_free(snd_instr_header_t *ptr);
void snd_instr_header_copy(snd_instr_header_t *dst, const snd_instr_header_t *src);
@@ -61,45 +61,45 @@ void snd_instr_header_set_follow_alias(snd_instr_header_t *info, int val);
*/
/** instrument types */
-#define SND_SEQ_INSTR_ATYPE_DATA 0 /**< instrument data */
-#define SND_SEQ_INSTR_ATYPE_ALIAS 1 /**< instrument alias */
+#define SND_SEQ_INSTR_ATYPE_DATA SNDRV_SEQ_INSTR_ATYPE_DATA /**< instrument data */
+#define SND_SEQ_INSTR_ATYPE_ALIAS SNDRV_SEQ_INSTR_ATYPE_ALIAS /**< instrument alias */
/** instrument ASCII identifiers */
-#define SND_SEQ_INSTR_ID_DLS1 "DLS1" /**< DLS1 */
-#define SND_SEQ_INSTR_ID_DLS2 "DLS2" /**< DLS2 */
-#define SND_SEQ_INSTR_ID_SIMPLE "Simple Wave" /**< Simple Wave */
-#define SND_SEQ_INSTR_ID_SOUNDFONT "SoundFont" /**< SoundFont */
-#define SND_SEQ_INSTR_ID_GUS_PATCH "GUS Patch" /**< Gravis Patch */
-#define SND_SEQ_INSTR_ID_INTERWAVE "InterWave FFFF" /**< InterWave FFFF */
-#define SND_SEQ_INSTR_ID_OPL2_3 "OPL2/3 FM" /**< OPL2/3 FM */
-#define SND_SEQ_INSTR_ID_OPL4 "OPL4" /**< OPL4 */
+#define SND_SEQ_INSTR_ID_DLS1 SNDRV_SEQ_INSTR_ID_DLS1 /**< DLS1 */
+#define SND_SEQ_INSTR_ID_DLS2 SNDRV_SEQ_INSTR_ID_DLS2 /**< DLS2 */
+#define SND_SEQ_INSTR_ID_SIMPLE SNDRV_SEQ_INSTR_ID_SIMPLE /**< Simple Wave */
+#define SND_SEQ_INSTR_ID_SOUNDFONT SNDRV_SEQ_INSTR_ID_SOUNDFONT /**< SoundFont */
+#define SND_SEQ_INSTR_ID_GUS_PATCH SNDRV_SEQ_INSTR_ID_GUS_PATCH /**< Gravis Patch */
+#define SND_SEQ_INSTR_ID_INTERWAVE SNDRV_SEQ_INSTR_ID_INTERWAVE /**< InterWave FFFF */
+#define SND_SEQ_INSTR_ID_OPL2_3 SNDRV_SEQ_INSTR_ID_OPL2_3 /**< OPL2/3 FM */
+#define SND_SEQ_INSTR_ID_OPL4 SNDRV_SEQ_INSTR_ID_OPL4 /**< OPL4 */
/** instrument types */
-#define SND_SEQ_INSTR_TYPE0_DLS1 (1<<0) /**< MIDI DLS v1 */
-#define SND_SEQ_INSTR_TYPE0_DLS2 (1<<1) /**< MIDI DLS v2 */
-#define SND_SEQ_INSTR_TYPE1_SIMPLE (1<<0) /**< Simple Wave */
-#define SND_SEQ_INSTR_TYPE1_SOUNDFONT (1<<1) /**< EMU SoundFont */
-#define SND_SEQ_INSTR_TYPE1_GUS_PATCH (1<<2) /**< Gravis UltraSound Patch */
-#define SND_SEQ_INSTR_TYPE1_INTERWAVE (1<<3) /**< InterWave FFFF */
-#define SND_SEQ_INSTR_TYPE2_OPL2_3 (1<<0) /**< Yamaha OPL2/3 FM */
-#define SND_SEQ_INSTR_TYPE2_OPL4 (1<<1) /**< Yamaha OPL4 */
+#define SND_SEQ_INSTR_TYPE0_DLS1 SNDRV_SEQ_INSTR_TYPE0_DLS1 /**< MIDI DLS v1 */
+#define SND_SEQ_INSTR_TYPE0_DLS2 SNDRV_SEQ_INSTR_TYPE0_DLS2 /**< MIDI DLS v2 */
+#define SND_SEQ_INSTR_TYPE1_SIMPLE SNDRV_SEQ_INSTR_TYPE1_SIMPLE /**< Simple Wave */
+#define SND_SEQ_INSTR_TYPE1_SOUNDFONT SNDRV_SEQ_INSTR_TYPE1_SOUNDFONT /**< EMU SoundFont */
+#define SND_SEQ_INSTR_TYPE1_GUS_PATCH SNDRV_SEQ_INSTR_TYPE1_GUS_PATCH /**< Gravis UltraSound Patch */
+#define SND_SEQ_INSTR_TYPE1_INTERWAVE SNDRV_SEQ_INSTR_TYPE1_INTERWAVE /**< InterWave FFFF */
+#define SND_SEQ_INSTR_TYPE2_OPL2_3 SNDRV_SEQ_INSTR_TYPE2_OPL2_3 /**< Yamaha OPL2/3 FM */
+#define SND_SEQ_INSTR_TYPE2_OPL4 SNDRV_SEQ_INSTR_TYPE2_OPL4 /**< Yamaha OPL4 */
/** put commands */
-#define SND_SEQ_INSTR_PUT_CMD_CREATE 0 /**< create a new layer */
-#define SND_SEQ_INSTR_PUT_CMD_REPLACE 1 /**< replace the old layer with new one */
-#define SND_SEQ_INSTR_PUT_CMD_MODIFY 2 /**< modify the existing layer */
-#define SND_SEQ_INSTR_PUT_CMD_ADD 3 /**< add one to the existing layer */
-#define SND_SEQ_INSTR_PUT_CMD_REMOVE 4 /**< remove the layer */
+#define SND_SEQ_INSTR_PUT_CMD_CREATE SNDRV_SEQ_INSTR_PUT_CMD_CREATE /**< create a new layer */
+#define SND_SEQ_INSTR_PUT_CMD_REPLACE SNDRV_SEQ_INSTR_PUT_CMD_REPLACE /**< replace the old layer with new one */
+#define SND_SEQ_INSTR_PUT_CMD_MODIFY SNDRV_SEQ_INSTR_PUT_CMD_MODIFY /**< modify the existing layer */
+#define SND_SEQ_INSTR_PUT_CMD_ADD SNDRV_SEQ_INSTR_PUT_CMD_ADD /**< add one to the existing layer */
+#define SND_SEQ_INSTR_PUT_CMD_REMOVE SNDRV_SEQ_INSTR_PUT_CMD_REMOVE /**< remove the layer */
/** get commands */
-#define SND_SEQ_INSTR_GET_CMD_FULL 0 /**< get the full data stream */
-#define SND_SEQ_INSTR_GET_CMD_PARTIAL 1 /**< get the partial data stream */
+#define SND_SEQ_INSTR_GET_CMD_FULL SNDRV_SEQ_INSTR_GET_CMD_FULL /**< get the full data stream */
+#define SND_SEQ_INSTR_GET_CMD_PARTIAL SNDRV_SEQ_INSTR_GET_CMD_PARTIAL /**< get the partial data stream */
/** free commands */
-#define SND_SEQ_INSTR_FREE_CMD_ALL 0 /**< remove all matching instruments */
-#define SND_SEQ_INSTR_FREE_CMD_PRIVATE 1 /**< remove only private instruments */
-#define SND_SEQ_INSTR_FREE_CMD_CLUSTER 2 /**< remove only cluster instruments */
-#define SND_SEQ_INSTR_FREE_CMD_SINGLE 3 /**< remove single instrument */
+#define SND_SEQ_INSTR_FREE_CMD_ALL SNDRV_SEQ_INSTR_FREE_CMD_ALL /**< remove all matching instruments */
+#define SND_SEQ_INSTR_FREE_CMD_PRIVATE SNDRV_SEQ_INSTR_FREE_CMD_PRIVATE /**< remove only private instruments */
+#define SND_SEQ_INSTR_FREE_CMD_CLUSTER SNDRV_SEQ_INSTR_FREE_CMD_CLUSTER /**< remove only cluster instruments */
+#define SND_SEQ_INSTR_FREE_CMD_SINGLE SNDRV_SEQ_INSTR_FREE_CMD_SINGLE /**< remove single instrument */
/**
diff --git a/include/pcm.h b/include/pcm.h
index f0dea3bf..13634780 100644
--- a/include/pcm.h
+++ b/include/pcm.h
@@ -209,18 +209,31 @@ typedef sndrv_pcm_sframes_t snd_pcm_sframes_t;
/** Timestamp */
typedef struct timeval snd_timestamp_t;
+/** device accepts mmaped access */
#define SND_PCM_INFO_MMAP SNDRV_PCM_INFO_MMAP
+/** device accepts mmaped access with sample resolution */
#define SND_PCM_INFO_MMAP_VALID SNDRV_PCM_INFO_MMAP_VALID
+/** device is doing double buffering */
#define SND_PCM_INFO_DOUBLE SNDRV_PCM_INFO_DOUBLE
+/** device transfers samples in batch */
#define SND_PCM_INFO_BATCH SNDRV_PCM_INFO_BATCH
+/** device accepts interleaved samples */
#define SND_PCM_INFO_INTERLEAVED SNDRV_PCM_INFO_INTERLEAVED
+/** device accepts non-interleaved samples */
#define SND_PCM_INFO_NONINTERLEAVED SNDRV_PCM_INFO_NONINTERLEAVED
+/** device accepts complex sample organization */
#define SND_PCM_INFO_COMPLEX SNDRV_PCM_INFO_COMPLEX
+/** device is capable block transfers */
#define SND_PCM_INFO_BLOCK_TRANSFER SNDRV_PCM_INFO_BLOCK_TRANSFER
+/** device can detect DAC/ADC overrange */
#define SND_PCM_INFO_OVERRANGE SNDRV_PCM_INFO_OVERRANGE
+/** device is capable to pause */
#define SND_PCM_INFO_PAUSE SNDRV_PCM_INFO_PAUSE
+/** device can do only half duplex */
#define SND_PCM_INFO_HALF_DUPLEX SNDRV_PCM_INFO_HALF_DUPLEX
+/** device can do only joint duplex (same parameters) */
#define SND_PCM_INFO_JOINT_DUPLEX SNDRV_PCM_INFO_JOINT_DUPLEX
+/** device can do a kind of synchronized start */
#define SND_PCM_INFO_SYNC_START SNDRV_PCM_INFO_SYNC_START
/** Non blocking mode \hideinitializer */
diff --git a/src/conf.c b/src/conf.c
index f5542770..1d62ab31 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -874,7 +874,7 @@ static int _snd_config_save_leaf(snd_config_t *n, snd_output_t *out,
{
int err;
unsigned int k;
- switch (snd_enum_to_int(n->type)) {
+ switch (n->type) {
case SND_CONFIG_TYPE_INTEGER:
snd_output_printf(out, "%ld", n->u.integer);
break;
@@ -1149,7 +1149,7 @@ int snd_config_remove(snd_config_t *config)
int snd_config_delete(snd_config_t *config)
{
assert(config);
- switch (snd_enum_to_int(config->type)) {
+ switch (config->type) {
case SND_CONFIG_TYPE_COMPOUND:
{
int err;
@@ -1309,7 +1309,7 @@ int snd_config_set_string(snd_config_t *config, const char *value)
int snd_config_set_ascii(snd_config_t *config, const char *ascii)
{
assert(config && ascii);
- switch (snd_enum_to_int(config->type)) {
+ switch (config->type) {
case SND_CONFIG_TYPE_INTEGER:
{
long i;
@@ -1396,7 +1396,7 @@ int snd_config_get_string(snd_config_t *config, const char **ptr)
int snd_config_get_ascii(snd_config_t *config, char **ascii)
{
assert(config && ascii);
- switch (snd_enum_to_int(config->type)) {
+ switch (config->type) {
case SND_CONFIG_TYPE_INTEGER:
{
char res[12];
diff --git a/src/control/control.c b/src/control/control.c
index 8bad8885..91c047fd 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -437,8 +437,8 @@ snd_ctl_t *snd_async_handler_get_ctl(snd_async_handler_t *handler)
return handler->u.ctl;
}
-int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
- snd_config_t *ctl_root, snd_config_t *ctl_conf, int mode)
+static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
+ snd_config_t *ctl_root, snd_config_t *ctl_conf, int mode)
{
const char *str;
char buf[256];
@@ -520,7 +520,7 @@ int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
return err >= 0 ? open_func(ctlp, name, ctl_root, ctl_conf, mode) : err;
}
-int snd_ctl_open_noupdate(snd_ctl_t **ctlp, snd_config_t *root, const char *name, int mode)
+static int snd_ctl_open_noupdate(snd_ctl_t **ctlp, snd_config_t *root, const char *name, int mode)
{
int err;
snd_config_t *ctl_conf;
@@ -604,7 +604,7 @@ static const char *snd_ctl_event_type_names[] = {
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)];
+ return snd_ctl_elem_type_names[type];
}
/**
@@ -615,7 +615,7 @@ const char *snd_ctl_elem_type_name(snd_ctl_elem_type_t type)
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)];
+ return snd_ctl_elem_iface_names[iface];
}
/**
@@ -626,7 +626,7 @@ const char *snd_ctl_elem_iface_name(snd_ctl_elem_iface_t iface)
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)];
+ return snd_ctl_event_type_names[type];
}
/**
@@ -703,7 +703,7 @@ snd_ctl_elem_iface_t snd_ctl_event_elem_get_interface(const snd_ctl_event_t *obj
{
assert(obj);
assert(obj->type == SND_CTL_EVENT_ELEM);
- return snd_int_to_enum(obj->data.elem.id.iface);
+ return obj->data.elem.id.iface;
}
/**
@@ -833,7 +833,7 @@ unsigned int snd_ctl_elem_id_get_numid(const snd_ctl_elem_id_t *obj)
snd_ctl_elem_iface_t snd_ctl_elem_id_get_interface(const snd_ctl_elem_id_t *obj)
{
assert(obj);
- return snd_int_to_enum(obj->iface);
+ return obj->iface;
}
/**
@@ -899,7 +899,7 @@ void snd_ctl_elem_id_set_numid(snd_ctl_elem_id_t *obj, unsigned int val)
void snd_ctl_elem_id_set_interface(snd_ctl_elem_id_t *obj, snd_ctl_elem_iface_t val)
{
assert(obj);
- obj->iface = snd_enum_to_int(val);
+ obj->iface = val;
}
/**
@@ -1135,7 +1135,7 @@ void snd_ctl_event_copy(snd_ctl_event_t *dst, const snd_ctl_event_t *src)
snd_ctl_event_type_t snd_ctl_event_get_type(const snd_ctl_event_t *obj)
{
assert(obj);
- return snd_int_to_enum(obj->type);
+ return obj->type;
}
/**
@@ -1259,7 +1259,7 @@ snd_ctl_elem_iface_t snd_ctl_elem_list_get_interface(const snd_ctl_elem_list_t *
{
assert(obj);
assert(idx < obj->used);
- return snd_int_to_enum(obj->pids[idx].iface);
+ return obj->pids[idx].iface;
}
/**
@@ -1374,7 +1374,7 @@ void snd_ctl_elem_info_copy(snd_ctl_elem_info_t *dst, const snd_ctl_elem_info_t
snd_ctl_elem_type_t snd_ctl_elem_info_get_type(const snd_ctl_elem_info_t *obj)
{
assert(obj);
- return snd_int_to_enum(obj->type);
+ return obj->type;
}
/**
@@ -1577,7 +1577,7 @@ unsigned int snd_ctl_elem_info_get_numid(const snd_ctl_elem_info_t *obj)
snd_ctl_elem_iface_t snd_ctl_elem_info_get_interface(const snd_ctl_elem_info_t *obj)
{
assert(obj);
- return snd_int_to_enum(obj->id.iface);
+ return obj->id.iface;
}
/**
@@ -1654,7 +1654,7 @@ void snd_ctl_elem_info_set_numid(snd_ctl_elem_info_t *obj, unsigned int val)
void snd_ctl_elem_info_set_interface(snd_ctl_elem_info_t *obj, snd_ctl_elem_iface_t val)
{
assert(obj);
- obj->id.iface = snd_enum_to_int(val);
+ obj->id.iface = val;
}
/**
@@ -1783,7 +1783,7 @@ unsigned int snd_ctl_elem_value_get_numid(const snd_ctl_elem_value_t *obj)
snd_ctl_elem_iface_t snd_ctl_elem_value_get_interface(const snd_ctl_elem_value_t *obj)
{
assert(obj);
- return snd_int_to_enum(obj->id.iface);
+ return obj->id.iface;
}
/**
@@ -1860,7 +1860,7 @@ void snd_ctl_elem_value_set_numid(snd_ctl_elem_value_t *obj, unsigned int val)
void snd_ctl_elem_value_set_interface(snd_ctl_elem_value_t *obj, snd_ctl_elem_iface_t val)
{
assert(obj);
- obj->id.iface = snd_enum_to_int(val);
+ obj->id.iface = val;
}
/**
diff --git a/src/control/hcontrol.c b/src/control/hcontrol.c
index 80025e45..c3b5637a 100644
--- a/src/control/hcontrol.c
+++ b/src/control/hcontrol.c
@@ -35,10 +35,14 @@
#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
+#ifndef DOC_HIDDEN
#define __USE_GNU
+#endif
#include "control_local.h"
+#ifndef DOC_HIDDEN
#define NOT_FOUND 1000000000
+#endif
static int snd_hctl_compare_default(const snd_hctl_elem_t *c1,
const snd_hctl_elem_t *c2);
@@ -776,7 +780,7 @@ unsigned int snd_hctl_elem_get_numid(const snd_hctl_elem_t *obj)
snd_ctl_elem_iface_t snd_hctl_elem_get_interface(const snd_hctl_elem_t *obj)
{
assert(obj);
- return snd_int_to_enum(obj->id.iface);
+ return obj->id.iface;
}
/**
diff --git a/src/control/setup.c b/src/control/setup.c
index a2154aeb..aeb66a6c 100644
--- a/src/control/setup.c
+++ b/src/control/setup.c
@@ -196,7 +196,7 @@ static int snd_config_get_ctl_elem_enumerated(snd_config_t *n, snd_ctl_t *ctl,
const char *str;
long val;
unsigned int idx, items;
- switch (snd_enum_to_int(snd_config_get_type(n))) {
+ switch (snd_config_get_type(n)) {
case SND_CONFIG_TYPE_INTEGER:
snd_config_get_integer(n, &val);
return val;
@@ -239,7 +239,7 @@ static int snd_config_get_ctl_elem_value(snd_config_t *conf,
count = snd_ctl_elem_info_get_count(info);
type = snd_ctl_elem_info_get_type(info);
if (count == 1) {
- switch (snd_enum_to_int(type)) {
+ switch (type) {
case SND_CTL_ELEM_TYPE_BOOLEAN:
v = snd_config_get_bool(conf);
if (v >= 0) {
@@ -271,11 +271,11 @@ static int snd_config_get_ctl_elem_value(snd_config_t *conf,
case SND_CTL_ELEM_TYPE_IEC958:
break;
default:
- SNDERR("Unknow control type: %d", snd_enum_to_int(type));
+ SNDERR("Unknow control type: %d", type);
return -EINVAL;
}
}
- switch (snd_enum_to_int(type)) {
+ switch (type) {
case SND_CTL_ELEM_TYPE_IEC958:
count = sizeof(snd_aes_iec958_t);
/* Fall through */
@@ -329,7 +329,7 @@ static int snd_config_get_ctl_elem_value(snd_config_t *conf,
SNDERR("bad value index");
return -EINVAL;
}
- switch (snd_enum_to_int(type)) {
+ switch (type) {
case SND_CTL_ELEM_TYPE_BOOLEAN:
v = snd_config_get_bool(n);
if (v < 0)
diff --git a/src/hwdep/hwdep_m4.c b/src/hwdep/hwdep_m4.c
index c161351c..8d390a43 100644
--- a/src/hwdep/hwdep_m4.c
+++ b/src/hwdep/hwdep_m4.c
@@ -73,7 +73,7 @@ const char *snd_hwdep_info_get_name(const snd_hwdep_info_t *obj)
snd_hwdep_iface_t snd_hwdep_info_get_iface(const snd_hwdep_info_t *obj)
{
assert(obj);
- return snd_int_to_enum(obj->iface);
+ return obj->iface;
}
void snd_hwdep_info_set_device(snd_hwdep_info_t *obj, unsigned int val)
diff --git a/src/instr/fm.c b/src/instr/fm.c
index 6d31a702..e272c168 100644
--- a/src/instr/fm.c
+++ b/src/instr/fm.c
@@ -1,3 +1,8 @@
+/**
+ * \file src/instr/fm.c
+ * \author Uros Bizjak <uros@kss-loka.si>
+ * \date 2000-2001
+ */
/*
* FM (OPL2/3) Instrument Format Support
* Copyright (c) 2000 Uros Bizjak <uros@kss-loka.si>
@@ -27,6 +32,11 @@
#include <asm/byteorder.h>
#include <sound/ainstr_fm.h>
+/**
+ * \brief Free the FM instrument handle
+ * \param fm FM instrument handle
+ * \return 0 on success otherwise a negative error code
+ */
int snd_instr_fm_free(snd_instr_fm_t *fm)
{
if (fm == NULL)
@@ -35,6 +45,14 @@ int snd_instr_fm_free(snd_instr_fm_t *fm)
return 0;
}
+/**
+ * \brief Convert the FM instrument to byte stream
+ * \param fm FM instrument handle
+ * \param name FM instrument name
+ * \param __data Result - allocated byte stream
+ * \param __size Result - size of allocated byte stream
+ * \return 0 on success otherwise a negative error code
+ */
int snd_instr_fm_convert_to_stream(snd_instr_fm_t *fm,
const char *name,
snd_instr_header_t **__data,
@@ -89,6 +107,13 @@ int snd_instr_fm_convert_to_stream(snd_instr_fm_t *fm,
return 0;
}
+/**
+ * \brief Convert the byte stream to FM instrument
+ * \param __data Input - byte stream containing FM instrument definition
+ * \param size Input - size of byte stream
+ * \param simple Result - allocated FM instrument handle
+ * \return 0 on success otherwise a negative error code
+ */
int snd_instr_fm_convert_from_stream(snd_instr_header_t *__data ATTRIBUTE_UNUSED,
size_t size ATTRIBUTE_UNUSED,
snd_instr_fm_t **simple ATTRIBUTE_UNUSED)
diff --git a/src/instr/iwffff.c b/src/instr/iwffff.c
index df1fd172..de2a0658 100644
--- a/src/instr/iwffff.c
+++ b/src/instr/iwffff.c
@@ -1,3 +1,8 @@
+/**
+ * \file src/instr/iwffff.c
+ * \author Jaroslav Kysela <perex@suse.cz>
+ * \date 1999-2001
+ */
/*
* InterWave FFFF Format Support
* Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>
@@ -31,6 +36,8 @@
* defines
*/
+#ifndef DOC_HIDDEN
+
#define IW_RAM_FILE "/proc/asound/%i/gus-ram-%i"
#define IW_ROM_FILE "/proc/asound/%i/gus-rom-%i"
@@ -182,6 +189,8 @@ struct _snd_iwffff_handle {
unsigned int share_id3;
};
+#endif /* DOC_HIDDEN */
+
/*
* local functions
*/
@@ -201,6 +210,13 @@ static int iwffff_get_rom_header(int card, int bank, iwffff_rom_header_t *header
return fd;
}
+/**
+ * \brief Open IWFFFF files
+ * \param handle IWFFFF handle
+ * \param name_fff filename of an FFF (header) file
+ * \param name_dat filename of an DAT (data) file
+ * \return 0 on success otherwise a negative error code
+ */
int snd_instr_iwffff_open(snd_iwffff_handle_t **handle, const char *name_fff, const char *name_dat)
{
snd_iwffff_handle_t *iwf;
@@ -253,6 +269,14 @@ int snd_instr_iwffff_open(snd_iwffff_handle_t **handle, const char *name_fff, co
return 0;
}
+/**
+ * \brief Open IWFFFF ROM
+ * \param handle IWFFFF handle
+ * \param card card number
+ * \param bank ROM bank number (0-3)
+ * \param file ROM file number
+ * \return 0 on success otherwise a negative error code
+ */
int snd_instr_iwffff_open_rom(snd_iwffff_handle_t **handle, int card, int bank, int file)
{
unsigned int next_ffff;
@@ -265,7 +289,7 @@ int snd_instr_iwffff_open_rom(snd_iwffff_handle_t **handle, int card, int bank,
return -EINVAL;
*handle = NULL;
idx = 0;
- if (bank > 4 || file > 255)
+ if (bank > 3 || file > 255)
return -1;
fd = iwffff_get_rom_header(card, bank, &header);
if (fd < 0)
@@ -310,17 +334,36 @@ int snd_instr_iwffff_open_rom(snd_iwffff_handle_t **handle, int card, int bank,
return -ENOENT;
}
-int snd_instr_iwffff_close(snd_iwffff_handle_t *iwf)
+/**
+ * \brief Open IWFFFF ROM file
+ * \param handle IWFFFF handle
+ * \param name IWFFFF ROM filename
+ * \param bank ROM bank number (0-3)
+ * \param file ROM file number
+ * \return 0 on success otherwise a negative error code
+ */
+int snd_instr_iwffff_open_rom_file(snd_iwffff_handle_t **handle ATTRIBUTE_UNUSED, const char *name ATTRIBUTE_UNUSED, int bank ATTRIBUTE_UNUSED, int file ATTRIBUTE_UNUSED)
+{
+ /* TODO */
+ return -ENXIO;
+}
+
+/**
+ * \brief Close and free IWFFFF handle
+ * \param handle IWFFFF handle
+ * \return 0 on success otherwise a negative error code
+ */
+int snd_instr_iwffff_close(snd_iwffff_handle_t *handle)
{
- if (iwf == NULL)
+ if (handle == NULL)
return -EINVAL;
- if (iwf->dat_filename)
- free(iwf->dat_filename);
- if (iwf->fff_filename)
- free(iwf->fff_filename);
- if (iwf->fff_data)
- free(iwf->fff_data);
- free(iwf);
+ if (handle->dat_filename)
+ free(handle->dat_filename);
+ if (handle->fff_filename)
+ free(handle->fff_filename);
+ if (handle->fff_data)
+ free(handle->fff_data);
+ free(handle);
return 0;
}
@@ -368,6 +411,11 @@ static void free_layer(iwffff_layer_t *layer)
free(layer);
}
+/**
+ * \brief Free IWFFFF instrument
+ * \param __instr IWFFFF instrument handle
+ * \return 0 on success otherwise a negative error code
+ */
int snd_instr_iwffff_free(snd_instr_iwffff_t *__instr)
{
iwffff_instrument_t *instr = (iwffff_instrument_t *)__instr;
@@ -401,7 +449,7 @@ static char *look_for_id(snd_iwffff_handle_t *iwf ATTRIBUTE_UNUSED, unsigned cha
static void copy_modulation(iwffff_lfo_t *glfo, unsigned char *buffer)
{
glfo->freq = snd_LE_to_host_16(*(((unsigned short *)buffer) + 0/2));
- glfo->depth = snd_LE_to_host_16(*(((unsigned short *)buffer) + 2/1));
+ glfo->depth = snd_LE_to_host_16(*(((unsigned short *)buffer) + 2/2));
glfo->sweep = snd_LE_to_host_16(*(((unsigned short *)buffer) + 4/2));
glfo->shape = buffer[6];
glfo->delay = buffer[7];
@@ -607,6 +655,14 @@ static int load_iw_patch(snd_iwffff_handle_t *iwf, iwffff_instrument_t *instr,
return 0;
}
+/**
+ * \brief Load IWFFFF instrument
+ * \param iwf IWFFFF handle
+ * \param bank program bank number
+ * \param prg program number
+ * \param __iwffff allocated IWFFFF instrument
+ * \return 0 on success otherwise a negative error code
+ */
int snd_instr_iwffff_load(snd_iwffff_handle_t *iwf, int bank, int prg, snd_instr_iwffff_t **__iwffff)
{
unsigned char *ptr, *end;
@@ -738,10 +794,18 @@ static int copy_env_to_stream(iwffff_xenv_t *xenv, iwffff_env_t *env, __u32 styp
return size;
}
-int snd_instr_iwffff_conv_to_stream(snd_instr_iwffff_t *iwffff,
- const char *name,
- snd_instr_header_t **__data,
- long *__size)
+/**
+ * \brief Convert the IWFFFF instrument to byte stream
+ * \param iwffff IWFFFF instrument handle
+ * \param name instrument name
+ * \param __data Result - allocated byte stream
+ * \param __size Result - size of allocated byte stream
+ * \return 0 on success otherwise a negative error code
+ */
+int snd_instr_iwffff_convert_to_stream(snd_instr_iwffff_t *iwffff,
+ const char *name,
+ snd_instr_header_t **__data,
+ size_t *__size)
{
snd_instr_header_t *put;
int size;
@@ -827,6 +891,13 @@ int snd_instr_iwffff_conv_to_stream(snd_instr_iwffff_t *iwffff,
return 0;
}
+/**
+ * \brief Convert the byte stream to IWFFFF instrument
+ * \param data Input - byte stream
+ * \param size Input - size of byte stream
+ * \param iwffff Result - allocated IWFFFF instrument handle
+ * \return 0 on success otherwise a negative error code
+ */
int snd_instr_iwffff_convert_from_stream(snd_instr_header_t *data ATTRIBUTE_UNUSED,
size_t size ATTRIBUTE_UNUSED,
snd_instr_iwffff_t **iwffff ATTRIBUTE_UNUSED)
diff --git a/src/instr/simple.c b/src/instr/simple.c
index 3200210a..a2d4009e 100644
--- a/src/instr/simple.c
+++ b/src/instr/simple.c
@@ -1,3 +1,8 @@
+/**
+ * \file src/instr/simple.c
+ * \author Jaroslav Kysela <perex@suse.cz>
+ * \date 1999-2001
+ */
/*
* Simple Wave Format Support
* Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>
@@ -28,6 +33,11 @@
#include <asm/byteorder.h>
#include <sound/ainstr_simple.h>
+/**
+ * \brief Free simple instrument
+ * \param simple Simple instrument handle
+ * \return 0 on success otherwise a negative error code
+ */
int snd_instr_simple_free(snd_instr_simple_t *simple)
{
if (simple == NULL)
@@ -48,6 +58,14 @@ static long simple_size(simple_instrument_t *instr)
return size;
}
+/**
+ * \brief Convert the simple instrument to byte stream
+ * \param simple Simple instrument handle
+ * \param name Simple instrument name
+ * \param __data Result - allocated byte stream
+ * \param __size Result - size of allocated byte stream
+ * \return 0 on success otherwise a negative error code
+ */
int snd_instr_simple_convert_to_stream(snd_instr_simple_t *simple,
const char *name,
snd_instr_header_t **__data,
@@ -97,6 +115,13 @@ int snd_instr_simple_convert_to_stream(snd_instr_simple_t *simple,
return 0;
}
+/**
+ * \brief Convert the byte stream to simple instrument
+ * \param __data byte stream
+ * \param size size of byte stream
+ * \param simple Result - simple instrument handle
+ * \return 0 on success otherwise a negative error code
+ */
int snd_instr_simple_convert_from_stream(snd_instr_header_t *__data ATTRIBUTE_UNUSED,
size_t size ATTRIBUTE_UNUSED,
snd_instr_simple_t **simple ATTRIBUTE_UNUSED)
diff --git a/src/mixer/simple.c b/src/mixer/simple.c
index a2d99310..e3ad773c 100644
--- a/src/mixer/simple.c
+++ b/src/mixer/simple.c
@@ -1131,7 +1131,7 @@ static int _snd_mixer_selem_set_switch_all(snd_mixer_elem_t *elem, int dir, int
*/
const char *snd_mixer_selem_channel_name(snd_mixer_selem_channel_id_t channel)
{
- static const char *array[snd_enum_to_int(SND_MIXER_SCHN_LAST) + 1] = {
+ static const char *array[SND_MIXER_SCHN_LAST + 1] = {
[SND_MIXER_SCHN_FRONT_LEFT] = "Front Left",
[SND_MIXER_SCHN_FRONT_RIGHT] = "Front Right",
[SND_MIXER_SCHN_FRONT_CENTER] = "Front Center",
@@ -1141,7 +1141,7 @@ const char *snd_mixer_selem_channel_name(snd_mixer_selem_channel_id_t channel)
};
const char *p;
assert(channel <= SND_MIXER_SCHN_LAST);
- p = array[snd_enum_to_int(channel)];
+ p = array[channel];
if (!p)
return "?";
return p;
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index aea129a9..b8f25648 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -636,7 +636,7 @@ static const char *snd_pcm_tstamp_mode_names[] = {
const char *snd_pcm_stream_name(snd_pcm_stream_t stream)
{
assert(stream <= SND_PCM_STREAM_LAST);
- return snd_pcm_stream_names[snd_enum_to_int(stream)];
+ return snd_pcm_stream_names[stream];
}
/**
@@ -647,7 +647,7 @@ const char *snd_pcm_stream_name(snd_pcm_stream_t stream)
const char *snd_pcm_access_name(snd_pcm_access_t acc)
{
assert(acc <= SND_PCM_ACCESS_LAST);
- return snd_pcm_access_names[snd_enum_to_int(acc)];
+ return snd_pcm_access_names[acc];
}
/**
@@ -658,7 +658,7 @@ const char *snd_pcm_access_name(snd_pcm_access_t acc)
const char *snd_pcm_format_name(snd_pcm_format_t format)
{
assert(format <= SND_PCM_FORMAT_LAST);
- return snd_pcm_format_names[snd_enum_to_int(format)];
+ return snd_pcm_format_names[format];
}
/**
@@ -669,7 +669,7 @@ const char *snd_pcm_format_name(snd_pcm_format_t format)
const char *snd_pcm_format_description(snd_pcm_format_t format)
{
assert(format <= SND_PCM_FORMAT_LAST);
- return snd_pcm_format_descriptions[snd_enum_to_int(format)];
+ return snd_pcm_format_descriptions[format];
}
/**
@@ -680,9 +680,9 @@ const char *snd_pcm_format_description(snd_pcm_format_t format)
snd_pcm_format_t snd_pcm_format_value(const char* name)
{
snd_pcm_format_t format;
- for (format = 0; format <= SND_PCM_FORMAT_LAST; snd_enum_incr(format)) {
- if (snd_pcm_format_names[snd_enum_to_int(format)] &&
- strcasecmp(name, snd_pcm_format_names[snd_enum_to_int(format)]) == 0) {
+ for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) {
+ if (snd_pcm_format_names[format] &&
+ strcasecmp(name, snd_pcm_format_names[format]) == 0) {
return format;
}
}
@@ -697,7 +697,7 @@ snd_pcm_format_t snd_pcm_format_value(const char* name)
const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat)
{
assert(subformat <= SND_PCM_SUBFORMAT_LAST);
- return snd_pcm_subformat_names[snd_enum_to_int(subformat)];
+ return snd_pcm_subformat_names[subformat];
}
/**
@@ -708,7 +708,7 @@ const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat)
const char *snd_pcm_subformat_description(snd_pcm_subformat_t subformat)
{
assert(subformat <= SND_PCM_SUBFORMAT_LAST);
- return snd_pcm_subformat_descriptions[snd_enum_to_int(subformat)];
+ return snd_pcm_subformat_descriptions[subformat];
}
/**
@@ -719,10 +719,12 @@ const char *snd_pcm_subformat_description(snd_pcm_subformat_t subformat)
const char *snd_pcm_start_mode_name(snd_pcm_start_t mode)
{
assert(mode <= SND_PCM_START_LAST);
- return snd_pcm_start_mode_names[snd_enum_to_int(mode)];
+ return snd_pcm_start_mode_names[mode];
}
+#ifndef DOC_HIDDEN
link_warning(snd_pcm_start_mode_name, "Warning: start_mode is deprecated, consider to use start_threshold");
+#endif
/**
* \brief (DEPRECATED) get name of PCM xrun mode setting
@@ -732,10 +734,12 @@ link_warning(snd_pcm_start_mode_name, "Warning: start_mode is deprecated, consid
const char *snd_pcm_xrun_mode_name(snd_pcm_xrun_t mode)
{
assert(mode <= SND_PCM_XRUN_LAST);
- return snd_pcm_xrun_mode_names[snd_enum_to_int(mode)];
+ return snd_pcm_xrun_mode_names[mode];
}
+#ifndef DOC_HIDDEN
link_warning(snd_pcm_xrun_mode_name, "Warning: xrun_mode is deprecated, consider to use stop_threshold");
+#endif
/**
* \brief get name of PCM tstamp mode setting
@@ -745,7 +749,7 @@ link_warning(snd_pcm_xrun_mode_name, "Warning: xrun_mode is deprecated, consider
const char *snd_pcm_tstamp_mode_name(snd_pcm_tstamp_t mode)
{
assert(mode <= SND_PCM_TSTAMP_LAST);
- return snd_pcm_tstamp_mode_names[snd_enum_to_int(mode)];
+ return snd_pcm_tstamp_mode_names[mode];
}
/**
@@ -756,7 +760,7 @@ const char *snd_pcm_tstamp_mode_name(snd_pcm_tstamp_t mode)
const char *snd_pcm_state_name(snd_pcm_state_t state)
{
assert(state <= SND_PCM_STATE_LAST);
- return snd_pcm_state_names[snd_enum_to_int(state)];
+ return snd_pcm_state_names[state];
}
/**
@@ -1867,7 +1871,7 @@ int snd_pcm_hw_params_get_access(const snd_pcm_hw_params_t *params)
*/
int snd_pcm_hw_params_test_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t val)
{
- return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_ACCESS, snd_enum_to_int(val), 0);
+ return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_ACCESS, val, 0);
}
/**
@@ -1879,7 +1883,7 @@ int snd_pcm_hw_params_test_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, s
*/
int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t val)
{
- return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_ACCESS, snd_enum_to_int(val), 0);
+ return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_ACCESS, val, 0);
}
/**
@@ -1890,7 +1894,7 @@ int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, sn
*/
snd_pcm_access_t snd_pcm_hw_params_set_access_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- return snd_int_to_enum(snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_ACCESS, NULL));
+ return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_ACCESS, NULL);
}
/**
@@ -1901,7 +1905,7 @@ snd_pcm_access_t snd_pcm_hw_params_set_access_first(snd_pcm_t *pcm, snd_pcm_hw_p
*/
snd_pcm_access_t snd_pcm_hw_params_set_access_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- return snd_int_to_enum(snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_ACCESS, NULL));
+ return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_ACCESS, NULL);
}
/**
@@ -1969,7 +1973,7 @@ int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, sn
*/
snd_pcm_format_t snd_pcm_hw_params_set_format_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- return snd_int_to_enum(snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_FORMAT, NULL));
+ return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_FORMAT, NULL);
}
/**
@@ -1980,7 +1984,7 @@ snd_pcm_format_t snd_pcm_hw_params_set_format_first(snd_pcm_t *pcm, snd_pcm_hw_p
*/
snd_pcm_format_t snd_pcm_hw_params_set_format_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- return snd_int_to_enum(snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_FORMAT, NULL));
+ return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_FORMAT, NULL);
}
/**
@@ -2015,7 +2019,7 @@ void snd_pcm_hw_params_get_format_mask(snd_pcm_hw_params_t *params, snd_pcm_form
*/
int snd_pcm_hw_params_test_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t val)
{
- return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_SUBFORMAT, snd_enum_to_int(val), 0);
+ return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_SUBFORMAT, val, 0);
}
/**
@@ -2037,7 +2041,7 @@ int snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params)
*/
int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t val)
{
- return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_SUBFORMAT, snd_enum_to_int(val), 0);
+ return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_SUBFORMAT, val, 0);
}
/**
@@ -2048,7 +2052,7 @@ int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
*/
snd_pcm_subformat_t snd_pcm_hw_params_set_subformat_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- return snd_int_to_enum(snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_SUBFORMAT, NULL));
+ return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_SUBFORMAT, NULL);
}
/**
@@ -2059,7 +2063,7 @@ snd_pcm_subformat_t snd_pcm_hw_params_set_subformat_first(snd_pcm_t *pcm, snd_pc
*/
snd_pcm_subformat_t snd_pcm_hw_params_set_subformat_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- return snd_int_to_enum(snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_SUBFORMAT, NULL));
+ return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_SUBFORMAT, NULL);
}
/**
@@ -3368,7 +3372,7 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
{
assert(pcm && params);
assert(pcm->setup);
- params->tstamp_mode = snd_enum_to_int(pcm->tstamp_mode);
+ params->tstamp_mode = pcm->tstamp_mode;
params->period_step = pcm->period_step;
params->sleep_min = pcm->sleep_min;
params->avail_min = pcm->avail_min;
@@ -3537,7 +3541,7 @@ int snd_pcm_sw_params_set_tstamp_mode(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_s
{
assert(pcm && params);
assert(val <= SND_PCM_TSTAMP_LAST);
- params->tstamp_mode = snd_enum_to_int(val);
+ params->tstamp_mode = val;
return 0;
}
@@ -3549,7 +3553,7 @@ int snd_pcm_sw_params_set_tstamp_mode(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_s
snd_pcm_tstamp_t snd_pcm_sw_params_get_tstamp_mode(const snd_pcm_sw_params_t *params)
{
assert(params);
- return snd_int_to_enum(params->tstamp_mode);
+ return params->tstamp_mode;
}
@@ -3829,7 +3833,7 @@ void snd_pcm_status_copy(snd_pcm_status_t *dst, const snd_pcm_status_t *src)
snd_pcm_state_t snd_pcm_status_get_state(const snd_pcm_status_t *obj)
{
assert(obj);
- return snd_int_to_enum(obj->state);
+ return obj->state;
}
/**
@@ -3961,7 +3965,7 @@ unsigned int snd_pcm_info_get_subdevice(const snd_pcm_info_t *obj)
snd_pcm_stream_t snd_pcm_info_get_stream(const snd_pcm_info_t *obj)
{
assert(obj);
- return snd_int_to_enum(obj->stream);
+ return obj->stream;
}
/**
@@ -4016,7 +4020,7 @@ const char *snd_pcm_info_get_subdevice_name(const snd_pcm_info_t *obj)
snd_pcm_class_t snd_pcm_info_get_class(const snd_pcm_info_t *obj)
{
assert(obj);
- return snd_int_to_enum(obj->dev_class);
+ return obj->dev_class;
}
/**
@@ -4027,7 +4031,7 @@ snd_pcm_class_t snd_pcm_info_get_class(const snd_pcm_info_t *obj)
snd_pcm_subclass_t snd_pcm_info_get_subclass(const snd_pcm_info_t *obj)
{
assert(obj);
- return snd_int_to_enum(obj->dev_subclass);
+ return obj->dev_subclass;
}
/**
@@ -4082,7 +4086,7 @@ void snd_pcm_info_set_subdevice(snd_pcm_info_t *obj, unsigned int val)
void snd_pcm_info_set_stream(snd_pcm_info_t *obj, snd_pcm_stream_t val)
{
assert(obj);
- obj->stream = snd_enum_to_int(val);
+ obj->stream = val;
}
/**
@@ -4183,7 +4187,7 @@ snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_
if (size > pcm->xfer_align)
size -= size % pcm->xfer_align;
- switch (snd_enum_to_int(state)) {
+ switch (state) {
case SND_PCM_STATE_PREPARED:
if (size >= pcm->start_threshold) {
err = snd_pcm_start(pcm);
@@ -4267,7 +4271,7 @@ snd_pcm_sframes_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area
if (size > pcm->xfer_align)
size -= size % pcm->xfer_align;
- switch (snd_enum_to_int(state)) {
+ switch (state) {
case SND_PCM_STATE_PREPARED:
case SND_PCM_STATE_RUNNING:
break;
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index 07066ec8..327aad2a 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -545,7 +545,7 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, int card, int device, in
if ((ret = snd_ctl_hw_open(&ctl, NULL, card, 0)) < 0)
return ret;
- switch (snd_enum_to_int(stream)) {
+ switch (stream) {
case SND_PCM_STREAM_PLAYBACK:
filefmt = SNDRV_FILE_PCM_STREAM_PLAYBACK;
break;
diff --git a/src/pcm/pcm_misc.c b/src/pcm/pcm_misc.c
index 8d150fb4..7811b7da 100644
--- a/src/pcm/pcm_misc.c
+++ b/src/pcm/pcm_misc.c
@@ -34,7 +34,7 @@
*/
int snd_pcm_format_signed(snd_pcm_format_t format)
{
- switch (snd_enum_to_int(format)) {
+ switch (format) {
case SNDRV_PCM_FORMAT_S8:
case SNDRV_PCM_FORMAT_S16_LE:
case SNDRV_PCM_FORMAT_S16_BE:
@@ -88,7 +88,7 @@ int snd_pcm_format_linear(snd_pcm_format_t format)
*/
int snd_pcm_format_little_endian(snd_pcm_format_t format)
{
- switch (snd_enum_to_int(format)) {
+ switch (format) {
case SNDRV_PCM_FORMAT_S16_LE:
case SNDRV_PCM_FORMAT_U16_LE:
case SNDRV_PCM_FORMAT_S24_LE:
@@ -150,7 +150,7 @@ int snd_pcm_format_cpu_endian(snd_pcm_format_t format)
*/
int snd_pcm_format_width(snd_pcm_format_t format)
{
- switch (snd_enum_to_int(format)) {
+ switch (format) {
case SNDRV_PCM_FORMAT_S8:
case SNDRV_PCM_FORMAT_U8:
return 8;
@@ -194,7 +194,7 @@ int snd_pcm_format_width(snd_pcm_format_t format)
*/
int snd_pcm_format_physical_width(snd_pcm_format_t format)
{
- switch (snd_enum_to_int(format)) {
+ switch (format) {
case SNDRV_PCM_FORMAT_S8:
case SNDRV_PCM_FORMAT_U8:
return 8;
@@ -237,7 +237,7 @@ int snd_pcm_format_physical_width(snd_pcm_format_t format)
*/
ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples)
{
- switch (snd_enum_to_int(format)) {
+ switch (format) {
case SNDRV_PCM_FORMAT_S8:
case SNDRV_PCM_FORMAT_U8:
return samples;
@@ -283,7 +283,7 @@ ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples)
*/
u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format)
{
- switch (snd_enum_to_int(format)) {
+ switch (format) {
case SNDRV_PCM_FORMAT_S8:
case SNDRV_PCM_FORMAT_S16_LE:
case SNDRV_PCM_FORMAT_S16_BE:
@@ -518,5 +518,5 @@ snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_end
default:
return SND_PCM_FORMAT_UNKNOWN;
}
- return snd_int_to_enum(((int(*)[2][2])linear_formats)[width][!!unsignd][!!big_endian]);
+ return ((int(*)[2][2])linear_formats)[width][!!unsignd][!!big_endian];
}
diff --git a/src/pcm/pcm_mmap.c b/src/pcm/pcm_mmap.c
index c8d588d9..05cf5fae 100644
--- a/src/pcm/pcm_mmap.c
+++ b/src/pcm/pcm_mmap.c
@@ -166,7 +166,7 @@ int snd_pcm_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *info)
int snd_pcm_channel_info_shm(snd_pcm_t *pcm, snd_pcm_channel_info_t *info,
int shmid)
{
- switch (snd_enum_to_int(pcm->access)) {
+ switch (pcm->access) {
case SND_PCM_ACCESS_MMAP_INTERLEAVED:
case SND_PCM_ACCESS_RW_INTERLEAVED:
info->first = info->channel * pcm->sample_bits;
@@ -367,7 +367,7 @@ snd_pcm_sframes_t snd_pcm_write_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t size)
snd_pcm_uframes_t cont = pcm->buffer_size - offset;
if (cont < frames)
frames = cont;
- switch (snd_enum_to_int(pcm->access)) {
+ switch (pcm->access) {
case SND_PCM_ACCESS_MMAP_INTERLEAVED:
{
const snd_pcm_channel_area_t *a = snd_pcm_mmap_areas(pcm);
@@ -413,7 +413,7 @@ snd_pcm_sframes_t snd_pcm_read_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t size)
snd_pcm_uframes_t cont = pcm->buffer_size - offset;
if (cont < frames)
frames = cont;
- switch (snd_enum_to_int(pcm->access)) {
+ switch (pcm->access) {
case SND_PCM_ACCESS_MMAP_INTERLEAVED:
{
const snd_pcm_channel_area_t *a = snd_pcm_mmap_areas(pcm);
diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c
index f1425a85..0e6a3c63 100644
--- a/src/pcm/pcm_null.c
+++ b/src/pcm/pcm_null.c
@@ -55,7 +55,7 @@ static int snd_pcm_null_async(snd_pcm_t *pcm ATTRIBUTE_UNUSED, int sig ATTRIBUTE
static int snd_pcm_null_info(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_info_t * info)
{
memset(info, 0, sizeof(*info));
- info->stream = snd_enum_to_int(pcm->stream);
+ info->stream = pcm->stream;
info->card = -1;
strncpy(info->id, pcm->name, sizeof(info->id));
strncpy(info->name, pcm->name, sizeof(info->name));
@@ -74,7 +74,7 @@ static int snd_pcm_null_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
{
snd_pcm_null_t *null = pcm->private_data;
memset(status, 0, sizeof(*status));
- status->state = snd_enum_to_int(null->state);
+ status->state = null->state;
status->trigger_tstamp = null->trigger_tstamp;
gettimeofday(&status->tstamp, 0);
status->avail = pcm->buffer_size;
@@ -154,7 +154,7 @@ static int snd_pcm_null_pause(snd_pcm_t *pcm, int enable)
static snd_pcm_sframes_t snd_pcm_null_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
{
snd_pcm_null_t *null = pcm->private_data;
- switch (snd_enum_to_int(null->state)) {
+ switch (null->state) {
case SND_PCM_STATE_RUNNING:
snd_pcm_mmap_hw_backward(pcm, frames);
/* Fall through */
@@ -169,7 +169,7 @@ static snd_pcm_sframes_t snd_pcm_null_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t f
static snd_pcm_sframes_t snd_pcm_null_fwd(snd_pcm_t *pcm, snd_pcm_uframes_t size)
{
snd_pcm_null_t *null = pcm->private_data;
- switch (snd_enum_to_int(null->state)) {
+ switch (null->state) {
case SND_PCM_STATE_RUNNING:
snd_pcm_mmap_hw_forward(pcm, size);
/* Fall through */
diff --git a/src/pcm/pcm_params.c b/src/pcm/pcm_params.c
index 380ef054..a66d652e 100644
--- a/src/pcm/pcm_params.c
+++ b/src/pcm/pcm_params.c
@@ -232,7 +232,7 @@ int snd_pcm_hw_param_set_integer(snd_pcm_t *pcm,
{
snd_pcm_hw_params_t save;
int err;
- switch (snd_enum_to_int(mode)) {
+ switch (mode) {
case SND_CHANGE:
break;
case SND_TRY:
@@ -373,7 +373,7 @@ int snd_pcm_hw_param_set_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
{
snd_pcm_hw_params_t save;
int err;
- switch (snd_enum_to_int(mode)) {
+ switch (mode) {
case SND_CHANGE:
break;
case SND_TRY:
@@ -445,7 +445,7 @@ int snd_pcm_hw_param_set_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
{
snd_pcm_hw_params_t save;
int err;
- switch (snd_enum_to_int(mode)) {
+ switch (mode) {
case SND_CHANGE:
break;
case SND_TRY:
@@ -553,7 +553,7 @@ int snd_pcm_hw_param_set_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
{
snd_pcm_hw_params_t save;
int err;
- switch (snd_enum_to_int(mode)) {
+ switch (mode) {
case SND_CHANGE:
break;
case SND_TRY:
@@ -645,7 +645,7 @@ int snd_pcm_hw_param_set(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
{
snd_pcm_hw_params_t save;
int err;
- switch (snd_enum_to_int(mode)) {
+ switch (mode) {
case SND_CHANGE:
break;
case SND_TRY:
@@ -700,7 +700,7 @@ int snd_pcm_hw_param_set_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
{
snd_pcm_hw_params_t save;
int err;
- switch (snd_enum_to_int(mode)) {
+ switch (mode) {
case SND_CHANGE:
break;
case SND_TRY:
@@ -1049,13 +1049,13 @@ void snd_pcm_hw_param_dump(const snd_pcm_hw_params_t *params,
const char *s;
switch (var) {
case SND_PCM_HW_PARAM_ACCESS:
- s = snd_pcm_access_name(snd_int_to_enum(k));
+ s = snd_pcm_access_name(k);
break;
case SND_PCM_HW_PARAM_FORMAT:
- s = snd_pcm_format_name(snd_int_to_enum(k));
+ s = snd_pcm_format_name(k);
break;
case SND_PCM_HW_PARAM_SUBFORMAT:
- s = snd_pcm_subformat_name(snd_int_to_enum(k));
+ s = snd_pcm_subformat_name(k);
break;
default:
assert(0);
@@ -1100,7 +1100,7 @@ const char *snd_pcm_hw_param_names[] = {
const char *snd_pcm_hw_param_name(snd_pcm_hw_param_t param)
{
assert(param <= SND_PCM_HW_PARAM_LAST);
- return snd_pcm_hw_param_names[snd_enum_to_int(param)];
+ return snd_pcm_hw_param_names[param];
}
#if 0
@@ -1561,7 +1561,7 @@ static int snd_pcm_hw_rule_format(snd_pcm_hw_params_t *params,
snd_pcm_format_t k;
snd_mask_t *mask = hw_param_mask(params, rule->var);
snd_interval_t *i = hw_param_interval(params, rule->deps[0]);
- for (k = 0; k <= SND_PCM_FORMAT_LAST; snd_enum_incr(k)) {
+ for (k = 0; k <= SND_PCM_FORMAT_LAST; k++) {
int bits;
if (!snd_pcm_format_mask_test(mask, k))
continue;
@@ -1589,7 +1589,7 @@ static int snd_pcm_hw_rule_sample_bits(snd_pcm_hw_params_t *params,
int c, changed = 0;
min = UINT_MAX;
max = 0;
- for (k = 0; k <= SND_PCM_FORMAT_LAST; snd_enum_incr(k)) {
+ for (k = 0; k <= SND_PCM_FORMAT_LAST; k++) {
int bits;
if (!snd_pcm_format_mask_test(mask, k))
continue;
@@ -2022,7 +2022,7 @@ static int snd_pcm_sw_params_default(snd_pcm_t *pcm, snd_pcm_sw_params_t *params
{
assert(pcm && params);
assert(pcm->setup);
- params->tstamp_mode = snd_enum_to_int(SND_PCM_TSTAMP_NONE);
+ params->tstamp_mode = SND_PCM_TSTAMP_NONE;
params->period_step = 1;
params->sleep_min = 0;
params->avail_min = pcm->period_size;
diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c
index eea5d113..023110ab 100644
--- a/src/pcm/pcm_plug.c
+++ b/src/pcm/pcm_plug.c
@@ -124,7 +124,7 @@ static snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format, const
return format;
if (!snd_pcm_format_mask_test(&lin, format)) {
unsigned int i;
- switch (snd_enum_to_int(format)) {
+ switch (format) {
case SND_PCM_FORMAT_MU_LAW:
case SND_PCM_FORMAT_A_LAW:
case SND_PCM_FORMAT_IMA_ADPCM:
@@ -179,9 +179,9 @@ static snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format, const
}
#define SND_PCM_FMTBIT_PLUG (SND_PCM_FMTBIT_LINEAR | \
- (1 << snd_enum_to_int(SND_PCM_FORMAT_MU_LAW)) | \
- (1 << snd_enum_to_int(SND_PCM_FORMAT_A_LAW)) | \
- (1 << snd_enum_to_int(SND_PCM_FORMAT_IMA_ADPCM)))
+ (1 << SND_PCM_FORMAT_MU_LAW) | \
+ (1 << SND_PCM_FORMAT_A_LAW) | \
+ (1 << SND_PCM_FORMAT_IMA_ADPCM))
static void snd_pcm_plug_clear(snd_pcm_t *pcm)
@@ -299,7 +299,7 @@ static int snd_pcm_plug_change_format(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_p
clt->channels != slv->channels)
return 0;
cfmt = clt->format;
- switch (snd_enum_to_int(clt->format)) {
+ switch (clt->format) {
case SND_PCM_FORMAT_MU_LAW:
f = snd_pcm_mulaw_open;
break;
@@ -320,7 +320,7 @@ static int snd_pcm_plug_change_format(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_p
clt->rate == slv->rate &&
clt->channels == clt->channels)
return 0;
- switch (snd_enum_to_int(slv->format)) {
+ switch (slv->format) {
case SND_PCM_FORMAT_MU_LAW:
f = snd_pcm_mulaw_open;
break;
@@ -455,7 +455,7 @@ static int snd_pcm_plug_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p
sformat_mask = snd_pcm_hw_param_get_mask(sparams,
SND_PCM_HW_PARAM_FORMAT);
snd_mask_none(&sfmt_mask);
- for (format = 0; format <= SND_PCM_FORMAT_LAST; snd_enum_incr(format)) {
+ for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) {
snd_pcm_format_t f;
if (!snd_pcm_format_mask_test(format_mask, format))
continue;
@@ -530,7 +530,7 @@ static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
sformat_mask = snd_pcm_hw_param_get_mask(sparams,
SND_PCM_HW_PARAM_FORMAT);
snd_mask_none(&fmt_mask);
- for (format = 0; format <= SND_PCM_FORMAT_LAST; snd_enum_incr(format)) {
+ for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) {
snd_pcm_format_t f;
if (!snd_pcm_format_mask_test(format_mask, format))
continue;
diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c
index e64e55a6..529fad16 100644
--- a/src/pcm/pcm_share.c
+++ b/src/pcm/pcm_share.c
@@ -136,7 +136,7 @@ static snd_pcm_uframes_t _snd_pcm_share_slave_forward(snd_pcm_share_slave_t *sla
list_for_each(i, &slave->clients) {
snd_pcm_share_t *share = list_entry(i, snd_pcm_share_t, list);
snd_pcm_t *pcm = share->pcm;
- switch (snd_enum_to_int(share->state)) {
+ switch (share->state) {
case SND_PCM_STATE_RUNNING:
break;
case SND_PCM_STATE_DRAINING:
@@ -193,7 +193,7 @@ static snd_pcm_uframes_t _snd_pcm_share_missing(snd_pcm_t *pcm)
snd_pcm_uframes_t missing = INT_MAX;
snd_pcm_sframes_t ready_missing;
// printf("state=%d hw_ptr=%d appl_ptr=%d slave appl_ptr=%d safety=%d silence=%d\n", share->state, slave->hw_ptr, share->appl_ptr, *slave->pcm->appl_ptr, slave->safety_threshold, slave->silence_frames);
- switch (snd_enum_to_int(share->state)) {
+ switch (share->state) {
case SND_PCM_STATE_RUNNING:
break;
case SND_PCM_STATE_DRAINING:
@@ -232,7 +232,7 @@ static snd_pcm_uframes_t _snd_pcm_share_missing(snd_pcm_t *pcm)
missing = safety_missing;
}
}
- switch (snd_enum_to_int(share->state)) {
+ switch (share->state) {
case SND_PCM_STATE_DRAINING:
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
if (hw_avail <= 0) {
@@ -683,7 +683,7 @@ static int snd_pcm_share_status(snd_pcm_t *pcm, snd_pcm_status_t *status)
goto _end;
_notrunning:
status->delay = sd + d;
- status->state = snd_enum_to_int(share->state);
+ status->state = share->state;
status->trigger_tstamp = share->trigger_tstamp;
_end:
Pthread_mutex_unlock(&slave->mutex);
@@ -702,7 +702,7 @@ static int _snd_pcm_share_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
snd_pcm_share_slave_t *slave = share->slave;
int err = 0;
snd_pcm_sframes_t sd;
- switch (snd_enum_to_int(share->state)) {
+ switch (share->state) {
case SND_PCM_STATE_XRUN:
return -EPIPE;
case SND_PCM_STATE_RUNNING:
@@ -919,7 +919,7 @@ static snd_pcm_sframes_t _snd_pcm_share_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t
snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
snd_pcm_sframes_t n;
- switch (snd_enum_to_int(share->state)) {
+ switch (share->state) {
case SND_PCM_STATE_RUNNING:
break;
case SND_PCM_STATE_PREPARED:
@@ -1007,7 +1007,7 @@ static int snd_pcm_share_drain(snd_pcm_t *pcm)
snd_pcm_share_slave_t *slave = share->slave;
int err = 0;
Pthread_mutex_lock(&slave->mutex);
- switch (snd_enum_to_int(share->state)) {
+ switch (share->state) {
case SND_PCM_STATE_OPEN:
err = -EBADFD;
goto _end;
@@ -1020,7 +1020,7 @@ static int snd_pcm_share_drain(snd_pcm_t *pcm)
break;
}
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
- switch (snd_enum_to_int(share->state)) {
+ switch (share->state) {
case SND_PCM_STATE_XRUN:
share->state = SND_PCM_STATE_SETUP;
goto _end;
@@ -1037,7 +1037,7 @@ static int snd_pcm_share_drain(snd_pcm_t *pcm)
break;
}
} else {
- switch (snd_enum_to_int(share->state)) {
+ switch (share->state) {
case SND_PCM_STATE_RUNNING:
_snd_pcm_share_stop(pcm, SND_PCM_STATE_DRAINING);
_snd_pcm_share_update(pcm);
@@ -1065,7 +1065,7 @@ static int snd_pcm_share_drop(snd_pcm_t *pcm)
snd_pcm_share_slave_t *slave = share->slave;
int err = 0;
Pthread_mutex_lock(&slave->mutex);
- switch (snd_enum_to_int(share->state)) {
+ switch (share->state) {
case SND_PCM_STATE_OPEN:
err = -EBADFD;
goto _end;
diff --git a/src/pcm/pcm_shm.c b/src/pcm/pcm_shm.c
index 062a5398..bdba9215 100644
--- a/src/pcm/pcm_shm.c
+++ b/src/pcm/pcm_shm.c
@@ -341,7 +341,7 @@ static snd_pcm_state_t snd_pcm_shm_state(snd_pcm_t *pcm)
snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SND_PCM_IOCTL_STATE;
- return snd_int_to_enum(snd_pcm_shm_action(pcm));
+ return snd_pcm_shm_action(pcm);
}
static int snd_pcm_shm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
@@ -591,7 +591,7 @@ int snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, const char *sockname, c
memcpy(req->name, sname, snamelen);
req->dev_type = SND_DEV_TYPE_PCM;
req->transport_type = SND_TRANSPORT_TYPE_SHM;
- req->stream = snd_enum_to_int(stream);
+ req->stream = stream;
req->mode = mode;
req->namelen = snamelen;
err = write(sock, req, reqlen);
diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c
index f6169be1..54451a9d 100644
--- a/src/rawmidi/rawmidi.c
+++ b/src/rawmidi/rawmidi.c
@@ -60,9 +60,9 @@ static int snd_rawmidi_params_default(snd_rawmidi_t *rawmidi, snd_rawmidi_params
return 0;
}
-int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
- const char *name, snd_config_t *rawmidi_root,
- snd_config_t *rawmidi_conf, int mode)
+static int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
+ const char *name, snd_config_t *rawmidi_root,
+ snd_config_t *rawmidi_conf, int mode)
{
const char *str;
char buf[256];
@@ -159,8 +159,8 @@ int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
return 0;
}
-int snd_rawmidi_open_noupdate(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
- snd_config_t *root, const char *name, int mode)
+static int snd_rawmidi_open_noupdate(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
+ snd_config_t *root, const char *name, int mode)
{
int err;
snd_config_t *rawmidi_conf;
@@ -385,7 +385,7 @@ unsigned int snd_rawmidi_info_get_subdevice(const snd_rawmidi_info_t *info)
snd_rawmidi_stream_t snd_rawmidi_info_get_stream(const snd_rawmidi_info_t *info)
{
assert(info);
- return snd_int_to_enum(info->stream);
+ return info->stream;
}
/**
@@ -495,7 +495,7 @@ void snd_rawmidi_info_set_subdevice(snd_rawmidi_info_t *info, unsigned int val)
void snd_rawmidi_info_set_stream(snd_rawmidi_info_t *info, snd_rawmidi_stream_t val)
{
assert(info);
- info->stream = snd_enum_to_int(val);
+ info->stream = val;
}
/**
diff --git a/src/rawmidi/rawmidi_hw.c b/src/rawmidi/rawmidi_hw.c
index b09c2d76..49bb4fa4 100644
--- a/src/rawmidi/rawmidi_hw.c
+++ b/src/rawmidi/rawmidi_hw.c
@@ -75,7 +75,7 @@ static int snd_rawmidi_hw_nonblock(snd_rawmidi_t *rmidi, int nonblock)
static int snd_rawmidi_hw_info(snd_rawmidi_t *rmidi, snd_rawmidi_info_t * info)
{
snd_rawmidi_hw_t *hw = rmidi->private_data;
- info->stream = snd_enum_to_int(rmidi->stream);
+ info->stream = rmidi->stream;
if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_INFO, info) < 0) {
SYSERR("SNDRV_RAWMIDI_IOCTL_INFO failed");
return -errno;
@@ -86,7 +86,7 @@ static int snd_rawmidi_hw_info(snd_rawmidi_t *rmidi, snd_rawmidi_info_t * info)
static int snd_rawmidi_hw_params(snd_rawmidi_t *rmidi, snd_rawmidi_params_t * params)
{
snd_rawmidi_hw_t *hw = rmidi->private_data;
- params->stream = snd_enum_to_int(rmidi->stream);
+ params->stream = rmidi->stream;
if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_PARAMS, params) < 0) {
SYSERR("SNDRV_RAWMIDI_IOCTL_PARAMS failed");
return -errno;
@@ -97,7 +97,7 @@ static int snd_rawmidi_hw_params(snd_rawmidi_t *rmidi, snd_rawmidi_params_t * pa
static int snd_rawmidi_hw_status(snd_rawmidi_t *rmidi, snd_rawmidi_status_t * status)
{
snd_rawmidi_hw_t *hw = rmidi->private_data;
- status->stream = snd_enum_to_int(rmidi->stream);
+ status->stream = rmidi->stream;
if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_STATUS, status) < 0) {
SYSERR("SNDRV_RAWMIDI_IOCTL_STATUS failed");
return -errno;
@@ -108,7 +108,7 @@ static int snd_rawmidi_hw_status(snd_rawmidi_t *rmidi, snd_rawmidi_status_t * st
static int snd_rawmidi_hw_drop(snd_rawmidi_t *rmidi)
{
snd_rawmidi_hw_t *hw = rmidi->private_data;
- int str = snd_enum_to_int(rmidi->stream);
+ int str = rmidi->stream;
if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_DROP, &str) < 0) {
SYSERR("SNDRV_RAWMIDI_IOCTL_DROP failed");
return -errno;
@@ -119,7 +119,7 @@ static int snd_rawmidi_hw_drop(snd_rawmidi_t *rmidi)
static int snd_rawmidi_hw_drain(snd_rawmidi_t *rmidi)
{
snd_rawmidi_hw_t *hw = rmidi->private_data;
- int str = snd_enum_to_int(rmidi->stream);
+ int str = rmidi->stream;
if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_DRAIN, &str) < 0) {
SYSERR("SNDRV_RAWMIDI_IOCTL_DRAIN failed");
return -errno;
diff --git a/src/seq/seq_midi_event.c b/src/seq/seq_midi_event.c
index 5740fe11..9df1c841 100644
--- a/src/seq/seq_midi_event.c
+++ b/src/seq/seq_midi_event.c
@@ -1,3 +1,10 @@
+/**
+ * \file seq/seq_midi_event.c
+ * \author Takashi Iwai <tiwai@suse.de>
+ * \author Jaroslav Kysela <perex@suse.cz>
+ * \date 2000-2001
+ */
+
/*
* MIDI byte <-> sequencer event coder
*
@@ -22,6 +29,7 @@
#include <malloc.h>
#include "local.h"
+#ifndef DOC_HIDDEN
/* midi status */
struct snd_midi_event {
@@ -47,6 +55,8 @@ struct snd_midi_event {
typedef void (*event_encode_t)(snd_midi_event_t *dev, snd_seq_event_t *ev);
typedef void (*event_decode_t)(snd_seq_event_t *ev, unsigned char *buf);
+#endif /* DOC_HIDDEN */
+
/*
* prototypes
*/
@@ -72,31 +82,31 @@ static struct status_event_list_t {
event_decode_t decode;
} status_event[] = {
/* 0x80 - 0xf0 */
- {SNDRV_SEQ_EVENT_NOTEOFF, 2, note_event, note_decode},
- {SNDRV_SEQ_EVENT_NOTEON, 2, note_event, note_decode},
- {SNDRV_SEQ_EVENT_KEYPRESS, 2, note_event, note_decode},
- {SNDRV_SEQ_EVENT_CONTROLLER, 2, two_param_ctrl_event, two_param_decode},
- {SNDRV_SEQ_EVENT_PGMCHANGE, 1, one_param_ctrl_event, one_param_decode},
- {SNDRV_SEQ_EVENT_CHANPRESS, 1, one_param_ctrl_event, one_param_decode},
- {SNDRV_SEQ_EVENT_PITCHBEND, 2, pitchbend_ctrl_event, pitchbend_decode},
- {SNDRV_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf0 */
+ {SND_SEQ_EVENT_NOTEOFF, 2, note_event, note_decode},
+ {SND_SEQ_EVENT_NOTEON, 2, note_event, note_decode},
+ {SND_SEQ_EVENT_KEYPRESS, 2, note_event, note_decode},
+ {SND_SEQ_EVENT_CONTROLLER, 2, two_param_ctrl_event, two_param_decode},
+ {SND_SEQ_EVENT_PGMCHANGE, 1, one_param_ctrl_event, one_param_decode},
+ {SND_SEQ_EVENT_CHANPRESS, 1, one_param_ctrl_event, one_param_decode},
+ {SND_SEQ_EVENT_PITCHBEND, 2, pitchbend_ctrl_event, pitchbend_decode},
+ {SND_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf0 */
/* 0xf0 - 0xff */
- {SNDRV_SEQ_EVENT_SYSEX, 1, NULL, NULL}, /* sysex: 0xf0 */
- {SNDRV_SEQ_EVENT_QFRAME, 1, one_param_event, one_param_decode}, /* 0xf1 */
- {SNDRV_SEQ_EVENT_SONGPOS, 2, songpos_event, songpos_decode}, /* 0xf2 */
- {SNDRV_SEQ_EVENT_SONGSEL, 1, one_param_event, one_param_decode}, /* 0xf3 */
- {SNDRV_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf4 */
- {SNDRV_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf5 */
- {SNDRV_SEQ_EVENT_TUNE_REQUEST, 0, NULL, NULL}, /* 0xf6 */
- {SNDRV_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf7 */
- {SNDRV_SEQ_EVENT_CLOCK, 0, NULL, NULL}, /* 0xf8 */
- {SNDRV_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf9 */
- {SNDRV_SEQ_EVENT_START, 0, NULL, NULL}, /* 0xfa */
- {SNDRV_SEQ_EVENT_CONTINUE, 0, NULL, NULL}, /* 0xfb */
- {SNDRV_SEQ_EVENT_STOP, 0, NULL, NULL}, /* 0xfc */
- {SNDRV_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xfd */
- {SNDRV_SEQ_EVENT_SENSING, 0, NULL, NULL}, /* 0xfe */
- {SNDRV_SEQ_EVENT_RESET, 0, NULL, NULL}, /* 0xff */
+ {SND_SEQ_EVENT_SYSEX, 1, NULL, NULL}, /* sysex: 0xf0 */
+ {SND_SEQ_EVENT_QFRAME, 1, one_param_event, one_param_decode}, /* 0xf1 */
+ {SND_SEQ_EVENT_SONGPOS, 2, songpos_event, songpos_decode}, /* 0xf2 */
+ {SND_SEQ_EVENT_SONGSEL, 1, one_param_event, one_param_decode}, /* 0xf3 */
+ {SND_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf4 */
+ {SND_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf5 */
+ {SND_SEQ_EVENT_TUNE_REQUEST, 0, NULL, NULL}, /* 0xf6 */
+ {SND_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf7 */
+ {SND_SEQ_EVENT_CLOCK, 0, NULL, NULL}, /* 0xf8 */
+ {SND_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf9 */
+ {SND_SEQ_EVENT_START, 0, NULL, NULL}, /* 0xfa */
+ {SND_SEQ_EVENT_CONTINUE, 0, NULL, NULL}, /* 0xfb */
+ {SND_SEQ_EVENT_STOP, 0, NULL, NULL}, /* 0xfc */
+ {SND_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xfd */
+ {SND_SEQ_EVENT_SENSING, 0, NULL, NULL}, /* 0xfe */
+ {SND_SEQ_EVENT_RESET, 0, NULL, NULL}, /* 0xff */
};
static int extra_decode_ctrl14(snd_midi_event_t *dev, unsigned char *buf, int len, snd_seq_event_t *ev);
@@ -105,17 +115,21 @@ static struct extra_event_list_t {
int event;
int (*decode)(snd_midi_event_t *dev, unsigned char *buf, int len, snd_seq_event_t *ev);
} extra_event[] = {
- {SNDRV_SEQ_EVENT_CONTROL14, extra_decode_ctrl14},
- /*{SNDRV_SEQ_EVENT_NONREGPARAM, extra_decode_nrpn},*/
- /*{SNDRV_SEQ_EVENT_REGPARAM, extra_decode_rpn},*/
+ {SND_SEQ_EVENT_CONTROL14, extra_decode_ctrl14},
+ /*{SND_SEQ_EVENT_NONREGPARAM, extra_decode_nrpn},*/
+ /*{SND_SEQ_EVENT_REGPARAM, extra_decode_rpn},*/
};
#define numberof(ary) (sizeof(ary)/sizeof(ary[0]))
-/*
- * new/delete record
+/**
+ * \brief Initialize MIDI event parser
+ * \param bufsize buffer size for MIDI message
+ * \param rdev allocated MIDI event parser
+ * \return 0 on success otherwise a negative error code
+ *
+ * Allocates and initializes MIDI event parser.
*/
-
int snd_midi_event_new(size_t bufsize, snd_midi_event_t **rdev)
{
snd_midi_event_t *dev;
@@ -136,6 +150,13 @@ int snd_midi_event_new(size_t bufsize, snd_midi_event_t **rdev)
return 0;
}
+/**
+ * \brief Free MIDI event parser
+ * \param rdev MIDI event parser
+ * \return 0 on success otherwise a negative error code
+ *
+ * Frees MIDI event parser.
+ */
void snd_midi_event_free(snd_midi_event_t *dev)
{
if (dev != NULL) {
@@ -155,24 +176,50 @@ inline static void reset_encode(snd_midi_event_t *dev)
dev->type = 0;
}
+/**
+ * \brief Reset MIDI encode parser
+ * \param dev MIDI event parser
+ * \return 0 on success otherwise a negative error code
+ *
+ * Resets MIDI encode parser
+ */
void snd_midi_event_reset_encode(snd_midi_event_t *dev)
{
reset_encode(dev);
}
+/**
+ * \brief Reset MIDI decode parser
+ * \param dev MIDI event parser
+ * \return 0 on success otherwise a negative error code
+ *
+ * Resets MIDI decode parser
+ */
void snd_midi_event_reset_decode(snd_midi_event_t *dev)
{
dev->lastcmd = 0xff;
}
+/**
+ * \brief Initializes MIDI parsers
+ * \param dev MIDI event parser
+ * \return 0 on success otherwise a negative error code
+ *
+ * Initializes MIDI parsers (both encode and decode)
+ */
void snd_midi_event_init(snd_midi_event_t *dev)
{
snd_midi_event_reset_encode(dev);
snd_midi_event_reset_decode(dev);
}
-/*
- * resize buffer
+/**
+ * \brief Resize MIDI message (event) buffer
+ * \param dev MIDI event parser
+ * \param bufsize new requested buffer size
+ * \return 0 on success otherwise a negative error code
+ *
+ * Resizes MIDI message (event) buffer.
*/
int snd_midi_event_resize_buffer(snd_midi_event_t *dev, size_t bufsize)
{
@@ -192,16 +239,24 @@ int snd_midi_event_resize_buffer(snd_midi_event_t *dev, size_t bufsize)
return 0;
}
-/*
- * read bytes and encode to sequencer event if finished
- * return the size of encoded bytes
+/**
+ * \brief Read bytes and encode to sequencer event if finished
+ * \param dev MIDI event parser
+ * \param buf MIDI byte stream
+ * \param count count of bytes of MIDI byte stream to encode
+ * \param ev Result - sequencer event
+ * \return count of encoded bytes otherwise a negative error code
+ *
+ * Read bytes and encode to sequencer event if finished.
+ * If complete sequencer event is available, ev->type is not
+ * equal to #SND_SEQ_EVENT_NONE.
*/
long snd_midi_event_encode(snd_midi_event_t *dev, unsigned char *buf, long count, snd_seq_event_t *ev)
{
long result = 0;
int rc;
- ev->type = SNDRV_SEQ_EVENT_NONE;
+ ev->type = SND_SEQ_EVENT_NONE;
while (count-- > 0) {
rc = snd_midi_event_encode_byte(dev, *buf++, ev);
@@ -215,11 +270,14 @@ long snd_midi_event_encode(snd_midi_event_t *dev, unsigned char *buf, long count
return result;
}
-/*
- * read one byte and encode to sequencer event:
- * return 1 if MIDI bytes are encoded to an event
- * 0 data is not finished
- * negative for error
+/**
+ * \brief Read one byte and encode to sequencer event if finished
+ * \param dev MIDI event parser
+ * \param c a byte of MIDI stream
+ * \param ev Result - sequencer event
+ * \return 1 - sequencer event is completed, 0 - next byte is required for completion, otherwise a negative error code
+ *
+ * Read byte and encode to sequencer event if finished.
*/
int snd_midi_event_encode_byte(snd_midi_event_t *dev, int c, snd_seq_event_t *ev)
{
@@ -323,9 +381,15 @@ static void songpos_event(snd_midi_event_t *dev, snd_seq_event_t *ev)
ev->data.control.value = (int)dev->buf[2] * 128 + (int)dev->buf[1];
}
-/*
- * decode from a sequencer event to midi bytes
- * return the size of decoded midi events
+/**
+ * \brief Decode sequencer event to MIDI byte stream
+ * \param dev MIDI event parser
+ * \param buf Result - MIDI byte stream
+ * \param count Available bytes in MIDI byte stream
+ * \param ev Event to decode
+ * \return count of decoded bytes otherwise a negative error code
+ *
+ * Decode sequencer event to MIDI byte stream.
*/
long snd_midi_event_decode(snd_midi_event_t *dev, unsigned char *buf, long count, snd_seq_event_t *ev)
{