From: Abramo Bagnara Date: Sat, 24 Mar 2001 16:14:44 +0000 (+0000) Subject: Completed PCM documentation X-Git-Tag: v1.0.3~912 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=ddc9a186cf0635bad75e71f8ffabc7aced9b105f;p=alsa-lib.git Completed PCM documentation --- diff --git a/include/pcm.h b/include/pcm.h index 7d7422e6..04d15473 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -281,6 +281,7 @@ typedef struct _snd_pcm_channel_area { unsigned int step; } snd_pcm_channel_area_t; +/** #SND_PCM_TYPE_METER scope handle */ typedef struct _snd_pcm_scope snd_pcm_scope_t; #ifdef __cplusplus @@ -330,12 +331,6 @@ snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm); /* HW params */ int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); -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_get_rate_numden(const snd_pcm_hw_params_t *params, unsigned int *rate_num, unsigned int *rate_den); @@ -343,6 +338,7 @@ int snd_pcm_hw_params_get_sbits(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); +#if 0 typedef struct _snd_pcm_hw_strategy snd_pcm_hw_strategy_t; /* choices need to be sorted on ascending badness */ @@ -360,6 +356,13 @@ 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_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); + +#endif int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params); int snd_pcm_sw_params_dump(snd_pcm_sw_params_t *params, snd_output_t *out); @@ -405,14 +408,21 @@ ssize_t snd_pcm_frames_to_bytes(snd_pcm_t *pcm, snd_pcm_sframes_t frames); int snd_pcm_bytes_to_samples(snd_pcm_t *pcm, ssize_t bytes); ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, int samples); -/* meter */ +/** #SND_PCM_TYPE_METER scope functions */ typedef struct _snd_pcm_scope_ops { + /** Enable and prepare it using current params */ int (*enable)(snd_pcm_scope_t *scope); + /** Disable */ void (*disable)(snd_pcm_scope_t *scope); + /** PCM has been started */ void (*start)(snd_pcm_scope_t *scope); + /** PCM has been stopped */ void (*stop)(snd_pcm_scope_t *scope); + /** New frames are present */ void (*update)(snd_pcm_scope_t *scope); + /** Reset status */ void (*reset)(snd_pcm_scope_t *scope); + /** PCM is closing */ void (*close)(snd_pcm_scope_t *scope); } snd_pcm_scope_ops_t; diff --git a/include/pcm_m4.h b/include/pcm_m4.h index 165bb4e5..86b95381 100644 --- a/include/pcm_m4.h +++ b/include/pcm_m4.h @@ -5,6 +5,11 @@ extern "C" { size_t snd_pcm_access_mask_sizeof(); + +/** \hideinitializer + * \brief allocate an empty #snd_pcm_access_mask_t using standard alloca + * \param ptr returned pointer + */ #define snd_pcm_access_mask_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_access_mask_t *) alloca(snd_pcm_access_mask_sizeof()); memset(*ptr, 0, snd_pcm_access_mask_sizeof()); } while (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); @@ -17,6 +22,10 @@ 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(); +/** \hideinitializer + * \brief allocate an empty #snd_pcm_format_mask_t using standard alloca + * \param ptr returned pointer + */ #define snd_pcm_format_mask_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_format_mask_t *) alloca(snd_pcm_format_mask_sizeof()); memset(*ptr, 0, snd_pcm_format_mask_sizeof()); } while (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); @@ -29,6 +38,10 @@ 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(); +/** \hideinitializer + * \brief allocate an empty #snd_pcm_subformat_mask_t using standard alloca + * \param ptr returned pointer + */ #define snd_pcm_subformat_mask_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_subformat_mask_t *) alloca(snd_pcm_subformat_mask_sizeof()); memset(*ptr, 0, snd_pcm_subformat_mask_sizeof()); } while (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); @@ -41,19 +54,23 @@ void snd_pcm_subformat_mask_set(snd_pcm_subformat_mask_t *mask, snd_pcm_subforma void snd_pcm_subformat_mask_reset(snd_pcm_subformat_mask_t *mask, snd_pcm_subformat_t val); size_t snd_pcm_hw_params_sizeof(); +/** \hideinitializer + * \brief allocate an invalid #snd_pcm_hw_params_t using standard alloca + * \param ptr returned pointer + */ #define snd_pcm_hw_params_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_hw_params_t *) alloca(snd_pcm_hw_params_sizeof()); memset(*ptr, 0, snd_pcm_hw_params_sizeof()); } while (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_get_access(const snd_pcm_hw_params_t *params); int snd_pcm_hw_params_test_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t val); int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, 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_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_get_format(const snd_pcm_hw_params_t *params); int snd_pcm_hw_params_test_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val); int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, 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); @@ -61,13 +78,13 @@ snd_pcm_format_t snd_pcm_hw_params_set_format_last(snd_pcm_t *pcm, snd_pcm_hw_pa int snd_pcm_hw_params_set_format_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_mask_t *mask); int snd_pcm_hw_params_test_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t val); -snd_pcm_subformat_t snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params); +int snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params); int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t val); 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_pcm_subformat_mask_t *mask); -unsigned int snd_pcm_hw_params_get_channels(const snd_pcm_hw_params_t *params); +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_test_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val); @@ -79,7 +96,7 @@ unsigned int snd_pcm_hw_params_set_channels_near(snd_pcm_t *pcm, snd_pcm_hw_para 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); +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_test_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); @@ -91,7 +108,7 @@ unsigned int snd_pcm_hw_params_set_rate_near(snd_pcm_t *pcm, snd_pcm_hw_params_t 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); +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_test_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); @@ -103,7 +120,7 @@ unsigned int snd_pcm_hw_params_set_period_time_near(snd_pcm_t *pcm, snd_pcm_hw_p 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_sframes_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_test_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int dir); @@ -116,7 +133,7 @@ snd_pcm_uframes_t snd_pcm_hw_params_set_period_size_first(snd_pcm_t *pcm, snd_pc 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); -unsigned int snd_pcm_hw_params_get_periods(const snd_pcm_hw_params_t *params, int *dir); +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_test_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); @@ -129,7 +146,7 @@ unsigned int snd_pcm_hw_params_set_periods_first(snd_pcm_t *pcm, snd_pcm_hw_para 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); -unsigned int snd_pcm_hw_params_get_buffer_time(const snd_pcm_hw_params_t *params, int *dir); +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_test_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); @@ -141,7 +158,7 @@ unsigned int snd_pcm_hw_params_set_buffer_time_near(snd_pcm_t *pcm, snd_pcm_hw_p 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_sframes_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_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val); @@ -153,7 +170,7 @@ snd_pcm_uframes_t snd_pcm_hw_params_set_buffer_size_near(snd_pcm_t *pcm, snd_pcm 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); +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_test_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); @@ -166,6 +183,10 @@ unsigned int snd_pcm_hw_params_set_tick_time_first(snd_pcm_t *pcm, snd_pcm_hw_pa 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(); +/** \hideinitializer + * \brief allocate an invalid #snd_pcm_sw_params_t using standard alloca + * \param ptr returned pointer + */ #define snd_pcm_sw_params_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_sw_params_t *) alloca(snd_pcm_sw_params_sizeof()); memset(*ptr, 0, snd_pcm_sw_params_sizeof()); } while (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); @@ -180,8 +201,10 @@ 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); +#if 0 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); +#endif 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); @@ -199,6 +222,10 @@ int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm, snd_pcm_sw_params_t *para snd_pcm_uframes_t snd_pcm_sw_params_get_silence_size(const snd_pcm_sw_params_t *params); size_t snd_pcm_status_sizeof(); +/** \hideinitializer + * \brief allocate an invalid #snd_pcm_status_t using standard alloca + * \param ptr returned pointer + */ #define snd_pcm_status_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_status_t *) alloca(snd_pcm_status_sizeof()); memset(*ptr, 0, snd_pcm_status_sizeof()); } while (0) int snd_pcm_status_malloc(snd_pcm_status_t **ptr); void snd_pcm_status_free(snd_pcm_status_t *obj); @@ -217,6 +244,10 @@ 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); size_t snd_pcm_info_sizeof(); +/** \hideinitializer + * \brief allocate an invalid #snd_pcm_info_t using standard alloca + * \param ptr returned pointer + */ #define snd_pcm_info_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_info_t *) alloca(snd_pcm_info_sizeof()); memset(*ptr, 0, snd_pcm_info_sizeof()); } while (0) int snd_pcm_info_malloc(snd_pcm_info_t **ptr); void snd_pcm_info_free(snd_pcm_info_t *obj); diff --git a/src/pcm/Makefile.am b/src/pcm/Makefile.am index 7b3b6c27..971fab72 100644 --- a/src/pcm/Makefile.am +++ b/src/pcm/Makefile.am @@ -2,7 +2,7 @@ EXTRA_LTLIBRARIES = libpcm.la libpcm_la_SOURCES = atomic.c mask.c interval.c \ - pcm.c pcm_m4.c pcm_hw.c pcm_plugin.c pcm_copy.c pcm_linear.c \ + pcm.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_null.c pcm_share.c \ diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 549d326b..c589114b 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -1,5 +1,5 @@ /** - * \file pcm.c + * \file pcm/pcm.c * \author Jaroslav Kysela * \author Abramo Bagnara * \date 2000-2001 @@ -48,7 +48,7 @@ /** * \brief get identifier of PCM handle - * \param pcm a PCM handle + * \param pcm PCM handle * \return ascii identifier of PCM handle * * Returns the ASCII identifier of given PCM handle. It's the same @@ -62,7 +62,7 @@ const char *snd_pcm_name(snd_pcm_t *pcm) /** * \brief get type of PCM handle - * \param pcm a PCM handle + * \param pcm PCM handle * \return type of PCM handle * * Returns the type #snd_pcm_type_t of given PCM handle. @@ -75,7 +75,7 @@ snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm) /** * \brief get stream for a PCM handle - * \param pcm a PCM handle + * \param pcm PCM handle * \return stream of PCM handle * * Returns the type #snd_pcm_stream_t of given PCM handle. @@ -262,9 +262,9 @@ snd_pcm_state_t snd_pcm_state(snd_pcm_t *pcm) } /** - * \brief Obtain delay in frames for a running PCM handle + * \brief Obtain delay for a running PCM handle * \param pcm PCM handle - * \param delayp Returned delay + * \param delayp Returned delay in frames * \return zero on success otherwise a negative error code * * Delay is distance between current application frame position and @@ -911,7 +911,7 @@ ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, int samples) * \param name ASCII identifier of the PCM handle * \param stream Wanted stream * \param mode Open mode (see #SND_PCM_NONBLOCK, #SND_PCM_ASYNC) - * \return a negative error code on failure or zero on success + * \return 0 or a negative error code on failure or zero on success */ int snd_pcm_open(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t stream, int mode) @@ -1056,9 +1056,9 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name, /** * \brief Wait for a PCM to become ready - * \param pcm a PCM handle + * \param pcm PCM handle * \param timeout maximum time in milliseconds to wait - * \return a negative error code on failure or zero on success + * \return 0 or a negative error code on failure or zero on success */ int snd_pcm_wait(snd_pcm_t *pcm, int timeout) { @@ -1074,7 +1074,7 @@ int snd_pcm_wait(snd_pcm_t *pcm, int timeout) /** * \brief Return number of frames ready to be read/written - * \param pcm a PCM handle + * \param pcm PCM handle * \return a positive number of frames ready otherwise a negative * error code * @@ -1088,7 +1088,7 @@ snd_pcm_sframes_t snd_pcm_avail_update(snd_pcm_t *pcm) /** * \brief Advance PCM frame position in mmap buffer - * \param pcm a PCM handle + * \param pcm PCM handle * \param size movement size * \return a positive number of actual movement size otherwise a negative * error code @@ -1411,6 +1411,2571 @@ int snd_pcm_areas_copy(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_ return 0; } +/** + * \brief Dump a PCM hardware configuration space + * \param params Configuration space + * \param out Output handle + * \return zero on success otherwise a negative error code + */ +int snd_pcm_hw_params_dump(snd_pcm_hw_params_t *params, snd_output_t *out) +{ + unsigned int k; + for (k = 0; k <= SND_PCM_HW_PARAM_LAST; k++) { + snd_output_printf(out, "%s: ", snd_pcm_hw_param_name(k)); + snd_pcm_hw_param_dump(params, k, out); + snd_output_putc(out, '\n'); + } + return 0; +} + +/** + * \brief Get rate exact info from a configuration space + * \param params Configuration space + * \param rate_num Pointer to returned rate numerator + * \param rate_den Pointer to returned rate denominator + * \return 0 or a negative error code if the info is not available + */ +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; + *rate_num = params->rate_num; + *rate_den = params->rate_den; + return 0; +} + +/** + * \brief Get sample resolution info from a configuration space + * \param params Configuration space + * \return significative bits in sample or a negative error code if the info is not available + */ +int snd_pcm_hw_params_get_sbits(const snd_pcm_hw_params_t *params) +{ + if (params->msbits == 0) + return -EINVAL; + return params->msbits; +} + +/** + * \brief Get hardare fifo size info from a configuration space + * \param params Configuration space + * \return fifo size in frames or a negative error code if the info is not available + */ +int snd_pcm_hw_params_get_fifo_size(const snd_pcm_hw_params_t *params) +{ + if (params->fifo_size == 0) + return -EINVAL; + return params->fifo_size; +} + +/** + * \brief Fill params with a full configuration space for a PCM + * \param pcm PCM handle + * \param params Configuration space + */ +int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) +{ + _snd_pcm_hw_params_any(params); + return snd_pcm_hw_refine(pcm, params); +} + +/** + * \brief get size of #snd_pcm_access_mask_t + * \return size in bytes + */ +size_t snd_pcm_access_mask_sizeof() +{ + return sizeof(snd_pcm_access_mask_t); +} + +/** + * \brief allocate an empty #snd_pcm_access_mask_t using standard malloc + * \param ptr returned pointer + * \return zero on success otherwise negative error code + */ +int snd_pcm_access_mask_malloc(snd_pcm_access_mask_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_pcm_access_mask_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +/** + * \brief frees a previously allocated #snd_pcm_access_mask_t + * \param pointer to object to free + */ +void snd_pcm_access_mask_free(snd_pcm_access_mask_t *obj) +{ + free(obj); +} + +/** + * \brief copy one #snd_pcm_access_mask_t to another + * \param dst pointer to destination + * \param src pointer to source + */ +void snd_pcm_access_mask_copy(snd_pcm_access_mask_t *dst, const snd_pcm_access_mask_t *src) +{ + assert(dst && src); + *dst = *src; +} + +/** + * \brief reset all bits in a #snd_pcm_access_mask_t + * \param mask pointer to mask + */ +void snd_pcm_access_mask_none(snd_pcm_access_mask_t *mask) +{ + snd_mask_none((snd_mask_t *) mask); +} + +/** + * \brief set all bits in a #snd_pcm_access_mask_t + * \param mask pointer to mask + */ +void snd_pcm_access_mask_any(snd_pcm_access_mask_t *mask) +{ + snd_mask_any((snd_mask_t *) mask); +} + +/** + * \brief test the presence of an access type in a #snd_pcm_access_mask_t + * \param mask pointer to mask + * \param val access type + */ +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); +} + +/** + * \brief make an access type present in a #snd_pcm_access_mask_t + * \param mask pointer to mask + * \param val access type + */ +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); +} + +/** + * \brief make an access type missing from a #snd_pcm_access_mask_t + * \param mask pointer to mask + * \param val access type + */ +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); +} + +/** + * \brief get size of #snd_pcm_format_mask_t + * \return size in bytes + */ +size_t snd_pcm_format_mask_sizeof() +{ + return sizeof(snd_pcm_format_mask_t); +} + +/** + * \brief allocate an empty #snd_pcm_format_mask_t using standard malloc + * \param ptr returned pointer + * \return zero on success otherwise negative error code + */ +int snd_pcm_format_mask_malloc(snd_pcm_format_mask_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_pcm_format_mask_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +/** + * \brief frees a previously allocated #snd_pcm_format_mask_t + * \param pointer to object to free + */ +void snd_pcm_format_mask_free(snd_pcm_format_mask_t *obj) +{ + free(obj); +} + +/** + * \brief copy one #snd_pcm_format_mask_t to another + * \param dst pointer to destination + * \param src pointer to source + */ +void snd_pcm_format_mask_copy(snd_pcm_format_mask_t *dst, const snd_pcm_format_mask_t *src) +{ + assert(dst && src); + *dst = *src; +} + +/** + * \brief reset all bits in a #snd_pcm_format_mask_t + * \param mask pointer to mask + */ +void snd_pcm_format_mask_none(snd_pcm_format_mask_t *mask) +{ + snd_mask_none((snd_mask_t *) mask); +} + +/** + * \brief set all bits in a #snd_pcm_format_mask_t + * \param mask pointer to mask + */ +void snd_pcm_format_mask_any(snd_pcm_format_mask_t *mask) +{ + snd_mask_any((snd_mask_t *) mask); +} + +/** + * \brief test the presence of a format in a #snd_pcm_format_mask_t + * \param mask pointer to mask + * \param val format + */ +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); +} + +/** + * \brief make a format present in a #snd_pcm_format_mask_t + * \param mask pointer to mask + * \param val format + */ +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); +} + +/** + * \brief make a format missing from a #snd_pcm_format_mask_t + * \param mask pointer to mask + * \param val format + */ +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); +} + + +/** + * \brief get size of #snd_pcm_subformat_mask_t + * \return size in bytes + */ +size_t snd_pcm_subformat_mask_sizeof() +{ + return sizeof(snd_pcm_subformat_mask_t); +} + +/** + * \brief allocate an empty #snd_pcm_subformat_mask_t using standard malloc + * \param ptr returned pointer + * \return zero on success otherwise negative error code + */ +int snd_pcm_subformat_mask_malloc(snd_pcm_subformat_mask_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_pcm_subformat_mask_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +/** + * \brief frees a previously allocated #snd_pcm_subformat_mask_t + * \param pointer to object to free + */ +void snd_pcm_subformat_mask_free(snd_pcm_subformat_mask_t *obj) +{ + free(obj); +} + +/** + * \brief copy one #snd_pcm_subformat_mask_t to another + * \param dst pointer to destination + * \param src pointer to source + */ +void snd_pcm_subformat_mask_copy(snd_pcm_subformat_mask_t *dst, const snd_pcm_subformat_mask_t *src) +{ + assert(dst && src); + *dst = *src; +} + +/** + * \brief reset all bits in a #snd_pcm_subformat_mask_t + * \param mask pointer to mask + */ +void snd_pcm_subformat_mask_none(snd_pcm_subformat_mask_t *mask) +{ + snd_mask_none((snd_mask_t *) mask); +} + +/** + * \brief set all bits in a #snd_pcm_subformat_mask_t + * \param mask pointer to mask + */ +void snd_pcm_subformat_mask_any(snd_pcm_subformat_mask_t *mask) +{ + snd_mask_any((snd_mask_t *) mask); +} + +/** + * \brief test the presence of a subformat in a #snd_pcm_subformat_mask_t + * \param mask pointer to mask + * \param val subformat + */ +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); +} + +/** + * \brief make a subformat present in a #snd_pcm_subformat_mask_t + * \param mask pointer to mask + * \param val subformat + */ +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); +} + +/** + * \brief make a subformat missing from a #snd_pcm_subformat_mask_t + * \param mask pointer to mask + * \param val subformat + */ +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); +} + + +/** + * \brief get size of #snd_pcm_hw_params_t + * \return size in bytes + */ +size_t snd_pcm_hw_params_sizeof() +{ + return sizeof(snd_pcm_hw_params_t); +} + +/** + * \brief allocate an invalid #snd_pcm_hw_params_t using standard malloc + * \param ptr returned pointer + * \return zero on success otherwise negative error code + */ +int snd_pcm_hw_params_malloc(snd_pcm_hw_params_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_pcm_hw_params_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +/** + * \brief frees a previously allocated #snd_pcm_hw_params_t + * \param pointer to object to free + */ +void snd_pcm_hw_params_free(snd_pcm_hw_params_t *obj) +{ + free(obj); +} + +/** + * \brief copy one #snd_pcm_hw_params_t to another + * \param dst pointer to destination + * \param src pointer to source + */ +void snd_pcm_hw_params_copy(snd_pcm_hw_params_t *dst, const snd_pcm_hw_params_t *src) +{ + assert(dst && src); + *dst = *src; +} + +/** + * \brief Extract access type from a configuration space + * \param params Configuration space + * \return access type or a negative error code if not exactly one is present + */ +int snd_pcm_hw_params_get_access(const snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_ACCESS, NULL); +} + +/** + * \brief Verify if an access type is available inside a configuration space for a PCM + * \param pcm PCM handle + * \param params Configuration space + * \param val access type + * \return 1 if available 0 otherwise + */ +int snd_pcm_hw_params_test_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t val) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_ACCESS, snd_enum_to_int(val), 0); +} + +/** + * \brief Restrict a configuration space to contain only one access type + * \param pcm PCM handle + * \param params Configuration space + * \param val access type + * \return 0 or a negative error code if configuration space would become empty + */ +int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t val) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_ACCESS, snd_enum_to_int(val), 0); +} + +/** + * \brief Restrict a configuration space to contain only its first access type + * \param pcm PCM handle + * \param params Configuration space + * \return access type + */ +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)); +} + +/** + * \brief Restrict a configuration space to contain only its last access type + * \param pcm PCM handle + * \param params Configuration space + * \return access type + */ +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)); +} + +/** + * \brief Restrict a configuration space to contain only a set of access types + * \param pcm PCM handle + * \param params Configuration space + * \param mask Access mask + * \return access type + */ +int snd_pcm_hw_params_set_access_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_mask_t *mask) +{ + return snd_pcm_hw_param_set_mask(pcm, params, SND_TRY, SND_PCM_HW_PARAM_ACCESS, (snd_mask_t *) mask); +} + + +/** + * \brief Extract format from a configuration space + * \param params Configuration space + * \return format or a negative error code if not exactly one is present + */ +int snd_pcm_hw_params_get_format(const snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_FORMAT, NULL); +} + +/** + * \brief Verify if a format is available inside a configuration space for a PCM + * \param pcm PCM handle + * \param params Configuration space + * \param val format + * \return 1 if available 0 otherwise + */ +int snd_pcm_hw_params_test_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_FORMAT, snd_enum_to_int(val), 0); +} + +/** + * \brief Restrict a configuration space to contain only one format + * \param pcm PCM handle + * \param params Configuration space + * \param val format + * \return 0 or a negative error code if configuration space would become empty + */ +int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_FORMAT, snd_enum_to_int(val), 0); +} + +/** + * \brief Restrict a configuration space to contain only its first format + * \param pcm PCM handle + * \param params Configuration space + * \return format + */ +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)); +} + +/** + * \brief Restrict a configuration space to contain only its last format + * \param pcm PCM handle + * \param params Configuration space + * \return format + */ +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)); +} + +/** + * \brief Restrict a configuration space to contain only a set of formats + * \param pcm PCM handle + * \param params Configuration space + * \param mask Format mask + * \return access type + */ +int snd_pcm_hw_params_set_format_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_mask_t *mask) +{ + return snd_pcm_hw_param_set_mask(pcm, params, SND_TRY, SND_PCM_HW_PARAM_FORMAT, (snd_mask_t *) mask); +} + + +/** + * \brief Verify if a subformat is available inside a configuration space for a PCM + * \param pcm PCM handle + * \param params Configuration space + * \param val subformat + * \return 1 if available 0 otherwise + */ +int snd_pcm_hw_params_test_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t val) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_SUBFORMAT, snd_enum_to_int(val), 0); +} + +/** + * \brief Extract subformat from a configuration space + * \param params Configuration space + * \return subformat or a negative error code if not exactly one is present + */ +int snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_SUBFORMAT, NULL); +} + +/** + * \brief Restrict a configuration space to contain only one subformat + * \param pcm PCM handle + * \param params Configuration space + * \param val subformat + * \return 0 or a negative error code if configuration space would become empty + */ +int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t val) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_SUBFORMAT, snd_enum_to_int(val), 0); +} + +/** + * \brief Restrict a configuration space to contain only its first subformat + * \param pcm PCM handle + * \param params Configuration space + * \return subformat + */ +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)); +} + +/** + * \brief Restrict a configuration space to contain only its last subformat + * \param pcm PCM handle + * \param params Configuration space + * \return subformat + */ +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)); +} + +/** + * \brief Restrict a configuration space to contain only a set of subformats + * \param pcm PCM handle + * \param params Configuration space + * \param mask Subformat mask + * \return access type + */ +int snd_pcm_hw_params_set_subformat_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_mask_t *mask) +{ + return snd_pcm_hw_param_set_mask(pcm, params, SND_TRY, SND_PCM_HW_PARAM_SUBFORMAT, (snd_mask_t *) mask); +} + + +/** + * \brief Extract channels from a configuration space + * \param params Configuration space + * \return channels count or a negative error code if not exactly one is present + */ +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); +} + +/** + * \brief Extract minimum channels count from a configuration space + * \param params Configuration space + * \return minimum channels count + */ +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); +} + +/** + * \brief Extract maximum channels count from a configuration space + * \param params Configuration space + * \return maximum channels count + */ +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); +} + +/** + * \brief Verify if a channels count is available inside a configuration space for a PCM + * \param pcm PCM handle + * \param params Configuration space + * \param val channels count + * \return 1 if available 0 otherwise + */ +int snd_pcm_hw_params_test_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_CHANNELS, val, 0); +} + +/** + * \brief Restrict a configuration space to contain only one channels count + * \param pcm PCM handle + * \param params Configuration space + * \param val channels count + * \return 0 or a negative error code if configuration space would become empty + */ +int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_CHANNELS, val, 0); +} + +/** + * \brief Restrict a configuration space with a minimum channels count + * \param pcm PCM handle + * \param params Configuration space + * \param val minimum channels count (on return filled with actual minimum) + * \return 0 or a negative error code if configuration space would become empty + */ +int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val) +{ + return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_CHANNELS, val, NULL); +} + +/** + * \brief Restrict a configuration space with a maximum channels count + * \param pcm PCM handle + * \param params Configuration space + * \param val maximum channels count (on return filled with actual maximum) + * \return 0 or a negative error code if configuration space would become empty + */ +int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val) +{ + return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_CHANNELS, val, NULL); +} + +/** + * \brief Restrict a configuration space to have channels counts in a given range + * \param pcm PCM handle + * \param params Configuration space + * \param min minimum channels count (on return filled with actual minimum) + * \param max maximum channels count (on return filled with actual maximum) + * \return 0 or a negative error code if configuration space would become empty + */ +int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, unsigned int *max) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_CHANNELS, min, NULL, max, NULL); +} + +/** + * \brief Restrict a configuration space to have channels count nearest to a target + * \param pcm PCM handle + * \param params Configuration space + * \param val target channels count + * \return choosen channels count + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its minimum channels count + * \param pcm PCM handle + * \param params Configuration space + * \return channels count + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its maximum channels count + * \param pcm PCM handle + * \param params Configuration space + * \return channels count + */ +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); +} + + +/** + * \brief Extract rate from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate rate or a negative error code if not exactly one is present + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + +/** + * \brief Extract minimum rate from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate minimum rate + * + * Exact value is <,=,> the returned one following dir (-1,0,1) + */ +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); +} + +/** + * \brief Extract maximum rate from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate maximum rate + * + * Exact value is <,=,> the returned one following dir (-1,0,1) + */ +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); +} + +/** + * \brief Verify if a rate is available inside a configuration space for a PCM + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate rate + * \param dir Sub unit direction + * \return 1 if available 0 otherwise + * + * Wanted exact value is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_test_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_RATE, val, dir); +} + +/** + * \brief Restrict a configuration space to contain only one rate + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate rate + * \param dir Sub unit direction + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted exact value is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_RATE, val, dir); +} + +/** + * \brief Restrict a configuration space with a minimum rate + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate minimum rate (on return filled with actual minimum) + * \param dir Sub unit direction (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_RATE, val, dir); +} + +/** + * \brief Restrict a configuration space with a maximum rate + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate maximum rate (on return filled with actual maximum) + * \param dir Sub unit direction (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_RATE, val, dir); +} + +/** + * \brief Restrict a configuration space to have rates in a given range + * \param pcm PCM handle + * \param params Configuration space + * \param min approximate minimum rate (on return filled with actual minimum) + * \param mindir Sub unit direction for minimum (on return filled with actual direction) + * \param max approximate maximum rate (on return filled with actual maximum) + * \param maxdir Sub unit direction for maximum (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_rate_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_RATE, min, mindir, max, maxdir); +} + +/** + * \brief Restrict a configuration space to have rate nearest to a target + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate target rate + * \return approximate choosen rate + * + * target/choosen exact value is <,=,> val following dir (-1,0,1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its minimum rate + * \param pcm PCM handle + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate rate + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its maximum rate + * \param pcm PCM handle + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate rate + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + + +/** + * \brief Extract period time from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate period duration in us or a negative error code if not exactly one is present + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + +/** + * \brief Extract minimum period time from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate minimum period duration in us + * + * Exact value is <,=,> the returned one following dir (-1,0,1) + */ +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); +} + +/** + * \brief Extract maximum period time from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate maximum period duration in us + * + * Exact value is <,=,> the returned one following dir (-1,0,1) + */ +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); +} + +/** + * \brief Verify if a period time is available inside a configuration space for a PCM + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate period duration in us + * \param dir Sub unit direction + * \return 1 if available 0 otherwise + * + * Wanted exact value is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_test_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); +} + +/** + * \brief Restrict a configuration space to contain only one period time + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate period duration in us + * \param dir Sub unit direction + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted exact value is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); +} + + +/** + * \brief Restrict a configuration space with a minimum period time + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate minimum period duration in us (on return filled with actual minimum) + * \param dir Sub unit direction (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); +} + +/** + * \brief Restrict a configuration space with a maximum period time + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate maximum period duration in us (on return filled with actual maximum) + * \param dir Sub unit direction (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); +} + +/** + * \brief Restrict a configuration space to have period times in a given range + * \param pcm PCM handle + * \param params Configuration space + * \param min approximate minimum period duration in us (on return filled with actual minimum) + * \param mindir Sub unit direction for minimum (on return filled with actual direction) + * \param max approximate maximum period duration in us (on return filled with actual maximum) + * \param maxdir Sub unit direction for maximum (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_period_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_TIME, min, mindir, max, maxdir); +} + +/** + * \brief Restrict a configuration space to have period time nearest to a target + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate target period duration in us + * \return approximate choosen period duration in us + * + * target/choosen exact value is <,=,> val following dir (-1,0,1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its minimum period time + * \param pcm PCM handle + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate period duration in us + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its maximum period time + * \param pcm PCM handle + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate period duration in us + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + + +/** + * \brief Extract period size from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate period size in frames or a negative error code if not exactly one is present + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +snd_pcm_sframes_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); +} + +/** + * \brief Extract minimum period size from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate minimum period size in frames + * + * Exact value is <,=,> the returned one following dir (-1,0,1) + */ +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); +} + +/** + * \brief Extract maximum period size from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate maximum period size in frames + * + * Exact value is <,=,> the returned one following dir (-1,0,1) + */ +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); +} + +/** + * \brief Verify if a period size is available inside a configuration space for a PCM + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate period size in frames + * \param dir Sub unit direction + * \return 1 if available 0 otherwise + * + * Wanted exact value is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_test_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_PERIOD_SIZE, val, dir); +} + +/** + * \brief Restrict a configuration space to contain only one period size + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate period size in frames + * \param dir Sub unit direction + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted exact value is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE, val, dir); +} + +/** + * \brief Restrict a configuration space with a minimum period size + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate minimum period size in frames (on return filled with actual minimum) + * \param dir Sub unit direction (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_period_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir) +{ + unsigned int _val = *val; + int err = snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir); + *val = _val; + return err; +} + +/** + * \brief Restrict a configuration space with a maximum period size + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate maximum period size in frames (on return filled with actual maximum) + * \param dir Sub unit direction (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_period_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir) +{ + unsigned int _val = *val; + int err = snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir); + *val = _val; + return err; +} + +/** + * \brief Restrict a configuration space to have period sizes in a given range + * \param pcm PCM handle + * \param params Configuration space + * \param min approximate minimum period size in frames (on return filled with actual minimum) + * \param mindir Sub unit direction for minimum (on return filled with actual direction) + * \param max approximate maximum period size in frames (on return filled with actual maximum) + * \param maxdir Sub unit direction for maximum (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_period_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, 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, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE, &_min, mindir, &_max, maxdir); + *min = _min; + *max = _max; + return err; +} + +/** + * \brief Restrict a configuration space to have period size nearest to a target + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate target period size in frames + * \return approximate choosen period size in frames + * + * target/choosen exact value is <,=,> val following dir (-1,0,1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its minimum period size + * \param pcm PCM handle + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate period size in frames + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its maximum period size + * \param pcm PCM handle + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate period size in frames + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only integer period sizes + * \param pcm PCM handle + * \param params Configuration space + * \return 0 or a negative error code if configuration space would become empty + */ +int snd_pcm_hw_params_set_period_size_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_set_integer(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE); +} + + +/** + * \brief Extract periods from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate periods per buffer or a negative error code if not exactly one is present + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + +/** + * \brief Extract minimum periods count from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate minimum periods per buffer + * + * Exact value is <,=,> the returned one following dir (-1,0,1) + */ +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); +} + +/** + * \brief Extract maximum periods count from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate maximum periods per buffer + * + * Exact value is <,=,> the returned one following dir (-1,0,1) + */ +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); +} + +/** + * \brief Verify if a periods count is available inside a configuration space for a PCM + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate periods per buffer + * \param dir Sub unit direction + * \return 1 if available 0 otherwise + * + * Wanted exact value is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_test_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_PERIODS, val, dir); +} + +/** + * \brief Restrict a configuration space to contain only one periods count + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate periods per buffer + * \param dir Sub unit direction + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted exact value is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS, val, dir); +} + +/** + * \brief Restrict a configuration space with a minimum periods count + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate minimum periods per buffer (on return filled with actual minimum) + * \param dir Sub unit direction (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS, val, dir); +} + +/** + * \brief Restrict a configuration space with a maximum periods count + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate maximum periods per buffer (on return filled with actual maximum) + * \param dir Sub unit direction (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS, val, dir); +} + +/** + * \brief Restrict a configuration space to have periods counts in a given range + * \param pcm PCM handle + * \param params Configuration space + * \param min approximate minimum periods per buffer (on return filled with actual minimum) + * \param mindir Sub unit direction for minimum (on return filled with actual direction) + * \param max approximate maximum periods per buffer (on return filled with actual maximum) + * \param maxdir Sub unit direction for maximum (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_periods_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS, min, mindir, max, maxdir); +} + +/** + * \brief Restrict a configuration space to have periods count nearest to a target + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate target periods per buffer + * \return approximate choosen periods per buffer + * + * target/choosen exact value is <,=,> val following dir (-1,0,1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its minimum periods count + * \param pcm PCM handle + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate periods per buffer + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its maximum periods count + * \param pcm PCM handle + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate periods per buffer + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only integer periods counts + * \param pcm PCM handle + * \param params Configuration space + * \return 0 or a negative error code if configuration space would become empty + */ +int snd_pcm_hw_params_set_periods_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) +{ + return snd_pcm_hw_param_set_integer(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS); +} + + +/** + * \brief Extract buffer time from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate buffer duration in us or a negative error code if not exactly one is present + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + +/** + * \brief Extract minimum buffer time from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate minimum buffer duration in us + * + * Exact value is <,=,> the returned one following dir (-1,0,1) + */ +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); +} + +/** + * \brief Extract maximum buffer time from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate maximum buffer duration in us + * + * Exact value is <,=,> the returned one following dir (-1,0,1) + */ +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); +} + +/** + * \brief Verify if a buffer time is available inside a configuration space for a PCM + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate buffer duration in us + * \param dir Sub unit direction + * \return 1 if available 0 otherwise + * + * Wanted exact value is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_test_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); +} + +/** + * \brief Restrict a configuration space to contain only one buffer time + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate buffer duration in us + * \param dir Sub unit direction + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted exact value is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); +} + +/** + * \brief Restrict a configuration space with a minimum buffer time + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate minimum buffer duration in us (on return filled with actual minimum) + * \param dir Sub unit direction (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); +} + +/** + * \brief Restrict a configuration space with a maximum buffer time + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate maximum buffer duration in us (on return filled with actual maximum) + * \param dir Sub unit direction (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); +} + +/** + * \brief Restrict a configuration space to have buffer times in a given range + * \param pcm PCM handle + * \param params Configuration space + * \param min approximate minimum buffer duration in us (on return filled with actual minimum) + * \param mindir Sub unit direction for minimum (on return filled with actual direction) + * \param max approximate maximum buffer duration in us (on return filled with actual maximum) + * \param maxdir Sub unit direction for maximum (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_buffer_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_TIME, min, mindir, max, maxdir); +} + +/** + * \brief Restrict a configuration space to have buffer time nearest to a target + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate target buffer duration in us + * \return approximate choosen buffer duration in us + * + * target/choosen exact value is <,=,> val following dir (-1,0,1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its minimum buffer time + * \param pcm PCM handle + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate buffer duration in us + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its maximum bufferd time + * \param pcm PCM handle + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate buffer duration in us + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + + +/** + * \brief Extract buffer size from a configuration space + * \param params Configuration space + * \return buffer size in frames or a negative error code if not exactly one is present + */ +snd_pcm_sframes_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); +} + +/** + * \brief Extract minimum buffer size from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate minimum buffer size in frames + * + * Exact value is <,=,> the returned one following dir (-1,0,1) + */ +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); +} + +/** + * \brief Extract maximum buffer size from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate maximum buffer size in frames + * + * Exact value is <,=,> the returned one following dir (-1,0,1) + */ +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); +} + +/** + * \brief Verify if a buffer size is available inside a configuration space for a PCM + * \param pcm PCM handle + * \param params Configuration space + * \param val buffer size in frames + * \param dir Sub unit direction + * \return 1 if available 0 otherwise + * + * Wanted exact value is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_BUFFER_SIZE, val, 0); +} + +/** + * \brief Restrict a configuration space to contain only one buffer size + * \param pcm PCM handle + * \param params Configuration space + * \param val buffer size in frames + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted exact value is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_SIZE, val, 0); +} + +/** + * \brief Restrict a configuration space with a minimum buffer size + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate minimum buffer size in frames (on return filled with actual minimum) + * \param dir Sub unit direction (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val) +{ + unsigned int _val = *val; + int err = snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL); + *val = _val; + return err; +} + +/** + * \brief Restrict a configuration space with a maximum buffer size + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate maximum buffer size in frames (on return filled with actual maximum) + * \param dir Sub unit direction (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val) +{ + unsigned int _val = *val; + int err = snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL); + *val = _val; + return err; +} + +/** + * \brief Restrict a configuration space to have buffer sizes in a given range + * \param pcm PCM handle + * \param params Configuration space + * \param min approximate minimum buffer size in frames (on return filled with actual minimum) + * \param mindir Sub unit direction for minimum (on return filled with actual direction) + * \param max approximate maximum buffer size in frames (on return filled with actual maximum) + * \param maxdir Sub unit direction for maximum (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_buffer_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, 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, SND_TRY, SND_PCM_HW_PARAM_BUFFER_SIZE, &_min, NULL, &_max, NULL); + *min = _min; + *max = _max; + return err; +} + +/** + * \brief Restrict a configuration space to have buffer size nearest to a target + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate target buffer size in frames + * \return approximate choosen buffer size in frames + * + * target/choosen exact value is <,=,> val following dir (-1,0,1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its minimum buffer size + * \param pcm PCM handle + * \param params Configuration space + * \return buffer size in frames + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its maximum buffer size + * \param pcm PCM handle + * \param params Configuration space + * \return buffer size in frames + */ +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); +} + + +/** + * \brief Extract tick time from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate tick duration in us or a negative error code if not exactly one is present + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + +/** + * \brief Extract minimum tick time from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate minimum tick duration in us + * + * Exact value is <,=,> the returned one following dir (-1,0,1) + */ +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); +} + +/** + * \brief Extract maximum tick time from a configuration space + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate maximum tick duration in us + * + * Exact value is <,=,> the returned one following dir (-1,0,1) + */ +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); +} + +/** + * \brief Verify if a tick time is available inside a configuration space for a PCM + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate tick duration in us + * \param dir Sub unit direction + * \return 1 if available 0 otherwise + * + * Wanted exact value is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_test_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_TICK_TIME, val, dir); +} + +/** + * \brief Restrict a configuration space to contain only one tick time + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate tick duration in us + * \param dir Sub unit direction + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted exact value is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_TICK_TIME, val, dir); +} + +/** + * \brief Restrict a configuration space with a minimum tick time + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate minimum tick duration in us (on return filled with actual minimum) + * \param dir Sub unit direction (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_tick_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_TICK_TIME, val, dir); +} + +/** + * \brief Restrict a configuration space with a maximum tick time + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate maximum tick duration in us (on return filled with actual maximum) + * \param dir Sub unit direction (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_tick_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) +{ + return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_TICK_TIME, val, dir); +} + +/** + * \brief Restrict a configuration space to have tick times in a given range + * \param pcm PCM handle + * \param params Configuration space + * \param min approximate minimum tick duration in us (on return filled with actual minimum) + * \param mindir Sub unit direction for minimum (on return filled with actual direction) + * \param max approximate maximum tick duration in us (on return filled with actual maximum) + * \param maxdir Sub unit direction for maximum (on return filled with actual direction) + * \return 0 or a negative error code if configuration space would become empty + * + * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1) + */ +int snd_pcm_hw_params_set_tick_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_TICK_TIME, min, mindir, max, maxdir); +} + +/** + * \brief Restrict a configuration space to have tick time nearest to a target + * \param pcm PCM handle + * \param params Configuration space + * \param val approximate target tick duration in us + * \return approximate choosen tick duration in us + * + * target/choosen exact value is <,=,> val following dir (-1,0,1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its minimum tick time + * \param pcm PCM handle + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate tick duration in us + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + +/** + * \brief Restrict a configuration space to contain only its maximum tick time + * \param pcm PCM handle + * \param params Configuration space + * \param dir Sub unit direction + * \return approximate tick duration in us + * + * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1) + */ +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); +} + +/** + * \brief Return current software configuration for a PCM + * \param pcm PCM handle + * \param params Software configuration container + * \return zero on success otherwise a negative error code + */ +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 = 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; + params->xfer_align = pcm->xfer_align; + params->silence_threshold = pcm->silence_threshold; + params->silence_size = pcm->silence_size; + params->boundary = pcm->boundary; + return 0; +} + +/** + * \brief Dump a software configuration + * \param params Software configuration container + * \param out Output handle + * \return zero on success otherwise a negative error code + */ +int snd_pcm_sw_params_dump(snd_pcm_sw_params_t *params, snd_output_t *out) +{ + 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; +} + +/** + * \brief get size of #snd_pcm_sw_params_t + * \return size in bytes + */ +size_t snd_pcm_sw_params_sizeof() +{ + return sizeof(snd_pcm_sw_params_t); +} + +/** + * \brief allocate an invalid #snd_pcm_sw_params_t using standard malloc + * \param ptr returned pointer + * \return zero on success otherwise negative error code + */ +int snd_pcm_sw_params_malloc(snd_pcm_sw_params_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_pcm_sw_params_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +/** + * \brief frees a previously allocated #snd_pcm_sw_params_t + * \param pointer to object to free + */ +void snd_pcm_sw_params_free(snd_pcm_sw_params_t *obj) +{ + free(obj); +} + +/** + * \brief copy one #snd_pcm_sw_params_t to another + * \param dst pointer to destination + * \param src pointer to source + */ +void snd_pcm_sw_params_copy(snd_pcm_sw_params_t *dst, const snd_pcm_sw_params_t *src) +{ + assert(dst && src); + *dst = *src; +} + +/** + * \brief Set start mode inside a software configuration container + * \param pcm PCM handle + * \param params Software configuration container + * \param val Start mode + * \return 0 or a negative error code + */ +int snd_pcm_sw_params_set_start_mode(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_start_t val) +{ + assert(pcm && params); + assert(val <= SND_PCM_START_LAST); + params->start_mode = snd_enum_to_int(val); + return 0; +} + +/** + * \brief Get start mode from a software configuration container + * \param params Software configuration container + * \return start mode + */ +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); +} + + +/** + * \brief Set xrun mode inside a software configuration container + * \param pcm PCM handle + * \param params Software configuration container + * \param val Xrun mode + * \return 0 or a negative error code + */ +int snd_pcm_sw_params_set_xrun_mode(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_xrun_t val) +{ + assert(pcm && params); + assert(val <= SND_PCM_XRUN_LAST); + params->xrun_mode = snd_enum_to_int(val); + return 0; +} + +/** + * \brief Get xrun mode from a software configuration container + * \param params Software configuration container + * \return xrun mode + */ +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); +} + + +/** + * \brief Set timestamp mode inside a software configuration container + * \param pcm PCM handle + * \param params Software configuration container + * \param val Timestamp mode + * \return 0 or a negative error code + */ +int snd_pcm_sw_params_set_tstamp_mode(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_tstamp_t val) +{ + assert(pcm && params); + assert(val <= SND_PCM_TSTAMP_LAST); + params->tstamp_mode = snd_enum_to_int(val); + return 0; +} + +/** + * \brief Get timestamp mode from a software configuration container + * \param params Software configuration container + * \return timestamp mode + */ +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); +} + + +#if 0 +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; +} +#endif + + +/** + * \brief Set minimum number of ticks to sleep inside a software configuration container + * \param pcm PCM handle + * \param params Software configuration container + * \param val Minimum ticks to sleep or 0 to disable the use of tick timer + * \return 0 or a negative error code + */ +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; +} + +/** + * \brief Get minimum numbers of ticks to sleep from a software configuration container + * \param params Software configuration container + * \return minimum number of ticks to sleep or 0 if tick timer is disabled + */ +unsigned int snd_pcm_sw_params_get_sleep_min(const snd_pcm_sw_params_t *params) +{ + assert(params); + return params->sleep_min; +} + +/** + * \brief Set avail min inside a software configuration container + * \param pcm PCM handle + * \param params Software configuration container + * \param val Minimum avail frames to consider PCM ready + * \return 0 or a negative error code + */ +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; +} + +/** + * \brief Get avail min from a software configuration container + * \param params Software configuration container + * \return minimum available frames to consider PCM ready + */ +snd_pcm_uframes_t snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *params) +{ + assert(params); + return params->avail_min; +} + + +/** + * \brief Set xfer align inside a software configuration container + * \param pcm PCM handle + * \param params Software configuration container + * \param val Chunk size (frames are attempted to be transferred in chunks) + * \return 0 or a negative error code + */ +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; +} + +/** + * \brief Get xfer align from a software configuration container + * \param params Software configuration container + * \return Chunk size (frames are attempted to be transferred in chunks) + */ +snd_pcm_uframes_t snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *params) +{ + assert(params); + return params->xfer_align; +} + + +/** + * \brief Set silence threshold inside a software configuration container + * \param pcm PCM handle + * \param params Software configuration container + * \param val Silence threshold in frames + * \return 0 or a negative error code + * + * A portion of playback buffer is overwritten with silence (see + * #snd_pcm_sw_params_set_silence_size) when playback underrun is nearer + * than silence threshold + */ +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; +} + +/** + * \brief Get silence threshold from a software configuration container + * \param params Software configuration container + * \return Silence threshold in frames + * + * A portion of playback buffer is overwritten with silence (see + * #snd_pcm_sw_params_get_silence_size) when playback underrun is nearer + * than silence threshold + */ +snd_pcm_uframes_t snd_pcm_sw_params_get_silence_threshold(const snd_pcm_sw_params_t *params) +{ + assert(params); + return params->silence_threshold; +} + + +/** + * \brief Set silence size inside a software configuration container + * \param pcm PCM handle + * \param params Software configuration container + * \param val Silence size in frames (0 for disabled) + * \return 0 or a negative error code + * + * A portion of playback buffer is overwritten with silence when playback + * underrun is nearer than silence threshold (see + * #snd_pcm_sw_params_set_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; +} + +/** + * \brief Get silence size from a software configuration container + * \param params Software configuration container + * \return Silence size in frames (0 for disabled) + * + * A portion of playback buffer is overwritten with silence when playback + * underrun is nearer than silence threshold (see + * #snd_pcm_sw_params_set_silence_threshold) + */ +snd_pcm_uframes_t snd_pcm_sw_params_get_silence_size(const snd_pcm_sw_params_t *params) +{ + assert(params); + return params->silence_size; +} + + +/** + * \brief get size of #snd_pcm_status_t + * \return size in bytes + */ +size_t snd_pcm_status_sizeof() +{ + return sizeof(snd_pcm_status_t); +} + +/** + * \brief allocate an invalid #snd_pcm_status_t using standard malloc + * \param ptr returned pointer + * \return zero on success otherwise negative error code + */ +int snd_pcm_status_malloc(snd_pcm_status_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_pcm_status_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +/** + * \brief frees a previously allocated #snd_pcm_status_t + * \param pointer to object to free + */ +void snd_pcm_status_free(snd_pcm_status_t *obj) +{ + free(obj); +} + +/** + * \brief copy one #snd_pcm_status_t to another + * \param dst pointer to destination + * \param src pointer to source + */ +void snd_pcm_status_copy(snd_pcm_status_t *dst, const snd_pcm_status_t *src) +{ + assert(dst && src); + *dst = *src; +} + +/** + * \brief Get state from a PCM status container (see #snd_pcm_state) + * \return PCM state + */ +snd_pcm_state_t snd_pcm_status_get_state(const snd_pcm_status_t *obj) +{ + assert(obj); + return snd_int_to_enum(obj->state); +} + +/** + * \brief Get trigger timestamp from a PCM status container + * \param ptr Pointer to returned timestamp + */ +void snd_pcm_status_get_trigger_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr) +{ + assert(obj && ptr); + *ptr = obj->trigger_tstamp; +} + +/** + * \brief Get "now" timestamp from a PCM status container + * \param ptr Pointer to returned timestamp + */ +void snd_pcm_status_get_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr) +{ + assert(obj && ptr); + *ptr = obj->tstamp; +} + +/** + * \brief Get delay from a PCM status container (see #snd_pcm_delay) + * \return Delay in frames + * + * Delay is distance between current application frame position and + * sound frame position. + * It's positive and less than buffer size in normal situation, + * negative on playback underrun and greater than buffer size on + * capture overrun. + */ +snd_pcm_sframes_t snd_pcm_status_get_delay(const snd_pcm_status_t *obj) +{ + assert(obj); + return obj->delay; +} + +/** + * \brief Get number of frames available from a PCM status container (see #snd_pcm_avail_update) + * \return Number of frames ready to be read/written + */ +snd_pcm_uframes_t snd_pcm_status_get_avail(const snd_pcm_status_t *obj) +{ + assert(obj); + return obj->avail; +} + +/** + * \brief Get maximum number of frames available from a PCM status container after last #snd_pcm_status call + * \return Maximum number of frames ready to be read/written + */ +snd_pcm_uframes_t snd_pcm_status_get_avail_max(const snd_pcm_status_t *obj) +{ + assert(obj); + return obj->avail_max; +} + +/** + * \brief get size of #snd_pcm_info_t + * \return size in bytes + */ +size_t snd_pcm_info_sizeof() +{ + return sizeof(snd_pcm_info_t); +} + +/** + * \brief allocate an invalid #snd_pcm_info_t using standard malloc + * \param ptr returned pointer + * \return zero on success otherwise negative error code + */ +int snd_pcm_info_malloc(snd_pcm_info_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_pcm_info_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +/** + * \brief frees a previously allocated #snd_pcm_info_t + * \param pointer to object to free + */ +void snd_pcm_info_free(snd_pcm_info_t *obj) +{ + free(obj); +} + +/** + * \brief copy one #snd_pcm_info_t to another + * \param dst pointer to destination + * \param src pointer to source + */ +void snd_pcm_info_copy(snd_pcm_info_t *dst, const snd_pcm_info_t *src) +{ + assert(dst && src); + *dst = *src; +} + +/** + * \brief Get device from a PCM info container + * \param obj PCM info container + * \return device number + */ +unsigned int snd_pcm_info_get_device(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->device; +} + +/** + * \brief Get subdevice from a PCM info container + * \param obj PCM info container + * \return subdevice number + */ +unsigned int snd_pcm_info_get_subdevice(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->subdevice; +} + +/** + * \brief Get stream (direction) from a PCM info container + * \param obj PCM info container + * \return stream + */ +snd_pcm_stream_t snd_pcm_info_get_stream(const snd_pcm_info_t *obj) +{ + assert(obj); + return snd_int_to_enum(obj->stream); +} + +/** + * \brief Get card from a PCM info container + * \param obj PCM info container + * \return card number or a negative error code if not associable to a card + */ +int snd_pcm_info_get_card(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->card; +} + +/** + * \brief Get id from a PCM info container + * \param obj PCM info container + * \return short id of PCM + */ +const char *snd_pcm_info_get_id(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->id; +} + +/** + * \brief Get name from a PCM info container + * \param obj PCM info container + * \return name of PCM + */ +const char *snd_pcm_info_get_name(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->name; +} + +/** + * \brief Get subdevice name from a PCM info container + * \param obj PCM info container + * \return name of used PCM subdevice + */ +const char *snd_pcm_info_get_subdevice_name(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->subname; +} + +/** + * \brief Get class from a PCM info container + * \param obj PCM info container + * \return class of PCM + */ +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); +} + +/** + * \brief Get subclass from a PCM info container + * \param obj PCM info container + * \return subclass of PCM + */ +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); +} + +/** + * \brief Get subdevices count from a PCM info container + * \param obj PCM info container + * \return subdevices total count of PCM + */ +unsigned int snd_pcm_info_get_subdevices_count(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->subdevices_count; +} + +/** + * \brief Get available subdevices count from a PCM info container + * \param obj PCM info container + * \return available subdevices count of PCM + */ +unsigned int snd_pcm_info_get_subdevices_avail(const snd_pcm_info_t *obj) +{ + assert(obj); + return obj->subdevices_avail; +} + +/** + * \brief Set wanted device inside a PCM info container (see #snd_ctl_pcm_info) + * \param obj PCM info container + * \param val Device number + */ +void snd_pcm_info_set_device(snd_pcm_info_t *obj, unsigned int val) +{ + assert(obj); + obj->device = val; +} + +/** + * \brief Set wanted subdevice inside a PCM info container (see #snd_ctl_pcm_info) + * \param obj PCM info container + * \param val Subdevice number + */ +void snd_pcm_info_set_subdevice(snd_pcm_info_t *obj, unsigned int val) +{ + assert(obj); + obj->subdevice = val; +} + +/** + * \brief Set wanted stream inside a PCM info container (see #snd_ctl_pcm_info) + * \param obj PCM info container + * \param val Stream + */ +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); +} + + +/** + * \brief Get channel areas for a given PCM when running + * \param pcm PCM handle + * \return pointer to channel areas (one for each channel) + */ +const snd_pcm_channel_area_t *snd_pcm_mmap_running_areas(snd_pcm_t *pcm) +{ + return pcm->running_areas; +} + +/** + * \brief Get channel areas for a given PCM when stopped + * \param pcm PCM handle + * \return pointer to channel areas (one for each channel) + */ +const snd_pcm_channel_area_t *snd_pcm_mmap_stopped_areas(snd_pcm_t *pcm) +{ + return pcm->stopped_areas; +} + +/** + * \brief Get appropriate channel areas for a given PCM according to its state (running or stopped) + * \param pcm PCM handle + * \return pointer to channel areas (one for each channel) + */ +const snd_pcm_channel_area_t *snd_pcm_mmap_areas(snd_pcm_t *pcm) +{ + if (pcm->stopped_areas && + snd_pcm_state(pcm) != SND_PCM_STATE_RUNNING) + return pcm->stopped_areas; + return pcm->running_areas; +} + +/** + * \brief Correct frames count according to contiguity consideration inside PCM ring buffer + * \param pcm PCM handle + * \param frames Frames to transfer + * \return Number of contiguous frames transferrable + */ +snd_pcm_uframes_t snd_pcm_mmap_xfer(snd_pcm_t *pcm, snd_pcm_uframes_t frames) +{ + assert(pcm); + if (pcm->stream == SND_PCM_STREAM_PLAYBACK) + return snd_pcm_mmap_playback_xfer(pcm, frames); + else + return snd_pcm_mmap_capture_xfer(pcm, frames); +} + +/** + * \brief Return application offset inside ring buffer + * \param pcm PCM handle + * \return Offset for frames transfer + */ +snd_pcm_uframes_t snd_pcm_mmap_offset(snd_pcm_t *pcm) +{ + assert(pcm); + return *pcm->appl_ptr % pcm->buffer_size; +} + #ifndef DOC_HIDDEN int _snd_pcm_poll_descriptor(snd_pcm_t *pcm) diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c index c56b87f8..e71fb2b7 100644 --- a/src/pcm/pcm_adpcm.c +++ b/src/pcm/pcm_adpcm.c @@ -409,7 +409,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_get(params, SND_PCM_HW_PARAM_CHANNELS, 0) * sizeof(*adpcm->states)); + adpcm->states = malloc(adpcm->plug.slave->channels * sizeof(*adpcm->states)); return 0; } diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index 5c93e50a..3abd9029 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -475,12 +475,16 @@ int snd_pcm_hw_param_set(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 *mask); -unsigned int snd_pcm_hw_param_get(const snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, int *dir); +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 param); +void snd_pcm_hw_param_dump(const snd_pcm_hw_params_t *params, + snd_pcm_hw_param_t var, snd_output_t *out); +#if 0 int snd_pcm_hw_strategy_simple_near(snd_pcm_hw_strategy_t *strategy, int order, snd_pcm_hw_param_t var, unsigned int best, @@ -489,6 +493,7 @@ int snd_pcm_hw_strategy_simple_choices(snd_pcm_hw_strategy_t *strategy, int orde snd_pcm_hw_param_t var, unsigned int count, snd_pcm_hw_strategy_simple_choices_list_t *choices); +#endif int snd_pcm_slave_conf(snd_config_t *conf, const char **namep, unsigned int count, ...); diff --git a/src/pcm/pcm_m4.c b/src/pcm/pcm_m4.c deleted file mode 100644 index 116fb335..00000000 --- a/src/pcm/pcm_m4.c +++ /dev/null @@ -1,1103 +0,0 @@ -/* - * PCM - Automatically generated functions - * Copyright (c) 2001 by Abramo Bagnara - * - * - * 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 = calloc(1, 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 = calloc(1, 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 = calloc(1, 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 = calloc(1, 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_test_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t val) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_ACCESS, snd_enum_to_int(val), 0); -} - -int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t val) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_ACCESS, snd_enum_to_int(val), 0); -} - -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_pcm_access_mask_t *mask) -{ - return snd_pcm_hw_param_set_mask(pcm, params, SND_TRY, 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_test_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_FORMAT, snd_enum_to_int(val), 0); -} - -int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TRY, 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_pcm_format_mask_t *mask) -{ - return snd_pcm_hw_param_set_mask(pcm, params, SND_TRY, SND_PCM_HW_PARAM_FORMAT, (snd_mask_t *) mask); -} - - -int snd_pcm_hw_params_test_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t val) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_SUBFORMAT, snd_enum_to_int(val), 0); -} - -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_pcm_subformat_t val) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_SUBFORMAT, snd_enum_to_int(val), 0); -} - -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_pcm_subformat_mask_t *mask) -{ - return snd_pcm_hw_param_set_mask(pcm, params, SND_TRY, 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_test_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_CHANNELS, val, 0); -} - -int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TRY, 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, unsigned int *val) -{ - return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, 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, unsigned int *val) -{ - return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, 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, unsigned int *min, unsigned int *max) -{ - return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, 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_test_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_RATE, val, dir); -} - -int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TRY, 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, unsigned int *val, int *dir) -{ - return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, 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, unsigned int *val, int *dir) -{ - return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, 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, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) -{ - return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, 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_test_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); -} - -int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TRY, 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, unsigned int *val, int *dir) -{ - return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, 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, unsigned int *val, int *dir) -{ - return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, 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, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) -{ - return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, 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_test_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int dir) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_PERIOD_SIZE, val, dir); -} - -int snd_pcm_hw_params_set_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int dir) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TRY, 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_pcm_uframes_t *val, int *dir) -{ - unsigned int _val = *val; - int err = snd_pcm_hw_param_set_min(pcm, params, SND_TRY, 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_pcm_uframes_t *val, int *dir) -{ - unsigned int _val = *val; - int err = snd_pcm_hw_param_set_max(pcm, params, SND_TRY, 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_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, SND_TRY, 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) -{ - return snd_pcm_hw_param_set_integer(pcm, params, SND_TRY, 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_test_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_PERIODS, val, dir); -} - -int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TRY, 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, unsigned int *val, int *dir) -{ - return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, 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, unsigned int *val, int *dir) -{ - return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, 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, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) -{ - return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, 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) -{ - return snd_pcm_hw_param_set_integer(pcm, params, SND_TRY, 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_test_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); -} - -int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TRY, 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, unsigned int *val, int *dir) -{ - return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, 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, unsigned int *val, int *dir) -{ - return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, 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, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) -{ - return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, 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_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_BUFFER_SIZE, val, 0); -} - -int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TRY, 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_pcm_uframes_t *val) -{ - unsigned int _val = *val; - int err = snd_pcm_hw_param_set_min(pcm, params, SND_TRY, 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_pcm_uframes_t *val) -{ - unsigned int _val = *val; - int err = snd_pcm_hw_param_set_max(pcm, params, SND_TRY, 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_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, SND_TRY, 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_test_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_TICK_TIME, val, dir); -} - -int snd_pcm_hw_params_set_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) -{ - return snd_pcm_hw_param_set(pcm, params, SND_TRY, 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, unsigned int *val, int *dir) -{ - return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, 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, unsigned int *val, int *dir) -{ - return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, 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, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) -{ - return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, 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 = calloc(1, 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_status_sizeof() -{ - return sizeof(snd_pcm_status_t); -} - -int snd_pcm_status_malloc(snd_pcm_status_t **ptr) -{ - assert(ptr); - *ptr = calloc(1, 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; -} - -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 = calloc(1, 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); -} - diff --git a/src/pcm/pcm_meter.c b/src/pcm/pcm_meter.c index 8b8ced56..a91a6424 100644 --- a/src/pcm/pcm_meter.c +++ b/src/pcm/pcm_meter.c @@ -1,3 +1,8 @@ +/** + * \file pcm/pcm_meter.c + * \author Abramo Bagnara + * \date 2001 + */ /* * PCM - Meter plugin * Copyright (c) 2001 by Abramo Bagnara @@ -18,6 +23,8 @@ * */ +#ifndef DOC_HIDDEN + #include #include #include @@ -163,21 +170,6 @@ int snd_pcm_scope_disable(snd_pcm_scope_t *scope) return 0; } -snd_pcm_scope_t *snd_pcm_meter_search_scope(snd_pcm_t *pcm, const char *name) -{ - snd_pcm_meter_t *meter; - struct list_head *pos; - assert(pcm->type == SND_PCM_TYPE_METER); - meter = pcm->private_data; - list_for_each(pos, &meter->scopes) { - snd_pcm_scope_t *scope; - scope = list_entry(pos, snd_pcm_scope_t, list); - if (scope->name && strcmp(scope->name, name) == 0) - return scope; - } - return NULL; -} - static void *snd_pcm_meter_thread(void *data) { snd_pcm_t *pcm = data; @@ -785,6 +777,14 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name, return 0; } +#endif + +/** + * \brief Add a scope to a #SND_PCM_TYPE_METER PCM + * \param pcm PCM handle + * \param scope Scope handle + * \return zero on success otherwise a negative error code + */ int snd_pcm_meter_add_scope(snd_pcm_t *pcm, snd_pcm_scope_t *scope) { snd_pcm_meter_t *meter; @@ -794,14 +794,46 @@ int snd_pcm_meter_add_scope(snd_pcm_t *pcm, snd_pcm_scope_t *scope) return 0; } +/** + * \brief Search an installed scope inside a #SND_PCM_TYPE_METER PCM + * \param pcm PCM handle + * \param name scope name + * \return pointer to found scope or NULL if none is found + */ +snd_pcm_scope_t *snd_pcm_meter_search_scope(snd_pcm_t *pcm, const char *name) +{ + snd_pcm_meter_t *meter; + struct list_head *pos; + assert(pcm->type == SND_PCM_TYPE_METER); + meter = pcm->private_data; + list_for_each(pos, &meter->scopes) { + snd_pcm_scope_t *scope; + scope = list_entry(pos, snd_pcm_scope_t, list); + if (scope->name && strcmp(scope->name, name) == 0) + return scope; + } + return NULL; +} + +/** + * \brief Get meter buffer size from a #SND_PCM_TYPE_METER PCM + * \param pcm PCM handle + * \return meter buffer size in frames + */ snd_pcm_uframes_t snd_pcm_meter_get_bufsize(snd_pcm_t *pcm) { snd_pcm_meter_t *meter; assert(pcm->type == SND_PCM_TYPE_METER); meter = pcm->private_data; + assert(meter->slave->setup); return meter->buf_size; } +/** + * \brief Get meter channels from a #SND_PCM_TYPE_METER PCM + * \param pcm PCM handle + * \return meter channels count + */ unsigned int snd_pcm_meter_get_channels(snd_pcm_t *pcm) { snd_pcm_meter_t *meter; @@ -811,6 +843,11 @@ unsigned int snd_pcm_meter_get_channels(snd_pcm_t *pcm) return meter->slave->channels; } +/** + * \brief Get meter rate from a #SND_PCM_TYPE_METER PCM + * \param pcm PCM handle + * \return approximate rate + */ unsigned int snd_pcm_meter_get_rate(snd_pcm_t *pcm) { snd_pcm_meter_t *meter; @@ -820,6 +857,11 @@ unsigned int snd_pcm_meter_get_rate(snd_pcm_t *pcm) return meter->slave->rate; } +/** + * \brief Get meter "now" frame pointer from a #SND_PCM_TYPE_METER PCM + * \param pcm PCM handle + * \return "now" frame pointer in frames (0 ... boundary - 1) see #snd_pcm_meter_get_boundary + */ snd_pcm_uframes_t snd_pcm_meter_get_now(snd_pcm_t *pcm) { snd_pcm_meter_t *meter; @@ -829,6 +871,11 @@ snd_pcm_uframes_t snd_pcm_meter_get_now(snd_pcm_t *pcm) return meter->now; } +/** + * \brief Get boundary for frame pointers from a #SND_PCM_TYPE_METER PCM + * \param pcm PCM handle + * \return boundary in frames + */ snd_pcm_uframes_t snd_pcm_meter_get_boundary(snd_pcm_t *pcm) { snd_pcm_meter_t *meter; @@ -838,31 +885,57 @@ snd_pcm_uframes_t snd_pcm_meter_get_boundary(snd_pcm_t *pcm) return meter->slave->boundary; } +/** + * \brief Set name of a #SND_PCM_TYPE_METER PCM scope + * \param scope PCM meter scope + * \param name scope name + */ void snd_pcm_scope_set_name(snd_pcm_scope_t *scope, const char *val) { scope->name = val; } +/** + * \brief Get name of a #SND_PCM_TYPE_METER PCM scope + * \param scope PCM meter scope + * \return scope name + */ const char *snd_pcm_scope_get_name(snd_pcm_scope_t *scope) { return scope->name; } +/** + * \brief Set callbacks for a #SND_PCM_TYPE_METER PCM scope + * \param scope PCM meter scope + * \param val callbacks + */ void snd_pcm_scope_set_ops(snd_pcm_scope_t *scope, snd_pcm_scope_ops_t *val) { scope->ops = val; } +/** + * \brief Get callbacks private value for a #SND_PCM_TYPE_METER PCM scope + * \param scope PCM meter scope + * \return Private data value + */ void *snd_pcm_scope_get_callback_private(snd_pcm_scope_t *scope) { return scope->private_data; } +/** + * \brief Get callbacks private value for a #SND_PCM_TYPE_METER PCM scope + * \param scope PCM meter scope + * \param val Private data value + */ void snd_pcm_scope_set_callback_private(snd_pcm_scope_t *scope, void *val) { scope->private_data = val; } +#ifndef DOC_HIDDEN typedef struct _snd_pcm_scope_s16 { snd_pcm_t *pcm; snd_pcm_adpcm_state_t *adpcm_states; @@ -1034,6 +1107,18 @@ snd_pcm_scope_ops_t s16_ops = { reset: s16_reset, }; +#endif + +/** + * \brief Add a s16 pseudo scope to a #SND_PCM_TYPE_METER PCM + * \param name Scope name + * \param scopep Pointer to newly created and added scope + * \return zero on success otherwise a negative error code + * + * s16 pseudo scope convert #SND_PCM_TYPE_METER PCM frames in CPU endian + * 16 bit frames for use with other scopes. Don't forget to insert it before + * and to not insert it more time (see #snd_pcm_meter_search_scope) + */ int snd_pcm_scope_s16_open(snd_pcm_t *pcm, const char *name, snd_pcm_scope_t **scopep) { @@ -1060,6 +1145,12 @@ int snd_pcm_scope_s16_open(snd_pcm_t *pcm, const char *name, return 0; } +/** + * \brief Get s16 pseudo scope frames buffer for a channel + * \param scope s16 pseudo scope handle + * \param channel Channel + * \return Pointer to channel buffer + */ int16_t *snd_pcm_scope_s16_get_channel_buffer(snd_pcm_scope_t *scope, unsigned int channel) { @@ -1074,6 +1165,11 @@ int16_t *snd_pcm_scope_s16_get_channel_buffer(snd_pcm_scope_t *scope, return s16->buf_areas[channel].addr; } +/** + * \brief allocate an invalid #snd_pcm_scope_t using standard malloc + * \param ptr returned pointer + * \return zero on success otherwise negative error code + */ int snd_pcm_scope_malloc(snd_pcm_scope_t **ptr) { assert(ptr); diff --git a/src/pcm/pcm_misc.c b/src/pcm/pcm_misc.c index 07863a3b..dffd681a 100644 --- a/src/pcm/pcm_misc.c +++ b/src/pcm/pcm_misc.c @@ -38,6 +38,12 @@ #include "pcm_local.h" #endif + +/** + * \brief Return sign info for a PCM sample linear format + * \param format Format + * \return 0 unsigned, 1 signed, a negative error code if format is not linear + */ int snd_pcm_format_signed(snd_pcm_format_t format) { switch (snd_enum_to_int(format)) { @@ -62,6 +68,11 @@ int snd_pcm_format_signed(snd_pcm_format_t format) } } +/** + * \brief Return sign info for a PCM sample linear format + * \param format Format + * \return 0 signed, 1 unsigned, a negative error code if format is not linear + */ int snd_pcm_format_unsigned(snd_pcm_format_t format) { int val; @@ -72,11 +83,21 @@ int snd_pcm_format_unsigned(snd_pcm_format_t format) return !val; } +/** + * \brief Return linear info for a PCM sample format + * \param format Format + * \return 0 non linear, 1 linear + */ int snd_pcm_format_linear(snd_pcm_format_t format) { return snd_pcm_format_signed(format) >= 0; } +/** + * \brief Return endian info for a PCM sample format + * \param format Format + * \return 0 big endian, 1 little endian, a negative error code if endian independent + */ int snd_pcm_format_little_endian(snd_pcm_format_t format) { switch (snd_enum_to_int(format)) { @@ -105,6 +126,11 @@ int snd_pcm_format_little_endian(snd_pcm_format_t format) } } +/** + * \brief Return endian info for a PCM sample format + * \param format Format + * \return 0 little endian, 1 big endian, a negative error code if endian independent + */ int snd_pcm_format_big_endian(snd_pcm_format_t format) { int val; @@ -115,6 +141,11 @@ int snd_pcm_format_big_endian(snd_pcm_format_t format) return !val; } +/** + * \brief Return endian info for a PCM sample format + * \param format Format + * \return 0 swapped, 1 CPU endian, a negative error code if endian independent + */ int snd_pcm_format_cpu_endian(snd_pcm_format_t format) { #ifdef SNDRV_LITTLE_ENDIAN @@ -124,6 +155,11 @@ int snd_pcm_format_cpu_endian(snd_pcm_format_t format) #endif } +/** + * \brief Return nominal bits per a PCM sample + * \param format Sample format + * \return bits per sample, a negative error code if not applicable + */ int snd_pcm_format_width(snd_pcm_format_t format) { switch (snd_enum_to_int(format)) { @@ -163,6 +199,11 @@ int snd_pcm_format_width(snd_pcm_format_t format) } } +/** + * \brief Return bits needed to store a PCM sample + * \param format Sample format + * \return bits per sample, a negative error code if not applicable + */ int snd_pcm_format_physical_width(snd_pcm_format_t format) { switch (snd_enum_to_int(format)) { @@ -200,6 +241,12 @@ int snd_pcm_format_physical_width(snd_pcm_format_t format) } } +/** + * \brief Return bytes needed to store a quantity of PCM sample + * \param format Sample format + * \param samples Samples count + * \return bytes needed, a negative error code if not integer or unknown + */ ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples) { switch (snd_enum_to_int(format)) { @@ -241,6 +288,11 @@ ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples) } } +/** + * \brief Return 64 bit expressing silence for a PCM sample format + * \param format Sample format + * \return silence 64 bit word + */ u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format) { switch (snd_enum_to_int(format)) { @@ -352,21 +404,45 @@ u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format) return 0; } +/** + * \brief Return 32 bit expressing silence for a PCM sample format + * \param format Sample format + * \return silence 32 bit word + */ u_int32_t snd_pcm_format_silence_32(snd_pcm_format_t format) { + assert(snd_pcm_format_physical_width(format) <= 32); return (u_int32_t)snd_pcm_format_silence_64(format); } +/** + * \brief Return 16 bit expressing silence for a PCM sample format + * \param format Sample format + * \return silence 16 bit word + */ u_int16_t snd_pcm_format_silence_16(snd_pcm_format_t format) { + assert(snd_pcm_format_physical_width(format) <= 16); return (u_int16_t)snd_pcm_format_silence_64(format); } +/** + * \brief Return 8 bit expressing silence for a PCM sample format + * \param format Sample format + * \return silence 8 bit word + */ u_int8_t snd_pcm_format_silence(snd_pcm_format_t format) { + assert(snd_pcm_format_physical_width(format) <= 8); return (u_int8_t)snd_pcm_format_silence_64(format); } +/** + * \brief Silence a PCM samples buufer + * \param format Sample format + * \param data Buffer + * \return samples Samples count + */ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int samples) { if (samples == 0) @@ -405,6 +481,7 @@ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int break; } default: + assert(0); return -EINVAL; } return 0; @@ -429,6 +506,12 @@ static int linear_formats[4*2*2] = { SNDRV_PCM_FORMAT_U32_BE }; +/** + * \brief Compose a PCM sample linear format + * \param width Nominal bits per sample + * \param unsignd Sign: 0 signed, 1 unsigned + * \return big_endian Endianness: 0 little endian, 1 big endian + */ snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_endian) { switch (width) { diff --git a/src/pcm/pcm_mmap.c b/src/pcm/pcm_mmap.c index fed127b1..933f67fa 100644 --- a/src/pcm/pcm_mmap.c +++ b/src/pcm/pcm_mmap.c @@ -44,24 +44,6 @@ size_t page_align(size_t size) return size; } -const snd_pcm_channel_area_t *snd_pcm_mmap_running_areas(snd_pcm_t *pcm) -{ - return pcm->running_areas; -} - -const snd_pcm_channel_area_t *snd_pcm_mmap_stopped_areas(snd_pcm_t *pcm) -{ - return pcm->stopped_areas; -} - -const snd_pcm_channel_area_t *snd_pcm_mmap_areas(snd_pcm_t *pcm) -{ - if (pcm->stopped_areas && - snd_pcm_state(pcm) != SND_PCM_STATE_RUNNING) - return pcm->stopped_areas; - return pcm->running_areas; -} - snd_pcm_uframes_t snd_pcm_mmap_playback_xfer(snd_pcm_t *pcm, snd_pcm_uframes_t frames) { snd_pcm_uframes_t cont; @@ -86,21 +68,6 @@ snd_pcm_uframes_t snd_pcm_mmap_capture_xfer(snd_pcm_t *pcm, snd_pcm_uframes_t fr return frames; } -snd_pcm_uframes_t snd_pcm_mmap_xfer(snd_pcm_t *pcm, snd_pcm_uframes_t frames) -{ - assert(pcm); - if (pcm->stream == SND_PCM_STREAM_PLAYBACK) - return snd_pcm_mmap_playback_xfer(pcm, frames); - else - return snd_pcm_mmap_capture_xfer(pcm, frames); -} - -snd_pcm_uframes_t snd_pcm_mmap_offset(snd_pcm_t *pcm) -{ - assert(pcm); - return *pcm->appl_ptr % pcm->buffer_size; -} - snd_pcm_uframes_t snd_pcm_mmap_hw_offset(snd_pcm_t *pcm) { assert(pcm); diff --git a/src/pcm/pcm_params.c b/src/pcm/pcm_params.c index 1baaabd6..4e8d0978 100644 --- a/src/pcm/pcm_params.c +++ b/src/pcm/pcm_params.c @@ -92,29 +92,24 @@ void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params) params->info = ~0U; } -/* Fill PARAMS with full configuration space boundaries */ -int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) -{ - _snd_pcm_hw_params_any(params); - return snd_pcm_hw_refine(pcm, params); -} - /* Return the value for field PAR if it's fixed in configuration space defined by PARAMS. Return -EINVAL otherwise */ -unsigned int snd_pcm_hw_param_get(const snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, int *dir) +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); - assert(snd_mask_single(mask)); + if (snd_mask_empty(mask) || !snd_mask_single(mask)) + return -EINVAL; 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); - assert(snd_interval_single(i)); + if (snd_interval_empty(i) || !snd_interval_single(i)) + return -EINVAL; if (dir) *dir = i->openmin; return snd_interval_value(i); @@ -947,35 +942,6 @@ 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_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; - *rate_num = params->rate_num; - *rate_den = params->rate_den; - return 0; -} - -/* Return significative bits in sample for configuration space defined - by PARAMS */ -int snd_pcm_hw_params_get_sbits(const snd_pcm_hw_params_t *params) -{ - if (params->msbits == 0) - return -EINVAL; - return params->msbits; -} - -/* Return fifo size for configuration space defined by PARAMS */ -int snd_pcm_hw_params_get_fifo_size(const snd_pcm_hw_params_t *params) -{ - if (params->fifo_size == 0) - return -EINVAL; - return params->fifo_size; -} - /* Choose one configuration from configuration space defined by PARAMS The configuration choosen is that obtained fixing in this order: first access @@ -1000,56 +966,6 @@ void snd_pcm_hw_params_choose(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_TICK_TIME, 0); } -/* Strategies */ - -struct _snd_pcm_hw_strategy { - unsigned int badness_min, badness_max; - int (*choose_param)(const snd_pcm_hw_params_t *params, - snd_pcm_t *pcm, - const snd_pcm_hw_strategy_t *strategy); - int (*next_value)(snd_pcm_hw_params_t *params, - unsigned int param, - int value, int *dir, - snd_pcm_t *pcm, - const snd_pcm_hw_strategy_t *strategy); - int (*min_badness)(const snd_pcm_hw_params_t *params, - unsigned int max_badness, - snd_pcm_t *pcm, - const snd_pcm_hw_strategy_t *strategy); - void *private_data; - void (*free)(snd_pcm_hw_strategy_t *strategy); -}; - -/* Independent badness */ -typedef struct _snd_pcm_hw_strategy_simple snd_pcm_hw_strategy_simple_t; - -struct _snd_pcm_hw_strategy_simple { - int valid; - unsigned int order; - int (*next_value)(snd_pcm_hw_params_t *params, - unsigned int param, - int value, int *dir, - snd_pcm_t *pcm, - const snd_pcm_hw_strategy_simple_t *par); - unsigned int (*min_badness)(const snd_pcm_hw_params_t *params, - unsigned int param, - snd_pcm_t *pcm, - const snd_pcm_hw_strategy_simple_t *par); - void *private_data; - void (*free)(snd_pcm_hw_strategy_simple_t *strategy); -}; - -typedef struct _snd_pcm_hw_strategy_simple_near { - int best; - unsigned int mul; -} snd_pcm_hw_strategy_simple_near_t; - -typedef struct _snd_pcm_hw_strategy_simple_choices { - unsigned int count; - /* choices need to be sorted on ascending badness */ - snd_pcm_hw_strategy_simple_choices_list_t *choices; -} snd_pcm_hw_strategy_simple_choices_t; - unsigned int snd_pcm_hw_param_count(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var) { @@ -1171,22 +1087,62 @@ const char *snd_pcm_hw_param_names[] = { HW_PARAM(TICK_TIME), }; -static const char *snd_pcm_hw_param_name(snd_pcm_hw_param_t param) +const char *snd_pcm_hw_param_name(snd_pcm_hw_param_t param) { assert(param <= SND_PCM_HW_PARAM_LAST); return snd_pcm_hw_param_names[snd_enum_to_int(param)]; } -int snd_pcm_hw_params_dump(snd_pcm_hw_params_t *params, snd_output_t *out) -{ - unsigned int k; - for (k = 0; k <= SND_PCM_HW_PARAM_LAST; k++) { - snd_output_printf(out, "%s: ", snd_pcm_hw_param_name(k)); - snd_pcm_hw_param_dump(params, k, out); - snd_output_putc(out, '\n'); - } - return 0; -} +#if 0 +/* Strategies */ + +struct _snd_pcm_hw_strategy { + unsigned int badness_min, badness_max; + int (*choose_param)(const snd_pcm_hw_params_t *params, + snd_pcm_t *pcm, + const snd_pcm_hw_strategy_t *strategy); + int (*next_value)(snd_pcm_hw_params_t *params, + unsigned int param, + int value, int *dir, + snd_pcm_t *pcm, + const snd_pcm_hw_strategy_t *strategy); + int (*min_badness)(const snd_pcm_hw_params_t *params, + unsigned int max_badness, + snd_pcm_t *pcm, + const snd_pcm_hw_strategy_t *strategy); + void *private_data; + void (*free)(snd_pcm_hw_strategy_t *strategy); +}; + +/* Independent badness */ +typedef struct _snd_pcm_hw_strategy_simple snd_pcm_hw_strategy_simple_t; + +struct _snd_pcm_hw_strategy_simple { + int valid; + unsigned int order; + int (*next_value)(snd_pcm_hw_params_t *params, + unsigned int param, + int value, int *dir, + snd_pcm_t *pcm, + const snd_pcm_hw_strategy_simple_t *par); + unsigned int (*min_badness)(const snd_pcm_hw_params_t *params, + unsigned int param, + snd_pcm_t *pcm, + const snd_pcm_hw_strategy_simple_t *par); + void *private_data; + void (*free)(snd_pcm_hw_strategy_simple_t *strategy); +}; + +typedef struct _snd_pcm_hw_strategy_simple_near { + int best; + unsigned int mul; +} snd_pcm_hw_strategy_simple_near_t; + +typedef struct _snd_pcm_hw_strategy_simple_choices { + unsigned int count; + /* choices need to be sorted on ascending badness */ + snd_pcm_hw_strategy_simple_choices_list_t *choices; +} snd_pcm_hw_strategy_simple_choices_t; int snd_pcm_hw_params_strategy(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, const snd_pcm_hw_strategy_t *strategy, @@ -1536,6 +1492,8 @@ int snd_pcm_hw_params_try_explain_failure(snd_pcm_t *pcm, return snd_pcm_hw_params_try_explain_failure1(pcm, fail, success, depth, out); } +#endif + typedef struct _snd_pcm_hw_rule snd_pcm_hw_rule_t; typedef int (*snd_pcm_hw_rule_func_t)(snd_pcm_hw_params_t *params, @@ -2050,23 +2008,6 @@ int snd_pcm_hw_params_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, return err; } -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 = 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; - params->xfer_align = pcm->xfer_align; - params->silence_threshold = pcm->silence_threshold; - params->silence_size = pcm->silence_size; - params->boundary = pcm->boundary; - return 0; -} - int snd_pcm_sw_params_default(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) { assert(pcm && params); @@ -2086,22 +2027,6 @@ int snd_pcm_sw_params_default(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) return 0; } -int snd_pcm_sw_params_dump(snd_pcm_sw_params_t *params, snd_output_t *out) -{ - 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; -} - - int snd_pcm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) { assert(pcm && params); diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index 8def7928..1171f9cb 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -357,7 +357,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_get(params, SND_PCM_HW_PARAM_CHANNELS, 0) * sizeof(*rate->states)); + rate->states = malloc(rate->plug.slave->channels * sizeof(*rate->states)); return 0; } diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c index 3f42f839..4abd50a8 100644 --- a/src/rawmidi/rawmidi.c +++ b/src/rawmidi/rawmidi.c @@ -313,7 +313,7 @@ int snd_rawmidi_info_malloc(snd_rawmidi_info_t **info) /** * \brief frees the snd_rawmidi_info_t structure - * \param params pointer to the snd_rawmidi_info_t structure to free + * \param info pointer to the snd_rawmidi_info_t structure to free * * Frees the given snd_rawmidi_params_t structure using the standard * free C library function.