Removed snd_enum_() macros.
Documentation changes in asoundlib.h.
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;
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);
@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 \
/** 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 */
* \{
*/
+/** 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)
/** \} */
* \{
*/
-#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" {
#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 */
#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
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);
*/
/** 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 */
/**
/** 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 */
{
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;
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;
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;
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];
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];
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;
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];
}
/**
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];
}
/**
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];
}
/**
{
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;
}
/**
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;
}
/**
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;
}
/**
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;
}
/**
{
assert(obj);
assert(idx < obj->used);
- return snd_int_to_enum(obj->pids[idx].iface);
+ return obj->pids[idx].iface;
}
/**
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;
}
/**
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;
}
/**
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;
}
/**
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;
}
/**
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;
}
/**
#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);
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;
}
/**
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;
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) {
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 */
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)
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)
+/**
+ * \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>
#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)
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,
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)
+/**
+ * \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>
* defines
*/
+#ifndef DOC_HIDDEN
+
#define IW_RAM_FILE "/proc/asound/%i/gus-ram-%i"
#define IW_ROM_FILE "/proc/asound/%i/gus-rom-%i"
unsigned int share_id3;
};
+#endif /* DOC_HIDDEN */
+
/*
* local functions
*/
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;
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;
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)
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;
}
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;
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];
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;
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;
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)
+/**
+ * \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>
#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)
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,
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)
*/
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",
};
const char *p;
assert(channel <= SND_MIXER_SCHN_LAST);
- p = array[snd_enum_to_int(channel)];
+ p = array[channel];
if (!p)
return "?";
return p;
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];
}
/**
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];
}
/**
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];
}
/**
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];
}
/**
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;
}
}
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];
}
/**
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];
}
/**
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
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
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];
}
/**
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];
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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);
}
/**
{
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;
{
assert(pcm && params);
assert(val <= SND_PCM_TSTAMP_LAST);
- params->tstamp_mode = snd_enum_to_int(val);
+ params->tstamp_mode = val;
return 0;
}
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;
}
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;
}
/**
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;
}
/**
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;
}
/**
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;
}
/**
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;
}
/**
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);
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;
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;
*/
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:
*/
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:
*/
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;
*/
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;
*/
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;
*/
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:
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];
}
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;
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);
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);
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));
{
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;
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 */
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 */
{
snd_pcm_hw_params_t save;
int err;
- switch (snd_enum_to_int(mode)) {
+ switch (mode) {
case SND_CHANGE:
break;
case SND_TRY:
{
snd_pcm_hw_params_t save;
int err;
- switch (snd_enum_to_int(mode)) {
+ switch (mode) {
case SND_CHANGE:
break;
case SND_TRY:
{
snd_pcm_hw_params_t save;
int err;
- switch (snd_enum_to_int(mode)) {
+ switch (mode) {
case SND_CHANGE:
break;
case SND_TRY:
{
snd_pcm_hw_params_t save;
int err;
- switch (snd_enum_to_int(mode)) {
+ switch (mode) {
case SND_CHANGE:
break;
case SND_TRY:
{
snd_pcm_hw_params_t save;
int err;
- switch (snd_enum_to_int(mode)) {
+ switch (mode) {
case SND_CHANGE:
break;
case SND_TRY:
{
snd_pcm_hw_params_t save;
int err;
- switch (snd_enum_to_int(mode)) {
+ switch (mode) {
case SND_CHANGE:
break;
case SND_TRY:
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);
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
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;
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;
{
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;
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:
}
#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)
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;
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;
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;
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;
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:
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:
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) {
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);
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:
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:
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;
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;
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);
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;
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)
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);
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];
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;
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;
}
/**
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;
}
/**
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;
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;
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;
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;
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;
+/**
+ * \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
*
#include <malloc.h>
#include "local.h"
+#ifndef DOC_HIDDEN
/* midi status */
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
*/
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);
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;
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) {
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)
{
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);
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)
{
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)
{