Added snd_pcm_hw_params_set_rate_resample function

- snd_pcm_hw_params_set_rate_resample()
- snd_pcm_hw_params_get_rate_resample()
This commit is contained in:
Jaroslav Kysela 2005-04-12 12:09:55 +00:00
parent 72ad0e9ae7
commit f65d9f3108
9 changed files with 72 additions and 4 deletions

View file

@ -174,6 +174,9 @@ ALSA_1.0.8 {
ALSA_1.0.9 {
global:
snd_pcm_hw_params_set_rate_resample;
snd_pcm_hw_params_get_rate_resample;
snd_pcm_ioplug_create;
snd_pcm_ioplug_delete;
snd_pcm_ioplug_reinit_status;

View file

@ -744,6 +744,7 @@ int snd_pcm_hw_params_current(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
if (!pcm->setup)
return -EBADFD;
memset(params, 0, snd_pcm_hw_params_sizeof());
params->flags = pcm->hw_flags;
snd_mask_copy(&params->masks[SND_PCM_HW_PARAM_ACCESS - SND_PCM_HW_PARAM_FIRST_MASK], (snd_mask_t *)&pcm->access);
snd_mask_copy(&params->masks[SND_PCM_HW_PARAM_FORMAT - SND_PCM_HW_PARAM_FIRST_MASK], (snd_mask_t *)&pcm->format);
snd_mask_copy(&params->masks[SND_PCM_HW_PARAM_SUBFORMAT - SND_PCM_HW_PARAM_FIRST_MASK], (snd_mask_t *)&pcm->subformat);
@ -3909,6 +3910,35 @@ int snd_pcm_hw_params_set_rate_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_RATE, val, dir);
}
/**
* \brief Restrict a configuration space to contain only real hardware rates
* \param pcm PCM handle
* \param params Configuration space
* \param val 0 = disable, 1 = enable (default) rate resampling
* \return 0 otherwise a negative error code
*/
int snd_pcm_hw_params_set_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val)
{
assert(pcm && params);
if (!val)
params->flags |= SND_PCM_HW_PARAMS_NORESAMPLE;
else
params->flags &= ~SND_PCM_HW_PARAMS_NORESAMPLE;
return snd_pcm_hw_refine(pcm, params);
}
/**
* \brief Extract resample state from a configuration space
* \param pcm PCM handle
* \param *val 0 = disable, 1 = enable rate resampling
* \return 0 otherwise a negative error code
*/
int snd_pcm_hw_params_get_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val)
{
assert(pcm && params && val);
*val = params->flags & SND_PCM_HW_PARAMS_NORESAMPLE ? 0 : 1;
return 0;
}
/**
* \brief Extract period time from a configuration space

View file

@ -58,7 +58,6 @@ typedef enum sndrv_pcm_hw_param snd_pcm_hw_param_t;
#define SND_PCM_HW_PARAM_BUFFER_BYTES SNDRV_PCM_HW_PARAM_BUFFER_BYTES
#define SND_PCM_HW_PARAM_TICK_TIME SNDRV_PCM_HW_PARAM_TICK_TIME
#define SND_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_LAST_INTERVAL
#define SND_PCM_HW_PARAMS_RUNTIME SNDRV_PCM_HW_PARAMS_RUNTIME
#define SND_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_LAST_MASK
#define SND_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_FIRST_MASK
#define SND_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_LAST_INTERVAL
@ -93,6 +92,12 @@ typedef enum sndrv_pcm_hw_param snd_pcm_hw_param_t;
/** device can do a kind of synchronized start */
#define SND_PCM_INFO_SYNC_START SNDRV_PCM_INFO_SYNC_START
#ifndef SNDRV_PCM_HW_PARAMS_NORESAMPLE
#define SND_PCM_HW_PARAMS_NORESAMPLE (1<<0)
#else
#define SND_PCM_HW_PARAMS_NORESAMPLE SNDRV_PCM_HW_PARAMS_NORESAMPLE
#endif
typedef struct _snd_pcm_rbptr {
snd_pcm_t *master;
volatile snd_pcm_uframes_t *ptr;
@ -199,6 +204,7 @@ struct _snd_pcm {
unsigned int msbits; /* used most significant bits */
unsigned int rate_num; /* rate numerator */
unsigned int rate_den; /* rate denominator */
unsigned int hw_flags; /* actual hardware flags */
snd_pcm_uframes_t fifo_size; /* chip FIFO size in frames */
snd_pcm_uframes_t buffer_size;
snd_interval_t buffer_time;

View file

@ -2281,6 +2281,7 @@ int _snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
}
pcm->min_align = min_align;
pcm->hw_flags = params->flags;
pcm->info = params->info;
pcm->msbits = params->msbits;
pcm->rate_num = params->rate_num;

View file

@ -728,6 +728,8 @@ static int snd_pcm_plug_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p
err = _snd_pcm_hw_params_refine(sparams, links, params);
if (err < 0)
return err;
if (params->flags & SND_PCM_HW_PARAMS_NORESAMPLE)
snd_interval_copy((snd_interval_t *)snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_RATE), snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_RATE));
return 0;
}
@ -830,6 +832,8 @@ static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
err = _snd_pcm_hw_params_refine(params, links, sparams);
if (err < 0)
return err;
if (params->flags & SND_PCM_HW_PARAMS_NORESAMPLE)
snd_interval_copy((snd_interval_t *)snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_RATE), snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_RATE));
/* FIXME */
params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
return 0;