alsa: report underrun better

This commit is contained in:
Wim Taymans 2017-10-24 18:04:03 +02:00
parent 5b4a4922db
commit 4f33a37ac6
2 changed files with 12 additions and 1 deletions

View file

@ -333,6 +333,7 @@ pull_frames(struct state *state,
bool do_pull)
{
snd_pcm_uframes_t total_frames = 0, to_write = frames;
bool underrun = false;
try_pull(state, frames, do_pull);
@ -390,8 +391,16 @@ pull_frames(struct state *state,
}
if (total_frames == 0 && do_pull) {
total_frames = SPA_MIN(frames, state->threshold);
spa_log_trace(state->log, "underrun, want %zd frames", total_frames);
snd_pcm_areas_silence(my_areas, offset, state->channels, total_frames, state->format);
state->underrun += total_frames;
underrun = true;
}
if (state->underrun > 0) {
if (state->underrun >= state->rate || !underrun) {
spa_log_warn(state->log, "underrun, for %zd frames", state->underrun);
state->underrun = 0;
}
}
return total_frames;
}

View file

@ -159,6 +159,8 @@ struct state {
int64_t sample_count;
int64_t last_ticks;
int64_t last_monotonic;
uint64_t underrun;
};
int