All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: tiwai@suse.de, thomas@coldfix.de
Cc: alsa-devel@alsa-project.org
Subject: [PATCH][RFC][alsa-utils 8/9] alsactl: handle disconnection of sound card
Date: Fri,  5 Oct 2018 23:47:28 +0900	[thread overview]
Message-ID: <20181005144729.21388-9-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20181005144729.21388-1-o-takashi@sakamocchi.jp>

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>
---
 alsactl/monitor.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/alsactl/monitor.c b/alsactl/monitor.c
index 807963c..4eb1ad1 100644
--- a/alsactl/monitor.c
+++ b/alsactl/monitor.c
@@ -312,6 +312,10 @@ static int run_dispatcher(int epfd, struct src_entry *srcs)
 			struct src_entry *src = (struct src_entry *)ev->data.ptr;
 			if (ev->events & EPOLLIN)
 				print_event(src->handle, src->name);
+			if (ev->events & EPOLLERR) {
+				operate_dispatcher(epfd, EPOLL_CTL_DEL, NULL, src);
+				remove_source_entry(src);
+			}
 		}
 	}
 
-- 
2.19.0

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  parent reply	other threads:[~2018-10-05 14:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-05 14:47 [PATCH][RFC][alsa-utils 0/9] alsactl: monitor mode friendly for Takashi Sakamoto
2018-10-05 14:47 ` [PATCH][RFC][alsa-utils 1/9] alsactl: install signal handler Takashi Sakamoto
2018-10-05 14:47 ` [PATCH][RFC][alsa-utils 2/9] alsactl: split event loop code to a function Takashi Sakamoto
2018-10-05 14:47 ` [PATCH][RFC][alsa-utils 3/9] alsactl: add an iterator of registered instances of sound card Takashi Sakamoto
2018-10-05 14:47 ` [PATCH][RFC][alsa-utils 4/9] alsactl: use epoll(7) instead of poll(2) Takashi Sakamoto
2018-10-05 14:47 ` [PATCH][RFC][alsa-utils 5/9] alsactl: use link list to maintain source of events Takashi Sakamoto
2018-10-05 17:14   ` Jaroslav Kysela
2018-10-07  3:04     ` Takashi Sakamoto
2018-10-08 15:06       ` Takashi Iwai
2018-10-08 15:14       ` Jaroslav Kysela
2018-10-09  3:15         ` Takashi Sakamoto
2018-10-05 14:47 ` [PATCH][RFC][alsa-utils 6/9] alsactl: use a list of source for event dispatcher instead of an array of source Takashi Sakamoto
2018-10-05 14:47 ` [PATCH][RFC][alsa-utils 7/9] alsactl: obsolete array for maintenance of handlers Takashi Sakamoto
2018-10-05 14:47 ` Takashi Sakamoto [this message]
2018-10-05 14:47 ` [PATCH][RFC][alsa-utils 9/9] alsactl: handle detection of new sound card Takashi Sakamoto
2018-10-05 14:51 ` [PATCH][RFC][alsa-utils 0/9] alsactl: monitor mode friendly for Takashi Sakamoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181005144729.21388-9-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=thomas@coldfix.de \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.