mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
alsa: add option to disable mmap access mode
This commit is contained in:
parent
2ff4615e53
commit
482f96a644
5 changed files with 17 additions and 8 deletions
|
|
@ -797,6 +797,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this->default_period_size = atoi(info->items[i].value);
|
||||
} else if (!strcmp(info->items[i].key, "api.alsa.headroom")) {
|
||||
this->default_headroom = atoi(info->items[i].value);
|
||||
} else if (!strcmp(info->items[i].key, "api.alsa.disable-mmap")) {
|
||||
this->disable_mmap = atoi(info->items[i].value);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -818,6 +818,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this->default_period_size = atoi(info->items[i].value);
|
||||
} else if (!strcmp(info->items[i].key, "api.alsa.headroom")) {
|
||||
this->default_headroom = atoi(info->items[i].value);
|
||||
} else if (!strcmp(info->items[i].key, "api.alsa.disable-mmap")) {
|
||||
this->disable_mmap = atoi(info->items[i].value);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -516,11 +516,17 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_
|
|||
snd_pcm_access_mask_alloca(&amask);
|
||||
snd_pcm_hw_params_get_access_mask(params, amask);
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_access(hndl, params,
|
||||
planar ? SND_PCM_ACCESS_MMAP_NONINTERLEAVED
|
||||
: SND_PCM_ACCESS_MMAP_INTERLEAVED)) < 0) {
|
||||
spa_log_debug(state->log, NAME" %p: MMAP not possible: %s", state,
|
||||
snd_strerror(err));
|
||||
state->use_mmap = !state->disable_mmap;
|
||||
if (state->use_mmap) {
|
||||
if ((err = snd_pcm_hw_params_set_access(hndl, params,
|
||||
planar ? SND_PCM_ACCESS_MMAP_NONINTERLEAVED
|
||||
: SND_PCM_ACCESS_MMAP_INTERLEAVED)) < 0) {
|
||||
spa_log_debug(state->log, NAME" %p: MMAP not possible: %s", state,
|
||||
snd_strerror(err));
|
||||
state->use_mmap = false;
|
||||
}
|
||||
}
|
||||
if (!state->use_mmap) {
|
||||
if ((err = snd_pcm_hw_params_set_access(hndl, params,
|
||||
planar ? SND_PCM_ACCESS_RW_NONINTERLEAVED
|
||||
: SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
|
||||
|
|
@ -528,9 +534,6 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_
|
|||
snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
state->use_mmap = false;
|
||||
} else {
|
||||
state->use_mmap = true;
|
||||
}
|
||||
|
||||
/* disable ALSA wakeups, we use a timer */
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ struct state {
|
|||
unsigned int default_channels;
|
||||
unsigned int default_rate;
|
||||
struct channel_map default_pos;
|
||||
unsigned int disable_mmap;
|
||||
|
||||
snd_pcm_uframes_t buffer_frames;
|
||||
snd_pcm_uframes_t period_frames;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ rules = [
|
|||
#audio.position = "FL,FR"
|
||||
#api.alsa.period-size = 1024
|
||||
#api.alsa.headroom = 0
|
||||
#api.alsa.disable-mmap = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue