From 08232943a24bdfb2623fda561a4cd8bf44a714cb Mon Sep 17 00:00:00 2001 From: Abramo Bagnara Date: Thu, 29 Mar 2001 10:11:38 +0000 Subject: [PATCH] Get rid of enum type checking ugly trick --- include/global.h | 9 --------- include/hwdep.h | 26 ++++++++++++-------------- include/local.h | 14 ++------------ include/mixer.h | 34 ++++------------------------------ include/seq.h | 15 +++------------ include/timer.h | 34 +++++++++++++++------------------- 6 files changed, 36 insertions(+), 96 deletions(-) diff --git a/include/global.h b/include/global.h index 76c8a26f..76a61d00 100644 --- a/include/global.h +++ b/include/global.h @@ -10,15 +10,6 @@ #define SND_BIG_ENDIAN SNDRV_BIG_ENDIAN #endif -//#define SND_ENUM_TYPECHECK - -#ifdef SND_ENUM_TYPECHECK -#define snd_enum_to_int(v) ((unsigned int)(unsigned long)(v)) -#define snd_int_to_enum(v) ((void *)(unsigned long)(v)) -#define snd_enum_incr(v) (++(unsigned long)(v)) -#else #define snd_enum_to_int(v) (v) #define snd_int_to_enum(v) (v) #define snd_enum_incr(v) (++(v)) -#endif - diff --git a/include/hwdep.h b/include/hwdep.h index 4b8da59a..2f97369a 100644 --- a/include/hwdep.h +++ b/include/hwdep.h @@ -5,28 +5,26 @@ * * ****************************************************************************/ +/** HwDep information container */ typedef struct _snd_hwdep_info snd_hwdep_info_t; -#ifdef SND_ENUM_TYPECHECK -typedef struct __snd_hwdep_type *snd_hwdep_type_t; -#else -typedef enum sndrv_hwdep_type snd_hwdep_type_t; -#endif - -#define SND_HWDEP_TYPE_OPL2 ((snd_hwdep_type_t) SNDRV_HWDEP_TYPE_OPL2) -#define SND_HWDEP_TYPE_OPL3 ((snd_hwdep_type_t) SNDRV_HWDEP_TYPE_OPL3) -#define SND_HWDEP_TYPE_OPL4 ((snd_hwdep_type_t) SNDRV_HWDEP_TYPE_OPL4) -#define SND_HWDEP_TYPE_SB16CSP ((snd_hwdep_type_t) SNDRV_HWDEP_TYPE_SB16CSP) -#define SND_HWDEP_TYPE_EMU10K1 ((snd_hwdep_type_t) SNDRV_HWDEP_TYPE_EMU10K1) -#define SND_HWDEP_TYPE_YSS225 ((snd_hwdep_type_t) SNDRV_HWDEP_TYPE_YSS225) -#define SND_HWDEP_TYPE_ICS2115 ((snd_hwdep_type_t) SNDRV_HWDEP_TYPE_ICS2115) -#define SND_HWDEP_TYPE_LAST ((snd_hwdep_type_t) SNDRV_HWDEP_TYPE_LAST) +typedef enum _snd_hwdep_type { + SND_HWDEP_TYPE_OPL2 = SNDRV_HWDEP_TYPE_OPL2, + SND_HWDEP_TYPE_OPL3 = SNDRV_HWDEP_TYPE_OPL3, + SND_HWDEP_TYPE_OPL4 = SNDRV_HWDEP_TYPE_OPL4, + SND_HWDEP_TYPE_SB16CSP = SNDRV_HWDEP_TYPE_SB16CSP, + SND_HWDEP_TYPE_EMU10K1 = SNDRV_HWDEP_TYPE_EMU10K1, + SND_HWDEP_TYPE_YSS225 = SNDRV_HWDEP_TYPE_YSS225, + SND_HWDEP_TYPE_ICS2115 = SNDRV_HWDEP_TYPE_ICS2115, + SND_HWDEP_TYPE_LAST = SNDRV_HWDEP_TYPE_LAST, +} snd_hwdep_type_t; #define SND_HWDEP_OPEN_READ (O_RDONLY) #define SND_HWDEP_OPEN_WRITE (O_WRONLY) #define SND_HWDEP_OPEN_DUPLEX (O_RDWR) #define SND_HWDEP_OPEN_NONBLOCK (O_NONBLOCK) +/** HwDep handle */ typedef struct _snd_hwdep snd_hwdep_t; #ifdef __cplusplus diff --git a/include/local.h b/include/local.h index 7cad3f45..46eed27f 100644 --- a/include/local.h +++ b/include/local.h @@ -43,21 +43,11 @@ #include "asoundlib.h" -enum _snd_set_mode { +typedef enum _snd_set_mode { SND_CHANGE, SND_TRY, SND_TEST, -}; - -#ifdef SND_ENUM_TYPECHECK -typedef struct __snd_set_mode *snd_set_mode_t; -#else -typedef enum _snd_set_mode snd_set_mode_t; -#endif - -#define SND_CHANGE ((snd_set_mode_t) SND_CHANGE) -#define SND_TRY ((snd_set_mode_t) SND_TRY) -#define SND_TEST ((snd_set_mode_t) SND_TEST) +} snd_set_mode_t; size_t page_align(size_t size); size_t page_size(void); diff --git a/include/mixer.h b/include/mixer.h index f012d097..5dbf8f36 100644 --- a/include/mixer.h +++ b/include/mixer.h @@ -17,20 +17,10 @@ typedef int (*snd_mixer_elem_callback_t)(snd_mixer_elem_t *elem, typedef int (*snd_mixer_compare_t)(const snd_mixer_elem_t *e1, const snd_mixer_elem_t *e2); -enum _snd_mixer_elem_type { +typedef enum _snd_mixer_elem_type { SND_MIXER_ELEM_SIMPLE, SND_MIXER_ELEM_LAST = SND_MIXER_ELEM_SIMPLE, -}; - -#ifdef SND_ENUM_TYPECHECK -typedef struct __snd_mixer_elem_type *snd_mixer_elem_type_t; -#else -typedef enum _snd_mixer_elem_type snd_mixer_elem_type_t; -#endif - -#define SND_MIXER_ELEM_SIMPLE ((snd_mixer_elem_type_t) SND_MIXER_ELEM_SIMPLE) -#define SND_MIXER_ELEM_LAST ((snd_mixer_elem_type_t) SND_MIXER_ELEM_LAST) - +} snd_mixer_elem_type_t; #ifdef __cplusplus extern "C" { @@ -63,7 +53,7 @@ int snd_mixer_class_unregister(snd_mixer_class_t *clss); * Simple (legacy) mixer API */ -enum _snd_mixer_selem_channel_id { +typedef enum _snd_mixer_selem_channel_id { SND_MIXER_SCHN_UNKNOWN = -1, SND_MIXER_SCHN_FRONT_LEFT = 0, SND_MIXER_SCHN_FRONT_RIGHT, @@ -73,28 +63,12 @@ enum _snd_mixer_selem_channel_id { SND_MIXER_SCHN_WOOFER, SND_MIXER_SCHN_LAST = 31, SND_MIXER_SCHN_MONO = SND_MIXER_SCHN_FRONT_LEFT -}; +} snd_mixer_selem_channel_id_t; /* Simple mixer */ typedef struct _snd_mixer_selem_id snd_mixer_selem_id_t; -#ifdef SND_ENUM_TYPECHECK -typedef struct __snd_mixer_selem_channel_id *snd_mixer_selem_channel_id_t; -#else -typedef enum _snd_mixer_selem_channel_id snd_mixer_selem_channel_id_t; -#endif - -#define SND_MIXER_SCHN_UNKNOWN ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_UNKNOWN) -#define SND_MIXER_SCHN_FRONT_LEFT ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_FRONT_LEFT) -#define SND_MIXER_SCHN_FRONT_RIGHT ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_FRONT_RIGHT) -#define SND_MIXER_SCHN_FRONT_CENTER ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_FRONT_CENTER) -#define SND_MIXER_SCHN_REAR_LEFT ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_REAR_LEFT) -#define SND_MIXER_SCHN_REAR_RIGHT ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_REAR_RIGHT) -#define SND_MIXER_SCHN_WOOFER ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_WOOFER) -#define SND_MIXER_SCHN_LAST ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_LAST) -#define SND_MIXER_SCHN_MONO ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_MONO) - #ifdef __cplusplus extern "C" { #endif diff --git a/include/seq.h b/include/seq.h index d9a1fb29..55f0e05a 100644 --- a/include/seq.h +++ b/include/seq.h @@ -300,22 +300,13 @@ typedef enum sndrv_seq_stop_mode snd_seq_stop_mode_t; #define SND_SEQ_NONBLOCK 1 -enum _snd_seq_type { +typedef enum _snd_seq_type { SND_SEQ_TYPE_HW, SND_SEQ_TYPE_SHM, SND_SEQ_TYPE_INET, -}; - -#ifdef SND_ENUM_TYPECHECK -typedef struct __snd_seq_type *snd_seq_type_t; -#else -typedef enum _snd_seq_type snd_seq_type_t; -#endif - -#define SND_SEQ_TYPE_HW ((snd_seq_type_t) SND_SEQ_TYPE_HW) -#define SND_SEQ_TYPE_SHM ((snd_seq_type_t) SND_SEQ_TYPE_SHM) -#define SND_SEQ_TYPE_INET ((snd_seq_type_t) SND_SEQ_TYPE_INET) +} snd_seq_type_t; +/** Sequencer handle */ typedef struct _snd_seq snd_seq_t; #ifdef __cplusplus diff --git a/include/timer.h b/include/timer.h index 6c97aae3..aa80e4d2 100644 --- a/include/timer.h +++ b/include/timer.h @@ -12,26 +12,22 @@ typedef struct sndrv_timer_params snd_timer_params_t; typedef struct sndrv_timer_status snd_timer_status_t; typedef struct sndrv_timer_read snd_timer_read_t; -#ifdef SND_ENUM_TYPECHECK -typedef struct __snd_timer_type *snd_timer_type_t; -typedef struct __snd_timer_slave_type *snd_timer_slave_type_t; -#else -typedef enum sndrv_timer_type snd_timer_type_t; -typedef enum sndrv_timer_slave_type snd_timer_slave_type_t; -#endif - -#define SND_TIMER_TYPE_NONE ((snd_timer_type_t) SNDRV_TIMER_TYPE_NONE) -#define SND_TIMER_TYPE_SLAVE ((snd_timer_type_t) SNDRV_TIMER_TYPE_SLAVE) -#define SND_TIMER_TYPE_GLOBAL ((snd_timer_type_t) SNDRV_TIMER_TYPE_GLOBAL) -#define SND_TIMER_TYPE_CARD ((snd_timer_type_t) SNDRV_TIMER_TYPE_CARD) -#define SND_TIMER_TYPE_PCM ((snd_timer_type_t) SNDRV_TIMER_TYPE_PCM) -#define SND_TIMER_TYPE_LAST ((snd_timer_type_t) SNDRV_TIMER_TYPE_LAST) +typedef enum _snd_timer_type { + SND_TIMER_TYPE_NONE = SNDRV_TIMER_TYPE_NONE, + SND_TIMER_TYPE_SLAVE = SNDRV_TIMER_TYPE_SLAVE, + SND_TIMER_TYPE_GLOBAL = SNDRV_TIMER_TYPE_GLOBAL, + SND_TIMER_TYPE_CARD = SNDRV_TIMER_TYPE_CARD, + SND_TIMER_TYPE_PCM = SNDRV_TIMER_TYPE_PCM, + SND_TIMER_TYPE_LAST = SNDRV_TIMER_TYPE_LAST, +} snd_timer_type_t; -#define SND_TIMER_STYPE_NONE ((snd_timer_slave_type_t) SNDRV_TIMER_STYPE_NONE -#define SND_TIMER_STYPE_APPLICATION ((snd_timer_slave_type_t) SNDRV_TIMER_STYPE_APPLICATION -#define SND_TIMER_STYPE_SEQUENCER ((snd_timer_slave_type_t) SNDRV_TIMER_STYPE_SEQUENCER -#define SND_TIMER_STYPE_OSS_SEQUENCER ((snd_timer_slave_type_t) SNDRV_TIMER_STYPE_OSS_SEQUENCER -#define SND_TIMER_STYPE_LAST ((snd_timer_slave_type_t) SNDRV_TIMER_STYPE_LAST +typedef enum _snd_timer_slave_type { + SND_TIMER_STYPE_NONE = SNDRV_TIMER_STYPE_NONE, + SND_TIMER_STYPE_APPLICATION = SNDRV_TIMER_STYPE_APPLICATION, + SND_TIMER_STYPE_SEQUENCER = SNDRV_TIMER_STYPE_SEQUENCER, + SND_TIMER_STYPE_OSS_SEQUENCER = SNDRV_TIMER_STYPE_OSS_SEQUENCER, + SND_TIMER_STYPE_LAST = SNDRV_TIMER_STYPE_LAST, +} snd_timer_slave_type_t; #define SND_TIMER_GLOBAL_SYSTEM SNDRV_TIMER_GLOBAL_SYSTEM #define SND_TIMER_GLOBAL_RTC SNDRV_TIMER_GLOBAL_RTC -- 2.11.0