]> git.alsa-project.org Git - alsa-utils.git/commitdiff
alsactl: handle disconnection of sound card
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 14 Oct 2018 14:36:32 +0000 (23:36 +0900)
committerJaroslav Kysela <perex@perex.cz>
Sun, 14 Oct 2018 14:57:15 +0000 (16:57 +0200)
Once sound card becomes disconnection state, corresponding control node
becomes to emit error event for listeners. When catching this type of
event, event dispatcher should stop observation of the node. However,
at present, a mode of monitor can't handle this correctly. As a result,
poll(2) is executed quite frequently in loop with no wait. This results
100% consumption of CPU time.

This commit takes the dispatcher to remove the node from observation
list when detecting the disconnection state.

Reported-by: Thomas Gläßle <thomas@coldfix.de>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
alsactl/monitor.c

index 09ef63cc57c4e8d2b3b4c5c8c7c58ce72c1dff23..559fb4cad65b0af2961b180e0772c3e42e339bd2 100644 (file)
@@ -285,6 +285,10 @@ static int run_dispatcher(int epfd, struct list_head *srcs)
                        struct src_entry *entry = (struct src_entry *)ev->data.ptr;
                        if (ev->events & EPOLLIN)
                                print_event(entry->handle, entry->name);
+                       if (ev->events & EPOLLERR) {
+                               operate_dispatcher(epfd, EPOLL_CTL_DEL, NULL, entry);
+                               remove_source_entry(entry);
+                       }
                }
        }