]> git.alsa-project.org Git - alsa-utils.git/commitdiff
axfer: handle -ETIMEDOUT before non-block I/O operation
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Tue, 29 Oct 2019 15:13:39 +0000 (00:13 +0900)
committerJaroslav Kysela <perex@perex.cz>
Wed, 30 Oct 2019 12:13:22 +0000 (13:13 +0100)
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>
axfer/xfer-libasound-irq-rw.c

index 184b85a1e542faea71b25ae361a61870898f28ae..6ed192756c78e1c677cbfde5960cda407a9207af 100644 (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;