Fix buffer size handling of direct plugins

Introduce "max_periods" option to specify the max number of periods
per buffer to each plugin.

- When max_periods = -1, the fixed buffer size as the slave size is
  used (old behavior).
- When max_periods = 0 (or 1), the number of periods is variable
  between 2 and the slave buffer size.
- When max_periods greater than 2 is given, it specifies the max
  periods of that pcm explicitly.

When no option is given in the PCM defintion, the value
"defaults.pcm.dmix_max_periods" is referred as default.
The default value is 0, as defined in alsa.conf.
You can override this in ~/.asoundrc or /etc/asound.conf as you like.
This commit is contained in:
Takashi Iwai 2006-04-06 18:49:11 +02:00
parent 33d69ef33b
commit 1128efc7d4
7 changed files with 41 additions and 56 deletions

View file

@ -117,7 +117,7 @@ struct snd_pcm_direct {
snd_timer_t *timer; /* timer used as poll_fd */
int interleaved; /* we have interleaved buffer */
int slowptr; /* use slow but more precise ptr updates */
int variable_buffer_size; /* allow the variable buffer size */
int max_periods; /* max periods (-1 = fixed periods, 0 = max buffer size) */
unsigned int channels; /* client's channels */
unsigned int *bindings;
union {
@ -187,7 +187,6 @@ int snd_pcm_direct_timer_stop(snd_pcm_direct_t *dmix);
void snd_pcm_direct_clear_timer_queue(snd_pcm_direct_t *dmix);
int snd_pcm_direct_set_timer_params(snd_pcm_direct_t *dmix);
int snd_pcm_direct_open_secondary_client(snd_pcm_t **spcmp, snd_pcm_direct_t *dmix, const char *client_name);
int snd_pcm_direct_get_slave_ipc_offset(snd_config_t *root, snd_config_t *sconf, int direction);
int snd_timer_async(snd_timer_t *timer, int sig, pid_t pid);
struct timespec snd_pcm_hw_fast_tstamp(snd_pcm_t *pcm);
@ -197,9 +196,9 @@ struct snd_pcm_direct_open_conf {
mode_t ipc_perm;
int ipc_gid;
int slowptr;
int variable_buffer_size;
int max_periods;
snd_config_t *slave;
snd_config_t *bindings;
};
int snd_pcm_direct_parse_open_conf(snd_config_t *conf, struct snd_pcm_direct_open_conf *rec);
int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf, int stream, struct snd_pcm_direct_open_conf *rec);