mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
alsa: use position duration as period size
Use half of the configured quantum as the period size in batch mode. This gives lower latency for USB devices depending on the quantum.
This commit is contained in:
parent
15ce86aff1
commit
8630b8846c
2 changed files with 6 additions and 1 deletions
|
|
@ -1327,17 +1327,21 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_
|
||||||
state->card->rate = rrate;
|
state->card->rate = rrate;
|
||||||
|
|
||||||
dir = 0;
|
dir = 0;
|
||||||
period_size = state->default_period_size ? state->default_period_size : 1024;
|
period_size = state->default_period_size;
|
||||||
is_batch = snd_pcm_hw_params_is_batch(params) &&
|
is_batch = snd_pcm_hw_params_is_batch(params) &&
|
||||||
!state->disable_batch;
|
!state->disable_batch;
|
||||||
|
|
||||||
if (is_batch) {
|
if (is_batch) {
|
||||||
|
if (period_size == 0)
|
||||||
|
period_size = state->position ? state->position->clock.duration : DEFAULT_PERIOD;
|
||||||
/* batch devices get their hw pointers updated every period. Make
|
/* batch devices get their hw pointers updated every period. Make
|
||||||
* the period smaller and add one period of headroom */
|
* the period smaller and add one period of headroom */
|
||||||
period_size /= 2;
|
period_size /= 2;
|
||||||
spa_log_info(state->log, "%s: batch mode, period_size:%ld",
|
spa_log_info(state->log, "%s: batch mode, period_size:%ld",
|
||||||
state->props.device, period_size);
|
state->props.device, period_size);
|
||||||
} else {
|
} else {
|
||||||
|
if (period_size == 0)
|
||||||
|
period_size = DEFAULT_PERIOD;
|
||||||
/* disable ALSA wakeups, we use a timer */
|
/* disable ALSA wakeups, we use a timer */
|
||||||
if (snd_pcm_hw_params_can_disable_period_wakeup(params))
|
if (snd_pcm_hw_params_can_disable_period_wakeup(params))
|
||||||
CHECK(snd_pcm_hw_params_set_period_wakeup(hndl, params, 0), "set_period_wakeup");
|
CHECK(snd_pcm_hw_params_set_period_wakeup(hndl, params, 0), "set_period_wakeup");
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ extern "C" {
|
||||||
#define MIN_LATENCY 16
|
#define MIN_LATENCY 16
|
||||||
#define MAX_LATENCY 8192
|
#define MAX_LATENCY 8192
|
||||||
|
|
||||||
|
#define DEFAULT_PERIOD 1024u
|
||||||
#define DEFAULT_RATE 48000u
|
#define DEFAULT_RATE 48000u
|
||||||
#define DEFAULT_CHANNELS 2u
|
#define DEFAULT_CHANNELS 2u
|
||||||
#define DEFAULT_USE_CHMAP false
|
#define DEFAULT_USE_CHMAP false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue