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

@ -662,7 +662,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
pcm->private_data = dshare;
dshare->state = SND_PCM_STATE_OPEN;
dshare->slowptr = opts->slowptr;
dshare->variable_buffer_size = opts->variable_buffer_size;
dshare->max_periods = opts->max_periods;
dshare->sync_ptr = snd_pcm_dshare_sync_ptr;
if (first_instance) {
@ -835,10 +835,9 @@ int _snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
struct slave_params params;
struct snd_pcm_direct_open_conf dopen;
int bsize, psize;
int ipc_offset;
int err;
err = snd_pcm_direct_parse_open_conf(conf, &dopen);
err = snd_pcm_direct_parse_open_conf(root, conf, stream, &dopen);
if (err < 0)
return err;
@ -869,13 +868,6 @@ int _snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
params.period_size = psize;
params.buffer_size = bsize;
ipc_offset = snd_pcm_direct_get_slave_ipc_offset(root, sconf, stream);
if (ipc_offset < 0) {
snd_config_delete(sconf);
return ipc_offset;
}
dopen.ipc_key += ipc_offset;
err = snd_pcm_dshare_open(pcmp, name, &dopen, &params,
root, sconf, stream, mode);
if (err < 0)