mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-17 08:56:49 -05:00
alsa: reset queued and free buffers on start
When we are out of buffers, drop the available samples.
This commit is contained in:
parent
f0244f659c
commit
bf1c927087
1 changed files with 22 additions and 1 deletions
|
|
@ -769,7 +769,8 @@ push_frames(struct state *state,
|
||||||
snd_pcm_uframes_t total_frames = 0;
|
snd_pcm_uframes_t total_frames = 0;
|
||||||
|
|
||||||
if (spa_list_is_empty(&state->free)) {
|
if (spa_list_is_empty(&state->free)) {
|
||||||
spa_log_trace(state->log, "no more buffers");
|
spa_log_warn(state->log, "no more buffers");
|
||||||
|
total_frames = state->threshold;
|
||||||
} else {
|
} else {
|
||||||
uint8_t *src;
|
uint8_t *src;
|
||||||
size_t n_bytes;
|
size_t n_bytes;
|
||||||
|
|
@ -940,6 +941,24 @@ next:
|
||||||
set_timeout(state, state->next_time);
|
set_timeout(state, state->next_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void reset_buffers(struct state *this)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
spa_list_init(&this->free);
|
||||||
|
spa_list_init(&this->ready);
|
||||||
|
|
||||||
|
for (i = 0; i < this->n_buffers; i++) {
|
||||||
|
struct buffer *b = &this->buffers[i];
|
||||||
|
if (this->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||||
|
SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUT);
|
||||||
|
} else {
|
||||||
|
spa_list_append(&this->free, &b->link);
|
||||||
|
SPA_FLAG_UNSET(b->flags, BUFFER_FLAG_OUT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int spa_alsa_start(struct state *state)
|
int spa_alsa_start(struct state *state)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
@ -984,6 +1003,8 @@ int spa_alsa_start(struct state *state)
|
||||||
spa_loop_add_source(state->data_loop, &state->source);
|
spa_loop_add_source(state->data_loop, &state->source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset_buffers(state);
|
||||||
|
|
||||||
if (state->stream == SND_PCM_STREAM_PLAYBACK) {
|
if (state->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||||
state->alsa_started = false;
|
state->alsa_started = false;
|
||||||
spa_alsa_write(state, state->threshold * 2, true);
|
spa_alsa_write(state, state->threshold * 2, true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue