]> git.alsa-project.org Git - alsa-utils.git/commitdiff
axfer: return ETIMEDOUT when no event occurs after waiter expiration
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Tue, 29 Oct 2019 15:12:11 +0000 (00:12 +0900)
committerJaroslav Kysela <perex@perex.cz>
Wed, 30 Oct 2019 12:13:22 +0000 (13:13 +0100)
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>
axfer/xfer-libasound.c

index f813024cfc6b12ab4545d0cbf4b6f2bb76702bb3..00ff0286ca5b89a33060dd28b8fe77d5a734c866 100644 (file)
@@ -343,21 +343,28 @@ 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;
@@ -365,7 +372,7 @@ int xfer_libasound_wait_event(struct libasound_state *state, int timeout_msec,
                        *revents = POLLIN;
        }
 
-       return err;
+       return 0;
 }
 
 static int configure_hw_params(struct libasound_state *state,