mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-05 13:30:00 -05:00
Added snd_pcm_hw_params_current() function and clear() functions for structures
This commit is contained in:
parent
453dd9f698
commit
dac0626b9f
6 changed files with 56 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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(¶ms->masks[SND_PCM_HW_PARAM_ACCESS], (snd_mask_t *)&pcm->access);
|
||||
snd_mask_copy(¶ms->masks[SND_PCM_HW_PARAM_FORMAT], (snd_mask_t *)&pcm->format);
|
||||
snd_mask_copy(¶ms->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(¶ms->intervals[SND_PCM_HW_PARAM_FRAME_BITS], frame_bits);
|
||||
snd_interval_set_value(¶ms->intervals[SND_PCM_HW_PARAM_CHANNELS], pcm->channels);
|
||||
snd_interval_set_value(¶ms->intervals[SND_PCM_HW_PARAM_RATE], pcm->rate);
|
||||
snd_interval_set_value(¶ms->intervals[SND_PCM_HW_PARAM_PERIOD_TIME], pcm->period_time);
|
||||
snd_interval_set_value(¶ms->intervals[SND_PCM_HW_PARAM_PERIOD_SIZE], pcm->period_size);
|
||||
snd_interval_copy(¶ms->intervals[SND_PCM_HW_PARAM_PERIODS], &pcm->periods);
|
||||
snd_interval_copy(¶ms->intervals[SND_PCM_HW_PARAM_BUFFER_TIME], &pcm->buffer_time);
|
||||
snd_interval_set_value(¶ms->intervals[SND_PCM_HW_PARAM_BUFFER_SIZE], pcm->buffer_size);
|
||||
snd_interval_set_value(¶ms->intervals[SND_PCM_HW_PARAM_BUFFER_BYTES], (pcm->buffer_size * frame_bits) / 8);
|
||||
snd_interval_set_value(¶ms->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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue