Skip to content

Commit

Permalink
axfer: return ETIMEDOUT when no event occurs after waiter expiration
Browse files Browse the repository at this point in the history
Although the waiter abstraction handles timeout as success, it should
report for callers to know timeout.

This commit takes the waiter to return -ETIMEDOUT when timeout expires.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
  • Loading branch information
takaswie authored and perexg committed Oct 30, 2019
1 parent 1c17128 commit e5e6a78
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions axfer/xfer-libasound.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,29 +343,36 @@ static int prepare_waiter(struct libasound_state *state)
int xfer_libasound_wait_event(struct libasound_state *state, int timeout_msec,
unsigned short *revents)
{
int err;
int count;

if (state->waiter_type != WAITER_TYPE_DEFAULT) {
struct waiter_context *waiter = state->waiter;
int err;

err = waiter_context_wait_event(waiter, timeout_msec);
if (err < 0)
return err;
count = waiter_context_wait_event(waiter, timeout_msec);
if (count < 0)
return count;
if (count == 0 && timeout_msec > 0)
return -ETIMEDOUT;

err = snd_pcm_poll_descriptors_revents(state->handle,
waiter->pfds, waiter->pfd_count, revents);
} else {
err = snd_pcm_wait(state->handle, timeout_msec);
if (err < 0)
return err;
} else {
count = snd_pcm_wait(state->handle, timeout_msec);
if (count < 0)
return count;
if (count == 0 && timeout_msec > 0)
return -ETIMEDOUT;

if (snd_pcm_stream(state->handle) == SND_PCM_STREAM_PLAYBACK)
*revents = POLLOUT;
else
*revents = POLLIN;
}

return err;
return 0;
}

static int configure_hw_params(struct libasound_state *state,
Expand Down

0 comments on commit e5e6a78

Please sign in to comment.