Skip to content

Commit

Permalink
aplay/alsa: warn if buffer is too short
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinPulec committed Sep 5, 2024
1 parent 52b9ed2 commit e3556c6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/audio/playback/alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,21 @@ static bool audio_play_alsa_reconfigure(void *state, struct audio_desc desc)

unsigned int buf_len;
int buf_dir = -1;
if (get_commandline_param("low-latency-audio") && get_commandline_param("alsa-playback-buffer") == NULL) {
CHECK_OK(snd_pcm_hw_params_set_buffer_time_first(s->handle, params,
&buf_len, &buf_dir));
if (get_commandline_param("low-latency-audio") != NULL &&
get_commandline_param("alsa-playback-buffer") == NULL) {
// set minimal value from the configuration space
CHECK_OK(snd_pcm_hw_params_set_buffer_time_first(s->handle, params, &buf_len, &buf_dir));
log_msg(LOG_LEVEL_INFO, MOD_NAME "ALSA driver buffer len set to: %lf ms\n", buf_len / 1000.0);
enum {
REC_MIN_BUF = 5000,
};
if (buf_len <= REC_MIN_BUF) {
MSG(WARNING,
"ALSA driver buffer len less than %d usec seem to "
"be too loow, consider using alsa-playback-buffer "
"instead of low-latency-audio.",
REC_MIN_BUF);
}
} else {
buf_len = (s->playback_mode == SYNC ? BUF_LEN_DEFAULT_SYNC : BUF_LEN_DEFAULT) * 1000;

Expand Down

0 comments on commit e3556c6

Please sign in to comment.