diff options
author | Abramo Bagnara <abramo@alsa-project.org> | 2001-02-04 17:03:17 +0000 |
---|---|---|
committer | Abramo Bagnara <abramo@alsa-project.org> | 2001-02-04 17:03:17 +0000 |
commit | a7561a9c7eaf4f0a5daa48f049c3d1e9a503380b (patch) | |
tree | c008f59b70a8f23caa4eb9e9c3cf4ffb84ff885f | |
parent | 544718f10d04eae7bebae17e0f669ccba996994c (diff) |
Corrected and completed encapsulation for PCM and rawmidi. Remove SND_PCM_HW_PARAM_* and use functions. Separated rawmidi info between streams
40 files changed, 2733 insertions, 1537 deletions
diff --git a/aserver/aserver.c b/aserver/aserver.c index 8a2c41d1..f143c264 100644 --- a/aserver/aserver.c +++ b/aserver/aserver.c @@ -274,7 +274,7 @@ int pcm_shm_open(client_t *client, int *cookie) snd_pcm_t *pcm; int err; int result; - err = snd_pcm_open(&pcm, client->name, client->stream, SND_PCM_NONBLOCK); + err = snd_pcm_open(&pcm, client->name, snd_int_to_enum(client->stream), SND_PCM_NONBLOCK); if (err < 0) return err; client->device.pcm.handle = pcm; @@ -394,7 +394,7 @@ 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_pcm_state(pcm); + ctrl->result = snd_enum_to_int(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 c4f553fb..d14edb8e 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -4,7 +4,7 @@ sysinclude_HEADERS = asoundlib.h # This is the order they will be concatenated into asoundlib.h! # header_files=header.h version.h global.h input.h output.h error.h mixer.h \ - pcm.h rawmidi.h timer.h hwdep.h control.h \ + pcm.h pcm_m4.h rawmidi.h rawmidi_m4.h timer.h hwdep.h control.h \ seq.h seqmid.h seq_midi_event.h \ conv.h instr.h conf.h footer.h diff --git a/include/header.h b/include/header.h index a8f1ed05..9fc487f1 100644 --- a/include/header.h +++ b/include/header.h @@ -45,3 +45,27 @@ #define SND_BIG_ENDIAN SNDRV_BIG_ENDIAN #endif + +enum _snd_set_mode { + SND_CHANGE, + SND_TRY, + SND_TEST, +}; + +//#define SND_ENUM_TYPECHECK + +#ifdef SND_ENUM_TYPECHECK +typedef struct __snd_set_mode *snd_set_mode_t; +#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 +typedef enum _snd_set_mode snd_set_mode_t; +#define snd_enum_to_int(v) (v) +#define snd_int_to_enum(v) (v) +#define snd_enum_incr(v) (++(v)) +#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) diff --git a/include/local.h b/include/local.h index f2d0c1b1..5c5e08e2 100644 --- a/include/local.h +++ b/include/local.h @@ -19,6 +19,16 @@ * */ +#define _snd_interval sndrv_interval +#define _snd_pcm_info sndrv_pcm_info +#define _snd_pcm_hw_params sndrv_pcm_hw_params +#define _snd_pcm_sw_params sndrv_pcm_sw_params +#define _snd_pcm_status sndrv_pcm_status + +#define _snd_rawmidi_info sndrv_rawmidi_info +#define _snd_rawmidi_params sndrv_rawmidi_params +#define _snd_rawmidi_status sndrv_rawmidi_status + #include "asoundlib.h" #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) diff --git a/include/pcm.h b/include/pcm.h index c99e7279..be371a4b 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -5,7 +5,27 @@ * * ****************************************************************************/ +typedef struct _snd_pcm_info snd_pcm_info_t; +typedef struct _snd_pcm_hw_params snd_pcm_hw_params_t; +typedef struct _snd_pcm_sw_params snd_pcm_sw_params_t; +typedef struct _snd_pcm_status snd_pcm_status_t; +typedef struct _snd_pcm_access_mask snd_pcm_access_mask_t; +typedef struct _snd_pcm_format_mask snd_pcm_format_mask_t; +typedef struct _snd_pcm_subformat_mask snd_pcm_subformat_mask_t; + /* sndrv aliasing */ +#ifdef SND_ENUM_TYPECHECK +typedef struct _snd_pcm_class *snd_pcm_class_t; +typedef struct _snd_pcm_subclass *snd_pcm_subclass_t; +typedef struct _snd_pcm_stream *snd_pcm_stream_t; +typedef struct _snd_pcm_access *snd_pcm_access_t; +typedef struct _snd_pcm_format *snd_pcm_format_t; +typedef struct _snd_pcm_subformat *snd_pcm_subformat_t; +typedef struct _snd_pcm_state *snd_pcm_state_t; +typedef struct _snd_pcm_start *snd_pcm_start_t; +typedef struct _snd_pcm_xrun *snd_pcm_xrun_t; +typedef struct _snd_pcm_tstamp *snd_pcm_tstamp_t; +#else typedef enum sndrv_pcm_class snd_pcm_class_t; typedef enum sndrv_pcm_subclass snd_pcm_subclass_t; typedef enum sndrv_pcm_stream snd_pcm_stream_t; @@ -13,82 +33,96 @@ typedef enum sndrv_pcm_access snd_pcm_access_t; typedef enum sndrv_pcm_format snd_pcm_format_t; typedef enum sndrv_pcm_subformat snd_pcm_subformat_t; typedef enum sndrv_pcm_state snd_pcm_state_t; -typedef enum sndrv_pcm_hw_param snd_pcm_hw_param_t; typedef enum sndrv_pcm_start snd_pcm_start_t; typedef enum sndrv_pcm_xrun snd_pcm_xrun_t; typedef enum sndrv_pcm_tstamp snd_pcm_tstamp_t; +#endif + +#define SND_PCM_CLASS_GENERIC ((snd_pcm_class_t) SNDRV_PCM_CLASS_GENERIC) +#define SND_PCM_CLASS_MULTI ((snd_pcm_class_t) SNDRV_PCM_CLASS_MULTI) +#define SND_PCM_CLASS_MODEM ((snd_pcm_class_t) SNDRV_PCM_CLASS_MODEM) +#define SND_PCM_CLASS_DIGITIZER ((snd_pcm_class_t) SNDRV_PCM_CLASS_DIGITIZER) +#define SND_PCM_SUBCLASS_GENERIC_MIX ((snd_pcm_subclass_t) SNDRV_PCM_SUBCLASS_GENERIC_MIX) +#define SND_PCM_SUBCLASS_MULTI_MIX ((snd_pcm_subclass_t) SNDRV_PCM_SUBCLASS_MULTI_MIX) +#define SND_PCM_STREAM_PLAYBACK ((snd_pcm_stream_t) SNDRV_PCM_STREAM_PLAYBACK) +#define SND_PCM_STREAM_CAPTURE ((snd_pcm_stream_t) SNDRV_PCM_STREAM_CAPTURE) +#define SND_PCM_STREAM_LAST ((snd_pcm_stream_t) SNDRV_PCM_STREAM_LAST) +#define SND_PCM_ACCESS_MMAP_INTERLEAVED ((snd_pcm_access_t) SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) +#define SND_PCM_ACCESS_MMAP_NONINTERLEAVED ((snd_pcm_access_t) SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED) +#define SND_PCM_ACCESS_MMAP_COMPLEX ((snd_pcm_access_t) SNDRV_PCM_ACCESS_MMAP_COMPLEX) +#define SND_PCM_ACCESS_RW_INTERLEAVED ((snd_pcm_access_t) SNDRV_PCM_ACCESS_RW_INTERLEAVED) +#define SND_PCM_ACCESS_RW_NONINTERLEAVED ((snd_pcm_access_t) SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) +#define SND_PCM_ACCESS_LAST ((snd_pcm_access_t) SNDRV_PCM_ACCESS_LAST) +#define SND_PCM_FORMAT_NONE ((snd_pcm_format_t) -1) +#define SND_PCM_FORMAT_S8 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_S8) +#define SND_PCM_FORMAT_U8 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_U8) +#define SND_PCM_FORMAT_S16_LE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_S16_LE) +#define SND_PCM_FORMAT_S16_BE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_S16_BE) +#define SND_PCM_FORMAT_U16_LE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_U16_LE) +#define SND_PCM_FORMAT_U16_BE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_U16_BE) +#define SND_PCM_FORMAT_S24_LE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_S24_LE) +#define SND_PCM_FORMAT_S24_BE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_S24_BE) +#define SND_PCM_FORMAT_U24_LE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_U24_LE) +#define SND_PCM_FORMAT_U24_BE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_U24_BE) +#define SND_PCM_FORMAT_S32_LE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_S32_LE) +#define SND_PCM_FORMAT_S32_BE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_S32_BE) +#define SND_PCM_FORMAT_U32_LE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_U32_LE) +#define SND_PCM_FORMAT_U32_BE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_U32_BE) +#define SND_PCM_FORMAT_FLOAT_LE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_FLOAT_LE) +#define SND_PCM_FORMAT_FLOAT_BE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_FLOAT_BE) +#define SND_PCM_FORMAT_FLOAT64_LE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_FLOAT64_LE) +#define SND_PCM_FORMAT_FLOAT64_BE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_FLOAT64_BE) +#define SND_PCM_FORMAT_IEC958_SUBFRAME_LE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE) +#define SND_PCM_FORMAT_IEC958_SUBFRAME_BE ((snd_pcm_format_t) SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE) +#define SND_PCM_FORMAT_MU_LAW ((snd_pcm_format_t) SNDRV_PCM_FORMAT_MU_LAW) +#define SND_PCM_FORMAT_A_LAW ((snd_pcm_format_t) SNDRV_PCM_FORMAT_A_LAW) +#define SND_PCM_FORMAT_IMA_ADPCM ((snd_pcm_format_t) SNDRV_PCM_FORMAT_IMA_ADPCM) +#define SND_PCM_FORMAT_MPEG ((snd_pcm_format_t) SNDRV_PCM_FORMAT_MPEG) +#define SND_PCM_FORMAT_GSM ((snd_pcm_format_t) SNDRV_PCM_FORMAT_GSM) +#define SND_PCM_FORMAT_SPECIAL ((snd_pcm_format_t) SNDRV_PCM_FORMAT_SPECIAL) +#define SND_PCM_FORMAT_LAST ((snd_pcm_format_t) SNDRV_PCM_FORMAT_LAST) +#define SND_PCM_FORMAT_S16 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_S16) +#define SND_PCM_FORMAT_U16 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_U16) +#define SND_PCM_FORMAT_S24 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_S24) +#define SND_PCM_FORMAT_U24 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_U24) +#define SND_PCM_FORMAT_S32 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_S32) +#define SND_PCM_FORMAT_U32 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_U32) +#define SND_PCM_FORMAT_FLOAT ((snd_pcm_format_t) SNDRV_PCM_FORMAT_FLOAT) +#define SND_PCM_FORMAT_FLOAT64 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_FLOAT64) +#define SND_PCM_FORMAT_IEC958_SUBFRAME ((snd_pcm_format_t) SNDRV_PCM_FORMAT_IEC958_SUBFRAME) +#define SND_PCM_FORMAT_S16 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_S16) +#define SND_PCM_FORMAT_U16 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_U16) +#define SND_PCM_FORMAT_S24 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_S24) +#define SND_PCM_FORMAT_U24 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_U24) +#define SND_PCM_FORMAT_S32 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_S32) +#define SND_PCM_FORMAT_U32 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_U32) +#define SND_PCM_FORMAT_FLOAT ((snd_pcm_format_t) SNDRV_PCM_FORMAT_FLOAT) +#define SND_PCM_FORMAT_FLOAT64 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_FLOAT64) +#define SND_PCM_FORMAT_IEC958_SUBFRAME ((snd_pcm_format_t) SNDRV_PCM_FORMAT_IEC958_SUBFRAME) +#define SND_PCM_SUBFORMAT_STD ((snd_pcm_subformat_t) SNDRV_PCM_SUBFORMAT_STD) +#define SND_PCM_SUBFORMAT_LAST ((snd_pcm_subformat_t) SNDRV_PCM_SUBFORMAT_LAST) +#define SND_PCM_STATE_OPEN ((snd_pcm_state_t) SNDRV_PCM_STATE_OPEN) +#define SND_PCM_STATE_SETUP ((snd_pcm_state_t) SNDRV_PCM_STATE_SETUP) +#define SND_PCM_STATE_PREPARED ((snd_pcm_state_t) SNDRV_PCM_STATE_PREPARED) +#define SND_PCM_STATE_RUNNING ((snd_pcm_state_t) SNDRV_PCM_STATE_RUNNING) +#define SND_PCM_STATE_XRUN ((snd_pcm_state_t) SNDRV_PCM_STATE_XRUN) +#define SND_PCM_STATE_DRAINING ((snd_pcm_state_t) SNDRV_PCM_STATE_DRAINING) +#define SND_PCM_STATE_PAUSED ((snd_pcm_state_t) SNDRV_PCM_STATE_PAUSED) +#define SND_PCM_STATE_LAST ((snd_pcm_state_t) SNDRV_PCM_STATE_LAST) +#define SND_PCM_START_DATA ((snd_pcm_start_t) SNDRV_PCM_START_DATA) +#define SND_PCM_START_EXPLICIT ((snd_pcm_start_t) SNDRV_PCM_START_EXPLICIT) +#define SND_PCM_START_LAST ((snd_pcm_start_t) SNDRV_PCM_START_LAST) +#define SND_PCM_XRUN_NONE ((snd_pcm_xrun_t) SNDRV_PCM_XRUN_NONE) +#define SND_PCM_XRUN_STOP ((snd_pcm_xrun_t) SNDRV_PCM_XRUN_STOP) +#define SND_PCM_XRUN_LAST ((snd_pcm_xrun_t) SNDRV_PCM_XRUN_LAST) +#define SND_PCM_TSTAMP_NONE ((snd_pcm_tstamp_t) SNDRV_PCM_TSTAMP_NONE) +#define SND_PCM_TSTAMP_MMAP ((snd_pcm_tstamp_t) SNDRV_PCM_TSTAMP_MMAP) +#define SND_PCM_TSTAMP_LAST ((snd_pcm_tstamp_t) SNDRV_PCM_TSTAMP_LAST) typedef sndrv_pcm_uframes_t snd_pcm_uframes_t; typedef sndrv_pcm_sframes_t snd_pcm_sframes_t; typedef struct timeval snd_timestamp_t; -typedef struct _snd_pcm_info snd_pcm_info_t; -typedef struct _snd_pcm_hw_params snd_pcm_hw_params_t; -typedef struct _snd_pcm_sw_params snd_pcm_sw_params_t; -typedef struct _snd_pcm_status snd_pcm_status_t; - -#define SND_PCM_CLASS_GENERIC SNDRV_PCM_CLASS_GENERIC -#define SND_PCM_CLASS_MULTI SNDRV_PCM_CLASS_MULTI -#define SND_PCM_CLASS_MODEM SNDRV_PCM_CLASS_MODEM -#define SND_PCM_CLASS_DIGITIZER SNDRV_PCM_CLASS_DIGITIZER -#define SND_PCM_SUBCLASS_GENERIC_MIX SNDRV_PCM_SUBCLASS_GENERIC_MIX -#define SND_PCM_SUBCLASS_MULTI_MIX SNDRV_PCM_SUBCLASS_MULTI_MIX -#define SND_PCM_STREAM_PLAYBACK SNDRV_PCM_STREAM_PLAYBACK -#define SND_PCM_STREAM_CAPTURE SNDRV_PCM_STREAM_CAPTURE -#define SND_PCM_STREAM_LAST SNDRV_PCM_STREAM_LAST -#define SND_PCM_ACCESS_MMAP_INTERLEAVED SNDRV_PCM_ACCESS_MMAP_INTERLEAVED -#define SND_PCM_ACCESS_MMAP_NONINTERLEAVED SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED -#define SND_PCM_ACCESS_MMAP_COMPLEX SNDRV_PCM_ACCESS_MMAP_COMPLEX -#define SND_PCM_ACCESS_RW_INTERLEAVED SNDRV_PCM_ACCESS_RW_INTERLEAVED -#define SND_PCM_ACCESS_RW_NONINTERLEAVED SNDRV_PCM_ACCESS_RW_NONINTERLEAVED -#define SND_PCM_ACCESS_LAST SNDRV_PCM_ACCESS_LAST -#define SND_PCM_FORMAT_S8 SNDRV_PCM_FORMAT_S8 -#define SND_PCM_FORMAT_U8 SNDRV_PCM_FORMAT_U8 -#define SND_PCM_FORMAT_S16_LE SNDRV_PCM_FORMAT_S16_LE -#define SND_PCM_FORMAT_S16_BE SNDRV_PCM_FORMAT_S16_BE -#define SND_PCM_FORMAT_U16_LE SNDRV_PCM_FORMAT_U16_LE -#define SND_PCM_FORMAT_U16_BE SNDRV_PCM_FORMAT_U16_BE -#define SND_PCM_FORMAT_S24_LE SNDRV_PCM_FORMAT_S24_LE -#define SND_PCM_FORMAT_S24_BE SNDRV_PCM_FORMAT_S24_BE -#define SND_PCM_FORMAT_U24_LE SNDRV_PCM_FORMAT_U24_LE -#define SND_PCM_FORMAT_U24_BE SNDRV_PCM_FORMAT_U24_BE -#define SND_PCM_FORMAT_S32_LE SNDRV_PCM_FORMAT_S32_LE -#define SND_PCM_FORMAT_S32_BE SNDRV_PCM_FORMAT_S32_BE -#define SND_PCM_FORMAT_U32_LE SNDRV_PCM_FORMAT_U32_LE -#define SND_PCM_FORMAT_U32_BE SNDRV_PCM_FORMAT_U32_BE -#define SND_PCM_FORMAT_FLOAT_LE SNDRV_PCM_FORMAT_FLOAT_LE -#define SND_PCM_FORMAT_FLOAT_BE SNDRV_PCM_FORMAT_FLOAT_BE -#define SND_PCM_FORMAT_FLOAT64_LE SNDRV_PCM_FORMAT_FLOAT64_LE -#define SND_PCM_FORMAT_FLOAT64_BE SNDRV_PCM_FORMAT_FLOAT64_BE -#define SND_PCM_FORMAT_IEC958_SUBFRAME_LE SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE -#define SND_PCM_FORMAT_IEC958_SUBFRAME_BE SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE -#define SND_PCM_FORMAT_MU_LAW SNDRV_PCM_FORMAT_MU_LAW -#define SND_PCM_FORMAT_A_LAW SNDRV_PCM_FORMAT_A_LAW -#define SND_PCM_FORMAT_IMA_ADPCM SNDRV_PCM_FORMAT_IMA_ADPCM -#define SND_PCM_FORMAT_MPEG SNDRV_PCM_FORMAT_MPEG -#define SND_PCM_FORMAT_GSM SNDRV_PCM_FORMAT_GSM -#define SND_PCM_FORMAT_SPECIAL SNDRV_PCM_FORMAT_SPECIAL -#define SND_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_LAST -#define SND_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16 -#define SND_PCM_FORMAT_U16 SNDRV_PCM_FORMAT_U16 -#define SND_PCM_FORMAT_S24 SNDRV_PCM_FORMAT_S24 -#define SND_PCM_FORMAT_U24 SNDRV_PCM_FORMAT_U24 -#define SND_PCM_FORMAT_S32 SNDRV_PCM_FORMAT_S32 -#define SND_PCM_FORMAT_U32 SNDRV_PCM_FORMAT_U32 -#define SND_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT -#define SND_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64 -#define SND_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME -#define SND_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16 -#define SND_PCM_FORMAT_U16 SNDRV_PCM_FORMAT_U16 -#define SND_PCM_FORMAT_S24 SNDRV_PCM_FORMAT_S24 -#define SND_PCM_FORMAT_U24 SNDRV_PCM_FORMAT_U24 -#define SND_PCM_FORMAT_S32 SNDRV_PCM_FORMAT_S32 -#define SND_PCM_FORMAT_U32 SNDRV_PCM_FORMAT_U32 -#define SND_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT -#define SND_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64 -#define SND_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME -#define SND_PCM_SUBFORMAT_STD SNDRV_PCM_SUBFORMAT_STD -#define SND_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_LAST #define SND_PCM_INFO_MMAP SNDRV_PCM_INFO_MMAP #define SND_PCM_INFO_MMAP_VALID SNDRV_PCM_INFO_MMAP_VALID #define SND_PCM_INFO_DOUBLE SNDRV_PCM_INFO_DOUBLE @@ -102,57 +136,13 @@ typedef struct _snd_pcm_status snd_pcm_status_t; #define SND_PCM_INFO_HALF_DUPLEX SNDRV_PCM_INFO_HALF_DUPLEX #define SND_PCM_INFO_JOINT_DUPLEX SNDRV_PCM_INFO_JOINT_DUPLEX #define SND_PCM_INFO_SYNC_START SNDRV_PCM_INFO_SYNC_START -#define SND_PCM_STATE_OPEN SNDRV_PCM_STATE_OPEN -#define SND_PCM_STATE_SETUP SNDRV_PCM_STATE_SETUP -#define SND_PCM_STATE_PREPARED SNDRV_PCM_STATE_PREPARED -#define SND_PCM_STATE_RUNNING SNDRV_PCM_STATE_RUNNING -#define SND_PCM_STATE_XRUN SNDRV_PCM_STATE_XRUN -#define SND_PCM_STATE_DRAINING SNDRV_PCM_STATE_DRAINING -#define SND_PCM_STATE_PAUSED SNDRV_PCM_STATE_PAUSED -#define SND_PCM_STATE_LAST SNDRV_PCM_STATE_LAST #define SND_PCM_MMAP_OFFSET_DATA SNDRV_PCM_MMAP_OFFSET_DATA #define SND_PCM_MMAP_OFFSET_STATUS SNDRV_PCM_MMAP_OFFSET_STATUS #define SND_PCM_MMAP_OFFSET_CONTROL SNDRV_PCM_MMAP_OFFSET_CONTROL -#define SND_PCM_HW_PARAM_ACCESS SNDRV_PCM_HW_PARAM_ACCESS -#define SND_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_FIRST_MASK -#define SND_PCM_HW_PARAM_FORMAT SNDRV_PCM_HW_PARAM_FORMAT -#define SND_PCM_HW_PARAM_SUBFORMAT SNDRV_PCM_HW_PARAM_SUBFORMAT -#define SND_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_LAST_MASK -#define SND_PCM_HW_PARAM_SAMPLE_BITS SNDRV_PCM_HW_PARAM_SAMPLE_BITS -#define SND_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_FIRST_INTERVAL -#define SND_PCM_HW_PARAM_FRAME_BITS SNDRV_PCM_HW_PARAM_FRAME_BITS -#define SND_PCM_HW_PARAM_CHANNELS SNDRV_PCM_HW_PARAM_CHANNELS -#define SND_PCM_HW_PARAM_RATE SNDRV_PCM_HW_PARAM_RATE -#define SND_PCM_HW_PARAM_PERIOD_TIME SNDRV_PCM_HW_PARAM_PERIOD_TIME -#define SND_PCM_HW_PARAM_PERIOD_SIZE SNDRV_PCM_HW_PARAM_PERIOD_SIZE -#define SND_PCM_HW_PARAM_PERIOD_BYTES SNDRV_PCM_HW_PARAM_PERIOD_BYTES -#define SND_PCM_HW_PARAM_PERIODS SNDRV_PCM_HW_PARAM_PERIODS -#define SND_PCM_HW_PARAM_BUFFER_TIME SNDRV_PCM_HW_PARAM_BUFFER_TIME -#define SND_PCM_HW_PARAM_BUFFER_SIZE SNDRV_PCM_HW_PARAM_BUFFER_SIZE -#define SND_PCM_HW_PARAM_BUFFER_BYTES SNDRV_PCM_HW_PARAM_BUFFER_BYTES -#define SND_PCM_HW_PARAM_TICK_TIME SNDRV_PCM_HW_PARAM_TICK_TIME -#define SND_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_LAST_INTERVAL -#define SND_PCM_HW_PARAM_LAST SNDRV_PCM_HW_PARAM_LAST -#define SND_PCM_HW_PARAMS_RUNTIME SNDRV_PCM_HW_PARAMS_RUNTIME -#define SND_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_LAST_MASK -#define SND_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_FIRST_MASK -#define SND_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_LAST_INTERVAL -#define SND_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_FIRST_INTERVAL -#define SND_PCM_START_DATA SNDRV_PCM_START_DATA -#define SND_PCM_START_EXPLICIT SNDRV_PCM_START_EXPLICIT -#define SND_PCM_START_LAST SNDRV_PCM_START_LAST -#define SND_PCM_XRUN_NONE SNDRV_PCM_XRUN_NONE -#define SND_PCM_XRUN_STOP SNDRV_PCM_XRUN_STOP -#define SND_PCM_XRUN_LAST SNDRV_PCM_XRUN_LAST -#define SND_PCM_TSTAMP_NONE SNDRV_PCM_TSTAMP_NONE -#define SND_PCM_TSTAMP_MMAP SNDRV_PCM_TSTAMP_MMAP -#define SND_PCM_TSTAMP_LAST SNDRV_PCM_TSTAMP_LAST -#define SND_PCM_STATE_XXXX SNDRV_PCM_STATE_XXXX #define SND_PCM_NONBLOCK 0x0001 #define SND_PCM_ASYNC 0x0002 -typedef struct _snd_mask snd_mask_t; typedef struct _snd_pcm snd_pcm_t; typedef enum _snd_pcm_type { @@ -187,7 +177,7 @@ extern "C" { #endif int snd_pcm_open(snd_pcm_t **pcm, char *name, - int stream, int mode); + snd_pcm_stream_t stream, int mode); snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm); int snd_pcm_close(snd_pcm_t *pcm); @@ -206,7 +196,7 @@ int snd_pcm_start(snd_pcm_t *pcm); int snd_pcm_drop(snd_pcm_t *pcm); int snd_pcm_drain(snd_pcm_t *pcm); int snd_pcm_pause(snd_pcm_t *pcm, int enable); -int snd_pcm_state(snd_pcm_t *pcm); +snd_pcm_state_t snd_pcm_state(snd_pcm_t *pcm); int snd_pcm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp); snd_pcm_sframes_t snd_pcm_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames); snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size); @@ -223,87 +213,22 @@ int snd_pcm_unlink(snd_pcm_t *pcm); int snd_pcm_wait(snd_pcm_t *pcm, int timeout); snd_pcm_sframes_t snd_pcm_avail_update(snd_pcm_t *pcm); -int snd_pcm_set_avail_min(snd_pcm_t *pcm, snd_pcm_uframes_t size); - - -/* Mask */ -size_t snd_mask_sizeof(); -#define snd_mask_alloca(maskp) ({(*maskp) = (snd_mask_t *) alloca(snd_mask_sizeof()); 0;}) -int snd_mask_malloc(snd_mask_t **maskp); -void snd_mask_free(snd_mask_t *mask); -void snd_mask_none(snd_mask_t *mask); -void snd_mask_any(snd_mask_t *mask); -void snd_mask_set(snd_mask_t *mask, unsigned int val); -void snd_mask_reset(snd_mask_t *mask, unsigned int val); -void snd_mask_copy(snd_mask_t *dst, const snd_mask_t *src); /* HW params */ -size_t snd_pcm_hw_params_sizeof(); -#define snd_pcm_hw_params_alloca(paramsp) ({(*paramsp) = (snd_pcm_hw_params_t *) alloca(snd_pcm_hw_params_sizeof()); 0;}) -int snd_pcm_hw_params_malloc(snd_pcm_hw_params_t **paramsp); -void snd_pcm_hw_params_free(snd_pcm_hw_params_t *params); -void snd_pcm_hw_params_copy(snd_pcm_hw_params_t *dst, const snd_pcm_hw_params_t *src); - int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); -int snd_pcm_hw_param_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var); -int snd_pcm_hw_param_test(const snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, unsigned int val); -int snd_pcm_hw_param_setinteger(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var); -int snd_pcm_hw_param_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, int *dir); -int snd_pcm_hw_param_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, int *dir); -int snd_pcm_hw_param_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, unsigned int val, - int *dir); -int snd_pcm_hw_param_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, - unsigned int val, int *dir); -int snd_pcm_hw_param_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, unsigned int val, int *dir); -int snd_pcm_hw_param_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, - unsigned int *min, int *mindir, - unsigned int *max, int *maxdir); -int snd_pcm_hw_param_set(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, unsigned int val, int dir); -int snd_pcm_hw_param_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, const snd_mask_t *mask); -int snd_pcm_hw_param_min_try(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, - unsigned int val, int *dir); -int snd_pcm_hw_param_max_try(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, - unsigned int val, int *dir); -int snd_pcm_hw_param_minmax_try(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, - unsigned int *min, int *mindir, - unsigned int *max, int *maxdir); -int snd_pcm_hw_param_set_try(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, unsigned int val, int dir); -int snd_pcm_hw_param_mask_try(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, const snd_mask_t *mask); -int snd_pcm_hw_param_value(const snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, int *dir); -unsigned int snd_pcm_hw_param_value_min(const snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, int *dir); -unsigned int snd_pcm_hw_param_value_max(const snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, int *dir); + int snd_pcm_hw_params_try_explain_failure(snd_pcm_t *pcm, snd_pcm_hw_params_t *fail, snd_pcm_hw_params_t *success, unsigned int depth, snd_output_t *out); -int snd_pcm_hw_params_info_rate(const snd_pcm_hw_params_t *params, - unsigned int *rate_num, - unsigned int *rate_den); -int snd_pcm_hw_params_info_msbits(const snd_pcm_hw_params_t *params); -int snd_pcm_hw_params_info_flags(const snd_pcm_hw_params_t *params); -int snd_pcm_hw_params_info_fifo_size(const snd_pcm_hw_params_t *params); -int snd_pcm_hw_params_info_dig_groups(const snd_pcm_hw_params_t *params); +int snd_pcm_hw_params_get_rate_numden(const snd_pcm_hw_params_t *params, + unsigned int *rate_num, + unsigned int *rate_den); +int snd_pcm_hw_params_get_sbits(const snd_pcm_hw_params_t *params); +int snd_pcm_hw_params_get_flags(const snd_pcm_hw_params_t *params); +int snd_pcm_hw_params_get_fifo_size(const snd_pcm_hw_params_t *params); int snd_pcm_hw_params_dump(snd_pcm_hw_params_t *params, snd_output_t *out); typedef struct _snd_pcm_hw_strategy snd_pcm_hw_strategy_t; @@ -323,77 +248,10 @@ void snd_pcm_hw_strategy_free(snd_pcm_hw_strategy_t *strategy); int snd_pcm_hw_strategy_simple(snd_pcm_hw_strategy_t **strategyp, unsigned int badness_min, unsigned int badness_max); -int snd_pcm_hw_strategy_simple_near(snd_pcm_hw_strategy_t *strategy, int order, - snd_pcm_hw_param_t var, - unsigned int best, - unsigned int mul); -int snd_pcm_hw_strategy_simple_choices(snd_pcm_hw_strategy_t *strategy, int order, - snd_pcm_hw_param_t var, - unsigned int count, - snd_pcm_hw_strategy_simple_choices_list_t *choices); - -/* SW params */ -typedef enum _snd_pcm_sw_param { - SND_PCM_SW_PARAM_START_MODE, - SND_PCM_SW_PARAM_XRUN_MODE, - SND_PCM_SW_PARAM_TSTAMP_MODE, - SND_PCM_SW_PARAM_PERIOD_STEP, - SND_PCM_SW_PARAM_SLEEP_MIN, - SND_PCM_SW_PARAM_AVAIL_MIN, - SND_PCM_SW_PARAM_XFER_ALIGN, - SND_PCM_SW_PARAM_SILENCE_THRESHOLD, - SND_PCM_SW_PARAM_SILENCE_SIZE, - SND_PCM_SW_PARAM_LAST = SND_PCM_SW_PARAM_SILENCE_SIZE, -} snd_pcm_sw_param_t; - -size_t snd_pcm_sw_params_sizeof(); -#define snd_pcm_sw_params_alloca(paramsp) ({(*paramsp) = (snd_pcm_sw_params_t *) alloca(snd_pcm_sw_params_sizeof()); 0;}) -int snd_pcm_sw_params_malloc(snd_pcm_sw_params_t **paramsp); -void snd_pcm_sw_params_free(snd_pcm_sw_params_t *params); -void snd_pcm_sw_params_copy(snd_pcm_sw_params_t *dst, const snd_pcm_sw_params_t *src); int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params); -int snd_pcm_sw_param_set(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_sw_param_t var, unsigned int val); -int snd_pcm_sw_param_near(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_sw_param_t var, unsigned int val); -int snd_pcm_sw_param_value(snd_pcm_sw_params_t *params, snd_pcm_sw_param_t var); int snd_pcm_sw_params_dump(snd_pcm_sw_params_t *params, snd_output_t *out); -/* Info */ -size_t snd_pcm_info_sizeof(); -#define snd_pcm_info_alloca(infop) ({(*infop) = (snd_pcm_info_t *) alloca(snd_pcm_info_sizeof()); 0;}) -int snd_pcm_info_malloc(snd_pcm_info_t **infop); -void snd_pcm_info_free(snd_pcm_info_t *info); -void snd_pcm_info_copy(snd_pcm_info_t *dst, const snd_pcm_info_t *src); -void snd_pcm_info_set_device(snd_pcm_info_t *info, unsigned int device); -void snd_pcm_info_set_subdevice(snd_pcm_info_t *info, unsigned int subdevice); -void snd_pcm_info_set_stream(snd_pcm_info_t *info, snd_pcm_stream_t stream); -int snd_pcm_info_card(snd_pcm_info_t *info); -unsigned int snd_pcm_info_device(snd_pcm_info_t *info); -unsigned int snd_pcm_info_subdevice(snd_pcm_info_t *info); -snd_pcm_stream_t snd_pcm_info_stream(snd_pcm_info_t *info); -const char *snd_pcm_info_device_id(snd_pcm_info_t *info); -const char *snd_pcm_info_device_name(snd_pcm_info_t *info); -const char *snd_pcm_info_subdevice_name(snd_pcm_info_t *info); -snd_pcm_class_t snd_pcm_info_device_class(snd_pcm_info_t *info); -snd_pcm_subclass_t snd_pcm_info_device_subclass(snd_pcm_info_t *info); -unsigned int snd_pcm_info_subdevices_count(snd_pcm_info_t *info); -unsigned int snd_pcm_info_subdevices_avail(snd_pcm_info_t *info); - -/* Status */ -size_t snd_pcm_status_sizeof(); -#define snd_pcm_status_alloca(statusp) ({(*statusp) = (snd_pcm_status_t *) alloca(snd_pcm_status_sizeof()); 0;}) -int snd_pcm_status_malloc(snd_pcm_status_t **statusp); -void snd_pcm_status_free(snd_pcm_status_t *status); -void snd_pcm_status_copy(snd_pcm_status_t *dst, const snd_pcm_status_t *src); - -snd_pcm_state_t snd_pcm_status_state(snd_pcm_status_t *status); -int snd_pcm_status_delay(snd_pcm_status_t *status); -int snd_pcm_status_avail(snd_pcm_status_t *status); -int snd_pcm_status_avail_max(snd_pcm_status_t *status); -void snd_pcm_status_tstamp(snd_pcm_status_t *status, - snd_timestamp_t *tstamp); -void snd_pcm_status_trigger_tstamp(snd_pcm_status_t *status, - snd_timestamp_t *tstamp); int snd_pcm_status_dump(snd_pcm_status_t *status, snd_output_t *out); /* mmap */ @@ -409,28 +267,26 @@ snd_pcm_sframes_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_ufram snd_pcm_sframes_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size); const char *snd_pcm_stream_name(snd_pcm_stream_t stream); -const char *snd_pcm_hw_param_name(snd_pcm_hw_param_t var); -const char *snd_pcm_sw_param_name(snd_pcm_sw_param_t var); const char *snd_pcm_access_name(snd_pcm_access_t access); const char *snd_pcm_format_name(snd_pcm_format_t format); const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat); const char *snd_pcm_format_description(snd_pcm_format_t format); -int snd_pcm_format_value(const char* name); +snd_pcm_format_t snd_pcm_format_value(const char* name); const char *snd_pcm_start_mode_name(snd_pcm_start_t mode); const char *snd_pcm_xrun_mode_name(snd_pcm_xrun_t mode); const char *snd_pcm_tstamp_mode_name(snd_pcm_tstamp_t mode); const char *snd_pcm_state_name(snd_pcm_state_t state); int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_channel, snd_pcm_uframes_t dst_offset, - unsigned int samples, int format); + unsigned int samples, snd_pcm_format_t format); int snd_pcm_areas_silence(const snd_pcm_channel_area_t *dst_channels, snd_pcm_uframes_t dst_offset, - unsigned int channels, snd_pcm_uframes_t frames, int format); + unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format); int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_channel, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_channel, snd_pcm_uframes_t src_offset, - unsigned int samples, int format); + unsigned int samples, snd_pcm_format_t format); int snd_pcm_areas_copy(const snd_pcm_channel_area_t *dst_channels, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_channels, snd_pcm_uframes_t src_offset, - unsigned int channels, snd_pcm_uframes_t frames, int format); + unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format); snd_pcm_sframes_t snd_pcm_bytes_to_frames(snd_pcm_t *pcm, ssize_t bytes); ssize_t snd_pcm_frames_to_bytes(snd_pcm_t *pcm, snd_pcm_sframes_t frames); @@ -440,21 +296,21 @@ ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, int samples); /* misc */ -int snd_pcm_format_signed(int format); -int snd_pcm_format_unsigned(int format); -int snd_pcm_format_linear(int format); -int snd_pcm_format_little_endian(int format); -int snd_pcm_format_big_endian(int format); -int snd_pcm_format_cpu_endian(int format); -int snd_pcm_format_width(int format); /* in bits */ -int snd_pcm_format_physical_width(int format); /* in bits */ -int snd_pcm_build_linear_format(int width, int unsignd, int big_endian); -ssize_t snd_pcm_format_size(int format, size_t samples); -u_int8_t snd_pcm_format_silence(int format); -u_int16_t snd_pcm_format_silence_16(int format); -u_int32_t snd_pcm_format_silence_32(int format); -u_int64_t snd_pcm_format_silence_64(int format); -int snd_pcm_format_set_silence(int format, void *buf, unsigned int samples); +int snd_pcm_format_signed(snd_pcm_format_t format); +int snd_pcm_format_unsigned(snd_pcm_format_t format); +int snd_pcm_format_linear(snd_pcm_format_t format); +int snd_pcm_format_little_endian(snd_pcm_format_t format); +int snd_pcm_format_big_endian(snd_pcm_format_t format); +int snd_pcm_format_cpu_endian(snd_pcm_format_t format); +int snd_pcm_format_width(snd_pcm_format_t format); /* in bits */ +int snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */ +snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_endian); +ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples); +u_int8_t snd_pcm_format_silence(snd_pcm_format_t format); +u_int16_t snd_pcm_format_silence_16(snd_pcm_format_t format); +u_int32_t snd_pcm_format_silence_32(snd_pcm_format_t format); +u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format); +int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int samples); #ifdef __cplusplus } diff --git a/include/pcm_m4.h b/include/pcm_m4.h new file mode 100644 index 00000000..bb7e4848 --- /dev/null +++ b/include/pcm_m4.h @@ -0,0 +1,244 @@ +#ifdef __cplusplus +extern "C" { +#endif + + +size_t snd_pcm_access_mask_sizeof(); +#define snd_pcm_access_mask_alloca(ptr) ({assert(ptr); *ptr = (snd_pcm_access_mask_t *) alloca(snd_pcm_access_mask_sizeof()); 0;}) +int snd_pcm_access_mask_malloc(snd_pcm_access_mask_t **ptr); +void snd_pcm_access_mask_free(snd_pcm_access_mask_t *obj); +void snd_pcm_access_mask_copy(snd_pcm_access_mask_t *dst, const snd_pcm_access_mask_t *src); + +void snd_pcm_access_mask_none(snd_pcm_access_mask_t *mask); +void snd_pcm_access_mask_any(snd_pcm_access_mask_t *mask); +int snd_pcm_access_mask_test(const snd_pcm_access_mask_t *mask, snd_pcm_access_t val); +void snd_pcm_access_mask_set(snd_pcm_access_mask_t *mask, snd_pcm_access_t val); +void snd_pcm_access_mask_reset(snd_pcm_access_mask_t *mask, snd_pcm_access_t val); + +size_t snd_pcm_format_mask_sizeof(); +#define snd_pcm_format_mask_alloca(ptr) ({assert(ptr); *ptr = (snd_pcm_format_mask_t *) alloca(snd_pcm_format_mask_sizeof()); 0;}) +int snd_pcm_format_mask_malloc(snd_pcm_format_mask_t **ptr); +void snd_pcm_format_mask_free(snd_pcm_format_mask_t *obj); +void snd_pcm_format_mask_copy(snd_pcm_format_mask_t *dst, const snd_pcm_format_mask_t *src); + +void snd_pcm_format_mask_none(snd_pcm_format_mask_t *mask); +void snd_pcm_format_mask_any(snd_pcm_format_mask_t *mask); +int snd_pcm_format_mask_test(const snd_pcm_format_mask_t *mask, snd_pcm_format_t val); +void snd_pcm_format_mask_set(snd_pcm_format_mask_t *mask, snd_pcm_format_t val); +void snd_pcm_format_mask_reset(snd_pcm_format_mask_t *mask, snd_pcm_format_t val); + +size_t snd_pcm_subformat_mask_sizeof(); +#define snd_pcm_subformat_mask_alloca(ptr) ({assert(ptr); *ptr = (snd_pcm_subformat_mask_t *) alloca(snd_pcm_subformat_mask_sizeof()); 0;}) +int snd_pcm_subformat_mask_malloc(snd_pcm_subformat_mask_t **ptr); +void snd_pcm_subformat_mask_free(snd_pcm_subformat_mask_t *obj); +void snd_pcm_subformat_mask_copy(snd_pcm_subformat_mask_t *dst, const snd_pcm_subformat_mask_t *src); + +void snd_pcm_subformat_mask_none(snd_pcm_subformat_mask_t *mask); +void snd_pcm_subformat_mask_any(snd_pcm_subformat_mask_t *mask); +int snd_pcm_subformat_mask_test(const snd_pcm_subformat_mask_t *mask, snd_pcm_subformat_t val); +void snd_pcm_subformat_mask_set(snd_pcm_subformat_mask_t *mask, snd_pcm_subformat_t val); +void snd_pcm_subformat_mask_reset(snd_pcm_subformat_mask_t *mask, snd_pcm_subformat_t val); + +size_t snd_pcm_hw_params_sizeof(); +#define snd_pcm_hw_params_alloca(ptr) ({assert(ptr); *ptr = (snd_pcm_hw_params_t *) alloca(snd_pcm_hw_params_sizeof()); 0;}) +int snd_pcm_hw_params_malloc(snd_pcm_hw_params_t **ptr); +void snd_pcm_hw_params_free(snd_pcm_hw_params_t *obj); +void snd_pcm_hw_params_copy(snd_pcm_hw_params_t *dst, const snd_pcm_hw_params_t *src); + +snd_pcm_access_t snd_pcm_hw_params_get_access(const snd_pcm_hw_params_t *params); +int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_access_t val); +snd_pcm_access_t snd_pcm_hw_params_set_access_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); +snd_pcm_access_t snd_pcm_hw_params_set_access_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); +int snd_pcm_hw_params_set_access_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_access_mask_t *mask); + +snd_pcm_format_t snd_pcm_hw_params_get_format(const snd_pcm_hw_params_t *params); +int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_format_t val); +snd_pcm_format_t snd_pcm_hw_params_set_format_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); +snd_pcm_format_t snd_pcm_hw_params_set_format_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); +int snd_pcm_hw_params_set_format_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_format_mask_t *mask); + +snd_pcm_subformat_t 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_set_mode_t mode, snd_pcm_subformat_t val); +snd_pcm_subformat_t snd_pcm_hw_params_set_subformat_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); +snd_pcm_subformat_t snd_pcm_hw_params_set_subformat_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); +int snd_pcm_hw_params_set_subformat_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_subformat_mask_t *mask); + +unsigned int snd_pcm_hw_params_get_channels(const snd_pcm_hw_params_t *params); +unsigned int snd_pcm_hw_params_get_channels_min(const snd_pcm_hw_params_t *params); +unsigned int snd_pcm_hw_params_get_channels_max(const snd_pcm_hw_params_t *params); +int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val); +int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val); +int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val); +int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, unsigned int *max); +unsigned int snd_pcm_hw_params_set_channels_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val); +unsigned int snd_pcm_hw_params_set_channels_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); +unsigned int snd_pcm_hw_params_set_channels_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); + +unsigned int snd_pcm_hw_params_get_rate(const snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_get_rate_min(const snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_get_rate_max(const snd_pcm_hw_params_t *params, int *dir); +int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir); +int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_rate_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir); +unsigned int snd_pcm_hw_params_set_rate_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir); +unsigned int snd_pcm_hw_params_set_rate_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_set_rate_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); + +unsigned int snd_pcm_hw_params_get_period_time(const snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_get_period_time_min(const snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_get_period_time_max(const snd_pcm_hw_params_t *params, int *dir); +int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir); +int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_period_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir); +unsigned int snd_pcm_hw_params_set_period_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir); +unsigned int snd_pcm_hw_params_set_period_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_set_period_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); + +snd_pcm_uframes_t snd_pcm_hw_params_get_period_size(const snd_pcm_hw_params_t *params, int *dir); +snd_pcm_uframes_t snd_pcm_hw_params_get_period_size_min(const snd_pcm_hw_params_t *params, int *dir); +snd_pcm_uframes_t snd_pcm_hw_params_get_period_size_max(const snd_pcm_hw_params_t *params, int *dir); +int snd_pcm_hw_params_set_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t val, int dir); +int snd_pcm_hw_params_set_period_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val, int *dir); +int snd_pcm_hw_params_set_period_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val, int *dir); +int snd_pcm_hw_params_set_period_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *min, int *mindir, snd_pcm_uframes_t *max, int *maxdir); +snd_pcm_uframes_t snd_pcm_hw_params_set_period_size_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int *dir); +snd_pcm_uframes_t snd_pcm_hw_params_set_period_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); +snd_pcm_uframes_t snd_pcm_hw_params_set_period_size_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); +int snd_pcm_hw_params_set_period_size_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode); + +unsigned int snd_pcm_hw_params_get_periods(const snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_get_periods_min(const snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_get_periods_max(const snd_pcm_hw_params_t *params, int *dir); +int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir); +int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_periods_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir); +unsigned int snd_pcm_hw_params_set_periods_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir); +unsigned int snd_pcm_hw_params_set_periods_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_set_periods_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); +int snd_pcm_hw_params_set_periods_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode); + +unsigned int snd_pcm_hw_params_get_buffer_time(const snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_get_buffer_time_min(const snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_get_buffer_time_max(const snd_pcm_hw_params_t *params, int *dir); +int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir); +int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_buffer_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir); +unsigned int snd_pcm_hw_params_set_buffer_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir); +unsigned int snd_pcm_hw_params_set_buffer_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_set_buffer_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); + +snd_pcm_uframes_t snd_pcm_hw_params_get_buffer_size(const snd_pcm_hw_params_t *params); +snd_pcm_uframes_t snd_pcm_hw_params_get_buffer_size_min(const snd_pcm_hw_params_t *params); +snd_pcm_uframes_t snd_pcm_hw_params_get_buffer_size_max(const snd_pcm_hw_params_t *params); +int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t val); +int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val); +int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val); +int snd_pcm_hw_params_set_buffer_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *min, snd_pcm_uframes_t *max); +snd_pcm_uframes_t snd_pcm_hw_params_set_buffer_size_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val); +snd_pcm_uframes_t snd_pcm_hw_params_set_buffer_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); +snd_pcm_uframes_t snd_pcm_hw_params_set_buffer_size_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); + +unsigned int snd_pcm_hw_params_get_tick_time(const snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_get_tick_time_min(const snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_get_tick_time_max(const snd_pcm_hw_params_t *params, int *dir); +int snd_pcm_hw_params_set_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir); +int snd_pcm_hw_params_set_tick_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_tick_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_tick_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir); +unsigned int snd_pcm_hw_params_set_tick_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir); +unsigned int snd_pcm_hw_params_set_tick_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); +unsigned int snd_pcm_hw_params_set_tick_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); + +size_t snd_pcm_sw_params_sizeof(); +#define snd_pcm_sw_params_alloca(ptr) ({assert(ptr); *ptr = (snd_pcm_sw_params_t *) alloca(snd_pcm_sw_params_sizeof()); 0;}) +int snd_pcm_sw_params_malloc(snd_pcm_sw_params_t **ptr); +void snd_pcm_sw_params_free(snd_pcm_sw_params_t *obj); +void snd_pcm_sw_params_copy(snd_pcm_sw_params_t *dst, const snd_pcm_sw_params_t *src); + +int snd_pcm_sw_params_set_start_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_start_t val); +snd_pcm_start_t snd_pcm_sw_params_get_start_mode(const snd_pcm_sw_params_t *params); + +int snd_pcm_sw_params_set_xrun_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_xrun_t val); +snd_pcm_xrun_t snd_pcm_sw_params_get_xrun_mode(const snd_pcm_sw_params_t *params); + +int snd_pcm_sw_params_set_tstamp_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_tstamp_t val); +snd_pcm_tstamp_t snd_pcm_sw_params_get_tstamp_mode(const snd_pcm_sw_params_t *params); + +int snd_pcm_sw_params_set_period_step(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, unsigned int val); +unsigned int snd_pcm_sw_params_get_period_step(const snd_pcm_sw_params_t *params); + +int snd_pcm_sw_params_set_sleep_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, unsigned int val); +unsigned int snd_pcm_sw_params_get_sleep_min(const snd_pcm_sw_params_t *params); + +int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val); +snd_pcm_uframes_t snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *params); + +int snd_pcm_sw_params_set_xfer_align(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val); +snd_pcm_uframes_t snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *params); + +int snd_pcm_sw_params_set_silence_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val); +snd_pcm_uframes_t snd_pcm_sw_params_get_silence_threshold(const snd_pcm_sw_params_t *params); + +int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val); +snd_pcm_uframes_t snd_pcm_sw_params_get_silence_size(const snd_pcm_sw_params_t *params); + +size_t snd_pcm_info_sizeof(); +#define snd_pcm_info_alloca(ptr) ({assert(ptr); *ptr = (snd_pcm_info_t *) alloca(snd_pcm_info_sizeof()); 0;}) +int snd_pcm_info_malloc(snd_pcm_info_t **ptr); +void snd_pcm_info_free(snd_pcm_info_t *obj); +void snd_pcm_info_copy(snd_pcm_info_t *dst, const snd_pcm_info_t *src); + +unsigned int snd_pcm_info_get_device(const snd_pcm_info_t *obj); + +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); + +int snd_pcm_info_get_card(const snd_pcm_info_t *obj); + +const char * snd_pcm_info_get_id(const snd_pcm_info_t *obj); + +const char * snd_pcm_info_get_name(const snd_pcm_info_t *obj); + +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); + +snd_pcm_subclass_t snd_pcm_info_get_subclass(const snd_pcm_info_t *obj); + +unsigned int snd_pcm_info_get_subdevices_count(const snd_pcm_info_t *obj); + +unsigned int snd_pcm_info_get_subdevices_avail(const snd_pcm_info_t *obj); + +void snd_pcm_info_set_device(snd_pcm_info_t *obj, unsigned int val); + +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); + +size_t snd_pcm_status_sizeof(); +#define snd_pcm_status_alloca(ptr) ({assert(ptr); *ptr = (snd_pcm_status_t *) alloca(snd_pcm_status_sizeof()); 0;}) +int snd_pcm_status_malloc(snd_pcm_status_t **ptr); +void snd_pcm_status_free(snd_pcm_status_t *obj); +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); + +void snd_pcm_status_get_trigger_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr); + +void snd_pcm_status_get_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr); + +snd_pcm_sframes_t snd_pcm_status_get_delay(const snd_pcm_status_t *obj); + +snd_pcm_uframes_t snd_pcm_status_get_avail(const snd_pcm_status_t *obj); + +snd_pcm_uframes_t snd_pcm_status_get_avail_max(const snd_pcm_status_t *obj); + + +#ifdef __cplusplus +} +#endif diff --git a/include/rawmidi.h b/include/rawmidi.h index b198582f..6bee080f 100644 --- a/include/rawmidi.h +++ b/include/rawmidi.h @@ -5,22 +5,24 @@ * * ****************************************************************************/ +typedef struct _snd_rawmidi_info snd_rawmidi_info_t; +typedef struct _snd_rawmidi_params snd_rawmidi_params_t; +typedef struct _snd_rawmidi_status snd_rawmidi_status_t; + +/* sndrv aliasing */ +#ifdef SND_ENUM_TYPECHECK +typedef struct _snd_rawmidi_stream *snd_rawmidi_stream_t; +#else typedef enum sndrv_rawmidi_stream snd_rawmidi_stream_t; -typedef struct sndrv_rawmidi_info snd_rawmidi_info_t; -typedef struct sndrv_rawmidi_params snd_rawmidi_params_t; -typedef struct sndrv_rawmidi_status snd_rawmidi_status_t; -#define SND_RAWMIDI_STREAM_OUTPUT SNDRV_RAWMIDI_STREAM_OUTPUT -#define SND_RAWMIDI_STREAM_INPUT SNDRV_RAWMIDI_STREAM_INPUT +#endif + +#define SND_RAWMIDI_STREAM_OUTPUT ((snd_rawmidi_stream_t) SNDRV_RAWMIDI_STREAM_OUTPUT) +#define SND_RAWMIDI_STREAM_INPUT ((snd_rawmidi_stream_t) SNDRV_RAWMIDI_STREAM_INPUT) #define SND_RAWMIDI_INFO_OUTPUT SNDRV_RAWMIDI_INFO_OUTPUT #define SND_RAWMIDI_INFO_INPUT SNDRV_RAWMIDI_INFO_INPUT #define SND_RAWMIDI_INFO_DUPLEX SNDRV_RAWMIDI_INFO_DUPLEX -#define SND_RAWMIDI_INFO_XXXX SNDRV_RAWMIDI_INFO_XXXX -#define SND_RAWMIDI_PARBIT_STREAM SNDRV_RAWMIDI_PARBIT_STREAM -#define SND_RAWMIDI_PARBIT_BUFFER_SIZE SNDRV_RAWMIDI_PARBIT_BUFFER_SIZE -#define SND_RAWMIDI_PARBIT_AVAIL_MIN SNDRV_RAWMIDI_PARBIT_AVAIL_MIN - -#define SND_RAWMIDI_OPEN_OUTPUT (1<<SND_RAWMIDI_STREAM_OUTPUT) -#define SND_RAWMIDI_OPEN_INPUT (1<<SND_RAWMIDI_STREAM_INPUT) +#define SND_RAWMIDI_OPEN_OUTPUT (1<<SNDRV_RAWMIDI_STREAM_OUTPUT) +#define SND_RAWMIDI_OPEN_INPUT (1<<SNDRV_RAWMIDI_STREAM_INPUT) #define SND_RAWMIDI_OPEN_DUPLEX (SND_RAWMIDI_OPEN_OUTPUT|SND_RAWMIDI_OPEN_INPUT) #define SND_RAWMIDI_APPEND 1 @@ -40,20 +42,21 @@ extern "C" { int snd_rawmidi_open(snd_rawmidi_t **handle, char *name, int streams, int mode); int snd_rawmidi_close(snd_rawmidi_t *handle); -int snd_rawmidi_card(snd_rawmidi_t *handle); -int snd_rawmidi_poll_descriptor(snd_rawmidi_t *handle); -int snd_rawmidi_nonblock(snd_rawmidi_t *handle, int nonblock); -int snd_rawmidi_info(snd_rawmidi_t *handle, snd_rawmidi_info_t * info); -int snd_rawmidi_params(snd_rawmidi_t *handle, snd_rawmidi_params_t * params); -int snd_rawmidi_status(snd_rawmidi_t *handle, snd_rawmidi_status_t * status); -int snd_rawmidi_output_drop(snd_rawmidi_t *handle); -int snd_rawmidi_output_drain(snd_rawmidi_t *handle); -int snd_rawmidi_input_drain(snd_rawmidi_t *handle); -int snd_rawmidi_drain(snd_rawmidi_t *handle, int channel); -int snd_rawmidi_drop(snd_rawmidi_t *handle, int channel); +int snd_rawmidi_poll_descriptor(snd_rawmidi_t *handle, snd_rawmidi_stream_t stream); +int snd_rawmidi_nonblock(snd_rawmidi_t *handle, snd_rawmidi_stream_t stream, int nonblock); +int snd_rawmidi_info(snd_rawmidi_t *handle, snd_rawmidi_stream_t stream, snd_rawmidi_info_t * info); +int snd_rawmidi_params(snd_rawmidi_t *handle, snd_rawmidi_stream_t stream, snd_rawmidi_params_t * params); +int snd_rawmidi_status(snd_rawmidi_t *handle, snd_rawmidi_stream_t stream, snd_rawmidi_status_t * status); +int snd_rawmidi_drain(snd_rawmidi_t *handle, snd_rawmidi_stream_t stream); +int snd_rawmidi_drop(snd_rawmidi_t *handle, snd_rawmidi_stream_t stream); ssize_t snd_rawmidi_write(snd_rawmidi_t *handle, const void *buffer, size_t size); ssize_t snd_rawmidi_read(snd_rawmidi_t *handle, void *buffer, size_t size); +int snd_rawmidi_params_current(snd_pcm_t *pcm, snd_rawmidi_params_t *params); +int snd_rawmidi_params_dump(snd_rawmidi_params_t *params, snd_output_t *out); + +int snd_rawmidi_status_dump(snd_rawmidi_status_t *status, snd_output_t *out); + #ifdef __cplusplus } #endif diff --git a/include/rawmidi_m4.h b/include/rawmidi_m4.h new file mode 100644 index 00000000..5d5e9e37 --- /dev/null +++ b/include/rawmidi_m4.h @@ -0,0 +1,67 @@ +#ifdef __cplusplus +extern "C" { +#endif + +size_t snd_rawmidi_params_sizeof(); +#define snd_rawmidi_params_alloca(ptr) ({assert(ptr); *ptr = (snd_rawmidi_params_t *) alloca(snd_rawmidi_params_sizeof()); 0;}) +int snd_rawmidi_params_malloc(snd_rawmidi_params_t **ptr); +void snd_rawmidi_params_free(snd_rawmidi_params_t *obj); +void snd_rawmidi_params_copy(snd_rawmidi_params_t *dst, const snd_rawmidi_params_t *src); + +int snd_rawmidi_params_set_buffer_size(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params, size_t val); +size_t snd_rawmidi_params_get_buffer_size(const snd_rawmidi_params_t *params); + +int snd_rawmidi_params_set_avail_min(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params, size_t val); +size_t snd_rawmidi_params_get_avail_min(const snd_rawmidi_params_t *params); + +int snd_rawmidi_params_set_no_active_sensing(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params, int val); +int snd_rawmidi_params_get_no_active_sensing(const snd_rawmidi_params_t *params); + +size_t snd_rawmidi_info_sizeof(); +#define snd_rawmidi_info_alloca(ptr) ({assert(ptr); *ptr = (snd_rawmidi_info_t *) alloca(snd_rawmidi_info_sizeof()); 0;}) +int snd_rawmidi_info_malloc(snd_rawmidi_info_t **ptr); +void snd_rawmidi_info_free(snd_rawmidi_info_t *obj); +void snd_rawmidi_info_copy(snd_rawmidi_info_t *dst, const snd_rawmidi_info_t *src); + +unsigned int snd_rawmidi_info_get_device(const snd_rawmidi_info_t *obj); + +unsigned int snd_rawmidi_info_get_subdevice(const snd_rawmidi_info_t *obj); + +snd_rawmidi_stream_t snd_rawmidi_info_get_stream(const snd_rawmidi_info_t *obj); + +int snd_rawmidi_info_get_card(const snd_rawmidi_info_t *obj); + +unsigned int snd_rawmidi_info_get_flags(const snd_rawmidi_info_t *obj); + +const char * snd_rawmidi_info_get_id(const snd_rawmidi_info_t *obj); + +const char * snd_rawmidi_info_get_name(const snd_rawmidi_info_t *obj); + +const char * snd_rawmidi_info_get_subdevice_name(const snd_rawmidi_info_t *obj); + +unsigned int snd_rawmidi_info_get_subdevices_count(const snd_rawmidi_info_t *obj); + +unsigned int snd_rawmidi_info_get_subdevices_avail(const snd_rawmidi_info_t *obj); + +void snd_rawmidi_info_set_device(snd_rawmidi_info_t *obj, unsigned int val); + +void snd_rawmidi_info_set_subdevice(snd_rawmidi_info_t *obj, unsigned int val); + +void snd_rawmidi_info_set_stream(snd_rawmidi_info_t *obj, snd_rawmidi_stream_t val); + +size_t snd_rawmidi_status_sizeof(); +#define snd_rawmidi_status_alloca(ptr) ({assert(ptr); *ptr = (snd_rawmidi_status_t *) alloca(snd_rawmidi_status_sizeof()); 0;}) +int snd_rawmidi_status_malloc(snd_rawmidi_status_t **ptr); +void snd_rawmidi_status_free(snd_rawmidi_status_t *obj); +void snd_rawmidi_status_copy(snd_rawmidi_status_t *dst, const snd_rawmidi_status_t *src); + +void snd_rawmidi_status_get_tstamp(const snd_rawmidi_status_t *obj, snd_timestamp_t *ptr); + +size_t snd_rawmidi_status_get_avail(const snd_rawmidi_status_t *obj); + +size_t snd_rawmidi_status_get_avail_max(const snd_rawmidi_status_t *obj); + + +#ifdef __cplusplus +} +#endif diff --git a/src/instr/fm.c b/src/instr/fm.c index d21b0298..d20be38c 100644 --- a/src/instr/fm.c +++ b/src/instr/fm.c @@ -56,7 +56,7 @@ int snd_instr_fm_convert_to_stream(snd_instr_fm_t *fm, if (put == NULL) return -ENOMEM; /* build header */ - bzero(put, sizeof(*put)); + memset(put, 0, sizeof(*put)); data = &put->data; if (name) strncpy(data->name, name, sizeof(data->name)-1); diff --git a/src/instr/iwffff.c b/src/instr/iwffff.c index 87147719..9aa12d8b 100644 --- a/src/instr/iwffff.c +++ b/src/instr/iwffff.c @@ -765,7 +765,7 @@ int snd_instr_iwffff_conv_to_stream(snd_instr_iwffff_t *iwffff, if (put == NULL) return -ENOMEM; /* build header */ - bzero(put, sizeof(*put)); + memset(put, 0, sizeof(*put)); data = &put->data; if (name) strncpy(data->name, name, sizeof(data->name)-1); diff --git a/src/instr/simple.c b/src/instr/simple.c index 0b1d13e6..8474bb44 100644 --- a/src/instr/simple.c +++ b/src/instr/simple.c @@ -71,7 +71,7 @@ int snd_instr_simple_convert_to_stream(snd_instr_simple_t *simple, if (put == NULL) return -ENOMEM; /* build header */ - bzero(put, sizeof(*put)); + memset(put, 0, sizeof(*put)); data = &put->data; if (name) strncpy(data->name, name, sizeof(data->name)-1); diff --git a/src/pcm/Makefile.am b/src/pcm/Makefile.am index 8e9d4075..38782794 100644 --- a/src/pcm/Makefile.am +++ b/src/pcm/Makefile.am @@ -2,7 +2,7 @@ EXTRA_LTLIBRARIES = libpcm.la libpcm_la_SOURCES = mask.c interval.c \ - pcm.c pcm_hw.c pcm_plugin.c pcm_copy.c pcm_linear.c \ + pcm.c pcm_m4.c pcm_hw.c pcm_plugin.c pcm_copy.c pcm_linear.c \ pcm_route.c pcm_mulaw.c pcm_alaw.c pcm_adpcm.c \ pcm_rate.c pcm_plug.c pcm_misc.c pcm_mmap.c pcm_multi.c \ pcm_shm.c pcm_file.c pcm_share.c pcm_null.c \ diff --git a/src/pcm/mask.h b/src/pcm/mask.h index 1bfefdd5..3f80b154 100644 --- a/src/pcm/mask.h +++ b/src/pcm/mask.h @@ -19,6 +19,8 @@ * */ +typedef struct _snd_mask snd_mask_t; + #define SND_MASK_MAX 31 #ifdef SND_MASK_INLINE diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index d33da637..8a37db48 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -39,7 +39,7 @@ snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm) return pcm->type; } -snd_pcm_type_t snd_pcm_stream(snd_pcm_t *pcm) +snd_pcm_stream_t snd_pcm_stream(snd_pcm_t *pcm) { assert(pcm); return pcm->stream; @@ -99,7 +99,7 @@ int snd_pcm_status(snd_pcm_t *pcm, snd_pcm_status_t *status) return pcm->fast_ops->status(pcm->fast_op_arg, status); } -int snd_pcm_state(snd_pcm_t *pcm) +snd_pcm_state_t snd_pcm_state(snd_pcm_t *pcm) { assert(pcm); return pcm->fast_ops->state(pcm->fast_op_arg); @@ -287,18 +287,6 @@ char *snd_pcm_hw_param_names[] = { HW_PARAM(TICK_TIME), }; -char *snd_pcm_sw_param_names[] = { - SW_PARAM(START_MODE), - SW_PARAM(XRUN_MODE), - SW_PARAM(TSTAMP_MODE), - SW_PARAM(PERIOD_STEP), - SW_PARAM(SLEEP_MIN), - SW_PARAM(AVAIL_MIN), - SW_PARAM(XFER_ALIGN), - SW_PARAM(SILENCE_THRESHOLD), - SW_PARAM(SILENCE_SIZE), -}; - char *snd_pcm_access_names[] = { ACCESS(MMAP_INTERLEAVED), ACCESS(MMAP_NONINTERLEAVED), @@ -391,77 +379,73 @@ 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[stream]; + return snd_pcm_stream_names[snd_enum_to_int(stream)]; } const char *snd_pcm_access_name(snd_pcm_access_t access) { assert(access <= SND_PCM_ACCESS_LAST); - return snd_pcm_access_names[access]; + return snd_pcm_access_names[snd_enum_to_int(access)]; } const char *snd_pcm_format_name(snd_pcm_format_t format) { assert(format <= SND_PCM_FORMAT_LAST); - return snd_pcm_format_names[format]; + return snd_pcm_format_names[snd_enum_to_int(format)]; } const char *snd_pcm_format_description(snd_pcm_format_t format) { assert(format <= SND_PCM_FORMAT_LAST); - return snd_pcm_format_descriptions[format]; + return snd_pcm_format_descriptions[snd_enum_to_int(format)]; } -int snd_pcm_format_value(const char* name) +snd_pcm_format_t snd_pcm_format_value(const char* name) { - unsigned int format; - for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) - if (snd_pcm_format_names[format] && - strcasecmp(name, snd_pcm_format_names[format]) == 0) + 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) { return format; - return -1; + } + } + return SND_PCM_FORMAT_NONE; } const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat) { assert(subformat <= SND_PCM_SUBFORMAT_LAST); - return snd_pcm_subformat_names[subformat]; + return snd_pcm_subformat_names[snd_enum_to_int(subformat)]; } 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[param]; -} - -const char *snd_pcm_sw_param_name(snd_pcm_sw_param_t param) -{ - assert(param <= SND_PCM_SW_PARAM_LAST); - return snd_pcm_sw_param_names[param]; + return snd_pcm_hw_param_names[snd_enum_to_int(param)]; } const char *snd_pcm_start_mode_name(snd_pcm_start_t mode) { assert(mode <= SND_PCM_START_LAST); - return snd_pcm_start_mode_names[mode]; + return snd_pcm_start_mode_names[snd_enum_to_int(mode)]; } const char *snd_pcm_xrun_mode_name(snd_pcm_xrun_t mode) { assert(mode <= SND_PCM_XRUN_LAST); - return snd_pcm_xrun_mode_names[mode]; + return snd_pcm_xrun_mode_names[snd_enum_to_int(mode)]; } const char *snd_pcm_tstamp_mode_name(snd_pcm_tstamp_t mode) { assert(mode <= SND_PCM_TSTAMP_LAST); - return snd_pcm_tstamp_mode_names[mode]; + return snd_pcm_tstamp_mode_names[snd_enum_to_int(mode)]; } const char *snd_pcm_state_name(snd_pcm_state_t state) { assert(state <= SND_PCM_STATE_LAST); - return snd_pcm_state_names[state]; + return snd_pcm_state_names[snd_enum_to_int(state)]; } int snd_pcm_dump_hw_setup(snd_pcm_t *pcm, snd_output_t *out) @@ -509,186 +493,10 @@ int snd_pcm_dump_setup(snd_pcm_t *pcm, snd_output_t *out) return 0; } -size_t snd_pcm_info_sizeof() -{ - return sizeof(snd_pcm_info_t); -} - -int snd_pcm_info_malloc(snd_pcm_info_t **infop) -{ - assert(infop); - *infop = malloc(sizeof(snd_pcm_info_t)); - if (!*infop) - return -ENOMEM; - return 0; -} - -void snd_pcm_info_free(snd_pcm_info_t *info) -{ - assert(info); - free(info); -} - -void snd_pcm_info_copy(snd_pcm_info_t *dst, - const snd_pcm_info_t *src) -{ - assert(dst && src); - *dst = *src; -} - -void snd_pcm_info_set_device(snd_pcm_info_t *info, unsigned int device) -{ - assert(info); - info->device = device; -} - -void snd_pcm_info_set_subdevice(snd_pcm_info_t *info, unsigned int subdevice) -{ - assert(info); - info->subdevice = subdevice; -} - -void snd_pcm_info_set_stream(snd_pcm_info_t *info, snd_pcm_stream_t stream) -{ - assert(info); - info->stream = stream; -} - -int snd_pcm_info_card(snd_pcm_info_t *info) -{ - assert(info); - return info->card; -} - -unsigned int snd_pcm_info_device(snd_pcm_info_t *info) -{ - assert(info); - return info->device; -} - -unsigned int snd_pcm_info_subdevice(snd_pcm_info_t *info) -{ - assert(info); - return info->subdevice; -} - -snd_pcm_stream_t snd_pcm_info_stream(snd_pcm_info_t *info) -{ - assert(info); - return info->stream; -} - -const char *snd_pcm_info_device_id(snd_pcm_info_t *info) -{ - assert(info); - return info->id; -} - -const char *snd_pcm_info_device_name(snd_pcm_info_t *info) -{ - assert(info); - return info->name; -} - -const char *snd_pcm_info_subdevice_name(snd_pcm_info_t *info) -{ - assert(info); - return info->subname; -} - -snd_pcm_class_t snd_pcm_info_device_class(snd_pcm_info_t *info) -{ - assert(info); - return info->dev_class; -} - -snd_pcm_subclass_t snd_pcm_info_device_subclass(snd_pcm_info_t *info) -{ - assert(info); - return info->dev_subclass; -} - -unsigned int snd_pcm_info_subdevices_count(snd_pcm_info_t *info) -{ - assert(info); - return info->subdevices_count; -} - -unsigned int snd_pcm_info_subdevices_avail(snd_pcm_info_t *info) -{ - assert(info); - return info->subdevices_avail; -} - -size_t snd_pcm_status_sizeof() -{ - return sizeof(snd_pcm_status_t); -} - -int snd_pcm_status_malloc(snd_pcm_status_t **statusp) -{ - assert(statusp); - *statusp = malloc(sizeof(snd_pcm_status_t)); - if (!*statusp) - return -ENOMEM; - return 0; -} - -void snd_pcm_status_free(snd_pcm_status_t *status) -{ - assert(status); - free(status); -} - -void snd_pcm_status_copy(snd_pcm_status_t *dst, - const snd_pcm_status_t *src) -{ - assert(dst && src); - *dst = *src; -} - -snd_pcm_state_t snd_pcm_status_state(snd_pcm_status_t *status) -{ - assert(status); - return status->state; -} - -int snd_pcm_status_delay(snd_pcm_status_t *status) -{ - assert(status); - return status->delay; -} - -int snd_pcm_status_avail(snd_pcm_status_t *status) -{ - assert(status); - return status->avail; -} - -int snd_pcm_status_avail_max(snd_pcm_status_t *status) -{ - assert(status); - return status->avail_max; -} - -void snd_pcm_status_tstamp(snd_pcm_status_t *status, - snd_timestamp_t *tstamp) -{ - assert(status && tstamp); - *tstamp = status->tstamp; -} - -void snd_pcm_status_trigger_tstamp(snd_pcm_status_t *status, - snd_timestamp_t *tstamp) -{ - assert(status && tstamp); - *tstamp = status->trigger_tstamp; -} - int snd_pcm_status_dump(snd_pcm_status_t *status, snd_output_t *out) { assert(status); - snd_output_printf(out, "state : %s\n", snd_pcm_state_name(status->state)); + snd_output_printf(out, "state : %s\n", snd_pcm_state_name((snd_pcm_state_t) status->state)); snd_output_printf(out, "trigger_time: %ld.%06ld\n", status->trigger_tstamp.tv_sec, status->trigger_tstamp.tv_usec); snd_output_printf(out, "tstamp : %ld.%06ld\n", @@ -736,7 +544,7 @@ ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, int samples) } int snd_pcm_open(snd_pcm_t **pcmp, char *name, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { char *str; int err; @@ -744,7 +552,7 @@ int snd_pcm_open(snd_pcm_t **pcmp, char *name, snd_config_iterator_t i; char *lib = NULL, *open = NULL; int (*open_func)(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode); + snd_pcm_stream_t stream, int mode); void *h; assert(pcmp && name); err = snd_config_update(); @@ -903,7 +711,7 @@ int snd_pcm_wait(snd_pcm_t *pcm, int timeout) pfd.events = pcm->stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN; err = poll(&pfd, 1, timeout); if (err < 0) - return err; + return -errno; return 0; } @@ -920,7 +728,7 @@ snd_pcm_sframes_t snd_pcm_mmap_forward(snd_pcm_t *pcm, snd_pcm_uframes_t size) } int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t dst_offset, - unsigned int samples, int format) + unsigned int samples, snd_pcm_format_t format) { /* FIXME: sub byte resolution and odd dst_offset */ char *dst; @@ -1002,7 +810,7 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes } int snd_pcm_areas_silence(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, - unsigned int channels, snd_pcm_uframes_t frames, int format) + unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format) { int width = snd_pcm_format_physical_width(format); while (channels > 0) { @@ -1044,7 +852,7 @@ int snd_pcm_areas_silence(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufram int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_area, snd_pcm_uframes_t src_offset, - unsigned int samples, int format) + unsigned int samples, snd_pcm_format_t format) { /* FIXME: sub byte resolution and odd dst_offset */ char *src, *dst; @@ -1139,7 +947,7 @@ int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t int snd_pcm_areas_copy(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset, - unsigned int channels, snd_pcm_uframes_t frames, int format) + unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format) { int width = snd_pcm_format_physical_width(format); while (channels > 0) { @@ -1194,14 +1002,14 @@ snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_ { snd_pcm_uframes_t xfer = 0; int err = 0; - int state = snd_pcm_state(pcm); + snd_pcm_state_t state = snd_pcm_state(pcm); if (size == 0) return 0; if (size > pcm->xfer_align) size -= size % pcm->xfer_align; - switch (state) { + switch (snd_enum_to_int(state)) { case SND_PCM_STATE_PREPARED: if (pcm->start_mode == SND_PCM_START_DATA) { err = snd_pcm_start(pcm); @@ -1278,14 +1086,14 @@ snd_pcm_sframes_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area { snd_pcm_uframes_t xfer = 0; int err = 0; - int state = snd_pcm_state(pcm); + snd_pcm_state_t state = snd_pcm_state(pcm); if (size == 0) return 0; if (size > pcm->xfer_align) size -= size % pcm->xfer_align; - switch (state) { + switch (snd_enum_to_int(state)) { case SND_PCM_STATE_PREPARED: case SND_PCM_STATE_RUNNING: break; diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c index f8882844..65810494 100644 --- a/src/pcm/pcm_adpcm.c +++ b/src/pcm/pcm_adpcm.c @@ -63,7 +63,7 @@ typedef struct { snd_pcm_plugin_t plug; int getput_idx; adpcm_f func; - int sformat; + snd_pcm_format_t sformat; snd_pcm_adpcm_state_t *states; } snd_pcm_adpcm_t; @@ -316,26 +316,25 @@ static int snd_pcm_adpcm_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t { snd_pcm_adpcm_t *adpcm = pcm->private; int err; - snd_mask_t *access_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN); - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS, + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS, access_mask); if (err < 0) return err; if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) { - snd_mask_t *format_mask = alloca(snd_mask_sizeof()); + snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof()); snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR); - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_FORMAT, - format_mask); + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT, + format_mask); } else { - err = _snd_pcm_hw_param_set(params, - SND_PCM_HW_PARAM_FORMAT, - SND_PCM_FORMAT_IMA_ADPCM, 0); + err = _snd_pcm_hw_params_set_format(params, + SND_PCM_FORMAT_IMA_ADPCM); } if (err < 0) return err; - err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT, - SND_PCM_SUBFORMAT_STD, 0); + err = _snd_pcm_hw_params_set_subformat(params, + SND_PCM_SUBFORMAT_STD); if (err < 0) return err; params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID); @@ -345,15 +344,13 @@ static int snd_pcm_adpcm_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t static int snd_pcm_adpcm_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams) { snd_pcm_adpcm_t *adpcm = pcm->private; - snd_mask_t *saccess_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP); _snd_pcm_hw_params_any(sparams); - _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, saccess_mask); - _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_FORMAT, - adpcm->sformat, 0); - _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_SUBFORMAT, - SND_PCM_SUBFORMAT_STD, 0); + _snd_pcm_hw_params_set_format(sparams, adpcm->sformat); + _snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD); return 0; } @@ -417,7 +414,7 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) { - adpcm->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0), SND_PCM_FORMAT_S16); + adpcm->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_params_get_format(params), SND_PCM_FORMAT_S16); adpcm->func = snd_pcm_adpcm_encode; } else { adpcm->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, adpcm->sformat); @@ -425,7 +422,7 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) } } else { if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) { - adpcm->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0)); + adpcm->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_params_get_format(params)); adpcm->func = snd_pcm_adpcm_decode; } else { adpcm->getput_idx = snd_pcm_linear_get_index(adpcm->sformat, SND_PCM_FORMAT_S16); @@ -433,7 +430,7 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) } } assert(!adpcm->states); - adpcm->states = malloc(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_CHANNELS, 0) * sizeof(*adpcm->states)); + adpcm->states = malloc(snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_CHANNELS, 0) * sizeof(*adpcm->states)); return 0; } @@ -556,7 +553,7 @@ snd_pcm_ops_t snd_pcm_adpcm_ops = { munmap: snd_pcm_plugin_munmap, }; -int snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave) +int snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave) { snd_pcm_t *pcm; snd_pcm_adpcm_t *adpcm; @@ -600,13 +597,13 @@ int snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *sla int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; char *sname = NULL; int err; snd_pcm_t *spcm; - int sformat = -1; + snd_pcm_format_t sformat = SND_PCM_FORMAT_NONE; snd_config_foreach(i, conf) { snd_config_t *n = snd_config_entry(i); if (strcmp(n->id, "comment") == 0) @@ -631,7 +628,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, return -EINVAL; } sformat = snd_pcm_format_value(f); - if (sformat < 0) { + if (sformat == SND_PCM_FORMAT_NONE) { ERR("Unknown sformat"); return -EINVAL; } @@ -649,7 +646,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, ERR("sname is not defined"); return -EINVAL; } - if (sformat < 0) { + if (sformat == SND_PCM_FORMAT_NONE) { ERR("sformat is not defined"); return -EINVAL; } diff --git a/src/pcm/pcm_alaw.c b/src/pcm/pcm_alaw.c index 90e6e60b..ec92e752 100644 --- a/src/pcm/pcm_alaw.c +++ b/src/pcm/pcm_alaw.c @@ -34,7 +34,7 @@ typedef struct { snd_pcm_plugin_t plug; int getput_idx; alaw_f func; - int sformat; + snd_pcm_format_t sformat; } snd_pcm_alaw_t; static inline int val_seg(int val) @@ -215,26 +215,24 @@ static int snd_pcm_alaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t * { snd_pcm_alaw_t *alaw = pcm->private; int err; - snd_mask_t *access_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN); - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS, + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS, access_mask); if (err < 0) return err; if (alaw->sformat == SND_PCM_FORMAT_A_LAW) { - snd_mask_t *format_mask = alloca(snd_mask_sizeof()); + snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof()); snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR); - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_FORMAT, - format_mask); + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT, + format_mask); } else { - err = _snd_pcm_hw_param_set(params, - SND_PCM_HW_PARAM_FORMAT, - SND_PCM_FORMAT_A_LAW, 0); + err = _snd_pcm_hw_params_set_format(params, + SND_PCM_FORMAT_A_LAW); } if (err < 0) return err; - err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT, - SND_PCM_SUBFORMAT_STD, 0); + err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD); if (err < 0) return err; params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID); @@ -244,15 +242,13 @@ static int snd_pcm_alaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t * static int snd_pcm_alaw_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams) { snd_pcm_alaw_t *alaw = pcm->private; - snd_mask_t *saccess_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP); _snd_pcm_hw_params_any(sparams); - _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, saccess_mask); - _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_FORMAT, - alaw->sformat, 0); - _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_SUBFORMAT, - SND_PCM_SUBFORMAT_STD, 0); + _snd_pcm_hw_params_set_format(sparams, alaw->sformat); + _snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD); return 0; } @@ -315,7 +311,7 @@ static int snd_pcm_alaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { if (alaw->sformat == SND_PCM_FORMAT_A_LAW) { - alaw->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0), SND_PCM_FORMAT_S16); + alaw->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_params_get_format(params), SND_PCM_FORMAT_S16); alaw->func = snd_pcm_alaw_encode; } else { alaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, alaw->sformat); @@ -323,7 +319,7 @@ static int snd_pcm_alaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) } } else { if (alaw->sformat == SND_PCM_FORMAT_A_LAW) { - alaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0)); + alaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_params_get_format(params)); alaw->func = snd_pcm_alaw_decode; } else { alaw->getput_idx = snd_pcm_linear_get_index(alaw->sformat, SND_PCM_FORMAT_S16); @@ -431,7 +427,7 @@ snd_pcm_ops_t snd_pcm_alaw_ops = { munmap: snd_pcm_plugin_munmap, }; -int snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave) +int snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave) { snd_pcm_t *pcm; snd_pcm_alaw_t *alaw; @@ -474,13 +470,13 @@ int snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slav int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; char *sname = NULL; int err; snd_pcm_t *spcm; - int sformat = -1; + snd_pcm_format_t sformat = SND_PCM_FORMAT_NONE; snd_config_foreach(i, conf) { snd_config_t *n = snd_config_entry(i); if (strcmp(n->id, "comment") == 0) @@ -505,7 +501,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, return -EINVAL; } sformat = snd_pcm_format_value(f); - if (sformat < 0) { + if (sformat == SND_PCM_FORMAT_NONE) { ERR("Unknown sformat"); return -EINVAL; } @@ -523,7 +519,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, ERR("sname is not defined"); return -EINVAL; } - if (sformat < 0) { + if (sformat == SND_PCM_FORMAT_NONE) { ERR("sformat is not defined"); return -EINVAL; } diff --git a/src/pcm/pcm_copy.c b/src/pcm/pcm_copy.c index 49772f86..2ae955ed 100644 --- a/src/pcm/pcm_copy.c +++ b/src/pcm/pcm_copy.c @@ -31,10 +31,10 @@ typedef struct { static int snd_pcm_copy_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params) { int err; - snd_mask_t *access_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN); - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS, - access_mask); + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS, + access_mask); if (err < 0) return err; params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID); @@ -43,10 +43,10 @@ static int snd_pcm_copy_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_ static int snd_pcm_copy_hw_refine_sprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *sparams) { - snd_mask_t *saccess_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP); _snd_pcm_hw_params_any(sparams); - _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, saccess_mask); return 0; } @@ -227,7 +227,7 @@ int snd_pcm_copy_open(snd_pcm_t **pcmp, char *name, snd_pcm_t *slave, int close_ int _snd_pcm_copy_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; char *sname = NULL; diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c index 844abca8..6c0407de 100644 --- a/src/pcm/pcm_file.c +++ b/src/pcm/pcm_file.c @@ -139,7 +139,7 @@ static int snd_pcm_file_status(snd_pcm_t *pcm, snd_pcm_status_t * status) return snd_pcm_status(file->slave, status); } -static int snd_pcm_file_state(snd_pcm_t *pcm) +static snd_pcm_state_t snd_pcm_file_state(snd_pcm_t *pcm) { snd_pcm_file_t *file = pcm->private; return snd_pcm_state(file->slave); @@ -461,7 +461,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, char *name, char *fname, int fd, char *f int _snd_pcm_file_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; char *sname = NULL; diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index 58b01af0..d53c48be 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -157,9 +157,9 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params) { snd_pcm_hw_t *hw = pcm->private; int fd = hw->fd; - if (params->start_mode == pcm->start_mode && - params->xrun_mode == pcm->xrun_mode && - params->tstamp_mode == pcm->tstamp_mode && + if ((snd_pcm_start_t) params->start_mode == pcm->start_mode && + (snd_pcm_xrun_t) params->xrun_mode == pcm->xrun_mode && + (snd_pcm_tstamp_t) params->tstamp_mode == pcm->tstamp_mode && params->period_step == pcm->period_step && params->sleep_min == pcm->sleep_min && params->xfer_align == pcm->xfer_align && @@ -209,10 +209,10 @@ static int snd_pcm_hw_status(snd_pcm_t *pcm, snd_pcm_status_t * status) return 0; } -static int snd_pcm_hw_state(snd_pcm_t *pcm) +static snd_pcm_state_t snd_pcm_hw_state(snd_pcm_t *pcm) { snd_pcm_hw_t *hw = pcm->private; - return hw->mmap_status->state; + return (snd_pcm_state_t) hw->mmap_status->state; } static int snd_pcm_hw_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp) @@ -541,7 +541,7 @@ snd_pcm_fast_ops_t snd_pcm_hw_fast_ops = { mmap_forward: snd_pcm_hw_mmap_forward, }; -int snd_pcm_hw_open_subdevice(snd_pcm_t **pcmp, int card, int device, int subdevice, int stream, int mode) +int snd_pcm_hw_open_subdevice(snd_pcm_t **pcmp, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode) { char filename[32]; char *filefmt; @@ -559,7 +559,7 @@ int snd_pcm_hw_open_subdevice(snd_pcm_t **pcmp, int card, int device, int subdev if ((ret = snd_ctl_hw_open(&ctl, NULL, card)) < 0) return ret; - switch (stream) { + switch (snd_enum_to_int(stream)) { case SND_PCM_STREAM_PLAYBACK: filefmt = SNDRV_FILE_PCM_STREAM_PLAYBACK; break; @@ -659,12 +659,12 @@ int snd_pcm_hw_open_subdevice(snd_pcm_t **pcmp, int card, int device, int subdev return ret; } -int snd_pcm_hw_open_device(snd_pcm_t **pcmp, int card, int device, int stream, int mode) +int snd_pcm_hw_open_device(snd_pcm_t **pcmp, int card, int device, snd_pcm_stream_t stream, int mode) { return snd_pcm_hw_open_subdevice(pcmp, card, device, -1, stream, mode); } -int snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, int card, int device, int subdevice, int stream, int mode) +int snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode) { int err = snd_pcm_hw_open_subdevice(pcmp, card, device, subdevice, stream, mode); if (err < 0) @@ -675,7 +675,7 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, int card, int device, int subd } int _snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; long card = -1, device = 0, subdevice = -1; diff --git a/src/pcm/pcm_linear.c b/src/pcm/pcm_linear.c index 5e4ab339..5b76a047 100644 --- a/src/pcm/pcm_linear.c +++ b/src/pcm/pcm_linear.c @@ -27,10 +27,11 @@ typedef struct { /* This field need to be the first */ snd_pcm_plugin_t plug; int conv_idx; - int sformat; + snd_pcm_format_t sformat; } snd_pcm_linear_t; -int snd_pcm_linear_convert_index(int src_format, int dst_format) +int snd_pcm_linear_convert_index(snd_pcm_format_t src_format, + snd_pcm_format_t dst_format) { int src_endian, dst_endian, sign, src_width, dst_width; @@ -55,7 +56,7 @@ int snd_pcm_linear_convert_index(int src_format, int dst_format) return src_width * 32 + src_endian * 16 + sign * 8 + dst_width * 2 + dst_endian; } -int snd_pcm_linear_get_index(int src_format, int dst_format) +int snd_pcm_linear_get_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format) { int sign, width, endian; sign = (snd_pcm_format_signed(src_format) != @@ -71,7 +72,7 @@ int snd_pcm_linear_get_index(int src_format, int dst_format) return width * 4 + endian * 2 + sign; } -int snd_pcm_linear_put_index(int src_format, int dst_format) +int snd_pcm_linear_put_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format) { int sign, width, endian; sign = (snd_pcm_format_signed(src_format) != @@ -132,20 +133,19 @@ void snd_pcm_linear_convert(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufr static int snd_pcm_linear_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params) { int err; - snd_mask_t *access_mask = alloca(snd_mask_sizeof()); - snd_mask_t *format_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof()); + snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof()); snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN); snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR); - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS, + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS, access_mask); if (err < 0) return err; - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_FORMAT, - format_mask); + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT, + format_mask); if (err < 0) return err; - err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT, - SND_PCM_SUBFORMAT_STD, 0); + err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD); if (err < 0) return err; params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID); @@ -155,15 +155,13 @@ static int snd_pcm_linear_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, sn static int snd_pcm_linear_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams) { snd_pcm_linear_t *linear = pcm->private; - snd_mask_t *saccess_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP); _snd_pcm_hw_params_any(sparams); - _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, saccess_mask); - _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_FORMAT, - linear->sformat, 0); - _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_SUBFORMAT, - SND_PCM_SUBFORMAT_STD, 0); + _snd_pcm_hw_params_set_format(sparams, linear->sformat); + _snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD); return 0; } @@ -224,11 +222,11 @@ static int snd_pcm_linear_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) if (err < 0) return err; if (pcm->stream == SND_PCM_STREAM_PLAYBACK) - linear->conv_idx = snd_pcm_linear_convert_index(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0), + linear->conv_idx = snd_pcm_linear_convert_index(snd_pcm_hw_params_get_format(params), linear->sformat); else linear->conv_idx = snd_pcm_linear_convert_index(linear->sformat, - snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0)); + snd_pcm_hw_params_get_format(params)); return 0; } @@ -328,7 +326,7 @@ snd_pcm_ops_t snd_pcm_linear_ops = { munmap: snd_pcm_plugin_munmap, }; -int snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave) +int snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave) { snd_pcm_t *pcm; snd_pcm_linear_t *linear; @@ -370,13 +368,13 @@ int snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *sl int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; char *sname = NULL; int err; snd_pcm_t *spcm; - int sformat = -1; + snd_pcm_format_t sformat = SND_PCM_FORMAT_NONE; snd_config_foreach(i, conf) { snd_config_t *n = snd_config_entry(i); if (strcmp(n->id, "comment") == 0) @@ -401,9 +399,9 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, return -EINVAL; } sformat = snd_pcm_format_value(f); - if (sformat < 0) { - ERR("Unknown sformat"); - return -EINVAL; + if (sformat == SND_PCM_FORMAT_NONE) { + ERR("Unknown sformat %s", f); + return err; } if (snd_pcm_format_linear(sformat) != 1) { ERR("sformat is not linear"); @@ -418,7 +416,7 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, ERR("sname is not defined"); return -EINVAL; } - if (sformat < 0) { + if (sformat == SND_PCM_FORMAT_NONE) { ERR("sformat is not defined"); return -EINVAL; } diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index 967b14fb..058901e8 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -20,12 +20,6 @@ * */ -#define _snd_interval sndrv_interval -#define _snd_pcm_info sndrv_pcm_info -#define _snd_pcm_hw_params sndrv_pcm_hw_params -#define _snd_pcm_sw_params sndrv_pcm_sw_params -#define _snd_pcm_status sndrv_pcm_status - #include <assert.h> #include <stdio.h> #include <stdlib.h> @@ -33,6 +27,10 @@ #include <sys/uio.h> #include <errno.h> +#define _snd_pcm_access_mask _snd_mask +#define _snd_pcm_format_mask _snd_mask +#define _snd_pcm_subformat_mask _snd_mask + #include "local.h" #define SND_INTERVAL_INLINE @@ -41,6 +39,32 @@ #define SND_MASK_INLINE #include "mask.h" +typedef enum sndrv_pcm_hw_param snd_pcm_hw_param_t; +#define SND_PCM_HW_PARAM_ACCESS SNDRV_PCM_HW_PARAM_ACCESS +#define SND_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_FIRST_MASK +#define SND_PCM_HW_PARAM_FORMAT SNDRV_PCM_HW_PARAM_FORMAT +#define SND_PCM_HW_PARAM_SUBFORMAT SNDRV_PCM_HW_PARAM_SUBFORMAT +#define SND_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_LAST_MASK +#define SND_PCM_HW_PARAM_SAMPLE_BITS SNDRV_PCM_HW_PARAM_SAMPLE_BITS +#define SND_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_FIRST_INTERVAL +#define SND_PCM_HW_PARAM_FRAME_BITS SNDRV_PCM_HW_PARAM_FRAME_BITS +#define SND_PCM_HW_PARAM_CHANNELS SNDRV_PCM_HW_PARAM_CHANNELS +#define SND_PCM_HW_PARAM_RATE SNDRV_PCM_HW_PARAM_RATE +#define SND_PCM_HW_PARAM_PERIOD_TIME SNDRV_PCM_HW_PARAM_PERIOD_TIME +#define SND_PCM_HW_PARAM_PERIOD_SIZE SNDRV_PCM_HW_PARAM_PERIOD_SIZE +#define SND_PCM_HW_PARAM_PERIOD_BYTES SNDRV_PCM_HW_PARAM_PERIOD_BYTES +#define SND_PCM_HW_PARAM_PERIODS SNDRV_PCM_HW_PARAM_PERIODS +#define SND_PCM_HW_PARAM_BUFFER_TIME SNDRV_PCM_HW_PARAM_BUFFER_TIME +#define SND_PCM_HW_PARAM_BUFFER_SIZE SNDRV_PCM_HW_PARAM_BUFFER_SIZE +#define SND_PCM_HW_PARAM_BUFFER_BYTES SNDRV_PCM_HW_PARAM_BUFFER_BYTES +#define SND_PCM_HW_PARAM_TICK_TIME SNDRV_PCM_HW_PARAM_TICK_TIME +#define SND_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_LAST_INTERVAL +#define SND_PCM_HW_PARAM_LAST SNDRV_PCM_HW_PARAM_LAST +#define SND_PCM_HW_PARAMS_RUNTIME SNDRV_PCM_HW_PARAMS_RUNTIME +#define SND_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_LAST_MASK +#define SND_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_FIRST_MASK +#define SND_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_LAST_INTERVAL +#define SND_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_FIRST_INTERVAL typedef struct _snd_pcm_channel_info { unsigned int channel; @@ -83,7 +107,7 @@ typedef struct { int (*drop)(snd_pcm_t *pcm); int (*drain)(snd_pcm_t *pcm); int (*pause)(snd_pcm_t *pcm, int enable); - int (*state)(snd_pcm_t *pcm); + snd_pcm_state_t (*state)(snd_pcm_t *pcm); int (*delay)(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp); snd_pcm_sframes_t (*rewind)(snd_pcm_t *pcm, snd_pcm_uframes_t frames); snd_pcm_sframes_t (*writei)(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size); @@ -143,11 +167,11 @@ struct _snd_pcm { void *private; }; -int snd_pcm_hw_open(snd_pcm_t **pcm, char *name, int card, int device, int subdevice, int stream, int mode); -int snd_pcm_plug_open_hw(snd_pcm_t **pcm, char *name, int card, int device, int subdevice, int stream, int mode); -int snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, char *socket, char *sname, int stream, int mode); +int snd_pcm_hw_open(snd_pcm_t **pcm, char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode); +int snd_pcm_plug_open_hw(snd_pcm_t **pcm, char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode); +int snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, char *socket, char *sname, snd_pcm_stream_t stream, int mode); int snd_pcm_file_open(snd_pcm_t **pcmp, char *name, char *fname, int fd, char *fmt, snd_pcm_t *slave, int close_slave); -int snd_pcm_null_open(snd_pcm_t **pcmp, char *name, int stream, int mode); +int snd_pcm_null_open(snd_pcm_t **pcmp, char *name, snd_pcm_stream_t stream, int mode); void snd_pcm_areas_from_buf(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas, void *buf); @@ -340,27 +364,41 @@ int snd_pcm_hw_params_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params); -void _snd_pcm_hw_param_setempty(snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var); -int _snd_pcm_hw_param_refine_interval(snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, - const snd_interval_t *val); -int _snd_pcm_hw_param_mask(snd_pcm_hw_params_t *params, - unsigned int var, const snd_mask_t *mask); +void _snd_pcm_hw_param_set_empty(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var); +int _snd_pcm_hw_param_set_interval(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, + const snd_interval_t *val); +int _snd_pcm_hw_param_set_mask(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, const snd_mask_t *mask); int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params, - unsigned int var); + snd_pcm_hw_param_t var); int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params, - unsigned int var); + snd_pcm_hw_param_t var); int _snd_pcm_hw_param_set(snd_pcm_hw_params_t *params, - unsigned int var, unsigned int val, int dir); -int _snd_pcm_hw_param_min(snd_pcm_hw_params_t *params, - unsigned int var, unsigned int val, int dir); -int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params, - unsigned int var, unsigned int val, int dir); -int _snd_pcm_hw_param_minmax(snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, - unsigned int min, int mindir, - unsigned int max, int maxdir); + snd_pcm_hw_param_t var, unsigned int val, int dir); +static inline int _snd_pcm_hw_params_set_format(snd_pcm_hw_params_t *params, + snd_pcm_format_t val) +{ + return _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_FORMAT, + (unsigned long) val, 0); +} + +static inline int _snd_pcm_hw_params_set_subformat(snd_pcm_hw_params_t *params, + snd_pcm_subformat_t val) +{ + return _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_FORMAT, + (unsigned long) val, 0); +} + +int _snd_pcm_hw_param_set_min(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, unsigned int val, int dir); +int _snd_pcm_hw_param_set_max(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, unsigned int val, int dir); +int _snd_pcm_hw_param_set_minmax(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, + unsigned int min, int mindir, + unsigned int max, int maxdir); int _snd_pcm_hw_param_refine(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, const snd_pcm_hw_params_t *src); @@ -377,11 +415,57 @@ int snd_pcm_hw_param_always_eq(const snd_pcm_hw_params_t *params, int snd_pcm_hw_param_never_eq(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, const snd_pcm_hw_params_t *params1); -const snd_mask_t *snd_pcm_hw_param_value_mask(const snd_pcm_hw_params_t *params, +const snd_mask_t *snd_pcm_hw_param_get_mask(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var); -const snd_interval_t *snd_pcm_hw_param_value_interval(const snd_pcm_hw_params_t *params, +const snd_interval_t *snd_pcm_hw_param_get_interval(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var); +int snd_pcm_hw_param_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var); +int snd_pcm_hw_param_set_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_set_mode_t mode, + snd_pcm_hw_param_t var); +unsigned int snd_pcm_hw_param_set_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, int *dir); +unsigned int snd_pcm_hw_param_set_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, int *dir); +unsigned int snd_pcm_hw_param_set_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, unsigned int val, + int *dir); +int snd_pcm_hw_param_set_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_set_mode_t mode, + snd_pcm_hw_param_t var, + unsigned int *val, int *dir); +int snd_pcm_hw_param_set_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_set_mode_t mode, + snd_pcm_hw_param_t var, unsigned int *val, int *dir); +int snd_pcm_hw_param_set_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_set_mode_t mode, + snd_pcm_hw_param_t var, + unsigned int *min, int *mindir, + unsigned int *max, int *maxdir); +int snd_pcm_hw_param_set(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_set_mode_t mode, + snd_pcm_hw_param_t var, unsigned int val, int dir); +int snd_pcm_hw_param_set_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_set_mode_t mode, + snd_pcm_hw_param_t var, const snd_mask_t *mask); +unsigned int snd_pcm_hw_param_get(const snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, int *dir); +unsigned int snd_pcm_hw_param_get_min(const snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, int *dir); +unsigned int snd_pcm_hw_param_get_max(const snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, int *dir); +const char *snd_pcm_hw_param_name(snd_pcm_hw_param_t var); +int snd_pcm_hw_strategy_simple_near(snd_pcm_hw_strategy_t *strategy, int order, + snd_pcm_hw_param_t var, + unsigned int best, + unsigned int mul); +int snd_pcm_hw_strategy_simple_choices(snd_pcm_hw_strategy_t *strategy, int order, + snd_pcm_hw_param_t var, + unsigned int count, + snd_pcm_hw_strategy_simple_choices_list_t *choices); + #define SND_PCM_HW_PARBIT_ACCESS (1 << SND_PCM_HW_PARAM_ACCESS) #define SND_PCM_HW_PARBIT_FORMAT (1 << SND_PCM_HW_PARAM_FORMAT) #define SND_PCM_HW_PARBIT_SUBFORMAT (1 << SND_PCM_HW_PARAM_SUBFORMAT) @@ -399,6 +483,6 @@ const snd_interval_t *snd_pcm_hw_param_value_interval(const snd_pcm_hw_params_t #define SND_PCM_HW_PARBIT_TICK_TIME (1 << SND_PCM_HW_PARAM_TICK_TIME) -#define SND_PCM_ACCBIT_MMAP ((1 << SND_PCM_ACCESS_MMAP_INTERLEAVED) | \ - (1 << SND_PCM_ACCESS_MMAP_NONINTERLEAVED) | \ - (1 << SND_PCM_ACCESS_MMAP_COMPLEX)) +#define SND_PCM_ACCBIT_MMAP ((1 << (unsigned long) SND_PCM_ACCESS_MMAP_INTERLEAVED) | \ + (1 << (unsigned long) SND_PCM_ACCESS_MMAP_NONINTERLEAVED) | \ + (1 << (unsigned long) SND_PCM_ACCESS_MMAP_COMPLEX)) diff --git a/src/pcm/pcm_m4.c b/src/pcm/pcm_m4.c new file mode 100644 index 00000000..6a88587c --- /dev/null +++ b/src/pcm/pcm_m4.c @@ -0,0 +1,1047 @@ +/* + * PCM - Automatically generated functions + * Copyright (c) 2001 by Abramo Bagnara <abramo@alsa-project.org> + * + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include "pcm_local.h" + + +size_t snd_pcm_access_mask_sizeof() +{ + return sizeof(snd_pcm_access_mask_t); +} + +int snd_pcm_access_mask_malloc(snd_pcm_access_mask_t **ptr) +{ + assert(ptr); + *ptr = malloc(sizeof(snd_pcm_access_mask_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_pcm_access_mask_free(snd_pcm_access_mask_t *obj) +{ + free(obj); +} + +void snd_pcm_access_mask_copy(snd_pcm_access_mask_t *dst, const snd_pcm_access_mask_t *src) +{ + assert(dst && src); + *dst = *src; +} + +void snd_pcm_access_mask_none(snd_pcm_access_mask_t *mask) +{ + snd_mask_none((snd_mask_t *) mask); +} + +void snd_pcm_access_mask_any(snd_pcm_access_mask_t *mask) +{ + snd_mask_any((snd_mask_t *) mask); +} + +int snd_pcm_access_mask_test(const snd_pcm_access_mask_t *mask, snd_pcm_access_t val) +{ + return snd_mask_test((snd_mask_t *) mask, (unsigned long) val); +} + +void snd_pcm_access_mask_set(snd_pcm_access_mask_t *mask, snd_pcm_access_t val) +{ + snd_mask_set((snd_mask_t *) mask, (unsigned long) val); +} + +void snd_pcm_access_mask_reset(snd_pcm_access_mask_t *mask, snd_pcm_access_t val) +{ + snd_mask_reset((snd_mask_t *) mask, (unsigned long) val); +} + + +size_t snd_pcm_format_mask_sizeof() +{ + return sizeof(snd_pcm_format_mask_t); +} + +int snd_pcm_format_mask_malloc(snd_pcm_format_mask_t **ptr) +{ + assert(ptr); + *ptr = malloc(sizeof(snd_pcm_format_mask_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_pcm_format_mask_free(snd_pcm_format_mask_t *obj) +{ + free(obj); +} + +void snd_pcm_format_mask_copy(snd_pcm_format_mask_t *dst, const snd_pcm_format_mask_t *src) +{ + assert(dst && src); + *dst = *src; +} + +void snd_pcm_format_mask_none(snd_pcm_format_mask_t *mask) +{ + snd_mask_none((snd_mask_t *) mask); +} + +void snd_pcm_format_mask_any(snd_pcm_format_mask_t *mask) +{ + snd_mask_any((snd_mask_t *) mask); +} + +int snd_pcm_format_mask_test(const snd_pcm_format_mask_t *mask, snd_pcm_format_t val) +{ + return snd_mask_test((snd_mask_t *) mask, (unsigned long) val); +} + +void snd_pcm_format_mask_set(snd_pcm_format_mask_t *mask, snd_pcm_format_t val) +{ + snd_mask_set((snd_mask_t *) mask, (unsigned long) val); +} + +void snd_pcm_format_mask_reset(snd_pcm_format_mask_t *mask, snd_pcm_format_t val) +{ + snd_mask_reset((snd_mask_t *) mask, (unsigned long) val); +} + + +size_t snd_pcm_subformat_mask_sizeof() +{ + return sizeof(snd_pcm_subformat_mask_t); +} + +int snd_pcm_subformat_mask_malloc(snd_pcm_subformat_mask_t **ptr) +{ + assert(ptr); + *ptr = malloc(sizeof(snd_pcm_subformat_mask_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_pcm_subformat_mask_free(snd_pcm_subformat_mask_t *obj) +{ + free(obj); +} + +void snd_pcm_subformat_mask_copy(snd_pcm_subformat_mask_t *dst, const snd_pcm_subformat_mask_t *src) +{ + assert(dst && src); + *dst = *src; +} + +void snd_pcm_subformat_mask_none(snd_pcm_subformat_mask_t *mask) +{ + snd_mask_none((snd_mask_t *) mask); +} + +void snd_pcm_subformat_mask_any(snd_pcm_subformat_mask_t *mask) +{ + snd_mask_any((snd_mask_t *) mask); +} + +int snd_pcm_subformat_mask_test(const snd_pcm_subformat_mask_t *mask, snd_pcm_subformat_t val) +{ + return snd_mask_test((snd_mask_t *) mask, (unsigned long) val); +} + +void snd_pcm_subformat_mask_set(snd_pcm_subformat_mask_t *mask, snd_pcm_subformat_t val) +{ + snd_mask_set((snd_mask_t *) mask, (unsigned long) val); +} + +void snd_pcm_subformat_mask_reset(snd_pcm_subformat_mask_t *mask, snd_pcm_subformat_t val) +{ + snd_mask_reset((snd_mask_t *) mask, (unsigned long) val); +} + + +size_t snd_pcm_hw_params_sizeof() +{ + return sizeof(snd_pcm_hw_params_t); +} + +int snd_pcm_hw_params_malloc(snd_pcm_hw_params_t **ptr) +{ + assert(ptr); + *ptr = malloc(sizeof(snd_pcm_hw_params_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_pcm_hw_params_free(snd_pcm_hw_params_t *obj) +{ + free(obj); +} + +void snd_pcm_hw_params_copy(snd_pcm_hw_params_t *dst, const snd_pcm_hw_params_t *src) +{ + assert(dst && src); + *dst = *src; +} + +snd_pcm_access_t snd_pcm_hw_params_get_access(const snd_pcm_hw_params_t *params) +{ + return snd_int_to_enum(snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_ACCESS, NULL)); +} + +int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_access_t val) +{ + return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_ACCESS, snd_enum_to_int(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)); +} + +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)); +} + +int snd_pcm_hw_params_set_access_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_access_mask_t *mask) +{ + return snd_pcm_hw_param_set_mask(pcm, params, mode, SND_PCM_HW_PARAM_ACCESS, (snd_mask_t *) mask); +} + + +snd_pcm_format_t snd_pcm_hw_params_get_format(const snd_pcm_hw_params_t *params) +{ + return snd_int_to_enum(snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_FORMAT, NULL)); +} + +int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_format_t val) +{ + return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_FORMAT, snd_enum_to_int(val), 0); +} + +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)); +} + +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)); +} + +int snd_pcm_hw_params_set_format_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_format_mask_t *mask) +{ + return snd_pcm_hw_param_set_mask(pcm, params, mode, SND_PCM_HW_PARAM_FORMAT, (snd_mask_t *) mask); +} + + +snd_pcm_subformat_t snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params) +{ + return snd_int_to_enum(snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_SUBFORMAT, NULL)); +} + +int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_subformat_t val) +{ + return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_SUBFORMAT, snd_enum_to_int(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)); +} + +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)); +} + +int snd_pcm_hw_params_set_subformat_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_subformat_mask_t *mask) +{ + return snd_pcm_hw_param_set_mask(pcm, params, mode, SND_PCM_HW_PARAM_SUBFORMAT, (snd_mask_t *) mask); +} + + +unsigned int snd_pcm_hw_params_get_channels(const snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_CHANNELS, NULL); +} + +unsigned int snd_pcm_hw_params_get_channels_min(const snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_CHANNELS, NULL); +} + +unsigned int snd_pcm_hw_params_get_channels_max(const snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_CHANNELS, NULL); +} + +int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val) +{ + return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_CHANNELS, val, 0); +} + +int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val) +{ + return snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_CHANNELS, val, NULL); +} + +int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val) +{ + return snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_CHANNELS, val, NULL); +} + +int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, unsigned int *max) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_CHANNELS, min, NULL, max, NULL); +} + +unsigned int snd_pcm_hw_params_set_channels_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val) +{ + return snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_CHANNELS, val, NULL); +} + +unsigned int snd_pcm_hw_params_set_channels_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_CHANNELS, NULL); +} + +unsigned int snd_pcm_hw_params_set_channels_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_CHANNELS, NULL); +} + + +unsigned int snd_pcm_hw_params_get_rate(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_RATE, dir); +} + +unsigned int snd_pcm_hw_params_get_rate_min(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_RATE, dir); +} + +unsigned int snd_pcm_hw_params_get_rate_max(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_RATE, dir); +} + +int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_RATE, val, dir); +} + +int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_RATE, val, dir); +} + +int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_RATE, val, dir); +} + +int snd_pcm_hw_params_set_rate_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_RATE, min, mindir, max, maxdir); +} + +unsigned int snd_pcm_hw_params_set_rate_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir) +{ + return snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_RATE, val, dir); +} + +unsigned int snd_pcm_hw_params_set_rate_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_RATE, dir); +} + +unsigned int snd_pcm_hw_params_set_rate_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_RATE, dir); +} + + +unsigned int snd_pcm_hw_params_get_period_time(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_PERIOD_TIME, dir); +} + +unsigned int snd_pcm_hw_params_get_period_time_min(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_PERIOD_TIME, dir); +} + +unsigned int snd_pcm_hw_params_get_period_time_max(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_PERIOD_TIME, dir); +} + +int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); +} + +int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); +} + +int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); +} + +int snd_pcm_hw_params_set_period_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_TIME, min, mindir, max, maxdir); +} + +unsigned int snd_pcm_hw_params_set_period_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir) +{ + return snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); +} + +unsigned int snd_pcm_hw_params_set_period_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_TIME, dir); +} + +unsigned int snd_pcm_hw_params_set_period_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_PERIOD_TIME, dir); +} + + +snd_pcm_uframes_t snd_pcm_hw_params_get_period_size(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_PERIOD_SIZE, dir); +} + +snd_pcm_uframes_t snd_pcm_hw_params_get_period_size_min(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_PERIOD_SIZE, dir); +} + +snd_pcm_uframes_t snd_pcm_hw_params_get_period_size_max(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_PERIOD_SIZE, dir); +} + +int snd_pcm_hw_params_set_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_SIZE, val, dir); +} + +int snd_pcm_hw_params_set_period_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val, int *dir) +{ + unsigned int _val = *val; + int err = snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir); + *val = _val; + return err; +} + +int snd_pcm_hw_params_set_period_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val, int *dir) +{ + unsigned int _val = *val; + int err = snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir); + *val = _val; + return err; +} + +int snd_pcm_hw_params_set_period_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *min, int *mindir, snd_pcm_uframes_t *max, int *maxdir) +{ + unsigned int _min = *min; + unsigned int _max = *max; + int err = snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_SIZE, &_min, mindir, &_max, maxdir); + *min = _min; + *max = _max; + return err; +} + +snd_pcm_uframes_t snd_pcm_hw_params_set_period_size_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int *dir) +{ + return snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_PERIOD_SIZE, val, dir); +} + +snd_pcm_uframes_t snd_pcm_hw_params_set_period_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_SIZE, dir); +} + +snd_pcm_uframes_t snd_pcm_hw_params_set_period_size_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_PERIOD_SIZE, dir); +} + +int snd_pcm_hw_params_set_period_size_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode) +{ + return snd_pcm_hw_param_set_integer(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_SIZE); +} + + +unsigned int snd_pcm_hw_params_get_periods(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_PERIODS, dir); +} + +unsigned int snd_pcm_hw_params_get_periods_min(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_PERIODS, dir); +} + +unsigned int snd_pcm_hw_params_get_periods_max(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_PERIODS, dir); +} + +int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_PERIODS, val, dir); +} + +int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_PERIODS, val, dir); +} + +int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_PERIODS, val, dir); +} + +int snd_pcm_hw_params_set_periods_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_PERIODS, min, mindir, max, maxdir); +} + +unsigned int snd_pcm_hw_params_set_periods_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir) +{ + return snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_PERIODS, val, dir); +} + +unsigned int snd_pcm_hw_params_set_periods_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIODS, dir); +} + +unsigned int snd_pcm_hw_params_set_periods_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_PERIODS, dir); +} + +int snd_pcm_hw_params_set_periods_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode) +{ + return snd_pcm_hw_param_set_integer(pcm, params, mode, SND_PCM_HW_PARAM_PERIODS); +} + + +unsigned int snd_pcm_hw_params_get_buffer_time(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_BUFFER_TIME, dir); +} + +unsigned int snd_pcm_hw_params_get_buffer_time_min(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_BUFFER_TIME, dir); +} + +unsigned int snd_pcm_hw_params_get_buffer_time_max(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_BUFFER_TIME, dir); +} + +int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); +} + +int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); +} + +int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); +} + +int snd_pcm_hw_params_set_buffer_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_TIME, min, mindir, max, maxdir); +} + +unsigned int snd_pcm_hw_params_set_buffer_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir) +{ + return snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); +} + +unsigned int snd_pcm_hw_params_set_buffer_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_BUFFER_TIME, dir); +} + +unsigned int snd_pcm_hw_params_set_buffer_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_BUFFER_TIME, dir); +} + + +snd_pcm_uframes_t snd_pcm_hw_params_get_buffer_size(const snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_BUFFER_SIZE, NULL); +} + +snd_pcm_uframes_t snd_pcm_hw_params_get_buffer_size_min(const snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_BUFFER_SIZE, NULL); +} + +snd_pcm_uframes_t snd_pcm_hw_params_get_buffer_size_max(const snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_BUFFER_SIZE, NULL); +} + +int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t val) +{ + return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_SIZE, val, 0); +} + +int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val) +{ + unsigned int _val = *val; + int err = snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL); + *val = _val; + return err; +} + +int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val) +{ + unsigned int _val = *val; + int err = snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL); + *val = _val; + return err; +} + +int snd_pcm_hw_params_set_buffer_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *min, snd_pcm_uframes_t *max) +{ + unsigned int _min = *min; + unsigned int _max = *max; + int err = snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_SIZE, &_min, NULL, &_max, NULL); + *min = _min; + *max = _max; + return err; +} + +snd_pcm_uframes_t snd_pcm_hw_params_set_buffer_size_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val) +{ + return snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_BUFFER_SIZE, val, NULL); +} + +snd_pcm_uframes_t snd_pcm_hw_params_set_buffer_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_BUFFER_SIZE, NULL); +} + +snd_pcm_uframes_t snd_pcm_hw_params_set_buffer_size_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_BUFFER_SIZE, NULL); +} + + +unsigned int snd_pcm_hw_params_get_tick_time(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_TICK_TIME, dir); +} + +unsigned int snd_pcm_hw_params_get_tick_time_min(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_TICK_TIME, dir); +} + +unsigned int snd_pcm_hw_params_get_tick_time_max(const snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_TICK_TIME, dir); +} + +int snd_pcm_hw_params_set_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_TICK_TIME, val, dir); +} + +int snd_pcm_hw_params_set_tick_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_TICK_TIME, val, dir); +} + +int snd_pcm_hw_params_set_tick_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_TICK_TIME, val, dir); +} + +int snd_pcm_hw_params_set_tick_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_TICK_TIME, min, mindir, max, maxdir); +} + +unsigned int snd_pcm_hw_params_set_tick_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir) +{ + return snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_TICK_TIME, val, dir); +} + +unsigned int snd_pcm_hw_params_set_tick_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_TICK_TIME, dir); +} + +unsigned int snd_pcm_hw_params_set_tick_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir) +{ + return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_TICK_TIME, dir); +} + + +size_t snd_pcm_sw_params_sizeof() +{ + return sizeof(snd_pcm_sw_params_t); +} + +int snd_pcm_sw_params_malloc(snd_pcm_sw_params_t **ptr) +{ + assert(ptr); + *ptr = malloc(sizeof(snd_pcm_sw_params_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_pcm_sw_params_free(snd_pcm_sw_params_t *obj) +{ + free(obj); +} + +void snd_pcm_sw_params_copy(snd_pcm_sw_params_t *dst, const snd_pcm_sw_params_t *src) +{ + assert(dst && src); + *dst = *src; +} + +int snd_pcm_sw_params_set_start_mode(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_start_t val) +{ + assert(pcm && params); + assert(val <= SND_PCM_START_LAST); + params->start_mode = snd_enum_to_int(val); + return 0; +} + +snd_pcm_start_t snd_pcm_sw_params_get_start_mode(const snd_pcm_sw_params_t *params) +{ + assert(params); + return snd_int_to_enum(params->start_mode); +} + + +int snd_pcm_sw_params_set_xrun_mode(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_xrun_t val) +{ + assert(pcm && params); + assert(val <= SND_PCM_XRUN_LAST); + params->xrun_mode = snd_enum_to_int(val); + return 0; +} + +snd_pcm_xrun_t snd_pcm_sw_params_get_xrun_mode(const snd_pcm_sw_params_t *params) +{ + assert(params); + return snd_int_to_enum(params->xrun_mode); +} + + +int snd_pcm_sw_params_set_tstamp_mode(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_tstamp_t val) +{ + assert(pcm && params); + assert(val <= SND_PCM_TSTAMP_LAST); + params->tstamp_mode = snd_enum_to_int(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); +} + + +int snd_pcm_sw_params_set_period_step(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, unsigned int val) +{ + assert(pcm && params); + params->period_step = val; + return 0; +} + +unsigned int snd_pcm_sw_params_get_period_step(const snd_pcm_sw_params_t *params) +{ + assert(params); + return params->period_step; +} + + +int snd_pcm_sw_params_set_sleep_min(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, unsigned int val) +{ + assert(pcm && params); + params->sleep_min = val; + return 0; +} + +unsigned int snd_pcm_sw_params_get_sleep_min(const snd_pcm_sw_params_t *params) +{ + assert(params); + return params->sleep_min; +} + + +int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val) +{ + assert(pcm && params); + params->avail_min = val; + return 0; +} + +snd_pcm_uframes_t snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *params) +{ + assert(params); + return params->avail_min; +} + + +int snd_pcm_sw_params_set_xfer_align(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val) +{ + assert(pcm && params); + assert(val % pcm->min_align == 0); + params->xfer_align = val; + return 0; +} + +snd_pcm_uframes_t snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *params) +{ + assert(params); + return params->xfer_align; +} + + +int snd_pcm_sw_params_set_silence_threshold(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val) +{ + assert(pcm && params); + assert(val + params->silence_size <= pcm->buffer_size); + params->silence_threshold = val; + return 0; +} + +snd_pcm_uframes_t snd_pcm_sw_params_get_silence_threshold(const snd_pcm_sw_params_t *params) +{ + assert(params); + return params->silence_threshold; +} + + +int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val) +{ + assert(pcm && params); + assert(val + params->silence_threshold <= pcm->buffer_size); + params->silence_size = val; + return 0; +} + +snd_pcm_uframes_t snd_pcm_sw_params_get_silence_size(const snd_pcm_sw_params_t *params) +{ + assert(params); + return params->silence_size; +} + + +size_t snd_pcm_info_sizeof() +{ + return sizeof(snd_pcm_info_t); +} + +int snd_pcm_info_malloc(snd_pcm_info_t **ptr) +{ + assert(ptr); + *ptr = malloc(sizeof(snd_pcm_info_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_pcm_info_free(snd_pcm_info_t *obj) +{ + free(obj); +} + +void snd_pcm_info_copy(snd_pcm_info_t *dst, const snd_pcm_info_t *src) +{ + assert(dst && src); + *dst = *src; +} + +unsigned int snd_pcm_info_get_device(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->device; +} + +unsigned int snd_pcm_info_get_subdevice(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->subdevice; +} + +snd_pcm_stream_t snd_pcm_info_get_stream(const snd_pcm_info_t *obj) +{ + assert(obj); + return snd_int_to_enum(obj->stream); +} + +int snd_pcm_info_get_card(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->card; +} + +const char * snd_pcm_info_get_id(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->id; +} + +const char * snd_pcm_info_get_name(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->name; +} + +const char * snd_pcm_info_get_subdevice_name(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->subname; +} + +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); +} + +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); +} + +unsigned int snd_pcm_info_get_subdevices_count(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->subdevices_count; +} + +unsigned int snd_pcm_info_get_subdevices_avail(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->subdevices_avail; +} + +void snd_pcm_info_set_device(snd_pcm_info_t *obj, unsigned int val) +{ + assert(obj); + obj->device = val; +} + +void snd_pcm_info_set_subdevice(snd_pcm_info_t *obj, unsigned int val) +{ + assert(obj); + obj->subdevice = 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); +} + +size_t snd_pcm_status_sizeof() +{ + return sizeof(snd_pcm_status_t); +} + +int snd_pcm_status_malloc(snd_pcm_status_t **ptr) +{ + assert(ptr); + *ptr = malloc(sizeof(snd_pcm_status_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_pcm_status_free(snd_pcm_status_t *obj) +{ + free(obj); +} + +void snd_pcm_status_copy(snd_pcm_status_t *dst, const snd_pcm_status_t *src) +{ + assert(dst && src); + *dst = *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); +} + +void snd_pcm_status_get_trigger_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr) +{ + assert(obj && ptr); + *ptr = obj->trigger_tstamp; +} + +void snd_pcm_status_get_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr) +{ + assert(obj && ptr); + *ptr = obj->tstamp; +} + +snd_pcm_sframes_t snd_pcm_status_get_delay(const snd_pcm_status_t *obj) +{ + assert(obj); + return obj->delay; +} + +snd_pcm_uframes_t snd_pcm_status_get_avail(const snd_pcm_status_t *obj) +{ + assert(obj); + return obj->avail; +} + +snd_pcm_uframes_t snd_pcm_status_get_avail_max(const snd_pcm_status_t *obj) +{ + assert(obj); + return obj->avail_max; +} + diff --git a/src/pcm/pcm_misc.c b/src/pcm/pcm_misc.c index 7a0b6131..be97dc16 100644 --- a/src/pcm/pcm_misc.c +++ b/src/pcm/pcm_misc.c @@ -26,6 +26,9 @@ #define bswap_16 swab16 #define bswap_32 swab32 #define bswap_64 swab64 +#define SND_PCM_FORMAT_NONE (-1) +#define snd_enum_to_int(v) (v) +#define snd_int_to_enum(v) (v) #else #include <stdio.h> #include <stdlib.h> @@ -36,9 +39,9 @@ #include "pcm_local.h" #endif -int snd_pcm_format_signed(int format) +int snd_pcm_format_signed(snd_pcm_format_t format) { - switch (format) { + switch (snd_enum_to_int(format)) { case SNDRV_PCM_FORMAT_S8: case SNDRV_PCM_FORMAT_S16_LE: case SNDRV_PCM_FORMAT_S16_BE: @@ -60,7 +63,7 @@ int snd_pcm_format_signed(int format) } } -int snd_pcm_format_unsigned(int format) +int snd_pcm_format_unsigned(snd_pcm_format_t format) { int val; @@ -70,14 +73,14 @@ int snd_pcm_format_unsigned(int format) return !val; } -int snd_pcm_format_linear(int format) +int snd_pcm_format_linear(snd_pcm_format_t format) { return snd_pcm_format_signed(format) >= 0; } -int snd_pcm_format_little_endian(int format) +int snd_pcm_format_little_endian(snd_pcm_format_t format) { - switch (format) { + switch (snd_enum_to_int(format)) { case SNDRV_PCM_FORMAT_S16_LE: case SNDRV_PCM_FORMAT_U16_LE: case SNDRV_PCM_FORMAT_S24_LE: @@ -103,7 +106,7 @@ int snd_pcm_format_little_endian(int format) } } -int snd_pcm_format_big_endian(int format) +int snd_pcm_format_big_endian(snd_pcm_format_t format) { int val; @@ -113,7 +116,7 @@ int snd_pcm_format_big_endian(int format) return !val; } -int snd_pcm_format_cpu_endian(int format) +int snd_pcm_format_cpu_endian(snd_pcm_format_t format) { #ifdef SNDRV_LITTLE_ENDIAN return snd_pcm_format_little_endian(format); @@ -122,9 +125,9 @@ int snd_pcm_format_cpu_endian(int format) #endif } -int snd_pcm_format_width(int format) +int snd_pcm_format_width(snd_pcm_format_t format) { - switch (format) { + switch (snd_enum_to_int(format)) { case SNDRV_PCM_FORMAT_S8: case SNDRV_PCM_FORMAT_U8: return 8; @@ -161,9 +164,9 @@ int snd_pcm_format_width(int format) } } -int snd_pcm_format_physical_width(int format) +int snd_pcm_format_physical_width(snd_pcm_format_t format) { - switch (format) { + switch (snd_enum_to_int(format)) { case SNDRV_PCM_FORMAT_S8: case SNDRV_PCM_FORMAT_U8: return 8; @@ -198,9 +201,9 @@ int snd_pcm_format_physical_width(int format) } } -ssize_t snd_pcm_format_size(int format, size_t samples) +ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples) { - switch (format) { + switch (snd_enum_to_int(format)) { case SNDRV_PCM_FORMAT_S8: case SNDRV_PCM_FORMAT_U8: return samples; @@ -238,9 +241,9 @@ ssize_t snd_pcm_format_size(int format, size_t samples) } } -u_int64_t snd_pcm_format_silence_64(int format) +u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format) { - switch (format) { + switch (snd_enum_to_int(format)) { case SNDRV_PCM_FORMAT_S8: case SNDRV_PCM_FORMAT_S16_LE: case SNDRV_PCM_FORMAT_S16_BE: @@ -340,27 +343,28 @@ u_int64_t snd_pcm_format_silence_64(int format) case SNDRV_PCM_FORMAT_IMA_ADPCM: /* special case */ case SNDRV_PCM_FORMAT_MPEG: case SNDRV_PCM_FORMAT_GSM: + case SNDRV_PCM_FORMAT_SPECIAL: return 0; } return 0; } -u_int32_t snd_pcm_format_silence_32(int format) +u_int32_t snd_pcm_format_silence_32(snd_pcm_format_t format) { return (u_int32_t)snd_pcm_format_silence_64(format); } -u_int16_t snd_pcm_format_silence_16(int format) +u_int16_t snd_pcm_format_silence_16(snd_pcm_format_t format) { return (u_int16_t)snd_pcm_format_silence_64(format); } -u_int8_t snd_pcm_format_silence(int format) +u_int8_t snd_pcm_format_silence(snd_pcm_format_t format) { return (u_int8_t)snd_pcm_format_silence_64(format); } -int snd_pcm_format_set_silence(int format, void *data, unsigned int samples) +int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int samples) { if (samples == 0) return 0; @@ -422,7 +426,7 @@ static int linear_formats[4*2*2] = { SNDRV_PCM_FORMAT_U32_BE }; -int snd_pcm_build_linear_format(int width, int unsignd, int big_endian) +snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_endian) { switch (width) { case 8: @@ -438,7 +442,7 @@ int snd_pcm_build_linear_format(int width, int unsignd, int big_endian) width = 3; break; default: - return -1; + return SND_PCM_FORMAT_NONE; } - return ((int(*)[2][2])linear_formats)[width][!!unsignd][!!big_endian]; + return snd_int_to_enum(((int(*)[2][2])linear_formats)[width][!!unsignd][!!big_endian]); } diff --git a/src/pcm/pcm_mmap.c b/src/pcm/pcm_mmap.c index af9f551e..89d1074a 100644 --- a/src/pcm/pcm_mmap.c +++ b/src/pcm/pcm_mmap.c @@ -227,7 +227,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 (pcm->access) { + switch (snd_enum_to_int(pcm->access)) { case SND_PCM_ACCESS_MMAP_INTERLEAVED: case SND_PCM_ACCESS_RW_INTERLEAVED: info->first = info->channel * pcm->sample_bits; @@ -432,7 +432,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 (pcm->access) { + switch (snd_enum_to_int(pcm->access)) { case SND_PCM_ACCESS_MMAP_INTERLEAVED: { const snd_pcm_channel_area_t *a = snd_pcm_mmap_areas(pcm); @@ -478,7 +478,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 (pcm->access) { + switch (snd_enum_to_int(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_mulaw.c b/src/pcm/pcm_mulaw.c index 42cae376..618ce831 100644 --- a/src/pcm/pcm_mulaw.c +++ b/src/pcm/pcm_mulaw.c @@ -34,7 +34,7 @@ typedef struct { snd_pcm_plugin_t plug; int getput_idx; mulaw_f func; - int sformat; + snd_pcm_format_t sformat; } snd_pcm_mulaw_t; static inline int val_seg(int val) @@ -232,24 +232,22 @@ static int snd_pcm_mulaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t { snd_pcm_mulaw_t *mulaw = pcm->private; int err; - snd_mask_t *access_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN); - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS, + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS, access_mask); if (err < 0) return err; if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) { - snd_mask_t *format_mask = alloca(snd_mask_sizeof()); + snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof()); snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR); - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_FORMAT, + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT, format_mask); } else { - err = _snd_pcm_hw_param_set(params, - SND_PCM_HW_PARAM_FORMAT, - SND_PCM_FORMAT_MU_LAW, 0); + err = _snd_pcm_hw_params_set_format(params, + SND_PCM_FORMAT_MU_LAW); } - err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT, - SND_PCM_SUBFORMAT_STD, 0); + err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD); if (err < 0) return err; params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID); @@ -259,15 +257,13 @@ static int snd_pcm_mulaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t static int snd_pcm_mulaw_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams) { snd_pcm_mulaw_t *mulaw = pcm->private; - snd_mask_t *saccess_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP); _snd_pcm_hw_params_any(sparams); - _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, - saccess_mask); - _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_FORMAT, - mulaw->sformat, 0); - _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_SUBFORMAT, - SND_PCM_SUBFORMAT_STD, 0); + _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + saccess_mask); + _snd_pcm_hw_params_set_format(sparams, mulaw->sformat); + _snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD); return 0; } @@ -330,7 +326,7 @@ static int snd_pcm_mulaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) { - mulaw->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0), SND_PCM_FORMAT_S16); + mulaw->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_params_get_format(params), SND_PCM_FORMAT_S16); mulaw->func = snd_pcm_mulaw_encode; } else { mulaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, mulaw->sformat); @@ -338,7 +334,7 @@ static int snd_pcm_mulaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) } } else { if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) { - mulaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0)); + mulaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_params_get_format(params)); mulaw->func = snd_pcm_mulaw_decode; } else { mulaw->getput_idx = snd_pcm_linear_get_index(mulaw->sformat, SND_PCM_FORMAT_S16); @@ -446,7 +442,7 @@ snd_pcm_ops_t snd_pcm_mulaw_ops = { munmap: snd_pcm_plugin_munmap, }; -int snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave) +int snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave) { snd_pcm_t *pcm; snd_pcm_mulaw_t *mulaw; @@ -489,13 +485,13 @@ int snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *sla int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; char *sname = NULL; int err; snd_pcm_t *spcm; - int sformat = -1; + snd_pcm_format_t sformat = SND_PCM_FORMAT_NONE; snd_config_foreach(i, conf) { snd_config_t *n = snd_config_entry(i); if (strcmp(n->id, "comment") == 0) @@ -520,7 +516,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, return -EINVAL; } sformat = snd_pcm_format_value(f); - if (sformat < 0) { + if (sformat == SND_PCM_FORMAT_NONE) { ERR("Unknown sformat"); return -EINVAL; } @@ -538,7 +534,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, ERR("sname is not defined"); return -EINVAL; } - if (sformat < 0) { + if (sformat == SND_PCM_FORMAT_NONE) { ERR("sformat is not defined"); return -EINVAL; } diff --git a/src/pcm/pcm_multi.c b/src/pcm/pcm_multi.c index f82b3587..ff3e25f3 100644 --- a/src/pcm/pcm_multi.c +++ b/src/pcm/pcm_multi.c @@ -84,7 +84,7 @@ static int snd_pcm_multi_info(snd_pcm_t *pcm, snd_pcm_info_t *info) if (multi->slaves_count == 1) return snd_pcm_info(multi->slaves[0].pcm, info); memset(info, 0, sizeof(*info)); - info->stream = pcm->stream; + info->stream = snd_enum_to_int(pcm->stream); info->card = -1; strcpy(info->id, "multi"); strcpy(info->name, "multi"); @@ -96,11 +96,11 @@ static int snd_pcm_multi_info(snd_pcm_t *pcm, snd_pcm_info_t *info) static int snd_pcm_multi_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) { snd_pcm_multi_t *multi = pcm->private; - snd_mask_t *access_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof()); int err; - snd_mask_any(access_mask); - snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED); - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS, + snd_pcm_access_mask_any(access_mask); + snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED); + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS, access_mask); if (err < 0) return err; @@ -117,10 +117,10 @@ static int snd_pcm_multi_hw_refine_sprepare(snd_pcm_t *pcm, int slave_idx, { snd_pcm_multi_t *multi = pcm->private; snd_pcm_multi_slave_t *slave = &multi->slaves[slave_idx]; - snd_mask_t *saccess_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP); _snd_pcm_hw_params_any(sparams); - _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, saccess_mask); _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_CHANNELS, slave->channels_count, 0); @@ -142,14 +142,14 @@ static int snd_pcm_multi_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, SND_PCM_HW_PARBIT_BUFFER_SIZE | SND_PCM_HW_PARBIT_BUFFER_TIME | SND_PCM_HW_PARBIT_TICK_TIME); - const snd_mask_t *access_mask = snd_pcm_hw_param_value_mask(params, SND_PCM_HW_PARAM_ACCESS); - if (!snd_mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) && - !snd_mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED) && - !snd_mask_test(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) { - snd_mask_t *saccess_mask = alloca(snd_mask_sizeof()); - snd_mask_any(saccess_mask); - snd_mask_reset(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); - err = _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + const snd_pcm_access_mask_t *access_mask = snd_pcm_hw_param_get_mask(params, SND_PCM_HW_PARAM_ACCESS); + if (!snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) && + !snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED) && + !snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) { + snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof()); + snd_pcm_access_mask_any(saccess_mask); + snd_pcm_access_mask_reset(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); + err = _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, saccess_mask); if (err < 0) return err; @@ -175,16 +175,16 @@ static int snd_pcm_multi_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, SND_PCM_HW_PARBIT_BUFFER_SIZE | SND_PCM_HW_PARBIT_BUFFER_TIME | SND_PCM_HW_PARBIT_TICK_TIME); - snd_mask_t *access_mask = alloca(snd_mask_sizeof()); - const snd_mask_t *saccess_mask = snd_pcm_hw_param_value_mask(sparams, SND_PCM_HW_PARAM_ACCESS); - snd_mask_any(access_mask); - snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED); - if (!snd_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) - snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); - if (!snd_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_COMPLEX) && - !snd_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED)) - snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_COMPLEX); - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS, + snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof()); + const snd_pcm_access_mask_t *saccess_mask = snd_pcm_hw_param_get_mask(sparams, SND_PCM_HW_PARAM_ACCESS); + snd_pcm_access_mask_any(access_mask); + snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED); + if (!snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) + snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); + if (!snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_COMPLEX) && + !snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED)) + snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_COMPLEX); + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS, access_mask); if (err < 0) return err; @@ -320,7 +320,7 @@ static int snd_pcm_multi_status(snd_pcm_t *pcm, snd_pcm_status_t *status) return snd_pcm_status(slave, status); } -static int snd_pcm_multi_state(snd_pcm_t *pcm) +static snd_pcm_state_t snd_pcm_multi_state(snd_pcm_t *pcm) { snd_pcm_multi_t *multi = pcm->private; snd_pcm_t *slave = multi->slaves[0].pcm; @@ -519,7 +519,7 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_pcm_t *pcm; snd_pcm_multi_t *multi; unsigned int i; - int stream; + snd_pcm_stream_t stream; char slave_map[32][32] = { { 0 } }; assert(pcmp); @@ -583,7 +583,7 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, } int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, j; snd_config_t *slave = NULL; diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c index b40420e9..59997b50 100644 --- a/src/pcm/pcm_null.c +++ b/src/pcm/pcm_null.c @@ -27,7 +27,7 @@ typedef struct { snd_timestamp_t trigger_tstamp; - int state; + snd_pcm_state_t state; int shmid; snd_pcm_uframes_t appl_ptr; snd_pcm_uframes_t hw_ptr; @@ -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 = pcm->stream; + info->stream = snd_enum_to_int(pcm->stream); info->card = -1; strcpy(info->id, "null"); strcpy(info->name, "null"); @@ -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; memset(status, 0, sizeof(*status)); - status->state = null->state; + status->state = snd_enum_to_int(null->state); status->trigger_tstamp = null->trigger_tstamp; gettimeofday(&status->tstamp, 0); status->avail = pcm->buffer_size; @@ -82,7 +82,7 @@ static int snd_pcm_null_status(snd_pcm_t *pcm, snd_pcm_status_t * status) return 0; } -static int snd_pcm_null_state(snd_pcm_t *pcm) +static snd_pcm_state_t snd_pcm_null_state(snd_pcm_t *pcm) { snd_pcm_null_t *null = pcm->private; return null->state; @@ -152,7 +152,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; - switch (null->state) { + switch (snd_enum_to_int(null->state)) { case SND_PCM_STATE_PREPARED: case SND_PCM_STATE_RUNNING: snd_pcm_mmap_appl_backward(pcm, frames); @@ -166,7 +166,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; - switch (null->state) { + switch (snd_enum_to_int(null->state)) { case SND_PCM_STATE_PREPARED: case SND_PCM_STATE_RUNNING: snd_pcm_mmap_appl_forward(pcm, size); @@ -319,7 +319,7 @@ snd_pcm_fast_ops_t snd_pcm_null_fast_ops = { mmap_forward: snd_pcm_null_mmap_forward, }; -int snd_pcm_null_open(snd_pcm_t **pcmp, char *name, int stream, int mode) +int snd_pcm_null_open(snd_pcm_t **pcmp, char *name, snd_pcm_stream_t stream, int mode) { snd_pcm_t *pcm; snd_pcm_null_t *null; @@ -372,7 +372,7 @@ int snd_pcm_null_open(snd_pcm_t **pcmp, char *name, int stream, int mode) int _snd_pcm_null_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; snd_config_foreach(i, conf) { diff --git a/src/pcm/pcm_params.c b/src/pcm/pcm_params.c index 49d23de5..a1d8816d 100644 --- a/src/pcm/pcm_params.c +++ b/src/pcm/pcm_params.c @@ -102,21 +102,19 @@ int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) /* Return the value for field PAR if it's fixed in configuration space defined by PARAMS. Return -EINVAL otherwise */ -int snd_pcm_hw_param_value(const snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, int *dir) +unsigned int snd_pcm_hw_param_get(const snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, int *dir) { if (hw_is_mask(var)) { const snd_mask_t *mask = hw_param_mask_c(params, var); - if (!snd_mask_single(mask)) - return -EINVAL; + assert(snd_mask_single(mask)); if (dir) *dir = 0; return snd_mask_value(mask); } if (hw_is_interval(var)) { const snd_interval_t *i = hw_param_interval_c(params, var); - if (!snd_interval_single(i)) - return -EINVAL; + assert(snd_interval_single(i)); if (dir) *dir = i->openmin; return snd_interval_value(i); @@ -126,8 +124,8 @@ int snd_pcm_hw_param_value(const snd_pcm_hw_params_t *params, } /* Return the minimum value for field PAR. */ -unsigned int snd_pcm_hw_param_value_min(const snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, int *dir) +unsigned int snd_pcm_hw_param_get_min(const snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, int *dir) { if (hw_is_mask(var)) { if (dir) @@ -145,7 +143,7 @@ unsigned int snd_pcm_hw_param_value_min(const snd_pcm_hw_params_t *params, } /* Return the maximum value for field PAR. */ -unsigned int snd_pcm_hw_param_value_max(const snd_pcm_hw_params_t *params, +unsigned int snd_pcm_hw_param_get_max(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, int *dir) { if (hw_is_mask(var)) { @@ -166,7 +164,7 @@ unsigned int snd_pcm_hw_param_value_max(const snd_pcm_hw_params_t *params, /* Return the mask for field PAR. This function can be called only for SND_PCM_HW_PARAM_ACCESS, SND_PCM_HW_PARAM_FORMAT, SND_PCM_HW_PARAM_SUBFORMAT. */ -const snd_mask_t *snd_pcm_hw_param_value_mask(const snd_pcm_hw_params_t *params, +const snd_mask_t *snd_pcm_hw_param_get_mask(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var) { assert(hw_is_mask(var)); @@ -176,7 +174,7 @@ const snd_mask_t *snd_pcm_hw_param_value_mask(const snd_pcm_hw_params_t *params, /* Return the interval for field PAR. This function cannot be called for SND_PCM_HW_PARAM_ACCESS, SND_PCM_HW_PARAM_FORMAT, SND_PCM_HW_PARAM_SUBFORMAT. */ -const snd_interval_t *snd_pcm_hw_param_value_interval(const snd_pcm_hw_params_t *params, +const snd_interval_t *snd_pcm_hw_param_get_interval(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var) { assert(hw_is_interval(var)); @@ -185,9 +183,9 @@ const snd_interval_t *snd_pcm_hw_param_value_interval(const snd_pcm_hw_params_t /* --- Refinement functions --- */ -int _snd_pcm_hw_param_refine_interval(snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, - const snd_interval_t *val) +int _snd_pcm_hw_param_set_interval(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, + const snd_interval_t *val) { int changed; assert(hw_is_interval(var)); @@ -199,8 +197,8 @@ int _snd_pcm_hw_param_refine_interval(snd_pcm_hw_params_t *params, return changed; } -void _snd_pcm_hw_param_setempty(snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var) +void _snd_pcm_hw_param_set_empty(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var) { if (hw_is_mask(var)) { snd_mask_none(hw_param_mask(params, var)); @@ -215,8 +213,8 @@ void _snd_pcm_hw_param_setempty(snd_pcm_hw_params_t *params, } } -int _snd_pcm_hw_param_setinteger(snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var) +int _snd_pcm_hw_param_set_integer(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var) { int changed; assert(hw_is_interval(var)); @@ -232,23 +230,44 @@ int _snd_pcm_hw_param_setinteger(snd_pcm_hw_params_t *params, non integer values. Reduce configuration space accordingly. Return -EINVAL if the configuration space is empty */ -int snd_pcm_hw_param_setinteger(snd_pcm_t *pcm, - snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var) +int snd_pcm_hw_param_set_integer(snd_pcm_t *pcm, + snd_pcm_hw_params_t *params, + snd_set_mode_t mode, + snd_pcm_hw_param_t var) { - int changed = _snd_pcm_hw_param_setinteger(params, var); - if (changed < 0) - return changed; + snd_pcm_hw_params_t save; + int err; + switch (snd_enum_to_int(mode)) { + case SND_CHANGE: + break; + case SND_TRY: + save = *params; + break; + case SND_TEST: + save = *params; + params = &save; + break; + default: + assert(0); + return -EINVAL; + } + err = _snd_pcm_hw_param_set_integer(params, var); + if (err < 0) + goto _fail; if (params->rmask) { - int err = snd_pcm_hw_refine(pcm, params); + err = snd_pcm_hw_refine(pcm, params); if (err < 0) - return err; + goto _fail; } return 0; + _fail: + if (mode == SND_TRY) + *params = save; + return err; } -int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var) +int _snd_pcm_hw_param_set_first(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var) { int changed; if (hw_is_mask(var)) @@ -271,22 +290,20 @@ int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params, values > minimum. Reduce configuration space accordingly. Return the minimum. */ -int snd_pcm_hw_param_first(snd_pcm_t *pcm, - snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, int *dir) +unsigned int snd_pcm_hw_param_set_first(snd_pcm_t *pcm, + snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, int *dir) { - int changed = _snd_pcm_hw_param_first(params, var); - if (changed < 0) - return changed; + _snd_pcm_hw_param_set_first(params, var); if (params->rmask) { int err = snd_pcm_hw_refine(pcm, params); assert(err >= 0); } - return snd_pcm_hw_param_value(params, var, dir); + return snd_pcm_hw_param_get(params, var, dir); } -int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var) +int _snd_pcm_hw_param_set_last(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var) { int changed; if (hw_is_mask(var)) @@ -309,22 +326,20 @@ int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params, values < maximum. Reduce configuration space accordingly. Return the maximum. */ -int snd_pcm_hw_param_last(snd_pcm_t *pcm, - snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, int *dir) +unsigned int snd_pcm_hw_param_set_last(snd_pcm_t *pcm, + snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, int *dir) { - int changed = _snd_pcm_hw_param_last(params, var); - if (changed < 0) - return changed; + _snd_pcm_hw_param_set_last(params, var); if (params->rmask) { int err = snd_pcm_hw_refine(pcm, params); assert(err >= 0); } - return snd_pcm_hw_param_value(params, var, dir); + return snd_pcm_hw_param_get(params, var, dir); } -int _snd_pcm_hw_param_min(snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, unsigned int val, int dir) +int _snd_pcm_hw_param_set_min(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, unsigned int val, int dir) { int changed; int open = 0; @@ -357,35 +372,44 @@ int _snd_pcm_hw_param_min(snd_pcm_hw_params_t *params, values < VAL. Reduce configuration space accordingly. Return new minimum or -EINVAL if the configuration space is empty */ -int snd_pcm_hw_param_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, unsigned int val, int *dir) -{ - int changed = _snd_pcm_hw_param_min(params, var, val, dir ? *dir : 0); - if (changed < 0) - return changed; - if (params->rmask) { - int err = snd_pcm_hw_refine(pcm, params); - if (err < 0) - return err; - } - return snd_pcm_hw_param_value_min(params, var, dir); -} - -int snd_pcm_hw_param_min_try(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, - unsigned int val, int *dir) +int snd_pcm_hw_param_set_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_set_mode_t mode, + snd_pcm_hw_param_t var, unsigned int *val, int *dir) { snd_pcm_hw_params_t save; int err; - save = *params; - err = snd_pcm_hw_param_min(pcm, params, var, val, dir); + switch (snd_enum_to_int(mode)) { + case SND_CHANGE: + break; + case SND_TRY: + save = *params; + break; + case SND_TEST: + save = *params; + params = &save; + break; + default: + assert(0); + return -EINVAL; + } + err = _snd_pcm_hw_param_set_min(params, var, *val, dir ? *dir : 0); if (err < 0) + goto _fail; + if ((mode != SND_TEST || hw_is_interval(var)) && params->rmask) { + err = snd_pcm_hw_refine(pcm, params); + if (err < 0) + goto _fail; + } + *val = snd_pcm_hw_param_get_min(params, var, dir); + return 0; + _fail: + if (mode == SND_TRY) *params = save; return err; } -int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, unsigned int val, int dir) +int _snd_pcm_hw_param_set_max(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, unsigned int val, int dir) { int changed; int open = 0; @@ -420,37 +444,46 @@ int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params, values >= VAL + 1. Reduce configuration space accordingly. Return new maximum or -EINVAL if the configuration space is empty */ -int snd_pcm_hw_param_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, unsigned int val, int *dir) -{ - int changed = _snd_pcm_hw_param_max(params, var, val, dir ? *dir : 0); - if (changed < 0) - return changed; - if (params->rmask) { - int err = snd_pcm_hw_refine(pcm, params); - if (err < 0) - return err; - } - return snd_pcm_hw_param_value_max(params, var, dir); -} - -int snd_pcm_hw_param_max_try(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, - unsigned int val, int *dir) +int snd_pcm_hw_param_set_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_set_mode_t mode, + snd_pcm_hw_param_t var, unsigned int *val, int *dir) { snd_pcm_hw_params_t save; int err; - save = *params; - err = snd_pcm_hw_param_max(pcm, params, var, val, dir); + switch (snd_enum_to_int(mode)) { + case SND_CHANGE: + break; + case SND_TRY: + save = *params; + break; + case SND_TEST: + save = *params; + params = &save; + break; + default: + assert(0); + return -EINVAL; + } + err = _snd_pcm_hw_param_set_max(params, var, *val, dir ? *dir : 0); if (err < 0) + goto _fail; + if ((mode != SND_TEST || hw_is_interval(var)) && params->rmask) { + err = snd_pcm_hw_refine(pcm, params); + if (err < 0) + goto _fail; + } + *val = snd_pcm_hw_param_get_max(params, var, dir); + return 0; + _fail: + if (mode == SND_TRY) *params = save; return err; } -int _snd_pcm_hw_param_minmax(snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, - unsigned int min, int mindir, - unsigned int max, int maxdir) +int _snd_pcm_hw_param_set_minmax(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, + unsigned int min, int mindir, + unsigned int max, int maxdir) { int changed, c1, c2; int openmin = 0, openmax = 0; @@ -517,38 +550,43 @@ int _snd_pcm_hw_param_minmax(snd_pcm_hw_params_t *params, values < MIN and all values > MAX. Reduce configuration space accordingly. Return 0 or -EINVAL if the configuration space is empty */ -int snd_pcm_hw_param_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, - unsigned int *min, int *mindir, - unsigned int *max, int *maxdir) -{ - int changed = _snd_pcm_hw_param_minmax(params, var, - *min, mindir ? *mindir : 0, - *max, maxdir ? *maxdir : 0); - if (changed < 0) - return changed; - if (params->rmask) { - int err = snd_pcm_hw_refine(pcm, params); - if (err < 0) - return err; - } - *min = snd_pcm_hw_param_value_min(params, var, mindir); - *max = snd_pcm_hw_param_value_max(params, var, maxdir); - return 0; -} - -int snd_pcm_hw_param_minmax_try(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, +int snd_pcm_hw_param_set_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_set_mode_t mode, snd_pcm_hw_param_t var, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) { snd_pcm_hw_params_t save; int err; - save = *params; - err = snd_pcm_hw_param_minmax(pcm, params, var, - min, mindir, - max, maxdir); + switch (snd_enum_to_int(mode)) { + case SND_CHANGE: + break; + case SND_TRY: + save = *params; + break; + case SND_TEST: + save = *params; + params = &save; + break; + default: + assert(0); + return -EINVAL; + } + err = _snd_pcm_hw_param_set_minmax(params, var, + *min, mindir ? *mindir : 0, + *max, maxdir ? *maxdir : 0); if (err < 0) + goto _fail; + if ((mode != SND_TEST || hw_is_interval(var)) && params->rmask) { + err = snd_pcm_hw_refine(pcm, params); + if (err < 0) + goto _fail; + } + *min = snd_pcm_hw_param_get_min(params, var, mindir); + *max = snd_pcm_hw_param_get_max(params, var, maxdir); + return 0; + _fail: + if (mode == SND_TRY) *params = save; return err; } @@ -604,36 +642,45 @@ int _snd_pcm_hw_param_set(snd_pcm_hw_params_t *params, /* Inside configuration space defined by PARAMS remove from PAR all values != VAL. Reduce configuration space accordingly. - Return VAL or -EINVAL if the configuration space is empty + Return -EINVAL if the configuration space is empty */ int snd_pcm_hw_param_set(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_set_mode_t mode, snd_pcm_hw_param_t var, unsigned int val, int dir) { - int changed = _snd_pcm_hw_param_set(params, var, val, dir); - if (changed < 0) - return changed; - if (params->rmask) { - int err = snd_pcm_hw_refine(pcm, params); - if (err < 0) - return err; - } - return snd_pcm_hw_param_value(params, var, 0); -} - -int snd_pcm_hw_param_set_try(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, unsigned int val, int dir) -{ snd_pcm_hw_params_t save; int err; - save = *params; - err = snd_pcm_hw_param_set(pcm, params, var, val, dir); + switch (snd_enum_to_int(mode)) { + case SND_CHANGE: + break; + case SND_TRY: + save = *params; + break; + case SND_TEST: + save = *params; + params = &save; + break; + default: + assert(0); + return -EINVAL; + } + err = _snd_pcm_hw_param_set(params, var, val, dir); if (err < 0) + goto _fail; + if ((mode != SND_TEST || hw_is_interval(var)) && params->rmask) { + err = snd_pcm_hw_refine(pcm, params); + if (err < 0) + goto _fail; + } + return 0; + _fail: + if (mode == SND_TRY) *params = save; return err; } -int _snd_pcm_hw_param_mask(snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, const snd_mask_t *val) +int _snd_pcm_hw_param_set_mask(snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, const snd_mask_t *val) { int changed; assert(hw_is_mask(var)); @@ -652,28 +699,37 @@ int _snd_pcm_hw_param_mask(snd_pcm_hw_params_t *params, Return 0 on success or -EINVAL if the configuration space is empty */ -int snd_pcm_hw_param_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, const snd_mask_t *val) -{ - int changed = _snd_pcm_hw_param_mask(params, var, val); - if (changed < 0) - return changed; - if (params->rmask) { - int err = snd_pcm_hw_refine(pcm, params); - if (err < 0) - return err; - } - return 0; -} - -int snd_pcm_hw_param_snd_mask_try(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, +int snd_pcm_hw_param_set_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_set_mode_t mode, snd_pcm_hw_param_t var, const snd_mask_t *val) { snd_pcm_hw_params_t save; int err; - save = *params; - err = snd_pcm_hw_param_mask(pcm, params, var, val); + switch (snd_enum_to_int(mode)) { + case SND_CHANGE: + break; + case SND_TRY: + save = *params; + break; + case SND_TEST: + save = *params; + params = &save; + break; + default: + assert(0); + return -EINVAL; + } + err = _snd_pcm_hw_param_set_mask(params, var, val); if (err < 0) + goto _fail; + if (mode != SND_TEST && params->rmask) { + err = snd_pcm_hw_refine(pcm, params); + if (err < 0) + goto _fail; + } + return 0; + _fail: + if (mode == SND_TRY) *params = save; return err; } @@ -684,11 +740,11 @@ int snd_pcm_hw_param_snd_mask_try(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, SND_PCM_HW_PARAM_FORMAT, SND_PCM_HW_PARAM_SUBFORMAT. Return the value found. */ -int snd_pcm_hw_param_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, unsigned int best, int *dir) +unsigned int snd_pcm_hw_param_set_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, unsigned int best, int *dir) { snd_pcm_hw_params_t save; - int v; + int v, err; unsigned int saved_min; int last = 0; int min, max; @@ -709,16 +765,16 @@ int snd_pcm_hw_param_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, } save = *params; saved_min = min; - min = snd_pcm_hw_param_min(pcm, params, var, min, &mindir); - if (min >= 0) { + err = snd_pcm_hw_param_set_min(pcm, params, SND_CHANGE, var, &min, &mindir); + if (err >= 0) { snd_pcm_hw_params_t params1; if (max < 0) goto _end; if ((unsigned int)min == saved_min && mindir == valdir) goto _end; params1 = save; - max = snd_pcm_hw_param_max(pcm, ¶ms1, var, max, &maxdir); - if (max < 0) + err = snd_pcm_hw_param_set_max(pcm, ¶ms1, SND_CHANGE, var, &max, &maxdir); + if (err < 0) goto _end; if (boundary_nearer(max, maxdir, best, valdir, min, mindir)) { *params = params1; @@ -726,15 +782,15 @@ int snd_pcm_hw_param_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, } } else { *params = save; - max = snd_pcm_hw_param_max(pcm, params, var, max, &maxdir); - assert(max >= 0); + err = snd_pcm_hw_param_set_max(pcm, params, SND_CHANGE, var, &max, &maxdir); + assert(err >= 0); last = 1; } _end: if (last) - v = snd_pcm_hw_param_last(pcm, params, var, dir); + v = snd_pcm_hw_param_set_last(pcm, params, var, dir); else - v = snd_pcm_hw_param_first(pcm, params, var, dir); + v = snd_pcm_hw_param_set_first(pcm, params, var, dir); assert(v >= 0); return v; } @@ -747,13 +803,13 @@ int snd_pcm_hw_param_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, SND_PCM_HW_PARAM_FORMAT, SND_PCM_HW_PARAM_SUBFORMAT. Return the value found. */ -int snd_pcm_hw_param_next(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, - unsigned int best, int bestdir, - unsigned int val, int *dir) +int snd_pcm_hw_param_set_next(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, + unsigned int best, int bestdir, + unsigned int val, int *dir) { snd_pcm_hw_params_t save; - int v; + int v, err; int last = 0; int min, max; int mindir, maxdir; @@ -780,13 +836,13 @@ int snd_pcm_hw_param_next(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, maxdir %= 2; save = *params; if (min >= 0 && - (min = snd_pcm_hw_param_min(pcm, params, var, min, &mindir)) >= 0) { + (err = snd_pcm_hw_param_set_min(pcm, params, SND_CHANGE, var, &min, &mindir)) >= 0) { snd_pcm_hw_params_t params1; if (max < 0) goto _end; params1 = save; - max = snd_pcm_hw_param_max(pcm, ¶ms1, var, max, &maxdir); - if (max < 0) + err = snd_pcm_hw_param_set_max(pcm, ¶ms1, SND_CHANGE, var, &max, &maxdir); + if (err < 0) goto _end; if (boundary_nearer(max, maxdir, best, bestdir, min, mindir)) { *params = params1; @@ -796,43 +852,43 @@ int snd_pcm_hw_param_next(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, if (max < 0) return -EINVAL; *params = save; - max = snd_pcm_hw_param_max(pcm, params, var, max, &maxdir); - if (max < 0) + err = snd_pcm_hw_param_set_max(pcm, params, SND_CHANGE, var, &max, &maxdir); + if (err < 0) return max; last = 1; } _end: if (last) - v = snd_pcm_hw_param_last(pcm, params, var, dir); + v = snd_pcm_hw_param_set_last(pcm, params, var, dir); else - v = snd_pcm_hw_param_first(pcm, params, var, dir); + v = snd_pcm_hw_param_set_first(pcm, params, var, dir); assert(v >= 0); return v; } -void snd_pcm_hw_param_near_minmax(snd_pcm_t *pcm, - snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, - unsigned int min, int *mindir, - unsigned int max, int *maxdir) +void snd_pcm_hw_param_set_near_minmax(snd_pcm_t *pcm, + snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, + unsigned int min, int *mindir, + unsigned int max, int *maxdir) { snd_pcm_hw_params_t tmp; int err; if (!boundary_lt(min, *mindir, max, *maxdir)) { - snd_pcm_hw_param_near(pcm, params, var, min, mindir); + snd_pcm_hw_param_set_near(pcm, params, var, min, mindir); return; } tmp = *params; - min = snd_pcm_hw_param_near(pcm, &tmp, var, min, mindir); + min = snd_pcm_hw_param_set_near(pcm, &tmp, var, min, mindir); if (boundary_lt(min, *mindir, max, *maxdir)) { tmp = *params; - max = snd_pcm_hw_param_near(pcm, &tmp, var, max, maxdir); + max = snd_pcm_hw_param_set_near(pcm, &tmp, var, max, maxdir); } else { max = min; *maxdir = *mindir; } - err = snd_pcm_hw_param_minmax(pcm, params, var, &min, mindir, - &max, maxdir); + err = snd_pcm_hw_param_set_minmax(pcm, params, SND_CHANGE, var, &min, mindir, + &max, maxdir); assert(err >= 0); } @@ -843,16 +899,16 @@ void snd_pcm_hw_param_refine_near(snd_pcm_t *pcm, { unsigned int min, max; int mindir, maxdir; - min = snd_pcm_hw_param_value_min(src, var, &mindir); - max = snd_pcm_hw_param_value_max(src, var, &maxdir); - snd_pcm_hw_param_near_minmax(pcm, params, var, + min = snd_pcm_hw_param_get_min(src, var, &mindir); + max = snd_pcm_hw_param_get_max(src, var, &maxdir); + snd_pcm_hw_param_set_near_minmax(pcm, params, var, min, &mindir, max, &maxdir); } /* ---- end of refinement functions ---- */ int snd_pcm_hw_param_empty(const snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var) + snd_pcm_hw_param_t var) { if (hw_is_mask(var)) return snd_mask_empty(hw_param_mask_c(params, var)); @@ -893,8 +949,8 @@ int snd_pcm_hw_param_never_eq(const snd_pcm_hw_params_t *params, /* Return rate numerator/denumerator obtainable for configuration space defined by PARAMS */ -int snd_pcm_hw_params_info_rate(const snd_pcm_hw_params_t *params, - unsigned int *rate_num, unsigned int *rate_den) +int snd_pcm_hw_params_get_rate_numden(const snd_pcm_hw_params_t *params, + unsigned int *rate_num, unsigned int *rate_den) { if (params->rate_den == 0) return -EINVAL; @@ -905,7 +961,7 @@ int snd_pcm_hw_params_info_rate(const snd_pcm_hw_params_t *params, /* Return significative bits in sample for configuration space defined by PARAMS */ -int snd_pcm_hw_params_info_msbits(const snd_pcm_hw_params_t *params) +int snd_pcm_hw_params_get_sbits(const snd_pcm_hw_params_t *params) { if (params->msbits == 0) return -EINVAL; @@ -913,7 +969,7 @@ int snd_pcm_hw_params_info_msbits(const snd_pcm_hw_params_t *params) } /* Return info for configuration space defined by PARAMS */ -int snd_pcm_hw_params_info_flags(const snd_pcm_hw_params_t *params) +int snd_pcm_hw_params_get_flags(const snd_pcm_hw_params_t *params) { if (params->info == ~0U) return -EINVAL; @@ -921,7 +977,7 @@ int snd_pcm_hw_params_info_flags(const snd_pcm_hw_params_t *params) } /* Return fifo size for configuration space defined by PARAMS */ -int snd_pcm_hw_params_info_fifo_size(const snd_pcm_hw_params_t *params) +int snd_pcm_hw_params_get_fifo_size(const snd_pcm_hw_params_t *params) { if (params->fifo_size == 0) return -EINVAL; @@ -941,31 +997,14 @@ int snd_pcm_hw_params_info_fifo_size(const snd_pcm_hw_params_t *params) */ void snd_pcm_hw_params_choose(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) { - int err; - - err = snd_pcm_hw_param_first(pcm, params, SND_PCM_HW_PARAM_ACCESS, 0); - assert(err >= 0); - - err = snd_pcm_hw_param_first(pcm, params, SND_PCM_HW_PARAM_FORMAT, 0); - assert(err >= 0); - - err = snd_pcm_hw_param_first(pcm, params, SND_PCM_HW_PARAM_SUBFORMAT, 0); - assert(err >= 0); - - err = snd_pcm_hw_param_first(pcm, params, SND_PCM_HW_PARAM_CHANNELS, 0); - assert(err >= 0); - - err = snd_pcm_hw_param_first(pcm, params, SND_PCM_HW_PARAM_RATE, 0); - assert(err >= 0); - - err = snd_pcm_hw_param_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_TIME, 0); - assert(err >= 0); - - err = snd_pcm_hw_param_last(pcm, params, SND_PCM_HW_PARAM_BUFFER_SIZE, 0); - assert(err >= 0); - - err = snd_pcm_hw_param_first(pcm, params, SND_PCM_HW_PARAM_TICK_TIME, 0); - assert(err >= 0); + snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_ACCESS, 0); + snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_FORMAT, 0); + snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_SUBFORMAT, 0); + snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_CHANNELS, 0); + snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_RATE, 0); + snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_TIME, 0); + snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_BUFFER_SIZE, 0); + snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_TICK_TIME, 0); } /* Strategies */ @@ -1018,21 +1057,6 @@ typedef struct _snd_pcm_hw_strategy_simple_choices { snd_pcm_hw_strategy_simple_choices_list_t *choices; } snd_pcm_hw_strategy_simple_choices_t; -int snd_pcm_hw_param_test(const snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, unsigned int val) -{ - if (hw_is_mask(var)) { - const snd_mask_t *mask = hw_param_mask_c(params, var); - return snd_mask_test(mask, val); - } - if (hw_is_interval(var)) { - const snd_interval_t *i = hw_param_interval_c(params, var); - return snd_interval_test(i, val); - } - assert(0); - return -EINVAL; -} - unsigned int snd_pcm_hw_param_count(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var) { @@ -1093,11 +1117,6 @@ void _snd_pcm_hw_param_copy(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, void snd_pcm_hw_param_dump(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, snd_output_t *out) { - static const char *(*funcs[])(unsigned int k) = { - [SND_PCM_HW_PARAM_ACCESS] = snd_pcm_access_name, - [SND_PCM_HW_PARAM_FORMAT] = snd_pcm_format_name, - [SND_PCM_HW_PARAM_SUBFORMAT] = snd_pcm_subformat_name, - }; if (hw_is_mask(var)) { const snd_mask_t *mask = hw_param_mask_c(params, var); if (snd_mask_empty(mask)) @@ -1106,13 +1125,23 @@ void snd_pcm_hw_param_dump(const snd_pcm_hw_params_t *params, snd_output_puts(out, " ALL"); else { unsigned int k; - const char *(*f)(unsigned int k); - assert(var < sizeof(funcs) / sizeof(funcs[0])); - f = funcs[var]; - assert(f); for (k = 0; k <= SND_MASK_MAX; ++k) { if (snd_mask_test(mask, k)) { - const char *s = f(k); + const char *s; + switch (var) { + case SND_PCM_HW_PARAM_ACCESS: + s = snd_pcm_access_name(snd_int_to_enum(k)); + break; + case SND_PCM_HW_PARAM_FORMAT: + s = snd_pcm_format_name(snd_int_to_enum(k)); + break; + case SND_PCM_HW_PARAM_SUBFORMAT: + s = snd_pcm_subformat_name(snd_int_to_enum(k)); + break; + default: + assert(0); + s = NULL; + } if (s) { snd_output_putc(out, ' '); snd_output_puts(out, s); @@ -1273,7 +1302,7 @@ unsigned int snd_pcm_hw_strategy_simple_near_min_badness(const snd_pcm_hw_params { const snd_pcm_hw_strategy_simple_near_t *p = par->private; snd_pcm_hw_params_t params1 = *params; - int value = snd_pcm_hw_param_near(pcm, ¶ms1, var, p->best, 0); + int value = snd_pcm_hw_param_set_near(pcm, ¶ms1, var, p->best, 0); int diff; assert(value >= 0); diff = p->best - value; @@ -1291,9 +1320,9 @@ int snd_pcm_hw_strategy_simple_near_next_value(snd_pcm_hw_params_t *params, const snd_pcm_hw_strategy_simple_near_t *p = par->private; if (value < 0) { *dir = 0; - return snd_pcm_hw_param_near(pcm, params, var, p->best, dir); + return snd_pcm_hw_param_set_near(pcm, params, var, p->best, dir); } else - return snd_pcm_hw_param_next(pcm, params, var, p->best, 0, value, dir); + return snd_pcm_hw_param_set_next(pcm, params, var, p->best, 0, value, dir); } void snd_pcm_hw_strategy_simple_choices_free(snd_pcm_hw_strategy_simple_t *par) @@ -1305,13 +1334,13 @@ void snd_pcm_hw_strategy_simple_choices_free(snd_pcm_hw_strategy_simple_t *par) unsigned int snd_pcm_hw_strategy_simple_choices_min_badness(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, - snd_pcm_t *pcm ATTRIBUTE_UNUSED, + snd_pcm_t *pcm, const snd_pcm_hw_strategy_simple_t *par) { const snd_pcm_hw_strategy_simple_choices_t *p = par->private; unsigned int k; for (k = 0; k < p->count; ++k) { - if (snd_pcm_hw_param_test(params, var, p->choices[k].value)) + if (snd_pcm_hw_param_set(pcm, (snd_pcm_hw_params_t *) params, SND_TEST, var, p->choices[k].value, 0)) return p->choices[k].badness; } assert(0); @@ -1336,16 +1365,11 @@ int snd_pcm_hw_strategy_simple_choices_next_value(snd_pcm_hw_params_t *params, } for (; k < p->count; ++k) { unsigned int v = p->choices[k].value; - if (snd_pcm_hw_param_test(params, var, v)) { - snd_pcm_hw_params_t save = *params; - int err = snd_pcm_hw_param_set(pcm, params, var, v, 0); - if (err < 0) { - *params = save; - continue; - } - *dir = 0; - return v; - } + int err = snd_pcm_hw_param_set(pcm, params, SND_TRY, var, v, 0); + if (err < 0) + continue; + *dir = 0; + return v; } return -1; } @@ -1547,18 +1571,18 @@ int snd_pcm_hw_rule_format(snd_pcm_hw_params_t *params, snd_pcm_hw_rule_t *rule) { int changed = 0; - unsigned int k; + 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; ++k) { + for (k = 0; k <= SND_PCM_FORMAT_LAST; snd_enum_incr(k)) { int bits; - if (!snd_mask_test(mask, k)) + if (!snd_pcm_format_mask_test(mask, k)) continue; bits = snd_pcm_format_physical_width(k); if (bits < 0) continue; if (!snd_interval_test(i, bits)) { - snd_mask_reset(mask, k); + snd_pcm_format_mask_reset(mask, k); if (snd_mask_empty(mask)) return -EINVAL; changed = 1; @@ -1572,15 +1596,15 @@ int snd_pcm_hw_rule_sample_bits(snd_pcm_hw_params_t *params, snd_pcm_hw_rule_t *rule) { unsigned int min, max; - unsigned int k; + snd_pcm_format_t k; snd_interval_t *i = hw_param_interval(params, rule->var); snd_mask_t *mask = hw_param_mask(params, rule->deps[0]); int c, changed = 0; min = UINT_MAX; max = 0; - for (k = 0; k <= SND_PCM_FORMAT_LAST; ++k) { + for (k = 0; k <= SND_PCM_FORMAT_LAST; snd_enum_incr(k)) { int bits; - if (!snd_mask_test(mask, k)) + if (!snd_pcm_format_mask_test(mask, k)) continue; bits = snd_pcm_format_physical_width(k); if (bits < 0) @@ -1749,13 +1773,13 @@ static snd_pcm_hw_rule_t refine_rules[] = { static snd_mask_t refine_masks[SND_PCM_HW_PARAM_LAST_MASK - SND_PCM_HW_PARAM_FIRST_MASK + 1] = { [SND_PCM_HW_PARAM_ACCESS - SND_PCM_HW_PARAM_FIRST_MASK] = { - bits: (1 << (SND_PCM_ACCESS_LAST + 1)) - 1, + bits: 0x1f, }, [SND_PCM_HW_PARAM_FORMAT - SND_PCM_HW_PARAM_FIRST_MASK] = { bits: 0x81ffffff, }, [SND_PCM_HW_PARAM_SUBFORMAT - SND_PCM_HW_PARAM_FIRST_MASK] = { - bits: (1 << (SND_PCM_SUBFORMAT_LAST + 1)) - 1, + bits: 0x1, }, }; @@ -2011,9 +2035,9 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) { assert(pcm && params); assert(pcm->setup); - params->start_mode = pcm->start_mode; - params->xrun_mode = pcm->xrun_mode; - params->tstamp_mode = pcm->tstamp_mode; + params->start_mode = snd_enum_to_int(pcm->start_mode); + params->xrun_mode = snd_enum_to_int(pcm->xrun_mode); + params->tstamp_mode = snd_enum_to_int(pcm->tstamp_mode); params->period_step = pcm->period_step; params->sleep_min = pcm->sleep_min; params->avail_min = pcm->avail_min; @@ -2028,9 +2052,9 @@ int snd_pcm_sw_params_default(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) { assert(pcm && params); assert(pcm->setup); - params->start_mode = SND_PCM_START_DATA; - params->xrun_mode = SND_PCM_XRUN_STOP; - params->tstamp_mode = SND_PCM_TSTAMP_NONE; + params->start_mode = snd_enum_to_int(SND_PCM_START_DATA); + params->xrun_mode = snd_enum_to_int(SND_PCM_XRUN_STOP); + params->tstamp_mode = snd_enum_to_int(SND_PCM_TSTAMP_NONE); params->period_step = 1; params->sleep_min = 0; params->avail_min = pcm->period_size; @@ -2041,178 +2065,18 @@ int snd_pcm_sw_params_default(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) return 0; } -int snd_pcm_sw_param_value(snd_pcm_sw_params_t *params, snd_pcm_sw_param_t var) -{ - switch (var) { - case SND_PCM_SW_PARAM_START_MODE: - return params->start_mode; - case SND_PCM_SW_PARAM_XRUN_MODE: - return params->xrun_mode; - case SND_PCM_SW_PARAM_TSTAMP_MODE: - return params->tstamp_mode; - case SND_PCM_SW_PARAM_PERIOD_STEP: - return params->period_step; - case SND_PCM_SW_PARAM_SLEEP_MIN: - return params->sleep_min; - case SND_PCM_SW_PARAM_AVAIL_MIN: - return params->avail_min; - case SND_PCM_SW_PARAM_XFER_ALIGN: - return params->xfer_align; - case SND_PCM_SW_PARAM_SILENCE_THRESHOLD: - return params->silence_threshold; - case SND_PCM_SW_PARAM_SILENCE_SIZE: - return params->silence_size; - default: - assert(0); - return -EINVAL; - } -} - -int snd_pcm_sw_param_set(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, - snd_pcm_sw_param_t var, unsigned int val) -{ - switch (var) { - case SND_PCM_SW_PARAM_START_MODE: - assert(val <= SND_PCM_START_LAST); - params->start_mode = val; - break; - case SND_PCM_SW_PARAM_XRUN_MODE: - assert(val <= SND_PCM_XRUN_LAST); - params->xrun_mode = val; - break; - case SND_PCM_SW_PARAM_TSTAMP_MODE: - assert(val <= SND_PCM_TSTAMP_LAST); - params->tstamp_mode = val; - break; - case SND_PCM_SW_PARAM_PERIOD_STEP: - params->period_step = val; - break; - case SND_PCM_SW_PARAM_SLEEP_MIN: - params->sleep_min = val; - break; - case SND_PCM_SW_PARAM_AVAIL_MIN: - assert(val > 0); - params->avail_min = val; - break; - case SND_PCM_SW_PARAM_XFER_ALIGN: - assert(val > 0 && val % pcm->min_align == 0); - params->xfer_align = val; - break; - case SND_PCM_SW_PARAM_SILENCE_THRESHOLD: - assert(val + params->silence_size <= pcm->buffer_size); - params->silence_threshold = val; - break; - case SND_PCM_SW_PARAM_SILENCE_SIZE: - assert(val + params->silence_threshold <= pcm->buffer_size); - params->silence_size = val; - break; - default: - assert(0); - return -EINVAL; - } - return val; -} - -int snd_pcm_sw_param_near(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, - snd_pcm_sw_param_t var, unsigned int val) -{ - switch (var) { - case SND_PCM_SW_PARAM_START_MODE: - assert(val <= SND_PCM_START_LAST); - params->start_mode = val; - break; - case SND_PCM_SW_PARAM_XRUN_MODE: - assert(val <= SND_PCM_XRUN_LAST); - params->xrun_mode = val; - break; - case SND_PCM_SW_PARAM_TSTAMP_MODE: - assert(val <= SND_PCM_TSTAMP_LAST); - params->tstamp_mode = val; - break; - case SND_PCM_SW_PARAM_AVAIL_MIN: - if (val == 0) - val = pcm->min_align; - params->avail_min = val; - break; - case SND_PCM_SW_PARAM_PERIOD_STEP: - params->period_step = val; - break; - case SND_PCM_SW_PARAM_SLEEP_MIN: - params->sleep_min = val; - break; - case SND_PCM_SW_PARAM_XFER_ALIGN: - { - snd_pcm_uframes_t r = val % pcm->min_align; - if (r >= (pcm->min_align + 1) / 2) - val += pcm->min_align - r; - else - val -= r; - if (val == 0) - val = pcm->min_align; - params->xfer_align = val; - break; - } - case SND_PCM_SW_PARAM_SILENCE_THRESHOLD: - if (val > pcm->buffer_size - params->silence_size) - val = pcm->buffer_size - params->silence_size; - params->silence_threshold = val; - break; - case SND_PCM_SW_PARAM_SILENCE_SIZE: - if (val > pcm->buffer_size - params->silence_threshold) - val = pcm->buffer_size - params->silence_threshold; - params->silence_size = val; - break; - default: - assert(0); - return -EINVAL; - } - return val; -} - -void snd_pcm_sw_param_dump(const snd_pcm_sw_params_t *params, - snd_pcm_sw_param_t var, snd_output_t *out) -{ - switch (var) { - case SND_PCM_SW_PARAM_START_MODE: - snd_output_puts(out, snd_pcm_start_mode_name(params->start_mode)); - break; - case SND_PCM_SW_PARAM_XRUN_MODE: - snd_output_puts(out, snd_pcm_xrun_mode_name(params->xrun_mode)); - break; - case SND_PCM_SW_PARAM_TSTAMP_MODE: - snd_output_puts(out, snd_pcm_tstamp_mode_name(params->tstamp_mode)); - break; - case SND_PCM_SW_PARAM_PERIOD_STEP: - snd_output_printf(out, "%d", params->period_step); - break; - case SND_PCM_SW_PARAM_SLEEP_MIN: - snd_output_printf(out, "%d", params->sleep_min); - break; - case SND_PCM_SW_PARAM_AVAIL_MIN: - snd_output_printf(out, "%ld", (long) params->avail_min); - break; - case SND_PCM_SW_PARAM_XFER_ALIGN: - snd_output_printf(out, "%ld", (long) params->xfer_align); - break; - case SND_PCM_SW_PARAM_SILENCE_THRESHOLD: - snd_output_printf(out, "%ld", (long) params->silence_threshold); - break; - case SND_PCM_SW_PARAM_SILENCE_SIZE: - snd_output_printf(out, "%ld", (long) params->silence_size); - break; - default: - assert(0); - } -} - int snd_pcm_sw_params_dump(snd_pcm_sw_params_t *params, snd_output_t *out) { - unsigned int k; - for (k = 0; k <= SND_PCM_SW_PARAM_LAST; k++) { - snd_output_printf(out, "%s: ", snd_pcm_sw_param_name(k)); - snd_pcm_sw_param_dump(params, k, out); - snd_output_putc(out, '\n'); - } + snd_output_printf(out, "start_mode: %s\n", snd_pcm_start_mode_name(snd_pcm_sw_params_get_start_mode(params))); + snd_output_printf(out, "xrun_mode: %s\n", snd_pcm_xrun_mode_name(snd_pcm_sw_params_get_xrun_mode(params))); + snd_output_printf(out, "tstamp_mode: %s\n", snd_pcm_tstamp_mode_name(snd_pcm_sw_params_get_tstamp_mode(params))); + snd_output_printf(out, "period_step: %u\n", params->period_step); + snd_output_printf(out, "sleep_min: %u\n", params->sleep_min); + snd_output_printf(out, "avail_min: %lu\n", params->avail_min); + snd_output_printf(out, "xfer_align: %lu\n", params->xfer_align); + snd_output_printf(out, "silence_threshold: %lu\n", params->silence_threshold); + snd_output_printf(out, "silence_size: %lu\n", params->silence_size); + snd_output_printf(out, "boundary: %lu\n", params->boundary); return 0; } @@ -2254,17 +2118,17 @@ int snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) return err; pcm->setup = 1; - pcm->access = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_ACCESS, 0); - pcm->format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0); - pcm->subformat = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_SUBFORMAT, 0); - pcm->channels = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_CHANNELS, 0); - pcm->rate = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_RATE, 0); - pcm->period_time = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_PERIOD_TIME, 0); - pcm->period_size = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_PERIOD_SIZE, 0); - pcm->buffer_size = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_BUFFER_SIZE, 0); - pcm->tick_time = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_TICK_TIME, 0); - pcm->sample_bits = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_SAMPLE_BITS, 0); - pcm->frame_bits = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FRAME_BITS, 0); + pcm->access = snd_pcm_hw_params_get_access(params); + pcm->format = snd_pcm_hw_params_get_format(params); + pcm->subformat = snd_pcm_hw_params_get_subformat(params); + pcm->channels = snd_pcm_hw_params_get_channels(params); + pcm->rate = snd_pcm_hw_params_get_rate(params, 0); + pcm->period_time = snd_pcm_hw_params_get_period_time(params, 0); + pcm->period_size = snd_pcm_hw_params_get_period_size(params, 0); + pcm->buffer_size = snd_pcm_hw_params_get_buffer_size(params); + pcm->tick_time = snd_pcm_hw_params_get_tick_time(params, 0); + pcm->sample_bits = snd_pcm_format_physical_width(pcm->format); + pcm->frame_bits = pcm->sample_bits * pcm->channels; fb = pcm->frame_bits; min_align = 1; while (fb % 8) { @@ -2316,9 +2180,9 @@ int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) err = pcm->ops->sw_params(pcm->op_arg, params); if (err < 0) return err; - pcm->start_mode = params->start_mode; - pcm->xrun_mode = params->xrun_mode; - pcm->tstamp_mode = params->tstamp_mode; + pcm->start_mode = snd_pcm_sw_params_get_start_mode(params); + pcm->xrun_mode = snd_pcm_sw_params_get_xrun_mode(params); + pcm->tstamp_mode = snd_pcm_sw_params_get_tstamp_mode(params); pcm->period_step = params->period_step; pcm->sleep_min = params->sleep_min; pcm->avail_min = params->avail_min; @@ -2329,53 +2193,3 @@ int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) return 0; } -size_t snd_pcm_hw_params_sizeof() -{ - return sizeof(snd_pcm_hw_params_t); -} - -int snd_pcm_hw_params_malloc(snd_pcm_hw_params_t **paramsp) -{ - *paramsp = malloc(sizeof(snd_pcm_hw_params_t)); - if (!*paramsp) - return -ENOMEM; - return 0; -} - -void snd_pcm_hw_params_free(snd_pcm_hw_params_t *params) -{ - free(params); -} - - -void snd_pcm_hw_params_copy(snd_pcm_hw_params_t *dst, - const snd_pcm_hw_params_t *src) -{ - *dst = *src; -} - -size_t snd_pcm_sw_params_sizeof() -{ - return sizeof(snd_pcm_sw_params_t); -} - -int snd_pcm_sw_params_malloc(snd_pcm_sw_params_t **paramsp) -{ - *paramsp = malloc(sizeof(snd_pcm_sw_params_t)); - if (!*paramsp) - return -ENOMEM; - return 0; -} - -void snd_pcm_sw_params_free(snd_pcm_sw_params_t *params) -{ - free(params); -} - - -void snd_pcm_sw_params_copy(snd_pcm_sw_params_t *dst, - const snd_pcm_sw_params_t *src) -{ - *dst = *src; -} - diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c index 746e6a4d..acb40a80 100644 --- a/src/pcm/pcm_plug.c +++ b/src/pcm/pcm_plug.c @@ -69,7 +69,7 @@ static int snd_pcm_plug_info(snd_pcm_t *pcm, snd_pcm_info_t *info) return 0; } -static unsigned int linear_preferred_formats[] = { +static snd_pcm_format_t linear_preferred_formats[] = { #ifdef SND_LITTLE_ENDIAN SND_PCM_FORMAT_S16_LE, SND_PCM_FORMAT_U16_LE, @@ -107,33 +107,33 @@ static unsigned int linear_preferred_formats[] = { SND_PCM_FORMAT_U8 }; -static unsigned int nonlinear_preferred_formats[] = { +static snd_pcm_format_t nonlinear_preferred_formats[] = { SND_PCM_FORMAT_MU_LAW, SND_PCM_FORMAT_A_LAW, SND_PCM_FORMAT_IMA_ADPCM, }; -static int snd_pcm_plug_slave_format(int format, const snd_mask_t *format_mask) +static snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format, const snd_pcm_format_mask_t *format_mask) { int w, u, e, wid, w1, dw; snd_mask_t *lin = alloca(snd_mask_sizeof()); - if (snd_mask_test(format_mask, format)) + if (snd_pcm_format_mask_test(format_mask, format)) return format; snd_mask_load(lin, SND_PCM_FMTBIT_LINEAR); - if (!snd_mask_test(lin, format)) { + if (!snd_pcm_format_mask_test(lin, format)) { unsigned int i; - switch (format) { + switch (snd_enum_to_int(format)) { case SND_PCM_FORMAT_MU_LAW: case SND_PCM_FORMAT_A_LAW: case SND_PCM_FORMAT_IMA_ADPCM: for (i = 0; i < sizeof(linear_preferred_formats) / sizeof(linear_preferred_formats[0]); ++i) { - unsigned int f = linear_preferred_formats[i]; - if (snd_mask_test(format_mask, f)) + snd_pcm_format_t f = linear_preferred_formats[i]; + if (snd_pcm_format_mask_test(format_mask, f)) return f; } /* Fall through */ default: - return -EINVAL; + return SND_PCM_FORMAT_NONE; } } @@ -141,11 +141,11 @@ static int snd_pcm_plug_slave_format(int format, const snd_mask_t *format_mask) if (snd_mask_empty(lin)) { unsigned int i; for (i = 0; i < sizeof(nonlinear_preferred_formats) / sizeof(nonlinear_preferred_formats[0]); ++i) { - unsigned int f = nonlinear_preferred_formats[i]; - if (snd_mask_test(format_mask, f)) + snd_pcm_format_t f = nonlinear_preferred_formats[i]; + if (snd_pcm_format_mask_test(format_mask, f)) return f; } - return -EINVAL; + return SND_PCM_FORMAT_NONE; } w = snd_pcm_format_width(format); u = snd_pcm_format_unsigned(format); @@ -157,9 +157,10 @@ static int snd_pcm_plug_slave_format(int format, const snd_mask_t *format_mask) for (end = 0; end < 2; ++end) { int sgn, u1 = u; for (sgn = 0; sgn < 2; ++sgn) { - int f; + snd_pcm_format_t f; f = snd_pcm_build_linear_format(w1, u1, e1); - if (f >= 0 && snd_mask_test(format_mask, f)) + assert(f != SND_PCM_FORMAT_NONE); + if (snd_pcm_format_mask_test(format_mask, f)) return f; u1 = !u1; } @@ -172,13 +173,13 @@ static int snd_pcm_plug_slave_format(int format, const snd_mask_t *format_mask) dw = -8; } } - return -EINVAL; + return SND_PCM_FORMAT_NONE; } #define SND_PCM_FMTBIT_PLUG (SND_PCM_FMTBIT_LINEAR | \ - (1 << SND_PCM_FORMAT_MU_LAW) | \ - (1 << SND_PCM_FORMAT_A_LAW) | \ - (1 << SND_PCM_FORMAT_IMA_ADPCM)) + (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))) static void snd_pcm_plug_clear(snd_pcm_t *pcm) @@ -286,8 +287,9 @@ static int snd_pcm_plug_change_channels(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm static int snd_pcm_plug_change_format(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_plug_params_t *clt, snd_pcm_plug_params_t *slv) { snd_pcm_plug_t *plug = pcm->private; - int err, cfmt; - int (*f)(snd_pcm_t **pcm, char *name, int sformat, snd_pcm_t *slave, int close_slave); + int err; + snd_pcm_format_t cfmt; + int (*f)(snd_pcm_t **pcm, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave); if (snd_pcm_format_linear(slv->format)) { /* Conversion is done in another plugin */ if (clt->format == slv->format || @@ -295,7 +297,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 (clt->format) { + switch (snd_enum_to_int(clt->format)) { case SND_PCM_FORMAT_MU_LAW: f = snd_pcm_mulaw_open; break; @@ -316,7 +318,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 (slv->format) { + switch (snd_enum_to_int(slv->format)) { case SND_PCM_FORMAT_MU_LAW: f = snd_pcm_mulaw_open; break; @@ -412,54 +414,54 @@ static int snd_pcm_plug_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p snd_pcm_t *slave = plug->req_slave; unsigned int links = (SND_PCM_HW_PARBIT_PERIOD_TIME | SND_PCM_HW_PARBIT_TICK_TIME); - const snd_mask_t *format_mask, *sformat_mask; + const snd_pcm_format_mask_t *format_mask, *sformat_mask; snd_mask_t *sfmt_mask = alloca(snd_mask_sizeof()); int err; - unsigned int format; + snd_pcm_format_t format; snd_interval_t t, buffer_size; const snd_interval_t *srate, *crate; snd_pcm_hw_param_refine_near(slave, sparams, SND_PCM_HW_PARAM_RATE, params); snd_pcm_hw_param_refine_near(slave, sparams, SND_PCM_HW_PARAM_CHANNELS, params); - format_mask = snd_pcm_hw_param_value_mask(params, + format_mask = snd_pcm_hw_param_get_mask(params, SND_PCM_HW_PARAM_FORMAT); - sformat_mask = snd_pcm_hw_param_value_mask(sparams, + 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; format++) { - int f; - if (!snd_mask_test(format_mask, format)) + for (format = 0; format <= SND_PCM_FORMAT_LAST; snd_enum_incr(format)) { + snd_pcm_format_t f; + if (!snd_pcm_format_mask_test(format_mask, format)) continue; - if (snd_mask_test(sformat_mask, format)) + if (snd_pcm_format_mask_test(sformat_mask, format)) f = format; else { f = snd_pcm_plug_slave_format(format, sformat_mask); - if (f < 0) + if (f == SND_PCM_FORMAT_NONE) continue; } - snd_mask_set(sfmt_mask, f); + snd_pcm_format_mask_set(sfmt_mask, f); } - err = snd_pcm_hw_param_mask(slave, sparams, - SND_PCM_HW_PARAM_FORMAT, sfmt_mask); + err = snd_pcm_hw_param_set_mask(slave, sparams, SND_CHANGE, + SND_PCM_HW_PARAM_FORMAT, sfmt_mask); assert(err >= 0); if (snd_pcm_hw_param_never_eq(params, SND_PCM_HW_PARAM_FORMAT, sparams) || snd_pcm_hw_param_never_eq(params, SND_PCM_HW_PARAM_CHANNELS, sparams) || snd_pcm_hw_param_never_eq(params, SND_PCM_HW_PARAM_RATE, sparams) || snd_pcm_hw_param_never_eq(params, SND_PCM_HW_PARAM_ACCESS, sparams)) { - snd_mask_t *access_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(access_mask, SND_PCM_ACCBIT_MMAP); - _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, access_mask); } - snd_interval_copy(&buffer_size, snd_pcm_hw_param_value_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE)); + snd_interval_copy(&buffer_size, snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE)); snd_interval_unfloor(&buffer_size); - crate = snd_pcm_hw_param_value_interval(params, SND_PCM_HW_PARAM_RATE); - srate = snd_pcm_hw_param_value_interval(sparams, SND_PCM_HW_PARAM_RATE); + crate = snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_RATE); + srate = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_RATE); snd_interval_muldiv(&buffer_size, srate, crate, &t); - err = _snd_pcm_hw_param_refine_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE, &t); + err = _snd_pcm_hw_param_set_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE, &t); if (err < 0) return err; err = _snd_pcm_hw_params_refine(sparams, links, params); @@ -474,54 +476,54 @@ static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, { unsigned int links = (SND_PCM_HW_PARBIT_PERIOD_TIME | SND_PCM_HW_PARBIT_TICK_TIME); - const snd_mask_t *format_mask, *sformat_mask; + const snd_pcm_format_mask_t *format_mask, *sformat_mask; snd_mask_t *fmt_mask = alloca(snd_mask_sizeof()); int err; - unsigned int format; + snd_pcm_format_t format; snd_interval_t t; const snd_interval_t *sbuffer_size; const snd_interval_t *srate, *crate; unsigned int rate_min, srate_min; int rate_mindir, srate_mindir; - format_mask = snd_pcm_hw_param_value_mask(params, + format_mask = snd_pcm_hw_param_get_mask(params, SND_PCM_HW_PARAM_FORMAT); - sformat_mask = snd_pcm_hw_param_value_mask(sparams, + 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; format++) { - int f; - if (!snd_mask_test(format_mask, format)) + for (format = 0; format <= SND_PCM_FORMAT_LAST; snd_enum_incr(format)) { + snd_pcm_format_t f; + if (!snd_pcm_format_mask_test(format_mask, format)) continue; - if (snd_mask_test(sformat_mask, format)) + if (snd_pcm_format_mask_test(sformat_mask, format)) f = format; else { f = snd_pcm_plug_slave_format(format, sformat_mask); - if (f < 0) + if (f == SND_PCM_FORMAT_NONE) continue; } - snd_mask_set(fmt_mask, format); + snd_pcm_format_mask_set(fmt_mask, format); } - err = _snd_pcm_hw_param_mask(params, + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT, fmt_mask); if (err < 0) return err; /* This is a temporary hack, waiting for a better solution */ - rate_min = snd_pcm_hw_param_value_min(params, SND_PCM_HW_PARAM_RATE, &rate_mindir); - srate_min = snd_pcm_hw_param_value_min(sparams, SND_PCM_HW_PARAM_RATE, &srate_mindir); + rate_min = snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_RATE, &rate_mindir); + srate_min = snd_pcm_hw_param_get_min(sparams, SND_PCM_HW_PARAM_RATE, &srate_mindir); if (rate_min == srate_min && srate_mindir > rate_mindir) { - err = _snd_pcm_hw_param_min(params, SND_PCM_HW_PARAM_RATE, srate_min, srate_mindir); + err = _snd_pcm_hw_param_set_min(params, SND_PCM_HW_PARAM_RATE, srate_min, srate_mindir); if (err < 0) return err; } - sbuffer_size = snd_pcm_hw_param_value_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE); - crate = snd_pcm_hw_param_value_interval(params, SND_PCM_HW_PARAM_RATE); - srate = snd_pcm_hw_param_value_interval(sparams, SND_PCM_HW_PARAM_RATE); + sbuffer_size = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE); + crate = snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_RATE); + srate = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_RATE); snd_interval_muldiv(sbuffer_size, crate, srate, &t); snd_interval_floor(&t); - err = _snd_pcm_hw_param_refine_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE, &t); + err = _snd_pcm_hw_param_set_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE, &t); if (err < 0) return err; err = _snd_pcm_hw_params_refine(params, links, sparams); @@ -563,21 +565,21 @@ static int snd_pcm_plug_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) err = snd_pcm_hw_refine_soft(slave, &sparams); assert(err >= 0); - clt_params.access = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_ACCESS, 0); - clt_params.format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0); - clt_params.channels = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_CHANNELS, 0); - clt_params.rate = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_RATE, 0); + clt_params.access = snd_pcm_hw_params_get_access(params); + clt_params.format = snd_pcm_hw_params_get_format(params); + clt_params.channels = snd_pcm_hw_params_get_channels(params); + clt_params.rate = snd_pcm_hw_params_get_rate(params, 0); - slv_params.format = snd_pcm_hw_param_value(&sparams, SND_PCM_HW_PARAM_FORMAT, 0); - slv_params.channels = snd_pcm_hw_param_value(&sparams, SND_PCM_HW_PARAM_CHANNELS, 0); - slv_params.rate = snd_pcm_hw_param_value(&sparams, SND_PCM_HW_PARAM_RATE, 0); + slv_params.format = snd_pcm_hw_params_get_format(&sparams); + slv_params.channels = snd_pcm_hw_params_get_channels(&sparams); + slv_params.rate = snd_pcm_hw_params_get_rate(&sparams, 0); snd_pcm_plug_clear(pcm); if (!(clt_params.format == slv_params.format && clt_params.channels == slv_params.channels && clt_params.rate == slv_params.rate && - snd_pcm_hw_param_test(&sparams, SND_PCM_HW_PARAM_ACCESS, - clt_params.access))) { - slv_params.access = snd_pcm_hw_param_first(slave, &sparams, SND_PCM_HW_PARAM_ACCESS, 0); + snd_pcm_hw_params_set_access(slave, &sparams, SND_TEST, + clt_params.access))) { + slv_params.access = snd_pcm_hw_params_set_access_first(slave, &sparams); err = snd_pcm_plug_insert_plugins(pcm, &clt_params, &slv_params); if (err < 0) return err; @@ -689,7 +691,7 @@ int snd_pcm_plug_open(snd_pcm_t **pcmp, return 0; } -int snd_pcm_plug_open_hw(snd_pcm_t **pcmp, char *name, int card, int device, int subdevice, int stream, int mode) +int snd_pcm_plug_open_hw(snd_pcm_t **pcmp, char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode) { snd_pcm_t *slave; int err; @@ -703,7 +705,7 @@ int snd_pcm_plug_open_hw(snd_pcm_t **pcmp, char *name, int card, int device, int int _snd_pcm_plug_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; char *sname = NULL; diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c index d562cf17..201b0a06 100644 --- a/src/pcm/pcm_plugin.c +++ b/src/pcm/pcm_plugin.c @@ -82,7 +82,7 @@ int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status) return 0; } -int snd_pcm_plugin_state(snd_pcm_t *pcm) +snd_pcm_state_t snd_pcm_plugin_state(snd_pcm_t *pcm) { snd_pcm_plugin_t *plugin = pcm->private; return snd_pcm_state(plugin->slave); diff --git a/src/pcm/pcm_plugin.h b/src/pcm/pcm_plugin.h index 74c7d102..a7068683 100644 --- a/src/pcm/pcm_plugin.h +++ b/src/pcm/pcm_plugin.h @@ -41,7 +41,7 @@ int snd_pcm_plugin_sw_refine(snd_pcm_t *pcm, snd_pcm_sw_params_t *params); int snd_pcm_plugin_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params); int snd_pcm_plugin_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * info); int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status); -int snd_pcm_plugin_state(snd_pcm_t *pcm); +snd_pcm_state_t snd_pcm_plugin_state(snd_pcm_t *pcm); int snd_pcm_plugin_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp); int snd_pcm_plugin_prepare(snd_pcm_t *pcm); int snd_pcm_plugin_start(snd_pcm_t *pcm); @@ -66,13 +66,20 @@ int snd_pcm_plugin_hw_params_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); int snd_pcm_plugin_hw_refine_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); #define SND_PCM_FMTBIT_LINEAR \ - ((1 << SND_PCM_FORMAT_S8 ) | (1 << SND_PCM_FORMAT_U8) | \ - (1 << SND_PCM_FORMAT_S16_LE) | (1 << SND_PCM_FORMAT_S16_BE) | \ - (1 << SND_PCM_FORMAT_U16_LE) | (1 << SND_PCM_FORMAT_U16_BE) | \ - (1 << SND_PCM_FORMAT_S24_LE) | (1 << SND_PCM_FORMAT_S24_BE) | \ - (1 << SND_PCM_FORMAT_U24_LE) | (1 << SND_PCM_FORMAT_U24_BE) | \ - (1 << SND_PCM_FORMAT_S32_LE) | (1 << SND_PCM_FORMAT_S32_BE) | \ - (1 << SND_PCM_FORMAT_U32_LE) | (1 << SND_PCM_FORMAT_U32_BE)) + ((1 << (unsigned long) SND_PCM_FORMAT_S8) | \ + (1 << (unsigned long) SND_PCM_FORMAT_U8) | \ + (1 << (unsigned long) SND_PCM_FORMAT_S16_LE) | \ + (1 << (unsigned long) SND_PCM_FORMAT_S16_BE) | \ + (1 << (unsigned long) SND_PCM_FORMAT_U16_LE) | \ + (1 << (unsigned long) SND_PCM_FORMAT_U16_BE) | \ + (1 << (unsigned long) SND_PCM_FORMAT_S24_LE) | \ + (1 << (unsigned long) SND_PCM_FORMAT_S24_BE) | \ + (1 << (unsigned long) SND_PCM_FORMAT_U24_LE) | \ + (1 << (unsigned long) SND_PCM_FORMAT_U24_BE) | \ + (1 << (unsigned long) SND_PCM_FORMAT_S32_LE) | \ + (1 << (unsigned long) SND_PCM_FORMAT_S32_BE) | \ + (1 << (unsigned long) SND_PCM_FORMAT_U32_LE) | \ + (1 << (unsigned long) SND_PCM_FORMAT_U32_BE)) extern snd_pcm_fast_ops_t snd_pcm_plugin_fast_ops; @@ -92,31 +99,31 @@ typedef int snd_pcm_route_ttable_entry_t; #define FULL ROUTE_PLUGIN_RESOLUTION #endif -int snd_pcm_linear_get_index(int src_format, int dst_format); -int snd_pcm_linear_put_index(int src_format, int dst_format); -int snd_pcm_linear_convert_index(int src_format, int dst_format); +int snd_pcm_linear_get_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format); +int snd_pcm_linear_put_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format); +int snd_pcm_linear_convert_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format); int snd_pcm_copy_open(snd_pcm_t **pcmp, char *name, snd_pcm_t *slave, int close_slave); -int snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave); -int snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave); -int snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave); -int snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, int sformat, snd_pcm_t *slave, int close_slave); +int snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave); +int snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave); +int snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave); +int snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave); int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *ttable, unsigned int tt_csize, unsigned int tt_ssize, unsigned int *tt_cused, unsigned int *tt_sused, int schannels); int snd_pcm_route_open(snd_pcm_t **pcmp, char *name, - int sformat, unsigned int schannels, + snd_pcm_format_t sformat, unsigned int schannels, snd_pcm_route_ttable_entry_t *ttable, unsigned int tt_ssize, unsigned int tt_cused, unsigned int tt_sused, snd_pcm_t *slave, int close_slave); -int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, int sformat, int srate, snd_pcm_t *slave, int close_slave); +int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, int srate, snd_pcm_t *slave, int close_slave); -#define SND_PCM_ACCBIT_PLUGIN ((1 << SND_PCM_ACCESS_MMAP_INTERLEAVED) | \ - (1 << SND_PCM_ACCESS_RW_INTERLEAVED) | \ - (1 << SND_PCM_ACCESS_MMAP_NONINTERLEAVED) | \ - (1 << SND_PCM_ACCESS_RW_NONINTERLEAVED)) +#define SND_PCM_ACCBIT_PLUGIN ((1 << (unsigned long) SND_PCM_ACCESS_MMAP_INTERLEAVED) | \ + (1 << (unsigned long) SND_PCM_ACCESS_RW_INTERLEAVED) | \ + (1 << (unsigned long) SND_PCM_ACCESS_MMAP_NONINTERLEAVED) | \ + (1 << (unsigned long) SND_PCM_ACCESS_RW_NONINTERLEAVED)) void snd_pcm_linear_convert(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset, diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index 0a298dce..c8c31a5a 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -50,7 +50,7 @@ typedef struct { int put_idx; unsigned int pitch; rate_f func; - int sformat; + snd_pcm_format_t sformat; int srate; snd_pcm_rate_state_t *states; } snd_pcm_rate_t; @@ -226,28 +226,27 @@ snd_pcm_uframes_t snd_pcm_rate_shrink(const snd_pcm_channel_area_t *dst_areas, static int snd_pcm_rate_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params) { int err; - snd_mask_t *access_mask = alloca(snd_mask_sizeof()); - snd_mask_t *format_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof()); + snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof()); snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN); snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR); - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS, + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS, access_mask); if (err < 0) return err; - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_FORMAT, + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT, format_mask); if (err < 0) return err; - err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT, - SND_PCM_SUBFORMAT_STD, 0); + err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD); if (err < 0) return err; - err = _snd_pcm_hw_param_min(params, - SND_PCM_HW_PARAM_RATE, RATE_MIN, 0); + err = _snd_pcm_hw_param_set_min(params, + SND_PCM_HW_PARAM_RATE, RATE_MIN, 0); if (err < 0) return err; - err = _snd_pcm_hw_param_max(params, - SND_PCM_HW_PARAM_RATE, RATE_MAX, 0); + err = _snd_pcm_hw_param_set_max(params, + SND_PCM_HW_PARAM_RATE, RATE_MAX, 0); if (err < 0) return err; params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID); @@ -257,19 +256,17 @@ static int snd_pcm_rate_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_ static int snd_pcm_rate_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams) { snd_pcm_rate_t *rate = pcm->private; - snd_mask_t *saccess_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP); _snd_pcm_hw_params_any(sparams); - _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, saccess_mask); - if (rate->sformat >= 0) { - _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_FORMAT, - rate->sformat, 0); - _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_SUBFORMAT, - SND_PCM_SUBFORMAT_STD, 0); + if (rate->sformat != SND_PCM_FORMAT_NONE) { + _snd_pcm_hw_params_set_format(sparams, rate->sformat); + _snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD); } - _snd_pcm_hw_param_minmax(sparams, SND_PCM_HW_PARAM_RATE, - rate->srate, 0, rate->srate + 1, -1); + _snd_pcm_hw_param_set_minmax(sparams, SND_PCM_HW_PARAM_RATE, + rate->srate, 0, rate->srate + 1, -1); return 0; } @@ -283,17 +280,17 @@ static int snd_pcm_rate_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p unsigned int links = (SND_PCM_HW_PARBIT_CHANNELS | SND_PCM_HW_PARBIT_PERIOD_TIME | SND_PCM_HW_PARBIT_TICK_TIME); - if (rate->sformat < 0) + if (rate->sformat == SND_PCM_FORMAT_NONE) links |= (SND_PCM_HW_PARBIT_FORMAT | SND_PCM_HW_PARBIT_SUBFORMAT | SND_PCM_HW_PARBIT_SAMPLE_BITS | SND_PCM_HW_PARBIT_FRAME_BITS); - snd_interval_copy(&buffer_size, snd_pcm_hw_param_value_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE)); + snd_interval_copy(&buffer_size, snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE)); snd_interval_unfloor(&buffer_size); - crate = snd_pcm_hw_param_value_interval(params, SND_PCM_HW_PARAM_RATE); - srate = snd_pcm_hw_param_value_interval(sparams, SND_PCM_HW_PARAM_RATE); + crate = snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_RATE); + srate = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_RATE); snd_interval_muldiv(&buffer_size, srate, crate, &t); - err = _snd_pcm_hw_param_refine_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE, &t); + err = _snd_pcm_hw_param_set_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE, &t); if (err < 0) return err; err = _snd_pcm_hw_params_refine(sparams, links, params); @@ -313,17 +310,17 @@ static int snd_pcm_rate_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p unsigned int links = (SND_PCM_HW_PARBIT_CHANNELS | SND_PCM_HW_PARBIT_PERIOD_TIME | SND_PCM_HW_PARBIT_TICK_TIME); - if (rate->sformat < 0) + if (rate->sformat == SND_PCM_FORMAT_NONE) links |= (SND_PCM_HW_PARBIT_FORMAT | SND_PCM_HW_PARBIT_SUBFORMAT | SND_PCM_HW_PARBIT_SAMPLE_BITS | SND_PCM_HW_PARBIT_FRAME_BITS); - sbuffer_size = snd_pcm_hw_param_value_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE); - crate = snd_pcm_hw_param_value_interval(params, SND_PCM_HW_PARAM_RATE); - srate = snd_pcm_hw_param_value_interval(sparams, SND_PCM_HW_PARAM_RATE); + sbuffer_size = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE); + crate = snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_RATE); + srate = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_RATE); snd_interval_muldiv(sbuffer_size, crate, srate, &t); snd_interval_floor(&t); - err = _snd_pcm_hw_param_refine_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE, &t); + err = _snd_pcm_hw_param_set_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE, &t); if (err < 0) return err; err = _snd_pcm_hw_params_refine(params, links, sparams); @@ -347,7 +344,7 @@ static int snd_pcm_rate_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) { snd_pcm_rate_t *rate = pcm->private; snd_pcm_t *slave = rate->plug.slave; - unsigned int src_format, dst_format; + snd_pcm_format_t src_format, dst_format; unsigned int src_rate, dst_rate; int err = snd_pcm_hw_params_slave(pcm, params, snd_pcm_rate_hw_refine_cchange, @@ -358,15 +355,15 @@ static int snd_pcm_rate_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) return err; if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { - src_format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0); + src_format = snd_pcm_hw_params_get_format(params); dst_format = slave->format; - src_rate = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_RATE, 0); + src_rate = snd_pcm_hw_params_get_rate(params, 0); dst_rate = slave->rate; } else { src_format = slave->format; - dst_format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0); + dst_format = snd_pcm_hw_params_get_format(params); src_rate = slave->rate; - dst_rate = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_RATE, 0); + dst_rate = snd_pcm_hw_params_get_rate(params, 0); } rate->get_idx = snd_pcm_linear_get_index(src_format, SND_PCM_FORMAT_S16); rate->put_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, dst_format); @@ -379,7 +376,7 @@ static int snd_pcm_rate_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) } rate->pitch = (((u_int64_t)dst_rate * DIV) + src_rate / 2) / src_rate; assert(!rate->states); - rate->states = malloc(snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_CHANNELS, 0) * sizeof(*rate->states)); + rate->states = malloc(snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_CHANNELS, 0) * sizeof(*rate->states)); return 0; } @@ -548,7 +545,7 @@ snd_pcm_sframes_t snd_pcm_rate_slave_frames(snd_pcm_t *pcm, snd_pcm_sframes_t fr static void snd_pcm_rate_dump(snd_pcm_t *pcm, snd_output_t *out) { snd_pcm_rate_t *rate = pcm->private; - if (rate->sformat < 0) + if (rate->sformat == SND_PCM_FORMAT_NONE) snd_output_printf(out, "Rate conversion PCM (%d)\n", rate->srate); else @@ -578,12 +575,13 @@ snd_pcm_ops_t snd_pcm_rate_ops = { munmap: snd_pcm_plugin_munmap, }; -int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, int sformat, int srate, snd_pcm_t *slave, int close_slave) +int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, int srate, snd_pcm_t *slave, int close_slave) { snd_pcm_t *pcm; snd_pcm_rate_t *rate; assert(pcmp && slave); - if (sformat >= 0 && snd_pcm_format_linear(sformat) != 1) + if (sformat != SND_PCM_FORMAT_NONE && + snd_pcm_format_linear(sformat) != 1) return -EINVAL; rate = calloc(1, sizeof(snd_pcm_rate_t)); if (!rate) { @@ -624,13 +622,13 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, int sformat, int srate, snd_ int _snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; char *sname = NULL; int err; snd_pcm_t *spcm; - int sformat = -1; + snd_pcm_format_t sformat = SND_PCM_FORMAT_NONE; long srate = -1; snd_config_foreach(i, conf) { snd_config_t *n = snd_config_entry(i); @@ -656,7 +654,7 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, return -EINVAL; } sformat = snd_pcm_format_value(f); - if (sformat < 0) { + if (sformat == SND_PCM_FORMAT_NONE) { ERR("Unknown sformat"); return -EINVAL; } diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index 9d1b20d3..10283706 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -49,7 +49,7 @@ typedef struct { int put_idx; int conv_idx; int src_size; - int dst_sfmt; + snd_pcm_format_t dst_sfmt; unsigned int ndsts; snd_pcm_route_ttable_dst_t *dsts; } snd_pcm_route_params_t; @@ -81,7 +81,7 @@ typedef union { typedef struct { /* This field need to be the first */ snd_pcm_plugin_t plug; - int sformat; + snd_pcm_format_t sformat; int schannels; snd_pcm_route_params_t params; } snd_pcm_route_t; @@ -438,23 +438,22 @@ static int snd_pcm_route_close(snd_pcm_t *pcm) static int snd_pcm_route_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params) { int err; - snd_mask_t *access_mask = alloca(snd_mask_sizeof()); - snd_mask_t *format_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof()); + snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof()); snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN); snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR); - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS, + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS, access_mask); if (err < 0) return err; - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_FORMAT, + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT, format_mask); if (err < 0) return err; - err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT, - SND_PCM_SUBFORMAT_STD, 0); + err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD); if (err < 0) return err; - err = _snd_pcm_hw_param_min(params, SND_PCM_HW_PARAM_CHANNELS, 1, 0); + err = _snd_pcm_hw_param_set_min(params, SND_PCM_HW_PARAM_CHANNELS, 1, 0); if (err < 0) return err; params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID); @@ -464,16 +463,14 @@ static int snd_pcm_route_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd static int snd_pcm_route_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams) { snd_pcm_route_t *route = pcm->private; - snd_mask_t *saccess_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP); _snd_pcm_hw_params_any(sparams); - _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, saccess_mask); - if (route->sformat >= 0) { - _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_FORMAT, - route->sformat, 0); - _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_SUBFORMAT, - SND_PCM_SUBFORMAT_STD, 0); + if (route->sformat != SND_PCM_FORMAT_NONE) { + _snd_pcm_hw_params_set_format(sparams, route->sformat); + _snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD); } if (route->schannels >= 0) { _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_CHANNELS, @@ -494,7 +491,7 @@ static int snd_pcm_route_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t * SND_PCM_HW_PARBIT_BUFFER_SIZE | SND_PCM_HW_PARBIT_BUFFER_TIME | SND_PCM_HW_PARBIT_TICK_TIME); - if (route->sformat < 0) + if (route->sformat == SND_PCM_FORMAT_NONE) links |= (SND_PCM_HW_PARBIT_FORMAT | SND_PCM_HW_PARBIT_SUBFORMAT | SND_PCM_HW_PARBIT_SAMPLE_BITS); @@ -518,7 +515,7 @@ static int snd_pcm_route_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t * SND_PCM_HW_PARBIT_BUFFER_SIZE | SND_PCM_HW_PARBIT_BUFFER_TIME | SND_PCM_HW_PARBIT_TICK_TIME); - if (route->sformat < 0) + if (route->sformat == SND_PCM_FORMAT_NONE) links |= (SND_PCM_HW_PARBIT_FORMAT | SND_PCM_HW_PARBIT_SUBFORMAT | SND_PCM_HW_PARBIT_SAMPLE_BITS); @@ -544,7 +541,7 @@ static int snd_pcm_route_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) { snd_pcm_route_t *route = pcm->private; snd_pcm_t *slave = route->plug.slave; - unsigned int src_format, dst_format; + snd_pcm_format_t src_format, dst_format; int err = snd_pcm_hw_params_slave(pcm, params, snd_pcm_route_hw_refine_cchange, snd_pcm_route_hw_refine_sprepare, @@ -554,11 +551,11 @@ static int snd_pcm_route_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) return err; if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { - src_format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0); + src_format = snd_pcm_hw_params_get_format(params); dst_format = slave->format; } else { src_format = slave->format; - dst_format = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_FORMAT, 0); + dst_format = snd_pcm_hw_params_get_format(params); } route->params.get_idx = snd_pcm_linear_get_index(src_format, SND_PCM_FORMAT_U16); route->params.put_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_U32, dst_format); @@ -648,7 +645,7 @@ static void snd_pcm_route_dump(snd_pcm_t *pcm, snd_output_t *out) { snd_pcm_route_t *route = pcm->private; unsigned int dst; - if (route->sformat < 0) + if (route->sformat == SND_PCM_FORMAT_NONE) snd_output_printf(out, "Route conversion PCM\n"); else snd_output_printf(out, "Route conversion PCM (sformat=%s)\n", @@ -697,7 +694,7 @@ snd_pcm_ops_t snd_pcm_route_ops = { munmap: snd_pcm_plugin_munmap, }; -int route_load_ttable(snd_pcm_route_params_t *params, int stream, +int route_load_ttable(snd_pcm_route_params_t *params, snd_pcm_stream_t stream, unsigned int tt_ssize, snd_pcm_route_ttable_entry_t *ttable, unsigned int tt_cused, unsigned int tt_sused) @@ -770,7 +767,7 @@ int route_load_ttable(snd_pcm_route_params_t *params, int stream, int snd_pcm_route_open(snd_pcm_t **pcmp, char *name, - int sformat, unsigned int schannels, + snd_pcm_format_t sformat, unsigned int schannels, snd_pcm_route_ttable_entry_t *ttable, unsigned int tt_ssize, unsigned int tt_cused, unsigned int tt_sused, @@ -780,7 +777,8 @@ int snd_pcm_route_open(snd_pcm_t **pcmp, char *name, snd_pcm_route_t *route; int err; assert(pcmp && slave && ttable); - if (sformat >= 0 && snd_pcm_format_linear(sformat) != 1) + if (sformat != SND_PCM_FORMAT_NONE && + snd_pcm_format_linear(sformat) != 1) return -EINVAL; route = calloc(1, sizeof(snd_pcm_route_t)); if (!route) { @@ -885,13 +883,13 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; char *sname = NULL; int err; snd_pcm_t *spcm; - int sformat = -1; + snd_pcm_format_t sformat = SND_PCM_FORMAT_NONE; long schannels = -1; snd_config_t *tt = NULL; snd_pcm_route_ttable_entry_t ttable[MAX_CHANNELS*MAX_CHANNELS]; @@ -920,7 +918,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name, return -EINVAL; } sformat = snd_pcm_format_value(f); - if (sformat < 0) { + if (sformat == SND_PCM_FORMAT_NONE) { ERR("Unknown sformat"); return -EINVAL; } diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c index 9d189d4e..e52d9409 100644 --- a/src/pcm/pcm_share.c +++ b/src/pcm/pcm_share.c @@ -67,7 +67,7 @@ typedef struct { struct list_head clients; struct list_head list; snd_pcm_t *pcm; - int format; + snd_pcm_format_t format; int rate; unsigned int channels_count; unsigned int open_count; @@ -100,7 +100,7 @@ typedef struct { pid_t async_pid; int drain_silenced; struct timeval trigger_tstamp; - int state; + snd_pcm_state_t state; snd_pcm_uframes_t hw_ptr; snd_pcm_uframes_t appl_ptr; int ready; @@ -108,7 +108,7 @@ typedef struct { int slave_socket; } snd_pcm_share_t; -static void _snd_pcm_share_stop(snd_pcm_t *pcm, int state); +static void _snd_pcm_share_stop(snd_pcm_t *pcm, snd_pcm_state_t state); static snd_pcm_uframes_t snd_pcm_share_slave_avail(snd_pcm_share_slave_t *slave) { @@ -142,7 +142,7 @@ static snd_pcm_uframes_t _snd_pcm_share_slave_forward(snd_pcm_share_slave_t *sla for (i = slave->clients.next; i != &slave->clients; i = i->next) { snd_pcm_share_t *share = list_entry(i, snd_pcm_share_t, list); snd_pcm_t *pcm = share->pcm; - switch (share->state) { + switch (snd_enum_to_int(share->state)) { case SND_PCM_STATE_RUNNING: break; case SND_PCM_STATE_DRAINING: @@ -199,7 +199,7 @@ static snd_pcm_uframes_t _snd_pcm_share_missing(snd_pcm_t *pcm, int slave_xrun) 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 (share->state) { + switch (snd_enum_to_int(share->state)) { case SND_PCM_STATE_RUNNING: break; case SND_PCM_STATE_DRAINING: @@ -238,7 +238,7 @@ static snd_pcm_uframes_t _snd_pcm_share_missing(snd_pcm_t *pcm, int slave_xrun) missing = safety_missing; } } - switch (share->state) { + switch (snd_enum_to_int(share->state)) { case SND_PCM_STATE_DRAINING: if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { if (hw_avail <= 0) { @@ -268,6 +268,9 @@ static snd_pcm_uframes_t _snd_pcm_share_missing(snd_pcm_t *pcm, int slave_xrun) } running = 1; break; + default: + assert(0); + break; } update_poll: @@ -369,7 +372,7 @@ void *snd_pcm_share_slave_thread(void *data) avail_min += spcm->boundary; // printf("avail_min=%d\n", avail_min); if ((snd_pcm_uframes_t)avail_min != spcm->avail_min) { - snd_pcm_sw_param_near(spcm, &slave->sw_params, SND_PCM_SW_PARAM_AVAIL_MIN, avail_min); + snd_pcm_sw_params_set_avail_min(spcm, &slave->sw_params, avail_min); err = snd_pcm_sw_params(spcm, &slave->sw_params); assert(err >= 0); } @@ -406,7 +409,6 @@ static void _snd_pcm_share_update(snd_pcm_t *pcm) if (missing < INT_MAX) { snd_pcm_uframes_t hw_ptr; snd_pcm_sframes_t avail_min; - int err; hw_ptr = slave->hw_ptr + missing; hw_ptr += spcm->period_size - 1; if (hw_ptr >= spcm->boundary) @@ -418,7 +420,8 @@ static void _snd_pcm_share_update(snd_pcm_t *pcm) if (avail_min < 0) avail_min += spcm->boundary; if ((snd_pcm_uframes_t)avail_min < spcm->avail_min) { - snd_pcm_sw_param_near(spcm, &slave->sw_params, SND_PCM_SW_PARAM_AVAIL_MIN, avail_min); + int err; + snd_pcm_sw_params_set_avail_min(spcm, &slave->sw_params, avail_min); err = snd_pcm_sw_params(spcm, &slave->sw_params); assert(err >= 0); } @@ -454,11 +457,11 @@ static int snd_pcm_share_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t { snd_pcm_share_t *share = pcm->private; snd_pcm_share_slave_t *slave = share->slave; - snd_mask_t *access_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof()); int err; - snd_mask_any(access_mask); - snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED); - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS, + snd_pcm_access_mask_any(access_mask); + snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED); + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS, access_mask); if (err < 0) return err; @@ -466,9 +469,8 @@ static int snd_pcm_share_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t share->channels_count, 0); if (err < 0) return err; - if (slave->format >= 0) { - err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_FORMAT, - slave->format, 0); + if (slave->format != SND_PCM_FORMAT_NONE) { + err = _snd_pcm_hw_params_set_format(params, slave->format); if (err < 0) return err; } @@ -487,10 +489,10 @@ static int snd_pcm_share_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t { snd_pcm_share_t *share = pcm->private; snd_pcm_share_slave_t *slave = share->slave; - snd_mask_t *saccess_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP); _snd_pcm_hw_params_any(sparams); - _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, saccess_mask); _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_CHANNELS, slave->channels_count, 0); @@ -510,14 +512,14 @@ static int snd_pcm_share_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_ SND_PCM_HW_PARBIT_BUFFER_TIME | SND_PCM_HW_PARBIT_PERIODS | SND_PCM_HW_PARBIT_TICK_TIME); - const snd_mask_t *access_mask = snd_pcm_hw_param_value_mask(params, SND_PCM_HW_PARAM_ACCESS); - if (!snd_mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) && - !snd_mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED) && - !snd_mask_test(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) { - snd_mask_t *saccess_mask = alloca(snd_mask_sizeof()); - snd_mask_any(saccess_mask); - snd_mask_reset(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); - err = _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + const snd_pcm_access_mask_t *access_mask = snd_pcm_hw_param_get_mask(params, SND_PCM_HW_PARAM_ACCESS); + if (!snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) && + !snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED) && + !snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) { + snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof()); + snd_pcm_access_mask_any(saccess_mask); + snd_pcm_access_mask_reset(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); + err = _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, saccess_mask); if (err < 0) return err; @@ -541,16 +543,16 @@ static int snd_pcm_share_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_ SND_PCM_HW_PARBIT_BUFFER_TIME | SND_PCM_HW_PARBIT_PERIODS | SND_PCM_HW_PARBIT_TICK_TIME); - snd_mask_t *access_mask = alloca(snd_mask_sizeof()); - const snd_mask_t *saccess_mask = snd_pcm_hw_param_value_mask(sparams, SND_PCM_HW_PARAM_ACCESS); - snd_mask_any(access_mask); - snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED); - if (!snd_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) - snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); - if (!snd_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_COMPLEX) && - !snd_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED)) - snd_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_COMPLEX); - err = _snd_pcm_hw_param_mask(params, SND_PCM_HW_PARAM_ACCESS, + snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof()); + const snd_pcm_access_mask_t *saccess_mask = snd_pcm_hw_param_get_mask(sparams, SND_PCM_HW_PARAM_ACCESS); + snd_pcm_access_mask_any(access_mask); + snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED); + if (!snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) + snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); + if (!snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_COMPLEX) && + !snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED)) + snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_COMPLEX); + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS, access_mask); if (err < 0) return err; @@ -591,12 +593,10 @@ static int snd_pcm_share_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) Pthread_mutex_lock(&slave->mutex); if (slave->setup_count > 1 || (slave->setup_count == 1 && !pcm->setup)) { - err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_FORMAT, - spcm->format, 0); + err = _snd_pcm_hw_params_set_format(params, spcm->format); if (err < 0) goto _err; - err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT, - spcm->subformat, 0); + err = _snd_pcm_hw_params_set_subformat(params, spcm->subformat); if (err < 0) goto _err; err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_RATE, @@ -686,14 +686,14 @@ static int snd_pcm_share_status(snd_pcm_t *pcm, snd_pcm_status_t *status) goto _end; _notrunning: status->delay = sd + d; - status->state = share->state; + status->state = snd_enum_to_int(share->state); status->trigger_tstamp = share->trigger_tstamp; _end: Pthread_mutex_unlock(&slave->mutex); return err; } -static int snd_pcm_share_state(snd_pcm_t *pcm) +static snd_pcm_state_t snd_pcm_share_state(snd_pcm_t *pcm) { snd_pcm_share_t *share = pcm->private; return share->state; @@ -705,7 +705,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 (share->state) { + switch (snd_enum_to_int(share->state)) { case SND_PCM_STATE_XRUN: return -EPIPE; case SND_PCM_STATE_RUNNING: @@ -915,7 +915,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; snd_pcm_share_slave_t *slave = share->slave; snd_pcm_sframes_t n; - switch (share->state) { + switch (snd_enum_to_int(share->state)) { case SND_PCM_STATE_RUNNING: break; case SND_PCM_STATE_PREPARED: @@ -962,7 +962,7 @@ static snd_pcm_sframes_t snd_pcm_share_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t } /* Warning: take the mutex before to call this */ -static void _snd_pcm_share_stop(snd_pcm_t *pcm, int state) +static void _snd_pcm_share_stop(snd_pcm_t *pcm, snd_pcm_state_t state) { snd_pcm_share_t *share = pcm->private; snd_pcm_share_slave_t *slave = share->slave; @@ -1001,7 +1001,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 (share->state) { + switch (snd_enum_to_int(share->state)) { case SND_PCM_STATE_OPEN: err = -EBADFD; goto _end; @@ -1010,9 +1010,11 @@ static int snd_pcm_share_drain(snd_pcm_t *pcm) goto _end; case SND_PCM_STATE_SETUP: goto _end; + default: + break; } if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { - switch (share->state) { + switch (snd_enum_to_int(share->state)) { case SND_PCM_STATE_XRUN: share->state = SND_PCM_STATE_SETUP; goto _end; @@ -1024,9 +1026,12 @@ static int snd_pcm_share_drain(snd_pcm_t *pcm) if (!(pcm->mode & SND_PCM_NONBLOCK)) snd_pcm_wait(pcm, -1); return 0; + default: + assert(0); + break; } } else { - switch (share->state) { + switch (snd_enum_to_int(share->state)) { case SND_PCM_STATE_RUNNING: _snd_pcm_share_stop(pcm, SND_PCM_STATE_DRAINING); _snd_pcm_share_update(pcm); @@ -1038,6 +1043,9 @@ static int snd_pcm_share_drain(snd_pcm_t *pcm) else share->state = SND_PCM_STATE_DRAINING; break; + default: + assert(0); + break; } } _end: @@ -1051,7 +1059,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 (share->state) { + switch (snd_enum_to_int(share->state)) { case SND_PCM_STATE_OPEN: err = -EBADFD; goto _end; @@ -1071,6 +1079,9 @@ static int snd_pcm_share_drop(snd_pcm_t *pcm) case SND_PCM_STATE_XRUN: share->state = SND_PCM_STATE_SETUP; break; + default: + assert(0); + break; } share->appl_ptr = share->hw_ptr = 0; @@ -1172,10 +1183,10 @@ snd_pcm_fast_ops_t snd_pcm_share_fast_ops = { }; int snd_pcm_share_open(snd_pcm_t **pcmp, char *name, char *sname, - int sformat, int srate, + snd_pcm_format_t sformat, int srate, unsigned int schannels_count, unsigned int channels_count, int *channels_map, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_pcm_t *pcm; snd_pcm_share_t *share; @@ -1350,7 +1361,7 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, char *name, char *sname, } int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; char *sname = NULL; @@ -1361,7 +1372,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, unsigned int channels_count = 0; long schannels_count = -1; unsigned int schannel_max = 0; - int sformat = -1; + snd_pcm_format_t sformat = SND_PCM_FORMAT_NONE; long srate = -1; snd_config_foreach(i, conf) { @@ -1388,7 +1399,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, return -EINVAL; } sformat = snd_pcm_format_value(f); - if (sformat < 0) { + if (sformat == SND_PCM_FORMAT_NONE) { ERR("Unknown format %s", f); return -EINVAL; } diff --git a/src/pcm/pcm_shm.c b/src/pcm/pcm_shm.c index 185b47e6..db0ef75f 100644 --- a/src/pcm/pcm_shm.c +++ b/src/pcm/pcm_shm.c @@ -154,10 +154,10 @@ static int snd_pcm_shm_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_p static int snd_pcm_shm_hw_refine_sprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *sparams) { - snd_mask_t *saccess_mask = alloca(snd_mask_sizeof()); + snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof()); snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP); _snd_pcm_hw_params_any(sparams); - _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, saccess_mask); return 0; } @@ -167,10 +167,10 @@ static int snd_pcm_shm_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pc { int err; unsigned int links = ~SND_PCM_HW_PARBIT_ACCESS; - const snd_mask_t *access_mask = snd_pcm_hw_param_value_mask(params, SND_PCM_HW_PARAM_ACCESS); - if (!snd_mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) && - !snd_mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED)) { - err = _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + const snd_pcm_access_mask_t *access_mask = snd_pcm_hw_param_get_mask(params, SND_PCM_HW_PARAM_ACCESS); + if (!snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) && + !snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED)) { + err = _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, access_mask); if (err < 0) return err; @@ -186,11 +186,11 @@ static int snd_pcm_shm_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pc { int err; unsigned int links = ~SND_PCM_HW_PARBIT_ACCESS; - snd_mask_t *access_mask = alloca(snd_mask_sizeof()); - snd_mask_copy(access_mask, snd_pcm_hw_param_value_mask(sparams, SND_PCM_HW_PARAM_ACCESS)); - snd_mask_set(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED); - snd_mask_set(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED); - err = _snd_pcm_hw_param_mask(sparams, SND_PCM_HW_PARAM_ACCESS, + snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof()); + snd_mask_copy(access_mask, snd_pcm_hw_param_get_mask(sparams, SND_PCM_HW_PARAM_ACCESS)); + snd_pcm_access_mask_set(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED); + snd_pcm_access_mask_set(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED); + err = _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS, access_mask); if (err < 0) return err; @@ -340,12 +340,12 @@ static int snd_pcm_shm_status(snd_pcm_t *pcm, snd_pcm_status_t * status) return err; } -static int snd_pcm_shm_state(snd_pcm_t *pcm) +static snd_pcm_state_t snd_pcm_shm_state(snd_pcm_t *pcm) { snd_pcm_shm_t *shm = pcm->private; volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl; ctrl->cmd = SND_PCM_IOCTL_STATE; - return snd_pcm_shm_action(pcm); + return snd_int_to_enum(snd_pcm_shm_action(pcm)); } static int snd_pcm_shm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp) @@ -565,7 +565,7 @@ static int make_inet_socket(const char *host, int port) } #endif -int snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, char *socket, char *sname, int stream, int mode) +int snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, char *socket, char *sname, snd_pcm_stream_t stream, int mode) { snd_pcm_t *pcm; snd_pcm_shm_t *shm = NULL; @@ -592,7 +592,7 @@ int snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, char *socket, char *sname, in memcpy(req->name, sname, snamelen); req->dev_type = SND_DEV_TYPE_PCM; req->transport_type = SND_TRANSPORT_TYPE_SHM; - req->stream = stream; + req->stream = snd_enum_to_int(stream); req->mode = mode; req->namelen = snamelen; err = write(sock, req, reqlen); @@ -719,7 +719,7 @@ int is_local(struct hostent *hent) } int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, - int stream, int mode) + snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; char *server = NULL; diff --git a/src/rawmidi/Makefile.am b/src/rawmidi/Makefile.am index 7b374de4..32b5051e 100644 --- a/src/rawmidi/Makefile.am +++ b/src/rawmidi/Makefile.am @@ -1,6 +1,6 @@ EXTRA_LTLIBRARIES=librawmidi.la -librawmidi_la_SOURCES = rawmidi.c rawmidi_hw.c +librawmidi_la_SOURCES = rawmidi.c rawmidi_m4.c rawmidi_hw.c noinst_HEADERS = rawmidi_local.h all: librawmidi.la diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c index 1b2c54cc..2d5a2c71 100644 --- a/src/rawmidi/rawmidi.c +++ b/src/rawmidi/rawmidi.c @@ -28,6 +28,14 @@ #include <dlfcn.h> #include "rawmidi_local.h" +static inline int snd_rawmidi_stream_ok(snd_rawmidi_t *rmidi, snd_rawmidi_stream_t stream) +{ + assert(rmidi); + assert(stream == SND_RAWMIDI_STREAM_INPUT || + stream == SND_RAWMIDI_STREAM_OUTPUT); + return rmidi->streams & (1 << (snd_enum_to_int(stream))); +} + int snd_rawmidi_close(snd_rawmidi_t *rmidi) { int err; @@ -40,22 +48,19 @@ int snd_rawmidi_close(snd_rawmidi_t *rmidi) return 0; } -int snd_rawmidi_card(snd_rawmidi_t *rmidi) +int snd_rawmidi_poll_descriptor(snd_rawmidi_t *rmidi, + snd_rawmidi_stream_t stream ATTRIBUTE_UNUSED) { - assert(rmidi); - return rmidi->ops->card(rmidi); -} - -int snd_rawmidi_poll_descriptor(snd_rawmidi_t *rmidi) -{ - assert(rmidi); + assert(snd_rawmidi_stream_ok(rmidi, stream)); return rmidi->poll_fd; } -int snd_rawmidi_nonblock(snd_rawmidi_t *rmidi, int nonblock) +int snd_rawmidi_nonblock(snd_rawmidi_t *rmidi, + snd_rawmidi_stream_t stream ATTRIBUTE_UNUSED, + int nonblock) { int err; - assert(rmidi); + assert(snd_rawmidi_stream_ok(rmidi, stream)); assert(!(rmidi->mode & SND_RAWMIDI_APPEND)); if ((err = rmidi->ops->nonblock(rmidi, nonblock)) < 0) return err; @@ -66,64 +71,59 @@ int snd_rawmidi_nonblock(snd_rawmidi_t *rmidi, int nonblock) return 0; } -int snd_rawmidi_info(snd_rawmidi_t *rmidi, snd_rawmidi_info_t * info) +int snd_rawmidi_info(snd_rawmidi_t *rmidi, + snd_rawmidi_stream_t stream, + snd_rawmidi_info_t * info) { - assert(rmidi && info); + assert(snd_rawmidi_stream_ok(rmidi, stream)); + assert(info); + info->stream = snd_enum_to_int(stream); return rmidi->ops->info(rmidi, info); } -int snd_rawmidi_params(snd_rawmidi_t *rmidi, snd_rawmidi_params_t * params) +int snd_rawmidi_params(snd_rawmidi_t *rmidi, + snd_rawmidi_stream_t stream, + snd_rawmidi_params_t * params) { - assert(rmidi && params); + assert(snd_rawmidi_stream_ok(rmidi, stream)); + assert(params); + params->stream = snd_enum_to_int(stream); return rmidi->ops->params(rmidi, params); } -int snd_rawmidi_status(snd_rawmidi_t *rmidi, snd_rawmidi_status_t * status) +int snd_rawmidi_status(snd_rawmidi_t *rmidi, + snd_rawmidi_stream_t stream, + snd_rawmidi_status_t * status) { - assert(rmidi && status); + assert(snd_rawmidi_stream_ok(rmidi, stream)); + assert(status); + status->stream = snd_enum_to_int(stream); return rmidi->ops->status(rmidi, status); } -int snd_rawmidi_drop(snd_rawmidi_t *rmidi, int str) -{ - assert(rmidi); - assert(str >= 0 && str <= 1); - assert(rmidi->streams & (1 << str)); - return rmidi->ops->drop(rmidi, str); -} - -int snd_rawmidi_output_drop(snd_rawmidi_t *rmidi) -{ - return snd_rawmidi_drop(rmidi, SND_RAWMIDI_STREAM_OUTPUT); -} - -int snd_rawmidi_drain(snd_rawmidi_t *rmidi, int str) -{ - assert(rmidi); - assert(str >= 0 && str <= 1); - assert(rmidi->streams & (1 << str)); - return rmidi->ops->drain(rmidi, str); -} - -int snd_rawmidi_output_drain(snd_rawmidi_t *rmidi) +int snd_rawmidi_drop(snd_rawmidi_t *rmidi, snd_rawmidi_stream_t stream) { - return snd_rawmidi_drain(rmidi, SND_RAWMIDI_STREAM_OUTPUT); + assert(snd_rawmidi_stream_ok(rmidi, stream)); + return rmidi->ops->drop(rmidi, stream); } -int snd_rawmidi_input_drain(snd_rawmidi_t *rmidi) +int snd_rawmidi_drain(snd_rawmidi_t *rmidi, snd_rawmidi_stream_t stream) { - return snd_rawmidi_drain(rmidi, SND_RAWMIDI_STREAM_INPUT); + assert(snd_rawmidi_stream_ok(rmidi, stream)); + return rmidi->ops->drain(rmidi, stream); } ssize_t snd_rawmidi_write(snd_rawmidi_t *rmidi, const void *buffer, size_t size) { - assert(rmidi && (buffer || size == 0)); + assert(snd_rawmidi_stream_ok(rmidi, SND_RAWMIDI_STREAM_OUTPUT)); + assert(buffer || size == 0); return rmidi->ops->write(rmidi, buffer, size); } ssize_t snd_rawmidi_read(snd_rawmidi_t *rmidi, void *buffer, size_t size) { - assert(rmidi && (buffer || size == 0)); + assert(snd_rawmidi_stream_ok(rmidi, SND_RAWMIDI_STREAM_INPUT)); + assert(buffer || size == 0); return rmidi->ops->read(rmidi, buffer, size); } diff --git a/src/rawmidi/rawmidi_hw.c b/src/rawmidi/rawmidi_hw.c index d38fd338..561d5cdc 100644 --- a/src/rawmidi/rawmidi_hw.c +++ b/src/rawmidi/rawmidi_hw.c @@ -49,12 +49,6 @@ static int snd_rawmidi_hw_close(snd_rawmidi_t *rmidi) return 0; } -static int snd_rawmidi_hw_card(snd_rawmidi_t *rmidi) -{ - snd_rawmidi_hw_t *hw = rmidi->private; - return hw->card; -} - static int snd_rawmidi_hw_nonblock(snd_rawmidi_t *rmidi, int nonblock) { snd_rawmidi_hw_t *hw = rmidi->private; @@ -105,7 +99,7 @@ static int snd_rawmidi_hw_status(snd_rawmidi_t *rmidi, snd_rawmidi_status_t * st return 0; } -static int snd_rawmidi_hw_drop(snd_rawmidi_t *rmidi, int stream) +static int snd_rawmidi_hw_drop(snd_rawmidi_t *rmidi, snd_rawmidi_stream_t stream) { snd_rawmidi_hw_t *hw = rmidi->private; if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_DROP, &stream) < 0) { @@ -115,7 +109,7 @@ static int snd_rawmidi_hw_drop(snd_rawmidi_t *rmidi, int stream) return 0; } -static int snd_rawmidi_hw_drain(snd_rawmidi_t *rmidi, int stream) +static int snd_rawmidi_hw_drain(snd_rawmidi_t *rmidi, snd_rawmidi_stream_t stream) { snd_rawmidi_hw_t *hw = rmidi->private; if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_DRAIN, &stream) < 0) { @@ -147,7 +141,6 @@ static ssize_t snd_rawmidi_hw_read(snd_rawmidi_t *rmidi, void *buffer, size_t si snd_rawmidi_ops_t snd_rawmidi_hw_ops = { close: snd_rawmidi_hw_close, - card: snd_rawmidi_hw_card, nonblock: snd_rawmidi_hw_nonblock, info: snd_rawmidi_hw_info, params: snd_rawmidi_hw_params, diff --git a/src/rawmidi/rawmidi_local.h b/src/rawmidi/rawmidi_local.h index 3d4d8b8e..fef3a288 100644 --- a/src/rawmidi/rawmidi_local.h +++ b/src/rawmidi/rawmidi_local.h @@ -28,13 +28,12 @@ typedef struct { int (*close)(snd_rawmidi_t *rawmidi); - int (*card)(snd_rawmidi_t *rawmidi); int (*nonblock)(snd_rawmidi_t *rawmidi, int nonblock); int (*info)(snd_rawmidi_t *rawmidi, snd_rawmidi_info_t *info); int (*params)(snd_rawmidi_t *rawmidi, snd_rawmidi_params_t *params); int (*status)(snd_rawmidi_t *rawmidi, snd_rawmidi_status_t *status); - int (*drop)(snd_rawmidi_t *rawmidi, int stream); - int (*drain)(snd_rawmidi_t *rawmidi, int stream); + int (*drop)(snd_rawmidi_t *rawmidi, snd_rawmidi_stream_t stream); + int (*drain)(snd_rawmidi_t *rawmidi, snd_rawmidi_stream_t stream); ssize_t (*write)(snd_rawmidi_t *rawmidi, const void *buffer, size_t size); ssize_t (*read)(snd_rawmidi_t *rawmidi, void *buffer, size_t size); } snd_rawmidi_ops_t; diff --git a/src/rawmidi/rawmidi_m4.c b/src/rawmidi/rawmidi_m4.c new file mode 100644 index 00000000..2d484d87 --- /dev/null +++ b/src/rawmidi/rawmidi_m4.c @@ -0,0 +1,238 @@ +/* + * Rawmidi - Automatically generated functions + * Copyright (c) 2001 by Abramo Bagnara <abramo@alsa-project.org> + * + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include "rawmidi_local.h" + +size_t snd_rawmidi_params_sizeof() +{ + return sizeof(snd_rawmidi_params_t); +} + +int snd_rawmidi_params_malloc(snd_rawmidi_params_t **ptr) +{ + assert(ptr); + *ptr = malloc(sizeof(snd_rawmidi_params_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_rawmidi_params_free(snd_rawmidi_params_t *obj) +{ + free(obj); +} + +void snd_rawmidi_params_copy(snd_rawmidi_params_t *dst, const snd_rawmidi_params_t *src) +{ + assert(dst && src); + *dst = *src; +} + +int snd_rawmidi_params_set_buffer_size(snd_rawmidi_t *rmidi ATTRIBUTE_UNUSED, snd_rawmidi_params_t *params, size_t val) +{ + assert(rmidi && params); + assert(val > params->avail_min); + params->buffer_size = val; + return 0; +} + +size_t snd_rawmidi_params_get_buffer_size(const snd_rawmidi_params_t *params) +{ + assert(params); + return params->buffer_size; +} + + +int snd_rawmidi_params_set_avail_min(snd_rawmidi_t *rmidi ATTRIBUTE_UNUSED, snd_rawmidi_params_t *params, size_t val) +{ + assert(rmidi && params); + assert(val < params->buffer_size); + params->avail_min = val; + return 0; +} + +size_t snd_rawmidi_params_get_avail_min(const snd_rawmidi_params_t *params) +{ + assert(params); + return params->avail_min; +} + + +int snd_rawmidi_params_set_no_active_sensing(snd_rawmidi_t *rmidi ATTRIBUTE_UNUSED, snd_rawmidi_params_t *params, int val) +{ + assert(rmidi && params); + params->no_active_sensing = val; + return 0; +} + +int snd_rawmidi_params_get_no_active_sensing(const snd_rawmidi_params_t *params) +{ + assert(params); + return params->no_active_sensing; +} + + +size_t snd_rawmidi_info_sizeof() +{ + return sizeof(snd_rawmidi_info_t); +} + +int snd_rawmidi_info_malloc(snd_rawmidi_info_t **ptr) +{ + assert(ptr); + *ptr = malloc(sizeof(snd_rawmidi_info_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_rawmidi_info_free(snd_rawmidi_info_t *obj) +{ + free(obj); +} + +void snd_rawmidi_info_copy(snd_rawmidi_info_t *dst, const snd_rawmidi_info_t *src) +{ + assert(dst && src); + *dst = *src; +} + +unsigned int snd_rawmidi_info_get_device(const snd_rawmidi_info_t *obj) +{ + assert(obj); + return obj->device; +} + +unsigned int snd_rawmidi_info_get_subdevice(const snd_rawmidi_info_t *obj) +{ + assert(obj); + return obj->subdevice; +} + +snd_rawmidi_stream_t snd_rawmidi_info_get_stream(const snd_rawmidi_info_t *obj) +{ + assert(obj); + return snd_int_to_enum(obj->stream); +} + +int snd_rawmidi_info_get_card(const snd_rawmidi_info_t *obj) +{ + assert(obj); + return obj->card; +} + +unsigned int snd_rawmidi_info_get_flags(const snd_rawmidi_info_t *obj) +{ + assert(obj); + return obj->flags; +} + +const char * snd_rawmidi_info_get_id(const snd_rawmidi_info_t *obj) +{ + assert(obj); + return obj->id; +} + +const char * snd_rawmidi_info_get_name(const snd_rawmidi_info_t *obj) +{ + assert(obj); + return obj->name; +} + +const char * snd_rawmidi_info_get_subdevice_name(const snd_rawmidi_info_t *obj) +{ + assert(obj); + return obj->subname; +} + +unsigned int snd_rawmidi_info_get_subdevices_count(const snd_rawmidi_info_t *obj) +{ + assert(obj); + return obj->subdevices_count; +} + +unsigned int snd_rawmidi_info_get_subdevices_avail(const snd_rawmidi_info_t *obj) +{ + assert(obj); + return obj->subdevices_avail; +} + +void snd_rawmidi_info_set_device(snd_rawmidi_info_t *obj, unsigned int val) +{ + assert(obj); + obj->device = val; +} + +void snd_rawmidi_info_set_subdevice(snd_rawmidi_info_t *obj, unsigned int val) +{ + assert(obj); + obj->subdevice = val; +} + +void snd_rawmidi_info_set_stream(snd_rawmidi_info_t *obj, snd_rawmidi_stream_t val) +{ + assert(obj); + obj->stream = snd_enum_to_int(val); +} + +size_t snd_rawmidi_status_sizeof() +{ + return sizeof(snd_rawmidi_status_t); +} + +int snd_rawmidi_status_malloc(snd_rawmidi_status_t **ptr) +{ + assert(ptr); + *ptr = malloc(sizeof(snd_rawmidi_status_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_rawmidi_status_free(snd_rawmidi_status_t *obj) +{ + free(obj); +} + +void snd_rawmidi_status_copy(snd_rawmidi_status_t *dst, const snd_rawmidi_status_t *src) +{ + assert(dst && src); + *dst = *src; +} + +void snd_rawmidi_status_get_tstamp(const snd_rawmidi_status_t *obj, snd_timestamp_t *ptr) +{ + assert(obj && ptr); + *ptr = obj->tstamp; +} + +size_t snd_rawmidi_status_get_avail(const snd_rawmidi_status_t *obj) +{ + assert(obj); + return obj->avail; +} + +size_t snd_rawmidi_status_get_avail_max(const snd_rawmidi_status_t *obj) +{ + assert(obj); + return obj->xruns; +} + |