]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Added snd_pcm_hw_params_current() function and clear() functions for structures
authorJaroslav Kysela <perex@perex.cz>
Sat, 12 Oct 2002 10:38:43 +0000 (10:38 +0000)
committerJaroslav Kysela <perex@perex.cz>
Sat, 12 Oct 2002 10:38:43 +0000 (10:38 +0000)
include/aserver.h
include/pcm.h
src/pcm/interval.h
src/pcm/interval_inline.h
src/pcm/pcm.c
src/pcm/pcm_local.h

index fe50a65938218ae2364ce4e0aa5dcb4a2a35f542..3561495d402b73195a2f0b5d0e0c19c0f6447b02 100644 (file)
@@ -39,6 +39,7 @@ typedef enum _snd_transport_type {
        SND_TRANSPORT_TYPE_TCP,
 } snd_transport_type_t;
 
+#define SND_PCM_IOCTL_AVAIL            _IOR('A', 0x22, sndrv_pcm_uframes_t)
 #define SND_PCM_IOCTL_STATE            _IO ('A', 0xf1)
 #define SND_PCM_IOCTL_MMAP             _IO ('A', 0xf2)
 #define SND_PCM_IOCTL_MUNMAP           _IO ('A', 0xf3)
@@ -72,6 +73,9 @@ typedef struct {
                snd_pcm_hw_params_t hw_params;
                snd_pcm_sw_params_t sw_params;
                snd_pcm_status_t status;
+               struct {
+                       snd_pcm_uframes_t frames;
+               } avail;
                struct {
                        snd_pcm_sframes_t frames;
                } delay;
index 308b53edf2ccfee667a85c05665ad8a5df431c02..0c94caf1779972af4c5c6a349114428d23c8128f 100644 (file)
@@ -392,8 +392,10 @@ int snd_async_add_pcm_handler(snd_async_handler_t **handler, snd_pcm_t *pcm,
                              snd_async_callback_t callback, void *private_data);
 snd_pcm_t *snd_async_handler_get_pcm(snd_async_handler_t *handler);
 int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info);
+int snd_pcm_hw_params_current(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
 int snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
 int snd_pcm_hw_free(snd_pcm_t *pcm);
+int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
 int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
 int snd_pcm_prepare(snd_pcm_t *pcm);
 int snd_pcm_reset(snd_pcm_t *pcm);
@@ -434,6 +436,7 @@ size_t snd_pcm_info_sizeof(void);
 #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);
+void snd_pcm_info_clear(snd_pcm_info_t *obj);
 void snd_pcm_info_copy(snd_pcm_info_t *dst, const snd_pcm_info_t *src);
 unsigned int snd_pcm_info_get_device(const snd_pcm_info_t *obj);
 unsigned int snd_pcm_info_get_subdevice(const snd_pcm_info_t *obj);
@@ -512,6 +515,7 @@ size_t snd_pcm_hw_params_sizeof(void);
 #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_clear(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);
 
 #ifndef ALSA_LIBRARY_BUILD
@@ -777,8 +781,6 @@ int snd_pcm_hw_params_get_min_align(const snd_pcm_hw_params_t *params, snd_pcm_u
  * \{
  */
 
-int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
-
 size_t snd_pcm_sw_params_sizeof(void);
 /** \hideinitializer
  * \brief allocate an invalid #snd_pcm_sw_params_t using standard alloca
@@ -787,6 +789,7 @@ size_t snd_pcm_sw_params_sizeof(void);
 #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);
+void snd_pcm_sw_params_clear(snd_pcm_sw_params_t *obj);
 void snd_pcm_sw_params_copy(snd_pcm_sw_params_t *dst, const snd_pcm_sw_params_t *src);
 int snd_pcm_sw_params_set_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);
@@ -901,6 +904,7 @@ size_t snd_pcm_status_sizeof(void);
 #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);
+void snd_pcm_status_clear(snd_pcm_status_t *obj);
 void snd_pcm_status_copy(snd_pcm_status_t *dst, const snd_pcm_status_t *src);
 snd_pcm_state_t snd_pcm_status_get_state(const snd_pcm_status_t *obj);
 void snd_pcm_status_get_trigger_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr);
index 7fdf4c7598220a39652eb7e1e1a437fba721fcd3..aec514ec8fbd48f9645cc466f9a3ed6573531638 100644 (file)
@@ -30,6 +30,7 @@ int snd_interval_setinteger(snd_interval_t *i);
 int snd_interval_empty(const snd_interval_t *i);
 int snd_interval_single(const snd_interval_t *i);
 int snd_interval_value(const snd_interval_t *i);
+void snd_interval_set_value(snd_interval_t *i, unsigned int val);
 int snd_interval_min(const snd_interval_t *i);
 int snd_interval_max(const snd_interval_t *i);
 int snd_interval_test(const snd_interval_t *i, unsigned int val);
index f1263b7b355543ea4723ee9a55a04101e1dfb0da..7cfb6e27c5f00ec1ac7e78269b06dbcb138d8124 100644 (file)
@@ -60,6 +60,14 @@ INTERVAL_INLINE int snd_interval_value(const snd_interval_t *i)
        return i->min;
 }
 
+INTERVAL_INLINE void snd_interval_set_value(snd_interval_t *i, unsigned int val)
+{
+       i->openmax = i->openmin = 0;
+       i->min = i->max = val;
+       i->integer = 0;
+       i->empty = 0;
+}
+
 INTERVAL_INLINE int snd_interval_min(const snd_interval_t *i)
 {
        assert(!snd_interval_empty(i));
index 137d2b16202fcbd369342d6e81bda4d6cc3d3f8b..baea5164821834f0fead28b8fb3fad82b6a36f69 100644 (file)
@@ -734,6 +734,41 @@ int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
        return pcm->ops->info(pcm->op_arg, info);
 }
 
+/** \brief Retreive current PCM hardware configuration chosen with #snd_pcm_hw_params
+ * \param pcm PCM handle
+ * \param params Configuration space definition container
+ * \return 0 on success otherwise a negative error code
+ */
+int snd_pcm_hw_params_current(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
+{
+       unsigned int frame_bits;
+
+       assert(pcm && params);
+       if (!pcm->setup)
+               return -EBADFD;
+       snd_pcm_hw_params_clear(params);
+       snd_mask_copy(&params->masks[SND_PCM_HW_PARAM_ACCESS], (snd_mask_t *)&pcm->access);
+       snd_mask_copy(&params->masks[SND_PCM_HW_PARAM_FORMAT], (snd_mask_t *)&pcm->format);
+       snd_mask_copy(&params->masks[SND_PCM_HW_PARAM_SUBFORMAT], (snd_mask_t *)&pcm->subformat);
+       frame_bits = snd_pcm_format_physical_width(pcm->format) * pcm->channels;
+       snd_interval_set_value(&params->intervals[SND_PCM_HW_PARAM_FRAME_BITS], frame_bits);
+       snd_interval_set_value(&params->intervals[SND_PCM_HW_PARAM_CHANNELS], pcm->channels);
+       snd_interval_set_value(&params->intervals[SND_PCM_HW_PARAM_RATE], pcm->rate);
+       snd_interval_set_value(&params->intervals[SND_PCM_HW_PARAM_PERIOD_TIME], pcm->period_time);
+       snd_interval_set_value(&params->intervals[SND_PCM_HW_PARAM_PERIOD_SIZE], pcm->period_size);
+       snd_interval_copy(&params->intervals[SND_PCM_HW_PARAM_PERIODS], &pcm->periods);
+       snd_interval_copy(&params->intervals[SND_PCM_HW_PARAM_BUFFER_TIME], &pcm->buffer_time);
+       snd_interval_set_value(&params->intervals[SND_PCM_HW_PARAM_BUFFER_SIZE], pcm->buffer_size);
+       snd_interval_set_value(&params->intervals[SND_PCM_HW_PARAM_BUFFER_BYTES], (pcm->buffer_size * frame_bits) / 8);
+       snd_interval_set_value(&params->intervals[SND_PCM_HW_PARAM_TICK_TIME], pcm->tick_time);
+       params->info = pcm->info;
+       params->msbits = pcm->msbits;
+       params->rate_num = pcm->rate_num;
+       params->rate_den = pcm->rate_den;
+       params->fifo_size = pcm->fifo_size;
+       return 0;
+} 
+
 /** \brief Install one PCM hardware configuration chosen from a configuration space and #snd_pcm_prepare it
  * \param pcm PCM handle
  * \param params Configuration space definition container
index b8a91ae74583585b5c174f8e1e839bcb11e80bac..14f9589a2bd638ba95b0dfba6101a7f5c2512827 100644 (file)
@@ -170,6 +170,7 @@ struct _snd_pcm {
        unsigned int rate;              /* rate in Hz */
        snd_pcm_uframes_t period_size;
        unsigned int period_time;       /* period duration */
+       snd_interval_t periods;
        unsigned int tick_time;
        snd_pcm_tstamp_t tstamp_mode;   /* timestamp mode */
        unsigned int period_step;
@@ -188,6 +189,7 @@ struct _snd_pcm {
        unsigned int rate_den;          /* rate denominator */
        snd_pcm_uframes_t fifo_size;    /* chip FIFO size in frames */
        snd_pcm_uframes_t buffer_size;
+       snd_interval_t buffer_time;
        unsigned int sample_bits;
        unsigned int frame_bits;
        snd_pcm_rbptr_t appl;