pipewire: fix timerfd deadlock issue
[AGL/meta-agl.git] / meta-pipewire / recipes-multimedia / pipewire / pipewire / 0001-null-sink-make-the-timerfd-non-blocking.patch
1 From c633004bf310998580ff8944c59d94689d6fca87 Mon Sep 17 00:00:00 2001
2 From: George Kiagiadakis <george.kiagiadakis@collabora.com>
3 Date: Thu, 1 Jul 2021 11:37:01 +0300
4 Subject: [PATCH] null-sink: make the timerfd non-blocking
5
6 Fixes #1377
7
8 Upstream-Status: Backport [from master/0.3.32]
9 Signed-off-by: George Kiagiadakis <george.kiagiadakis@collabora.com>
10 ---
11  spa/plugins/support/null-audio-sink.c | 8 ++++++--
12  1 file changed, 6 insertions(+), 2 deletions(-)
13
14 diff --git a/spa/plugins/support/null-audio-sink.c b/spa/plugins/support/null-audio-sink.c
15 index e9588f1e2..12e671db8 100644
16 --- a/spa/plugins/support/null-audio-sink.c
17 +++ b/spa/plugins/support/null-audio-sink.c
18 @@ -221,8 +221,11 @@ static void on_timeout(struct spa_source *source)
19         spa_log_trace(this->log, "timeout");
20
21         if (spa_system_timerfd_read(this->data_system,
22 -                               this->timer_source.fd, &expirations) < 0)
23 +                               this->timer_source.fd, &expirations) < 0) {
24 +               if (errno == EAGAIN)
25 +                       return;
26                 perror("read timerfd");
27 +       }
28
29         nsec = this->next_time;
30
31 @@ -818,7 +821,8 @@ impl_init(const struct spa_handle_factory *factory,
32
33         this->timer_source.func = on_timeout;
34         this->timer_source.data = this;
35 -       this->timer_source.fd = spa_system_timerfd_create(this->data_system, CLOCK_MONOTONIC, SPA_FD_CLOEXEC);
36 +       this->timer_source.fd = spa_system_timerfd_create(this->data_system, CLOCK_MONOTONIC,
37 +                                                         SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
38         this->timer_source.mask = SPA_IO_IN;
39         this->timer_source.rmask = 0;
40         this->timerspec.it_value.tv_sec = 0;
41 --
42 2.30.2
43