axfer: handle -ETIMEDOUT before non-block I/O operation

When running for IRQ-based scheduling model, transmission backend is
expected to queue PCM event in different context from the main thread.
When queueing no events during time equivalent to one period of PCM
buffer, the backend has problems.

This commit outputs report it for non-blocking operation for IRQ-based
scheduling model. The timeout is equivalent to all frames in buffer,
instead of period for safe.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Takashi Sakamoto 2019-10-30 00:13:39 +09:00 committed by Jaroslav Kysela
parent 498ca99461
commit 7d7c988e05

View file

@ -21,12 +21,21 @@ struct rw_closure {
static int wait_for_avail(struct libasound_state *state)
{
unsigned int msec_per_buffer;
unsigned short revents;
unsigned short event;
int err;
// Wait during msec equivalent to all audio data frames in buffer
// instead of period, for safe.
err = snd_pcm_hw_params_get_buffer_time(state->hw_params,
&msec_per_buffer, NULL);
if (err < 0)
return err;
msec_per_buffer /= 1000;
// Wait for hardware IRQ when no available space.
err = xfer_libasound_wait_event(state, -1, &revents);
err = xfer_libasound_wait_event(state, msec_per_buffer, &revents);
if (err < 0)
return err;