mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
alsa: don't read more than available samples
Keep the original available samples and use them to avoid reading a chunk when there is not enough data.
This commit is contained in:
parent
56c03c11f8
commit
e28b613404
1 changed files with 4 additions and 2 deletions
|
|
@ -2115,7 +2115,7 @@ int spa_alsa_read(struct state *state)
|
||||||
|
|
||||||
if (state->following && state->alsa_started) {
|
if (state->following && state->alsa_started) {
|
||||||
uint64_t current_time;
|
uint64_t current_time;
|
||||||
snd_pcm_uframes_t delay, target;
|
snd_pcm_uframes_t avail, delay, target;
|
||||||
uint32_t threshold = state->threshold;
|
uint32_t threshold = state->threshold;
|
||||||
|
|
||||||
current_time = state->position->clock.nsec;
|
current_time = state->position->clock.nsec;
|
||||||
|
|
@ -2123,6 +2123,8 @@ int spa_alsa_read(struct state *state)
|
||||||
if ((res = get_status(state, current_time, &delay, &target)) < 0)
|
if ((res = get_status(state, current_time, &delay, &target)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
avail = delay;
|
||||||
|
|
||||||
if (state->alsa_sync) {
|
if (state->alsa_sync) {
|
||||||
spa_log_warn(state->log, "%s: follower delay:%lu target:%lu thr:%u, resync",
|
spa_log_warn(state->log, "%s: follower delay:%lu target:%lu thr:%u, resync",
|
||||||
state->props.device, delay, target, threshold);
|
state->props.device, delay, target, threshold);
|
||||||
|
|
@ -2137,7 +2139,7 @@ int spa_alsa_read(struct state *state)
|
||||||
if ((res = update_time(state, current_time, delay, target, true)) < 0)
|
if ((res = update_time(state, current_time, delay, target, true)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
if (delay < state->read_size)
|
if (avail < state->read_size)
|
||||||
max_read = 0;
|
max_read = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue